Allow pasting images into the chat input
This commit is contained in:
@@ -65,6 +65,22 @@ export const MessageInput = React.memo(
|
||||
e.target.value = "";
|
||||
};
|
||||
|
||||
const handlePaste = (e: React.ClipboardEvent<HTMLTextAreaElement>) => {
|
||||
if (isLoading) return;
|
||||
const items = e.clipboardData?.items;
|
||||
if (!items) return;
|
||||
for (const item of items) {
|
||||
if (item.type.startsWith("image/")) {
|
||||
const file = item.getAsFile();
|
||||
if (file) {
|
||||
e.preventDefault();
|
||||
onImageSelect(file);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const canSend = !isLoading && Boolean(query.trim() || pendingImage);
|
||||
|
||||
return (
|
||||
@@ -100,6 +116,7 @@ export const MessageInput = React.memo(
|
||||
ref={textareaRef}
|
||||
onChange={handleQueryChange}
|
||||
onKeyDown={handleKeyDown}
|
||||
onPaste={handlePaste}
|
||||
value={query}
|
||||
rows={2}
|
||||
placeholder="Ask Simba anything..."
|
||||
|
||||
Reference in New Issue
Block a user