-
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 |
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?