Conversation
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.
Adds File > New from Clipboard (⇧⌘V), as in Preview. It opens the image on the clipboard as a new project that is exactly the size of the image, in one step. Until now you had to go through New Canvas (which already fills in the clipboard image's size), click Create, and then paste, which made two undo steps. It works for pixels copied inside Compositor and for
images copied in other apps.
What's added
ProjectWorkspace.newFromClipboard(): creates a new tab with a document the size of the copied image, holding the image as its only layer. Creating the document and adding the layer are one undo step, named "New from Clipboard".ImageImportError.tooLarge). If the clipboard holds no image, the app beeps.EditorSession.pasteboardImage(): the code that reads an image from another app, moved out of Paste so both commands use it.Not covered: a whole layer copied with ⌘C and no selection. That puts only the layer's ID on the pasteboard, not an image, so New from Clipboard beeps. Supporting it would mean rendering the copied layer (or folder, or adjustment layer) into an image first. I've left that out to keep this change small, but I'm happy to add it if you want it.
How to use
Tests
Two new tests in
SelectionClipboardTests:newFromClipboardOpensATabTheSizeOfTheCopiedPixels: copies a 30×20 selection and checks the new tab's size, its single layer (name, position, size, pixels), the undo name, and that the source project is left unchanged.newFromClipboardTakesAnImageFromAnotherApp: puts a PNG on the pasteboard and checks that the empty first tab is reused at 12×7. It then checks that text on the clipboard returns false and opens no tab.🤖 Generated with Claude Code