fup: add paste handler for uploading things from the clipboard

This commit is contained in:
Luke Granger-Brown 2021-03-26 21:35:37 +00:00
parent 017458ae2e
commit 6e539188ac

View file

@ -147,4 +147,13 @@ if (document.body.classList.contains('upload-page')) {
uploadFile(f, expiryEl.value);
}
}, false);
document.body.addEventListener('paste', (e) => {
e.preventDefault();
const clipboardData = e.clipboardData || window.clipboardData;
for (const item of clipboardData.items) {
if (item.kind === 'file') {
uploadFile(item.getAsFile(), expiryEl.value);
}
}
});
}