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
Enable Firefox clipboard commands #2601
Conversation
What if you add the "clipboardRead" permission into the permissions array in manifest.json? Just an idea needing checks - I have no laptop at hand. |
We already have it, I'm afraid. |
With 1548561 (implied necessary by https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Interact_with_the_clipboard), |
The 'working' example from the issue in their issue tracker doesn't work on FF54 or today's nightly. I'm giving up on reading the clipboard for now. |
1548561
to
d5db97e
Compare
I've done all I want to with this now; IMO it's ready to go. For posterity, several issues combined to stop pasting from working for me earlier:
The last of these is still an issue for us, but there's no way of working around it. |
According to https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Interact_with_the_clipboard, an web-extension is able to do pasting on its background page using any content-editable elment. And I've succeed in pasting on background page, using But there're still some problems if using
Updated: |
Chrome are implementing an async clipboard API. It's been suggested on (one of the many) Firefox issue(s). We should keep an eye to see if this comes to anything, since it would make all the pain and weirdness go away. |
@mrmr1993 What is the status of this? Is it good-to-go, from your perspective? |
Yes. I'd like for there to be a better solution, but there doesn't seem to be for the time being. I'll keep an eye on the Firefox issues so that we can use something better when it comes up.
On 15 Sep 2017 10:15 am, "Stephen Blott" <notifications@github.com<mailto:notifications@github.com>> wrote:
@mrmr1993<https://github.com/mrmr1993> What is the status of this? Is it good-to-go, from your perspective?
|
Any chance of merging this soon? 😇 |
Maybe. Maybe not. My understanding is that it's not as reliable as we'd like. And something which works only sometimes is a bad UX. |
Would it be possible to at least get the yanking/copying to the clipboard part merged in the not-too-distant future? Judging by the multiple duplicates here and also my own experience that is the much more common operation, and the one that apparently works already. Especially if pasting from the clipboard might have to wait for the Firefox bug mentioned above, which would surely take a few months to actually be available in release versions. Thanks! |
@mrmr1993... @majutsushi makes a good point, no? If the yanking is reliable then we should merge that and (perhaps) disable all of the paste commands on FF. |
Sounds good. I'll rebase now. |
5a1f36c
to
ec95cc2
Compare
Rebased. (Old version here) |
Any updates on this? |
I had a dream this was merged. Now, I'm not saying I possess the gift of precognition, but I'm hoping for an early christmas miracle 🎄 ✨ |
@smblott-github I think this has reached a good state; it LGTM. Let's merge if there are no further objections. |
Can do, but I preferred not to. If there are any issues, I thought it would be better if we could just point the commands back to the old code on Chrome. |
This adds support for pasting rich text from the clipboard
In latest Firefox, we can paste into contenteditable elements that aren't This PR now gives Firefox the same full clipboard support as Chrome. |
@mrmr1993 As I mentioned before, |
I'm going to test the different behavior on pasting between Chrome and Firefox, and try using browser-specified APIs like Here're test results:
So I suggest that Vimium uses a function (this: HTMLElement, event: ClipboardEvent): void {
const d = event.clipboardData, text = d && typeof d.getData === "function" ? d.getData("text/plain") : "";
event.preventDefault();
event.stopImmediatePropagation();
if (!text) { return; }
(event.target as HTMLElement).ownerDocument.execCommand("insertText", false, text + "");
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
url = url[0..25] + "...." if 28 < url.length | ||
HUD.showForDuration("Yanked #{url}", 2000) | ||
|
||
openCopiedUrlInNewTab: (count) -> | ||
HUD.pasteFromClipboard (url) -> | ||
for i in [0...count] by 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might change this to use mkRepeatCommand
in main.coffee
(to keep the count
logic in as few places as possible).
Clipboard.copy data | ||
focusedElement?.focus() | ||
window.parent.focus() | ||
UIComponentServer.postMessage {name: "unfocusIfFocused", data} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfocusIfFocused
, above, does not take data
, does it? I'll remove data
here; let me know if that's incorrect, @mrmr1993.
Tweak of philc#2601.
These are no longer needed following philc#2601. @mrmr1993... If these are ever needed again, then we can just revert this commit (and make them background commands again).
@mrmr1993 I see that the new permission here causes Chrome to disable Vimium until the user accepts the new permission. Might you be able to look into doing this dynamically: https://developer.chrome.com/apps/permissions? |
The clipboardWrite permission is safe to remove from manifest on Chrome. The only effects I can see are:
But I think it's a good change to notice users that Vimium is allowed to modify the system clipboard. |
@smblott-github I had a look into it (branch here), but to no success. To quote Mozilla's docs:
None of those things happens when a user tries to paste a URL using our commands. It looks like optional permissions are a no-go for us on FF. (Sorry for the delay with this, I've had a few busy days.) |
OK. Thank you. |
This replaces #2524.
I haven't converted theDoneLinkHints.activateModeToCopyLinkUrl
command to use the new handler, since I'm focusing on getting Firefox to paste.NB: this directs the copy/paste commands via the HUD. This feels (and is) weird, but it's the best we've got if the background page doesn't do this for us on FF.
/cc @smblott-github