Closed Bug 1325759 Opened 8 years ago Closed 7 years ago

Copy image binary content as well as URL

Categories

(WebExtensions :: Untriaged, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1356543

People

(Reporter: bugzilla, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [design-decision-approved])

The WebExtension API documentation[1] for Document.execCommand() makes it look as though it's possible to add text to the clipboard via execCommand('copy'). However, I can see no way of copying the actual binary data of an image; i.e. as per the "Copy Image" item from the context menu. As part of porting the Image Toolbar add-on, I would like a way to continue to offer this functionality. Note: Some discussions online propose using canvas to extract a dataURL, that's not really an acceptable solution. It's very useful to be able to copy images and paste into an image editor, document editor, etc. [1]: https://developer.mozilla.org/en/docs/Web/API/Document/execCommand
I should add, currently using the following to copy both image content and URL simultaneously: > var param = Components.classes["@mozilla.org/embedcomp/command-params;1"] > .createInstance(Components.interfaces.nsICommandParams); > param.setLongValue("imageCopy", Components.interfaces.nsIContentViewerEdit.COPY_IMAGE_ALL); > document.commandDispatcher.getControllerForCommand("cmd_copyImage") > .QueryInterface(Components.interfaces.nsICommandController) > .doCommandWithParams("cmd_copyImage", param);
Presumably execCommand could be overloaded to optionally take a pageAction.ImageDataType or something like that?
Sorry for bugspam, ignore comment 2, I don't know what I'm talking about. pageAction is not what I thought it was :-)
Whiteboard: [design-decision-needed] triaged
Blocks: 1311472
Hi Ben, this has been added to the agenda for the June 6 WebExtension APIs triage meeting. I hope you'll be able to join us! Agenda: https://docs.google.com/document/d/1pTNjK5i_8gHt3EeiUiu5KCUVeRcfwn7ybCPDBSx6CLM/edit#heading=h.34n4lirhljve
Flags: needinfo?(amckay)
I note the following triage meeting comments: > Andy to investigate why Chrome deprecated this and then removed > Unclear about how to implement this in Firefox Not sure about Chrome, but it's interesting that Firefox also has these as separate context menu items these days ("Copy Image" and "Copy Image Location"). IIRC the Firefox context menu used to have a single item that performed both functions as well. It might be easier to find out why Firefox changed (I assume it's all here in Bugzilla somewhere).
I think we need to support this and make clipboard manipulation as easy as possible. It's possible we could do dupe this over to bug 1344410 or one of the many other bugs around clipboard. My chrome deprecation comment was referring to bug 1344410.
Flags: needinfo?(amckay)
Whiteboard: [design-decision-needed] triaged → [design-decision-approved][triaged]
Whiteboard: [design-decision-approved][triaged] → [design-decision-approved]
Is this the same with bug 1356543?
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → DUPLICATE
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.