@affino/diagram-core 0.10.2 → 0.11.1

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.
@@ -1,10 +1,12 @@
1
- import type { DiagramEdge, DiagramEdgeEndpoint, DiagramEntities, DiagramGeometry, DiagramId, DiagramPoint, DiagramPort, DiagramRect } from "./types.js";
1
+ import type { DiagramEdge, DiagramEdgeEndpoint, DiagramEntities, DiagramGeometry, DiagramId, DiagramPoint, DiagramPort, DiagramRect, DiagramTable, DiagramTableCellPosition } from "./types.js";
2
2
  export declare function rectIntersects(a: DiagramRect, b: DiagramRect): boolean;
3
3
  export declare function rectContainsPoint(rect: DiagramRect, point: DiagramPoint, radius?: number): boolean;
4
4
  export declare function rectFromPoints(points: ReadonlyArray<DiagramPoint>): DiagramRect;
5
5
  export declare function inflateRect(rect: DiagramRect, amount: number): DiagramRect;
6
6
  export declare function rectCenter(rect: DiagramRect): DiagramPoint;
7
7
  export declare function distance(a: DiagramPoint, b: DiagramPoint): number;
8
+ /** Returns the zero-based table cell at a world-space point, or null when outside the table. */
9
+ export declare function getDiagramTableCellAt(table: DiagramTable, point: DiagramPoint): DiagramTableCellPosition | null;
8
10
  export declare function createEntityGeometry(id: DiagramId, entities: DiagramEntities): DiagramGeometry | null;
9
11
  export declare function resolveEdgePath(edge: DiagramEdge, entities: DiagramEntities): ReadonlyArray<DiagramPoint>;
10
12
  export declare function resolveEndpoint(endpoint: DiagramEdgeEndpoint, entities: DiagramEntities): DiagramPoint;
