forked from open-webui/open-webui
refac: message drag file input
This commit is contained in:
parent
cc3f84f916
commit
df3d95bf2a
1 changed files with 17 additions and 7 deletions
|
@ -119,12 +119,16 @@
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
const dropZone = document.querySelector('body');
|
const dropZone = document.querySelector('body');
|
||||||
|
|
||||||
dropZone?.addEventListener('dragover', (e) => {
|
const onDragOver = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
dragged = true;
|
dragged = true;
|
||||||
});
|
};
|
||||||
|
|
||||||
dropZone.addEventListener('drop', async (e) => {
|
const onDragLeave = () => {
|
||||||
|
dragged = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
const onDrop = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
|
||||||
|
@ -158,11 +162,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
dragged = false;
|
dragged = false;
|
||||||
});
|
};
|
||||||
|
|
||||||
dropZone?.addEventListener('dragleave', () => {
|
dropZone?.addEventListener('dragover', onDragOver);
|
||||||
dragged = false;
|
dropZone?.addEventListener('drop', onDrop);
|
||||||
});
|
dropZone?.addEventListener('dragleave', onDragLeave);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
dropZone?.removeEventListener('dragover', onDragOver);
|
||||||
|
dropZone?.removeEventListener('drop', onDrop);
|
||||||
|
dropZone?.removeEventListener('dragleave', onDragLeave);
|
||||||
|
};
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue