From 6e539188ac344f5ac0b6dc4b16dbec5e4c0e12fa Mon Sep 17 00:00:00 2001
From: Luke Granger-Brown <hg@lukegb.com>
Date: Fri, 26 Mar 2021 21:35:37 +0000
Subject: [PATCH] fup: add paste handler for uploading things from the
 clipboard

---
 web/fup/fupstatic/js/base.js | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/web/fup/fupstatic/js/base.js b/web/fup/fupstatic/js/base.js
index 0ce8d2405c..3f3951a4c1 100644
--- a/web/fup/fupstatic/js/base.js
+++ b/web/fup/fupstatic/js/base.js
@@ -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);
+      }
+    }
+  });
 }