diff --git a/Components/ChatInput.svelte b/Components/ChatInput.svelte index e75a4b1..f10aac2 100644 --- a/Components/ChatInput.svelte +++ b/Components/ChatInput.svelte @@ -470,6 +470,27 @@ e.stopPropagation(); } + function handleAttachments() { + const input = document.createElement("input"); + input.multiple = true; + input.type = "file"; + + input.onchange = async () => { + if (input.files) { + const dataTransfer = new DataTransfer(); + + for (let index = 0; index < input.files.length; index++) { + dataTransfer.items.add(input.files[index]); + } + + const files = await inputService.getFilesFromDataTransfer(dataTransfer); + const newAttachments = files.filter(file => !attachments.some(a => a.base64 === file.base64)); + attachments = [...attachments, ...newAttachments]; + } + }; + input.click(); + } + function handleCursorPositionChange() { if (!$searchState.active || $searchState.position === null) { return; @@ -554,10 +575,9 @@