From 6d8f083c6f9650a65331ade64fe2ca256a60f2aa Mon Sep 17 00:00:00 2001 From: AbbasSalloum <63022908+AbbasSalloum@users.noreply.github.com> Date: Fri, 12 Dec 2025 06:55:16 -0500 Subject: [PATCH] Adding a feature to paste files you ctrl v (#2183) --- frontend/src/components/MessageInput.tsx | 26 ++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/frontend/src/components/MessageInput.tsx b/frontend/src/components/MessageInput.tsx index 4e494959..750b0b12 100644 --- a/frontend/src/components/MessageInput.tsx +++ b/frontend/src/components/MessageInput.tsx @@ -532,6 +532,31 @@ export default function MessageInput({ } }; + const handlePaste = (e: React.ClipboardEvent) => { + const clipboardItems = e.clipboardData?.items; + const files: File[] = []; + + if (!clipboardItems) return; + + for (let i = 0; i < clipboardItems.length; i++) { + const item = clipboardItems[i]; + + if (item.kind === 'file') { + const file = item.getAsFile(); + if (file) { + files.push(file); + } + } + } + + if (files.length > 0) { + // Prevent weird binary stuff from being pasted as text + e.preventDefault(); + uploadFiles(files); + } +}; + + const handlePostDocumentSelect = (doc: any) => { console.log('Selected document:', doc); }; @@ -691,6 +716,7 @@ export default function MessageInput({ className="inputbox-style no-scrollbar bg-lotion dark:text-bright-gray dark:placeholder:text-bright-gray/50 w-full overflow-x-hidden overflow-y-auto rounded-t-[23px] px-2 text-base leading-tight whitespace-pre-wrap opacity-100 placeholder:text-gray-500 focus:outline-hidden sm:px-3 dark:bg-transparent" onInput={handleInput} onKeyDown={handleKeyDown} + onPaste={handlePaste} aria-label={t('inputPlaceholder')} />