Skip to content

[mac] Fix pasting screenshots from system clipboard (#295)#298

Merged
Shpigford merged 1 commit into
mainfrom
issue-295-clipboard
Apr 29, 2026
Merged

[mac] Fix pasting screenshots from system clipboard (#295)#298
Shpigford merged 1 commit into
mainfrom
issue-295-clipboard

Conversation

@Shpigford

Copy link
Copy Markdown
Owner

Summary

NSTextView's default validateMenuItem(_:) disables Edit > Paste whenever the clipboard has no string/RTF data — which is exactly what a Cmd+Shift+Ctrl+4 screenshot looks like (raw TIFF only). Cmd+V was being silently dropped before our paste(_:) override ever ran.

Force-allow paste: in the override, then route raw image bytes through a typed-data probe: PNG/JPEG/GIF/HEIC pass through with original bytes (preserves animation, JPEG quality), TIFF — macOS's generic image container — decodes and re-encodes to PNG so we don't drop multi-MB uncompressed siblings next to notes. Same image-paste logic added to LiveEditorView's existing Cmd+V monitor for the experimental live-preview engine.

Test plan

  • Cmd+Shift+Ctrl+4 → drag region → Cmd+V in editor inserts ![](slug-N.png) and writes a sibling .png next to the doc
  • Cmd+V of a .jpg/.gif copied from Finder still preserves original bytes (file-URL branch unchanged)
  • Cmd+V of an image URL string (e.g. browser address bar) still triggers download path
  • Cmd+V of plain text still inserts as text

Fixes #295

NSTextView's default validateMenuItem(_:) disables Edit > Paste when the
clipboard has only image data (no string/RTF), so Cmd+V on a screenshot
silently no-op'd before reaching paste(_:). Force-allow paste: in the
override and route raw image bytes (PNG/JPEG/GIF/HEIC pass through,
TIFF → PNG) ourselves. Same image-paste path added to LiveEditorView's
Cmd+V monitor for the experimental live-preview engine.
@Shpigford
Shpigford merged commit 14a6ecb into main Apr 29, 2026
4 checks passed
@Shpigford
Shpigford deleted the issue-295-clipboard branch April 29, 2026 16:52
Shpigford added a commit that referenced this pull request Apr 29, 2026
NSTextView's default validateMenuItem(_:) disables Edit > Paste when the
clipboard has only image data (no string/RTF), so Cmd+V on a screenshot
silently no-op'd before reaching paste(_:). Force-allow paste: in the
override and route raw image bytes (PNG/JPEG/GIF/HEIC pass through,
TIFF → PNG) ourselves. Same image-paste path added to LiveEditorView's
Cmd+V monitor for the experimental live-preview engine.
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.

Pasting images from system clipboard doesn't work

1 participant