fup: allow for pasting text content from clipboard

This commit is contained in:
Luke Granger-Brown 2021-03-26 21:42:42 +00:00
parent 6e539188ac
commit fa086419c8

View file

@ -153,6 +153,14 @@ if (document.body.classList.contains('upload-page')) {
for (const item of clipboardData.items) { for (const item of clipboardData.items) {
if (item.kind === 'file') { if (item.kind === 'file') {
uploadFile(item.getAsFile(), expiryEl.value); uploadFile(item.getAsFile(), expiryEl.value);
} else if (item.kind === 'string') {
item.getAsString((data) => {
// This is a hack, we should do something... more sensible.
const uploadData = new Blob([data], { type: 'text/plain' });
uploadData.name = 'clipboard.txt';
uploadFile(uploadData, expiryEl.value);
});
} }
} }
}); });