summaryrefslogtreecommitdiff
path: root/apps/web/src/lib/commands/timeline/element/split-elements.ts
diff options
context:
space:
mode:
authorMaze Winther <mazewinther@gmail.com>2026-04-07 04:41:27 +0200
committerMaze Winther <mazewinther@gmail.com>2026-04-07 04:41:27 +0200
commitcbd1b8212370c67b34a70dccd21bd82de72fead2 (patch)
treed97cbee2aae22c22b59c59a50e9f8a6af0ae8ccf /apps/web/src/lib/commands/timeline/element/split-elements.ts
parent4f7d401a974047d37673ee8e3840dceaaddc295c (diff)
downloadopencut-cbd1b8212370c67b34a70dccd21bd82de72fead2.tar.gz
refactor: structured track layout per scene
Diffstat (limited to 'apps/web/src/lib/commands/timeline/element/split-elements.ts')
-rw-r--r--apps/web/src/lib/commands/timeline/element/split-elements.ts20
1 files changed, 14 insertions, 6 deletions
diff --git a/apps/web/src/lib/commands/timeline/element/split-elements.ts b/apps/web/src/lib/commands/timeline/element/split-elements.ts
index 79722b4c..9799f7e8 100644
--- a/apps/web/src/lib/commands/timeline/element/split-elements.ts
+++ b/apps/web/src/lib/commands/timeline/element/split-elements.ts
@@ -1,5 +1,5 @@
import { Command, type CommandResult } from "@/lib/commands/base-command";
-import type { TimelineTrack } from "@/lib/timeline";
+import type { SceneTracks, TimelineElement } from "@/lib/timeline";
import { generateUUID } from "@/utils/id";
import { EditorCore } from "@/core";
import { isRetimableElement } from "@/lib/timeline";
@@ -7,7 +7,7 @@ import { splitAnimationsAtTime } from "@/lib/animation";
import { getSourceSpanAtClipTime } from "@/lib/retime";
export class SplitElementsCommand extends Command {
- private savedState: TimelineTrack[] | null = null;
+ private savedState: SceneTracks | null = null;
private rightSideElements: { trackId: string; elementId: string }[] = [];
private readonly elements: { trackId: string; elementId: string }[];
private readonly splitTime: number;
@@ -34,10 +34,12 @@ export class SplitElementsCommand extends Command {
execute(): CommandResult | undefined {
const editor = EditorCore.getInstance();
- this.savedState = editor.timeline.getTracks();
+ this.savedState = editor.scenes.getActiveScene().tracks;
this.rightSideElements = [];
- const updatedTracks = this.savedState.map((track) => {
+ const splitTrack = <TTrack extends { id: string; elements: TimelineElement[] }>(
+ track: TTrack,
+ ): TTrack => {
const elementsToSplit = this.elements.filter(
(target) => target.trackId === track.id,
);
@@ -148,8 +150,14 @@ export class SplitElementsCommand extends Command {
];
});
- return { ...track, elements } as typeof track;
- });
+ return { ...track, elements } as TTrack;
+ };
+
+ const updatedTracks: SceneTracks = {
+ overlay: this.savedState.overlay.map((track) => splitTrack(track)),
+ main: splitTrack(this.savedState.main),
+ audio: this.savedState.audio.map((track) => splitTrack(track)),
+ };
editor.timeline.updateTracks(updatedTracks);