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 <noreply@anthropic.com>
This commit is contained in:
parent
6bad0d42ca
commit
147f473fd3
|
|
@ -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",
|
||||
() => {
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Reference in New Issue