diff options
| author | Maze Winther <mazewinther@gmail.com> | 2026-03-31 23:40:59 +0200 |
|---|---|---|
| committer | Maze Winther <mazewinther@gmail.com> | 2026-03-31 23:40:59 +0200 |
| commit | b048b739bd598f9d9ff97166f29bcb6e37c40607 (patch) | |
| tree | 3aaa2c11331b6b65a40142b0294b2ceb340e6531 /apps/web/src/core/managers | |
| parent | 608dc1a62fdb133e218f45796cf936bdfb27c7ae (diff) | |
| parent | dc82826951c03cca91ea1431b0b8abdfd9dba583 (diff) | |
| download | opencut-b048b739bd598f9d9ff97166f29bcb6e37c40607.tar.gz | |
Merge branch 'refactor-selection-commands'
Diffstat (limited to 'apps/web/src/core/managers')
| -rw-r--r-- | apps/web/src/core/managers/commands.ts | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/apps/web/src/core/managers/commands.ts b/apps/web/src/core/managers/commands.ts index 4c53857b..918fc33e 100644 --- a/apps/web/src/core/managers/commands.ts +++ b/apps/web/src/core/managers/commands.ts @@ -11,6 +11,7 @@ interface CommandHistoryEntry { export class CommandManager { private history: CommandHistoryEntry[] = []; private redoStack: CommandHistoryEntry[] = []; + private reactors: Array<() => void> = []; constructor(private editor: EditorCore) {} @@ -18,6 +19,7 @@ export class CommandManager { const previousSelection = this.getSelectionSnapshot(); const result = command.execute(); const selectionOverride = this.applySelectionOverride(result); + this.runReactors(); this.history.push({ command, previousSelection, @@ -35,6 +37,10 @@ export class CommandManager { this.redoStack = []; } + registerReactor(reactor: () => void): void { + this.reactors.push(reactor); + } + undo(): void { if (this.history.length === 0) return; const entry = this.history.pop(); @@ -64,6 +70,7 @@ export class CommandManager { const previousSelection = this.getSelectionSnapshot(); const result = entry.command.redo(); const selectionOverride = this.applySelectionOverride(result); + this.runReactors(); this.history.push({ command: entry.command, @@ -100,4 +107,10 @@ export class CommandManager { this.editor.selection.setSelectedElements({ elements: selectionOverride }); return selectionOverride; } + + private runReactors(): void { + for (const reactor of this.reactors) { + reactor(); + } + } } |
