Superior clipboard manipulation
Won't work on non-https connections, but actually works...
This commit is contained in:
parent
08f647cd01
commit
3ee3bd2dab
|
@ -1,16 +1,17 @@
|
|||
function copy_screenshot(el) {
|
||||
html2canvas(el).then((canvas) => {
|
||||
console.log("Copying image to clipboard");
|
||||
let data = canvas.toDataURL();
|
||||
|
||||
const textArea = document.createElement("textarea");
|
||||
textArea.value = data;
|
||||
|
||||
document.body.prepend(textArea);
|
||||
textArea.select();
|
||||
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(textArea);
|
||||
canvas.toBlob((b) => {
|
||||
try {
|
||||
navigator.clipboard.write([
|
||||
new ClipboardItem({
|
||||
'image/png': b
|
||||
})
|
||||
]);
|
||||
} catch (e) {
|
||||
console.error("Failed to copy!");
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue