From 1807a118a86cf2b6207572a909eb363169b1e5b9 Mon Sep 17 00:00:00 2001 From: Abelino Chavez Date: Thu, 29 Jan 2026 15:52:03 -0600 Subject: [PATCH] feat(timeline): add Ctrl+X cut shortcut for timeline elements Implements cut functionality (copy + delete) with Ctrl+X keybinding: - Added "cut-selected" action type - Added "ctrl+x" keybinding mapping - Added action handler that copies then deletes selected elements - Added keyboard shortcut help description Partially addresses #672 Co-Authored-By: Claude Opus 4.5 --- apps/web/src/constants/actions.ts | 3 ++- apps/web/src/hooks/use-editor-actions.ts | 10 ++++++++++ apps/web/src/hooks/use-keyboard-shortcuts-help.ts | 4 ++++ apps/web/src/stores/keybindings-store.ts | 1 + 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/apps/web/src/constants/actions.ts b/apps/web/src/constants/actions.ts index 50e8ae5d7..8bd4d2c7a 100644 --- a/apps/web/src/constants/actions.ts +++ b/apps/web/src/constants/actions.ts @@ -47,7 +47,8 @@ export type Action = | "undo" // Undo last action | "redo" // Redo last undone action | "copy-selected" // Copy selected elements to clipboard - | "paste-selected"; // Paste elements from clipboard at playhead + | "paste-selected" // Paste elements from clipboard at playhead + | "cut-selected"; // Cut selected elements (copy + delete) /** * Defines the arguments, if present for a given type that is required to be passed on diff --git a/apps/web/src/hooks/use-editor-actions.ts b/apps/web/src/hooks/use-editor-actions.ts index 9287d2e03..73cbd6ab7 100644 --- a/apps/web/src/hooks/use-editor-actions.ts +++ b/apps/web/src/hooks/use-editor-actions.ts @@ -206,6 +206,16 @@ export function useEditorActions() { undefined ); + useActionHandler( + "cut-selected", + () => { + if (selectedElements.length === 0) return; + useTimelineStore.getState().copySelected(); + deleteSelected(); + }, + undefined + ); + useActionHandler( "paste-selected", () => { diff --git a/apps/web/src/hooks/use-keyboard-shortcuts-help.ts b/apps/web/src/hooks/use-keyboard-shortcuts-help.ts index 29e3c09b7..e4f481802 100644 --- a/apps/web/src/hooks/use-keyboard-shortcuts-help.ts +++ b/apps/web/src/hooks/use-keyboard-shortcuts-help.ts @@ -67,6 +67,10 @@ const actionDescriptions: Record< description: "Copy selected elements", category: "Editing", }, + "cut-selected": { + description: "Cut selected elements", + category: "Editing", + }, "paste-selected": { description: "Paste elements at playhead", category: "Editing", diff --git a/apps/web/src/stores/keybindings-store.ts b/apps/web/src/stores/keybindings-store.ts index febcaa307..90e367488 100644 --- a/apps/web/src/stores/keybindings-store.ts +++ b/apps/web/src/stores/keybindings-store.ts @@ -24,6 +24,7 @@ export const defaultKeybindings: KeybindingConfig = { "ctrl+a": "select-all", "ctrl+d": "duplicate-selected", "ctrl+c": "copy-selected", + "ctrl+x": "cut-selected", "ctrl+v": "paste-selected", "ctrl+z": "undo", "ctrl+shift+z": "redo",