summaryrefslogtreecommitdiff
path: root/apps/web/src/lib/commands
diff options
context:
space:
mode:
Diffstat (limited to 'apps/web/src/lib/commands')
-rw-r--r--apps/web/src/lib/commands/batch-command.ts25
-rw-r--r--apps/web/src/lib/commands/index.ts1
2 files changed, 26 insertions, 0 deletions
diff --git a/apps/web/src/lib/commands/batch-command.ts b/apps/web/src/lib/commands/batch-command.ts
new file mode 100644
index 00000000..05b51d38
--- /dev/null
+++ b/apps/web/src/lib/commands/batch-command.ts
@@ -0,0 +1,25 @@
+import { Command } from "./base-command";
+
+export class BatchCommand extends Command {
+ constructor(private commands: Command[]) {
+ super();
+ }
+
+ execute(): void {
+ for (const command of this.commands) {
+ command.execute();
+ }
+ }
+
+ undo(): void {
+ for (const command of [...this.commands].reverse()) {
+ command.undo();
+ }
+ }
+
+ redo(): void {
+ for (const command of this.commands) {
+ command.execute();
+ }
+ }
+}
diff --git a/apps/web/src/lib/commands/index.ts b/apps/web/src/lib/commands/index.ts
index 6700087b..03de07c4 100644
--- a/apps/web/src/lib/commands/index.ts
+++ b/apps/web/src/lib/commands/index.ts
@@ -1,4 +1,5 @@
export { Command } from "./base-command";
+export { BatchCommand } from "./batch-command";
export * from "./timeline";
export * from "./media";