we're basically done

This commit is contained in:
Maze Winther
2026-01-27 16:39:59 +01:00
parent af3100950e
commit 1f8391487e
70 changed files with 1230 additions and 699 deletions
+3
View File
@@ -7,6 +7,7 @@ import { RendererManager } from "./managers/renderer-manager";
import { CommandManager } from "./managers/commands";
import { SaveManager } from "./managers/save-manager";
import { AudioManager } from "./managers/audio-manager";
import { SelectionManager } from "./managers/selection-manager";
export class EditorCore {
private static instance: EditorCore | null = null;
@@ -20,6 +21,7 @@ export class EditorCore {
public readonly renderer: RendererManager;
public readonly save: SaveManager;
public readonly audio: AudioManager;
public readonly selection: SelectionManager;
private constructor() {
this.command = new CommandManager();
@@ -31,6 +33,7 @@ export class EditorCore {
this.renderer = new RendererManager(this);
this.save = new SaveManager(this);
this.audio = new AudioManager(this);
this.selection = new SelectionManager(this);
this.save.start();
}
@@ -0,0 +1,35 @@
import type { EditorCore } from "@/core";
type ElementRef = { trackId: string; elementId: string };
export class SelectionManager {
private selectedElements: ElementRef[] = [];
private listeners = new Set<() => void>();
constructor(editor: EditorCore) {
void editor;
}
getSelectedElements(): ElementRef[] {
return this.selectedElements;
}
setSelectedElements({ elements }: { elements: ElementRef[] }): void {
this.selectedElements = elements;
this.notify();
}
clearSelection(): void {
this.selectedElements = [];
this.notify();
}
subscribe(listener: () => void): () => void {
this.listeners.add(listener);
return () => this.listeners.delete(listener);
}
private notify(): void {
this.listeners.forEach((fn) => fn());
}
}
@@ -142,10 +142,10 @@ export class TimelineManager {
elements: { trackId: string; elementId: string }[];
splitTime: number;
retainSide?: "both" | "left" | "right";
}): string[] {
}): { trackId: string; elementId: string }[] {
const command = new SplitElementsCommand(elements, splitTime, retainSide);
this.editor.command.execute({ command });
return command.splitElementIds;
return command.getRightSideElements();
}
getTotalDuration(): number {
@@ -184,9 +184,10 @@ export class TimelineManager {
}: {
time: number;
clipboardItems: ClipboardItem[];
}): void {
}): { trackId: string; elementId: string }[] {
const command = new PasteCommand(time, clipboardItems);
this.editor.command.execute({ command });
return command.getPastedElements();
}
deleteElements({
@@ -230,9 +231,10 @@ export class TimelineManager {
elements,
}: {
elements: { trackId: string; elementId: string }[];
}): void {
}): { trackId: string; elementId: string }[] {
const command = new DuplicateElementsCommand({ elements });
this.editor.command.execute({ command });
return command.getDuplicatedElements();
}
toggleElementsVisibility({