From f8fb238b228881ef970739b7d884912058b41347 Mon Sep 17 00:00:00 2001 From: Maze Winther Date: Tue, 31 Mar 2026 22:53:16 +0200 Subject: feat: centralize selection management --- .../src/lib/commands/timeline/element/split-elements.ts | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'apps/web/src/lib/commands/timeline/element/split-elements.ts') diff --git a/apps/web/src/lib/commands/timeline/element/split-elements.ts b/apps/web/src/lib/commands/timeline/element/split-elements.ts index 2acac683..e9742906 100644 --- a/apps/web/src/lib/commands/timeline/element/split-elements.ts +++ b/apps/web/src/lib/commands/timeline/element/split-elements.ts @@ -1,4 +1,4 @@ -import { Command } from "@/lib/commands/base-command"; +import { Command, type CommandResult } from "@/lib/commands/base-command"; import type { TimelineTrack } from "@/lib/timeline"; import { generateUUID } from "@/utils/id"; import { EditorCore } from "@/core"; @@ -9,7 +9,6 @@ import { getSourceSpanAtClipTime } from "@/lib/retime"; export class SplitElementsCommand extends Command { private savedState: TimelineTrack[] | null = null; private rightSideElements: { trackId: string; elementId: string }[] = []; - private previousSelection: { trackId: string; elementId: string }[] = []; private readonly elements: { trackId: string; elementId: string }[]; private readonly splitTime: number; private readonly retainSide: "both" | "left" | "right"; @@ -37,10 +36,9 @@ export class SplitElementsCommand extends Command { return this.rightSideElements; } - execute(): void { + execute(): CommandResult | undefined { const editor = EditorCore.getInstance(); this.savedState = editor.timeline.getTracks(); - this.previousSelection = editor.selection.getSelectedElements(); this.rightSideElements = []; const updatedTracks = this.savedState.map((track) => { @@ -173,9 +171,9 @@ export class SplitElementsCommand extends Command { editor.timeline.updateTracks(updatedTracks); if (this.rightSideElements.length > 0) { - editor.selection.setSelectedElements({ - elements: this.rightSideElements, - }); + return { + select: this.rightSideElements, + }; } } @@ -183,9 +181,6 @@ export class SplitElementsCommand extends Command { if (this.savedState) { const editor = EditorCore.getInstance(); editor.timeline.updateTracks(this.savedState); - editor.selection.setSelectedElements({ - elements: this.previousSelection, - }); } } } -- cgit v1.3.1