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

Support for Google Colab #190

Closed calpa closed 1 year ago

calpa commented 3 years ago

Setup

Browser: Google Chrome Editor: VSCode

Description

Can I use GhostText with Google Colab?

indigoviolet commented 1 year ago

@fregante Is there any form of documentation indicating how one might debug/add support for a site on which GhostText doesn't work? I'm interested in getting it to work on Colab.

fregante commented 1 year ago

"Support" is made of 2 parts:

If the value an be set via DOM, like for a standard contentEditable, the second point would be easy:

https://github.com/fregante/GhostText/blob/a3ac72db5c05edbe0d4e2cef70c1a4fd5cdfd11b/source/ghost-text.js#L12-L29

In the more likely case where you have to access the website’s own script data, you'd have to go through the AdvancedTextWrapper, which communicates with the unsafe-messenger script to get and set the text:

https://github.com/fregante/GhostText/blob/a3ac72db5c05edbe0d4e2cef70c1a4fd5cdfd11b/source/unsafe-messenger.js#L33-L52

You can see the above piece of code uses a local CodeMirror property and then sends the value via events.

fregante commented 1 year ago

It looks like Google Colab uses Monaco editor, which is tracked here:

I'd definitely love to add support for it.

fregante commented 1 year ago

Support was added in v23.3.11 🎉

https://github.com/fregante/GhostText/releases/tag/23.3.11