diff --git a/index.html b/index.html index aebe37d0..b76359f6 100644 --- a/index.html +++ b/index.html @@ -3,6 +3,7 @@ + WebEditor3D diff --git a/playwright.config.ts b/playwright.config.ts index 443159ab..921b227a 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -2,6 +2,7 @@ import { defineConfig, devices } from "@playwright/test"; export default defineConfig({ testDir: "./tests/e2e", + testMatch: ["**/*.e2e.ts"], timeout: 30_000, expect: { timeout: 5_000 diff --git a/public/favicon.svg b/public/favicon.svg new file mode 100644 index 00000000..876d2ada --- /dev/null +++ b/public/favicon.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/app/editor-store.ts b/src/app/editor-store.ts index e588819d..8aaf3dd6 100644 --- a/src/app/editor-store.ts +++ b/src/app/editor-store.ts @@ -37,6 +37,7 @@ export class EditorStore { private readonly storage: KeyValueStorage | null; private readonly storageKey: string; private lastCommandLabel: string | null = null; + private snapshot: EditorStoreState; private readonly commandContext: CommandContext = { getDocument: () => this.document, @@ -57,6 +58,7 @@ export class EditorStore { this.document = options.initialDocument ?? createEmptySceneDocument(); this.storage = options.storage ?? null; this.storageKey = options.storageKey ?? DEFAULT_SCENE_DRAFT_STORAGE_KEY; + this.snapshot = this.createSnapshot(); } subscribe = (listener: EditorStoreListener) => { @@ -67,14 +69,7 @@ export class EditorStore { }; }; - getState = (): EditorStoreState => ({ - document: this.document, - selection: this.selection, - toolMode: this.toolMode, - canUndo: this.history.canUndo(), - canRedo: this.history.canRedo(), - lastCommandLabel: this.lastCommandLabel - }); + getState = (): EditorStoreState => this.snapshot; setToolMode(toolMode: ToolMode) { if (this.toolMode === toolMode) { @@ -168,10 +163,23 @@ export class EditorStore { } private emit() { + this.snapshot = this.createSnapshot(); + for (const listener of this.listeners) { listener(); } } + + private createSnapshot(): EditorStoreState { + return { + document: this.document, + selection: this.selection, + toolMode: this.toolMode, + canUndo: this.history.canUndo(), + canRedo: this.history.canRedo(), + lastCommandLabel: this.lastCommandLabel + }; + } } export function createEditorStore(options?: EditorStoreOptions): EditorStore {