cheminfo / nmrium

React component to display and process nuclear magnetic resonance (NMR) spectra.
https://docs.nmrium.org
MIT License
55 stars 25 forks source link

it seems copying to a clipboard not working anymore for images in Safari #2713

Open hamed-musallam opened 1 year ago

hamed-musallam commented 1 year ago
          it seems copying to a clipboard not working anymore for images

Screenshot 2023-10-18 at 12 07 04

_Originally posted by @hamed-musallam in https://github.com/cheminfo/nmrium/pull/2712#discussion_r1363610730_

lpatiny commented 11 months ago

It also does not work one Firefox but it used to work apparently (in v0.23.0).

@targos I think we discussed already about this issue but I don't remember the conclusion.

targos commented 11 months ago

I don't remember either.

lpatiny commented 11 months ago

@hamed-musallam Could you try to investigate this issue ? I don't see any error in the console but there may be an issue between the 'click' and the 'event'. I think the browser needs to know that there is a cause to effect relationship between the click and the clipboard.write call (for security reason). The complexity of the application could explain that some browsers can not track the sequence of events.

Concerning Firefox I also think that copy as an image is currently not supported using 'write': https://caniuse.com/async-clipboard. However it supports 'setImageData' that should solve this issue: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/clipboard/setImageData. So you can check which version to use depending the availability of the method.

hamed-musallam commented 9 months ago

To use setImageData, an extension must be added to Firefox, which is an extra step that I think all users will not do. Therefore, for now, I will maintain the current workaround solution

targos commented 9 months ago

Yeah, asking the user to install an extension just for copy to clipboard feature is too much (and we would have to maintain that extension)

lpatiny commented 6 months ago

I checked Firefox again and the Nightly build is now working !

image

I like bugs that solves by themself ;) (kind of).

However it still does not work on Safari and I don't know why. There is no error message. We should at least not give a message that it is being copied if it is not.

@hamed-musallam Could you check the Safari issue ?