From 0a6f00749bb0720664409e9c4eca82928e6773c7 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Mon, 16 Jun 2025 22:15:15 +0400 Subject: feat: paste images --- public/static/scripts/form.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 public/static/scripts/form.js (limited to 'public/static') diff --git a/public/static/scripts/form.js b/public/static/scripts/form.js new file mode 100644 index 0000000..6e4f608 --- /dev/null +++ b/public/static/scripts/form.js @@ -0,0 +1,29 @@ +document.onpaste = () => { + var items = (event.clipboardData || event.originalEvent.clipboardData).items; + + for (index in items) { + var item = items[index]; + if (item.kind === 'file') { + file = item.getAsFile(); + showFile(file); + } + } +}; + +function showFile(file) { + setFormDetailsVisiblity(file != null); + + if (file == null) { + fileUploadWrapper.innerHTML = '

Click, drop, or paste files here

'; + + if (fileURLWrapper) { + fileURLWrapper.style.display = 'flex'; + } + } else { + fileUploadWrapper.innerHTML = `

File: ${file.name}

`; + + if (fileURLWrapper) { + fileURLWrapper.style.display = 'none'; + } + } +} \ No newline at end of file -- cgit v1.2.3