@html-graph/html-graph 8.23.0 → 8.24.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/dist/html-graph.d.ts +13 -0
- package/dist/html-graph.js +41 -23
- package/dist/html-graph.min.js +29 -20
- package/dist/html-graph.min.umd.cjs +1 -1
- package/dist/html-graph.umd.cjs +41 -23
- package/package.json +1 -1
package/dist/html-graph.umd.cjs
CHANGED
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
this.attachedNodeIds.delete(nodeId);
|
|
86
86
|
}
|
|
87
87
|
attachEdge(edgeId) {
|
|
88
|
-
const svg = this.graphStore.getEdge(edgeId).payload.shape.
|
|
88
|
+
const svg = this.graphStore.getEdge(edgeId).payload.shape.element;
|
|
89
89
|
this.edgeIdToElementMap.set(edgeId, svg);
|
|
90
90
|
this.container.appendChild(svg);
|
|
91
91
|
this.renderEdge(edgeId);
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
updateEdgeShape(edgeId) {
|
|
128
128
|
const element = this.edgeIdToElementMap.get(edgeId);
|
|
129
129
|
this.container.removeChild(element);
|
|
130
|
-
const svg = this.graphStore.getEdge(edgeId).payload.shape.
|
|
130
|
+
const svg = this.graphStore.getEdge(edgeId).payload.shape.element;
|
|
131
131
|
this.edgeIdToElementMap.set(edgeId, svg);
|
|
132
132
|
this.container.appendChild(svg);
|
|
133
133
|
}
|
|
@@ -152,7 +152,7 @@
|
|
|
152
152
|
}
|
|
153
153
|
updateEdgePriority(edgeId) {
|
|
154
154
|
const edge = this.graphStore.getEdge(edgeId);
|
|
155
|
-
edge.payload.shape.
|
|
155
|
+
edge.payload.shape.element.style.zIndex = `${edge.payload.priority}`;
|
|
156
156
|
}
|
|
157
157
|
createEdgeRenderPort(port, rectPort, rectCanvas, scale) {
|
|
158
158
|
const contentPoint = this.viewportStore.createContentCoords({
|
|
@@ -761,7 +761,7 @@
|
|
|
761
761
|
if (this.hasEdge(request.id)) throw new CanvasError(canvasErrorText.addEdgeWithExistingId(request.id));
|
|
762
762
|
if (!this.hasPort(request.from)) throw new CanvasError(canvasErrorText.addEdgeFromNonexistentPort(request.id, request.from));
|
|
763
763
|
if (!this.hasPort(request.to)) throw new CanvasError(canvasErrorText.addEdgeToNonexistentPort(request.id, request.to));
|
|
764
|
-
const useEdgeId = this.findEdgeIdByElement(request.shape.
|
|
764
|
+
const useEdgeId = this.findEdgeIdByElement(request.shape.element);
|
|
765
765
|
if (useEdgeId !== void 0) throw new CanvasError(canvasErrorText.addEdgeWithElementInUse(request.id, useEdgeId));
|
|
766
766
|
this.addEdgeInternal(request);
|
|
767
767
|
this.afterEdgeAddedEmitter.emit(request.id);
|
|
@@ -902,7 +902,7 @@
|
|
|
902
902
|
priority: request.priority
|
|
903
903
|
}
|
|
904
904
|
});
|
|
905
|
-
this.edgesElementsMap.set(request.shape.
|
|
905
|
+
this.edgesElementsMap.set(request.shape.element, request.id);
|
|
906
906
|
if (request.from !== request.to) {
|
|
907
907
|
this.portOutgoingEdges.get(request.from).add(request.id);
|
|
908
908
|
this.portIncomingEdges.get(request.to).add(request.id);
|
|
@@ -917,7 +917,7 @@
|
|
|
917
917
|
this.portOutgoingEdges.get(from).delete(edgeId);
|
|
918
918
|
this.portOutgoingEdges.get(to).delete(edgeId);
|
|
919
919
|
this.edges.delete(edgeId);
|
|
920
|
-
this.edgesElementsMap.delete(payload.shape.
|
|
920
|
+
this.edgesElementsMap.delete(payload.shape.element);
|
|
921
921
|
}
|
|
922
922
|
};
|
|
923
923
|
//#endregion
|
|
@@ -2135,6 +2135,7 @@
|
|
|
2135
2135
|
//#region src/edges/shapes/path-edge-shape/path-edge-shape.ts
|
|
2136
2136
|
var PathEdgeShape = class {
|
|
2137
2137
|
params;
|
|
2138
|
+
element;
|
|
2138
2139
|
svg;
|
|
2139
2140
|
group = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
2140
2141
|
line;
|
|
@@ -2147,8 +2148,9 @@
|
|
|
2147
2148
|
this.params = params;
|
|
2148
2149
|
[this.afterRenderEmitter, this.onAfterRender] = createPair();
|
|
2149
2150
|
this.arrowRenderer = this.params.arrowRenderer;
|
|
2150
|
-
this.
|
|
2151
|
-
this.svg
|
|
2151
|
+
this.element = createEdgeSvg(params.color);
|
|
2152
|
+
this.svg = this.element;
|
|
2153
|
+
this.element.appendChild(this.group);
|
|
2152
2154
|
this.line = createEdgePath(params.width);
|
|
2153
2155
|
this.group.appendChild(this.line);
|
|
2154
2156
|
if (params.hasSourceArrow) {
|
|
@@ -2162,7 +2164,7 @@
|
|
|
2162
2164
|
}
|
|
2163
2165
|
render(params) {
|
|
2164
2166
|
const { x, y, width, height, from, to } = createEdgeRectangle(params.from, params.to, this.params.padding);
|
|
2165
|
-
setSvgRectangle(this.
|
|
2167
|
+
setSvgRectangle(this.element, {
|
|
2166
2168
|
x,
|
|
2167
2169
|
y,
|
|
2168
2170
|
width,
|
|
@@ -2320,6 +2322,7 @@
|
|
|
2320
2322
|
//#endregion
|
|
2321
2323
|
//#region src/edges/shapes/bezier-edge-shape/bezier-edge-shape.ts
|
|
2322
2324
|
var BezierEdgeShape = class {
|
|
2325
|
+
element;
|
|
2323
2326
|
svg;
|
|
2324
2327
|
group;
|
|
2325
2328
|
line;
|
|
@@ -2386,7 +2389,8 @@
|
|
|
2386
2389
|
createLinePath: this.createLinePath,
|
|
2387
2390
|
padding: 50
|
|
2388
2391
|
});
|
|
2389
|
-
this.
|
|
2392
|
+
this.element = this.pathShape.element;
|
|
2393
|
+
this.svg = this.element;
|
|
2390
2394
|
this.group = this.pathShape.group;
|
|
2391
2395
|
this.line = this.pathShape.line;
|
|
2392
2396
|
this.sourceArrow = this.pathShape.sourceArrow;
|
|
@@ -2409,6 +2413,7 @@
|
|
|
2409
2413
|
* use OrthogonalEdgeShape instead
|
|
2410
2414
|
*/
|
|
2411
2415
|
var HorizontalEdgeShape = class {
|
|
2416
|
+
element;
|
|
2412
2417
|
svg;
|
|
2413
2418
|
group;
|
|
2414
2419
|
line;
|
|
@@ -2476,7 +2481,8 @@
|
|
|
2476
2481
|
createLinePath: this.createLinePath,
|
|
2477
2482
|
padding: 50
|
|
2478
2483
|
});
|
|
2479
|
-
this.
|
|
2484
|
+
this.element = this.pathShape.element;
|
|
2485
|
+
this.svg = this.element;
|
|
2480
2486
|
this.group = this.pathShape.group;
|
|
2481
2487
|
this.line = this.pathShape.line;
|
|
2482
2488
|
this.sourceArrow = this.pathShape.sourceArrow;
|
|
@@ -2501,6 +2507,7 @@
|
|
|
2501
2507
|
//#endregion
|
|
2502
2508
|
//#region src/edges/shapes/straight-edge-shape/straight-edge-shape.ts
|
|
2503
2509
|
var StraightEdgeShape = class {
|
|
2510
|
+
element;
|
|
2504
2511
|
svg;
|
|
2505
2512
|
group;
|
|
2506
2513
|
line;
|
|
@@ -2571,7 +2578,8 @@
|
|
|
2571
2578
|
createLinePath: this.createLinePath,
|
|
2572
2579
|
padding: 50
|
|
2573
2580
|
});
|
|
2574
|
-
this.
|
|
2581
|
+
this.element = this.pathShape.element;
|
|
2582
|
+
this.svg = this.element;
|
|
2575
2583
|
this.group = this.pathShape.group;
|
|
2576
2584
|
this.line = this.pathShape.line;
|
|
2577
2585
|
this.sourceArrow = this.pathShape.sourceArrow;
|
|
@@ -2595,6 +2603,7 @@
|
|
|
2595
2603
|
* use OrthogonalEdgeShape instead
|
|
2596
2604
|
*/
|
|
2597
2605
|
var VerticalEdgeShape = class {
|
|
2606
|
+
element;
|
|
2598
2607
|
svg;
|
|
2599
2608
|
group;
|
|
2600
2609
|
line;
|
|
@@ -2662,7 +2671,8 @@
|
|
|
2662
2671
|
createLinePath: this.createLinePath,
|
|
2663
2672
|
padding: 50
|
|
2664
2673
|
});
|
|
2665
|
-
this.
|
|
2674
|
+
this.element = this.pathShape.element;
|
|
2675
|
+
this.svg = this.element;
|
|
2666
2676
|
this.group = this.pathShape.group;
|
|
2667
2677
|
this.line = this.pathShape.line;
|
|
2668
2678
|
this.sourceArrow = this.pathShape.sourceArrow;
|
|
@@ -2700,6 +2710,7 @@
|
|
|
2700
2710
|
//#endregion
|
|
2701
2711
|
//#region src/edges/shapes/orthogonal-edge-shape/orthogonal-edge-shape.ts
|
|
2702
2712
|
var OrthogonalEdgeShape = class {
|
|
2713
|
+
element;
|
|
2703
2714
|
svg;
|
|
2704
2715
|
group;
|
|
2705
2716
|
line;
|
|
@@ -2767,7 +2778,8 @@
|
|
|
2767
2778
|
createLinePath: this.createLinePath,
|
|
2768
2779
|
padding: 50
|
|
2769
2780
|
});
|
|
2770
|
-
this.
|
|
2781
|
+
this.element = this.pathShape.element;
|
|
2782
|
+
this.svg = this.element;
|
|
2771
2783
|
this.group = this.pathShape.group;
|
|
2772
2784
|
this.line = this.pathShape.line;
|
|
2773
2785
|
this.sourceArrow = this.pathShape.sourceArrow;
|
|
@@ -2813,6 +2825,7 @@
|
|
|
2813
2825
|
//#region src/edges/shapes/direct-edge-shape/direct-edge-shape.ts
|
|
2814
2826
|
var defaultPortOffset = edgeConstants.portOffset;
|
|
2815
2827
|
var DirectEdgeShape = class {
|
|
2828
|
+
element;
|
|
2816
2829
|
svg;
|
|
2817
2830
|
group = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
2818
2831
|
line;
|
|
@@ -2834,8 +2847,9 @@
|
|
|
2834
2847
|
this.arrowRenderer = resolveArrowRenderer(params?.arrowRenderer ?? {});
|
|
2835
2848
|
this.sourceOffsetFn = resolvePortOffsetFn(params?.sourceOffset ?? defaultPortOffset);
|
|
2836
2849
|
this.targetOffsetFn = resolvePortOffsetFn(params?.targetOffset ?? defaultPortOffset);
|
|
2837
|
-
this.
|
|
2838
|
-
this.svg
|
|
2850
|
+
this.element = createEdgeSvg(this.color);
|
|
2851
|
+
this.svg = this.element;
|
|
2852
|
+
this.element.appendChild(this.group);
|
|
2839
2853
|
this.line = createEdgePath(this.width);
|
|
2840
2854
|
this.group.appendChild(this.line);
|
|
2841
2855
|
if (params?.hasSourceArrow) {
|
|
@@ -2849,7 +2863,7 @@
|
|
|
2849
2863
|
}
|
|
2850
2864
|
render(params) {
|
|
2851
2865
|
const { x, y, width, height, from, to } = createEdgeRectangle(params.from, params.to, 50);
|
|
2852
|
-
setSvgRectangle(this.
|
|
2866
|
+
setSvgRectangle(this.element, {
|
|
2853
2867
|
x,
|
|
2854
2868
|
y,
|
|
2855
2869
|
width,
|
|
@@ -3014,6 +3028,7 @@
|
|
|
3014
3028
|
//#region src/edges/shapes/interactive-edge-shape/interactive-edge-shape.ts
|
|
3015
3029
|
var InteractiveEdgeShape = class InteractiveEdgeShape {
|
|
3016
3030
|
baseEdge;
|
|
3031
|
+
element;
|
|
3017
3032
|
svg;
|
|
3018
3033
|
group;
|
|
3019
3034
|
line;
|
|
@@ -3031,7 +3046,8 @@
|
|
|
3031
3046
|
constructor(baseEdge, params) {
|
|
3032
3047
|
this.baseEdge = baseEdge;
|
|
3033
3048
|
if (baseEdge instanceof InteractiveEdgeShape) throw new InteractiveEdgeError("interactive edge can be configured only once");
|
|
3034
|
-
this.
|
|
3049
|
+
this.element = this.baseEdge.element;
|
|
3050
|
+
this.svg = this.element;
|
|
3035
3051
|
this.group = this.baseEdge.group;
|
|
3036
3052
|
this.line = this.baseEdge.line;
|
|
3037
3053
|
this.sourceArrow = this.baseEdge.sourceArrow;
|
|
@@ -3069,17 +3085,19 @@
|
|
|
3069
3085
|
sourceArrow;
|
|
3070
3086
|
targetArrow;
|
|
3071
3087
|
onAfterRender;
|
|
3088
|
+
element;
|
|
3072
3089
|
svg;
|
|
3073
3090
|
constructor(baseShape, midpointElement) {
|
|
3074
3091
|
this.baseShape = baseShape;
|
|
3075
3092
|
this.midpointElement = midpointElement;
|
|
3076
|
-
this.
|
|
3093
|
+
this.element = this.baseShape.element;
|
|
3094
|
+
this.svg = this.element;
|
|
3077
3095
|
this.group = this.baseShape.group;
|
|
3078
3096
|
this.line = this.baseShape.line;
|
|
3079
3097
|
this.sourceArrow = this.baseShape.sourceArrow;
|
|
3080
3098
|
this.targetArrow = this.baseShape.targetArrow;
|
|
3081
3099
|
this.onAfterRender = this.baseShape.onAfterRender;
|
|
3082
|
-
this.
|
|
3100
|
+
this.element.append(this.midpointElement);
|
|
3083
3101
|
this.baseShape.onAfterRender.subscribe((model) => {
|
|
3084
3102
|
const midpoint = model.edgePath.midpoint;
|
|
3085
3103
|
const transform = `translate(${midpoint.x}px, ${midpoint.y}px)`;
|
|
@@ -5085,16 +5103,16 @@
|
|
|
5085
5103
|
onEdgeSelected;
|
|
5086
5104
|
onAfterEdgeAdded = (edgeId) => {
|
|
5087
5105
|
const { shape } = this.canvas.graph.getEdge(edgeId);
|
|
5088
|
-
this.configurator.enable(shape.
|
|
5106
|
+
this.configurator.enable(shape.element);
|
|
5089
5107
|
};
|
|
5090
5108
|
onBeforeEdgeRemoved = (edgeId) => {
|
|
5091
5109
|
const { shape } = this.canvas.graph.getEdge(edgeId);
|
|
5092
|
-
this.configurator.disable(shape.
|
|
5110
|
+
this.configurator.disable(shape.element);
|
|
5093
5111
|
};
|
|
5094
5112
|
reset = () => {
|
|
5095
5113
|
this.canvas.graph.getAllEdgeIds().forEach((edgeId) => {
|
|
5096
5114
|
const { shape } = this.canvas.graph.getEdge(edgeId);
|
|
5097
|
-
this.configurator.disable(shape.
|
|
5115
|
+
this.configurator.disable(shape.element);
|
|
5098
5116
|
});
|
|
5099
5117
|
};
|
|
5100
5118
|
constructor(canvas, window, pointInsideVerifier, eventTagger, params) {
|