LuanEdCosta / copy-image-clipboard

Lightweight library to copy PNG and JPG images to clipboard
https://luanedcosta.github.io/copy-image-clipboard/
MIT License
59 stars 12 forks source link

Does not work in Firefox #36

Closed sdudnic closed 2 years ago

sdudnic commented 2 years ago

The example https://luanedcosta.github.io/copy-image-clipboard/ does not work in Firefox, we obtain the message

ClipboardItem is not defined

Browsers (please complete the following information)

Browser name: Firefox (Windows) Version: 103.0.2 (64-bit)

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

image

LuanEdCosta commented 2 years ago

Hi @sdudnic, thanks for creating this issue.

I've already documented this problem here.


You have to visit about:config and set dom.events.asyncClipboard.clipboardItem to true.

image

sdudnic commented 2 years ago

Hi @sdudnic, thanks for creating this issue.

I've already documented this problem here.

You have to visit about:config and set dom.events.asyncClipboard.clipboardItem to true.

image

could you also inform all my users of my site of that procedure? Should I create a UserManual of how to use my site?

sdudnic commented 2 years ago

So, it seems there is no univseral solution to copy an image to clipboard. Modifying the settings in Firefox should event not be proposed: any client of the web application is aware of that manipunation to do, so in practice is not a solution.

LuanEdCosta commented 2 years ago

For now the only way of copying images on Firefox is setting this flag to true, but obviously you should not ask your users to do that.

You can still use this library and check if it's possible to copy to clipboard or not using the canCopyImagesToClipboard function (example from docs). This way people using browsers that support copying images will have the functionality.

This library only makes easier copying images to clipboard using browser web API's, it's not my fault that Firefox decided to hide this feature behind a flag.

https://developer.mozilla.org/en-US/docs/Web/API/ClipboardItem#browser_compatibility