clipboard-polyfill
clipboard-polyfill copied to clipboard
writeText throws exception in chrome within an iframe
Scenarios:
- copy text to clipboard running on Chrome within an iframe using
import { writeText } from 'clipboard-polyfill/text'
.
Current behaviors:
- It throws exception
.
When changing to write api and insert it as a ClipboardItem. It works fine.
write([new ClipboardItem({
[ClipboardItemMimeType.TextPlain]: 'some text',
}])
Do you know what are the different between permissions of 2 api.
Chrome version: Version 95.0.4638.54
That does sound pretty weird. Do you have an example page I can try to debug?
something's weird also happens in my product, it only works for write api. you can play around here (notes that I just try with the navigator api)
https://stackblitz.com/edit/js-cnr1ww?file=index.js ( issue for both 2apis)
with the same code if I am running on w3schools, it's working fine.
something's weird also happens in my product, it only works for write api. you can play around here (notes that I just try with the navigator api)
https://stackblitz.com/edit/js-cnr1ww?file=index.js ( issue for both 2apis)
with the same code if I am running on w3schools, it's working fine.
If I copy your HTML to a local file, navigator.clipboard.writeText('data')
seems to work perfectly.
(Note that testing inside stackblitz.com
is not good way, since that wraps the page in even more frames.)
Do you have another example page that exhibits the issue?
Could you let me know if v4.0.0-rc3
fixes your issue?
I'm closing this for now, because the latest build tries more fallbacks for writeText()
. Please feel welcome to file a new issue if you still have trouble!