fregante / GhostText

👻 Use your text editor to write in your browser. Everything you type in the editor will be instantly updated in the browser (and vice versa).
https://GhostText.fregante.com
MIT License
3.25k stars 116 forks source link

Send the selection from the browser to the editor (events) #257

Open fregante opened 1 year ago

fregante commented 1 year ago

Setup

Browser: Safari Editor: Sublime Text

Description

It seems that the browser doesn't send the updated selection back to the editor. I vaguely remember discussing this in the past but it's possible we didn't do it just to keep things simple (it's not easy to listen to the selection changes in every field type)

Edit: indeed the event isn't even supported outside Firefox on textareas https://developer.mozilla.org/en-US/docs/Web/API/HTMLTextAreaElement/selectionchange_event but it might work when attached to the document https://stackoverflow.com/a/58294874