@affino/diagram-vue 0.4.0 → 0.5.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 CHANGED
@@ -73,7 +73,7 @@ viewport.setViewport({ x: 120, y: 40, zoom: 1.25 })
73
73
  `useDiagramVisibleEntities()` exposes:
74
74
 
75
75
  - `nodes`, `edges`, `ports`, `shapes`, and `texts` for SVG rendering;
76
- - `activeHandles` for selected resize/port handles;
76
+ - `activeHandles` for selected resize/port handles and source/target handles on selected edges;
77
77
  - `overlayAnchors` for context menus and toolbars.
78
78
 
79
79
  Selected entities are included even when outside the viewport, which keeps handles and overlays stable during keyboard or programmatic selection changes. `useDiagramTextEditor()` owns one shared DOM editor overlay for the active text entity; it reads bounds from core, positions through the viewport transform, and commits through the `editText` command.
@@ -88,7 +88,7 @@ Do not put domain rules, snapping decisions, hit testing, undo/redo, or geometry
88
88
 
89
89
  For DOM overlays call `getDomEntityStyle(entity, viewport.viewport.value)`; text editor positioning already applies the same transform. Use core `zoomViewportAt()` for cursor focus and `zoomViewportCentered()` for toolbar zoom. Minimap dimensions use the world scene bounds and the same camera transform.
90
90
 
91
- Preview geometry remains transient until pointerup. Render the interaction preview and its handles from core state; entity IDs are opaque strings and may contain `:`. Use `handle.ownerId`, never parse `handle.id`. Escape/pointercancel cancels without history; pointerup commits one undo operation.
91
+ Preview geometry remains transient until pointerup. Start endpoint gestures with `interaction.beginEdgeEndpointHandle(handle.ownerId, "source" | "target", event)` and render `interaction.getPreviewGeometry(edgeId)` while the gesture is active. Entity IDs are opaque strings and may contain `:`. Use `handle.ownerId`, never parse `handle.id`. Escape/pointercancel cancels without history; pointerup commits one undo operation.
92
92
 
93
93
  ### Migration from 0.1.0
94
94
 
@@ -77,6 +77,7 @@ function sameSnapshot(previous, next) {
77
77
  && previous.previewDelta === next.previewDelta
78
78
  && previous.resizePreview === next.resizePreview
79
79
  && previous.resizePreviewEntries === next.resizePreviewEntries
80
+ && previous.edgeEndpointPreview === next.edgeEndpointPreview
80
81
  && previous.marquee === next.marquee;
81
82
  }
82
83
  function toWorldPoint(event, mapper) {
@@ -63,7 +63,10 @@ function buildProjection(controller, bounds, includeSelection, entityCache) {
63
63
  }
64
64
  const activeGeometries = entities.filter((entity) => entity.selected).map((entity) => entity.geometry);
65
65
  const anchorGeometries = activeGeometries.filter((geometry) => geometry.kind !== "edge");
66
- const activeHandles = anchorGeometries.length > 1 ? createGroupHandles(anchorGeometries) : activeGeometries.flatMap(createHandles);
66
+ const activeHandles = [
67
+ ...(anchorGeometries.length > 1 ? createGroupHandles(anchorGeometries) : activeGeometries.flatMap(createHandles)),
68
+ ...activeGeometries.filter((geometry) => geometry.kind === "edge").flatMap(createEdgeEndpointHandles),
69
+ ];
67
70
  return Object.freeze({
68
71
  ids: Object.freeze(entities.map((entity) => entity.id)),
69
72
  nodes: freezeKind(entities, "node"),
@@ -81,9 +84,8 @@ function freezeKind(entities, kind) {
81
84
  }
82
85
  function createHandles(geometry) {
83
86
  var _a, _b, _c;
84
- if (geometry.kind === "edge") {
87
+ if (geometry.kind === "edge")
85
88
  return [];
86
- }
87
89
  const rect = (_a = geometry.unrotatedBounds) !== null && _a !== void 0 ? _a : geometry.bounds;
88
90
  if (geometry.kind === "port") {
89
91
  return [{ id: `${geometry.id}:port`, ownerId: geometry.id, kind: "port", point: (_b = geometry.point) !== null && _b !== void 0 ? _b : { x: rect.x, y: rect.y } }];
@@ -101,6 +103,15 @@ function createHandles(geometry) {
101
103
  { id: `${geometry.id}:sw`, ownerId: geometry.id, kind: "resize", point: corners[3] },
102
104
  ];
103
105
  }
106
+ function createEdgeEndpointHandles(geometry) {
107
+ var _a;
108
+ if (geometry.kind !== "edge" || !((_a = geometry.path) === null || _a === void 0 ? void 0 : _a.length))
109
+ return [];
110
+ return [
111
+ { id: `${geometry.id}:source`, ownerId: geometry.id, kind: "edge-endpoint", point: geometry.path[0] },
112
+ { id: `${geometry.id}:target`, ownerId: geometry.id, kind: "edge-endpoint", point: geometry.path[geometry.path.length - 1] },
113
+ ];
114
+ }
104
115
  function createGroupHandles(geometries) {
105
116
  const rect = unionRects(geometries.map((geometry) => geometry.bounds));
106
117
  if (!rect)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@affino/diagram-vue",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "author": "Anton Pavlov <a.pavlov@affino.dev>",
5
5
  "type": "module",
6
6
  "description": "Vue adapter for @affino/diagram-core",
@@ -21,7 +21,7 @@
21
21
  "vue": "^3.3.0"
22
22
  },
23
23
  "dependencies": {
24
- "@affino/diagram-core": "^0.5.0"
24
+ "@affino/diagram-core": "^0.6.0"
25
25
  },
26
26
  "license": "MIT",
27
27
  "devDependencies": {