diff --git a/packages/builder/src/components/common/Dropzone.svelte b/packages/builder/src/components/common/Dropzone.svelte index 7ec394063c..500a875d88 100644 --- a/packages/builder/src/components/common/Dropzone.svelte +++ b/packages/builder/src/components/common/Dropzone.svelte @@ -6,13 +6,16 @@ export let files = [] let selectedImageIdx = 0 + let fileDragged = false $: selectedImage = files[selectedImageIdx] - async function processFiles(evt) { - const filesToProcess = Array.from(evt.target.files).map( - ({ name, path, size }) => ({ name, path, size }) - ) + async function processFiles(fileList) { + const filesToProcess = Array.from(fileList).map(({ name, path, size }) => ({ + name, + path, + size, + })) const response = await api.post(`/api/files/process`, { files: filesToProcess, @@ -29,12 +32,37 @@ function navigateRight() { selectedImageIdx += 1 } + + function handleFile(evt) { + processFiles(evt.target.files) + } + + function handleDragOver(evt) { + evt.preventDefault() + fileDragged = true + } + + function handleDragLeave(evt) { + evt.preventDefault() + fileDragged = false + } + + function handleDrop(evt) { + evt.preventDefault() + processFiles(evt.dataTransfer.files) + fileDragged = false + } -