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",