Skip to content

feat(canvas): cut frames and layers with ⌘X and the context menus - #462

Closed
kitravee wants to merge 7 commits into
doop-design:mainfrom
kitravee:feat/cut-command-main
Closed

kitravee wants to merge 7 commits into
doop-design:mainfrom
kitravee:feat/cut-command-main

Conversation

@kitravee

@kitravee kitravee commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Closes #333

Demo

CleanShot.2569-11-09.at.20.24.07.mp4

What

  • ⌘X cuts the selection. Cut copies the picked layers, or the selected frames when no layer is picked, then removes them the way ⌫ does, as one undo step. Locked frames and layers stay on the canvas, but Cut still copies them.
  • The frame context menu has a Cut item ("Cut N frames" for a multi-selection), and so does the element context menu.
  • Only editors can cut. For viewers and link guests, ⌘X does nothing and the menus hide or disable Cut. The server still checks the edit role on PATCH and DELETE /api/frames/:id, as before.
  • Cut removes nothing unless the copy reached the clipboard. All three entry points go through one helper, cutWith in src/lib/canvasClipboard.ts.
  • Holding ⌘X cuts once. The canvas key handler cancels the repeated keydowns, the same way it ignores a held ⌫.
  • copySelection and cutSelection now live in src/lib/elementClipboard.ts instead of CanvasPage.

Tests

  • tests/cutSelection.test.ts covers cutting frames as one undo step, keeping a locked frame, cutting a picked element out of its frame, refusing a viewer, and an empty selection.
  • tests/elementContextMenuBrowser.test.ts picks "Cut 2 frames" from a frame title in Chromium.

🤖 Generated with Claude Code

kitravee and others added 5 commits November 9, 2026 20:01
Cut copies the selection the way ⌘C does, then removes it the way ⌫ does,
as one undo step. Nothing is removed unless the copy landed; locked frames
and layers are copied but stay; viewers cannot cut. A held ⌘X is ignored,
so it never takes the element and then the frame under it.

Closes doop-design#333

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… DataTransfer

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cutWith runs the removal only once the copy landed, for ⌘X and both
context menus. A held ⌘X is stopped by cancelling its repeat keydown in
the existing key handler, so the separate capture listener goes away.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@greptile-apps

greptile-apps Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The latest changes appear safe to merge; both previous findings are addressed.

Summary

Adds Cut for selected frames and layers through ⌘X and both context menus.

  • Editors can cut selected canvas content with ⌘X or context menus.

Reviews (2) · Last reviewed commit: "fix(canvas): keep menu cuts to what they..." · Reviewed by Greptile

Comment thread src/components/FrameContextMenu.tsx Resolved
Comment thread src/components/ElementContextMenu.tsx Resolved
…nswers

The menus' Cut waits for navigator.clipboard before removing anything.
The frame menu now removes the frames it copied, not whatever is selected
when the write lands, and the element menu cancels when the frame changed
in the meantime instead of saving its older HTML over the newer one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kitravee

kitravee commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Nov 9, 2026
Resolves the conflicts with the action registry (doop-design#448): ⌘X stays with the
native cut event, which the registry does not bind, and copy keeps going
through copySelection in elementClipboard.ts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kgoedecke

Copy link
Copy Markdown
Collaborator

Thanks for this, @kitravee, and for the demo! Cut already shipped on main in 7769503 ("feat(canvas): cut frames and elements with ⌘X and the context menus"), which also closed #333. It works the same way: ⌘X copies the picked layers or selected frames and deletes them only after the clipboard accepts the copy, there's Cut in the frame and element context menus, and locked items get copied but stay on the canvas. Since this PR would duplicate that work, I'm closing it. Sorry the two overlapped, and thank you for contributing.

@kgoedecke kgoedecke closed this Nov 21, 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.

There's no cut feature only copy

2 participants