From 4fe2d268f8e3b2ff33d66bea00f6ee068c8a8209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daphn=C3=A9=20Popin?= Date: Tue, 26 Nov 2024 16:50:10 +0100 Subject: [PATCH] Ext: rework buttons in input bar --- .../components/conversation/AttachFile.tsx | 44 +++++++ .../conversation/AttachFragment.tsx | 120 +++++++++--------- .../app/src/components/input_bar/InputBar.tsx | 2 +- .../input_bar/InputBarContainer.tsx | 38 +++--- 4 files changed, 126 insertions(+), 78 deletions(-) create mode 100644 extension/app/src/components/conversation/AttachFile.tsx diff --git a/extension/app/src/components/conversation/AttachFile.tsx b/extension/app/src/components/conversation/AttachFile.tsx new file mode 100644 index 0000000000000..440c55b6f1778 --- /dev/null +++ b/extension/app/src/components/conversation/AttachFile.tsx @@ -0,0 +1,44 @@ +import { supportedFileExtensions } from "@dust-tt/client"; +import { AttachmentIcon, Button } from "@dust-tt/sparkle"; +import type { EditorService } from "@extension/components/input_bar/editor/useCustomEditor"; +import type { FileUploaderService } from "@extension/hooks/useFileUploaderService"; +import { useRef } from "react"; + +type AttachFileProps = { + fileUploaderService: FileUploaderService; + editorService: EditorService; +}; + +export const AttachFile = ({ + fileUploaderService, + editorService, +}: AttachFileProps) => { + const fileInputRef = useRef(null); + return ( + <> + { + await fileUploaderService.handleFileChange(e); + if (fileInputRef.current) { + fileInputRef.current.value = ""; + } + editorService.focusEnd(); + }} + ref={fileInputRef} + style={{ display: "none" }} + type="file" + multiple={true} + /> +