From fa086419c82f5bbede1ab2ea40cb86b2e374253a Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Fri, 26 Mar 2021 21:42:42 +0000 Subject: [PATCH] fup: allow for pasting text content from clipboard --- web/fup/fupstatic/js/base.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/web/fup/fupstatic/js/base.js b/web/fup/fupstatic/js/base.js index 3f3951a4c1..d76b9fd467 100644 --- a/web/fup/fupstatic/js/base.js +++ b/web/fup/fupstatic/js/base.js @@ -153,6 +153,14 @@ if (document.body.classList.contains('upload-page')) { for (const item of clipboardData.items) { if (item.kind === 'file') { 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); + }); } } });