You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a way to determine the start + end position of selected text?
The goal is to add a custom keyboard short cut which triggers a function that modifies the selected text in a particular way (wraps it in some custom formatting).
The simplest approach seems like it would be to use mde.value() to retrieve the full text, replace the desired subsection, and then call mde.value(..) again to update the content, however, I couldn't figure out a straight-forward way to get the position of the selected region.
Any suggestions?
The text was updated successfully, but these errors were encountered:
I think you can get what you want from the codemirror instance
If you really want the char index, then maybe try the .getCursor() in any case, you really have to use the codemirror instance to get these kind of things, see their manual for all available methods
Greetings!
Is there a way to determine the start + end position of selected text?
The goal is to add a custom keyboard short cut which triggers a function that modifies the selected text in a particular way (wraps it in some custom formatting).
The simplest approach seems like it would be to use
mde.value()
to retrieve the full text, replace the desired subsection, and then callmde.value(..)
again to update the content, however, I couldn't figure out a straight-forward way to get the position of the selected region.Any suggestions?
The text was updated successfully, but these errors were encountered: