From 147f473fd3cb32fcc4057cec6f6b0d835173062f Mon Sep 17 00:00:00 2001 From: Abelino Chavez Date: Fri, 30 Jan 2026 20:42:51 -0600 Subject: [PATCH] feat: add Ctrl+X cut shortcut for timeline elements (#672) Adds a "cut-selected" action that copies selected elements to clipboard and then deletes them, enabling standard cut behavior. Note: Drag/drop elements to other tracks was already implemented. Co-Authored-By: Claude Opus 4.5 --- .../src/hooks/actions/use-editor-actions.ts | 27 +++++++++++++++++++ apps/web/src/lib/actions/definitions.ts | 5 ++++ 2 files changed, 32 insertions(+) diff --git a/apps/web/src/hooks/actions/use-editor-actions.ts b/apps/web/src/hooks/actions/use-editor-actions.ts index 1ce890cb..abf54dd8 100644 --- a/apps/web/src/hooks/actions/use-editor-actions.ts +++ b/apps/web/src/hooks/actions/use-editor-actions.ts @@ -274,6 +274,33 @@ export function useEditorActions() { undefined, ); + useActionHandler( + "cut-selected", + () => { + if (selectedElements.length === 0) return; + + // Copy elements to clipboard + const results = editor.timeline.getElementsWithTracks({ + elements: selectedElements, + }); + const items = results.map(({ track, element }) => { + const { ...elementWithoutId } = element; + return { + trackId: track.id, + trackType: track.type, + element: elementWithoutId, + }; + }); + setClipboard({ items }); + + // Delete the selected elements + editor.timeline.deleteElements({ + elements: selectedElements, + }); + }, + undefined, + ); + useActionHandler( "paste-copied", () => { diff --git a/apps/web/src/lib/actions/definitions.ts b/apps/web/src/lib/actions/definitions.ts index 83144a25..bdcb685d 100644 --- a/apps/web/src/lib/actions/definitions.ts +++ b/apps/web/src/lib/actions/definitions.ts @@ -95,6 +95,11 @@ export const ACTIONS = { category: "editing", defaultShortcuts: ["ctrl+c"], }, + "cut-selected": { + description: "Cut selected elements", + category: "editing", + defaultShortcuts: ["ctrl+x"], + }, "paste-copied": { description: "Paste elements at playhead", category: "editing",