Skip to content

Skip image paste when clipboard also has text#64

Merged
paulwellnerbou merged 1 commit into
mainfrom
claude/happy-boyd-872967
May 8, 2026
Merged

Skip image paste when clipboard also has text#64
paulwellnerbou merged 1 commit into
mainfrom
claude/happy-boyd-872967

Conversation

@paulwellnerbou
Copy link
Copy Markdown
Owner

Summary

  • When pasting copied content from Word (and similar rich-text editors), the editor was inserting both the text and a PNG screenshot that Word puts on the clipboard alongside the text.
  • The DOM paste handler in EditPage.tsx runs after CodeMirror's own paste handler (bubble phase), so e.preventDefault() could not stop CodeMirror from inserting the text first; the handler then uploaded the screenshot on top.
  • Fix: if the clipboard contains text/plain or text/html alongside an image file blob, treat the image as a redundant rendering and skip the upload. Pure-image pastes (Finder, screenshot tools, "Copy Image") still upload as before.

Trade-off

  • The only realistic regression is "copy a single image out of Word/Outlook," since those apps still ship HTML wrapping the image. If anyone reports it, we can tighten the heuristic by sniffing the HTML for Word-specific markers (e.g. urn:schemas-microsoft-com:office, Mso… classes) instead of any text presence.

Test plan

  • Copy a paragraph from Word and paste into the editor → only text is inserted, no pasted-*.png upload.
  • Copy an image via macOS screenshot (Cmd+Shift+Ctrl+4) and paste → image uploads and reference is inserted.
  • Copy an image file in Finder and paste → image uploads and reference is inserted.
  • Copy a region of a webpage (text + inline images) and paste → text/html is inserted by CodeMirror, no spurious uploads (images come through as <img src> in HTML, not as file blobs).

🤖 Generated with Claude Code

When pasting from Word (and similar rich-text editors), the clipboard
contains both the text/html content and a PNG screenshot of the
selection. The previous handler would let CodeMirror insert the text
and then also upload the screenshot, producing duplicate output.

If the clipboard carries text/plain or text/html alongside an image
file blob, treat the image as a redundant rendering and skip the
upload.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@paulwellnerbou paulwellnerbou merged commit 2d4a4f4 into main May 8, 2026
1 check passed
@paulwellnerbou paulwellnerbou deleted the claude/happy-boyd-872967 branch May 8, 2026 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant