Commit 2db57b13 authored by Steven's avatar Steven

fix: handle pasted files in memo editor

Fixes #5568
parent 0dbc35a2
...@@ -29,8 +29,29 @@ export const EditorContent = forwardRef<EditorRefActions, EditorContentProps>(({ ...@@ -29,8 +29,29 @@ export const EditorContent = forwardRef<EditorRefActions, EditorContentProps>(({
dispatch(actions.updateContent(content)); dispatch(actions.updateContent(content));
}; };
const handlePaste = () => { const handlePaste = (event: React.ClipboardEvent<Element>) => {
// Paste handling is managed by the Editor component internally const clipboard = event.clipboardData;
if (!clipboard) return;
const files: File[] = [];
if (clipboard.items && clipboard.items.length > 0) {
for (const item of Array.from(clipboard.items)) {
if (item.kind !== "file") continue;
const file = item.getAsFile();
if (file) files.push(file);
}
} else if (clipboard.files && clipboard.files.length > 0) {
files.push(...Array.from(clipboard.files));
}
if (files.length === 0) return;
const localFiles: LocalFile[] = files.map((file) => ({
file,
previewUrl: createBlobUrl(file),
}));
localFiles.forEach((localFile) => dispatch(actions.addLocalFile(localFile)));
event.preventDefault();
}; };
return ( return (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment