I want to write text and html to the user clipboard. I am using the code snippet from MDN: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/write
navigator.permissions.query({ name: 'clipboard-write' }).then(result => {
if (result.state === 'granted') {
let data = [new ClipboardItem({ "text/plain": message })];
navigator.clipboard.write(data).then(function() {
$.growl.notice({ message: ResourceService.getKey("CopyToClipboardSuccess"), location: "tc", title: "" });
}, function() {
$.growl.error({ message: ResourceService.getKey("CopyToClipboardError"), location: "tc", title: "" });
});
}
});
All I get is this error:
Uncaught (in promise) TypeError: Failed to construct 'ClipboardItem': Failed to convert value to 'Blob'.
Is there another way to copy text and HTML to the clipboard. What do I miss?