alonswartz / notesium

Markdown notes system with bi-directional links, Vim integration and local webapp
https://www.notesium.com
MIT License
56 stars 3 forks source link

Support "copy-on-select" in web UI #55

Open JedMeister opened 3 months ago

JedMeister commented 3 months ago

I use the Linux "copy-on-select; paste-on-middle-click" lots. And currently Notesium web UI does not support the "copy-on-select" bit - the "paste-on-middle-click" works fine.

TBH, I find it a constant frustration as I'm so used to using it (muscle memory?), that whenever I copy anything out of Notesium, I constantly find myself having to go back and use <CTRL><c> - then I have to use <CTRL><v> to paste (Windows style...).

I probably should just bite the bullet and use it in the terminal because then it would "just work" (default behaviour in any X app AFAIK), but I don't because I'm lazy... :grin:

From what I gather after doing a bit of reading, the "copy-on-select" is more correctly called "PRIMARY selection". Hopefully these links are of some value?:

FWIW apparently this functionality has been in X since the 90s. And whilst it seems to be an X11 specific feature, I run Wayland these days and it seems to work fine in almost all apps. I have hit a few that don't honor it, but the only one I can think of OTTOMH is Notesium! :stuck_out_tongue_winking_eye:

alonswartz commented 2 weeks ago

@JedMeister I can confirm copy-on-select works as expected in chrome, but does not seem to work in firefox (129.0.2).

What browser/version are you using? Could you test to see if copy-on-select works for you here: https://codemirror.net/5/mode/markdown/

JedMeister commented 2 weeks ago

Hmm. It works on the main text, but not the code window - which I'm guessing was what you wanted me to test?

I'm not sure how much you've poked around, but here are a couple of docs that may be relevant?:

https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/write

I'm not sure whether leveraging FF addon stuff is possible? (AFAIK they're just js snippets but I don't know... :rofl:). In case it is relevant, here's another doc:

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard

And here's a FF addon:

https://addons.mozilla.org/en-US/firefox/addon/copy-on-select-2/ https://github.com/farblos/copy-on-select-2

I haven't tested it, but am happy to if leveraging some of that might be of value?