@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/Changelog.md
CHANGED
|
@@ -6,9 +6,22 @@ List of releases and changes.
|
|
|
6
6
|
|
|
7
7
|
## Next release Joyeuse
|
|
8
8
|
|
|
9
|
+
## v. 4.2.4
|
|
10
|
+
|
|
11
|
+
- Enable configuring line style in shaped looks [#313](https://github.com/metadevpro/daga/pull/313)
|
|
12
|
+
- Enable default values for parameters of looks [#313](https://github.com/metadevpro/daga/pull/313)
|
|
13
|
+
- Use optional `label` fields in `Property` [#314](https://github.com/metadevpro/daga/pull/314)
|
|
14
|
+
- Use default values for `basic` and `editable` fields of `Property` [#315](https://github.com/metadevpro/daga/pull/315)
|
|
15
|
+
|
|
16
|
+
## v. 4.2.3
|
|
17
|
+
|
|
18
|
+
- Enable toggling whether individual sections can be highlighted or entire nodes [#308](https://github.com/metadevpro/daga/pull/308)
|
|
19
|
+
- Enable toggling whether connections tighten automatically and whether they can loop and share ports [#309](https://github.com/metadevpro/daga/pull/309)
|
|
20
|
+
- Enable toggling background color of connection label [#310](https://github.com/metadevpro/daga/pull/310)
|
|
21
|
+
|
|
9
22
|
## v. 4.2.2
|
|
10
23
|
|
|
11
|
-
- Fix zoom on double
|
|
24
|
+
- Fix zoom on double click [#307](https://github.com/metadevpro/daga/pull/307)
|
|
12
25
|
|
|
13
26
|
## v. 4.2.1
|
|
14
27
|
|
package/index.cjs.js
CHANGED
|
@@ -1224,8 +1224,9 @@ class DiagramElementSet extends DiagramEntitySet {
|
|
|
1224
1224
|
* @see ValueSet
|
|
1225
1225
|
*/
|
|
1226
1226
|
class Property {
|
|
1227
|
-
constructor(name, type, defaultValue, basic, editable, rootAttribute) {
|
|
1227
|
+
constructor(name, label, type, defaultValue, basic, editable, rootAttribute) {
|
|
1228
1228
|
this.name = name;
|
|
1229
|
+
this.label = label;
|
|
1229
1230
|
this.type = type;
|
|
1230
1231
|
this.defaultValue = defaultValue;
|
|
1231
1232
|
this.basic = basic;
|
|
@@ -1745,7 +1746,7 @@ class ValueSet {
|
|
|
1745
1746
|
this.setRootElementValue(rootAttribute, this.values[key]);
|
|
1746
1747
|
}
|
|
1747
1748
|
}
|
|
1748
|
-
if (property.basic) {
|
|
1749
|
+
if (property.basic !== false) {
|
|
1749
1750
|
this.displayedProperties.push(property);
|
|
1750
1751
|
} else {
|
|
1751
1752
|
this.hiddenProperties.push(property);
|
|
@@ -2138,11 +2139,14 @@ class DiagramConnection extends DiagramElement {
|
|
|
2138
2139
|
* @public
|
|
2139
2140
|
*/
|
|
2140
2141
|
tighten() {
|
|
2141
|
-
var _a, _b;
|
|
2142
|
-
|
|
2142
|
+
var _a, _b, _c, _d, _e;
|
|
2143
|
+
const allowConnectionLoops = ((_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.allowConnectionLoops) || false;
|
|
2144
|
+
const allowSharingPorts = ((_b = this.model.canvas) === null || _b === void 0 ? void 0 : _b.allowSharingPorts) !== false;
|
|
2145
|
+
const allowSharingBothPorts = ((_c = this.model.canvas) === null || _c === void 0 ? void 0 : _c.allowSharingBothPorts) || false;
|
|
2146
|
+
if (((_d = this.start) === null || _d === void 0 ? void 0 : _d.rootElement) && this.end) {
|
|
2143
2147
|
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]);
|
|
2144
2148
|
checkAlternativeStartPorts: for (const alternativeStartPort of alternativeStartPortsSortedByDistanceAscending) {
|
|
2145
|
-
if (alternativeStartPort === this.end) {
|
|
2149
|
+
if (!allowConnectionLoops && alternativeStartPort === this.end) {
|
|
2146
2150
|
// alternative start port not valid, it is the same as the end port
|
|
2147
2151
|
continue checkAlternativeStartPorts;
|
|
2148
2152
|
}
|
|
@@ -2150,7 +2154,11 @@ class DiagramConnection extends DiagramElement {
|
|
|
2150
2154
|
// alternative start port not valid, it doesn't allow outgoing connections
|
|
2151
2155
|
continue checkAlternativeStartPorts;
|
|
2152
2156
|
}
|
|
2153
|
-
{
|
|
2157
|
+
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)) {
|
|
2158
|
+
// alternative start port not valid, it already has other connections
|
|
2159
|
+
continue checkAlternativeStartPorts;
|
|
2160
|
+
}
|
|
2161
|
+
if (!allowSharingBothPorts) {
|
|
2154
2162
|
for (const connection of alternativeStartPort.outgoingConnections) {
|
|
2155
2163
|
if (connection !== this && connection.end === this.end) {
|
|
2156
2164
|
// alternative start port not valid, there is a connection whose start and end matches the alternative start port and this connection's end
|
|
@@ -2173,10 +2181,10 @@ class DiagramConnection extends DiagramElement {
|
|
|
2173
2181
|
}
|
|
2174
2182
|
}
|
|
2175
2183
|
}
|
|
2176
|
-
if (((
|
|
2184
|
+
if (((_e = this.end) === null || _e === void 0 ? void 0 : _e.rootElement) && this.start) {
|
|
2177
2185
|
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]);
|
|
2178
2186
|
checkAlternativeEndPorts: for (const alternativeEndPort of alternativeEndPortsSortedByDistanceAscending) {
|
|
2179
|
-
if (alternativeEndPort === this.start) {
|
|
2187
|
+
if (!allowConnectionLoops && alternativeEndPort === this.start) {
|
|
2180
2188
|
// alternative end port not valid, it is the same as the end port
|
|
2181
2189
|
continue checkAlternativeEndPorts;
|
|
2182
2190
|
}
|
|
@@ -2184,7 +2192,11 @@ class DiagramConnection extends DiagramElement {
|
|
|
2184
2192
|
// alternative end port not valid, it doesn't allow incoming connections
|
|
2185
2193
|
continue checkAlternativeEndPorts;
|
|
2186
2194
|
}
|
|
2187
|
-
{
|
|
2195
|
+
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)) {
|
|
2196
|
+
// alternative end port not valid, it already has other connections
|
|
2197
|
+
continue checkAlternativeEndPorts;
|
|
2198
|
+
}
|
|
2199
|
+
if (!allowSharingBothPorts) {
|
|
2188
2200
|
for (const connection of alternativeEndPort.incomingConnections) {
|
|
2189
2201
|
if (connection !== this && connection.start === this.start) {
|
|
2190
2202
|
// alternative end port not valid, there is a connection whose start and end matches the alternative end port and this connection's start
|
|
@@ -2292,6 +2304,7 @@ const DIAGRAM_FIELD_DEFAULTS = {
|
|
|
2292
2304
|
fontFamily: "'Wonder Unit Sans', sans-serif",
|
|
2293
2305
|
color: '#000000',
|
|
2294
2306
|
selectedColor: '#000000',
|
|
2307
|
+
backgroundColor: '#00000000',
|
|
2295
2308
|
horizontalAlign: exports.HorizontalAlign.Center,
|
|
2296
2309
|
verticalAlign: exports.VerticalAlign.Center,
|
|
2297
2310
|
orientation: exports.Side.Top,
|
|
@@ -2948,6 +2961,7 @@ class DiagramSection extends DiagramElement {
|
|
|
2948
2961
|
* @public
|
|
2949
2962
|
*/
|
|
2950
2963
|
setGeometry(geometry) {
|
|
2964
|
+
var _a;
|
|
2951
2965
|
const oldCoordsX = [this.coords[0], this.coords[0] + this.width];
|
|
2952
2966
|
const oldCoordsY = [this.coords[1], this.coords[1] + this.height];
|
|
2953
2967
|
this.coords = [...geometry.coords];
|
|
@@ -2971,8 +2985,10 @@ class DiagramSection extends DiagramElement {
|
|
|
2971
2985
|
for (const decorator of this.decorators) {
|
|
2972
2986
|
decorator.move(translatePointWithAnchors(decorator.coords, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY, decorator.anchorPointX, decorator.anchorPointY));
|
|
2973
2987
|
}
|
|
2988
|
+
if (((_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.autoTightenConnections) !== false) {
|
|
2989
|
+
this.getConnections().forEach(c => c.tighten());
|
|
2990
|
+
}
|
|
2974
2991
|
// Update canvas.
|
|
2975
|
-
this.getConnections().forEach(c => c.tighten());
|
|
2976
2992
|
this.updateInView();
|
|
2977
2993
|
}
|
|
2978
2994
|
}
|
|
@@ -3691,6 +3707,7 @@ class DiagramNode extends DiagramElement {
|
|
|
3691
3707
|
* @public
|
|
3692
3708
|
*/
|
|
3693
3709
|
setGeometry(geometry) {
|
|
3710
|
+
var _a;
|
|
3694
3711
|
this.raise();
|
|
3695
3712
|
const oldCoordsX = [this.coords[0], this.coords[0] + this.width];
|
|
3696
3713
|
const oldCoordsY = [this.coords[1], this.coords[1] + this.height];
|
|
@@ -3728,8 +3745,10 @@ class DiagramNode extends DiagramElement {
|
|
|
3728
3745
|
for (const decorator of this.decorators) {
|
|
3729
3746
|
decorator.move(translatePointWithAnchors(decorator.coords, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY, decorator.anchorPointX, decorator.anchorPointY));
|
|
3730
3747
|
}
|
|
3748
|
+
if (((_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.autoTightenConnections) !== false) {
|
|
3749
|
+
this.getConnections().forEach(c => c.tighten());
|
|
3750
|
+
}
|
|
3731
3751
|
// Update canvas.
|
|
3732
|
-
this.getConnections().forEach(c => c.tighten());
|
|
3733
3752
|
this.updateInView();
|
|
3734
3753
|
}
|
|
3735
3754
|
/**
|
|
@@ -6236,8 +6255,14 @@ const initializeLook = selection => {
|
|
|
6236
6255
|
selection.filter('.stretchable-image-look').append('image').attr('class', 'bottom-image').attr('preserveAspectRatio', 'none');
|
|
6237
6256
|
selection.filter('.stretchable-image-look').append('image').attr('class', 'bottom-right-image').attr('preserveAspectRatio', 'none');
|
|
6238
6257
|
};
|
|
6258
|
+
const SHAPED_LOOK_DEFAULTS = {
|
|
6259
|
+
fillColor: '#FFFFFF',
|
|
6260
|
+
borderColor: '#000000',
|
|
6261
|
+
borderThickness: 1,
|
|
6262
|
+
borderStyle: exports.LineStyle.Solid
|
|
6263
|
+
};
|
|
6239
6264
|
const updateLook = selection => {
|
|
6240
|
-
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`);
|
|
6265
|
+
selection.filter('.shaped-look').select('path').attr('d', d => generalClosedPath(d.look.shape || exports.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));
|
|
6241
6266
|
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);
|
|
6242
6267
|
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);
|
|
6243
6268
|
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);
|
|
@@ -6423,10 +6448,11 @@ class DiagramUserHighlight extends DiagramElementSet {
|
|
|
6423
6448
|
* @public
|
|
6424
6449
|
* @param canvas A canvas.
|
|
6425
6450
|
*/
|
|
6426
|
-
constructor(canvas) {
|
|
6451
|
+
constructor(canvas, highlightSections = true) {
|
|
6427
6452
|
super();
|
|
6428
6453
|
this.focus = undefined;
|
|
6429
6454
|
this.canvas = canvas;
|
|
6455
|
+
this.highlightSections = highlightSections;
|
|
6430
6456
|
}
|
|
6431
6457
|
/**
|
|
6432
6458
|
* 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.
|
|
@@ -6452,6 +6478,20 @@ class DiagramUserHighlight extends DiagramElementSet {
|
|
|
6452
6478
|
add(element) {
|
|
6453
6479
|
super.add(element);
|
|
6454
6480
|
if (element instanceof DiagramNode) {
|
|
6481
|
+
if (!this.highlightSections) {
|
|
6482
|
+
for (const section of element.sections) {
|
|
6483
|
+
super.add(section);
|
|
6484
|
+
for (const port of section.ports) {
|
|
6485
|
+
super.add(port);
|
|
6486
|
+
this.canvas.updatePortsInView(port.id);
|
|
6487
|
+
}
|
|
6488
|
+
if (section.label) {
|
|
6489
|
+
super.add(section.label);
|
|
6490
|
+
this.canvas.updateFieldsInView(section.label.id);
|
|
6491
|
+
}
|
|
6492
|
+
this.canvas.updateSectionsInView(section.id);
|
|
6493
|
+
}
|
|
6494
|
+
}
|
|
6455
6495
|
for (const port of element.ports) {
|
|
6456
6496
|
super.add(port);
|
|
6457
6497
|
this.canvas.updatePortsInView(port.id);
|
|
@@ -6462,15 +6502,19 @@ class DiagramUserHighlight extends DiagramElementSet {
|
|
|
6462
6502
|
}
|
|
6463
6503
|
this.canvas.updateNodesInView(element.id);
|
|
6464
6504
|
} else if (element instanceof DiagramSection) {
|
|
6465
|
-
|
|
6466
|
-
|
|
6467
|
-
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
|
|
6471
|
-
|
|
6505
|
+
if (!this.highlightSections && element.node) {
|
|
6506
|
+
this.add(element.node);
|
|
6507
|
+
} else {
|
|
6508
|
+
for (const port of element.ports) {
|
|
6509
|
+
super.add(port);
|
|
6510
|
+
this.canvas.updatePortsInView(port.id);
|
|
6511
|
+
}
|
|
6512
|
+
if (element.label) {
|
|
6513
|
+
super.add(element.label);
|
|
6514
|
+
this.canvas.updateFieldsInView(element.label.id);
|
|
6515
|
+
}
|
|
6516
|
+
this.canvas.updateSectionsInView(element.id);
|
|
6472
6517
|
}
|
|
6473
|
-
this.canvas.updateSectionsInView(element.id);
|
|
6474
6518
|
} else if (element instanceof DiagramPort) {
|
|
6475
6519
|
if (element.label) {
|
|
6476
6520
|
super.add(element.label);
|
|
@@ -6939,7 +6983,6 @@ const RESIZER_THICKNESS = 6;
|
|
|
6939
6983
|
*/
|
|
6940
6984
|
const ACTION_STACK_SIZE = 25;
|
|
6941
6985
|
const UNFINISHED_CONNECTION_ID = 'diagram-connection-unfinished';
|
|
6942
|
-
const MAX_DISTANCE_TO_PORT = 100;
|
|
6943
6986
|
class DiagramCanvas {
|
|
6944
6987
|
get connectionType() {
|
|
6945
6988
|
return this._connectionType;
|
|
@@ -6957,7 +7000,7 @@ class DiagramCanvas {
|
|
|
6957
7000
|
* @param config The configuration object used to set the parameters of this canvas.
|
|
6958
7001
|
*/
|
|
6959
7002
|
constructor(parentComponent, config) {
|
|
6960
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
7003
|
+
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;
|
|
6961
7004
|
this.backgroundPatternId = `daga-background-pattern-id-${DiagramCanvas.canvasCount++}`;
|
|
6962
7005
|
this.zoomTransform = d3__namespace.zoomIdentity;
|
|
6963
7006
|
// used to distinguish drags from clicks when dragging elements and during multiple selection
|
|
@@ -6973,19 +7016,24 @@ class DiagramCanvas {
|
|
|
6973
7016
|
this.parentComponent = parentComponent;
|
|
6974
7017
|
this.model = new DiagramModel(this, undefined, config.name || 'unnamed', '', config.type || '', config.properties || []);
|
|
6975
7018
|
this.userSelection = new DiagramUserSelection(this);
|
|
6976
|
-
this.userHighlight = new DiagramUserHighlight(this);
|
|
6977
|
-
this.contextMenu = new DiagramContextMenu(this, (
|
|
6978
|
-
this.backgroundColor = ((
|
|
6979
|
-
this.gridStyle = (
|
|
6980
|
-
this.gridSize = ((
|
|
6981
|
-
this.gridThickness = Math.abs(((
|
|
6982
|
-
this.gridColor = ((
|
|
6983
|
-
this.snapToGrid = ((
|
|
6984
|
-
this.zoomFactor = ((
|
|
6985
|
-
this.panRate = ((
|
|
6986
|
-
this.inferConnectionType = config.inferConnectionType || false;
|
|
7019
|
+
this.userHighlight = new DiagramUserHighlight(this, ((_a = config.canvas) === null || _a === void 0 ? void 0 : _a.highlightSections) !== false);
|
|
7020
|
+
this.contextMenu = new DiagramContextMenu(this, (_b = config.canvas) === null || _b === void 0 ? void 0 : _b.contextMenu);
|
|
7021
|
+
this.backgroundColor = ((_c = config.canvas) === null || _c === void 0 ? void 0 : _c.backgroundColor) || '#FFFFFF';
|
|
7022
|
+
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;
|
|
7023
|
+
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);
|
|
7024
|
+
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);
|
|
7025
|
+
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;
|
|
7026
|
+
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;
|
|
7027
|
+
this.zoomFactor = ((_w = config.canvas) === null || _w === void 0 ? void 0 : _w.zoomFactor) || 2;
|
|
7028
|
+
this.panRate = ((_x = config.canvas) === null || _x === void 0 ? void 0 : _x.panRate) || 100;
|
|
7029
|
+
this.inferConnectionType = ((_y = config.connectionSettings) === null || _y === void 0 ? void 0 : _y.inferConnectionType) || false;
|
|
7030
|
+
this.autoTightenConnections = ((_z = config.connectionSettings) === null || _z === void 0 ? void 0 : _z.autoTighten) !== false;
|
|
7031
|
+
this.allowConnectionLoops = ((_0 = config.connectionSettings) === null || _0 === void 0 ? void 0 : _0.allowLoops) || false;
|
|
7032
|
+
this.allowSharingPorts = ((_1 = config.connectionSettings) === null || _1 === void 0 ? void 0 : _1.sharePorts) !== false;
|
|
7033
|
+
this.allowSharingBothPorts = ((_2 = config.connectionSettings) === null || _2 === void 0 ? void 0 : _2.shareBothPorts) || false;
|
|
7034
|
+
this.portHighlightRadius = ((_3 = config.connectionSettings) === null || _3 === void 0 ? void 0 : _3.portHighlightRadius) || 100;
|
|
6987
7035
|
this.multipleSelectionOn = false;
|
|
6988
|
-
this.priorityThresholds = ((
|
|
7036
|
+
this.priorityThresholds = ((_4 = config.canvas) === null || _4 === void 0 ? void 0 : _4.priorityThresholds) || [];
|
|
6989
7037
|
this.priorityThreshold = this.priorityThresholds ? this.priorityThresholds[0] : undefined;
|
|
6990
7038
|
this.layoutFormat = config.layoutFormat;
|
|
6991
7039
|
this.userActions = config.userActions || {};
|
|
@@ -7012,7 +7060,7 @@ class DiagramCanvas {
|
|
|
7012
7060
|
const connectionType = new DiagramConnectionType(Object.assign(Object.assign({}, config.connectionTypeDefaults), connectionTypeConfig));
|
|
7013
7061
|
this.model.connections.types.add(connectionType);
|
|
7014
7062
|
}
|
|
7015
|
-
this._connectionType = config.defaultConnection !== undefined ? this.model.connections.types.get(config.defaultConnection) : undefined;
|
|
7063
|
+
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;
|
|
7016
7064
|
}
|
|
7017
7065
|
}
|
|
7018
7066
|
addValidator(validator) {
|
|
@@ -7860,7 +7908,7 @@ class DiagramCanvas {
|
|
|
7860
7908
|
if (this.multipleSelectionOn || this.secondaryButton) {
|
|
7861
7909
|
this.startMultipleSelection(event);
|
|
7862
7910
|
} else {
|
|
7863
|
-
if (this.canUserPerformAction(exports.DiagramActions.AddConnection) && !d.removed) {
|
|
7911
|
+
if (this.canUserPerformAction(exports.DiagramActions.AddConnection) && (this.allowSharingPorts || d.incomingConnections.length === 0 && d.outgoingConnections.length === 0) && !d.removed) {
|
|
7864
7912
|
setCursorStyle(exports.CursorStyle.Grabbing);
|
|
7865
7913
|
this.startConnection(d);
|
|
7866
7914
|
// should be true after having called this.startConnection()
|
|
@@ -7879,7 +7927,7 @@ class DiagramCanvas {
|
|
|
7879
7927
|
if (this.canUserPerformAction(exports.DiagramActions.AddConnection) && !d.removed) {
|
|
7880
7928
|
if (this.unfinishedConnection !== undefined) {
|
|
7881
7929
|
const endCoords = [event.x, event.y];
|
|
7882
|
-
(_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));
|
|
7930
|
+
(_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));
|
|
7883
7931
|
const unfinishedConnectionGhostNode = (_d = this.unfinishedConnectionTracer) === null || _d === void 0 ? void 0 : _d.node();
|
|
7884
7932
|
if (unfinishedConnectionGhostNode) {
|
|
7885
7933
|
let margin = 2;
|
|
@@ -7906,7 +7954,7 @@ class DiagramCanvas {
|
|
|
7906
7954
|
closestPortFound = port;
|
|
7907
7955
|
}
|
|
7908
7956
|
}
|
|
7909
|
-
if (closestPortFound && minDistanceFound <
|
|
7957
|
+
if (closestPortFound && minDistanceFound < this.portHighlightRadius) {
|
|
7910
7958
|
this.userHighlight.focusOn(closestPortFound);
|
|
7911
7959
|
} else {
|
|
7912
7960
|
this.userHighlight.clear();
|
|
@@ -8027,14 +8075,14 @@ class DiagramCanvas {
|
|
|
8027
8075
|
enterSelection.select('g.diagram-connection-end-label').append('text').style('user-select', 'none');
|
|
8028
8076
|
mergeSelection.attr('opacity', d => d.removed ? 0.5 : 1).select('path.diagram-connection-path').attr('d', d => {
|
|
8029
8077
|
var _a, _b;
|
|
8030
|
-
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);
|
|
8031
|
-
}).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');
|
|
8078
|
+
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);
|
|
8079
|
+
}).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');
|
|
8032
8080
|
mergeSelection.select('path.diagram-connection-path-box').attr('d', d => {
|
|
8033
8081
|
var _a, _b;
|
|
8034
|
-
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);
|
|
8082
|
+
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);
|
|
8035
8083
|
}).attr('stroke', 'transparent')
|
|
8036
8084
|
// allow generating pointer events even when it is transparent
|
|
8037
|
-
.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');
|
|
8085
|
+
.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');
|
|
8038
8086
|
mergeSelection.data().forEach(connection => {
|
|
8039
8087
|
this.updateConnectionLabelsInView(connection);
|
|
8040
8088
|
this.updateConnectionMarkersInView(connection);
|
|
@@ -8311,6 +8359,77 @@ class DiagramCanvas {
|
|
|
8311
8359
|
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), connection.type.label);
|
|
8312
8360
|
if (pathNode) {
|
|
8313
8361
|
const pathLength = pathNode.getTotalLength();
|
|
8362
|
+
let startLabelShiftX = 0;
|
|
8363
|
+
let startLabelShiftY = 0;
|
|
8364
|
+
let middleLabelShiftX = 0;
|
|
8365
|
+
let middleLabelShiftY = 0;
|
|
8366
|
+
let endLabelShiftX = 0;
|
|
8367
|
+
let endLabelShiftY = 0;
|
|
8368
|
+
if (labelConfiguration.backgroundColor === '#00000000') {
|
|
8369
|
+
// background color is transparent / not set, so we find an alternative position for the label
|
|
8370
|
+
const deltaX = connection.endCoords[0] - connection.startCoords[0];
|
|
8371
|
+
const deltaY = connection.endCoords[1] - connection.startCoords[1];
|
|
8372
|
+
switch (connection.startDirection) {
|
|
8373
|
+
case exports.Side.Top:
|
|
8374
|
+
startLabelShiftX = deltaX >= 0 ? 1 : -1;
|
|
8375
|
+
middleLabelShiftX = startLabelShiftX;
|
|
8376
|
+
endLabelShiftX = startLabelShiftX;
|
|
8377
|
+
startLabelShiftY = -1;
|
|
8378
|
+
break;
|
|
8379
|
+
case exports.Side.Bottom:
|
|
8380
|
+
startLabelShiftX = deltaX >= 0 ? 1 : -1;
|
|
8381
|
+
middleLabelShiftX = startLabelShiftX;
|
|
8382
|
+
endLabelShiftX = startLabelShiftX;
|
|
8383
|
+
startLabelShiftY = 1;
|
|
8384
|
+
break;
|
|
8385
|
+
case exports.Side.Left:
|
|
8386
|
+
startLabelShiftX = -1;
|
|
8387
|
+
startLabelShiftY = deltaY > 0 ? 1 : -1;
|
|
8388
|
+
middleLabelShiftY = startLabelShiftY;
|
|
8389
|
+
endLabelShiftY = startLabelShiftY;
|
|
8390
|
+
break;
|
|
8391
|
+
case exports.Side.Right:
|
|
8392
|
+
startLabelShiftX = 1;
|
|
8393
|
+
startLabelShiftY = deltaY > 0 ? 1 : -1;
|
|
8394
|
+
middleLabelShiftY = startLabelShiftY;
|
|
8395
|
+
endLabelShiftY = startLabelShiftY;
|
|
8396
|
+
break;
|
|
8397
|
+
default:
|
|
8398
|
+
startLabelShiftX = 1;
|
|
8399
|
+
middleLabelShiftX = startLabelShiftX;
|
|
8400
|
+
endLabelShiftX = startLabelShiftX;
|
|
8401
|
+
startLabelShiftY = -1;
|
|
8402
|
+
middleLabelShiftY = startLabelShiftY;
|
|
8403
|
+
endLabelShiftY = startLabelShiftY;
|
|
8404
|
+
}
|
|
8405
|
+
switch (connection.endDirection) {
|
|
8406
|
+
case exports.Side.Top:
|
|
8407
|
+
endLabelShiftX = deltaX >= 0 ? 1 : -1;
|
|
8408
|
+
middleLabelShiftX = endLabelShiftX;
|
|
8409
|
+
endLabelShiftY = 1;
|
|
8410
|
+
break;
|
|
8411
|
+
case exports.Side.Bottom:
|
|
8412
|
+
endLabelShiftX = deltaX >= 0 ? 1 : -1;
|
|
8413
|
+
middleLabelShiftX = endLabelShiftX;
|
|
8414
|
+
endLabelShiftY = -1;
|
|
8415
|
+
break;
|
|
8416
|
+
case exports.Side.Left:
|
|
8417
|
+
endLabelShiftX = -1;
|
|
8418
|
+
endLabelShiftY = deltaY > 0 ? 1 : -1;
|
|
8419
|
+
middleLabelShiftY = endLabelShiftY;
|
|
8420
|
+
break;
|
|
8421
|
+
case exports.Side.Right:
|
|
8422
|
+
endLabelShiftX = 1;
|
|
8423
|
+
endLabelShiftY = deltaY > 0 ? 1 : -1;
|
|
8424
|
+
middleLabelShiftY = endLabelShiftY;
|
|
8425
|
+
break;
|
|
8426
|
+
default:
|
|
8427
|
+
endLabelShiftX = 1;
|
|
8428
|
+
middleLabelShiftX = endLabelShiftX;
|
|
8429
|
+
endLabelShiftY = -1;
|
|
8430
|
+
middleLabelShiftY = endLabelShiftY;
|
|
8431
|
+
}
|
|
8432
|
+
}
|
|
8314
8433
|
// bind start labels
|
|
8315
8434
|
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);
|
|
8316
8435
|
const startLabelBoundingRect = (_a = connectionSelection.select('g.diagram-connection-start-label text').node()) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
@@ -8319,8 +8438,8 @@ class DiagramCanvas {
|
|
|
8319
8438
|
const boundingWidth = !connection.startLabel ? 0 : startLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
|
|
8320
8439
|
const boundingHeight = !connection.startLabel ? 0 : startLabelBoundingRect.height / this.zoomTransform.k + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
|
|
8321
8440
|
const pathStartLabelPoint = pathNode.getPointAtLength(Math.max(getLeftMargin(labelConfiguration) + boundingWidth / 2, getRightMargin(labelConfiguration) + boundingWidth / 2, getTopMargin(labelConfiguration) + boundingHeight / 2, getBottomMargin(labelConfiguration) + boundingHeight / 2));
|
|
8322
|
-
connectionSelection.select('g.diagram-connection-start-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill',
|
|
8323
|
-
connectionSelection.select('g.diagram-connection-start-label').attr('transform', `translate(${pathStartLabelPoint.x},${pathStartLabelPoint.y})`);
|
|
8441
|
+
connectionSelection.select('g.diagram-connection-start-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.backgroundColor).attr('stroke', 'none');
|
|
8442
|
+
connectionSelection.select('g.diagram-connection-start-label').attr('transform', `translate(${pathStartLabelPoint.x + startLabelShiftX * boundingWidth},${pathStartLabelPoint.y + startLabelShiftY * boundingHeight})`);
|
|
8324
8443
|
}
|
|
8325
8444
|
// bind middle labels
|
|
8326
8445
|
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);
|
|
@@ -8330,8 +8449,8 @@ class DiagramCanvas {
|
|
|
8330
8449
|
const boundingWidth = !connection.middleLabel ? 0 : middleLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
|
|
8331
8450
|
const boundingHeight = !connection.middleLabel ? 0 : middleLabelBoundingRect.height / this.zoomTransform.k + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
|
|
8332
8451
|
const pathMiddleLabelPoint = pathNode.getPointAtLength(pathLength / 2);
|
|
8333
|
-
connectionSelection.select('g.diagram-connection-middle-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill',
|
|
8334
|
-
connectionSelection.select('g.diagram-connection-middle-label').attr('transform', `translate(${pathMiddleLabelPoint.x},${pathMiddleLabelPoint.y})`);
|
|
8452
|
+
connectionSelection.select('g.diagram-connection-middle-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.backgroundColor).attr('stroke', 'none');
|
|
8453
|
+
connectionSelection.select('g.diagram-connection-middle-label').attr('transform', `translate(${pathMiddleLabelPoint.x + middleLabelShiftX * boundingWidth},${pathMiddleLabelPoint.y + middleLabelShiftY * boundingHeight})`);
|
|
8335
8454
|
}
|
|
8336
8455
|
// bind end labels
|
|
8337
8456
|
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);
|
|
@@ -8341,8 +8460,8 @@ class DiagramCanvas {
|
|
|
8341
8460
|
const boundingWidth = !connection.endLabel ? 0 : endLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
|
|
8342
8461
|
const boundingHeight = !connection.endLabel ? 0 : endLabelBoundingRect.height / this.zoomTransform.k + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
|
|
8343
8462
|
const pathEndLabelPoint = pathNode.getPointAtLength(pathLength - Math.max(getLeftMargin(labelConfiguration) + boundingWidth / 2, getRightMargin(labelConfiguration) + boundingWidth / 2, getTopMargin(labelConfiguration) + boundingHeight / 2, getBottomMargin(labelConfiguration) + boundingHeight / 2));
|
|
8344
|
-
connectionSelection.select('g.diagram-connection-end-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill',
|
|
8345
|
-
connectionSelection.select('g.diagram-connection-end-label').attr('transform', `translate(${pathEndLabelPoint.x},${pathEndLabelPoint.y})`);
|
|
8463
|
+
connectionSelection.select('g.diagram-connection-end-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.backgroundColor).attr('stroke', 'none');
|
|
8464
|
+
connectionSelection.select('g.diagram-connection-end-label').attr('transform', `translate(${pathEndLabelPoint.x + endLabelShiftX * boundingWidth},${pathEndLabelPoint.y + endLabelShiftY * boundingHeight})`);
|
|
8346
8465
|
}
|
|
8347
8466
|
}
|
|
8348
8467
|
}
|
|
@@ -8514,51 +8633,61 @@ class DiagramCanvas {
|
|
|
8514
8633
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
8515
8634
|
this.userHighlight.clear();
|
|
8516
8635
|
if (this.unfinishedConnection !== undefined) {
|
|
8517
|
-
if (this.unfinishedConnection.start
|
|
8518
|
-
|
|
8519
|
-
|
|
8520
|
-
|
|
8521
|
-
|
|
8522
|
-
|
|
8523
|
-
|
|
8524
|
-
|
|
8525
|
-
|
|
8526
|
-
|
|
8527
|
-
|
|
8528
|
-
|
|
8529
|
-
|
|
8530
|
-
|
|
8531
|
-
|
|
8532
|
-
|
|
8636
|
+
if (!this.allowConnectionLoops && this.unfinishedConnection.start === port) {
|
|
8637
|
+
this.dropConnection();
|
|
8638
|
+
return;
|
|
8639
|
+
}
|
|
8640
|
+
if (!this.allowSharingPorts && (port.incomingConnections.length > 0 || port.outgoingConnections.length > 0)) {
|
|
8641
|
+
this.dropConnection();
|
|
8642
|
+
return;
|
|
8643
|
+
}
|
|
8644
|
+
if (!this.allowSharingBothPorts && this.model.connections.find(c => {
|
|
8645
|
+
var _a, _b;
|
|
8646
|
+
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;
|
|
8647
|
+
}) !== undefined) {
|
|
8648
|
+
this.dropConnection();
|
|
8649
|
+
return;
|
|
8650
|
+
}
|
|
8651
|
+
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) {
|
|
8652
|
+
const addConnectionAction = new AddConnectionAction(this, this.unfinishedConnection.type, (_j = this.unfinishedConnection.start) === null || _j === void 0 ? void 0 : _j.id, port.id);
|
|
8653
|
+
// clean up the previous unfinished connection
|
|
8654
|
+
this.dropConnection();
|
|
8655
|
+
addConnectionAction.do();
|
|
8656
|
+
this.actionStack.add(addConnectionAction);
|
|
8657
|
+
} 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) {
|
|
8658
|
+
const addConnectionAction = new AddConnectionAction(this, this.unfinishedConnection.type, port.id, (_t = this.unfinishedConnection.start) === null || _t === void 0 ? void 0 : _t.id);
|
|
8659
|
+
// clean up the previous unfinished connection
|
|
8660
|
+
this.dropConnection();
|
|
8661
|
+
addConnectionAction.do();
|
|
8662
|
+
this.actionStack.add(addConnectionAction);
|
|
8663
|
+
} else {
|
|
8664
|
+
if (this.inferConnectionType) {
|
|
8665
|
+
let differentConnectionType = this.model.connections.types.all().find(t => {
|
|
8666
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
8667
|
+
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;
|
|
8668
|
+
});
|
|
8669
|
+
let invertConnection = false;
|
|
8670
|
+
if (differentConnectionType === undefined) {
|
|
8671
|
+
differentConnectionType = this.model.connections.types.all().find(t => {
|
|
8533
8672
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
8534
|
-
return t.
|
|
8673
|
+
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;
|
|
8535
8674
|
});
|
|
8536
|
-
|
|
8537
|
-
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
if (differentConnectionType !== undefined) {
|
|
8545
|
-
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);
|
|
8546
|
-
// clean up the previous unfinished connection
|
|
8547
|
-
this.dropConnection();
|
|
8548
|
-
addConnectionAction.do();
|
|
8549
|
-
this.actionStack.add(addConnectionAction);
|
|
8550
|
-
} else {
|
|
8551
|
-
// error: connection target of wrong type and no allowed type can be found
|
|
8552
|
-
this.dropConnection();
|
|
8553
|
-
}
|
|
8675
|
+
invertConnection = true;
|
|
8676
|
+
}
|
|
8677
|
+
if (differentConnectionType !== undefined) {
|
|
8678
|
+
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);
|
|
8679
|
+
// clean up the previous unfinished connection
|
|
8680
|
+
this.dropConnection();
|
|
8681
|
+
addConnectionAction.do();
|
|
8682
|
+
this.actionStack.add(addConnectionAction);
|
|
8554
8683
|
} else {
|
|
8555
|
-
// error: connection target of wrong type and
|
|
8684
|
+
// error: connection target of wrong type and no allowed type can be found
|
|
8556
8685
|
this.dropConnection();
|
|
8557
8686
|
}
|
|
8687
|
+
} else {
|
|
8688
|
+
// error: connection target of wrong type and can't guess for a different type
|
|
8689
|
+
this.dropConnection();
|
|
8558
8690
|
}
|
|
8559
|
-
} else {
|
|
8560
|
-
// error: start port of a connection can't also be the end port
|
|
8561
|
-
this.dropConnection();
|
|
8562
8691
|
}
|
|
8563
8692
|
}
|
|
8564
8693
|
}
|