mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-06-06 04:59:24 +02:00
add copy-paste images (#1722)
This commit is contained in:
parent
b5aa7370a2
commit
43557f738b
@ -1,4 +1,4 @@
|
||||
import React, { useEffect, useRef } from "react";
|
||||
import React, { EventHandler, useEffect, useRef } from "react";
|
||||
import { FiSend, FiFilter, FiPlusCircle, FiCpu } from "react-icons/fi";
|
||||
import ChatInputOption from "./ChatInputOption";
|
||||
import { FaBrain } from "react-icons/fa";
|
||||
@ -55,6 +55,23 @@ export function ChatInputBar({
|
||||
}
|
||||
}, [message]);
|
||||
|
||||
const handlePaste = (event: React.ClipboardEvent) => {
|
||||
const items = event.clipboardData?.items;
|
||||
if (items) {
|
||||
const pastedFiles = [];
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
if (items[i].kind === "file") {
|
||||
const file = items[i].getAsFile();
|
||||
if (file) pastedFiles.push(file);
|
||||
}
|
||||
}
|
||||
if (pastedFiles.length > 0) {
|
||||
event.preventDefault();
|
||||
handleFileUpload(pastedFiles);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const { llmProviders } = useChatContext();
|
||||
const [_, llmName] = getFinalLLM(llmProviders, selectedAssistant, null);
|
||||
|
||||
@ -112,6 +129,7 @@ export function ChatInputBar({
|
||||
</div>
|
||||
)}
|
||||
<textarea
|
||||
onPaste={handlePaste}
|
||||
ref={textAreaRef}
|
||||
className={`
|
||||
m-0
|
||||
|
Loading…
x
Reference in New Issue
Block a user