How to read the selected text in js?


#1

Hi,

Iam writing a new package and am wondering how to read the selected text in js?

Thanks


#2

This page should contain the information you need, specifically the getText() function.


#3

I was wrong. The direct way is to call the getSelectedText() function on the TextEditor object. Messing with the Selection object should be appropriate for more elaborate selection-related shenanigans but is not required for just reading what text is selected.