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) {
|
function copy_screenshot(el) {
|
||||||
html2canvas(el).then((canvas) => {
|
html2canvas(el).then((canvas) => {
|
||||||
console.log("Copying image to clipboard");
|
console.log("Copying image to clipboard");
|
||||||
let data = canvas.toDataURL();
|
canvas.toBlob((b) => {
|
||||||
|
try {
|
||||||
const textArea = document.createElement("textarea");
|
navigator.clipboard.write([
|
||||||
textArea.value = data;
|
new ClipboardItem({
|
||||||
|
'image/png': b
|
||||||
document.body.prepend(textArea);
|
})
|
||||||
textArea.select();
|
]);
|
||||||
|
} catch (e) {
|
||||||
document.execCommand('copy');
|
console.error("Failed to copy!");
|
||||||
document.body.removeChild(textArea);
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue