From f7d40460f58e6c3fdec7e1c0c767e3a701262d50 Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Sat, 19 Sep 2026 17:28:25 -0400 Subject: [PATCH] paste: when the clipboard carries files, never let the HTML/URL fragment into the composer (#132) Verified headless that pasting an image copied from a web page (bitmap + text/html + text/plain URL) already produced only the upload card and an empty composer; make that explicit with a preventDefault so a future editor change can't regress it. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA --- src/app/hooks/useFilePasteHandler.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/app/hooks/useFilePasteHandler.ts b/src/app/hooks/useFilePasteHandler.ts index 867262f49..bb3e07428 100644 --- a/src/app/hooks/useFilePasteHandler.ts +++ b/src/app/hooks/useFilePasteHandler.ts @@ -5,7 +5,14 @@ export const useFilePasteHandler = (onPaste: (file: File[]) => void): ClipboardE useCallback( (evt) => { const files = getDataTransferFiles(evt.clipboardData); - if (files) onPaste(files); + if (files) { + // [Gitea #132] An image copied from a web page arrives with a + // text/html `…` fragment and a text/plain URL beside + // the bitmap. Only the file is wanted — stop the editor's own + // HTML/text insertion so nothing else lands in the composer. + evt.preventDefault(); + onPaste(files); + } }, [onPaste], );