diff --git a/src/routes/dashboard/projects/[id]/+page.svelte b/src/routes/dashboard/projects/[id]/+page.svelte index f770d7b..06582d8 100644 --- a/src/routes/dashboard/projects/[id]/+page.svelte +++ b/src/routes/dashboard/projects/[id]/+page.svelte @@ -37,6 +37,38 @@ } let formPending = $state(false); + +onMount(() => { + + 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 +212,7 @@