Skip to content

Add clipboard image paste support (Issue #214) #234

Open
norendren wants to merge 1 commit intosamcf:mainfrom
norendren:clipboard-images
Open

Add clipboard image paste support (Issue #214) #234
norendren wants to merge 1 commit intosamcf:mainfrom
norendren:clipboard-images

Conversation

@norendren
Copy link
Copy Markdown

@norendren norendren commented Mar 23, 2026

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:

Active panel Upload library Scene action
Tokens Token images Placed as a token at canvas center
Scene Scene images Set as the scene background
Props / default Prop images Placed as a prop at canvas center

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:

  • System clipboard — holds images copied from outside the app
  • Object clipboard — internal DataScript state (:user/clipboard) that persists across reloads, used for duplicating canvas objects with Ctrl+C / Ctrl+V

The conflict: pressing Ctrl+V with 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 paste DOM event rather than a keydown listener. The paste event 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 via navigator.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 clearing
  • provider/image.cljsuse-image-uploader now returns a Promise resolving with the created image records so callers can act on the hashes post-upload

@norendren norendren changed the title Add clipboard image paste support (#214) Add clipboard image paste support (Issue #214) Mar 23, 2026
@norendren norendren closed this Apr 5, 2026
@norendren norendren deleted the clipboard-images branch April 5, 2026 16:19
@norendren norendren restored the clipboard-images branch April 5, 2026 16:20
@norendren
Copy link
Copy Markdown
Author

Oops, was cleaning up some branches in fork and this one got dinged 😅

@norendren norendren reopened this Apr 5, 2026
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