[mac] Fix pasting screenshots from system clipboard (#295)#298
Merged
Conversation
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
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NSTextView's default
validateMenuItem(_:)disables Edit > Paste whenever the clipboard has no string/RTF data — which is exactly what aCmd+Shift+Ctrl+4screenshot looks like (raw TIFF only). Cmd+V was being silently dropped before ourpaste(_:)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 toLiveEditorView's existing Cmd+V monitor for the experimental live-preview engine.Test plan
Cmd+Shift+Ctrl+4→ drag region →Cmd+Vin editor insertsand writes a sibling.pngnext to the docCmd+Vof a.jpg/.gifcopied from Finder still preserves original bytes (file-URL branch unchanged)Cmd+Vof an image URL string (e.g. browser address bar) still triggers download pathCmd+Vof plain text still inserts as textFixes #295