How to get selected text from the editor in a plugin

Here is a snippet from a plugin that replaces the text in the editor:

 const { cm } = inkdrop.getActiveEditor()
 cm.replaceSelection(md)

How do I get the currently selected text in the editor?

Thanks

You can use cm.getSelection(). It returns an empty string when nothing is selected.

1 Like

Thanks. I wasn’t sure where to look up the editor api, now I know :slight_smile:

1 Like