@affino/diagram-core 0.10.1 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -1
- package/dist/DiagramEngine.d.ts +1 -0
- package/dist/DiagramEngine.d.ts.map +1 -1
- package/dist/DiagramEngine.js +625 -49
- package/dist/geometry.d.ts +3 -1
- package/dist/geometry.d.ts.map +1 -1
- package/dist/geometry.js +44 -0
- package/dist/interaction.d.ts +7 -0
- package/dist/interaction.d.ts.map +1 -1
- package/dist/interaction.js +193 -25
- package/dist/internal/DiagramClipboardService.d.ts.map +1 -1
- package/dist/internal/DiagramClipboardService.js +43 -6
- package/dist/internal/DiagramSceneStore.d.ts.map +1 -1
- package/dist/internal/DiagramSceneStore.js +12 -2
- package/dist/internal/model.d.ts +5 -1
- package/dist/internal/model.d.ts.map +1 -1
- package/dist/types.d.ts +123 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,6 +33,38 @@ const boundedEngine = createDiagramEngine({}, { history: { maxEntries: 200 } })
|
|
|
33
33
|
|
|
34
34
|
`updateEntities` applies metadata updates to existing entities in one undoable command. Metadata is merged by key, so omitted keys remain unchanged. The command does not remove metadata keys; assigning `undefined` stores an `undefined` value. Unknown IDs are ignored, and updates with no effective changes create no history entry. Use `setEntityMetadata` to replace the complete metadata object.
|
|
35
35
|
|
|
36
|
+
### Groups
|
|
37
|
+
|
|
38
|
+
Groups are structural scene entities with stable IDs and ordered `childIds`. Group only existing, ungrouped nodes, edges, texts, shapes, or tables; ports cannot be direct children because they follow their owning node. Nested groups are rejected with a `TypeError` during scene construction, `transact()`, and deserialization.
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
engine.dispatch({ type: "groupEntities", id: "g1", ids: ["n1", "n2"] })
|
|
42
|
+
engine.dispatch({ type: "moveEntities", ids: ["g1"], delta: { x: 24, y: 0 } })
|
|
43
|
+
engine.dispatch({ type: "resizeEntities", entries: [{ id: "g1", x: 0, y: 0, width: 240, height: 128 }] })
|
|
44
|
+
engine.dispatch({ type: "ungroupEntities", ids: ["g1"] })
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Group and ungroup commands participate in undo/redo. `serialize()`, `DiagramSceneInput`, and `DiagramDocument` preserve groups and their members. Copy, paste, and duplicate remap group and member IDs together; edges between copied nodes retain their remapped port references. Deleting a group deletes its members and dependent ports/edges. Ungrouping removes only the group and keeps child IDs and geometry.
|
|
48
|
+
|
|
49
|
+
### Visual tables
|
|
50
|
+
|
|
51
|
+
`DiagramTable` is a plain text table object, not a spreadsheet. It stores a stable ID, world bounds, cells, row/column sizes, per-cell alignment, and table-level grid/border styles. Missing cell content defaults to empty text; omitted row and column sizes are initialized evenly. Tables are included in scene/document serialization, render order, hit testing, selection, move/resize, z-order, history, batch commands, copy/paste, duplicate, and delete.
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
engine.dispatch({ type: "createTable", table: {
|
|
55
|
+
id: "notes", kind: "table", x: 40, y: 40, width: 320, height: 120,
|
|
56
|
+
rowCount: 2, columnCount: 2,
|
|
57
|
+
cells: [[{ text: "Item", horizontalAlign: "center" }, { text: "Value" }], [{ text: "Relay" }, { text: "R1" }]],
|
|
58
|
+
} })
|
|
59
|
+
engine.dispatch({ type: "insertTableRow", id: "notes", index: 1 }) // zero-based insertion point, including rowCount
|
|
60
|
+
engine.dispatch({ type: "updateTableCell", id: "notes", row: 1, column: 0, cell: { text: "Breaker", verticalAlign: "middle" } })
|
|
61
|
+
engine.dispatch({ type: "updateTableStyle", id: "notes", style: { grid: { visible: true }, border: { radius: 8 } } })
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Row/column indexes are zero-based. Insert accepts indexes `0..count`; delete and resize accept `0..count-1`. Deleting the last row or column is rejected as a no-op. Empty text is valid. Tables and row/column dimensions must be finite and positive; row heights and column widths must sum to the outer table size. Alignment is `left|center|right` and `top|middle|bottom`. Line style is `solid|dashed|dotted`; colors must be non-empty strings; stroke widths, cell padding, and corner radius must be finite and non-negative. Invalid constructor/deserialization input throws `TypeError`; invalid commands return `changed: false` and create no history entry. Table cell hit testing is available through `getDiagramTableCellAt(table, worldPoint)`.
|
|
65
|
+
|
|
66
|
+
Cell edits are dispatched as one `updateTableCell` command. The Vue adapter keeps keystrokes in a local active editor and commits once on Enter, blur, or cell navigation; Escape discards the draft.
|
|
67
|
+
|
|
36
68
|
### Atomic graph edits and documents
|
|
37
69
|
|
|
38
70
|
`dispatchBatch()` applies commands against a draft in order and publishes one change and one undo entry only after every command succeeds. Set `expectedRevision` to `getDocumentRevision()` to reject stale document edits. Viewport and selection changes do not advance that revision. A rejected result contains `failedCommandIndex`, `reason`, and known `affectedIds`; the scene, subscribers, and undo/redo stacks remain untouched.
|
|
@@ -109,7 +141,7 @@ Holding Shift during a resize preserves the original aspect ratio. The modifier
|
|
|
109
141
|
|
|
110
142
|
Selected edge endpoints use `beginEdgeEndpointHandle(id, endpoint, event)`. The controller publishes an `edgeEndpointPreview` on scheduled frames and `getPreviewGeometry(id)` returns the previewed route without changing the scene. Pointer up commits one undoable `moveEdgeEndpoint`; cancel discards the preview.
|
|
111
143
|
|
|
112
|
-
Holding Shift while dragging an endpoint
|
|
144
|
+
Holding Shift while dragging an endpoint projects the vector from the stationary opposite endpoint to the nearest cardinal angle (0°, 90°, 180°, or 270°), preserving its length. After the pointer moves 4 screen pixels, the angle stays latched until Shift is released; pressing Shift again chooses a new angle from the current pointer position relative to the stationary endpoint. Port, alignment, and grid snapping preserve the cardinal angle. Orthogonal routes remain orthogonal as the endpoint-adjacent waypoint adjusts. Preview and final command use the same geometry. Selection drags retain their dominant-axis latch behavior.
|
|
113
145
|
|
|
114
146
|
Selection drags snap by default to ports, alignments, and equal spacing. Configure grid spacing and screen-space tolerance when creating the controller; the tolerance is converted to world units using the viewport zoom. The `snapGuides` snapshot field contains world-space line segments for active alignment and equal-spacing matches. Set `enabled: false` to disable drag snapping. Moving a selected edge translates free endpoints and route points while preserving node/port endpoint attachments.
|
|
115
147
|
|
package/dist/DiagramEngine.d.ts
CHANGED
|
@@ -88,6 +88,7 @@ export declare class DiagramEngine {
|
|
|
88
88
|
private isEntityLockedOrReadOnly;
|
|
89
89
|
private isEntityNonDeletable;
|
|
90
90
|
private isEntityTranslatable;
|
|
91
|
+
private isEntityResizable;
|
|
91
92
|
}
|
|
92
93
|
export declare function createDiagramEngine(initialScene?: DiagramSceneInput, options?: DiagramEngineOptions): DiagramEngine;
|
|
93
94
|
export declare function serializeScene(scene: DiagramScene): SerializedDiagramScene;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiagramEngine.d.ts","sourceRoot":"","sources":["../src/DiagramEngine.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"DiagramEngine.d.ts","sourceRoot":"","sources":["../src/DiagramEngine.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAUlB,eAAe,EACf,UAAU,EACV,qBAAqB,EACrB,SAAS,EACT,YAAY,EACZ,mBAAmB,EACnB,WAAW,EACX,yBAAyB,EAIzB,YAAY,EACZ,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,iBAAiB,EACjB,4BAA4B,EAE5B,iBAAiB,EAEjB,sBAAsB,EACtB,eAAe,EAChB,MAAM,YAAY,CAAA;AAEnB,qBAAa,aAAa;IACxB,OAAO,CAAC,KAAK,CAAmB;IAChC,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,eAAe,CAA+B;IACtD,OAAO,CAAC,YAAY,CAA4B;IAChD,O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