-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add automatic clipboard support #1347
base: master
Are you sure you want to change the base?
Conversation
49ae1a9
to
e6b643c
Compare
Looks nice and clean, so a good start. But if browser support is too poor then I don't think we want to merge it yet. I'm not sure how paste is supposed to work even with that chrome bug fixed. We intercept Ctrl+V, so what will be firing the paste event? |
This works in 2 ways:
It's true that support varies. However, all browsers seem to be working on it and it's a change that doesn't break anything so I don't really see a reason to hold back. |
According to MDN this is only supported on Chrome and Opera. Not Firefox, IE, Edge or Safari. I think that this can result in a lot of confused users. Where can I find information about all browsers working on this? |
ping @juanjoDiaz |
Sorry @samhed, totally missed this. You are right. It seems that:
One thing to keep in mind is that this PR was mean to be just the foundation of a possible clipboard functionality and it just uses the Clipboard Async API if available. |
a9c29d8
to
8a38fdd
Compare
The list of supported browsers there looks great. If they are able to achieve that so should we be! What's the state of this code at the moment? |
The async clipboard support (which is what's used in this PR) is now also supported in Safari: https://webkit.org/blog/10855/async-clipboard-api/ Firefox keeps having it as an open issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1619251 Just FYI. |
This PR looks like it would get noVNC much closer to an expected experience -- especially now that Chrome, Edge, and Safari support the async Clipboard API. If browser support is a blocker, I could follow up with a new PR that:
Thoughts? |
I'm opposed to merging something that isn't supported by all major browsers, Firefox is important. I don't have the time to investigate this personally right now, but https://github.com/zenorocha/clipboard.js claims support for Firefox as well, couldn't we do what they do? |
@samhed from what I understand, Firefox's limitations are mostly around async clipboard events e.g. when noVNC wants to copy data to the user's clipboard without their input. Clipboard.js depends on a "user originating" event to perform a clipboard copy. I suppose a stop-gap would be to offer a button in the UI to let the user retrieve the server's clipboard data. |
Hi guys, this feature looks really neat, I was wondering if you have any ETA on this |
@CendioOssman this is something we'd love to have for our novnc install, and I'm happy to do the dev work necessary if there's any requests you have.... any sense what you'd want to see here (besides no active merge conflicts and it actually tested and working) to consider a merge? |
What I'd like to see broad support in the browsers. I.e. this works on at least Chrome, Firefox and Safari (Edge would be nice too though). Failing that, a clean fallback handling until missing pieces are in place in all browsers. I haven't kept track of this so I'm afraid I don't know what the current state of the browsers is, or how well this code matches that. Some testing would be helpful to get a better picture. |
02c8427
to
24dbf21
Compare
All checks have passed. We're closer to have clipboard support! Thanks @juanjoDiaz |
Hi all, I've rebased and reverted the hacks that I tried for Safari. This PR has been open now for 3.5 years. Browsers have evolved a bit, but the the problems not so much 😅 Firefox continues to not support reading from clipboard. They seem to be working on it but it will be based on the annoying "Paste" button as Safari is. See https://bugzilla.mozilla.org/show_bug.cgi?id=1770358 Safari continues to work based on the "Paste" button. So, with the current implementation based on the So, not much else that I can do here. |
Thanks for moving this forward! I tested your new code, but I still can't make it work well on Safari on macOS. I do get the paste button more rarely now, but it still gets “stuck” occasionally. And even when the paste button shows, it doesn't paste things. What I did:
I cleared all browser caches in Safari and made sure I pulled the latest version from your branch. Are we certain that the Safari issue with the paste button is properly fixed? As described above, pasting appears to be possible in Safari on macOS (but still buggy). But copying from the remote to the macOS client doesn't work whatsoever for me. Have you gotten that to work on your end? I also tested Safari on iPadOS, it still doesn't seem to work at all sadly. As I wrote in an earlier post, it seems it should be possible:
I also tested in both Chrome and Firefox on Fedora. Chrome works flawlessly, it's really nice! Firefox works really well regarding copy, just like you have said. To summarize, I get the feeling this needs further polishing for Safari, both on macOS and iPadOS/iOS. If we get that working well, I believe we can merge this. We would have a good foundation ready for Firefox once their paste-feature gets released. |
This is the "onFocus" workaround. This is why suggested disabling the pasting completely in Safari.
No, it doesn't. So, all in all, Chrome works so nicely because of the "focus" workaround. So the real question is: what do we do with pasting on Safari and Firefox? Wdyt? |
Sorry, I wasn't clear. I have no problem at all with the concept of a floating “paste” button. I think it is an acceptable inconvenience when weighed against the safety issues Chrome users have to face.
What I meant is that it is possible to copy/paste stuff on an iPad using that jsfiddle, but not when using noVNC. I'm not even getting the paste button on iPad when using noVNC.
Yeah, I think we need to embrace the floating paste button. But I would appreciate it if we could avoid another button in the noVNC UI. I think the focus workaround needs further tweaks to not break things on Safari. The focus handler seems to trigger too much. My guess is that clicking the floating focus button briefly removes focus from the page (I have not verified this). Do you think it would be possible to find a solution that automatically shows the floating paste button at the cursor only when we want it to? |
hehe we are not understanding each other here 😅
That's it! Should we use the Keypresses don't sound great either... Which other event do we have that we can use? So, it seems that adding a button to noVNC UI is the only working approach here... 😕 |
Thanks for clarifying! Perhaps we can continue using "focus".. Can we detect if the browser is using the "paste" button approach? If we can detect it in a nice way, we could apply some sort of rate limiting or other kind of workaround to make it usable. What do you think? |
Hi! Sorry, I didn't see your answer. AFAIK, we can't detect if the browser is using the "paste" button other than detecting if the browser is chrome, firefox or safari. |
In case we expect the "paste" button to appear on focus, perhaps we can approximately detect it by seeing if we immediately lose focus again? The next steps should be to solve these two issues:
|
Hi, is there any recent update on the status of this PR? |
It seems this issue is resolved in a forked version kasmtech/noVNC |
Firefox 127 added more clipboard api support |
In Apache Guacamole, they seems to use a mix of the Asynchronous Clipboard API like you do and some hacky way with a textarea as a fallback And they sync clipboard on these events Their explanation: https://guacamole.apache.org/faq/#clipboard This is what Apache team ended up with after 6 or 7 PRs and 8 years of evolution. |
Sounds promising that Firefox added more support in 127! I would love to see this get merged. I'd be happy to help out with testing if the PR is updated to address the issues mentioned above:
|
@pleandre thank you for looking into what Apache achieved! If you are up for it, feel free to open a new PR. We'll help out as best we can. |
Below I have tried to summarize the discussion, as well as doing some testing on
To conclude, Chrome currently works without a hiccup and gives a great user My suggestion would be to consider Chrome as a separate entity than Safari and |
One way we could differentiate between the Chrome way of doing things and the Firefox/Safari way would be to look for the presence of the That is, of course, if we are dead set on avoiding looking at the user agent or |
Worth noting is that Firefox has this issue still open, indicating that the UX of the paste button may change in the future: https://bugzilla.mozilla.org/show_bug.cgi?id=1777197 Moreover, the issues in Safari that I highlighted above are also reproducible in Epiphany on Linux. |
Man I Fixed This Automatic Clipboard Snyc Issue XD . Check the latest pull . @juanjoDiaz @CendioOssman @samhed @GirlBossRush @AdrianSanchezLopez |
@0xAungkon what is your PR really do. I deploy it. Expecting I can do copy on my local machine and paste it into the remote machine I connect via vnc, but nothing happen. |
I’m honestly quite stunned how such a slam dunk of a feature has become a Herculean effort of epic proportions. It’s an API call, not a skunkworks moonshot. We’ve built a 10 billion dollar space telescope in less time. How long has the conversation been going on? Let’s take a look together… Six years ago, the brain trust at Mozilla decided that their average users intellect was sharp enough to choose a web browser, but a touch too dull to decide if websites should have full clipboard access. The guards hold firm for another two years, allowing minimal access while renewing their vow to never let their dopey flock be tricked into complete self destruction. Wow! It’s sort of incredible if you stop to appreciate the impact of inaction. A global pandemic has circumnavigated Earth thrice in as many years. Empires have risen and returned to dust. And now in 2024, the software industry forages for answers in the ashes of a zero interest rate economy. Is it really fair to blame all of this on a single brood of stubborn and unflappable butterflies? I’ve got a better one for you: Why would you presume fair treatment from a “non-profit” that has a documented history of using your donation money to do everything but build the gosh damn browser? There’s nothing wrong with pinning all of the bad things in the world on them because of a simple fact: Mozilla’s leadership holds your heart in contempt. The C-Suite and development teams do not prioritize what’s best for Firefox, your privacy, or anything else other than you sending them more money. Despite everything and anything, it’s important to put this half decade into perspective. Over a billion human lives have joined our planet, their formative years shaped by rapid technological advancements once exclusive to the future fantasies of only the most implausible science fiction novels. Indoor plumbing, Greek fire, MRNA vaccines, global satellite internet, LLM artificial intelligence. These are just a select few of the mundane miracles that stand in comparison to our greatest achievement: Asynchronous clipboard APIs. Sometimes all you need is hope and a little bit of faith! But sadly there are at least an odd several hundred some people trapped in an inescapable realm beyond hope’s grasp. It’s called Mozilla’s pocket and it’s a dank, damp pit. Words fail to describe just how dark and sweaty are the conditions of this sour swamp for those unfortunate, wretched, coffin warmers. These are a motley bunch with a common desire for compromise and sloppy delegation. All their hopes and dreams, embedded into Firefox like the barnacles of a beached whale on a hot Summer’s day. It’s a heart wrenching tale and they don’t want to hear it. “How dare you compare my choice of web browser to living in a decaying corpse!” they cry, “Sure, Firefox has some issues and I’d love it if Mozilla could get it together, but if I won’t use Firefox then who will?” Do you even hear yourself? Look in the mirror and say this out loud: “Mozilla decides what’s best for me. I’ll settle for whatever they decide I’m smart enough to handle.” Doesn’t feel so good, huh? Now I want you use some of that self-respect and take control of your life again. They don’t care about you. Move on, please. Really though, what’s truly gross is how the remaining Firefox holdouts act like they’re proselytizing freedom, when it’s more like begging for scraps from a corporation that’s gobbled up more than two decades —— Now you listen to me, and you listen good. Posting in this thread year after year, asking when the feature will finally get merged — I’ve got some news for you. You’re acting like a clown. And since I had the genius to leave thread notifications on for the past four years, that would make me the ringleader of this circus. Maybe Mozilla was right! Some people really need to be told what to do… If you’re a maintainer, it takes about two hours to add the feature. Less with caffeine and prescription stimulants. It’s most definitely easier than it was to read this thread. Everyone else stuffed in this cramped little car, fork the repo and do not send a pull request. Leave this place and never return. Install a different browser. Take a vitamin. Try a different salad dressing while you still have time. All that matters is that person who’s reading this finds the courage to stand up for themselves and stop letting other people decide what’s best for them. Why? Obviously, because I said so! Now get to work! 👏 👏 |
This PR adds support for automatic copy-pasting.
So when you are focused on the canvas and paste text it's pasted in the server and when you copy something in the server it's automatically copied to your local keyboard.
I've seen #1301 and #1174. But this takes a very different approach since it adds support for copy-pasting to noVNC's core. And I think that it's quite cleaner.
I've tested it in Safari, Firefox, and Chrome.
Unfortunately, the Clipboard API is only supported by Chrome and the
paste
event is broken (see https://bugs.chromium.org/p/chromium/issues/detail?id=634426).So it just does nothing in Safari and Firefox, while in Chrome the copying of data works but not the pasting.
So, for now, this is not super useful but it should become better as browser support improves.
WDYT?