Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom button to insert text at cursor #36

Open
deathau opened this issue Jul 5, 2024 · 2 comments
Open

Custom button to insert text at cursor #36

deathau opened this issue Jul 5, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@deathau
Copy link

deathau commented Jul 5, 2024

The default button actions all add text where the cursor is (or at the beginning of the line). I was wondering if there was a way to achieve that with this component.

For a custom button, I can handle the CustomButtonClicked event, but I can't find a way to get the cursor position or anything to insert text, meaning I can only really append or prepend to the entire markdown text.

Alternately, is there a way I can add a JavaScript function as an action for my custom button? If I could do that, I could just do something like

<MarkdownToolbarButton Separator Name="Custom button" 
                         JSAction="(editor) => editor.codemirror.replaceSelection('Custom')"
                         Icon="fa fa-star" 
                         Title="A Custom Button" />

(as per Ionaru/easy-markdown-editor#273 (comment))

@erossini
Copy link
Owner

I'll think about how I can add this functionality.
Enrico

@erossini erossini self-assigned this Sep 20, 2024
@erossini erossini added the enhancement New feature or request label Sep 20, 2024
@lbanobre
Copy link

Hi @erossini, Maybe implementing insertTexts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants