@metadev/daga 4.2.13 → 4.2.15
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/Changelog.md +14 -0
- package/index.cjs.js +184 -65
- package/index.esm.js +185 -66
- package/package.json +1 -1
- package/src/index.d.ts +1 -0
- package/src/lib/diagram/canvas/diagram-canvas-util.d.ts +3 -1
- package/src/lib/diagram/canvas/diagram-canvas.d.ts +4 -1
- package/src/lib/diagram/config/diagram-components-config.d.ts +5 -0
- package/src/lib/diagram/config/diagram-config.d.ts +12 -4
- package/src/lib/diagram/model/diagram-connection.d.ts +1 -1
- package/src/lib/diagram/model/diagram-node.d.ts +13 -3
- package/src/lib/diagram/model/diagram-port.d.ts +1 -1
- package/src/lib/diagram/model/diagram-section.d.ts +3 -3
- package/src/lib/interfaces/canvas.d.ts +22 -3
package/index.esm.js
CHANGED
|
@@ -2420,7 +2420,7 @@ class DiagramConnection extends DiagramElement {
|
|
|
2420
2420
|
*/
|
|
2421
2421
|
this.endLabel = '';
|
|
2422
2422
|
/**
|
|
2423
|
-
* Points that this connection
|
|
2423
|
+
* Points that this connection must pass through in its route from its start point to its end point, in order.
|
|
2424
2424
|
* @public
|
|
2425
2425
|
*/
|
|
2426
2426
|
this.points = [];
|
|
@@ -2438,8 +2438,10 @@ class DiagramConnection extends DiagramElement {
|
|
|
2438
2438
|
(_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateConnectionsInView(this.id);
|
|
2439
2439
|
}
|
|
2440
2440
|
raise() {
|
|
2441
|
-
var _a;
|
|
2441
|
+
var _a, _b, _c;
|
|
2442
2442
|
(_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
|
|
2443
|
+
(_b = this.start) === null || _b === void 0 ? void 0 : _b.raise(false);
|
|
2444
|
+
(_c = this.end) === null || _c === void 0 ? void 0 : _c.raise(false);
|
|
2443
2445
|
}
|
|
2444
2446
|
/**
|
|
2445
2447
|
* Set the start of this connection to the given port or reset this connection's starting port if `undefined`.
|
|
@@ -2493,11 +2495,12 @@ class DiagramConnection extends DiagramElement {
|
|
|
2493
2495
|
* @public
|
|
2494
2496
|
*/
|
|
2495
2497
|
tighten() {
|
|
2496
|
-
var _a, _b, _c, _d, _e;
|
|
2498
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2497
2499
|
const allowConnectionLoops = ((_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.allowConnectionLoops) || false;
|
|
2498
2500
|
const allowSharingPorts = ((_b = this.model.canvas) === null || _b === void 0 ? void 0 : _b.allowSharingPorts) !== false;
|
|
2499
2501
|
const allowSharingBothPorts = ((_c = this.model.canvas) === null || _c === void 0 ? void 0 : _c.allowSharingBothPorts) || false;
|
|
2500
|
-
|
|
2502
|
+
const tightenConnectionsAcrossPortTypes = ((_d = this.model.canvas) === null || _d === void 0 ? void 0 : _d.tightenConnectionsAcrossPortTypes) || false;
|
|
2503
|
+
if (((_e = this.start) === null || _e === void 0 ? void 0 : _e.rootElement) && this.end) {
|
|
2501
2504
|
const alternativeStartPortsSortedByDistanceAscending = this.start.rootElement.ports.map(p => [p, p.distanceTo(this.end.coords)]).sort((a, b) => a[1] - b[1]).map(a => a[0]);
|
|
2502
2505
|
checkAlternativeStartPorts: for (const alternativeStartPort of alternativeStartPortsSortedByDistanceAscending) {
|
|
2503
2506
|
if (!allowConnectionLoops && alternativeStartPort === this.end) {
|
|
@@ -2508,6 +2511,10 @@ class DiagramConnection extends DiagramElement {
|
|
|
2508
2511
|
// alternative start port not valid, it doesn't allow outgoing connections
|
|
2509
2512
|
continue checkAlternativeStartPorts;
|
|
2510
2513
|
}
|
|
2514
|
+
if (!tightenConnectionsAcrossPortTypes && alternativeStartPort.type !== this.start.type) {
|
|
2515
|
+
// alternative start port not valid, the port type is different
|
|
2516
|
+
continue checkAlternativeStartPorts;
|
|
2517
|
+
}
|
|
2511
2518
|
if (!allowSharingPorts && (alternativeStartPort.incomingConnections.filter(c => !c.removed && c !== this).length > 0 || alternativeStartPort.outgoingConnections.filter(c => !c.removed && c !== this).length > 0)) {
|
|
2512
2519
|
// alternative start port not valid, it already has other connections
|
|
2513
2520
|
continue checkAlternativeStartPorts;
|
|
@@ -2535,7 +2542,7 @@ class DiagramConnection extends DiagramElement {
|
|
|
2535
2542
|
}
|
|
2536
2543
|
}
|
|
2537
2544
|
}
|
|
2538
|
-
if (((
|
|
2545
|
+
if (((_f = this.end) === null || _f === void 0 ? void 0 : _f.rootElement) && this.start) {
|
|
2539
2546
|
const alternativeEndPortsSortedByDistanceAscending = this.end.rootElement.ports.map(p => [p, p.distanceTo(this.start.coords)]).sort((a, b) => a[1] - b[1]).map(a => a[0]);
|
|
2540
2547
|
checkAlternativeEndPorts: for (const alternativeEndPort of alternativeEndPortsSortedByDistanceAscending) {
|
|
2541
2548
|
if (!allowConnectionLoops && alternativeEndPort === this.start) {
|
|
@@ -2546,6 +2553,10 @@ class DiagramConnection extends DiagramElement {
|
|
|
2546
2553
|
// alternative end port not valid, it doesn't allow incoming connections
|
|
2547
2554
|
continue checkAlternativeEndPorts;
|
|
2548
2555
|
}
|
|
2556
|
+
if (!tightenConnectionsAcrossPortTypes && alternativeEndPort.type !== this.end.type) {
|
|
2557
|
+
// alternative end port not valid, the port type is different
|
|
2558
|
+
continue checkAlternativeEndPorts;
|
|
2559
|
+
}
|
|
2549
2560
|
if (!allowSharingPorts && (alternativeEndPort.incomingConnections.filter(c => !c.removed && c !== this).length > 0 || alternativeEndPort.outgoingConnections.filter(c => !c.removed && c !== this).length > 0)) {
|
|
2550
2561
|
// alternative end port not valid, it already has other connections
|
|
2551
2562
|
continue checkAlternativeEndPorts;
|
|
@@ -2614,6 +2625,7 @@ class DiagramConnectionSet extends DiagramElementSet {
|
|
|
2614
2625
|
* @returns The instanced connection.
|
|
2615
2626
|
*/
|
|
2616
2627
|
new(type, start, end, id) {
|
|
2628
|
+
var _a, _b;
|
|
2617
2629
|
let connectionType;
|
|
2618
2630
|
if (type instanceof DiagramConnectionType) {
|
|
2619
2631
|
connectionType = type;
|
|
@@ -2628,6 +2640,8 @@ class DiagramConnectionSet extends DiagramElementSet {
|
|
|
2628
2640
|
super.add(connection);
|
|
2629
2641
|
connection.updateInView();
|
|
2630
2642
|
connection.valueSet.resetValues();
|
|
2643
|
+
(_a = connection.start) === null || _a === void 0 ? void 0 : _a.raise(false);
|
|
2644
|
+
(_b = connection.end) === null || _b === void 0 ? void 0 : _b.raise(false);
|
|
2631
2645
|
return connection;
|
|
2632
2646
|
}
|
|
2633
2647
|
remove(id) {
|
|
@@ -2956,6 +2970,11 @@ const getTopPadding$1 = config => {
|
|
|
2956
2970
|
}
|
|
2957
2971
|
};
|
|
2958
2972
|
|
|
2973
|
+
var ResizableMode;
|
|
2974
|
+
(function (ResizableMode) {
|
|
2975
|
+
ResizableMode[ResizableMode["OnlyWhenSelected"] = 0] = "OnlyWhenSelected";
|
|
2976
|
+
})(ResizableMode || (ResizableMode = {}));
|
|
2977
|
+
|
|
2959
2978
|
/**
|
|
2960
2979
|
* Default value of the default width of a diagram section.
|
|
2961
2980
|
* @private
|
|
@@ -3160,12 +3179,15 @@ class DiagramSection extends DiagramElement {
|
|
|
3160
3179
|
* @public
|
|
3161
3180
|
*/
|
|
3162
3181
|
getResizableX() {
|
|
3163
|
-
var _a
|
|
3182
|
+
var _a;
|
|
3164
3183
|
const sectionType = this.type;
|
|
3165
3184
|
if ((sectionType === null || sectionType === void 0 ? void 0 : sectionType.resizableX) !== undefined) {
|
|
3185
|
+
if (sectionType.resizableX === ResizableMode.OnlyWhenSelected) {
|
|
3186
|
+
return this.selected;
|
|
3187
|
+
}
|
|
3166
3188
|
return sectionType.resizableX;
|
|
3167
3189
|
}
|
|
3168
|
-
return ((
|
|
3190
|
+
return ((_a = this.node) === null || _a === void 0 ? void 0 : _a.getResizableX()) || false;
|
|
3169
3191
|
}
|
|
3170
3192
|
/**
|
|
3171
3193
|
* Returns whether this section can be resized vertically.
|
|
@@ -3174,12 +3196,15 @@ class DiagramSection extends DiagramElement {
|
|
|
3174
3196
|
* @public
|
|
3175
3197
|
*/
|
|
3176
3198
|
getResizableY() {
|
|
3177
|
-
var _a
|
|
3199
|
+
var _a;
|
|
3178
3200
|
const sectionType = this.type;
|
|
3179
3201
|
if ((sectionType === null || sectionType === void 0 ? void 0 : sectionType.resizableY) !== undefined) {
|
|
3202
|
+
if (sectionType.resizableY === ResizableMode.OnlyWhenSelected) {
|
|
3203
|
+
return this.selected;
|
|
3204
|
+
}
|
|
3180
3205
|
return sectionType.resizableY;
|
|
3181
3206
|
}
|
|
3182
|
-
return ((
|
|
3207
|
+
return ((_a = this.node) === null || _a === void 0 ? void 0 : _a.getResizableY()) || false;
|
|
3183
3208
|
}
|
|
3184
3209
|
/**
|
|
3185
3210
|
* Get the port of this section which is closest to the given coordinates.
|
|
@@ -3690,6 +3715,28 @@ class DiagramNode extends DiagramElement {
|
|
|
3690
3715
|
getPriority() {
|
|
3691
3716
|
return this.type.priority;
|
|
3692
3717
|
}
|
|
3718
|
+
/**
|
|
3719
|
+
* Returns whether this node can be resized horizontally.
|
|
3720
|
+
* @public
|
|
3721
|
+
*/
|
|
3722
|
+
getResizableX() {
|
|
3723
|
+
const resizableX = this.type.resizableX;
|
|
3724
|
+
if (resizableX === ResizableMode.OnlyWhenSelected) {
|
|
3725
|
+
return this.selected;
|
|
3726
|
+
}
|
|
3727
|
+
return resizableX;
|
|
3728
|
+
}
|
|
3729
|
+
/**
|
|
3730
|
+
* Returns whether this node can be resized vertically.
|
|
3731
|
+
* @public
|
|
3732
|
+
*/
|
|
3733
|
+
getResizableY() {
|
|
3734
|
+
const resizableY = this.type.resizableY;
|
|
3735
|
+
if (resizableY === ResizableMode.OnlyWhenSelected) {
|
|
3736
|
+
return this.selected;
|
|
3737
|
+
}
|
|
3738
|
+
return resizableY;
|
|
3739
|
+
}
|
|
3693
3740
|
/**
|
|
3694
3741
|
* Get the port of this node which is closest to the given coordinates.
|
|
3695
3742
|
* @param coords A point in the diagram.
|
|
@@ -4712,17 +4759,19 @@ class DiagramPort extends DiagramElement {
|
|
|
4712
4759
|
var _a;
|
|
4713
4760
|
(_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updatePortsInView(this.id);
|
|
4714
4761
|
}
|
|
4715
|
-
raise() {
|
|
4762
|
+
raise(raiseConnections = true) {
|
|
4716
4763
|
var _a;
|
|
4717
4764
|
(_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
|
|
4718
4765
|
if (this.label) {
|
|
4719
4766
|
this.label.raise();
|
|
4720
4767
|
}
|
|
4721
|
-
|
|
4722
|
-
connection.
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
connection.
|
|
4768
|
+
if (raiseConnections) {
|
|
4769
|
+
for (const connection of this.incomingConnections) {
|
|
4770
|
+
connection.raise();
|
|
4771
|
+
}
|
|
4772
|
+
for (const connection of this.outgoingConnections) {
|
|
4773
|
+
connection.raise();
|
|
4774
|
+
}
|
|
4726
4775
|
}
|
|
4727
4776
|
}
|
|
4728
4777
|
/**
|
|
@@ -6644,8 +6693,8 @@ const isSecondaryButton = event => {
|
|
|
6644
6693
|
* @private
|
|
6645
6694
|
* @see linePath
|
|
6646
6695
|
*/
|
|
6647
|
-
const getConnectionPath = (shape, startCoords, endCoords, startDirection, endDirection, width, startMarkerWidth, endMarkerWidth) => {
|
|
6648
|
-
return linePath(shape, [startCoords, endCoords], startDirection, endDirection, Math.max(
|
|
6696
|
+
const getConnectionPath = (shape, startCoords, endCoords, startDirection, endDirection, points, width, startMarkerWidth, endMarkerWidth) => {
|
|
6697
|
+
return linePath(shape, [startCoords, ...points, endCoords], startDirection, endDirection, Math.max(
|
|
6649
6698
|
// reasonable value for the minimumDistanceBeforeTurn relative to the line width
|
|
6650
6699
|
10, startMarkerWidth || 0, endMarkerWidth || 0) * width);
|
|
6651
6700
|
};
|
|
@@ -6665,6 +6714,34 @@ const getRelatedNodeOrItself = element => {
|
|
|
6665
6714
|
}
|
|
6666
6715
|
return element.rootElement instanceof DiagramNode || element.rootElement instanceof DiagramSection || element.rootElement instanceof DiagramPort ? getRelatedNodeOrItself(element.rootElement) : element;
|
|
6667
6716
|
};
|
|
6717
|
+
const needsResizerX = element => {
|
|
6718
|
+
if (element instanceof DiagramNode) {
|
|
6719
|
+
return element.type.resizableX !== false;
|
|
6720
|
+
}
|
|
6721
|
+
if (element instanceof DiagramSection) {
|
|
6722
|
+
if (element.type !== undefined) {
|
|
6723
|
+
return element.type.resizableX !== false;
|
|
6724
|
+
}
|
|
6725
|
+
if (element.node !== undefined) {
|
|
6726
|
+
return needsResizerX(element.node);
|
|
6727
|
+
}
|
|
6728
|
+
}
|
|
6729
|
+
return false;
|
|
6730
|
+
};
|
|
6731
|
+
const needsResizerY = element => {
|
|
6732
|
+
if (element instanceof DiagramNode) {
|
|
6733
|
+
return element.type.resizableY !== false;
|
|
6734
|
+
}
|
|
6735
|
+
if (element instanceof DiagramSection) {
|
|
6736
|
+
if (element.type !== undefined) {
|
|
6737
|
+
return element.type.resizableY !== false;
|
|
6738
|
+
}
|
|
6739
|
+
if (element.node !== undefined) {
|
|
6740
|
+
return needsResizerY(element.node);
|
|
6741
|
+
}
|
|
6742
|
+
}
|
|
6743
|
+
return false;
|
|
6744
|
+
};
|
|
6668
6745
|
const initializeLook = selection => {
|
|
6669
6746
|
selection.filter('.shaped-look').append('path');
|
|
6670
6747
|
selection.filter('.image-look').append('image').attr('preserveAspectRatio', 'none');
|
|
@@ -7430,7 +7507,7 @@ class DiagramCanvas {
|
|
|
7430
7507
|
* @param config The configuration object used to set the parameters of this canvas.
|
|
7431
7508
|
*/
|
|
7432
7509
|
constructor(parentComponent, config) {
|
|
7433
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
|
|
7510
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
|
|
7434
7511
|
this.backgroundPatternId = `daga-background-pattern-id-${DiagramCanvas.canvasCount++}`;
|
|
7435
7512
|
this.zoomTransform = d3.zoomIdentity;
|
|
7436
7513
|
// used to distinguish drags from clicks when dragging elements and during multiple selection
|
|
@@ -7458,12 +7535,13 @@ class DiagramCanvas {
|
|
|
7458
7535
|
this.panRate = ((_z = config.canvas) === null || _z === void 0 ? void 0 : _z.panRate) || 100;
|
|
7459
7536
|
this.inferConnectionType = ((_0 = config.connectionSettings) === null || _0 === void 0 ? void 0 : _0.inferConnectionType) || false;
|
|
7460
7537
|
this.autoTightenConnections = ((_1 = config.connectionSettings) === null || _1 === void 0 ? void 0 : _1.autoTighten) !== false;
|
|
7461
|
-
this.
|
|
7462
|
-
this.
|
|
7463
|
-
this.
|
|
7464
|
-
this.
|
|
7538
|
+
this.tightenConnectionsAcrossPortTypes = ((_2 = config.connectionSettings) === null || _2 === void 0 ? void 0 : _2.tightenAcrossPortTypes) || false;
|
|
7539
|
+
this.allowConnectionLoops = ((_3 = config.connectionSettings) === null || _3 === void 0 ? void 0 : _3.allowLoops) || false;
|
|
7540
|
+
this.allowSharingPorts = ((_4 = config.connectionSettings) === null || _4 === void 0 ? void 0 : _4.sharePorts) !== false;
|
|
7541
|
+
this.allowSharingBothPorts = ((_5 = config.connectionSettings) === null || _5 === void 0 ? void 0 : _5.shareBothPorts) || false;
|
|
7542
|
+
this.portHighlightRadius = ((_6 = config.connectionSettings) === null || _6 === void 0 ? void 0 : _6.portHighlightRadius) || 100;
|
|
7465
7543
|
this.multipleSelectionOn = false;
|
|
7466
|
-
this.priorityThresholds = ((
|
|
7544
|
+
this.priorityThresholds = ((_7 = config.canvas) === null || _7 === void 0 ? void 0 : _7.priorityThresholds) || [];
|
|
7467
7545
|
this.priorityThreshold = this.priorityThresholds ? this.priorityThresholds[0] : undefined;
|
|
7468
7546
|
this.layoutFormat = config.layoutFormat;
|
|
7469
7547
|
this.userActions = config.userActions || {};
|
|
@@ -7490,7 +7568,7 @@ class DiagramCanvas {
|
|
|
7490
7568
|
const connectionType = new DiagramConnectionType(Object.assign(Object.assign({}, config.connectionTypeDefaults), connectionTypeConfig));
|
|
7491
7569
|
this.model.connections.types.add(connectionType);
|
|
7492
7570
|
}
|
|
7493
|
-
this._connectionType = ((
|
|
7571
|
+
this._connectionType = ((_8 = config === null || config === void 0 ? void 0 : config.connectionSettings) === null || _8 === void 0 ? void 0 : _8.defaultConnection) !== undefined ? this.model.connections.types.get(config.connectionSettings.defaultConnection) : undefined;
|
|
7494
7572
|
}
|
|
7495
7573
|
}
|
|
7496
7574
|
addValidator(validator) {
|
|
@@ -7750,7 +7828,14 @@ class DiagramCanvas {
|
|
|
7750
7828
|
}
|
|
7751
7829
|
}
|
|
7752
7830
|
getViewCoordinates() {
|
|
7753
|
-
|
|
7831
|
+
var _a, _b, _c;
|
|
7832
|
+
const canvasViewBoundingBox = (_c = (_b = (_a = this.selectCanvasView()) === null || _a === void 0 ? void 0 : _a.select('rect')) === null || _b === void 0 ? void 0 : _b.node()) === null || _c === void 0 ? void 0 : _c.getBBox();
|
|
7833
|
+
/*
|
|
7834
|
+
transform the coordinates of the zoomTransform to the coordinates
|
|
7835
|
+
needed to point the zoomTransfrom to the center of the screen to
|
|
7836
|
+
ensure that canvas.translateTo(getViewCoordinates()) has no effect
|
|
7837
|
+
*/
|
|
7838
|
+
return [((canvasViewBoundingBox.width + canvasViewBoundingBox.x) / 2 - this.zoomTransform.x) / this.zoomTransform.k, ((canvasViewBoundingBox.height + canvasViewBoundingBox.y) / 2 - this.zoomTransform.y) / this.zoomTransform.k];
|
|
7754
7839
|
}
|
|
7755
7840
|
translateBy(x, y) {
|
|
7756
7841
|
if (!isNaN(x) && !isNaN(y)) {
|
|
@@ -7762,12 +7847,42 @@ class DiagramCanvas {
|
|
|
7762
7847
|
this.zoomBehavior.translateTo(this.selectCanvasView(), x, y);
|
|
7763
7848
|
}
|
|
7764
7849
|
}
|
|
7765
|
-
|
|
7850
|
+
zoomAndPanTo(x, y, z, duration) {
|
|
7851
|
+
if (!duration || duration <= 0) {
|
|
7852
|
+
this.zoomBehavior.scaleTo(this.selectCanvasView(), z);
|
|
7853
|
+
this.zoomBehavior.translateTo(this.selectCanvasView(), x, y);
|
|
7854
|
+
return;
|
|
7855
|
+
}
|
|
7856
|
+
this.zoomBehavior.interpolate(d3.interpolate);
|
|
7857
|
+
const [startingX, startingY] = this.getViewCoordinates();
|
|
7858
|
+
const startingZoom = this.getZoomLevel();
|
|
7859
|
+
const targetX = x,
|
|
7860
|
+
targetY = y,
|
|
7861
|
+
targetZoom = z;
|
|
7862
|
+
this.selectCanvasElements().transition().duration(duration).ease(d3.easeCubicInOut).tween('progress', () => {
|
|
7863
|
+
let animationInterrupted = false;
|
|
7864
|
+
return value => {
|
|
7865
|
+
try {
|
|
7866
|
+
if (!animationInterrupted) {
|
|
7867
|
+
const currentX = value * (targetX - startingX) + startingX;
|
|
7868
|
+
const currentY = value * (targetY - startingY) + startingY;
|
|
7869
|
+
const currentZoom = value * (targetZoom - startingZoom) + startingZoom;
|
|
7870
|
+
this.zoomBehavior.scaleTo(this.selectCanvasView(), currentZoom);
|
|
7871
|
+
this.zoomBehavior.translateTo(this.selectCanvasView(), currentX, currentY);
|
|
7872
|
+
}
|
|
7873
|
+
} catch (e) {
|
|
7874
|
+
console.warn('Animation has been interrupted');
|
|
7875
|
+
animationInterrupted = true;
|
|
7876
|
+
}
|
|
7877
|
+
};
|
|
7878
|
+
});
|
|
7879
|
+
}
|
|
7880
|
+
center(nodeIds, maxZoomLevel, duration) {
|
|
7766
7881
|
var _a;
|
|
7767
7882
|
// if there are no nodes, we have nothing to do here
|
|
7768
7883
|
if (this.model.nodes.length > 0) {
|
|
7769
7884
|
const canvasViewBoundingBox = (_a = this.selectCanvasView().select('rect').node()) === null || _a === void 0 ? void 0 : _a.getBBox();
|
|
7770
|
-
const nonRemovedNodes = this.model.nodes.all();
|
|
7885
|
+
const nonRemovedNodes = (nodeIds === null || nodeIds === void 0 ? void 0 : nodeIds.map(i => this.model.nodes.get(i)).filter(n => !!n)) || this.model.nodes.all();
|
|
7771
7886
|
const minimumX = Math.min(...nonRemovedNodes.map(n => n.coords[0]));
|
|
7772
7887
|
const maximumX = Math.max(...nonRemovedNodes.map(n => n.coords[0] + n.width));
|
|
7773
7888
|
const averageX = (minimumX + maximumX) / 2;
|
|
@@ -7782,12 +7897,12 @@ class DiagramCanvas {
|
|
|
7782
7897
|
* (windowRangeX / rangeX) is the zoom level to fit everything horizontally
|
|
7783
7898
|
* (windowRangeY / rangeY) is the zoom level to fit everything vertically
|
|
7784
7899
|
* the minimum between them is the zoom to fit everything in the screen both horizontally and vertically
|
|
7785
|
-
* we also add
|
|
7900
|
+
* we also add maxZoomLevel to the list so that if the zoom exceeds maxZoomLevel it is set to maxZoomLevel
|
|
7901
|
+
* or 1 if maxZoomLevel is undefined
|
|
7786
7902
|
* a zoom bigger than 1 means zooming in instead of out, and we don't want to zoom in if it's not necessary
|
|
7787
7903
|
*/
|
|
7788
|
-
const zoom = Math.min(windowRangeX / rangeX, windowRangeY / rangeY, 1);
|
|
7789
|
-
this.
|
|
7790
|
-
this.zoomTo(zoom);
|
|
7904
|
+
const zoom = Math.min(windowRangeX / rangeX, windowRangeY / rangeY, maxZoomLevel !== undefined ? maxZoomLevel : 1);
|
|
7905
|
+
this.zoomAndPanTo(averageX, averageY, zoom, duration);
|
|
7791
7906
|
}
|
|
7792
7907
|
}
|
|
7793
7908
|
getClosestGridPoint(point) {
|
|
@@ -7843,7 +7958,7 @@ class DiagramCanvas {
|
|
|
7843
7958
|
updateNodesInView(...ids) {
|
|
7844
7959
|
let updateSelection = this.selectCanvasElements().selectAll('g.diagram-node').data(this.model.nodes.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
|
|
7845
7960
|
const exitSelection = updateSelection.exit();
|
|
7846
|
-
const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', d => `diagram-node${d
|
|
7961
|
+
const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', d => `diagram-node${needsResizerX(d) ? ' resizable-x' : ''}${needsResizerY(d) ? ' resizable-y' : ''} ${d.type.defaultLook.lookType}`);
|
|
7847
7962
|
if (ids && ids.length > 0) {
|
|
7848
7963
|
updateSelection = updateSelection.filter(d => ids.includes(d.id));
|
|
7849
7964
|
}
|
|
@@ -7907,27 +8022,27 @@ class DiagramCanvas {
|
|
|
7907
8022
|
}));
|
|
7908
8023
|
initializeLook(enterSelection);
|
|
7909
8024
|
enterSelection.filter('.resizable-x').append('line').attr('class', 'left-resizer').attr('stroke', 'transparent').attr('stroke-width', `${RESIZER_THICKNESS}px`).on(Events.MouseOver, (_event, d) => {
|
|
7910
|
-
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.
|
|
8025
|
+
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
|
|
7911
8026
|
setCursorStyle(CursorStyle.EWResize);
|
|
7912
8027
|
}
|
|
7913
8028
|
}).on(Events.MouseOut, (_event, d) => {
|
|
7914
|
-
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.
|
|
8029
|
+
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
|
|
7915
8030
|
setCursorStyle();
|
|
7916
8031
|
}
|
|
7917
8032
|
}).call(d3.drag().on(DragEvents.Start, (_event, d) => {
|
|
7918
|
-
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.
|
|
8033
|
+
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
|
|
7919
8034
|
setCursorStyle(CursorStyle.EWResize);
|
|
7920
8035
|
this.currentAction = new SetGeometryAction(this, DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
|
|
7921
8036
|
} else {
|
|
7922
8037
|
setCursorStyle(CursorStyle.NotAllowed);
|
|
7923
8038
|
}
|
|
7924
8039
|
}).on(DragEvents.Drag, (event, d) => {
|
|
7925
|
-
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.
|
|
8040
|
+
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
|
|
7926
8041
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7927
8042
|
d.stretch(Side.Left, d.coords[0] - pointerCoords[0]);
|
|
7928
8043
|
}
|
|
7929
8044
|
}).on(DragEvents.End, (event, d) => {
|
|
7930
|
-
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.
|
|
8045
|
+
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
|
|
7931
8046
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7932
8047
|
if (this.snapToGrid) {
|
|
7933
8048
|
pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
|
|
@@ -7943,27 +8058,27 @@ class DiagramCanvas {
|
|
|
7943
8058
|
setCursorStyle();
|
|
7944
8059
|
}));
|
|
7945
8060
|
enterSelection.filter('.resizable-y').append('line').attr('class', 'top-resizer').attr('stroke', 'transparent').attr('stroke-width', `${RESIZER_THICKNESS}px`).on(Events.MouseOver, (_event, d) => {
|
|
7946
|
-
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.
|
|
8061
|
+
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
|
|
7947
8062
|
setCursorStyle(CursorStyle.NSResize);
|
|
7948
8063
|
}
|
|
7949
8064
|
}).on(Events.MouseOut, (_event, d) => {
|
|
7950
|
-
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.
|
|
8065
|
+
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
|
|
7951
8066
|
setCursorStyle();
|
|
7952
8067
|
}
|
|
7953
8068
|
}).call(d3.drag().on(DragEvents.Start, (_event, d) => {
|
|
7954
|
-
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.
|
|
8069
|
+
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
|
|
7955
8070
|
setCursorStyle(CursorStyle.NSResize);
|
|
7956
8071
|
this.currentAction = new SetGeometryAction(this, DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
|
|
7957
8072
|
} else {
|
|
7958
8073
|
setCursorStyle(CursorStyle.NotAllowed);
|
|
7959
8074
|
}
|
|
7960
8075
|
}).on(DragEvents.Drag, (event, d) => {
|
|
7961
|
-
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.
|
|
8076
|
+
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
|
|
7962
8077
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7963
8078
|
d.stretch(Side.Top, d.coords[1] - pointerCoords[1]);
|
|
7964
8079
|
}
|
|
7965
8080
|
}).on(DragEvents.End, (event, d) => {
|
|
7966
|
-
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.
|
|
8081
|
+
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
|
|
7967
8082
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7968
8083
|
if (this.snapToGrid) {
|
|
7969
8084
|
pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
|
|
@@ -7979,27 +8094,27 @@ class DiagramCanvas {
|
|
|
7979
8094
|
setCursorStyle();
|
|
7980
8095
|
}));
|
|
7981
8096
|
enterSelection.filter('.resizable-x').append('line').attr('class', 'right-resizer').attr('stroke', 'transparent').attr('stroke-width', `${RESIZER_THICKNESS}px`).on(Events.MouseOver, (_event, d) => {
|
|
7982
|
-
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.
|
|
8097
|
+
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
|
|
7983
8098
|
setCursorStyle(CursorStyle.EWResize);
|
|
7984
8099
|
}
|
|
7985
8100
|
}).on(Events.MouseOut, (_event, d) => {
|
|
7986
|
-
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.
|
|
8101
|
+
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
|
|
7987
8102
|
setCursorStyle();
|
|
7988
8103
|
}
|
|
7989
8104
|
}).call(d3.drag().on(DragEvents.Start, (_event, d) => {
|
|
7990
|
-
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.
|
|
8105
|
+
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
|
|
7991
8106
|
setCursorStyle(CursorStyle.EWResize);
|
|
7992
8107
|
this.currentAction = new SetGeometryAction(this, DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
|
|
7993
8108
|
} else {
|
|
7994
8109
|
setCursorStyle(CursorStyle.NotAllowed);
|
|
7995
8110
|
}
|
|
7996
8111
|
}).on(DragEvents.Drag, (event, d) => {
|
|
7997
|
-
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.
|
|
8112
|
+
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
|
|
7998
8113
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7999
8114
|
d.stretch(Side.Right, pointerCoords[0] - (d.coords[0] + d.width));
|
|
8000
8115
|
}
|
|
8001
8116
|
}).on(DragEvents.End, (event, d) => {
|
|
8002
|
-
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.
|
|
8117
|
+
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
|
|
8003
8118
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
8004
8119
|
if (this.snapToGrid) {
|
|
8005
8120
|
pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[2], pointerCoords[1] - d.type.snapToGridOffset[3]]);
|
|
@@ -8015,27 +8130,27 @@ class DiagramCanvas {
|
|
|
8015
8130
|
setCursorStyle();
|
|
8016
8131
|
}));
|
|
8017
8132
|
enterSelection.filter('.resizable-y').append('line').attr('class', 'bottom-resizer').attr('stroke', 'transparent').attr('stroke-width', `${RESIZER_THICKNESS}px`).on(Events.MouseOver, (_event, d) => {
|
|
8018
|
-
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.
|
|
8133
|
+
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
|
|
8019
8134
|
setCursorStyle(CursorStyle.NSResize);
|
|
8020
8135
|
}
|
|
8021
8136
|
}).on(Events.MouseOut, (_event, d) => {
|
|
8022
|
-
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.
|
|
8137
|
+
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
|
|
8023
8138
|
setCursorStyle();
|
|
8024
8139
|
}
|
|
8025
8140
|
}).call(d3.drag().on(DragEvents.Start, (_event, d) => {
|
|
8026
|
-
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.
|
|
8141
|
+
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
|
|
8027
8142
|
setCursorStyle(CursorStyle.NSResize);
|
|
8028
8143
|
this.currentAction = new SetGeometryAction(this, DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
|
|
8029
8144
|
} else {
|
|
8030
8145
|
setCursorStyle(CursorStyle.NotAllowed);
|
|
8031
8146
|
}
|
|
8032
8147
|
}).on(DragEvents.Drag, (event, d) => {
|
|
8033
|
-
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.
|
|
8148
|
+
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
|
|
8034
8149
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
8035
8150
|
d.stretch(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height));
|
|
8036
8151
|
}
|
|
8037
8152
|
}).on(DragEvents.End, (event, d) => {
|
|
8038
|
-
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.
|
|
8153
|
+
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
|
|
8039
8154
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
8040
8155
|
if (this.snapToGrid) {
|
|
8041
8156
|
if (this.snapToGrid) {
|
|
@@ -8054,17 +8169,17 @@ class DiagramCanvas {
|
|
|
8054
8169
|
}));
|
|
8055
8170
|
mergeSelection.attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).attr('opacity', d => d.removed ? 0.5 : 1);
|
|
8056
8171
|
updateLook(mergeSelection);
|
|
8057
|
-
mergeSelection.filter('.resizable-x').select('line.left-resizer').attr('x1', RESIZER_THICKNESS / 2).attr('x2', RESIZER_THICKNESS / 2).attr('y1', 0).attr('y2', d => d.height);
|
|
8058
|
-
mergeSelection.filter('.resizable-y').select('line.top-resizer').attr('x1', 0).attr('x2', d => d.width).attr('y1', RESIZER_THICKNESS / 2).attr('y2', RESIZER_THICKNESS / 2);
|
|
8059
|
-
mergeSelection.filter('.resizable-x').select('line.right-resizer').attr('x1', d => d.width - RESIZER_THICKNESS / 2).attr('x2', d => d.width - RESIZER_THICKNESS / 2).attr('y1', 0).attr('y2', d => d.height);
|
|
8060
|
-
mergeSelection.filter('.resizable-y').select('line.bottom-resizer').attr('x1', 0).attr('x2', d => d.width).attr('y1', d => d.height - RESIZER_THICKNESS / 2).attr('y2', d => d.height - RESIZER_THICKNESS / 2);
|
|
8172
|
+
mergeSelection.filter('.resizable-x').select('line.left-resizer').style('pointer-events', d => d.getResizableX() ? 'initial' : 'none').attr('x1', RESIZER_THICKNESS / 2).attr('x2', RESIZER_THICKNESS / 2).attr('y1', 0).attr('y2', d => d.height);
|
|
8173
|
+
mergeSelection.filter('.resizable-y').select('line.top-resizer').style('pointer-events', d => d.getResizableY() ? 'initial' : 'none').attr('x1', 0).attr('x2', d => d.width).attr('y1', RESIZER_THICKNESS / 2).attr('y2', RESIZER_THICKNESS / 2);
|
|
8174
|
+
mergeSelection.filter('.resizable-x').select('line.right-resizer').style('pointer-events', d => d.getResizableX() ? 'initial' : 'none').attr('x1', d => d.width - RESIZER_THICKNESS / 2).attr('x2', d => d.width - RESIZER_THICKNESS / 2).attr('y1', 0).attr('y2', d => d.height);
|
|
8175
|
+
mergeSelection.filter('.resizable-y').select('line.bottom-resizer').style('pointer-events', d => d.getResizableY() ? 'initial' : 'none').attr('x1', 0).attr('x2', d => d.width).attr('y1', d => d.height - RESIZER_THICKNESS / 2).attr('y2', d => d.height - RESIZER_THICKNESS / 2);
|
|
8061
8176
|
}
|
|
8062
8177
|
updateSectionsInView(...ids) {
|
|
8063
8178
|
let updateSelection = this.selectCanvasElements().selectAll('g.diagram-section').data(this.model.sections.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
|
|
8064
8179
|
const exitSelection = updateSelection.exit();
|
|
8065
8180
|
const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', d => {
|
|
8066
8181
|
var _a;
|
|
8067
|
-
return `diagram-section${d
|
|
8182
|
+
return `diagram-section${needsResizerX(d) ? ' resizable-x' : ''}${needsResizerY(d) ? ' resizable-y' : ''} ${(_a = d.look) === null || _a === void 0 ? void 0 : _a.lookType}`;
|
|
8068
8183
|
});
|
|
8069
8184
|
if (ids && ids.length > 0) {
|
|
8070
8185
|
updateSelection = updateSelection.filter(d => ids.includes(d.id));
|
|
@@ -8283,10 +8398,10 @@ class DiagramCanvas {
|
|
|
8283
8398
|
}));
|
|
8284
8399
|
mergeSelection.attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).attr('opacity', d => d.removed ? 0.5 : 1);
|
|
8285
8400
|
updateLook(mergeSelection);
|
|
8286
|
-
mergeSelection.filter('.resizable-x').select('line.left-resizer').attr('x1', RESIZER_THICKNESS / 2).attr('x2', RESIZER_THICKNESS / 2).attr('y1', 0).attr('y2', d => d.height);
|
|
8287
|
-
mergeSelection.filter('.resizable-y').select('line.top-resizer').attr('x1', 0).attr('x2', d => d.width).attr('y1', RESIZER_THICKNESS / 2).attr('y2', RESIZER_THICKNESS / 2);
|
|
8288
|
-
mergeSelection.filter('.resizable-x').select('line.right-resizer').attr('x1', d => d.width - RESIZER_THICKNESS / 2).attr('x2', d => d.width - RESIZER_THICKNESS / 2).attr('y1', 0).attr('y2', d => d.height);
|
|
8289
|
-
mergeSelection.filter('.resizable-y').select('line.bottom-resizer').attr('x1', 0).attr('x2', d => d.width).attr('y1', d => d.height - RESIZER_THICKNESS / 2).attr('y2', d => d.height - RESIZER_THICKNESS / 2);
|
|
8401
|
+
mergeSelection.filter('.resizable-x').select('line.left-resizer').style('pointer-events', d => d.getResizableX() ? 'initial' : 'none').attr('x1', RESIZER_THICKNESS / 2).attr('x2', RESIZER_THICKNESS / 2).attr('y1', 0).attr('y2', d => d.height);
|
|
8402
|
+
mergeSelection.filter('.resizable-y').select('line.top-resizer').style('pointer-events', d => d.getResizableY() ? 'initial' : 'none').attr('x1', 0).attr('x2', d => d.width).attr('y1', RESIZER_THICKNESS / 2).attr('y2', RESIZER_THICKNESS / 2);
|
|
8403
|
+
mergeSelection.filter('.resizable-x').select('line.right-resizer').style('pointer-events', d => d.getResizableX() ? 'initial' : 'none').attr('x1', d => d.width - RESIZER_THICKNESS / 2).attr('x2', d => d.width - RESIZER_THICKNESS / 2).attr('y1', 0).attr('y2', d => d.height);
|
|
8404
|
+
mergeSelection.filter('.resizable-y').select('line.bottom-resizer').style('pointer-events', d => d.getResizableY() ? 'initial' : 'none').attr('x1', 0).attr('x2', d => d.width).attr('y1', d => d.height - RESIZER_THICKNESS / 2).attr('y2', d => d.height - RESIZER_THICKNESS / 2);
|
|
8290
8405
|
}
|
|
8291
8406
|
updatePortsInView(...ids) {
|
|
8292
8407
|
let updateSelection = this.selectCanvasElements().selectAll('g.diagram-port').data(this.model.ports.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
|
|
@@ -8371,14 +8486,14 @@ class DiagramCanvas {
|
|
|
8371
8486
|
}
|
|
8372
8487
|
}
|
|
8373
8488
|
}).on(DragEvents.Drag, (event, d) => {
|
|
8374
|
-
var _a, _b, _c, _d;
|
|
8489
|
+
var _a, _b, _c, _d, _e;
|
|
8375
8490
|
if (this.multipleSelectionOn || this.secondaryButton) {
|
|
8376
8491
|
this.continueMultipleSelection(event);
|
|
8377
8492
|
} else {
|
|
8378
8493
|
if (this.canUserPerformAction(DiagramActions.AddConnection) && !d.removed) {
|
|
8379
8494
|
if (this.unfinishedConnection !== undefined) {
|
|
8380
8495
|
const endCoords = [event.x, event.y];
|
|
8381
|
-
(_a = this.unfinishedConnectionTracer) === null || _a === void 0 ? void 0 : _a.attr('d', getConnectionPath(this.unfinishedConnection.look.shape || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.shape, this.unfinishedConnection.startCoords, endCoords, this.unfinishedConnection.startDirection, this.unfinishedConnection.endDirection, this.unfinishedConnection.type.defaultLook.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness, (_b = this.unfinishedConnection.type.defaultStartMarkerLook) === null || _b === void 0 ? void 0 : _b.width, (_c = this.unfinishedConnection.type.defaultEndMarkerLook) === null || _c === void 0 ? void 0 : _c.width));
|
|
8496
|
+
(_a = this.unfinishedConnectionTracer) === null || _a === void 0 ? void 0 : _a.attr('d', getConnectionPath(this.unfinishedConnection.look.shape || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.shape, this.unfinishedConnection.startCoords, endCoords, this.unfinishedConnection.startDirection, this.unfinishedConnection.endDirection, this.unfinishedConnection.points, this.unfinishedConnection.type.defaultLook.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness, (_b = this.unfinishedConnection.type.defaultStartMarkerLook) === null || _b === void 0 ? void 0 : _b.width, (_c = this.unfinishedConnection.type.defaultEndMarkerLook) === null || _c === void 0 ? void 0 : _c.width));
|
|
8382
8497
|
const unfinishedConnectionGhostNode = (_d = this.unfinishedConnectionTracer) === null || _d === void 0 ? void 0 : _d.node();
|
|
8383
8498
|
if (unfinishedConnectionGhostNode) {
|
|
8384
8499
|
let margin = 2;
|
|
@@ -8393,6 +8508,7 @@ class DiagramCanvas {
|
|
|
8393
8508
|
this.unfinishedConnection.endCoords = endCoords;
|
|
8394
8509
|
}
|
|
8395
8510
|
this.updateConnectionsInView(UNFINISHED_CONNECTION_ID);
|
|
8511
|
+
(_e = this.unfinishedConnectionPort) === null || _e === void 0 ? void 0 : _e.raise(false);
|
|
8396
8512
|
// highlight closest target port
|
|
8397
8513
|
if (this.model.ports.length > 0) {
|
|
8398
8514
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
@@ -8526,11 +8642,11 @@ class DiagramCanvas {
|
|
|
8526
8642
|
enterSelection.select('g.diagram-connection-end-label').append('text').style('user-select', 'none');
|
|
8527
8643
|
mergeSelection.attr('opacity', d => d.removed ? 0.5 : 1).select('path.diagram-connection-path').attr('d', d => {
|
|
8528
8644
|
var _a, _b;
|
|
8529
|
-
return getConnectionPath(d.look.shape || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.type.defaultLook.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness, (_a = d.type.defaultStartMarkerLook) === null || _a === void 0 ? void 0 : _a.width, (_b = d.type.defaultEndMarkerLook) === null || _b === void 0 ? void 0 : _b.width);
|
|
8645
|
+
return getConnectionPath(d.look.shape || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.points, d.type.defaultLook.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness, (_a = d.type.defaultStartMarkerLook) === null || _a === void 0 ? void 0 : _a.width, (_b = d.type.defaultEndMarkerLook) === null || _b === void 0 ? void 0 : _b.width);
|
|
8530
8646
|
}).attr('marker-start', d => `url(#${d.id}-start-marker)`).attr('marker-end', d => `url(#${d.id}-end-marker)`).attr('stroke', d => d.look.color || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.color).attr('stroke-width', d => `${d.look.thickness}px`).attr('stroke-dasharray', d => lineStyleDasharray(d.look.style || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.style, d.type.defaultLook.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness)).attr('fill', 'none');
|
|
8531
8647
|
mergeSelection.select('path.diagram-connection-path-box').attr('d', d => {
|
|
8532
8648
|
var _a, _b;
|
|
8533
|
-
return getConnectionPath(d.look.shape || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.type.defaultLook.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness, (_a = d.type.defaultStartMarkerLook) === null || _a === void 0 ? void 0 : _a.width, (_b = d.type.defaultEndMarkerLook) === null || _b === void 0 ? void 0 : _b.width);
|
|
8649
|
+
return getConnectionPath(d.look.shape || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.points, d.type.defaultLook.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness, (_a = d.type.defaultStartMarkerLook) === null || _a === void 0 ? void 0 : _a.width, (_b = d.type.defaultEndMarkerLook) === null || _b === void 0 ? void 0 : _b.width);
|
|
8534
8650
|
}).attr('stroke', 'transparent')
|
|
8535
8651
|
// allow generating pointer events even when it is transparent
|
|
8536
8652
|
.attr('pointer-events', 'stroke').attr('stroke-width', d => `${(d.look.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness) + CONNECTION_PATH_BOX_THICKNESS}px`).attr('stroke-dasharray', d => lineStyleDasharray(d.look.style || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.style, d.type.defaultLook.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness)).attr('fill', 'none');
|
|
@@ -9086,6 +9202,7 @@ class DiagramCanvas {
|
|
|
9086
9202
|
if (port.allowsOutgoing || port.allowsIncoming) {
|
|
9087
9203
|
if (this.connectionType && (this.connectionType.canStartFromType(((_b = (_a = port.getNode()) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.id) || '') && port.allowsOutgoing || this.connectionType.canFinishOnType(((_d = (_c = port.getNode()) === null || _c === void 0 ? void 0 : _c.type) === null || _d === void 0 ? void 0 : _d.id) || '') && port.allowsIncoming)) {
|
|
9088
9204
|
this.unfinishedConnection = new DiagramConnection(this.model, this.connectionType, port, undefined, UNFINISHED_CONNECTION_ID);
|
|
9205
|
+
this.unfinishedConnectionPort = port;
|
|
9089
9206
|
} else {
|
|
9090
9207
|
if (this.inferConnectionType) {
|
|
9091
9208
|
let differentConnectionType = this.model.connections.types.all().find(t => {
|
|
@@ -9100,6 +9217,7 @@ class DiagramCanvas {
|
|
|
9100
9217
|
}
|
|
9101
9218
|
if (differentConnectionType !== undefined) {
|
|
9102
9219
|
this.unfinishedConnection = new DiagramConnection(this.model, differentConnectionType, port, undefined, UNFINISHED_CONNECTION_ID);
|
|
9220
|
+
this.unfinishedConnectionPort = port;
|
|
9103
9221
|
}
|
|
9104
9222
|
}
|
|
9105
9223
|
}
|
|
@@ -9173,6 +9291,7 @@ class DiagramCanvas {
|
|
|
9173
9291
|
(_b = this.unfinishedConnection) === null || _b === void 0 ? void 0 : _b.setEnd(undefined);
|
|
9174
9292
|
(_d = (_c = this.unfinishedConnection) === null || _c === void 0 ? void 0 : _c.select()) === null || _d === void 0 ? void 0 : _d.remove();
|
|
9175
9293
|
this.unfinishedConnection = undefined;
|
|
9294
|
+
this.unfinishedConnectionPort = undefined;
|
|
9176
9295
|
}
|
|
9177
9296
|
cancelAllUserActions() {
|
|
9178
9297
|
this.currentAction = undefined;
|
|
@@ -10289,4 +10408,4 @@ const getLocationsOfNodes = model => {
|
|
|
10289
10408
|
return locations;
|
|
10290
10409
|
};
|
|
10291
10410
|
|
|
10292
|
-
export { ACTION_STACK_SIZE, ActionStack, AddConnectionAction, AddNodeAction, AdjacencyLayout, ApplyLayoutAction, BreadthAdjacencyLayout, BreadthLayout, ClosedShape, CollabClient, Corner, CursorStyle, DIAGRAM_FIELD_DEFAULTS, DagaExporter, DagaImporter, DiagramActionMethod, DiagramActions, DiagramCanvas, DiagramConnection, DiagramConnectionSet, DiagramConnectionType, DiagramContextMenu, DiagramDecorator, DiagramDecoratorSet, DiagramDoubleClickEvent, DiagramElement, DiagramElementSet, DiagramEntitySet, DiagramEvent, DiagramEvents, DiagramField, DiagramFieldSet, DiagramHighlightedEvent, DiagramModel, DiagramNode, DiagramNodeSet, DiagramNodeType, DiagramObject, DiagramObjectSet, DiagramPort, DiagramPortSet, DiagramPortType, DiagramSecondaryClickEvent, DiagramSection, DiagramSectionSet, DiagramSelectionEvent, DiagramUserHighlight, DiagramUserSelection, DiagramZoomEvent, DragEvents, EditFieldAction, Events, ForceLayout, HorizontalAlign, HorizontalLayout, Keys, LineShape, LineStyle, MoveAction, PasteAction, PriorityLayout, Property, PropertySet, RemoveAction, SetGeometryAction, SetParentAction, Side, TreeLayout, Type, UpdateValuesAction, ValueSet, VerticalAlign, VerticalLayout, ZoomEvents, addIfNotExists, diff, equals, filterByOnlyAncestors, filterByOnlyDescendants, generalClosedPath, getBottomMargin, getBottomPadding$1 as getBottomPadding, getLeftMargin, getLeftPadding$1 as getLeftPadding, getLocationsOfNodes, getRightMargin, getRightPadding$1 as getRightPadding, getTopMargin, getTopPadding$1 as getTopPadding, isObject, layouts, linePath, lineStyleDasharray, removeIfExists, setCursorStyle };
|
|
10411
|
+
export { ACTION_STACK_SIZE, ActionStack, AddConnectionAction, AddNodeAction, AdjacencyLayout, ApplyLayoutAction, BreadthAdjacencyLayout, BreadthLayout, ClosedShape, CollabClient, Corner, CursorStyle, DIAGRAM_FIELD_DEFAULTS, DagaExporter, DagaImporter, DiagramActionMethod, DiagramActions, DiagramCanvas, DiagramConnection, DiagramConnectionSet, DiagramConnectionType, DiagramContextMenu, DiagramDecorator, DiagramDecoratorSet, DiagramDoubleClickEvent, DiagramElement, DiagramElementSet, DiagramEntitySet, DiagramEvent, DiagramEvents, DiagramField, DiagramFieldSet, DiagramHighlightedEvent, DiagramModel, DiagramNode, DiagramNodeSet, DiagramNodeType, DiagramObject, DiagramObjectSet, DiagramPort, DiagramPortSet, DiagramPortType, DiagramSecondaryClickEvent, DiagramSection, DiagramSectionSet, DiagramSelectionEvent, DiagramUserHighlight, DiagramUserSelection, DiagramZoomEvent, DragEvents, EditFieldAction, Events, ForceLayout, HorizontalAlign, HorizontalLayout, Keys, LineShape, LineStyle, MoveAction, PasteAction, PriorityLayout, Property, PropertySet, RemoveAction, ResizableMode, SetGeometryAction, SetParentAction, Side, TreeLayout, Type, UpdateValuesAction, ValueSet, VerticalAlign, VerticalLayout, ZoomEvents, addIfNotExists, diff, equals, filterByOnlyAncestors, filterByOnlyDescendants, generalClosedPath, getBottomMargin, getBottomPadding$1 as getBottomPadding, getLeftMargin, getLeftPadding$1 as getLeftPadding, getLocationsOfNodes, getRightMargin, getRightPadding$1 as getRightPadding, getTopMargin, getTopPadding$1 as getTopPadding, isObject, layouts, linePath, lineStyleDasharray, removeIfExists, setCursorStyle };
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export { CollabClient } from './lib/diagram/collab/collab-client';
|
|
|
9
9
|
export type { CollabTimestamp, CollabTimestampSet } from './lib/diagram/collab/primitives';
|
|
10
10
|
export type { CanvasConfig, GridConfig, GridStyle } from './lib/diagram/config/diagram-canvas-config';
|
|
11
11
|
export type { ButtonsComponentConfig, ComponentsConfig, ConnectionTemplateConfig, ErrorsComponentConfig, NodeTemplateConfig, PaletteComponentConfig, PaletteSectionConfig, PropertyEditorComponentConfig } from './lib/diagram/config/diagram-components-config';
|
|
12
|
+
export { ResizableMode } from './lib/diagram/config/diagram-config';
|
|
12
13
|
export type { ConnectionTypeConfig, DiagramConfig, FieldConfig, NodeTypeConfig, PortConfig, PortTypeConfig, SectionConfig, SectionGridConfig, UserActionConfig } from './lib/diagram/config/diagram-config';
|
|
13
14
|
export type { ConnectionLook, ConnectionLookConfig, ImageLook, ImageLookConfig, Look, LookConfig, MarkerImageLook, MarkerImageLookConfig, ShapedLook, ShapedLookConfig, StretchableImageLook, StretchableImageLookConfig } from './lib/diagram/config/diagram-look-config';
|
|
14
15
|
export { DagaExporter } from './lib/diagram/converters/daga-exporter';
|
|
@@ -20,9 +20,11 @@ export declare const isSecondaryButton: (event: MouseEvent) => boolean;
|
|
|
20
20
|
* @private
|
|
21
21
|
* @see linePath
|
|
22
22
|
*/
|
|
23
|
-
export declare const getConnectionPath: (shape: LineShape | LineFunction, startCoords: Point, endCoords: Point, startDirection: Side | undefined, endDirection: Side | undefined, width: number, startMarkerWidth: number | undefined, endMarkerWidth: number | undefined) => string;
|
|
23
|
+
export declare const getConnectionPath: (shape: LineShape | LineFunction, startCoords: Point, endCoords: Point, startDirection: Side | undefined, endDirection: Side | undefined, points: Point[], width: number, startMarkerWidth: number | undefined, endMarkerWidth: number | undefined) => string;
|
|
24
24
|
export declare const setCursorStyle: (style?: CursorStyle) => void;
|
|
25
25
|
export declare const getRelatedNodeOrItself: (element: DiagramNode | DiagramSection | DiagramPort | DiagramField) => DiagramNode | DiagramSection | DiagramPort | DiagramField;
|
|
26
|
+
export declare const needsResizerX: (element: DiagramNode | DiagramSection) => boolean;
|
|
27
|
+
export declare const needsResizerY: (element: DiagramNode | DiagramSection) => boolean;
|
|
26
28
|
export declare const initializeLook: (selection: d3.Selection<SVGGElement, DiagramNode | DiagramSection | DiagramPort, d3.BaseType, unknown>) => void;
|
|
27
29
|
export declare const SHAPED_LOOK_DEFAULTS: {
|
|
28
30
|
fillColor: string;
|