mirror of
https://github.com/OpenCut-app/OpenCut.git
synced 2026-07-13 21:52:53 +02:00
28 lines
738 B
TypeScript
28 lines
738 B
TypeScript
import { Command } from "@/lib/commands/base-command";
|
|
import { EditorCore } from "@/core";
|
|
import type { TimelineTrack } from "@/types/timeline";
|
|
|
|
export class RemoveTrackCommand extends Command {
|
|
private savedState: TimelineTrack[] | null = null;
|
|
|
|
constructor(private trackId: string) {
|
|
super();
|
|
}
|
|
|
|
execute(): void {
|
|
const editor = EditorCore.getInstance();
|
|
this.savedState = editor.timeline.getTracks();
|
|
const updatedTracks = this.savedState.filter(
|
|
(track) => track.id !== this.trackId,
|
|
);
|
|
editor.timeline.updateTracks(updatedTracks);
|
|
}
|
|
|
|
undo(): void {
|
|
if (this.savedState) {
|
|
const editor = EditorCore.getInstance();
|
|
editor.timeline.updateTracks(this.savedState);
|
|
}
|
|
}
|
|
}
|