fix: ctrl v

This commit is contained in:
Ibrahima G. Coulibaly
2025-02-23 00:41:04 +01:00
parent 23c5d63ad9
commit 62f084eb45
5 changed files with 151 additions and 112 deletions

View File

@@ -38,6 +38,14 @@ export default function ToolFileInput({
});
}
};
const handlePaste = (event: ClipboardEvent) => {
const clipboardItems = event.clipboardData?.items ?? [];
const item = clipboardItems[0];
if (item.type.includes('image')) {
const file = item.getAsFile();
onChange(file!);
}
};
useEffect(() => {
if (value) {
const objectUrl = URL.createObjectURL(value);
@@ -57,6 +65,15 @@ export default function ToolFileInput({
const handleImportClick = () => {
fileInputRef.current?.click();
};
useEffect(() => {
window.addEventListener('paste', handlePaste);
return () => {
window.removeEventListener('paste', handlePaste);
};
}, [handlePaste]);
return (
<Box>
<InputHeader title={title} />