task(G1): layout data model - LayoutDefinition type, Yjs layouts map, undo-tracked CRUD in CADDocument
This commit is contained in:
@@ -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(() => {
|
||||
|
||||
Reference in New Issue
Block a user