[Clipboard API] Support PNG images in async clipboard API
Categories
(Core :: DOM: Events, enhancement, P3)
Tracking
()
People
(Reporter: adel.mehrban, Unassigned)
References
(Blocks 1 open bug)
Details
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/82.0.4056.3 Safari/537.36
Steps to reproduce:
Trying to copy an image into the clipboard using Clipboard API navigator.clipboard.write
method
Demo here: https://codepen.io/yashints/pen/bGNvpGM
Actual results:
ReferenceError: ClipboardItem is not defined
Expected results:
Image data to be copied into clipboard
Comment 1•5 years ago
|
||
Using the provided demo, I have reproduced this issue on Windows 10 and Ubuntu 18, on all the latest versions of the main channels.
Thank you for your contribution!
Comment 2•5 years ago
|
||
I am not sure whether this component is correct. If incorrect, please set a more appropriate one. Thank you!
Comment 3•5 years ago
|
||
These are behind a pref (dom.events.asyncClipboard.dataTransfer
) and disabled by default.
annyG, do we already have a bug tracking turning these on by default? I didn't find one.
Reporter | ||
Comment 4•5 years ago
|
||
Turning that flag on didn’t have any effect BTW
Comment 5•5 years ago
|
||
In one of my bugs (https://bugzilla.mozilla.org/show_bug.cgi?id=1461465#c54) I mentioned that we don't support non-text data for read
and write
APIs even with the dom.events.asyncClipboard.dataTransfer
pref turned on. I am a little bit fuzzy on the exact reason, but I believe at the time when I was working on this, Chrome did not support non-text read/write APIs either and we wanted to hold off until the clipboard specification became final. I am now seeing that Chrome 76 added support for copy/pasting PNG images. Currently, we don't have a bug tracking turning on dom.events.asyncClipboard.dataTransfer
by default, nor for adding non-text data support.
Updated•5 years ago
|
Reporter | ||
Comment 6•5 years ago
|
||
Is there any reason the only option is going to be PNG like Chrome? Why not go above that and add for example jpg as well?
Updated•5 years ago
|
Comment 7•4 years ago
|
||
This very same issue caused by ReferenceError: ClipboardItem is not defined
also appears on MacOS FF version 83.0 (64-bit) and 84.0b4 (64-bit).
Comment 8•4 years ago
|
||
IMO that is clearly a defect, not an enhancement.
My implementation in bug 1619947 actually has code to copy images to the clipboard. However the code is still a draft.
Updated•3 years ago
|
Description
•