File tree Expand file tree Collapse file tree 6 files changed +51
-19
lines changed
apps/web/src/lib/commands Expand file tree Collapse file tree 6 files changed +51
-19
lines changed Original file line number Diff line number Diff line change 11import type { EditorSelectionPatch } from "@/lib/selection/editor-selection" ;
2+ import type { ElementRef } from "@/lib/timeline/types" ;
23
34export interface CommandResult {
45 selection ?: EditorSelectionPatch ;
56}
67
8+ export function createElementSelectionResult (
9+ selectedElements : ElementRef [ ] ,
10+ ) : CommandResult {
11+ return {
12+ selection : {
13+ selectedElements,
14+ selectedKeyframes : [ ] ,
15+ keyframeSelectionAnchor : null ,
16+ selectedMaskPoints : null ,
17+ } ,
18+ } ;
19+ }
20+
721export abstract class Command {
822 abstract execute ( ) : CommandResult | undefined ;
923
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ export class BatchCommand extends Command {
1010
1111 for ( const command of this . commands ) {
1212 const result = command . execute ( ) ;
13- if ( result ?. select !== undefined ) {
13+ if ( result ?. selection !== undefined ) {
1414 latestSelectionResult = result ;
1515 }
1616 }
@@ -29,7 +29,7 @@ export class BatchCommand extends Command {
2929
3030 for ( const command of this . commands ) {
3131 const result = command . redo ( ) ;
32- if ( result ?. select !== undefined ) {
32+ if ( result ?. selection !== undefined ) {
3333 latestSelectionResult = result ;
3434 }
3535 }
Original file line number Diff line number Diff line change 1- import { Command , type CommandResult } from "@/lib/commands/base-command" ;
1+ import {
2+ Command ,
3+ createElementSelectionResult ,
4+ type CommandResult ,
5+ } from "@/lib/commands/base-command" ;
26import { EditorCore } from "@/core" ;
37import type { SceneTracks , TimelineElement } from "@/lib/timeline" ;
48import type { ElementClipboardItem } from "@/lib/clipboard" ;
59import { generateUUID } from "@/utils/id" ;
6- import { applyPlacement , resolveTrackPlacement , enforceMainTrackStart } from "@/lib/timeline/placement" ;
10+ import {
11+ applyPlacement ,
12+ resolveTrackPlacement ,
13+ enforceMainTrackStart ,
14+ } from "@/lib/timeline/placement" ;
715import { cloneAnimations } from "@/lib/animation" ;
816
917export class PasteCommand extends Command {
@@ -122,7 +130,7 @@ export class PasteCommand extends Command {
122130 editor . timeline . updateTracks ( updatedTracks ) ;
123131
124132 if ( this . pastedElements . length > 0 ) {
125- return { select : this . pastedElements } ;
133+ return createElementSelectionResult ( this . pastedElements ) ;
126134 }
127135 return undefined ;
128136 }
@@ -183,4 +191,3 @@ function buildPastedElements({
183191
184192 return elementsToAdd ;
185193}
186-
Original file line number Diff line number Diff line change 1- import { Command , type CommandResult } from "@/lib/commands/base-command" ;
1+ import {
2+ Command ,
3+ createElementSelectionResult ,
4+ type CommandResult ,
5+ } from "@/lib/commands/base-command" ;
26import type { SceneTracks , TimelineElement } from "@/lib/timeline" ;
37import { generateUUID } from "@/utils/id" ;
48import { EditorCore } from "@/core" ;
5- import { applyPlacement , resolveTrackPlacement } from "@/lib/timeline/placement" ;
9+ import {
10+ applyPlacement ,
11+ resolveTrackPlacement ,
12+ } from "@/lib/timeline/placement" ;
613import { cloneAnimations } from "@/lib/animation" ;
714
815interface DuplicateElementsParams {
@@ -91,9 +98,7 @@ export class DuplicateElementsCommand extends Command {
9198 editor . timeline . updateTracks ( updatedTracks ) ;
9299
93100 if ( this . duplicatedElements . length > 0 ) {
94- return {
95- select : this . duplicatedElements ,
96- } ;
101+ return createElementSelectionResult ( this . duplicatedElements ) ;
97102 }
98103 return undefined ;
99104 }
Original file line number Diff line number Diff line change 1- import { Command , type CommandResult } from "@/lib/commands/base-command" ;
1+ import {
2+ Command ,
3+ createElementSelectionResult ,
4+ type CommandResult ,
5+ } from "@/lib/commands/base-command" ;
26import { EditorCore } from "@/core" ;
37import type {
48 SceneTracks ,
@@ -114,12 +118,12 @@ export class MoveElementCommand extends Command {
114118 } ) ;
115119
116120 editor . timeline . updateTracks ( updatedTracks ) ;
117- return {
118- select : this . moves . map ( ( { elementId, targetTrackId } ) => ( {
121+ return createElementSelectionResult (
122+ this . moves . map ( ( { elementId, targetTrackId } ) => ( {
119123 trackId : targetTrackId ,
120124 elementId,
121125 } ) ) ,
122- } ;
126+ ) ;
123127 }
124128
125129 undo ( ) : void {
Original file line number Diff line number Diff line change 1- import { Command , type CommandResult } from "@/lib/commands/base-command" ;
1+ import {
2+ Command ,
3+ createElementSelectionResult ,
4+ type CommandResult ,
5+ } from "@/lib/commands/base-command" ;
26import type { SceneTracks , TimelineElement } from "@/lib/timeline" ;
37import { generateUUID } from "@/utils/id" ;
48import { EditorCore } from "@/core" ;
@@ -164,9 +168,7 @@ export class SplitElementsCommand extends Command {
164168 editor . timeline . updateTracks ( updatedTracks ) ;
165169
166170 if ( this . rightSideElements . length > 0 ) {
167- return {
168- select : this . rightSideElements ,
169- } ;
171+ return createElementSelectionResult ( this . rightSideElements ) ;
170172 }
171173 return undefined ;
172174 }
You can’t perform that action at this time.
0 commit comments