Add clipboard image paste support (Issue #214) #234
Open
norendren wants to merge 1 commit intosamcf:mainfrom
Open
Add clipboard image paste support (Issue #214) #234norendren wants to merge 1 commit intosamcf:mainfrom
norendren wants to merge 1 commit intosamcf:mainfrom
Conversation
Author
|
Oops, was cleaning up some branches in fork and this one got dinged 😅 |
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
Implements #214
Images can now be pasted directly from the system clipboard (
Ctrl+V/Cmd+V) into the scene, including image upload to currently-open panel (defaults to Props when collapsed)Behavior
Paste targets the active panel's image library and places the image on the scene immediately:
If no image panel is open or expanded, images default to the Props library.
Clipboard conflict handling
The app has two independent clipboard concepts that needed to be reconciled:
:user/clipboard) that persists across reloads, used for duplicating canvas objects withCtrl+C/Ctrl+VThe conflict: pressing
Ctrl+Vwith an image on the system clipboard and objects in the internal clipboard would previously trigger both behaviors simultaneously.Resolution: All paste behavior is now routed through the native
pasteDOM event rather than akeydownlistener. Thepasteevent checks for image files first; if found, the image path runs and the object path is skipped. If no image is present, it falls through to:clipboard/paste.To make this deterministic: when the user copies or cuts canvas objects (
Ctrl+C/Ctrl+X), the app now writes an empty string to the system clipboard vianavigator.clipboard.writeText(""). This clears any stale image from the system clipboard so subsequent pastes correctly fall through to object duplication. This behavior felt a little hacky to implement but I think it aligns well with the expected behavior of copy/paste commands from users.Files changed
provider/shortcut.cljs— paste event handler, copy/cut system clipboard clearingprovider/image.cljs—use-image-uploadernow returns a Promise resolving with the created image records so callers can act on the hashes post-upload