How to Handle Browser Clipboard in JS
The other day I wanted to be able to copy/paste files to an HTML textarea. like in Github or GitLab. Since I’m not a frontend expert I quickly browsed to MDN. <textarea id="mytextarea"></textarea> const myTextArea = document.querySelector("#mytextarea") myTextArea.addEventListener("paste", (e) => { let paste = (event.clipboardData || window.clipboardData).files; console.log(paste) }) Even if you didn’t read the doc, you might think that if you paste some text, the files element would be empty....