@@ -1 +1 @@
1
- {"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../src/geometry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,eAAe,EAAE,eAAe,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAEvJ,wBAAgB,cAAc,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,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,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,GAAG,YAAY,CASrG"}
package/dist/geometry.js CHANGED
@@ -37,6 +37,28 @@ export function rectCenter(rect) {
37
37
  export function distance(a, b) {
38
38
  return Math.hypot(a.x - b.x, a.y - b.y);
39
39
  }
40
+ /** Returns the zero-based table cell at a world-space point, or null when outside the table. */
41
+ export function getDiagramTableCellAt(table, point) {
42
+ var _a, _b;
43
+ if (point.x < table.x || point.y < table.y || point.x > table.x + table.width || point.y > table.y + table.height)
44
+ return null;
45
+ const columnWidths = (_a = table.columnWidths) !== null && _a !== void 0 ? _a : Array(table.columnCount).fill(table.width / table.columnCount);
46
+ const rowHeights = (_b = table.rowHeights) !== null && _b !== void 0 ? _b : Array(table.rowCount).fill(table.height / table.rowCount);
47
+ const column = findCellIndex(point.x - table.x, columnWidths, table.width);
48
+ const row = findCellIndex(point.y - table.y, rowHeights, table.height);
49
+ return { row, column };
50
+ }
51
+ function findCellIndex(offset, sizes, total) {
52
+ if (offset >= total)
53
+ return sizes.length - 1;
54
+ let edge = 0;
55
+ for (let index = 0; index < sizes.length; index += 1) {
56
+ edge += sizes[index];
57
+ if (offset < edge)
58
+ return index;
59
+ }
60
+ return Math.max(0, sizes.length - 1);
61
+ }
40
62
  export function createEntityGeometry(id, entities) {
41
63
  var _a, _b, _c, _d, _e, _f, _g, _h;
42
64
  const node = entities.nodesById.get(id);
@@ -66,6 +88,19 @@ export function createEntityGeometry(id, entities) {
66
88
  if (shape) {
67
89
  return rectGeometry(id, "shape", { x: shape.x, y: shape.y, width: shape.width, height: shape.height }, (_h = shape.rotation) !== null && _h !== void 0 ? _h : 0, 3);
68
90
  }
91
+ const group = entities.groupsById.get(id);
92
+ if (group) {
93
+ const bounds = unionRects(group.childIds
94
+ .filter((childId) => childId !== id)
95
+ .map((childId) => { var _a; return (_a = createEntityGeometry(childId, entities)) === null || _a === void 0 ? void 0 : _a.bounds; })
96
+ .filter((rect) => Boolean(rect)));
97
+ if (!bounds)
98
+ return null;
99
+ return { id, kind: "group", bounds, unrotatedBounds: bounds, rotation: 0, hitBounds: inflateRect(bounds, 6) };
100
+ }
101
+ const table = entities.tablesById.get(id);
102
+ if (table)
103
+ return rectGeometry(id, "table", { x: table.x, y: table.y, width: table.width, height: table.height }, 0, 3);
69
104
  return null;
70
105
  }
71
106
  export function resolveEdgePath(edge, entities) {
@@ -129,3 +164,12 @@ function normalizeRotation(rotation) {
129
164
  const normalized = rotation % 360;
130
165
  return normalized < 0 ? normalized + 360 : normalized;
131
166
  }
167
+ function unionRects(rects) {
168
+ if (!rects.length)
169
+ return null;
170
+ const minX = Math.min(...rects.map((rect) => rect.x));
171
+ const minY = Math.min(...rects.map((rect) => rect.y));
172
+ const maxX = Math.max(...rects.map((rect) => rect.x + rect.width));
173
+ const maxY = Math.max(...rects.map((rect) => rect.y + rect.height));
174
+ return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
175
+ }
@@ -49,7 +49,7 @@ export declare class DiagramInteractionController {
49
49
  pointerMove(event: DiagramPointerEvent): void;
50
50
  pointerUp(event: DiagramPointerEvent): void;
51
51
  cancel(): void;
52
- /** Returns the renderer-ready geometry for the active move preview. */
52
+ /** Returns renderer-ready geometry for active move and table resize previews. */
53
53
  getPreviewGeometry(id: DiagramId): DiagramGeometry | null;
54
54
  getSnapshot(): DiagramInteractionSnapshot;
55
55
  getPendingMoveCount(): number;
@@ -59,6 +59,8 @@ export declare class DiagramInteractionController {
59
59
  private createSelectionResizePreviewEntries;
60
60
  private createResizePreview;
61
61
  private resizeGridSize;
62
+ private expandedDragSelectionIds;
63
+ private isDraggedEntity;
62
64
  private updateShiftAxis;
63
65
  private isPastAxisActivation;
64
66
  private createOrthogonalWaypointPreview;
@@ -1 +1 @@
1
- {"version":3,"file":"interaction.d.ts","sourceRoot":"","sources":["../src/interaction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACv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AAmB,GAAG,IAAI;IAiD3C,MAAM,IAAI,IAAI;IAKd,iFAAiF;IACjF,kBAAkB,CAAC,EAAE,EAAE,SAAS,GAAG,eAAe,GAAG,IAAI;IAwEzD,WAAW,IAAI,0BAA0B;IAezC,mBAAmB,IAAI,MAAM;IAI7B,cAAc,IAAI,MAAM;IAIxB,OAAO,CAAC,gBAAgB;IAwExB,OAAO,CAAC,0BAA0B;IAQlC,OAAO,CAAC,mCAAmC;IAqB3C,OAAO,CAAC,mBAAmB;IAoB3B,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,wBAAwB;IAShC,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,eAAe;IAyBvB,OAAO,CAAC,oBAAoB;IAM5B,OAAO,CAAC,+BAA+B;IA8BvC,OAAO,CAAC,sBAAsB;IAoB9B,OAAO,CAAC,YAAY;CA4BrB;AAaD,wBAAgB,kCAAkC,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,GAAE,yBAA8B,GAAG,4BAA4B,CAE/I"}
@@ -232,6 +232,9 @@ export class DiagramInteractionController {
232
232
  return;
233
233
  }
234
234
  }
235
+ const ownerGroup = [...this.engine.getScene().entities.groupsById.values()].find((group) => group.childIds.includes(targetId));
236
+ if (ownerGroup)
237
+ targetId = ownerGroup.id;
235
238
  const selection = this.engine.getScene().selection;
236
239
  if (event.shiftKey) {
237
240
  this.engine.dispatch({ type: "setSelection", selection: { ids: [targetId], primaryId: targetId }, mode: "toggle" });
@@ -388,14 +391,39 @@ export class DiagramInteractionController {
388
391
  this.clearGesture();
389
392
  this.tool = "select";
390
393
  }
391
- /** Returns the renderer-ready geometry for the active move preview. */
394
+ /** Returns renderer-ready geometry for active move and table resize previews. */
392
395
  getPreviewGeometry(id) {
393
- var _a, _b, _c, _d, _e;
396
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
394
397
  const geometry = this.engine.getGeometrySnapshot(id);
395
- if ((geometry === null || geometry === void 0 ? void 0 : geometry.kind) === "edge" && ((_a = geometry.path) === null || _a === void 0 ? void 0 : _a.length) && this.edgeEndpointId === id && this.edgeEndpointKind && this.edgeEndpointPreview) {
398
+ if ((geometry === null || geometry === void 0 ? void 0 : geometry.kind) === "table") {
399
+ const directEntry = this.resizePreviewEntries.find((entry) => entry.id === id);
400
+ if (directEntry)
401
+ return resizePreviewGeometry(geometry, directEntry);
402
+ if (this.tool === "resize-selection") {
403
+ const scene = this.engine.getScene();
404
+ const ownerGroup = [...scene.entities.groupsById.values()].find((group) => group.childIds.includes(id));
405
+ const groupEntry = ownerGroup ? this.resizePreviewEntries.find((entry) => entry.id === ownerGroup.id) : undefined;
406
+ const groupGeometry = ownerGroup && groupEntry ? this.engine.getGeometrySnapshot(ownerGroup.id) : null;
407
+ if (ownerGroup && groupEntry && groupGeometry) {
408
+ const from = groupGeometry.bounds;
409
+ const to = { x: (_a = groupEntry.x) !== null && _a !== void 0 ? _a : from.x, y: (_b = groupEntry.y) !== null && _b !== void 0 ? _b : from.y, width: (_c = groupEntry.width) !== null && _c !== void 0 ? _c : from.width, height: (_d = groupEntry.height) !== null && _d !== void 0 ? _d : from.height };
410
+ const scaleX = from.width === 0 ? 1 : to.width / from.width;
411
+ const scaleY = from.height === 0 ? 1 : to.height / from.height;
412
+ const tableBounds = (_e = geometry.unrotatedBounds) !== null && _e !== void 0 ? _e : geometry.bounds;
413
+ return resizePreviewGeometry(geometry, {
414
+ id,
415
+ x: to.x + (tableBounds.x - from.x) * scaleX,
416
+ y: to.y + (tableBounds.y - from.y) * scaleY,
417
+ width: tableBounds.width * scaleX,
418
+ height: tableBounds.height * scaleY,
419
+ });
420
+ }
421
+ }
422
+ }
423
+ if ((geometry === null || geometry === void 0 ? void 0 : geometry.kind) === "edge" && ((_f = geometry.path) === null || _f === void 0 ? void 0 : _f.length) && this.edgeEndpointId === id && this.edgeEndpointKind && this.edgeEndpointPreview) {
396
424
  const path = [
397
425
  this.edgeEndpointKind === "source" ? this.edgeEndpointPreview : geometry.path[0],
398
- ...((_b = this.edgeWaypointPreview) !== null && _b !== void 0 ? _b : geometry.path.slice(1, -1)),
426
+ ...((_g = this.edgeWaypointPreview) !== null && _g !== void 0 ? _g : geometry.path.slice(1, -1)),
399
427
  this.edgeEndpointKind === "target" ? this.edgeEndpointPreview : geometry.path[geometry.path.length - 1],
400
428
  ];
401
429
  const bounds = boundsFromPoints(path);
@@ -407,7 +435,7 @@ export class DiagramInteractionController {
407
435
  const edge = scene.entities.edgesById.get(id);
408
436
  if (geometry.kind === "edge" && edge) {
409
437
  const delta = this.previewDelta;
410
- const moved = new Set(this.dragSelectionIds);
438
+ const moved = new Set(this.expandedDragSelectionIds());
411
439
  const endpointMoves = (endpoint) => {
412
440
  var _a, _b;
413
441
  return endpoint.kind === "point"
@@ -416,7 +444,7 @@ export class DiagramInteractionController {
416
444
  ? moved.has(endpoint.nodeId)
417
445
  : moved.has((_b = (_a = scene.entities.portsById.get(endpoint.portId)) === null || _a === void 0 ? void 0 : _a.nodeId) !== null && _b !== void 0 ? _b : "");
418
446
  };
419
- const path = (_c = geometry.path) === null || _c === void 0 ? void 0 : _c.map((point, index) => {
447
+ const path = (_h = geometry.path) === null || _h === void 0 ? void 0 : _h.map((point, index) => {
420
448
  var _a, _b;
421
449
  const isSource = index === 0;
422
450
  const isTarget = index === ((_b = (_a = geometry.path) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) - 1;
@@ -431,7 +459,7 @@ export class DiagramInteractionController {
431
459
  return Object.freeze({ ...geometry, path: Object.freeze(path), bounds, hitBounds: inflateRect(bounds, 6) });
432
460
  }
433
461
  }
434
- if (!this.dragSelectionIds.includes(id))
462
+ if (!this.isDraggedEntity(id))
435
463
  return geometry;
436
464
  const move = (point) => ({ x: point.x + this.previewDelta.x, y: point.y + this.previewDelta.y });
437
465
  return Object.freeze({
@@ -439,8 +467,8 @@ export class DiagramInteractionController {
439
467
  bounds: { ...geometry.bounds, x: geometry.bounds.x + this.previewDelta.x, y: geometry.bounds.y + this.previewDelta.y },
440
468
  hitBounds: { ...geometry.hitBounds, x: geometry.hitBounds.x + this.previewDelta.x, y: geometry.hitBounds.y + this.previewDelta.y },
441
469
  unrotatedBounds: geometry.unrotatedBounds ? { ...geometry.unrotatedBounds, x: geometry.unrotatedBounds.x + this.previewDelta.x, y: geometry.unrotatedBounds.y + this.previewDelta.y } : undefined,
442
- corners: (_d = geometry.corners) === null || _d === void 0 ? void 0 : _d.map(move),
443
- path: (_e = geometry.path) === null || _e === void 0 ? void 0 : _e.map(move),
470
+ corners: (_j = geometry.corners) === null || _j === void 0 ? void 0 : _j.map(move),
471
+ path: (_k = geometry.path) === null || _k === void 0 ? void 0 : _k.map(move),
444
472
  point: geometry.point ? move(geometry.point) : undefined,
445
473
  });
446
474
  }
@@ -482,7 +510,8 @@ export class DiagramInteractionController {
482
510
  const viewport = this.engine.getScene().viewport;
483
511
  const zoom = viewport.zoom > 0 ? viewport.zoom : 1;
484
512
  const selection = this.engine.getScene().selection;
485
- const snapped = this.engine.snapTranslation({ ...selection, ids: this.dragSelectionIds, primaryId: this.dragSelectionIds.includes((_b = selection.primaryId) !== null && _b !== void 0 ? _b : "") ? selection.primaryId : (_c = this.dragSelectionIds[0]) !== null && _c !== void 0 ? _c : null }, constrainedDelta, {
513
+ const snapIds = [...new Set([...this.dragSelectionIds, ...this.expandedDragSelectionIds()])];
514
+ const snapped = this.engine.snapTranslation({ ...selection, ids: snapIds, primaryId: this.dragSelectionIds.includes((_b = selection.primaryId) !== null && _b !== void 0 ? _b : "") ? selection.primaryId : (_c = this.dragSelectionIds[0]) !== null && _c !== void 0 ? _c : null }, constrainedDelta, {
486
515
  radius: ((_d = this.snapOptions.tolerancePx) !== null && _d !== void 0 ? _d : 6) / zoom,
487
516
  gridSize: this.snapOptions.gridSize,
488
517
  axisConstraint,
@@ -593,6 +622,22 @@ export class DiagramInteractionController {
593
622
  resizeGridSize() {
594
623
  return !this.latestShiftKey || this.snapOptions.enabled === false ? undefined : this.snapOptions.gridSize;
595
624
  }
625
+ expandedDragSelectionIds() {
626
+ var _a, _b;
627
+ const groups = this.engine.getScene().entities.groupsById;
628
+ const ids = new Set(this.dragSelectionIds);
629
+ for (const id of this.dragSelectionIds) {
630
+ for (const childId of (_b = (_a = groups.get(id)) === null || _a === void 0 ? void 0 : _a.childIds) !== null && _b !== void 0 ? _b : [])
631
+ ids.add(childId);
632
+ }
633
+ return [...ids];
634
+ }
635
+ isDraggedEntity(id) {
636
+ if (this.dragSelectionIds.includes(id))
637
+ return true;
638
+ const groups = this.engine.getScene().entities.groupsById;
639
+ return this.dragSelectionIds.some((groupId) => { var _a; return ((_a = groups.get(groupId)) === null || _a === void 0 ? void 0 : _a.childIds.includes(id)) === true; });
640
+ }
596
641
  updateShiftAxis(shiftKey, point) {
597
642
  const wasShifted = this.latestShiftKey;
598
643
  this.latestShiftKey = shiftKey;
@@ -664,12 +709,17 @@ export class DiagramInteractionController {
664
709
  getMarqueeSelectionIds(rect) {
665
710
  const visible = new Set(this.engine.queryVisible(rect));
666
711
  const scene = this.engine.getScene();
712
+ const groupedChildren = new Set([...scene.entities.groupsById.values()].flatMap((group) => group.childIds));
667
713
  return [
714
+ ...scene.order.groupIds,
668
715
  ...scene.order.nodeIds,
669
716
  ...scene.order.shapeIds,
717
+ ...scene.order.tableIds,
670
718
  ...scene.order.textIds,
671
719
  ...scene.order.edgeIds,
672
720
  ].filter((id) => {
721
+ if (groupedChildren.has(id))
722
+ return false;
673
723
  if (!visible.has(id))
674
724
  return false;
675
725
  if (this.marqueeMode === "intersect")
@@ -707,6 +757,17 @@ export class DiagramInteractionController {
707
757
  this.pendingMoveCount = 0;
708
758
  }
709
759
  }
760
+ function resizePreviewGeometry(geometry, entry) {
761
+ var _a, _b, _c, _d, _e;
762
+ const previous = (_a = geometry.unrotatedBounds) !== null && _a !== void 0 ? _a : geometry.bounds;
763
+ const bounds = {
764
+ x: (_b = entry.x) !== null && _b !== void 0 ? _b : previous.x,
765
+ y: (_c = entry.y) !== null && _c !== void 0 ? _c : previous.y,
766
+ width: (_d = entry.width) !== null && _d !== void 0 ? _d : previous.width,
767
+ height: (_e = entry.height) !== null && _e !== void 0 ? _e : previous.height,
768
+ };
769
+ return Object.freeze({ ...geometry, bounds, unrotatedBounds: bounds, hitBounds: inflateRect(bounds, 3), rotation: 0 });
770
+ }
710
771
  export function createDiagramInteractionController(engine, options = {}) {
711
772
  return new DiagramInteractionController(engine, options);
712
773
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DiagramClipboardService.d.ts","sourceRoot":"","sources":["../../src/internal/DiagramClipboardService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAoC,SAAS,EAAe,YAAY,EAAE,gBAAgB,EAA6B,MAAM,aAAa,CAAA;AACxK,OAAO,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAEtD,KAAK,kBAAkB,GAAG,CAAC,GAAG,EAAE,aAAa,CAAC,SAAS,CAAC,KAAK,KAAK,CAAA;AAClE,KAAK,kBAAkB,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,SAAS,KAAK,gBAAgB,CAAA;AAEhG,qBAAa,uBAAuB;IAClC,cAAc,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,aAAa,CAAC,SAAS,CAAC,EAAE,kBAAkB,EAAE,kBAAkB,GAAG,gBAAgB;IAyB7H,gBAAgB,CAAC,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,EAAE,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,kBAAkB,GAAG,KAAK,GAAG,IAAI;CA4BvL"}
1
+ {"version":3,"file":"DiagramClipboardService.d.ts","sourceRoot":"","sources":["../../src/internal/DiagramClipboardService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAkD,SAAS,EAAe,YAAY,EAAE,gBAAgB,EAA2C,MAAM,aAAa,CAAA;AACpM,OAAO,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAEtD,KAAK,kBAAkB,GAAG,CAAC,GAAG,EAAE,aAAa,CAAC,SAAS,CAAC,KAAK,KAAK,CAAA;AAClE,KAAK,kBAAkB,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,SAAS,KAAK,gBAAgB,CAAA;AAEhG,qBAAa,uBAAuB;IAClC,cAAc,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,aAAa,CAAC,SAAS,CAAC,EAAE,kBAAkB,EAAE,kBAAkB,GAAG,gBAAgB;IA2C7H,gBAAgB,CAAC,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,EAAE,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,kBAAkB,GAAG,KAAK,GAAG,IAAI;CAkCvL"}
@@ -1,6 +1,26 @@
1
1
  export class DiagramClipboardService {
2
2
  exportSubgraph(state, ids, normalizeSelection) {
3
- const selected = new Set(ids);
3
+ const selected = new Set();
4
+ for (const id of ids) {
5
+ const group = state.entities.groupsById.get(id);
6
+ if (group) {
7
+ selected.add(id);
8
+ for (const childId of group.childIds)
9
+ selected.add(childId);
10
+ continue;
11
+ }
12
+ const owner = [...state.entities.groupsById.values()].find((candidate) => candidate.childIds.includes(id));
13
+ if (owner) {
14
+ selected.add(owner.id);
15
+ for (const childId of owner.childIds)
16
+ selected.add(childId);
17
+ }
18
+ else
19
+ selected.add(id);
20
+ }
21
+ const groups = state.order.groupIds
22
+ .map((id) => state.entities.groupsById.get(id))
23
+ .filter((group) => group !== undefined && selected.has(group.id));
4
24
  const nodes = state.order.nodeIds
5
25
  .map((id) => state.entities.nodesById.get(id))
6
26
  .filter((entity) => entity !== undefined && selected.has(entity.id));
@@ -19,30 +39,36 @@ export class DiagramClipboardService {
19
39
  shapes: state.order.shapeIds
20
40
  .map((id) => state.entities.shapesById.get(id))
21
41
  .filter((entity) => entity !== undefined && selected.has(entity.id)),
42
+ tables: state.order.tableIds.map((id) => state.entities.tablesById.get(id)).filter((entity) => entity !== undefined && selected.has(entity.id)),
43
+ groups,
22
44
  selection: normalizeSelection({ ids: [...selected], primaryId: state.selection.primaryId }),
23
45
  viewport: state.viewport,
24
46
  };
25
47
  }
26
48
  createPastePatch(state, clipboard, offset, createDeletePatch, normalizeSelection) {
49
+ var _a, _b, _c, _d;
27
50
  const remap = new Map();
28
51
  const reserve = (id) => {
29
52
  const next = uniqueId(state, `${id}-copy`, remap.size + 1);
30
53
  remap.set(id, next);
31
54
  return next;
32
55
  };
33
- for (const entity of [...clipboard.nodes, ...clipboard.ports, ...clipboard.edges, ...clipboard.texts, ...clipboard.shapes])
56
+ for (const entity of [...clipboard.nodes, ...clipboard.ports, ...clipboard.edges, ...clipboard.texts, ...clipboard.shapes, ...((_a = clipboard.groups) !== null && _a !== void 0 ? _a : []), ...((_b = clipboard.tables) !== null && _b !== void 0 ? _b : [])])
34
57
  reserve(entity.id);
35
58
  const nodes = clipboard.nodes.map((node) => { var _a; return ({ ...node, id: remap.get(node.id), x: node.x + offset.x, y: node.y + offset.y, portIds: (_a = node.portIds) === null || _a === void 0 ? void 0 : _a.map((id) => { var _a; return (_a = remap.get(id)) !== null && _a !== void 0 ? _a : id; }) }); });
36
59
  const ports = clipboard.ports.map((port) => { var _a; return ({ ...port, id: remap.get(port.id), nodeId: (_a = remap.get(port.nodeId)) !== null && _a !== void 0 ? _a : port.nodeId }); });
37
60
  const edges = clipboard.edges.map((edge) => { var _a; return ({ ...edge, id: remap.get(edge.id), source: remapEndpoint(edge.source, remap), target: remapEndpoint(edge.target, remap), points: (_a = edge.points) === null || _a === void 0 ? void 0 : _a.map((point) => ({ x: point.x + offset.x, y: point.y + offset.y })) }); });
38
61
  const texts = clipboard.texts.map((text) => ({ ...text, id: remap.get(text.id), x: text.x + offset.x, y: text.y + offset.y }));
39
62
  const shapes = clipboard.shapes.map((shape) => ({ ...shape, id: remap.get(shape.id), x: shape.x + offset.x, y: shape.y + offset.y }));
40
- const pastedIds = [...nodes, ...ports, ...edges, ...texts, ...shapes].map((entity) => entity.id);
63
+ const groups = ((_c = clipboard.groups) !== null && _c !== void 0 ? _c : []).map((group) => ({ ...group, id: remap.get(group.id), childIds: group.childIds.map((id) => { var _a; return (_a = remap.get(id)) !== null && _a !== void 0 ? _a : id; }) }));
64
+ const tables = ((_d = clipboard.tables) !== null && _d !== void 0 ? _d : []).map((table) => ({ ...table, id: remap.get(table.id), x: table.x + offset.x, y: table.y + offset.y }));
65
+ const pastedIds = [...nodes, ...ports, ...edges, ...texts, ...shapes, ...groups, ...tables].map((entity) => entity.id);
41
66
  if (!pastedIds.length)
42
67
  return null;
43
68
  return {
69
+ orderChanged: true,
44
70
  apply: (next) => {
45
- var _a, _b, _c, _d, _e, _f, _g, _h;
71
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
46
72
  for (const node of nodes) {
47
73
  next.entities.nodesById.set(node.id, node);
48
74
  next.order.nodeIds.push(node.id);
@@ -67,7 +93,18 @@ export class DiagramClipboardService {
67
93
  next.order.shapeIds.push(shape.id);
68
94
  next.versions.set(shape.id, 0);
69
95
  }
70
- next.selection = normalizeSelection({ ids: pastedIds.filter((id) => !next.entities.portsById.has(id)), primaryId: (_h = (_f = (_d = (_b = (_a = nodes[0]) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : (_c = texts[0]) === null || _c === void 0 ? void 0 : _c.id) !== null && _d !== void 0 ? _d : (_e = shapes[0]) === null || _e === void 0 ? void 0 : _e.id) !== null && _f !== void 0 ? _f : (_g = edges[0]) === null || _g === void 0 ? void 0 : _g.id) !== null && _h !== void 0 ? _h : null });
96
+ for (const group of groups) {
97
+ next.entities.groupsById.set(group.id, group);
98
+ next.order.groupIds.push(group.id);
99
+ next.versions.set(group.id, 0);
100
+ }
101
+ for (const table of tables) {
102
+ next.entities.tablesById.set(table.id, table);
103
+ next.order.tableIds.push(table.id);
104
+ next.versions.set(table.id, 0);
105
+ }
106
+ const selectedIds = groups.length ? groups.map((group) => group.id) : pastedIds.filter((id) => !next.entities.portsById.has(id));
107
+ next.selection = normalizeSelection({ ids: selectedIds, primaryId: (_k = (_h = (_f = (_d = (_b = (_a = groups[0]) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : (_c = nodes[0]) === null || _c === void 0 ? void 0 : _c.id) !== null && _d !== void 0 ? _d : (_e = texts[0]) === null || _e === void 0 ? void 0 : _e.id) !== null && _f !== void 0 ? _f : (_g = shapes[0]) === null || _g === void 0 ? void 0 : _g.id) !== null && _h !== void 0 ? _h : (_j = edges[0]) === null || _j === void 0 ? void 0 : _j.id) !== null && _k !== void 0 ? _k : null });
71
108
  return new Set([...pastedIds, "selection"]);
72
109
  },
73
110
  inverse: createDeletePatch(pastedIds),
@@ -99,5 +136,5 @@ function uniqueId(state, base, seed) {
99
136
  return id;
100
137
  }
101
138
  function hasEntity(state, id) {
102
- return state.entities.nodesById.has(id) || state.entities.edgesById.has(id) || state.entities.textsById.has(id) || state.entities.shapesById.has(id) || state.entities.portsById.has(id);
139
+ return state.entities.nodesById.has(id) || state.entities.edgesById.has(id) || state.entities.textsById.has(id) || state.entities.shapesById.has(id) || state.entities.portsById.has(id) || state.entities.groupsById.has(id) || state.entities.tablesById.has(id);
103
140
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DiagramSceneStore.d.ts","sourceRoot":"","sources":["../../src/internal/DiagramSceneStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,iBAAiB,EAAoB,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEjI,OAAO,KAAK,EAAE,aAAa,EAAmB,MAAM,YAAY,CAAA;AAIhE,qBAAa,iBAAiB;IAC5B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAA;IAC7B,OAAO,CAAC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AAE,WAAW,EAAE,MAAM,IAAI,CAAA;KAAE;IAUnE,OAAO,CAAC,cAAc;IA4BtB,OAAO,CAAC,iBAAiB;CAO1B;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,iBAAiB,GAAG,aAAa,CAoC3E"}
@@ -68,7 +68,7 @@ export class DiagramSceneStore {
68
68
  };
69
69
  }
70
70
  createSnapshot(changedIds) {
71
- var _a, _b, _c, _d, _e;
71
+ var _a, _b, _c, _d, _e, _f, _g;
72
72
  return deepFreeze({
73
73
  entities: {
74
74
  nodesById: this.createReadonlyMap(this.state.entities.nodesById, (_a = this.snapshot) === null || _a === void 0 ? void 0 : _a.entities.nodesById, changedIds),
@@ -76,12 +76,16 @@ export class DiagramSceneStore {
76
76
  textsById: this.createReadonlyMap(this.state.entities.textsById, (_c = this.snapshot) === null || _c === void 0 ? void 0 : _c.entities.textsById, changedIds),
77
77
  shapesById: this.createReadonlyMap(this.state.entities.shapesById, (_d = this.snapshot) === null || _d === void 0 ? void 0 : _d.entities.shapesById, changedIds),
78
78
  portsById: this.createReadonlyMap(this.state.entities.portsById, (_e = this.snapshot) === null || _e === void 0 ? void 0 : _e.entities.portsById, changedIds),
79
+ groupsById: this.createReadonlyMap(this.state.entities.groupsById, (_f = this.snapshot) === null || _f === void 0 ? void 0 : _f.entities.groupsById, changedIds),
80
+ tablesById: this.createReadonlyMap(this.state.entities.tablesById, (_g = this.snapshot) === null || _g === void 0 ? void 0 : _g.entities.tablesById, changedIds),
79
81
  },
80
82
  order: {
81
83
  nodeIds: [...this.state.order.nodeIds],
82
84
  edgeIds: [...this.state.order.edgeIds],
83
85
  textIds: [...this.state.order.textIds],
84
86
  shapeIds: [...this.state.order.shapeIds],
87
+ groupIds: [...this.state.order.groupIds],
88
+ tableIds: [...this.state.order.tableIds],
85
89
  },
86
90
  selection: {
87
91
  ids: [...this.state.selection.ids],
@@ -96,13 +100,15 @@ export class DiagramSceneStore {
96
100
  }
97
101
  }
98
102
  export function createInternalState(input) {
99
- var _a, _b, _c, _d, _e;
103
+ var _a, _b, _c, _d, _e, _f, _g;
100
104
  const entities = {
101
105
  nodesById: toMap((_a = input.nodes) !== null && _a !== void 0 ? _a : []),
102
106
  edgesById: toMap((_b = input.edges) !== null && _b !== void 0 ? _b : []),
103
107
  textsById: toMap((_c = input.texts) !== null && _c !== void 0 ? _c : []),
104
108
  shapesById: toMap((_d = input.shapes) !== null && _d !== void 0 ? _d : []),
105
109
  portsById: toMap((_e = input.ports) !== null && _e !== void 0 ? _e : []),
110
+ groupsById: toMap((_f = input.groups) !== null && _f !== void 0 ? _f : []),
111
+ tablesById: toMap((_g = input.tables) !== null && _g !== void 0 ? _g : []),
106
112
  };
107
113
  const ids = [
108
114
  ...entities.nodesById.keys(),
@@ -110,6 +116,8 @@ export function createInternalState(input) {
110
116
  ...entities.textsById.keys(),
111
117
  ...entities.shapesById.keys(),
112
118
  ...entities.portsById.keys(),
119
+ ...entities.groupsById.keys(),
120
+ ...entities.tablesById.keys(),
113
121
  ];
114
122
  return {
115
123
  entities,
@@ -118,6 +126,8 @@ export function createInternalState(input) {
118
126
  edgeIds: [...entities.edgesById.keys()],
119
127
  textIds: [...entities.textsById.keys()],
120
128
  shapeIds: [...entities.shapesById.keys()],
129
+ groupIds: [...entities.groupsById.keys()],
130
+ tableIds: [...entities.tablesById.keys()],
121
131
  },
122
132
  selection: normalizeSelection(input.selection),
123
133
  viewport: { ...DEFAULT_VIEWPORT, ...input.viewport },
@@ -1,16 +1,20 @@
1
- import type { DiagramEdge, DiagramGeometry, DiagramId, DiagramNode, DiagramPort, DiagramSceneInput, DiagramSelection, DiagramShape, DiagramText, DiagramViewport } from "../types.js";
1
+ import type { DiagramEdge, DiagramGeometry, DiagramGroup, DiagramId, DiagramNode, DiagramPort, DiagramSceneInput, DiagramSelection, DiagramShape, DiagramTable, DiagramText, DiagramViewport } from "../types.js";
2
2
  export type MutableEntities = {
3
3
  nodesById: Map<DiagramId, DiagramNode>;
4
4
  edgesById: Map<DiagramId, DiagramEdge>;
5
5
  textsById: Map<DiagramId, DiagramText>;
6
6
  shapesById: Map<DiagramId, DiagramShape>;
7
7
  portsById: Map<DiagramId, DiagramPort>;
8
+ groupsById: Map<DiagramId, DiagramGroup>;
9
+ tablesById: Map<DiagramId, DiagramTable>;
8
10
  };
9
11
  export type MutableOrder = {
10
12
  nodeIds: DiagramId[];
11
13
  edgeIds: DiagramId[];
12
14
  textIds: DiagramId[];
13
15
  shapeIds: DiagramId[];
16
+ groupIds: DiagramId[];
17
+ tableIds: DiagramId[];
14
18
  };
15
19
  export type InternalState = {
16
20
  entities: MutableEntities;
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/internal/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,WAAW,EAAE,eAAe,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAEpM,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;IACtC,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;IACtC,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;IACtC,UAAU,EAAE,GAAG,CAAC,SAAS,EAAE,YAAY,CAAC,CAAA;IACxC,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;CACvC,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,SAAS,EAAE,CAAA;IACpB,OAAO,EAAE,SAAS,EAAE,CAAA;IACpB,OAAO,EAAE,SAAS,EAAE,CAAA;IACpB,QAAQ,EAAE,SAAS,EAAE,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,eAAe,CAAA;IAC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