@metadev/daga 4.2.2 → 4.2.4
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 -1
- package/index.cjs.js +217 -88
- package/index.esm.js +217 -88
- package/package.json +1 -1
- package/src/lib/diagram/canvas/diagram-canvas-util.d.ts +7 -1
- package/src/lib/diagram/canvas/diagram-canvas.d.ts +6 -1
- package/src/lib/diagram/canvas/diagram-user-highlight.d.ts +5 -1
- package/src/lib/diagram/config/diagram-canvas-config.d.ts +5 -0
- package/src/lib/diagram/config/diagram-config.d.ts +49 -8
- package/src/lib/diagram/config/diagram-look-config.d.ts +17 -8
- package/src/lib/diagram/model/diagram-connection.d.ts +0 -16
- package/src/lib/diagram/model/diagram-field.d.ts +1 -0
- package/src/lib/diagram/property/property.d.ts +10 -4
- package/src/lib/interfaces/canvas.d.ts +29 -4
package/index.esm.js
CHANGED
|
@@ -1203,8 +1203,9 @@ class DiagramElementSet extends DiagramEntitySet {
|
|
|
1203
1203
|
* @see ValueSet
|
|
1204
1204
|
*/
|
|
1205
1205
|
class Property {
|
|
1206
|
-
constructor(name, type, defaultValue, basic, editable, rootAttribute) {
|
|
1206
|
+
constructor(name, label, type, defaultValue, basic, editable, rootAttribute) {
|
|
1207
1207
|
this.name = name;
|
|
1208
|
+
this.label = label;
|
|
1208
1209
|
this.type = type;
|
|
1209
1210
|
this.defaultValue = defaultValue;
|
|
1210
1211
|
this.basic = basic;
|
|
@@ -1724,7 +1725,7 @@ class ValueSet {
|
|
|
1724
1725
|
this.setRootElementValue(rootAttribute, this.values[key]);
|
|
1725
1726
|
}
|
|
1726
1727
|
}
|
|
1727
|
-
if (property.basic) {
|
|
1728
|
+
if (property.basic !== false) {
|
|
1728
1729
|
this.displayedProperties.push(property);
|
|
1729
1730
|
} else {
|
|
1730
1731
|
this.hiddenProperties.push(property);
|
|
@@ -2117,11 +2118,14 @@ class DiagramConnection extends DiagramElement {
|
|
|
2117
2118
|
* @public
|
|
2118
2119
|
*/
|
|
2119
2120
|
tighten() {
|
|
2120
|
-
var _a, _b;
|
|
2121
|
-
|
|
2121
|
+
var _a, _b, _c, _d, _e;
|
|
2122
|
+
const allowConnectionLoops = ((_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.allowConnectionLoops) || false;
|
|
2123
|
+
const allowSharingPorts = ((_b = this.model.canvas) === null || _b === void 0 ? void 0 : _b.allowSharingPorts) !== false;
|
|
2124
|
+
const allowSharingBothPorts = ((_c = this.model.canvas) === null || _c === void 0 ? void 0 : _c.allowSharingBothPorts) || false;
|
|
2125
|
+
if (((_d = this.start) === null || _d === void 0 ? void 0 : _d.rootElement) && this.end) {
|
|
2122
2126
|
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]);
|
|
2123
2127
|
checkAlternativeStartPorts: for (const alternativeStartPort of alternativeStartPortsSortedByDistanceAscending) {
|
|
2124
|
-
if (alternativeStartPort === this.end) {
|
|
2128
|
+
if (!allowConnectionLoops && alternativeStartPort === this.end) {
|
|
2125
2129
|
// alternative start port not valid, it is the same as the end port
|
|
2126
2130
|
continue checkAlternativeStartPorts;
|
|
2127
2131
|
}
|
|
@@ -2129,7 +2133,11 @@ class DiagramConnection extends DiagramElement {
|
|
|
2129
2133
|
// alternative start port not valid, it doesn't allow outgoing connections
|
|
2130
2134
|
continue checkAlternativeStartPorts;
|
|
2131
2135
|
}
|
|
2132
|
-
{
|
|
2136
|
+
if (!allowSharingPorts && (alternativeStartPort.incomingConnections.length === 1 && alternativeStartPort.incomingConnections[0] !== this || alternativeStartPort.incomingConnections.length > 1 || alternativeStartPort.outgoingConnections.length === 1 && alternativeStartPort.outgoingConnections[0] !== this || alternativeStartPort.outgoingConnections.length > 1)) {
|
|
2137
|
+
// alternative start port not valid, it already has other connections
|
|
2138
|
+
continue checkAlternativeStartPorts;
|
|
2139
|
+
}
|
|
2140
|
+
if (!allowSharingBothPorts) {
|
|
2133
2141
|
for (const connection of alternativeStartPort.outgoingConnections) {
|
|
2134
2142
|
if (connection !== this && connection.end === this.end) {
|
|
2135
2143
|
// alternative start port not valid, there is a connection whose start and end matches the alternative start port and this connection's end
|
|
@@ -2152,10 +2160,10 @@ class DiagramConnection extends DiagramElement {
|
|
|
2152
2160
|
}
|
|
2153
2161
|
}
|
|
2154
2162
|
}
|
|
2155
|
-
if (((
|
|
2163
|
+
if (((_e = this.end) === null || _e === void 0 ? void 0 : _e.rootElement) && this.start) {
|
|
2156
2164
|
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]);
|
|
2157
2165
|
checkAlternativeEndPorts: for (const alternativeEndPort of alternativeEndPortsSortedByDistanceAscending) {
|
|
2158
|
-
if (alternativeEndPort === this.start) {
|
|
2166
|
+
if (!allowConnectionLoops && alternativeEndPort === this.start) {
|
|
2159
2167
|
// alternative end port not valid, it is the same as the end port
|
|
2160
2168
|
continue checkAlternativeEndPorts;
|
|
2161
2169
|
}
|
|
@@ -2163,7 +2171,11 @@ class DiagramConnection extends DiagramElement {
|
|
|
2163
2171
|
// alternative end port not valid, it doesn't allow incoming connections
|
|
2164
2172
|
continue checkAlternativeEndPorts;
|
|
2165
2173
|
}
|
|
2166
|
-
{
|
|
2174
|
+
if (!allowSharingPorts && (alternativeEndPort.outgoingConnections.length === 1 && alternativeEndPort.outgoingConnections[0] !== this || alternativeEndPort.outgoingConnections.length > 1 || alternativeEndPort.incomingConnections.length === 1 && alternativeEndPort.incomingConnections[0] !== this || alternativeEndPort.incomingConnections.length > 1)) {
|
|
2175
|
+
// alternative end port not valid, it already has other connections
|
|
2176
|
+
continue checkAlternativeEndPorts;
|
|
2177
|
+
}
|
|
2178
|
+
if (!allowSharingBothPorts) {
|
|
2167
2179
|
for (const connection of alternativeEndPort.incomingConnections) {
|
|
2168
2180
|
if (connection !== this && connection.start === this.start) {
|
|
2169
2181
|
// alternative end port not valid, there is a connection whose start and end matches the alternative end port and this connection's start
|
|
@@ -2271,6 +2283,7 @@ const DIAGRAM_FIELD_DEFAULTS = {
|
|
|
2271
2283
|
fontFamily: "'Wonder Unit Sans', sans-serif",
|
|
2272
2284
|
color: '#000000',
|
|
2273
2285
|
selectedColor: '#000000',
|
|
2286
|
+
backgroundColor: '#00000000',
|
|
2274
2287
|
horizontalAlign: HorizontalAlign.Center,
|
|
2275
2288
|
verticalAlign: VerticalAlign.Center,
|
|
2276
2289
|
orientation: Side.Top,
|
|
@@ -2927,6 +2940,7 @@ class DiagramSection extends DiagramElement {
|
|
|
2927
2940
|
* @public
|
|
2928
2941
|
*/
|
|
2929
2942
|
setGeometry(geometry) {
|
|
2943
|
+
var _a;
|
|
2930
2944
|
const oldCoordsX = [this.coords[0], this.coords[0] + this.width];
|
|
2931
2945
|
const oldCoordsY = [this.coords[1], this.coords[1] + this.height];
|
|
2932
2946
|
this.coords = [...geometry.coords];
|
|
@@ -2950,8 +2964,10 @@ class DiagramSection extends DiagramElement {
|
|
|
2950
2964
|
for (const decorator of this.decorators) {
|
|
2951
2965
|
decorator.move(translatePointWithAnchors(decorator.coords, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY, decorator.anchorPointX, decorator.anchorPointY));
|
|
2952
2966
|
}
|
|
2967
|
+
if (((_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.autoTightenConnections) !== false) {
|
|
2968
|
+
this.getConnections().forEach(c => c.tighten());
|
|
2969
|
+
}
|
|
2953
2970
|
// Update canvas.
|
|
2954
|
-
this.getConnections().forEach(c => c.tighten());
|
|
2955
2971
|
this.updateInView();
|
|
2956
2972
|
}
|
|
2957
2973
|
}
|
|
@@ -3670,6 +3686,7 @@ class DiagramNode extends DiagramElement {
|
|
|
3670
3686
|
* @public
|
|
3671
3687
|
*/
|
|
3672
3688
|
setGeometry(geometry) {
|
|
3689
|
+
var _a;
|
|
3673
3690
|
this.raise();
|
|
3674
3691
|
const oldCoordsX = [this.coords[0], this.coords[0] + this.width];
|
|
3675
3692
|
const oldCoordsY = [this.coords[1], this.coords[1] + this.height];
|
|
@@ -3707,8 +3724,10 @@ class DiagramNode extends DiagramElement {
|
|
|
3707
3724
|
for (const decorator of this.decorators) {
|
|
3708
3725
|
decorator.move(translatePointWithAnchors(decorator.coords, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY, decorator.anchorPointX, decorator.anchorPointY));
|
|
3709
3726
|
}
|
|
3727
|
+
if (((_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.autoTightenConnections) !== false) {
|
|
3728
|
+
this.getConnections().forEach(c => c.tighten());
|
|
3729
|
+
}
|
|
3710
3730
|
// Update canvas.
|
|
3711
|
-
this.getConnections().forEach(c => c.tighten());
|
|
3712
3731
|
this.updateInView();
|
|
3713
3732
|
}
|
|
3714
3733
|
/**
|
|
@@ -6215,8 +6234,14 @@ const initializeLook = selection => {
|
|
|
6215
6234
|
selection.filter('.stretchable-image-look').append('image').attr('class', 'bottom-image').attr('preserveAspectRatio', 'none');
|
|
6216
6235
|
selection.filter('.stretchable-image-look').append('image').attr('class', 'bottom-right-image').attr('preserveAspectRatio', 'none');
|
|
6217
6236
|
};
|
|
6237
|
+
const SHAPED_LOOK_DEFAULTS = {
|
|
6238
|
+
fillColor: '#FFFFFF',
|
|
6239
|
+
borderColor: '#000000',
|
|
6240
|
+
borderThickness: 1,
|
|
6241
|
+
borderStyle: LineStyle.Solid
|
|
6242
|
+
};
|
|
6218
6243
|
const updateLook = selection => {
|
|
6219
|
-
selection.filter('.shaped-look').select('path').attr('d', d => generalClosedPath(d.look.shape, 0, 0, d.width, d.height)).attr('fill', d => d.look.fillColor).attr('stroke', d => d.look.borderColor).attr('stroke-width', d => `${d.look.borderThickness}px`);
|
|
6244
|
+
selection.filter('.shaped-look').select('path').attr('d', d => generalClosedPath(d.look.shape || ClosedShape.Rectangle, 0, 0, d.width, d.height)).attr('fill', d => d.look.fillColor || SHAPED_LOOK_DEFAULTS.fillColor).attr('stroke', d => d.look.borderColor || SHAPED_LOOK_DEFAULTS.borderColor).attr('stroke-width', d => `${d.look.borderThickness || SHAPED_LOOK_DEFAULTS.borderThickness}px`).attr('stroke-dasharray', d => lineStyleDasharray(d.look.borderStyle || SHAPED_LOOK_DEFAULTS.borderStyle, d.look.borderThickness || SHAPED_LOOK_DEFAULTS.borderThickness));
|
|
6220
6245
|
selection.filter('.image-look').select('image').attr('x', 0).attr('y', 0).attr('width', d => d.width).attr('height', d => d.height).attr('href', d => d.look.backgroundImage);
|
|
6221
6246
|
selection.filter('.stretchable-image-look').select('image.top-left-image').attr('x', 0).attr('y', 0).attr('width', d => d.look.leftMargin).attr('height', d => d.look.topMargin).attr('href', d => d.look.backgroundImageTopLeft);
|
|
6222
6247
|
selection.filter('.stretchable-image-look').select('image.top-image').attr('x', d => d.look.leftMargin).attr('y', 0).attr('width', d => d.width - d.look.rightMargin - d.look.leftMargin).attr('height', d => d.look.topMargin).attr('href', d => d.look.backgroundImageTop);
|
|
@@ -6402,10 +6427,11 @@ class DiagramUserHighlight extends DiagramElementSet {
|
|
|
6402
6427
|
* @public
|
|
6403
6428
|
* @param canvas A canvas.
|
|
6404
6429
|
*/
|
|
6405
|
-
constructor(canvas) {
|
|
6430
|
+
constructor(canvas, highlightSections = true) {
|
|
6406
6431
|
super();
|
|
6407
6432
|
this.focus = undefined;
|
|
6408
6433
|
this.canvas = canvas;
|
|
6434
|
+
this.highlightSections = highlightSections;
|
|
6409
6435
|
}
|
|
6410
6436
|
/**
|
|
6411
6437
|
* Gets the focus of the user highlight, which is the element where the current user highlight started regardless of which other elements were highlighted as a consequence.
|
|
@@ -6431,6 +6457,20 @@ class DiagramUserHighlight extends DiagramElementSet {
|
|
|
6431
6457
|
add(element) {
|
|
6432
6458
|
super.add(element);
|
|
6433
6459
|
if (element instanceof DiagramNode) {
|
|
6460
|
+
if (!this.highlightSections) {
|
|
6461
|
+
for (const section of element.sections) {
|
|
6462
|
+
super.add(section);
|
|
6463
|
+
for (const port of section.ports) {
|
|
6464
|
+
super.add(port);
|
|
6465
|
+
this.canvas.updatePortsInView(port.id);
|
|
6466
|
+
}
|
|
6467
|
+
if (section.label) {
|
|
6468
|
+
super.add(section.label);
|
|
6469
|
+
this.canvas.updateFieldsInView(section.label.id);
|
|
6470
|
+
}
|
|
6471
|
+
this.canvas.updateSectionsInView(section.id);
|
|
6472
|
+
}
|
|
6473
|
+
}
|
|
6434
6474
|
for (const port of element.ports) {
|
|
6435
6475
|
super.add(port);
|
|
6436
6476
|
this.canvas.updatePortsInView(port.id);
|
|
@@ -6441,15 +6481,19 @@ class DiagramUserHighlight extends DiagramElementSet {
|
|
|
6441
6481
|
}
|
|
6442
6482
|
this.canvas.updateNodesInView(element.id);
|
|
6443
6483
|
} else if (element instanceof DiagramSection) {
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6484
|
+
if (!this.highlightSections && element.node) {
|
|
6485
|
+
this.add(element.node);
|
|
6486
|
+
} else {
|
|
6487
|
+
for (const port of element.ports) {
|
|
6488
|
+
super.add(port);
|
|
6489
|
+
this.canvas.updatePortsInView(port.id);
|
|
6490
|
+
}
|
|
6491
|
+
if (element.label) {
|
|
6492
|
+
super.add(element.label);
|
|
6493
|
+
this.canvas.updateFieldsInView(element.label.id);
|
|
6494
|
+
}
|
|
6495
|
+
this.canvas.updateSectionsInView(element.id);
|
|
6451
6496
|
}
|
|
6452
|
-
this.canvas.updateSectionsInView(element.id);
|
|
6453
6497
|
} else if (element instanceof DiagramPort) {
|
|
6454
6498
|
if (element.label) {
|
|
6455
6499
|
super.add(element.label);
|
|
@@ -6918,7 +6962,6 @@ const RESIZER_THICKNESS = 6;
|
|
|
6918
6962
|
*/
|
|
6919
6963
|
const ACTION_STACK_SIZE = 25;
|
|
6920
6964
|
const UNFINISHED_CONNECTION_ID = 'diagram-connection-unfinished';
|
|
6921
|
-
const MAX_DISTANCE_TO_PORT = 100;
|
|
6922
6965
|
class DiagramCanvas {
|
|
6923
6966
|
get connectionType() {
|
|
6924
6967
|
return this._connectionType;
|
|
@@ -6936,7 +6979,7 @@ class DiagramCanvas {
|
|
|
6936
6979
|
* @param config The configuration object used to set the parameters of this canvas.
|
|
6937
6980
|
*/
|
|
6938
6981
|
constructor(parentComponent, config) {
|
|
6939
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
6982
|
+
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;
|
|
6940
6983
|
this.backgroundPatternId = `daga-background-pattern-id-${DiagramCanvas.canvasCount++}`;
|
|
6941
6984
|
this.zoomTransform = d3.zoomIdentity;
|
|
6942
6985
|
// used to distinguish drags from clicks when dragging elements and during multiple selection
|
|
@@ -6952,19 +6995,24 @@ class DiagramCanvas {
|
|
|
6952
6995
|
this.parentComponent = parentComponent;
|
|
6953
6996
|
this.model = new DiagramModel(this, undefined, config.name || 'unnamed', '', config.type || '', config.properties || []);
|
|
6954
6997
|
this.userSelection = new DiagramUserSelection(this);
|
|
6955
|
-
this.userHighlight = new DiagramUserHighlight(this);
|
|
6956
|
-
this.contextMenu = new DiagramContextMenu(this, (
|
|
6957
|
-
this.backgroundColor = ((
|
|
6958
|
-
this.gridStyle = (
|
|
6959
|
-
this.gridSize = ((
|
|
6960
|
-
this.gridThickness = Math.abs(((
|
|
6961
|
-
this.gridColor = ((
|
|
6962
|
-
this.snapToGrid = ((
|
|
6963
|
-
this.zoomFactor = ((
|
|
6964
|
-
this.panRate = ((
|
|
6965
|
-
this.inferConnectionType = config.inferConnectionType || false;
|
|
6998
|
+
this.userHighlight = new DiagramUserHighlight(this, ((_a = config.canvas) === null || _a === void 0 ? void 0 : _a.highlightSections) !== false);
|
|
6999
|
+
this.contextMenu = new DiagramContextMenu(this, (_b = config.canvas) === null || _b === void 0 ? void 0 : _b.contextMenu);
|
|
7000
|
+
this.backgroundColor = ((_c = config.canvas) === null || _c === void 0 ? void 0 : _c.backgroundColor) || '#FFFFFF';
|
|
7001
|
+
this.gridStyle = (_f = (_e = (_d = config.canvas) === null || _d === void 0 ? void 0 : _d.grid) === null || _e === void 0 ? void 0 : _e.style) !== null && _f !== void 0 ? _f : GRID_DEFAULTS.style;
|
|
7002
|
+
this.gridSize = ((_h = (_g = config.canvas) === null || _g === void 0 ? void 0 : _g.grid) === null || _h === void 0 ? void 0 : _h.enabled) === false || ((_j = config.canvas) === null || _j === void 0 ? void 0 : _j.grid) === undefined ? 0 : Math.abs(((_l = (_k = config.canvas) === null || _k === void 0 ? void 0 : _k.grid) === null || _l === void 0 ? void 0 : _l.spacing) || GRID_DEFAULTS.spacing);
|
|
7003
|
+
this.gridThickness = Math.abs(((_o = (_m = config.canvas) === null || _m === void 0 ? void 0 : _m.grid) === null || _o === void 0 ? void 0 : _o.thickness) || GRID_DEFAULTS.thickness);
|
|
7004
|
+
this.gridColor = ((_q = (_p = config.canvas) === null || _p === void 0 ? void 0 : _p.grid) === null || _q === void 0 ? void 0 : _q.color) || GRID_DEFAULTS.color;
|
|
7005
|
+
this.snapToGrid = ((_s = (_r = config.canvas) === null || _r === void 0 ? void 0 : _r.grid) === null || _s === void 0 ? void 0 : _s.enabled) === false || ((_t = config.canvas) === null || _t === void 0 ? void 0 : _t.grid) === undefined ? false : ((_v = (_u = config.canvas) === null || _u === void 0 ? void 0 : _u.grid) === null || _v === void 0 ? void 0 : _v.snap) || GRID_DEFAULTS.snap;
|
|
7006
|
+
this.zoomFactor = ((_w = config.canvas) === null || _w === void 0 ? void 0 : _w.zoomFactor) || 2;
|
|
7007
|
+
this.panRate = ((_x = config.canvas) === null || _x === void 0 ? void 0 : _x.panRate) || 100;
|
|
7008
|
+
this.inferConnectionType = ((_y = config.connectionSettings) === null || _y === void 0 ? void 0 : _y.inferConnectionType) || false;
|
|
7009
|
+
this.autoTightenConnections = ((_z = config.connectionSettings) === null || _z === void 0 ? void 0 : _z.autoTighten) !== false;
|
|
7010
|
+
this.allowConnectionLoops = ((_0 = config.connectionSettings) === null || _0 === void 0 ? void 0 : _0.allowLoops) || false;
|
|
7011
|
+
this.allowSharingPorts = ((_1 = config.connectionSettings) === null || _1 === void 0 ? void 0 : _1.sharePorts) !== false;
|
|
7012
|
+
this.allowSharingBothPorts = ((_2 = config.connectionSettings) === null || _2 === void 0 ? void 0 : _2.shareBothPorts) || false;
|
|
7013
|
+
this.portHighlightRadius = ((_3 = config.connectionSettings) === null || _3 === void 0 ? void 0 : _3.portHighlightRadius) || 100;
|
|
6966
7014
|
this.multipleSelectionOn = false;
|
|
6967
|
-
this.priorityThresholds = ((
|
|
7015
|
+
this.priorityThresholds = ((_4 = config.canvas) === null || _4 === void 0 ? void 0 : _4.priorityThresholds) || [];
|
|
6968
7016
|
this.priorityThreshold = this.priorityThresholds ? this.priorityThresholds[0] : undefined;
|
|
6969
7017
|
this.layoutFormat = config.layoutFormat;
|
|
6970
7018
|
this.userActions = config.userActions || {};
|
|
@@ -6991,7 +7039,7 @@ class DiagramCanvas {
|
|
|
6991
7039
|
const connectionType = new DiagramConnectionType(Object.assign(Object.assign({}, config.connectionTypeDefaults), connectionTypeConfig));
|
|
6992
7040
|
this.model.connections.types.add(connectionType);
|
|
6993
7041
|
}
|
|
6994
|
-
this._connectionType = config.defaultConnection !== undefined ? this.model.connections.types.get(config.defaultConnection) : undefined;
|
|
7042
|
+
this._connectionType = ((_5 = config === null || config === void 0 ? void 0 : config.connectionSettings) === null || _5 === void 0 ? void 0 : _5.defaultConnection) !== undefined ? this.model.connections.types.get(config.connectionSettings.defaultConnection) : undefined;
|
|
6995
7043
|
}
|
|
6996
7044
|
}
|
|
6997
7045
|
addValidator(validator) {
|
|
@@ -7839,7 +7887,7 @@ class DiagramCanvas {
|
|
|
7839
7887
|
if (this.multipleSelectionOn || this.secondaryButton) {
|
|
7840
7888
|
this.startMultipleSelection(event);
|
|
7841
7889
|
} else {
|
|
7842
|
-
if (this.canUserPerformAction(DiagramActions.AddConnection) && !d.removed) {
|
|
7890
|
+
if (this.canUserPerformAction(DiagramActions.AddConnection) && (this.allowSharingPorts || d.incomingConnections.length === 0 && d.outgoingConnections.length === 0) && !d.removed) {
|
|
7843
7891
|
setCursorStyle(CursorStyle.Grabbing);
|
|
7844
7892
|
this.startConnection(d);
|
|
7845
7893
|
// should be true after having called this.startConnection()
|
|
@@ -7858,7 +7906,7 @@ class DiagramCanvas {
|
|
|
7858
7906
|
if (this.canUserPerformAction(DiagramActions.AddConnection) && !d.removed) {
|
|
7859
7907
|
if (this.unfinishedConnection !== undefined) {
|
|
7860
7908
|
const endCoords = [event.x, event.y];
|
|
7861
|
-
(_a = this.unfinishedConnectionTracer) === null || _a === void 0 ? void 0 : _a.attr('d', getConnectionPath(this.unfinishedConnection.look.shape, this.unfinishedConnection.startCoords, endCoords, this.unfinishedConnection.startDirection, this.unfinishedConnection.endDirection, this.unfinishedConnection.look.thickness, (_b = this.unfinishedConnection.startMarkerLook) === null || _b === void 0 ? void 0 : _b.width, (_c = this.unfinishedConnection.endMarkerLook) === null || _c === void 0 ? void 0 : _c.width));
|
|
7909
|
+
(_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.look.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness, (_b = this.unfinishedConnection.startMarkerLook) === null || _b === void 0 ? void 0 : _b.width, (_c = this.unfinishedConnection.endMarkerLook) === null || _c === void 0 ? void 0 : _c.width));
|
|
7862
7910
|
const unfinishedConnectionGhostNode = (_d = this.unfinishedConnectionTracer) === null || _d === void 0 ? void 0 : _d.node();
|
|
7863
7911
|
if (unfinishedConnectionGhostNode) {
|
|
7864
7912
|
let margin = 2;
|
|
@@ -7885,7 +7933,7 @@ class DiagramCanvas {
|
|
|
7885
7933
|
closestPortFound = port;
|
|
7886
7934
|
}
|
|
7887
7935
|
}
|
|
7888
|
-
if (closestPortFound && minDistanceFound <
|
|
7936
|
+
if (closestPortFound && minDistanceFound < this.portHighlightRadius) {
|
|
7889
7937
|
this.userHighlight.focusOn(closestPortFound);
|
|
7890
7938
|
} else {
|
|
7891
7939
|
this.userHighlight.clear();
|
|
@@ -8006,14 +8054,14 @@ class DiagramCanvas {
|
|
|
8006
8054
|
enterSelection.select('g.diagram-connection-end-label').append('text').style('user-select', 'none');
|
|
8007
8055
|
mergeSelection.attr('opacity', d => d.removed ? 0.5 : 1).select('path.diagram-connection-path').attr('d', d => {
|
|
8008
8056
|
var _a, _b;
|
|
8009
|
-
return getConnectionPath(d.look.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.look.thickness, (_a = d.startMarkerLook) === null || _a === void 0 ? void 0 : _a.width, (_b = d.endMarkerLook) === null || _b === void 0 ? void 0 : _b.width);
|
|
8010
|
-
}).attr('marker-start', d => `url(#${d.id}-start-marker)`).attr('marker-end', d => `url(#${d.id}-end-marker)`).attr('stroke', d => d.look.color).attr('stroke-width', d => `${d.look.thickness}px`).attr('stroke-dasharray', d => lineStyleDasharray(d.look.style, d.look.thickness)).attr('fill', 'none');
|
|
8057
|
+
return getConnectionPath(d.look.shape || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.look.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness, (_a = d.startMarkerLook) === null || _a === void 0 ? void 0 : _a.width, (_b = d.endMarkerLook) === null || _b === void 0 ? void 0 : _b.width);
|
|
8058
|
+
}).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.look.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness)).attr('fill', 'none');
|
|
8011
8059
|
mergeSelection.select('path.diagram-connection-path-box').attr('d', d => {
|
|
8012
8060
|
var _a, _b;
|
|
8013
|
-
return getConnectionPath(d.look.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.look.thickness, (_a = d.startMarkerLook) === null || _a === void 0 ? void 0 : _a.width, (_b = d.endMarkerLook) === null || _b === void 0 ? void 0 : _b.width);
|
|
8061
|
+
return getConnectionPath(d.look.shape || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.look.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness, (_a = d.startMarkerLook) === null || _a === void 0 ? void 0 : _a.width, (_b = d.endMarkerLook) === null || _b === void 0 ? void 0 : _b.width);
|
|
8014
8062
|
}).attr('stroke', 'transparent')
|
|
8015
8063
|
// allow generating pointer events even when it is transparent
|
|
8016
|
-
.attr('pointer-events', 'stroke').attr('stroke-width', d => `${d.look.thickness + CONNECTION_PATH_BOX_THICKNESS}px`).attr('stroke-dasharray', d => lineStyleDasharray(d.look.style, d.look.thickness)).attr('fill', 'none');
|
|
8064
|
+
.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.look.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness)).attr('fill', 'none');
|
|
8017
8065
|
mergeSelection.data().forEach(connection => {
|
|
8018
8066
|
this.updateConnectionLabelsInView(connection);
|
|
8019
8067
|
this.updateConnectionMarkersInView(connection);
|
|
@@ -8290,6 +8338,77 @@ class DiagramCanvas {
|
|
|
8290
8338
|
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), connection.type.label);
|
|
8291
8339
|
if (pathNode) {
|
|
8292
8340
|
const pathLength = pathNode.getTotalLength();
|
|
8341
|
+
let startLabelShiftX = 0;
|
|
8342
|
+
let startLabelShiftY = 0;
|
|
8343
|
+
let middleLabelShiftX = 0;
|
|
8344
|
+
let middleLabelShiftY = 0;
|
|
8345
|
+
let endLabelShiftX = 0;
|
|
8346
|
+
let endLabelShiftY = 0;
|
|
8347
|
+
if (labelConfiguration.backgroundColor === '#00000000') {
|
|
8348
|
+
// background color is transparent / not set, so we find an alternative position for the label
|
|
8349
|
+
const deltaX = connection.endCoords[0] - connection.startCoords[0];
|
|
8350
|
+
const deltaY = connection.endCoords[1] - connection.startCoords[1];
|
|
8351
|
+
switch (connection.startDirection) {
|
|
8352
|
+
case Side.Top:
|
|
8353
|
+
startLabelShiftX = deltaX >= 0 ? 1 : -1;
|
|
8354
|
+
middleLabelShiftX = startLabelShiftX;
|
|
8355
|
+
endLabelShiftX = startLabelShiftX;
|
|
8356
|
+
startLabelShiftY = -1;
|
|
8357
|
+
break;
|
|
8358
|
+
case Side.Bottom:
|
|
8359
|
+
startLabelShiftX = deltaX >= 0 ? 1 : -1;
|
|
8360
|
+
middleLabelShiftX = startLabelShiftX;
|
|
8361
|
+
endLabelShiftX = startLabelShiftX;
|
|
8362
|
+
startLabelShiftY = 1;
|
|
8363
|
+
break;
|
|
8364
|
+
case Side.Left:
|
|
8365
|
+
startLabelShiftX = -1;
|
|
8366
|
+
startLabelShiftY = deltaY > 0 ? 1 : -1;
|
|
8367
|
+
middleLabelShiftY = startLabelShiftY;
|
|
8368
|
+
endLabelShiftY = startLabelShiftY;
|
|
8369
|
+
break;
|
|
8370
|
+
case Side.Right:
|
|
8371
|
+
startLabelShiftX = 1;
|
|
8372
|
+
startLabelShiftY = deltaY > 0 ? 1 : -1;
|
|
8373
|
+
middleLabelShiftY = startLabelShiftY;
|
|
8374
|
+
endLabelShiftY = startLabelShiftY;
|
|
8375
|
+
break;
|
|
8376
|
+
default:
|
|
8377
|
+
startLabelShiftX = 1;
|
|
8378
|
+
middleLabelShiftX = startLabelShiftX;
|
|
8379
|
+
endLabelShiftX = startLabelShiftX;
|
|
8380
|
+
startLabelShiftY = -1;
|
|
8381
|
+
middleLabelShiftY = startLabelShiftY;
|
|
8382
|
+
endLabelShiftY = startLabelShiftY;
|
|
8383
|
+
}
|
|
8384
|
+
switch (connection.endDirection) {
|
|
8385
|
+
case Side.Top:
|
|
8386
|
+
endLabelShiftX = deltaX >= 0 ? 1 : -1;
|
|
8387
|
+
middleLabelShiftX = endLabelShiftX;
|
|
8388
|
+
endLabelShiftY = 1;
|
|
8389
|
+
break;
|
|
8390
|
+
case Side.Bottom:
|
|
8391
|
+
endLabelShiftX = deltaX >= 0 ? 1 : -1;
|
|
8392
|
+
middleLabelShiftX = endLabelShiftX;
|
|
8393
|
+
endLabelShiftY = -1;
|
|
8394
|
+
break;
|
|
8395
|
+
case Side.Left:
|
|
8396
|
+
endLabelShiftX = -1;
|
|
8397
|
+
endLabelShiftY = deltaY > 0 ? 1 : -1;
|
|
8398
|
+
middleLabelShiftY = endLabelShiftY;
|
|
8399
|
+
break;
|
|
8400
|
+
case Side.Right:
|
|
8401
|
+
endLabelShiftX = 1;
|
|
8402
|
+
endLabelShiftY = deltaY > 0 ? 1 : -1;
|
|
8403
|
+
middleLabelShiftY = endLabelShiftY;
|
|
8404
|
+
break;
|
|
8405
|
+
default:
|
|
8406
|
+
endLabelShiftX = 1;
|
|
8407
|
+
middleLabelShiftX = endLabelShiftX;
|
|
8408
|
+
endLabelShiftY = -1;
|
|
8409
|
+
middleLabelShiftY = endLabelShiftY;
|
|
8410
|
+
}
|
|
8411
|
+
}
|
|
8293
8412
|
// bind start labels
|
|
8294
8413
|
connectionSelection.select('g.diagram-connection-start-label text').attr('x', 0).attr('y', labelConfiguration.fontSize / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.fontFamily).attr('font-size', labelConfiguration.fontSize).attr('fill', connection.selected ? labelConfiguration.selectedColor : labelConfiguration.color).style('font-kerning', 'none').text(connection.startLabel);
|
|
8295
8414
|
const startLabelBoundingRect = (_a = connectionSelection.select('g.diagram-connection-start-label text').node()) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
@@ -8298,8 +8417,8 @@ class DiagramCanvas {
|
|
|
8298
8417
|
const boundingWidth = !connection.startLabel ? 0 : startLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
|
|
8299
8418
|
const boundingHeight = !connection.startLabel ? 0 : startLabelBoundingRect.height / this.zoomTransform.k + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
|
|
8300
8419
|
const pathStartLabelPoint = pathNode.getPointAtLength(Math.max(getLeftMargin(labelConfiguration) + boundingWidth / 2, getRightMargin(labelConfiguration) + boundingWidth / 2, getTopMargin(labelConfiguration) + boundingHeight / 2, getBottomMargin(labelConfiguration) + boundingHeight / 2));
|
|
8301
|
-
connectionSelection.select('g.diagram-connection-start-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill',
|
|
8302
|
-
connectionSelection.select('g.diagram-connection-start-label').attr('transform', `translate(${pathStartLabelPoint.x},${pathStartLabelPoint.y})`);
|
|
8420
|
+
connectionSelection.select('g.diagram-connection-start-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.backgroundColor).attr('stroke', 'none');
|
|
8421
|
+
connectionSelection.select('g.diagram-connection-start-label').attr('transform', `translate(${pathStartLabelPoint.x + startLabelShiftX * boundingWidth},${pathStartLabelPoint.y + startLabelShiftY * boundingHeight})`);
|
|
8303
8422
|
}
|
|
8304
8423
|
// bind middle labels
|
|
8305
8424
|
connectionSelection.select('g.diagram-connection-middle-label text').attr('x', 0).attr('y', labelConfiguration.fontSize / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.fontFamily).attr('font-size', labelConfiguration.fontSize).attr('fill', connection.selected ? labelConfiguration.selectedColor : labelConfiguration.color).style('font-kerning', 'none').text(connection.middleLabel);
|
|
@@ -8309,8 +8428,8 @@ class DiagramCanvas {
|
|
|
8309
8428
|
const boundingWidth = !connection.middleLabel ? 0 : middleLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
|
|
8310
8429
|
const boundingHeight = !connection.middleLabel ? 0 : middleLabelBoundingRect.height / this.zoomTransform.k + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
|
|
8311
8430
|
const pathMiddleLabelPoint = pathNode.getPointAtLength(pathLength / 2);
|
|
8312
|
-
connectionSelection.select('g.diagram-connection-middle-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill',
|
|
8313
|
-
connectionSelection.select('g.diagram-connection-middle-label').attr('transform', `translate(${pathMiddleLabelPoint.x},${pathMiddleLabelPoint.y})`);
|
|
8431
|
+
connectionSelection.select('g.diagram-connection-middle-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.backgroundColor).attr('stroke', 'none');
|
|
8432
|
+
connectionSelection.select('g.diagram-connection-middle-label').attr('transform', `translate(${pathMiddleLabelPoint.x + middleLabelShiftX * boundingWidth},${pathMiddleLabelPoint.y + middleLabelShiftY * boundingHeight})`);
|
|
8314
8433
|
}
|
|
8315
8434
|
// bind end labels
|
|
8316
8435
|
connectionSelection.select('g.diagram-connection-end-label text').attr('x', 0).attr('y', labelConfiguration.fontSize / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.fontFamily).attr('font-size', labelConfiguration.fontSize).attr('fill', connection.selected ? labelConfiguration.selectedColor : labelConfiguration.color).style('font-kerning', 'none').text(connection.endLabel);
|
|
@@ -8320,8 +8439,8 @@ class DiagramCanvas {
|
|
|
8320
8439
|
const boundingWidth = !connection.endLabel ? 0 : endLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
|
|
8321
8440
|
const boundingHeight = !connection.endLabel ? 0 : endLabelBoundingRect.height / this.zoomTransform.k + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
|
|
8322
8441
|
const pathEndLabelPoint = pathNode.getPointAtLength(pathLength - Math.max(getLeftMargin(labelConfiguration) + boundingWidth / 2, getRightMargin(labelConfiguration) + boundingWidth / 2, getTopMargin(labelConfiguration) + boundingHeight / 2, getBottomMargin(labelConfiguration) + boundingHeight / 2));
|
|
8323
|
-
connectionSelection.select('g.diagram-connection-end-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill',
|
|
8324
|
-
connectionSelection.select('g.diagram-connection-end-label').attr('transform', `translate(${pathEndLabelPoint.x},${pathEndLabelPoint.y})`);
|
|
8442
|
+
connectionSelection.select('g.diagram-connection-end-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.backgroundColor).attr('stroke', 'none');
|
|
8443
|
+
connectionSelection.select('g.diagram-connection-end-label').attr('transform', `translate(${pathEndLabelPoint.x + endLabelShiftX * boundingWidth},${pathEndLabelPoint.y + endLabelShiftY * boundingHeight})`);
|
|
8325
8444
|
}
|
|
8326
8445
|
}
|
|
8327
8446
|
}
|
|
@@ -8493,51 +8612,61 @@ class DiagramCanvas {
|
|
|
8493
8612
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
8494
8613
|
this.userHighlight.clear();
|
|
8495
8614
|
if (this.unfinishedConnection !== undefined) {
|
|
8496
|
-
if (this.unfinishedConnection.start
|
|
8497
|
-
|
|
8498
|
-
|
|
8499
|
-
|
|
8500
|
-
|
|
8501
|
-
|
|
8502
|
-
|
|
8503
|
-
|
|
8504
|
-
|
|
8505
|
-
|
|
8506
|
-
|
|
8507
|
-
|
|
8508
|
-
|
|
8509
|
-
|
|
8510
|
-
|
|
8511
|
-
|
|
8615
|
+
if (!this.allowConnectionLoops && this.unfinishedConnection.start === port) {
|
|
8616
|
+
this.dropConnection();
|
|
8617
|
+
return;
|
|
8618
|
+
}
|
|
8619
|
+
if (!this.allowSharingPorts && (port.incomingConnections.length > 0 || port.outgoingConnections.length > 0)) {
|
|
8620
|
+
this.dropConnection();
|
|
8621
|
+
return;
|
|
8622
|
+
}
|
|
8623
|
+
if (!this.allowSharingBothPorts && this.model.connections.find(c => {
|
|
8624
|
+
var _a, _b;
|
|
8625
|
+
return c.start === ((_a = this.unfinishedConnection) === null || _a === void 0 ? void 0 : _a.start) && c.end === port || c.end === ((_b = this.unfinishedConnection) === null || _b === void 0 ? void 0 : _b.start) && c.start === port;
|
|
8626
|
+
}) !== undefined) {
|
|
8627
|
+
this.dropConnection();
|
|
8628
|
+
return;
|
|
8629
|
+
}
|
|
8630
|
+
if (this.unfinishedConnection.type.canStartFromType(((_d = (_c = (_b = (_a = this.unfinishedConnection) === null || _a === void 0 ? void 0 : _a.start) === null || _b === void 0 ? void 0 : _b.getNode()) === null || _c === void 0 ? void 0 : _c.type) === null || _d === void 0 ? void 0 : _d.id) || '') && ((_f = (_e = this.unfinishedConnection) === null || _e === void 0 ? void 0 : _e.start) === null || _f === void 0 ? void 0 : _f.allowsOutgoing) && this.unfinishedConnection.type.canFinishOnType(((_h = (_g = port.getNode()) === null || _g === void 0 ? void 0 : _g.type) === null || _h === void 0 ? void 0 : _h.id) || '') && port.allowsIncoming) {
|
|
8631
|
+
const addConnectionAction = new AddConnectionAction(this, this.unfinishedConnection.type, (_j = this.unfinishedConnection.start) === null || _j === void 0 ? void 0 : _j.id, port.id);
|
|
8632
|
+
// clean up the previous unfinished connection
|
|
8633
|
+
this.dropConnection();
|
|
8634
|
+
addConnectionAction.do();
|
|
8635
|
+
this.actionStack.add(addConnectionAction);
|
|
8636
|
+
} else if (this.unfinishedConnection.type.canFinishOnType(((_o = (_m = (_l = (_k = this.unfinishedConnection) === null || _k === void 0 ? void 0 : _k.start) === null || _l === void 0 ? void 0 : _l.getNode()) === null || _m === void 0 ? void 0 : _m.type) === null || _o === void 0 ? void 0 : _o.id) || '') && ((_q = (_p = this.unfinishedConnection) === null || _p === void 0 ? void 0 : _p.start) === null || _q === void 0 ? void 0 : _q.allowsIncoming) && this.unfinishedConnection.type.canStartFromType(((_s = (_r = port.getNode()) === null || _r === void 0 ? void 0 : _r.type) === null || _s === void 0 ? void 0 : _s.id) || '') && port.allowsOutgoing) {
|
|
8637
|
+
const addConnectionAction = new AddConnectionAction(this, this.unfinishedConnection.type, port.id, (_t = this.unfinishedConnection.start) === null || _t === void 0 ? void 0 : _t.id);
|
|
8638
|
+
// clean up the previous unfinished connection
|
|
8639
|
+
this.dropConnection();
|
|
8640
|
+
addConnectionAction.do();
|
|
8641
|
+
this.actionStack.add(addConnectionAction);
|
|
8642
|
+
} else {
|
|
8643
|
+
if (this.inferConnectionType) {
|
|
8644
|
+
let differentConnectionType = this.model.connections.types.all().find(t => {
|
|
8645
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
8646
|
+
return t.canStartFromType(((_d = (_c = (_b = (_a = this.unfinishedConnection) === null || _a === void 0 ? void 0 : _a.start) === null || _b === void 0 ? void 0 : _b.getNode()) === null || _c === void 0 ? void 0 : _c.type) === null || _d === void 0 ? void 0 : _d.id) || '') && ((_f = (_e = this.unfinishedConnection) === null || _e === void 0 ? void 0 : _e.start) === null || _f === void 0 ? void 0 : _f.allowsOutgoing) && t.canFinishOnType(((_h = (_g = port.getNode()) === null || _g === void 0 ? void 0 : _g.type) === null || _h === void 0 ? void 0 : _h.id) || '') && port.allowsIncoming;
|
|
8647
|
+
});
|
|
8648
|
+
let invertConnection = false;
|
|
8649
|
+
if (differentConnectionType === undefined) {
|
|
8650
|
+
differentConnectionType = this.model.connections.types.all().find(t => {
|
|
8512
8651
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
8513
|
-
return t.
|
|
8652
|
+
return t.canFinishOnType(((_d = (_c = (_b = (_a = this.unfinishedConnection) === null || _a === void 0 ? void 0 : _a.start) === null || _b === void 0 ? void 0 : _b.getNode()) === null || _c === void 0 ? void 0 : _c.type) === null || _d === void 0 ? void 0 : _d.id) || '') && ((_f = (_e = this.unfinishedConnection) === null || _e === void 0 ? void 0 : _e.start) === null || _f === void 0 ? void 0 : _f.allowsIncoming) && t.canStartFromType(((_h = (_g = port.getNode()) === null || _g === void 0 ? void 0 : _g.type) === null || _h === void 0 ? void 0 : _h.id) || '') && port.allowsOutgoing;
|
|
8514
8653
|
});
|
|
8515
|
-
|
|
8516
|
-
|
|
8517
|
-
|
|
8518
|
-
|
|
8519
|
-
|
|
8520
|
-
|
|
8521
|
-
|
|
8522
|
-
|
|
8523
|
-
if (differentConnectionType !== undefined) {
|
|
8524
|
-
const addConnectionAction = new AddConnectionAction(this, differentConnectionType, invertConnection ? port.id : (_u = this.unfinishedConnection.start) === null || _u === void 0 ? void 0 : _u.id, invertConnection ? (_v = this.unfinishedConnection.start) === null || _v === void 0 ? void 0 : _v.id : port.id);
|
|
8525
|
-
// clean up the previous unfinished connection
|
|
8526
|
-
this.dropConnection();
|
|
8527
|
-
addConnectionAction.do();
|
|
8528
|
-
this.actionStack.add(addConnectionAction);
|
|
8529
|
-
} else {
|
|
8530
|
-
// error: connection target of wrong type and no allowed type can be found
|
|
8531
|
-
this.dropConnection();
|
|
8532
|
-
}
|
|
8654
|
+
invertConnection = true;
|
|
8655
|
+
}
|
|
8656
|
+
if (differentConnectionType !== undefined) {
|
|
8657
|
+
const addConnectionAction = new AddConnectionAction(this, differentConnectionType, invertConnection ? port.id : (_u = this.unfinishedConnection.start) === null || _u === void 0 ? void 0 : _u.id, invertConnection ? (_v = this.unfinishedConnection.start) === null || _v === void 0 ? void 0 : _v.id : port.id);
|
|
8658
|
+
// clean up the previous unfinished connection
|
|
8659
|
+
this.dropConnection();
|
|
8660
|
+
addConnectionAction.do();
|
|
8661
|
+
this.actionStack.add(addConnectionAction);
|
|
8533
8662
|
} else {
|
|
8534
|
-
// error: connection target of wrong type and
|
|
8663
|
+
// error: connection target of wrong type and no allowed type can be found
|
|
8535
8664
|
this.dropConnection();
|
|
8536
8665
|
}
|
|
8666
|
+
} else {
|
|
8667
|
+
// error: connection target of wrong type and can't guess for a different type
|
|
8668
|
+
this.dropConnection();
|
|
8537
8669
|
}
|
|
8538
|
-
} else {
|
|
8539
|
-
// error: start port of a connection can't also be the end port
|
|
8540
|
-
this.dropConnection();
|
|
8541
8670
|
}
|
|
8542
8671
|
}
|
|
8543
8672
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as d3 from 'd3';
|
|
2
2
|
import { Point } from '../../util/canvas-util';
|
|
3
|
-
import { LineFunction, LineShape } from '../../util/line';
|
|
3
|
+
import { LineFunction, LineShape, LineStyle } from '../../util/line';
|
|
4
4
|
import { CursorStyle } from '../../util/style';
|
|
5
5
|
import { Side } from '../../util/svg-util';
|
|
6
6
|
import { DiagramField } from '../model/diagram-field';
|
|
@@ -24,6 +24,12 @@ export declare const getConnectionPath: (shape: LineShape | LineFunction, startC
|
|
|
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
26
|
export declare const initializeLook: (selection: d3.Selection<SVGGElement, DiagramNode | DiagramSection | DiagramPort, d3.BaseType, unknown>) => void;
|
|
27
|
+
export declare const SHAPED_LOOK_DEFAULTS: {
|
|
28
|
+
fillColor: string;
|
|
29
|
+
borderColor: string;
|
|
30
|
+
borderThickness: number;
|
|
31
|
+
borderStyle: LineStyle;
|
|
32
|
+
};
|
|
27
33
|
export declare const updateLook: (selection: d3.Selection<SVGGElement, DiagramNode | DiagramSection | DiagramPort, d3.BaseType, unknown>) => void;
|
|
28
34
|
export declare const GRID_DEFAULTS: {
|
|
29
35
|
enabled: boolean;
|
|
@@ -49,10 +49,15 @@ export declare class DiagramCanvas implements Canvas {
|
|
|
49
49
|
zoomFactor: number;
|
|
50
50
|
panRate: number;
|
|
51
51
|
inferConnectionType: boolean;
|
|
52
|
-
multipleSelectionOn: boolean;
|
|
53
52
|
private _connectionType?;
|
|
54
53
|
get connectionType(): DiagramConnectionType | undefined;
|
|
55
54
|
set connectionType(value: DiagramConnectionType | undefined);
|
|
55
|
+
autoTightenConnections: boolean;
|
|
56
|
+
allowConnectionLoops: boolean;
|
|
57
|
+
allowSharingPorts: boolean;
|
|
58
|
+
allowSharingBothPorts: boolean;
|
|
59
|
+
portHighlightRadius: number;
|
|
60
|
+
multipleSelectionOn: boolean;
|
|
56
61
|
layoutFormat?: string;
|
|
57
62
|
validators: DiagramValidator[];
|
|
58
63
|
userActions: {
|
|
@@ -8,12 +8,16 @@ import { DiagramElement, DiagramElementSet } from '../model/diagram-element';
|
|
|
8
8
|
export declare class DiagramUserHighlight extends DiagramElementSet<DiagramElement> {
|
|
9
9
|
private readonly canvas;
|
|
10
10
|
private focus?;
|
|
11
|
+
/**
|
|
12
|
+
* Whether sections can be highlighted individually or the whole node must be highlighted when highlighting a section.
|
|
13
|
+
*/
|
|
14
|
+
private highlightSections;
|
|
11
15
|
/**
|
|
12
16
|
* Constructs a user highlight object.
|
|
13
17
|
* @public
|
|
14
18
|
* @param canvas A canvas.
|
|
15
19
|
*/
|
|
16
|
-
constructor(canvas: Canvas);
|
|
20
|
+
constructor(canvas: Canvas, highlightSections?: boolean);
|
|
17
21
|
/**
|
|
18
22
|
* Gets the focus of the user highlight, which is the element where the current user highlight started regardless of which other elements were highlighted as a consequence.
|
|
19
23
|
* @public
|
|
@@ -30,6 +30,11 @@ export interface CanvasConfig {
|
|
|
30
30
|
* @default 100
|
|
31
31
|
*/
|
|
32
32
|
panRate?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Whether sections can be highlighted individually or the whole node must be highlighted when highlighting a section.
|
|
35
|
+
* @default true
|
|
36
|
+
*/
|
|
37
|
+
highlightSections?: boolean;
|
|
33
38
|
/**
|
|
34
39
|
* Possible values of the priority threshold that the user can toggle between to hide nodes whose priority value is below it.
|
|
35
40
|
* If it is possible to toggle the priority threshold via the filter button, it should have at least two values.
|