From d1ecff6879329cb6ec4566049a8c7fccff19573f Mon Sep 17 00:00:00 2001 From: Kavyansh Khaitan <73186427+KavyanshKhaitan2@users.noreply.github.com> Date: Tue, 3 Feb 2026 21:04:26 +0530 Subject: [PATCH 1/2] Implement paste event for image file input Add paste functionality for image uploads in project description. --- .../dashboard/projects/[id]/+page.svelte | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/routes/dashboard/projects/[id]/+page.svelte b/src/routes/dashboard/projects/[id]/+page.svelte index f770d7b..a8b1935 100644 --- a/src/routes/dashboard/projects/[id]/+page.svelte +++ b/src/routes/dashboard/projects/[id]/+page.svelte @@ -37,6 +37,36 @@ } let formPending = $state(false); + + + document.addEventListener('DOMContentLoaded', () => { + const pasteArea = document.querySelector('#description'); + const fileInput = document.querySelector('#imagefield'); + + pasteArea.addEventListener('paste', (event) => { + // Prevent the default paste behavior (e.g., pasting into the contenteditable div as text/html) + // Access the clipboard data items + const items = event.clipboardData.items; + + // Iterate over the items to find a file + for (const item of items) { + if (item.kind === 'file') { + const blob = item.getAsFile(); + + // Create a DataTransfer object to manage files + const dataTransfer = new DataTransfer(); + dataTransfer.items.add(blob); + + // Assign the DataTransfer's file list to the input element + fileInput.files = dataTransfer.files; + + // Optional: Provide a visual cue that the file was accepted + break; // Stop after finding the first file + } + } + }); + }); + @@ -180,6 +210,7 @@