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 --- .../lib/commands/timeline/element/duplicate-elements.ts | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'apps/web/src/lib/commands/timeline/element/duplicate-elements.ts') diff --git a/apps/web/src/lib/commands/timeline/element/duplicate-elements.ts b/apps/web/src/lib/commands/timeline/element/duplicate-elements.ts index 90e178d0..df3531eb 100644 --- a/apps/web/src/lib/commands/timeline/element/duplicate-elements.ts +++ b/apps/web/src/lib/commands/timeline/element/duplicate-elements.ts @@ -1,4 +1,4 @@ -import { Command } from "@/lib/commands/base-command"; +import { Command, type CommandResult } from "@/lib/commands/base-command"; import type { TimelineElement, TimelineTrack } from "@/lib/timeline"; import { generateUUID } from "@/utils/id"; import { EditorCore } from "@/core"; @@ -12,7 +12,6 @@ interface DuplicateElementsParams { export class DuplicateElementsCommand extends Command { private duplicatedElements: { trackId: string; elementId: string }[] = []; private savedState: TimelineTrack[] | null = null; - private previousSelection: { trackId: string; elementId: string }[] = []; private elements: DuplicateElementsParams["elements"]; constructor({ elements }: DuplicateElementsParams) { @@ -20,10 +19,9 @@ export class DuplicateElementsCommand extends Command { this.elements = elements; } - execute(): void { + execute(): CommandResult | undefined { const editor = EditorCore.getInstance(); this.savedState = editor.timeline.getTracks(); - this.previousSelection = editor.selection.getSelectedElements(); this.duplicatedElements = []; let updatedTracks = [...this.savedState]; @@ -89,9 +87,9 @@ export class DuplicateElementsCommand extends Command { editor.timeline.updateTracks(updatedTracks); if (this.duplicatedElements.length > 0) { - editor.selection.setSelectedElements({ - elements: this.duplicatedElements, - }); + return { + select: this.duplicatedElements, + }; } } @@ -99,9 +97,6 @@ export class DuplicateElementsCommand extends Command { if (this.savedState) { const editor = EditorCore.getInstance(); editor.timeline.updateTracks(this.savedState); - editor.selection.setSelectedElements({ - elements: this.previousSelection, - }); } } -- cgit v1.3.1