From 2db57b139a6828f064bc6329fd69950acad6ce85 Mon Sep 17 00:00:00 2001 From: Steven Date: Mon, 2 Feb 2026 20:36:08 +0800 Subject: [PATCH] fix: handle pasted files in memo editor Fixes #5568 --- .../MemoEditor/components/EditorContent.tsx | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/web/src/components/MemoEditor/components/EditorContent.tsx b/web/src/components/MemoEditor/components/EditorContent.tsx index 6abd22ab8..5cc14f784 100644 --- a/web/src/components/MemoEditor/components/EditorContent.tsx +++ b/web/src/components/MemoEditor/components/EditorContent.tsx @@ -29,8 +29,29 @@ export const EditorContent = forwardRef(({ dispatch(actions.updateContent(content)); }; - const handlePaste = () => { - // Paste handling is managed by the Editor component internally + const handlePaste = (event: React.ClipboardEvent) => { + 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 (