diff options
Diffstat (limited to 'apps/web/src/core/managers')
| -rw-r--r-- | apps/web/src/core/managers/timeline-manager.ts | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/apps/web/src/core/managers/timeline-manager.ts b/apps/web/src/core/managers/timeline-manager.ts index 22cba52d..ad9f7792 100644 --- a/apps/web/src/core/managers/timeline-manager.ts +++ b/apps/web/src/core/managers/timeline-manager.ts @@ -24,6 +24,7 @@ import { UpdateElementStartTimeCommand, MoveElementCommand, } from "@/lib/commands/timeline"; +import { BatchCommand } from "@/lib/commands"; import type { InsertElementParams } from "@/lib/commands/timeline/element/insert-element"; export class TimelineManager { @@ -198,17 +199,27 @@ export class TimelineManager { this.editor.command.execute({ command }); } - updateElement({ - trackId, - elementId, + updateElements({ updates, + pushHistory = true, }: { - trackId: string; - elementId: string; - updates: Partial<Record<string, unknown>>; + updates: Array<{ + trackId: string; + elementId: string; + updates: Partial<Record<string, unknown>>; + }>; + pushHistory?: boolean; }): void { - const command = new UpdateElementCommand(trackId, elementId, updates); - this.editor.command.execute({ command }); + const commands = updates.map( + ({ trackId, elementId, updates: elementUpdates }) => + new UpdateElementCommand(trackId, elementId, elementUpdates), + ); + const command = commands.length === 1 ? commands[0] : new BatchCommand(commands); + if (pushHistory) { + this.editor.command.execute({ command }); + } else { + command.execute(); + } } duplicateElements({ |
