mirror of
https://github.com/andy-stack/vaultkeeper-ai.git
synced 2026-07-22 06:42:03 +00:00
feat: implement file attachment button functionality
Add handleAttachments function to create file input dialog and process selected files through inputService. Wire up attachment button click handler and update aria-label to use Copy.ButtonAttachFiles enum value.
This commit is contained in:
parent
f51f171da2
commit
e542134b9f
2 changed files with 24 additions and 3 deletions
|
|
@ -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 @@
|
|||
<button
|
||||
id="chat-attachment-button"
|
||||
bind:this={attachmentButton}
|
||||
on:click={() => { }}
|
||||
on:click={() => { handleAttachments() }}
|
||||
disabled={isSubmitting}
|
||||
aria-label={"Attachment"}>
|
||||
<!-- Copy.AttachmentLabel -->
|
||||
aria-label={Copy.ButtonAttachFiles}>
|
||||
</button>
|
||||
|
||||
<button
|
||||
|
|
|
|||
|
|
@ -119,6 +119,7 @@ export enum Copy {
|
|||
ButtonTurnOffWebSearch = "Turn off Web Search",
|
||||
ButtonTurnOnWebSearch = "Turn on Web Search",
|
||||
ButtonUserInstruction = "User Instruction",
|
||||
ButtonAttachFiles = "Attach Files",
|
||||
|
||||
// Agent file message
|
||||
AttachedFile = `The user has attached the file {fileName}. The contents of the file are included below.
|
||||
|
|
|
|||
Loading…
Reference in a new issue