task(G1): layout data model - LayoutDefinition type, Yjs layouts map, undo-tracked CRUD in CADDocument

This commit is contained in:
Agent Zero
2026-08-29 02:39:30 +02:00
parent d51111fc2c
commit e750a45d7a
4 changed files with 162 additions and 3 deletions
+8
View File
@@ -6,6 +6,7 @@ import * as Y from 'yjs';
import type { CADElement, CADLayer, BlockDefinition } from '../types/cad.types';
import type { ElementGroup } from '../tools/modification/GroupTool';
import type { BackgroundConfig } from '../services/backgroundService';
import type { LayoutDefinition } from '../types/cad.types';
export interface YjsDocumentData {
elements: Y.Map<CADElement>;
@@ -14,6 +15,7 @@ export interface YjsDocumentData {
meta: Y.Map<unknown>;
groups: Y.Map<ElementGroup>;
bgConfig: Y.Map<BackgroundConfig>;
layouts: Y.Map<LayoutDefinition>; // Task G1
}
export class YjsDocument {
@@ -29,6 +31,7 @@ export class YjsDocument {
meta: this.doc.getMap<unknown>('meta'),
groups: this.doc.getMap<ElementGroup>('groups'),
bgConfig: this.doc.getMap<BackgroundConfig>('bgConfig'),
layouts: this.doc.getMap<LayoutDefinition>('layouts'),
};
}
@@ -57,6 +60,11 @@ export class YjsDocument {
return Array.from(this.data.bgConfig.values());
}
/** Get all layouts as a plain array (Task G1) */
getLayouts(): LayoutDefinition[] {
return Array.from(this.data.layouts.values());
}
/** Add or update a single element */
setElement(el: CADElement): void {
this.doc.transact(() => {