diff --git a/assets/js/screenshot_utility.js b/assets/js/screenshot_utility.js index 67a33f5..784b7e5 100644 --- a/assets/js/screenshot_utility.js +++ b/assets/js/screenshot_utility.js @@ -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!"); + } + }); }); }