Closed silverwind closed 1 year ago
This is the relevant code: https://github.com/tomayac/SVGcode/blob/80bc0bdc1e2a93ec3b022ebffbc0038a1714f8a1/src/js/clipboard.js#L65. What operating system does this happen on?
MacOS, window.ClipboardItem
does exist with the about:config
preference enabled. So I think it ends in this branch:
await navigator.clipboard.write([
new ClipboardItem({
'text/plain': new Promise(async (resolve) => {
resolve(new Blob([svg], { type: 'text/plain' }));
}),
}),
]);
Thanks for the report. I will take a look soon.
I think the likely fix will be to remove the Promise
wrapping. I tested the API with non-promise and Safari copied it fine. The fact that it works with Promise in Safari while not in Firefox is likely an implementation difference between the two.
Fixed via https://github.com/tomayac/SVGcode/commit/4a2234480c6b2105577310e90b7da7d0ae80c127. Thanks for reporting!
Thanks, confirmed working!
To reproduce:
dom.events.asyncClipboard.clipboardItem
inabout:config
Copy SVG
[object Promise]
I'm not sure where this goes wrong, but I suspect it has something to do with the user agent sniffing. I'm using this same API in this module, so I think it is operational and the bug is from this app code, not from Firefox.