diff options
Diffstat (limited to 'apps/web/src/lib/commands/timeline')
4 files changed, 35 insertions, 17 deletions
diff --git a/apps/web/src/lib/commands/timeline/clipboard/paste.ts b/apps/web/src/lib/commands/timeline/clipboard/paste.ts index 347c4f68..58199a94 100644 --- a/apps/web/src/lib/commands/timeline/clipboard/paste.ts +++ b/apps/web/src/lib/commands/timeline/clipboard/paste.ts @@ -1,9 +1,17 @@ -import { Command, type CommandResult } from "@/lib/commands/base-command"; +import { + Command, + createElementSelectionResult, + type CommandResult, +} from "@/lib/commands/base-command"; import { EditorCore } from "@/core"; import type { SceneTracks, TimelineElement } from "@/lib/timeline"; import type { ElementClipboardItem } from "@/lib/clipboard"; import { generateUUID } from "@/utils/id"; -import { applyPlacement, resolveTrackPlacement, enforceMainTrackStart } from "@/lib/timeline/placement"; +import { + applyPlacement, + resolveTrackPlacement, + enforceMainTrackStart, +} from "@/lib/timeline/placement"; import { cloneAnimations } from "@/lib/animation"; export class PasteCommand extends Command { @@ -122,7 +130,7 @@ export class PasteCommand extends Command { editor.timeline.updateTracks(updatedTracks); if (this.pastedElements.length > 0) { - return { select: this.pastedElements }; + return createElementSelectionResult(this.pastedElements); } return undefined; } @@ -183,4 +191,3 @@ function buildPastedElements({ return elementsToAdd; } - 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 ab7a4a25..c044a4e3 100644 --- a/apps/web/src/lib/commands/timeline/element/duplicate-elements.ts +++ b/apps/web/src/lib/commands/timeline/element/duplicate-elements.ts @@ -1,8 +1,15 @@ -import { Command, type CommandResult } from "@/lib/commands/base-command"; +import { + Command, + createElementSelectionResult, + type CommandResult, +} from "@/lib/commands/base-command"; import type { SceneTracks, TimelineElement } from "@/lib/timeline"; import { generateUUID } from "@/utils/id"; import { EditorCore } from "@/core"; -import { applyPlacement, resolveTrackPlacement } from "@/lib/timeline/placement"; +import { + applyPlacement, + resolveTrackPlacement, +} from "@/lib/timeline/placement"; import { cloneAnimations } from "@/lib/animation"; interface DuplicateElementsParams { @@ -91,9 +98,7 @@ export class DuplicateElementsCommand extends Command { editor.timeline.updateTracks(updatedTracks); if (this.duplicatedElements.length > 0) { - return { - select: this.duplicatedElements, - }; + return createElementSelectionResult(this.duplicatedElements); } return undefined; } diff --git a/apps/web/src/lib/commands/timeline/element/move-elements.ts b/apps/web/src/lib/commands/timeline/element/move-elements.ts index 533c85b4..782374d5 100644 --- a/apps/web/src/lib/commands/timeline/element/move-elements.ts +++ b/apps/web/src/lib/commands/timeline/element/move-elements.ts @@ -1,4 +1,8 @@ -import { Command, type CommandResult } from "@/lib/commands/base-command"; +import { + Command, + createElementSelectionResult, + type CommandResult, +} from "@/lib/commands/base-command"; import { EditorCore } from "@/core"; import type { SceneTracks, @@ -114,12 +118,12 @@ export class MoveElementCommand extends Command { }); editor.timeline.updateTracks(updatedTracks); - return { - select: this.moves.map(({ elementId, targetTrackId }) => ({ + return createElementSelectionResult( + this.moves.map(({ elementId, targetTrackId }) => ({ trackId: targetTrackId, elementId, })), - }; + ); } undo(): void { 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 0f2495f3..f172d9c4 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,8 @@ -import { Command, type CommandResult } from "@/lib/commands/base-command"; +import { + Command, + createElementSelectionResult, + type CommandResult, +} from "@/lib/commands/base-command"; import type { SceneTracks, TimelineElement } from "@/lib/timeline"; import { generateUUID } from "@/utils/id"; import { EditorCore } from "@/core"; @@ -164,9 +168,7 @@ export class SplitElementsCommand extends Command { editor.timeline.updateTracks(updatedTracks); if (this.rightSideElements.length > 0) { - return { - select: this.rightSideElements, - }; + return createElementSelectionResult(this.rightSideElements); } return undefined; } |
