mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-20 00:14:50 +00:00
Adding a feature to paste files you ctrl v (#2183)
This commit is contained in:
1 parent
909bc421c0
commit
6d8f083c6f
1 file changed
+26
@@ -532,6 +532,31 @@ export default function MessageInput({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handlePaste = (e: React.ClipboardEvent<HTMLTextAreaElement>) => {
|
||||||
|
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) => {
|
const handlePostDocumentSelect = (doc: any) => {
|
||||||
console.log('Selected document:', doc);
|
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"
|
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}
|
onInput={handleInput}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
|
onPaste={handlePaste}
|
||||||
aria-label={t('inputPlaceholder')}
|
aria-label={t('inputPlaceholder')}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in new issue
Block a user