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

Expose position of textarea #174

Open kevinhwang91 opened 3 years ago

kevinhwang91 commented 3 years ago

Description

Comparing with firenvim, I prefer GhostText, which is not conflicted my shortcuts in chromium and doesn't slow me down in neovim.

I have tried GhostText with raghur/vim-ghost. I wanna make the position of nvim cover the textarea so I need the position of textarea. After enabling the log, the position of the textarea isn't passed to websocket server.

recd on websocket: ('127.0.0.1', 53718) message:
{"text":"","selections":[{"start":0,"end":0}],"title":"xxxxxxxxx","url":"github.com","syntax":""}
subnut commented 3 years ago

Well, I don't think it's possible to access the absolute position of the text area relative to your monitor....


Since you use neovim, check out nvim-ghost.nvim. It's awesome as it only focuses on neovim support.

fregante commented 3 years ago

Well, I don't think it's possible to access the absolute position of the text area relative to your monitor....

It its via getBoundingClientRect + window.screenTop/Left - (window.outerHeight - window.innerHeight)

I thought about this in the past but I figured that most of the times the textarea is too small for this to make sense. The good part of using your editor is that it's a bigger window, so sizing it to the textarea would be counterproductive.