mirror of https://github.com/kortix-ai/suna.git
Merge pull request #944 from Chaitanya045/Enable_paste_images_into_chat
This commit is contained in:
commit
40cfc13fd4
|
@ -16,6 +16,7 @@ import { Tooltip } from '@/components/ui/tooltip';
|
||||||
import { TooltipProvider, TooltipTrigger } from '@radix-ui/react-tooltip';
|
import { TooltipProvider, TooltipTrigger } from '@radix-ui/react-tooltip';
|
||||||
import { BillingModal } from '@/components/billing/billing-modal';
|
import { BillingModal } from '@/components/billing/billing-modal';
|
||||||
import ChatDropdown from './chat-dropdown';
|
import ChatDropdown from './chat-dropdown';
|
||||||
|
import { handleFiles } from './file-upload-handler';
|
||||||
|
|
||||||
interface MessageInputProps {
|
interface MessageInputProps {
|
||||||
value: string;
|
value: string;
|
||||||
|
@ -129,6 +130,29 @@ export const MessageInput = forwardRef<HTMLTextAreaElement, MessageInputProps>(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handlePaste = (e: React.ClipboardEvent<HTMLTextAreaElement>) => {
|
||||||
|
if (!e.clipboardData) return;
|
||||||
|
const items = Array.from(e.clipboardData.items);
|
||||||
|
const imageFiles: File[] = [];
|
||||||
|
for (const item of items) {
|
||||||
|
if (item.kind === 'file' && item.type.startsWith('image/')) {
|
||||||
|
const file = item.getAsFile();
|
||||||
|
if (file) imageFiles.push(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (imageFiles.length > 0) {
|
||||||
|
e.preventDefault();
|
||||||
|
handleFiles(
|
||||||
|
imageFiles,
|
||||||
|
sandboxId,
|
||||||
|
setPendingFiles,
|
||||||
|
setUploadedFiles,
|
||||||
|
setIsUploading,
|
||||||
|
messages,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const renderDropdown = () => {
|
const renderDropdown = () => {
|
||||||
if (isLoggedIn) {
|
if (isLoggedIn) {
|
||||||
const showAdvancedFeatures = enableAdvancedConfig || (customAgentsEnabled && !flagsLoading);
|
const showAdvancedFeatures = enableAdvancedConfig || (customAgentsEnabled && !flagsLoading);
|
||||||
|
@ -167,6 +191,7 @@ export const MessageInput = forwardRef<HTMLTextAreaElement, MessageInputProps>(
|
||||||
value={value}
|
value={value}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
|
onPaste={handlePaste}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
className={cn(
|
className={cn(
|
||||||
'w-full bg-transparent dark:bg-transparent border-none shadow-none focus-visible:ring-0 px-0.5 pb-6 pt-4 !text-[15px] min-h-[36px] max-h-[200px] overflow-y-auto resize-none',
|
'w-full bg-transparent dark:bg-transparent border-none shadow-none focus-visible:ring-0 px-0.5 pb-6 pt-4 !text-[15px] min-h-[36px] max-h-[200px] overflow-y-auto resize-none',
|
||||||
|
|
Loading…
Reference in New Issue