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

Demo page not working on latest Mozilla Firefox #41

Closed xdung24 closed 1 year ago

xdung24 commented 1 year ago

Describe the bug

Code not working on latest Firefox, but works well on Google Chrome/Chromium The demo url for testing also doesn't work (https://luanedcosta.github.io/copy-image-clipboard/) I haven't test on older version of Mozilla Firefox

Browsers (please complete the following information)

Browser name: Mozilla Firefox Version: 107.0.1

Expected behavior

The demo page as well as the code should work properly

Screenshots

Screen Shot 2022-12-08 at 09 59 00 Screen Shot 2022-12-08 at 09 58 22 Screen Shot 2022-12-08 at 09 57 31
LuanEdCosta commented 1 year ago

Unfortunately this is a Firefox problem. They decided to disable the ClipboardItem by default, so we have to enable a flag on Firefox configs to work properly.

image Print from MDN Docs: https://developer.mozilla.org/en-US/docs/Web/API/ClipboardItem#browser_compatibility


The browser ClipboardAPI is a recent feature with many cross-browser compatibility issues. We should not ask for users to enable this flag. Instead, we can disable the copy button using the canCopyImagesToClipboard function from this library.


Sorry for the long explanation. I plan to rewrite docs and the demo to explain these details in a better way.