Open khughitt opened 1 month ago
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?