@metadev/daga 4.0.2 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Changelog.md +22 -0
- package/README.md +1 -0
- package/index.cjs.js +481 -253
- package/index.esm.js +481 -253
- package/package.json +3 -3
- package/src/lib/diagram/canvas/diagram-canvas.d.ts +2 -1
- package/src/lib/diagram/collab/collab-action.d.ts +31 -1
- package/src/lib/diagram/config/diagram-components-config.d.ts +8 -0
- package/src/lib/diagram/config/diagram-config.d.ts +6 -1
- package/src/lib/diagram/diagram-action.d.ts +23 -0
- package/src/lib/diagram/layout/adjacency-layout.d.ts +2 -0
- package/src/lib/diagram/layout/breadth-adjacency-layout.d.ts +2 -0
- package/src/lib/diagram/layout/breadth-layout.d.ts +2 -0
- package/src/lib/diagram/layout/force-layout.d.ts +2 -0
- package/src/lib/diagram/layout/horizontal-layout.d.ts +2 -0
- package/src/lib/diagram/layout/priority-layout.d.ts +2 -0
- package/src/lib/diagram/layout/tree-layout.d.ts +2 -0
- package/src/lib/diagram/layout/vertical-layout.d.ts +2 -0
- package/src/lib/diagram/model/diagram-element.d.ts +1 -1
- package/src/lib/diagram/model/diagram-field.d.ts +9 -3
- package/src/lib/diagram/model/diagram-node.d.ts +20 -0
- package/src/lib/interfaces/canvas.d.ts +8 -1
- package/index.cjs.d.ts +0 -1
- package/index.esm.d.ts +0 -1
package/index.cjs.js
CHANGED
|
@@ -825,7 +825,7 @@ const numberOfColumns = s => {
|
|
|
825
825
|
};
|
|
826
826
|
const numberOfRows = s => {
|
|
827
827
|
var _a;
|
|
828
|
-
return ((_a = s.match(/\n/g)) === null || _a ===
|
|
828
|
+
return ((_a = s.match(/\n/g)) === null || _a === void 0 ? void 0 : _a.length) || 0;
|
|
829
829
|
};
|
|
830
830
|
|
|
831
831
|
/******************************************************************************
|
|
@@ -1051,14 +1051,14 @@ class DiagramElement {
|
|
|
1051
1051
|
*/
|
|
1052
1052
|
get highlighted() {
|
|
1053
1053
|
var _a, _b;
|
|
1054
|
-
return ((_b = (_a = this.model.canvas) === null || _a ===
|
|
1054
|
+
return ((_b = (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.userHighlight) === null || _b === void 0 ? void 0 : _b.contains(this.id)) || false;
|
|
1055
1055
|
}
|
|
1056
1056
|
/**
|
|
1057
1057
|
* Whether this diagram element is currently in the user selection.
|
|
1058
1058
|
*/
|
|
1059
1059
|
get selected() {
|
|
1060
1060
|
var _a, _b;
|
|
1061
|
-
return ((_b = (_a = this.model.canvas) === null || _a ===
|
|
1061
|
+
return ((_b = (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.userSelection) === null || _b === void 0 ? void 0 : _b.contains(this.id)) || false;
|
|
1062
1062
|
}
|
|
1063
1063
|
constructor(model, id) {
|
|
1064
1064
|
/**
|
|
@@ -1087,7 +1087,7 @@ class DiagramElement {
|
|
|
1087
1087
|
*/
|
|
1088
1088
|
select() {
|
|
1089
1089
|
var _a, _b;
|
|
1090
|
-
return (_b = (_a = this.model.canvas) === null || _a ===
|
|
1090
|
+
return (_b = (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.selectCanvasView()) === null || _b === void 0 ? void 0 : _b.select(`[id='${escapeSelector(this.id)}']`);
|
|
1091
1091
|
}
|
|
1092
1092
|
}
|
|
1093
1093
|
class DiagramElementSet extends DiagramEntitySet {
|
|
@@ -1485,7 +1485,7 @@ class ValueSet {
|
|
|
1485
1485
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1486
1486
|
getValue(key) {
|
|
1487
1487
|
var _a;
|
|
1488
|
-
const rootAttribute = (_a = this.propertySet.getProperty(key)) === null || _a ===
|
|
1488
|
+
const rootAttribute = (_a = this.propertySet.getProperty(key)) === null || _a === void 0 ? void 0 : _a.rootAttribute;
|
|
1489
1489
|
if (rootAttribute !== undefined && rootAttribute !== null) {
|
|
1490
1490
|
this.values[key] = this.getRootElementValue(rootAttribute);
|
|
1491
1491
|
}
|
|
@@ -1570,7 +1570,7 @@ class ValueSet {
|
|
|
1570
1570
|
if (property && property.type === exports.Type.Object) {
|
|
1571
1571
|
return this.getSubValueSet(key).hasAnySetValue();
|
|
1572
1572
|
}
|
|
1573
|
-
return !empty(value) && !equals(value, property === null || property ===
|
|
1573
|
+
return !empty(value) && !equals(value, property === null || property === void 0 ? void 0 : property.defaultValue);
|
|
1574
1574
|
}
|
|
1575
1575
|
/**
|
|
1576
1576
|
* Checks if any of the values in the set are not empty or the default value.
|
|
@@ -1691,10 +1691,8 @@ class ValueSet {
|
|
|
1691
1691
|
this.values[key] = structuredClone(property.defaultValue);
|
|
1692
1692
|
}
|
|
1693
1693
|
if (rootAttribute !== undefined && rootAttribute !== null) {
|
|
1694
|
-
if (property.defaultValue !== undefined && !equals(this.
|
|
1694
|
+
if (property.defaultValue !== undefined && !equals(this.getRootElementValue(rootAttribute), property.defaultValue)) {
|
|
1695
1695
|
this.setRootElementValue(rootAttribute, this.values[key]);
|
|
1696
|
-
} else {
|
|
1697
|
-
this.values[key] = this.getRootElementValue(rootAttribute);
|
|
1698
1696
|
}
|
|
1699
1697
|
}
|
|
1700
1698
|
if (property.basic) {
|
|
@@ -1839,7 +1837,7 @@ class DiagramConnection extends DiagramElement {
|
|
|
1839
1837
|
}
|
|
1840
1838
|
set type(type) {
|
|
1841
1839
|
var _a, _b;
|
|
1842
|
-
(_b = (_a = this.model.canvas) === null || _a ===
|
|
1840
|
+
(_b = (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.userSelection) === null || _b === void 0 ? void 0 : _b.openInPropertyEditor(undefined);
|
|
1843
1841
|
this._type = type;
|
|
1844
1842
|
if (this.valueSet) {
|
|
1845
1843
|
this.valueSet = new ValueSet(type.propertySet, this);
|
|
@@ -2028,11 +2026,11 @@ class DiagramConnection extends DiagramElement {
|
|
|
2028
2026
|
}
|
|
2029
2027
|
updateInView() {
|
|
2030
2028
|
var _a;
|
|
2031
|
-
(_a = this.model.canvas) === null || _a ===
|
|
2029
|
+
(_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateConnectionsInView(this.id);
|
|
2032
2030
|
}
|
|
2033
2031
|
raise() {
|
|
2034
2032
|
var _a;
|
|
2035
|
-
(_a = this.select()) === null || _a ===
|
|
2033
|
+
(_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
|
|
2036
2034
|
}
|
|
2037
2035
|
/**
|
|
2038
2036
|
* Set the start of this connection to the given port or reset this connection's starting port if `undefined`.
|
|
@@ -2048,12 +2046,12 @@ class DiagramConnection extends DiagramElement {
|
|
|
2048
2046
|
this.start = start;
|
|
2049
2047
|
if (start !== undefined) {
|
|
2050
2048
|
start.outgoingConnections.push(this);
|
|
2051
|
-
this.startDirection = start === null || start ===
|
|
2052
|
-
this.startCoords = (start === null || start ===
|
|
2049
|
+
this.startDirection = start === null || start === void 0 ? void 0 : start.direction;
|
|
2050
|
+
this.startCoords = (start === null || start === void 0 ? void 0 : start.connectionPoint) || [0, 0];
|
|
2053
2051
|
}
|
|
2054
2052
|
} else {
|
|
2055
|
-
this.startDirection = start === null || start ===
|
|
2056
|
-
this.startCoords = (start === null || start ===
|
|
2053
|
+
this.startDirection = start === null || start === void 0 ? void 0 : start.direction;
|
|
2054
|
+
this.startCoords = (start === null || start === void 0 ? void 0 : start.connectionPoint) || [0, 0];
|
|
2057
2055
|
}
|
|
2058
2056
|
this.updateInView();
|
|
2059
2057
|
}
|
|
@@ -2071,12 +2069,12 @@ class DiagramConnection extends DiagramElement {
|
|
|
2071
2069
|
this.end = end;
|
|
2072
2070
|
if (end !== undefined) {
|
|
2073
2071
|
end.incomingConnections.push(this);
|
|
2074
|
-
this.endDirection = end === null || end ===
|
|
2075
|
-
this.endCoords = (end === null || end ===
|
|
2072
|
+
this.endDirection = end === null || end === void 0 ? void 0 : end.direction;
|
|
2073
|
+
this.endCoords = (end === null || end === void 0 ? void 0 : end.connectionPoint) || [0, 0];
|
|
2076
2074
|
}
|
|
2077
2075
|
} else {
|
|
2078
|
-
this.endDirection = end === null || end ===
|
|
2079
|
-
this.endCoords = (end === null || end ===
|
|
2076
|
+
this.endDirection = end === null || end === void 0 ? void 0 : end.direction;
|
|
2077
|
+
this.endCoords = (end === null || end === void 0 ? void 0 : end.connectionPoint) || [0, 0];
|
|
2080
2078
|
}
|
|
2081
2079
|
this.updateInView();
|
|
2082
2080
|
}
|
|
@@ -2087,7 +2085,7 @@ class DiagramConnection extends DiagramElement {
|
|
|
2087
2085
|
*/
|
|
2088
2086
|
tighten() {
|
|
2089
2087
|
var _a, _b;
|
|
2090
|
-
if (((_a = this.start) === null || _a ===
|
|
2088
|
+
if (((_a = this.start) === null || _a === void 0 ? void 0 : _a.rootElement) && this.end) {
|
|
2091
2089
|
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]);
|
|
2092
2090
|
checkAlternativeStartPorts: for (const alternativeStartPort of alternativeStartPortsSortedByDistanceAscending) {
|
|
2093
2091
|
if (alternativeStartPort === this.end) {
|
|
@@ -2121,7 +2119,7 @@ class DiagramConnection extends DiagramElement {
|
|
|
2121
2119
|
}
|
|
2122
2120
|
}
|
|
2123
2121
|
}
|
|
2124
|
-
if (((_b = this.end) === null || _b ===
|
|
2122
|
+
if (((_b = this.end) === null || _b === void 0 ? void 0 : _b.rootElement) && this.start) {
|
|
2125
2123
|
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]);
|
|
2126
2124
|
checkAlternativeEndPorts: for (const alternativeEndPort of alternativeEndPortsSortedByDistanceAscending) {
|
|
2127
2125
|
if (alternativeEndPort === this.start) {
|
|
@@ -2217,8 +2215,8 @@ class DiagramConnectionSet extends DiagramElementSet {
|
|
|
2217
2215
|
const connection = this.get(id, true);
|
|
2218
2216
|
if (connection) {
|
|
2219
2217
|
// remove from ports
|
|
2220
|
-
removeIfExists(((_a = connection.start) === null || _a ===
|
|
2221
|
-
removeIfExists(((_b = connection.end) === null || _b ===
|
|
2218
|
+
removeIfExists(((_a = connection.start) === null || _a === void 0 ? void 0 : _a.outgoingConnections) || [], connection);
|
|
2219
|
+
removeIfExists(((_b = connection.end) === null || _b === void 0 ? void 0 : _b.incomingConnections) || [], connection);
|
|
2222
2220
|
// remove from set of connections
|
|
2223
2221
|
super.remove(id);
|
|
2224
2222
|
// remove from canvas
|
|
@@ -2242,6 +2240,7 @@ const DIAGRAM_FIELD_DEFAULTS = {
|
|
|
2242
2240
|
selectedColor: '#000000',
|
|
2243
2241
|
horizontalAlign: exports.HorizontalAlign.Center,
|
|
2244
2242
|
verticalAlign: exports.VerticalAlign.Center,
|
|
2243
|
+
orientation: exports.Side.Top,
|
|
2245
2244
|
fit: false
|
|
2246
2245
|
};
|
|
2247
2246
|
/**
|
|
@@ -2261,17 +2260,17 @@ class DiagramField extends DiagramElement {
|
|
|
2261
2260
|
}
|
|
2262
2261
|
set text(value) {
|
|
2263
2262
|
var _a;
|
|
2264
|
-
if (value === null || value === undefined || (value === null || value ===
|
|
2263
|
+
if (value === null || value === undefined || (value === null || value === void 0 ? void 0 : value.trim()) === '') {
|
|
2265
2264
|
value = this.defaultText;
|
|
2266
2265
|
}
|
|
2267
2266
|
this._text = value;
|
|
2268
2267
|
this.updateInView();
|
|
2269
2268
|
if (this.fit) {
|
|
2270
|
-
(_a = this.model.canvas) === null || _a ===
|
|
2269
|
+
(_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.fitFieldRootInView(this.id);
|
|
2271
2270
|
}
|
|
2272
2271
|
}
|
|
2273
|
-
constructor(model, rootElement, coords, width, height, fontSize, fontFamily, color, selectedColor, horizontalAlign, verticalAlign, text, editable, fit) {
|
|
2274
|
-
const id = `${rootElement === null || rootElement ===
|
|
2272
|
+
constructor(model, rootElement, coords, width, height, fontSize, fontFamily, color, selectedColor, horizontalAlign, verticalAlign, orientation, text, editable, fit) {
|
|
2273
|
+
const id = `${rootElement === null || rootElement === void 0 ? void 0 : rootElement.id}_field`;
|
|
2275
2274
|
if (model.fields.get(id) !== undefined) {
|
|
2276
2275
|
throw new Error('DiagramField for rootElement already exists');
|
|
2277
2276
|
}
|
|
@@ -2291,6 +2290,7 @@ class DiagramField extends DiagramElement {
|
|
|
2291
2290
|
this.selectedColor = selectedColor;
|
|
2292
2291
|
this.horizontalAlign = horizontalAlign;
|
|
2293
2292
|
this.verticalAlign = verticalAlign;
|
|
2293
|
+
this.orientation = orientation;
|
|
2294
2294
|
this.defaultText = text;
|
|
2295
2295
|
this._text = text;
|
|
2296
2296
|
this.editable = editable;
|
|
@@ -2301,11 +2301,11 @@ class DiagramField extends DiagramElement {
|
|
|
2301
2301
|
}
|
|
2302
2302
|
updateInView() {
|
|
2303
2303
|
var _a;
|
|
2304
|
-
(_a = this.model.canvas) === null || _a ===
|
|
2304
|
+
(_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateFieldsInView(this.id);
|
|
2305
2305
|
}
|
|
2306
2306
|
raise() {
|
|
2307
2307
|
var _a;
|
|
2308
|
-
(_a = this.select()) === null || _a ===
|
|
2308
|
+
(_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
|
|
2309
2309
|
}
|
|
2310
2310
|
/**
|
|
2311
2311
|
* Change the coordinates of this field to the given coordinates.
|
|
@@ -2318,7 +2318,7 @@ class DiagramField extends DiagramElement {
|
|
|
2318
2318
|
}
|
|
2319
2319
|
getPriority() {
|
|
2320
2320
|
var _a;
|
|
2321
|
-
return ((_a = this.rootElement) === null || _a ===
|
|
2321
|
+
return ((_a = this.rootElement) === null || _a === void 0 ? void 0 : _a.getPriority()) || DEFAULT_PRIORITY;
|
|
2322
2322
|
}
|
|
2323
2323
|
}
|
|
2324
2324
|
class DiagramFieldSet extends DiagramElementSet {
|
|
@@ -2334,8 +2334,8 @@ class DiagramFieldSet extends DiagramElementSet {
|
|
|
2334
2334
|
* Instance a new field and add it to this set. This method is normally called when instancing an element with a field and it is rarely called by itself.
|
|
2335
2335
|
* @private
|
|
2336
2336
|
*/
|
|
2337
|
-
new(rootElement, coords, fontSize, fontFamily, color, selectedColor, width, height, horizontalAlign, verticalAlign, text, editable, fit) {
|
|
2338
|
-
const field = new DiagramField(this.model, rootElement, coords, width, height, fontSize, fontFamily, color, selectedColor, horizontalAlign, verticalAlign, text, editable, fit);
|
|
2337
|
+
new(rootElement, coords, fontSize, fontFamily, color, selectedColor, width, height, horizontalAlign, verticalAlign, orientation, text, editable, fit) {
|
|
2338
|
+
const field = new DiagramField(this.model, rootElement, coords, width, height, fontSize, fontFamily, color, selectedColor, horizontalAlign, verticalAlign, orientation, text, editable, fit);
|
|
2339
2339
|
super.add(field);
|
|
2340
2340
|
field.updateInView();
|
|
2341
2341
|
// add this field to its root element
|
|
@@ -2349,7 +2349,7 @@ class DiagramFieldSet extends DiagramElementSet {
|
|
|
2349
2349
|
const field = this.get(id, true);
|
|
2350
2350
|
if (field) {
|
|
2351
2351
|
// remove from root element
|
|
2352
|
-
if (((_a = field.rootElement) === null || _a ===
|
|
2352
|
+
if (((_a = field.rootElement) === null || _a === void 0 ? void 0 : _a.label) !== undefined) {
|
|
2353
2353
|
if (field.rootElement.label === field) {
|
|
2354
2354
|
field.rootElement.label = undefined;
|
|
2355
2355
|
}
|
|
@@ -2362,7 +2362,7 @@ class DiagramFieldSet extends DiagramElementSet {
|
|
|
2362
2362
|
}
|
|
2363
2363
|
}
|
|
2364
2364
|
const getBottomMargin = config => {
|
|
2365
|
-
if ((config === null || config ===
|
|
2365
|
+
if ((config === null || config === void 0 ? void 0 : config.margin) === null || (config === null || config === void 0 ? void 0 : config.margin) === undefined) {
|
|
2366
2366
|
return DIAGRAM_FIELD_DEFAULTS.margin;
|
|
2367
2367
|
} else if (typeof config.margin === 'number') {
|
|
2368
2368
|
return config.margin;
|
|
@@ -2381,7 +2381,7 @@ const getBottomMargin = config => {
|
|
|
2381
2381
|
}
|
|
2382
2382
|
};
|
|
2383
2383
|
const getLeftMargin = config => {
|
|
2384
|
-
if ((config === null || config ===
|
|
2384
|
+
if ((config === null || config === void 0 ? void 0 : config.margin) === null || (config === null || config === void 0 ? void 0 : config.margin) === undefined) {
|
|
2385
2385
|
return DIAGRAM_FIELD_DEFAULTS.margin;
|
|
2386
2386
|
} else if (typeof config.margin === 'number') {
|
|
2387
2387
|
return config.margin;
|
|
@@ -2400,7 +2400,7 @@ const getLeftMargin = config => {
|
|
|
2400
2400
|
}
|
|
2401
2401
|
};
|
|
2402
2402
|
const getRightMargin = config => {
|
|
2403
|
-
if ((config === null || config ===
|
|
2403
|
+
if ((config === null || config === void 0 ? void 0 : config.margin) === null || (config === null || config === void 0 ? void 0 : config.margin) === undefined) {
|
|
2404
2404
|
return DIAGRAM_FIELD_DEFAULTS.margin;
|
|
2405
2405
|
} else if (typeof config.margin === 'number') {
|
|
2406
2406
|
return config.margin;
|
|
@@ -2419,7 +2419,7 @@ const getRightMargin = config => {
|
|
|
2419
2419
|
}
|
|
2420
2420
|
};
|
|
2421
2421
|
const getTopMargin = config => {
|
|
2422
|
-
if ((config === null || config ===
|
|
2422
|
+
if ((config === null || config === void 0 ? void 0 : config.margin) === null || (config === null || config === void 0 ? void 0 : config.margin) === undefined) {
|
|
2423
2423
|
return DIAGRAM_FIELD_DEFAULTS.margin;
|
|
2424
2424
|
} else if (typeof config.margin === 'number') {
|
|
2425
2425
|
return config.margin;
|
|
@@ -2438,7 +2438,7 @@ const getTopMargin = config => {
|
|
|
2438
2438
|
}
|
|
2439
2439
|
};
|
|
2440
2440
|
const getBottomPadding$1 = config => {
|
|
2441
|
-
if ((config === null || config ===
|
|
2441
|
+
if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
|
|
2442
2442
|
return DIAGRAM_FIELD_DEFAULTS.padding;
|
|
2443
2443
|
} else if (typeof config.padding === 'number') {
|
|
2444
2444
|
return config.padding;
|
|
@@ -2457,7 +2457,7 @@ const getBottomPadding$1 = config => {
|
|
|
2457
2457
|
}
|
|
2458
2458
|
};
|
|
2459
2459
|
const getLeftPadding$1 = config => {
|
|
2460
|
-
if ((config === null || config ===
|
|
2460
|
+
if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
|
|
2461
2461
|
return DIAGRAM_FIELD_DEFAULTS.padding;
|
|
2462
2462
|
} else if (typeof config.padding === 'number') {
|
|
2463
2463
|
return config.padding;
|
|
@@ -2476,7 +2476,7 @@ const getLeftPadding$1 = config => {
|
|
|
2476
2476
|
}
|
|
2477
2477
|
};
|
|
2478
2478
|
const getRightPadding$1 = config => {
|
|
2479
|
-
if ((config === null || config ===
|
|
2479
|
+
if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
|
|
2480
2480
|
return DIAGRAM_FIELD_DEFAULTS.padding;
|
|
2481
2481
|
} else if (typeof config.padding === 'number') {
|
|
2482
2482
|
return config.padding;
|
|
@@ -2495,7 +2495,7 @@ const getRightPadding$1 = config => {
|
|
|
2495
2495
|
}
|
|
2496
2496
|
};
|
|
2497
2497
|
const getTopPadding$1 = config => {
|
|
2498
|
-
if ((config === null || config ===
|
|
2498
|
+
if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
|
|
2499
2499
|
return DIAGRAM_FIELD_DEFAULTS.padding;
|
|
2500
2500
|
} else if (typeof config.padding === 'number') {
|
|
2501
2501
|
return config.padding;
|
|
@@ -2587,7 +2587,7 @@ class DiagramSection extends DiagramElement {
|
|
|
2587
2587
|
*/
|
|
2588
2588
|
get name() {
|
|
2589
2589
|
var _a;
|
|
2590
|
-
return ((_a = this.label) === null || _a ===
|
|
2590
|
+
return ((_a = this.label) === null || _a === void 0 ? void 0 : _a.text) || '';
|
|
2591
2591
|
}
|
|
2592
2592
|
set name(name) {
|
|
2593
2593
|
if (this.label) {
|
|
@@ -2602,15 +2602,15 @@ class DiagramSection extends DiagramElement {
|
|
|
2602
2602
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2603
2603
|
if (this.selected) {
|
|
2604
2604
|
if (this.highlighted) {
|
|
2605
|
-
return this._selectedAndHighlightedLook !== undefined ? this._selectedAndHighlightedLook : ((_a = this.type) === null || _a ===
|
|
2605
|
+
return this._selectedAndHighlightedLook !== undefined ? this._selectedAndHighlightedLook : ((_a = this.type) === null || _a === void 0 ? void 0 : _a.selectedAndHighlightedLook) || ((_b = this.node) === null || _b === void 0 ? void 0 : _b.look);
|
|
2606
2606
|
} else {
|
|
2607
|
-
return this._selectedLook !== undefined ? this._selectedLook : ((_c = this.type) === null || _c ===
|
|
2607
|
+
return this._selectedLook !== undefined ? this._selectedLook : ((_c = this.type) === null || _c === void 0 ? void 0 : _c.selectedLook) || ((_d = this.node) === null || _d === void 0 ? void 0 : _d.look);
|
|
2608
2608
|
}
|
|
2609
2609
|
} else {
|
|
2610
2610
|
if (this.highlighted) {
|
|
2611
|
-
return this._highlightedLook !== undefined ? this._highlightedLook : ((_e = this.type) === null || _e ===
|
|
2611
|
+
return this._highlightedLook !== undefined ? this._highlightedLook : ((_e = this.type) === null || _e === void 0 ? void 0 : _e.highlightedLook) || ((_f = this.node) === null || _f === void 0 ? void 0 : _f.look);
|
|
2612
2612
|
} else {
|
|
2613
|
-
return this._defaultLook !== undefined ? this._defaultLook : ((_g = this.type) === null || _g ===
|
|
2613
|
+
return this._defaultLook !== undefined ? this._defaultLook : ((_g = this.type) === null || _g === void 0 ? void 0 : _g.defaultLook) || ((_h = this.node) === null || _h === void 0 ? void 0 : _h.look);
|
|
2614
2614
|
}
|
|
2615
2615
|
}
|
|
2616
2616
|
}
|
|
@@ -2663,11 +2663,11 @@ class DiagramSection extends DiagramElement {
|
|
|
2663
2663
|
}
|
|
2664
2664
|
updateInView() {
|
|
2665
2665
|
var _a;
|
|
2666
|
-
(_a = this.model.canvas) === null || _a ===
|
|
2666
|
+
(_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateSectionsInView(this.id);
|
|
2667
2667
|
}
|
|
2668
2668
|
raise() {
|
|
2669
2669
|
var _a;
|
|
2670
|
-
(_a = this.select()) === null || _a ===
|
|
2670
|
+
(_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
|
|
2671
2671
|
if (this.label) {
|
|
2672
2672
|
this.label.raise();
|
|
2673
2673
|
}
|
|
@@ -2680,19 +2680,19 @@ class DiagramSection extends DiagramElement {
|
|
|
2680
2680
|
}
|
|
2681
2681
|
get type() {
|
|
2682
2682
|
var _a, _b, _c, _d, _e;
|
|
2683
|
-
return (_e = (_d = (_c = (_b = (_a = this.node) === null || _a ===
|
|
2683
|
+
return (_e = (_d = (_c = (_b = (_a = this.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.sectionGrid) === null || _c === void 0 ? void 0 : _c.sections) === null || _d === void 0 ? void 0 : _d[this.indexYInNode]) === null || _e === void 0 ? void 0 : _e[this.indexXInNode];
|
|
2684
2684
|
}
|
|
2685
2685
|
getMinWidth() {
|
|
2686
2686
|
var _a, _b, _c, _d;
|
|
2687
|
-
return ((_d = (_c = (_b = (_a = this.node) === null || _a ===
|
|
2687
|
+
return ((_d = (_c = (_b = (_a = this.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.sectionGrid) === null || _c === void 0 ? void 0 : _c.minWidths) === null || _d === void 0 ? void 0 : _d[this.indexXInNode]) || DIAGRAM_SECTION_MIN_WIDTH;
|
|
2688
2688
|
}
|
|
2689
2689
|
getMinHeight() {
|
|
2690
2690
|
var _a, _b, _c, _d;
|
|
2691
|
-
return ((_d = (_c = (_b = (_a = this.node) === null || _a ===
|
|
2691
|
+
return ((_d = (_c = (_b = (_a = this.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.sectionGrid) === null || _c === void 0 ? void 0 : _c.minHeights) === null || _d === void 0 ? void 0 : _d[this.indexYInNode]) || DIAGRAM_SECTION_MIN_HEIGHT;
|
|
2692
2692
|
}
|
|
2693
2693
|
getPriority() {
|
|
2694
2694
|
var _a, _b, _c, _d, _e, _f;
|
|
2695
|
-
return ((_f = (_e = (_d = (_c = (_b = (_a = this.node) === null || _a ===
|
|
2695
|
+
return ((_f = (_e = (_d = (_c = (_b = (_a = this.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.sectionGrid) === null || _c === void 0 ? void 0 : _c.sections) === null || _d === void 0 ? void 0 : _d[this.indexYInNode]) === null || _e === void 0 ? void 0 : _e[this.indexXInNode]) === null || _f === void 0 ? void 0 : _f.priority) || DEFAULT_PRIORITY;
|
|
2696
2696
|
}
|
|
2697
2697
|
/**
|
|
2698
2698
|
* Get the port of this section which is closest to the given coordinates.
|
|
@@ -2857,9 +2857,9 @@ class DiagramSection extends DiagramElement {
|
|
|
2857
2857
|
// Set label's dimensions as a function of ours.
|
|
2858
2858
|
const type = this.type;
|
|
2859
2859
|
if (this.label) {
|
|
2860
|
-
this.label.coords = [this.coords[0] + getLeftMargin(type === null || type ===
|
|
2861
|
-
this.label.width = this.width - getLeftMargin(type === null || type ===
|
|
2862
|
-
this.label.height = this.height - getTopMargin(type === null || type ===
|
|
2860
|
+
this.label.coords = [this.coords[0] + getLeftMargin(type === null || type === void 0 ? void 0 : type.label), this.coords[1] + getTopMargin(type === null || type === void 0 ? void 0 : type.label)];
|
|
2861
|
+
this.label.width = this.width - getLeftMargin(type === null || type === void 0 ? void 0 : type.label) - getRightMargin(type === null || type === void 0 ? void 0 : type.label);
|
|
2862
|
+
this.label.height = this.height - getTopMargin(type === null || type === void 0 ? void 0 : type.label) - getBottomMargin(type === null || type === void 0 ? void 0 : type.label);
|
|
2863
2863
|
this.label.updateInView();
|
|
2864
2864
|
}
|
|
2865
2865
|
// Move decorators to match the new coords.
|
|
@@ -2893,13 +2893,13 @@ class DiagramSectionSet extends DiagramElementSet {
|
|
|
2893
2893
|
node.sections.push(section);
|
|
2894
2894
|
node.updateInView();
|
|
2895
2895
|
// add section ports
|
|
2896
|
-
const sectionPorts = (_d = (_c = (_b = (_a = node.type.sectionGrid) === null || _a ===
|
|
2896
|
+
const sectionPorts = (_d = (_c = (_b = (_a = node.type.sectionGrid) === null || _a === void 0 ? void 0 : _a.sections) === null || _b === void 0 ? void 0 : _b[indexYInNode]) === null || _c === void 0 ? void 0 : _c[indexXInNode]) === null || _d === void 0 ? void 0 : _d.ports;
|
|
2897
2897
|
if (sectionPorts && sectionPorts.length > 0) {
|
|
2898
2898
|
for (let i = 0; i < sectionPorts.length; ++i) {
|
|
2899
2899
|
const portConfig = sectionPorts[i];
|
|
2900
|
-
const port = this.model.ports.new(portConfig.type !== undefined ? this.model.ports.types.get(portConfig.type) : undefined, section, [section.coords[0] + (portConfig.coords[0] || 0), section.coords[1] + (portConfig.coords[1] || 0)], portConfig.connectionPoint !== undefined ? [section.coords[0] + (portConfig.connectionPoint[0] || 0), section.coords[1] + (portConfig.connectionPoint[1] || 0)] : undefined, portConfig === null || portConfig ===
|
|
2901
|
-
if ((_e = port.type) === null || _e ===
|
|
2902
|
-
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_f = port.type) === null || _f ===
|
|
2900
|
+
const port = this.model.ports.new(portConfig.type !== undefined ? this.model.ports.types.get(portConfig.type) : undefined, section, [section.coords[0] + (portConfig.coords[0] || 0), section.coords[1] + (portConfig.coords[1] || 0)], portConfig.connectionPoint !== undefined ? [section.coords[0] + (portConfig.connectionPoint[0] || 0), section.coords[1] + (portConfig.connectionPoint[1] || 0)] : undefined, portConfig === null || portConfig === void 0 ? void 0 : portConfig.direction, `${section.id}_${i}`);
|
|
2901
|
+
if ((_e = port.type) === null || _e === void 0 ? void 0 : _e.label) {
|
|
2902
|
+
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_f = port.type) === null || _f === void 0 ? void 0 : _f.label);
|
|
2903
2903
|
const labelWidth = 6 * labelConfiguration.fontSize + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
|
|
2904
2904
|
const labelHeight = labelConfiguration.fontSize + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
|
|
2905
2905
|
let labelCoords;
|
|
@@ -2915,15 +2915,15 @@ class DiagramSectionSet extends DiagramElementSet {
|
|
|
2915
2915
|
default:
|
|
2916
2916
|
labelCoords = port.coords;
|
|
2917
2917
|
}
|
|
2918
|
-
this.model.fields.new(port, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, '', labelConfiguration.editable, labelConfiguration.fit);
|
|
2918
|
+
this.model.fields.new(port, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit);
|
|
2919
2919
|
}
|
|
2920
2920
|
}
|
|
2921
2921
|
}
|
|
2922
2922
|
// add section label
|
|
2923
|
-
const sectionLabel = (_k = (_j = (_h = (_g = node.type.sectionGrid) === null || _g ===
|
|
2923
|
+
const sectionLabel = (_k = (_j = (_h = (_g = node.type.sectionGrid) === null || _g === void 0 ? void 0 : _g.sections) === null || _h === void 0 ? void 0 : _h[indexYInNode]) === null || _j === void 0 ? void 0 : _j[indexXInNode]) === null || _k === void 0 ? void 0 : _k.label;
|
|
2924
2924
|
if (sectionLabel) {
|
|
2925
2925
|
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), sectionLabel);
|
|
2926
|
-
this.model.fields.new(section, [section.coords[0] + getLeftMargin(labelConfiguration), section.coords[1] + getTopMargin(labelConfiguration)], labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, section.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), section.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, '', labelConfiguration.editable, labelConfiguration.fit);
|
|
2926
|
+
this.model.fields.new(section, [section.coords[0] + getLeftMargin(labelConfiguration), section.coords[1] + getTopMargin(labelConfiguration)], labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, section.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), section.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit);
|
|
2927
2927
|
}
|
|
2928
2928
|
return section;
|
|
2929
2929
|
}
|
|
@@ -3027,7 +3027,7 @@ class DiagramNodeType {
|
|
|
3027
3027
|
this.canBeParentless = values.canBeParentless;
|
|
3028
3028
|
this.childrenTypes = values.childrenTypes;
|
|
3029
3029
|
this.priority = values.priority;
|
|
3030
|
-
this.propertySet = new PropertySet((options === null || options ===
|
|
3030
|
+
this.propertySet = new PropertySet((options === null || options === void 0 ? void 0 : options.properties) || []);
|
|
3031
3031
|
}
|
|
3032
3032
|
}
|
|
3033
3033
|
/**
|
|
@@ -3043,7 +3043,7 @@ class DiagramNode extends DiagramElement {
|
|
|
3043
3043
|
}
|
|
3044
3044
|
set type(type) {
|
|
3045
3045
|
var _a, _b;
|
|
3046
|
-
(_b = (_a = this.model.canvas) === null || _a ===
|
|
3046
|
+
(_b = (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.userSelection) === null || _b === void 0 ? void 0 : _b.openInPropertyEditor(undefined);
|
|
3047
3047
|
this._type = type;
|
|
3048
3048
|
if (this.valueSet) {
|
|
3049
3049
|
this.valueSet = new ValueSet(type.propertySet, this);
|
|
@@ -3065,7 +3065,7 @@ class DiagramNode extends DiagramElement {
|
|
|
3065
3065
|
*/
|
|
3066
3066
|
get name() {
|
|
3067
3067
|
var _a;
|
|
3068
|
-
return ((_a = this.label) === null || _a ===
|
|
3068
|
+
return ((_a = this.label) === null || _a === void 0 ? void 0 : _a.text) || '';
|
|
3069
3069
|
}
|
|
3070
3070
|
set name(name) {
|
|
3071
3071
|
if (this.label) {
|
|
@@ -3155,20 +3155,20 @@ class DiagramNode extends DiagramElement {
|
|
|
3155
3155
|
}
|
|
3156
3156
|
updateInView() {
|
|
3157
3157
|
var _a;
|
|
3158
|
-
(_a = this.model.canvas) === null || _a ===
|
|
3158
|
+
(_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateNodesInView(this.id);
|
|
3159
3159
|
}
|
|
3160
3160
|
raise() {
|
|
3161
3161
|
var _a;
|
|
3162
|
-
(_a = this.select()) === null || _a ===
|
|
3162
|
+
(_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
|
|
3163
|
+
for (const section of this.sections) {
|
|
3164
|
+
section.raise();
|
|
3165
|
+
}
|
|
3163
3166
|
if (this.label) {
|
|
3164
3167
|
this.label.raise();
|
|
3165
3168
|
}
|
|
3166
3169
|
for (const port of this.ports) {
|
|
3167
3170
|
port.raise();
|
|
3168
3171
|
}
|
|
3169
|
-
for (const section of this.sections) {
|
|
3170
|
-
section.raise();
|
|
3171
|
-
}
|
|
3172
3172
|
for (const decorator of this.decorators) {
|
|
3173
3173
|
decorator.raise();
|
|
3174
3174
|
}
|
|
@@ -3266,7 +3266,7 @@ class DiagramNode extends DiagramElement {
|
|
|
3266
3266
|
if (!includeRemoved && incomingConnection.removed) {
|
|
3267
3267
|
continue;
|
|
3268
3268
|
}
|
|
3269
|
-
const otherNode = (_a = incomingConnection.start) === null || _a ===
|
|
3269
|
+
const otherNode = (_a = incomingConnection.start) === null || _a === void 0 ? void 0 : _a.getNode();
|
|
3270
3270
|
if (otherNode) {
|
|
3271
3271
|
if (!includeRemoved && otherNode.removed) {
|
|
3272
3272
|
continue;
|
|
@@ -3278,7 +3278,7 @@ class DiagramNode extends DiagramElement {
|
|
|
3278
3278
|
if (!includeRemoved && outgoingConnection.removed) {
|
|
3279
3279
|
continue;
|
|
3280
3280
|
}
|
|
3281
|
-
const otherNode = (_b = outgoingConnection.end) === null || _b ===
|
|
3281
|
+
const otherNode = (_b = outgoingConnection.end) === null || _b === void 0 ? void 0 : _b.getNode();
|
|
3282
3282
|
if (otherNode) {
|
|
3283
3283
|
if (!includeRemoved && otherNode.removed) {
|
|
3284
3284
|
continue;
|
|
@@ -3297,7 +3297,7 @@ class DiagramNode extends DiagramElement {
|
|
|
3297
3297
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
3298
3298
|
let node = this;
|
|
3299
3299
|
while (node.parent !== undefined) {
|
|
3300
|
-
node = node === null || node ===
|
|
3300
|
+
node = node === null || node === void 0 ? void 0 : node.parent;
|
|
3301
3301
|
}
|
|
3302
3302
|
return node;
|
|
3303
3303
|
}
|
|
@@ -3602,6 +3602,106 @@ class DiagramNode extends DiagramElement {
|
|
|
3602
3602
|
this.getConnections().forEach(c => c.tighten());
|
|
3603
3603
|
this.updateInView();
|
|
3604
3604
|
}
|
|
3605
|
+
/**
|
|
3606
|
+
* Removes all sections with the given index along the x axis.
|
|
3607
|
+
* @public
|
|
3608
|
+
*/
|
|
3609
|
+
removeSectionColumn(columnIndex) {
|
|
3610
|
+
var _a;
|
|
3611
|
+
const margin = ((_a = this.type.sectionGrid) === null || _a === void 0 ? void 0 : _a.margin) || 0;
|
|
3612
|
+
let columnWidth = 0;
|
|
3613
|
+
const sections = [...this.sections];
|
|
3614
|
+
for (const section of sections) {
|
|
3615
|
+
if (section.indexYInNode === columnIndex) {
|
|
3616
|
+
columnWidth = Math.max(columnWidth, section.width);
|
|
3617
|
+
this.model.sections.remove(section.id);
|
|
3618
|
+
}
|
|
3619
|
+
}
|
|
3620
|
+
for (const section of sections) {
|
|
3621
|
+
if (section.indexYInNode > columnIndex) {
|
|
3622
|
+
--section.indexYInNode;
|
|
3623
|
+
section.move([section.coords[0] - columnWidth - margin, section.coords[1]]);
|
|
3624
|
+
}
|
|
3625
|
+
}
|
|
3626
|
+
this.stretch(exports.Side.Right, -margin - columnWidth);
|
|
3627
|
+
}
|
|
3628
|
+
/**
|
|
3629
|
+
* Removes all sections with the given index along the y axis.
|
|
3630
|
+
* @public
|
|
3631
|
+
*/
|
|
3632
|
+
removeSectionRow(rowIndex) {
|
|
3633
|
+
var _a;
|
|
3634
|
+
const margin = ((_a = this.type.sectionGrid) === null || _a === void 0 ? void 0 : _a.margin) || 0;
|
|
3635
|
+
let rowHeight = 0;
|
|
3636
|
+
const sections = [...this.sections];
|
|
3637
|
+
for (const section of sections) {
|
|
3638
|
+
if (section.indexXInNode === rowIndex) {
|
|
3639
|
+
rowHeight = Math.max(rowHeight, section.height);
|
|
3640
|
+
this.model.sections.remove(section.id);
|
|
3641
|
+
}
|
|
3642
|
+
}
|
|
3643
|
+
for (const section of sections) {
|
|
3644
|
+
if (section.indexYInNode > rowIndex) {
|
|
3645
|
+
--section.indexXInNode;
|
|
3646
|
+
section.move([section.coords[0], section.coords[1] - rowHeight - margin]);
|
|
3647
|
+
}
|
|
3648
|
+
}
|
|
3649
|
+
this.stretch(exports.Side.Bottom, -margin - rowHeight);
|
|
3650
|
+
}
|
|
3651
|
+
/**
|
|
3652
|
+
* Creates a copy of all sections with the given index along the x axis.
|
|
3653
|
+
* @public
|
|
3654
|
+
*/
|
|
3655
|
+
copySectionColumn(columnIndex) {
|
|
3656
|
+
var _a;
|
|
3657
|
+
const margin = ((_a = this.type.sectionGrid) === null || _a === void 0 ? void 0 : _a.margin) || 0;
|
|
3658
|
+
let columnWidth = 0;
|
|
3659
|
+
const sections = [...this.sections];
|
|
3660
|
+
for (const section of sections) {
|
|
3661
|
+
if (section.indexXInNode === columnIndex) {
|
|
3662
|
+
columnWidth = Math.max(columnWidth, section.width);
|
|
3663
|
+
let newSectionIdIndexX = section.indexXInNode + 1;
|
|
3664
|
+
while (this.model.sections.get(`${section.id}_copy_${newSectionIdIndexX}_${section.indexYInNode}`, true) !== undefined) {
|
|
3665
|
+
++newSectionIdIndexX;
|
|
3666
|
+
}
|
|
3667
|
+
this.model.sections.new(this, section.indexXInNode + 1, section.indexYInNode, [section.coords[0] + section.width + margin, section.coords[1]], section.width, section.height, `${section.id}_copy_${newSectionIdIndexX}_${section.indexYInNode}`);
|
|
3668
|
+
}
|
|
3669
|
+
}
|
|
3670
|
+
for (const section of sections) {
|
|
3671
|
+
if (section.indexXInNode > columnIndex) {
|
|
3672
|
+
++section.indexXInNode;
|
|
3673
|
+
section.move([section.coords[0] + columnWidth + margin, section.coords[1]]);
|
|
3674
|
+
}
|
|
3675
|
+
}
|
|
3676
|
+
this.stretch(exports.Side.Right, margin + columnWidth);
|
|
3677
|
+
}
|
|
3678
|
+
/**
|
|
3679
|
+
* Creates a copy of all sections with the given index along the y axis.
|
|
3680
|
+
* @public
|
|
3681
|
+
*/
|
|
3682
|
+
copySectionRow(rowIndex) {
|
|
3683
|
+
var _a;
|
|
3684
|
+
const margin = ((_a = this.type.sectionGrid) === null || _a === void 0 ? void 0 : _a.margin) || 0;
|
|
3685
|
+
let rowHeight = 0;
|
|
3686
|
+
const sections = [...this.sections];
|
|
3687
|
+
for (const section of sections) {
|
|
3688
|
+
if (section.indexYInNode === rowIndex) {
|
|
3689
|
+
rowHeight = Math.max(rowHeight, section.height);
|
|
3690
|
+
let newSectionIdIndexY = section.indexYInNode + 1;
|
|
3691
|
+
while (this.model.sections.get(`${section.id}_copy_${section.indexXInNode}_${newSectionIdIndexY}`, true) !== undefined) {
|
|
3692
|
+
++newSectionIdIndexY;
|
|
3693
|
+
}
|
|
3694
|
+
this.model.sections.new(this, section.indexXInNode, section.indexYInNode + 1, [section.coords[0], section.coords[1] + section.height + margin], section.width, section.height, `${section.id}_copy_${section.indexXInNode}_${newSectionIdIndexY}`);
|
|
3695
|
+
}
|
|
3696
|
+
}
|
|
3697
|
+
for (const section of sections) {
|
|
3698
|
+
if (section.indexYInNode > rowIndex) {
|
|
3699
|
+
++section.indexYInNode;
|
|
3700
|
+
section.move([section.coords[0], section.coords[1] + rowHeight + margin]);
|
|
3701
|
+
}
|
|
3702
|
+
}
|
|
3703
|
+
this.stretch(exports.Side.Bottom, margin + rowHeight);
|
|
3704
|
+
}
|
|
3605
3705
|
}
|
|
3606
3706
|
class DiagramNodeSet extends DiagramElementSet {
|
|
3607
3707
|
/**
|
|
@@ -3647,10 +3747,10 @@ class DiagramNodeSet extends DiagramElementSet {
|
|
|
3647
3747
|
for (let j = 0; j < nodeType.sectionGrid.sections.length; ++j) {
|
|
3648
3748
|
let widthAccumulator = node.coords[0] + (nodeType.sectionGrid.margin || 0);
|
|
3649
3749
|
for (let i = 0; i < nodeType.sectionGrid.sections[j].length; ++i) {
|
|
3650
|
-
this.model.sections.new(node, i, j, [widthAccumulator, heightAccumulator], ((_a = nodeType.sectionGrid.defaultWidths) === null || _a ===
|
|
3651
|
-
widthAccumulator += (((_c = nodeType.sectionGrid.defaultWidths) === null || _c ===
|
|
3750
|
+
this.model.sections.new(node, i, j, [widthAccumulator, heightAccumulator], ((_a = nodeType.sectionGrid.defaultWidths) === null || _a === void 0 ? void 0 : _a[i]) || DIAGRAM_SECTION_DEFAULT_WIDTH, ((_b = nodeType.sectionGrid.defaultHeights) === null || _b === void 0 ? void 0 : _b[j]) || DIAGRAM_SECTION_DEFAULT_HEIGHT, `${node.id}_${j}_${i}`);
|
|
3751
|
+
widthAccumulator += (((_c = nodeType.sectionGrid.defaultWidths) === null || _c === void 0 ? void 0 : _c[i]) || DIAGRAM_SECTION_DEFAULT_WIDTH) + (nodeType.sectionGrid.margin || 0);
|
|
3652
3752
|
}
|
|
3653
|
-
heightAccumulator += (((_d = nodeType.sectionGrid.defaultHeights) === null || _d ===
|
|
3753
|
+
heightAccumulator += (((_d = nodeType.sectionGrid.defaultHeights) === null || _d === void 0 ? void 0 : _d[j]) || DIAGRAM_SECTION_DEFAULT_HEIGHT) + (nodeType.sectionGrid.margin || 0);
|
|
3654
3754
|
}
|
|
3655
3755
|
}
|
|
3656
3756
|
// add node ports
|
|
@@ -3659,8 +3759,8 @@ class DiagramNodeSet extends DiagramElementSet {
|
|
|
3659
3759
|
const portConfig = nodeType.ports[i];
|
|
3660
3760
|
const portType = portConfig.type !== undefined ? this.model.ports.types.get(portConfig.type) : undefined;
|
|
3661
3761
|
const port = this.model.ports.new(portType, node, [node.coords[0] + portConfig.coords[0], node.coords[1] + portConfig.coords[1]], portConfig.connectionPoint !== undefined ? [node.coords[0] + (portConfig.connectionPoint[0] || 0), node.coords[1] + (portConfig.connectionPoint[1] || 0)] : undefined, portConfig.direction, `${node.id}_port_${i}`);
|
|
3662
|
-
if ((_e = port.type) === null || _e ===
|
|
3663
|
-
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_f = port.type) === null || _f ===
|
|
3762
|
+
if ((_e = port.type) === null || _e === void 0 ? void 0 : _e.label) {
|
|
3763
|
+
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_f = port.type) === null || _f === void 0 ? void 0 : _f.label);
|
|
3664
3764
|
const labelWidth = 6 * labelConfiguration.fontSize + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
|
|
3665
3765
|
const labelHeight = labelConfiguration.fontSize + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
|
|
3666
3766
|
let labelCoords;
|
|
@@ -3676,14 +3776,14 @@ class DiagramNodeSet extends DiagramElementSet {
|
|
|
3676
3776
|
default:
|
|
3677
3777
|
labelCoords = port.coords;
|
|
3678
3778
|
}
|
|
3679
|
-
this.model.fields.new(port, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, '', labelConfiguration.editable, labelConfiguration.fit);
|
|
3779
|
+
this.model.fields.new(port, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit);
|
|
3680
3780
|
}
|
|
3681
3781
|
}
|
|
3682
3782
|
}
|
|
3683
3783
|
// add node label
|
|
3684
3784
|
if (nodeType.label) {
|
|
3685
3785
|
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), nodeType.label);
|
|
3686
|
-
this.model.fields.new(node, [node.coords[0] + getLeftMargin(labelConfiguration), node.coords[1] + getTopMargin(labelConfiguration)], labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, node.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), node.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, '', labelConfiguration.editable, labelConfiguration.fit);
|
|
3786
|
+
this.model.fields.new(node, [node.coords[0] + getLeftMargin(labelConfiguration), node.coords[1] + getTopMargin(labelConfiguration)], labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, node.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), node.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit);
|
|
3687
3787
|
}
|
|
3688
3788
|
// add node decorators
|
|
3689
3789
|
if (nodeType.decorators.length > 0) {
|
|
@@ -3693,7 +3793,7 @@ class DiagramNodeSet extends DiagramElementSet {
|
|
|
3693
3793
|
}
|
|
3694
3794
|
}
|
|
3695
3795
|
node.valueSet.resetValues();
|
|
3696
|
-
(_g = node.model.canvas) === null || _g ===
|
|
3796
|
+
(_g = node.model.canvas) === null || _g === void 0 ? void 0 : _g.fitNodeInView(node.id);
|
|
3697
3797
|
return node;
|
|
3698
3798
|
}
|
|
3699
3799
|
remove(id) {
|
|
@@ -3785,7 +3885,7 @@ const filterByOnlyDescendants = nodes => {
|
|
|
3785
3885
|
return nodes;
|
|
3786
3886
|
};
|
|
3787
3887
|
const getBottomPadding = config => {
|
|
3788
|
-
if ((config === null || config ===
|
|
3888
|
+
if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
|
|
3789
3889
|
return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
|
|
3790
3890
|
} else if (typeof config.padding === 'number') {
|
|
3791
3891
|
return config.padding;
|
|
@@ -3804,7 +3904,7 @@ const getBottomPadding = config => {
|
|
|
3804
3904
|
}
|
|
3805
3905
|
};
|
|
3806
3906
|
const getLeftPadding = config => {
|
|
3807
|
-
if ((config === null || config ===
|
|
3907
|
+
if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
|
|
3808
3908
|
return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
|
|
3809
3909
|
} else if (typeof config.padding === 'number') {
|
|
3810
3910
|
return config.padding;
|
|
@@ -3823,7 +3923,7 @@ const getLeftPadding = config => {
|
|
|
3823
3923
|
}
|
|
3824
3924
|
};
|
|
3825
3925
|
const getRightPadding = config => {
|
|
3826
|
-
if ((config === null || config ===
|
|
3926
|
+
if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
|
|
3827
3927
|
return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
|
|
3828
3928
|
} else if (typeof config.padding === 'number') {
|
|
3829
3929
|
return config.padding;
|
|
@@ -3842,7 +3942,7 @@ const getRightPadding = config => {
|
|
|
3842
3942
|
}
|
|
3843
3943
|
};
|
|
3844
3944
|
const getTopPadding = config => {
|
|
3845
|
-
if ((config === null || config ===
|
|
3945
|
+
if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
|
|
3846
3946
|
return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
|
|
3847
3947
|
} else if (typeof config.padding === 'number') {
|
|
3848
3948
|
return config.padding;
|
|
@@ -3931,7 +4031,7 @@ class DiagramPort extends DiagramElement {
|
|
|
3931
4031
|
}
|
|
3932
4032
|
get typeString() {
|
|
3933
4033
|
var _a;
|
|
3934
|
-
return (_a = this.type) === null || _a ===
|
|
4034
|
+
return (_a = this.type) === null || _a === void 0 ? void 0 : _a.id;
|
|
3935
4035
|
}
|
|
3936
4036
|
set typeString(typeString) {
|
|
3937
4037
|
if (typeString === undefined) {
|
|
@@ -3948,14 +4048,14 @@ class DiagramPort extends DiagramElement {
|
|
|
3948
4048
|
*/
|
|
3949
4049
|
get allowsOutgoing() {
|
|
3950
4050
|
var _a, _b;
|
|
3951
|
-
return ((_a = this.type) === null || _a ===
|
|
4051
|
+
return ((_a = this.type) === null || _a === void 0 ? void 0 : _a.allowsOutgoing) !== undefined ? (_b = this.type) === null || _b === void 0 ? void 0 : _b.allowsOutgoing : true;
|
|
3952
4052
|
}
|
|
3953
4053
|
/**
|
|
3954
4054
|
* Whether this port can be used as a connection end point.
|
|
3955
4055
|
*/
|
|
3956
4056
|
get allowsIncoming() {
|
|
3957
4057
|
var _a, _b;
|
|
3958
|
-
return ((_a = this.type) === null || _a ===
|
|
4058
|
+
return ((_a = this.type) === null || _a === void 0 ? void 0 : _a.allowsIncoming) !== undefined ? (_b = this.type) === null || _b === void 0 ? void 0 : _b.allowsIncoming : true;
|
|
3959
4059
|
}
|
|
3960
4060
|
/**
|
|
3961
4061
|
* Name of this port. Alias for this port's label's text.
|
|
@@ -3963,7 +4063,7 @@ class DiagramPort extends DiagramElement {
|
|
|
3963
4063
|
*/
|
|
3964
4064
|
get name() {
|
|
3965
4065
|
var _a;
|
|
3966
|
-
return ((_a = this.label) === null || _a ===
|
|
4066
|
+
return ((_a = this.label) === null || _a === void 0 ? void 0 : _a.text) || '';
|
|
3967
4067
|
}
|
|
3968
4068
|
set name(name) {
|
|
3969
4069
|
if (this.label) {
|
|
@@ -3978,15 +4078,15 @@ class DiagramPort extends DiagramElement {
|
|
|
3978
4078
|
var _a, _b, _c, _d;
|
|
3979
4079
|
if (this.selected) {
|
|
3980
4080
|
if (this.highlighted) {
|
|
3981
|
-
return this._selectedAndHighlightedLook !== undefined ? this._selectedAndHighlightedLook : (_a = this.type || DIAGRAM_PORT_LOOKS) === null || _a ===
|
|
4081
|
+
return this._selectedAndHighlightedLook !== undefined ? this._selectedAndHighlightedLook : (_a = this.type || DIAGRAM_PORT_LOOKS) === null || _a === void 0 ? void 0 : _a.selectedAndHighlightedLook;
|
|
3982
4082
|
} else {
|
|
3983
|
-
return this._selectedLook !== undefined ? this._selectedLook : (_b = this.type || DIAGRAM_PORT_LOOKS) === null || _b ===
|
|
4083
|
+
return this._selectedLook !== undefined ? this._selectedLook : (_b = this.type || DIAGRAM_PORT_LOOKS) === null || _b === void 0 ? void 0 : _b.selectedLook;
|
|
3984
4084
|
}
|
|
3985
4085
|
} else {
|
|
3986
4086
|
if (this.highlighted) {
|
|
3987
|
-
return this._highlightedLook !== undefined ? this._highlightedLook : (_c = this.type || DIAGRAM_PORT_LOOKS) === null || _c ===
|
|
4087
|
+
return this._highlightedLook !== undefined ? this._highlightedLook : (_c = this.type || DIAGRAM_PORT_LOOKS) === null || _c === void 0 ? void 0 : _c.highlightedLook;
|
|
3988
4088
|
} else {
|
|
3989
|
-
return this._defaultLook !== undefined ? this._defaultLook : (_d = this.type || DIAGRAM_PORT_LOOKS) === null || _d ===
|
|
4089
|
+
return this._defaultLook !== undefined ? this._defaultLook : (_d = this.type || DIAGRAM_PORT_LOOKS) === null || _d === void 0 ? void 0 : _d.defaultLook;
|
|
3990
4090
|
}
|
|
3991
4091
|
}
|
|
3992
4092
|
}
|
|
@@ -4015,7 +4115,7 @@ class DiagramPort extends DiagramElement {
|
|
|
4015
4115
|
*/
|
|
4016
4116
|
get width() {
|
|
4017
4117
|
var _a;
|
|
4018
|
-
return ((_a = this.type) === null || _a ===
|
|
4118
|
+
return ((_a = this.type) === null || _a === void 0 ? void 0 : _a.width) || DIAGRAM_PORT_TYPE_DEFAULTS.width;
|
|
4019
4119
|
}
|
|
4020
4120
|
/**
|
|
4021
4121
|
* Current height of this port. Same as the width.
|
|
@@ -4053,11 +4153,11 @@ class DiagramPort extends DiagramElement {
|
|
|
4053
4153
|
}
|
|
4054
4154
|
updateInView() {
|
|
4055
4155
|
var _a;
|
|
4056
|
-
(_a = this.model.canvas) === null || _a ===
|
|
4156
|
+
(_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updatePortsInView(this.id);
|
|
4057
4157
|
}
|
|
4058
4158
|
raise() {
|
|
4059
4159
|
var _a;
|
|
4060
|
-
(_a = this.select()) === null || _a ===
|
|
4160
|
+
(_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
|
|
4061
4161
|
if (this.label) {
|
|
4062
4162
|
this.label.raise();
|
|
4063
4163
|
}
|
|
@@ -4099,7 +4199,7 @@ class DiagramPort extends DiagramElement {
|
|
|
4099
4199
|
}
|
|
4100
4200
|
getPriority() {
|
|
4101
4201
|
var _a;
|
|
4102
|
-
return ((_a = this.rootElement) === null || _a ===
|
|
4202
|
+
return ((_a = this.rootElement) === null || _a === void 0 ? void 0 : _a.getPriority()) || DEFAULT_PRIORITY;
|
|
4103
4203
|
}
|
|
4104
4204
|
/**
|
|
4105
4205
|
* Change the coordinates of this port to the given coordinates and move its labels correspondingly.
|
|
@@ -4230,7 +4330,7 @@ class DagaImporter {
|
|
|
4230
4330
|
// add node label
|
|
4231
4331
|
if (newNodeType.label) {
|
|
4232
4332
|
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newNodeType.label);
|
|
4233
|
-
const newField = new DiagramField(model, newNode, [newNode.coords[0] + getLeftMargin(labelConfiguration), newNode.coords[1] + getTopMargin(labelConfiguration)], newNode.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), newNode.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, '', labelConfiguration.editable, labelConfiguration.fit);
|
|
4333
|
+
const newField = new DiagramField(model, newNode, [newNode.coords[0] + getLeftMargin(labelConfiguration), newNode.coords[1] + getTopMargin(labelConfiguration)], newNode.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), newNode.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit);
|
|
4234
4334
|
newField.text = node.label;
|
|
4235
4335
|
newNode.label = newField;
|
|
4236
4336
|
model.fields.add(newField);
|
|
@@ -4240,19 +4340,19 @@ class DagaImporter {
|
|
|
4240
4340
|
for (const child of node.children || []) {
|
|
4241
4341
|
const newChild = this.importNode(model, child);
|
|
4242
4342
|
if (newChild !== undefined) {
|
|
4243
|
-
(_a = newNode.children) === null || _a ===
|
|
4343
|
+
(_a = newNode.children) === null || _a === void 0 ? void 0 : _a.push(newChild);
|
|
4244
4344
|
newChild.parent = newNode;
|
|
4245
4345
|
}
|
|
4246
4346
|
}
|
|
4247
4347
|
for (const section of node.sections || []) {
|
|
4248
4348
|
const newSection = new DiagramSection(model, newNode, section.indexXInNode, section.indexYInNode, section.coords, section.width, section.height, section.id);
|
|
4249
|
-
(_b = newNode.sections) === null || _b ===
|
|
4349
|
+
(_b = newNode.sections) === null || _b === void 0 ? void 0 : _b.push(newSection);
|
|
4250
4350
|
model.sections.add(newSection);
|
|
4251
4351
|
if (section.label) {
|
|
4252
4352
|
// add section label
|
|
4253
|
-
if ((_f = (_e = (_d = (_c = newNodeType.sectionGrid) === null || _c ===
|
|
4254
|
-
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_k = (_j = (_h = (_g = newNodeType.sectionGrid) === null || _g ===
|
|
4255
|
-
const newField = new DiagramField(model, newSection, [newSection.coords[0] + getLeftMargin(labelConfiguration), newSection.coords[1] + getTopMargin(labelConfiguration)], newSection.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), newSection.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, '', labelConfiguration.editable, labelConfiguration.fit);
|
|
4353
|
+
if ((_f = (_e = (_d = (_c = newNodeType.sectionGrid) === null || _c === void 0 ? void 0 : _c.sections) === null || _d === void 0 ? void 0 : _d[section.indexYInNode]) === null || _e === void 0 ? void 0 : _e[section.indexXInNode]) === null || _f === void 0 ? void 0 : _f.label) {
|
|
4354
|
+
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_k = (_j = (_h = (_g = newNodeType.sectionGrid) === null || _g === void 0 ? void 0 : _g.sections) === null || _h === void 0 ? void 0 : _h[section.indexYInNode]) === null || _j === void 0 ? void 0 : _j[section.indexXInNode]) === null || _k === void 0 ? void 0 : _k.label);
|
|
4355
|
+
const newField = new DiagramField(model, newSection, [newSection.coords[0] + getLeftMargin(labelConfiguration), newSection.coords[1] + getTopMargin(labelConfiguration)], newSection.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), newSection.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit);
|
|
4256
4356
|
newField.text = section.label;
|
|
4257
4357
|
newSection.label = newField;
|
|
4258
4358
|
model.fields.add(newField);
|
|
@@ -4267,8 +4367,8 @@ class DagaImporter {
|
|
|
4267
4367
|
model.ports.add(newPort);
|
|
4268
4368
|
if (port.label) {
|
|
4269
4369
|
// add port label
|
|
4270
|
-
if (newNodeType.ports.length > portCounter && (newPortType === null || newPortType ===
|
|
4271
|
-
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newPortType === null || newPortType ===
|
|
4370
|
+
if (newNodeType.ports.length > portCounter && (newPortType === null || newPortType === void 0 ? void 0 : newPortType.label)) {
|
|
4371
|
+
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newPortType === null || newPortType === void 0 ? void 0 : newPortType.label);
|
|
4272
4372
|
let labelCoords;
|
|
4273
4373
|
switch (newPort.direction) {
|
|
4274
4374
|
case exports.Side.Top:
|
|
@@ -4284,7 +4384,7 @@ class DagaImporter {
|
|
|
4284
4384
|
default:
|
|
4285
4385
|
labelCoords = newPort.coords;
|
|
4286
4386
|
}
|
|
4287
|
-
const newField = new DiagramField(model, newPort, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, '', labelConfiguration.editable, labelConfiguration.fit);
|
|
4387
|
+
const newField = new DiagramField(model, newPort, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit);
|
|
4288
4388
|
newField.text = port.label;
|
|
4289
4389
|
newPort.label = newField;
|
|
4290
4390
|
model.fields.add(newField);
|
|
@@ -4314,8 +4414,8 @@ class DagaImporter {
|
|
|
4314
4414
|
model.ports.add(newPort);
|
|
4315
4415
|
if (port.label) {
|
|
4316
4416
|
// add port label
|
|
4317
|
-
if (newNodeType.ports.length > portCounter && (newPortType === null || newPortType ===
|
|
4318
|
-
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newPortType === null || newPortType ===
|
|
4417
|
+
if (newNodeType.ports.length > portCounter && (newPortType === null || newPortType === void 0 ? void 0 : newPortType.label)) {
|
|
4418
|
+
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newPortType === null || newPortType === void 0 ? void 0 : newPortType.label);
|
|
4319
4419
|
let labelCoords;
|
|
4320
4420
|
switch (newPort.direction) {
|
|
4321
4421
|
case exports.Side.Top:
|
|
@@ -4331,7 +4431,7 @@ class DagaImporter {
|
|
|
4331
4431
|
default:
|
|
4332
4432
|
labelCoords = newPort.coords;
|
|
4333
4433
|
}
|
|
4334
|
-
const newField = new DiagramField(model, newPort, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, '', labelConfiguration.editable, labelConfiguration.fit);
|
|
4434
|
+
const newField = new DiagramField(model, newPort, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit);
|
|
4335
4435
|
newField.text = port.label;
|
|
4336
4436
|
newPort.label = newField;
|
|
4337
4437
|
model.fields.add(newField);
|
|
@@ -4415,14 +4515,16 @@ class AddNodeCollabAction {
|
|
|
4415
4515
|
var _a;
|
|
4416
4516
|
const node = this.canvas.model.nodes.new(this.typeId, this.coords, this.id);
|
|
4417
4517
|
if (this.parentId !== undefined) {
|
|
4418
|
-
(_a = this.canvas.model.nodes.get(this.parentId)) === null || _a ===
|
|
4419
|
-
}
|
|
4420
|
-
if (this.values !== undefined) {
|
|
4421
|
-
node.valueSet.setValues(structuredClone(Object.assign(Object.assign({}, node.valueSet.getValues()), this.values)));
|
|
4518
|
+
(_a = this.canvas.model.nodes.get(this.parentId)) === null || _a === void 0 ? void 0 : _a.addChild(node);
|
|
4422
4519
|
}
|
|
4423
4520
|
if (node.label) {
|
|
4424
4521
|
node.label.text = this.label || '';
|
|
4425
4522
|
}
|
|
4523
|
+
if (this.values !== undefined) {
|
|
4524
|
+
node.valueSet.setValues(structuredClone(Object.assign(Object.assign({}, node.valueSet.getValues()), this.values)));
|
|
4525
|
+
} else {
|
|
4526
|
+
node.valueSet.resetValues();
|
|
4527
|
+
}
|
|
4426
4528
|
}
|
|
4427
4529
|
serialize() {
|
|
4428
4530
|
return {
|
|
@@ -4439,6 +4541,54 @@ class AddNodeCollabAction {
|
|
|
4439
4541
|
return new AddNodeCollabAction(canvas, serialized.id, serialized.typeId, serialized.coords, serialized.parentId, serialized.label, serialized.values);
|
|
4440
4542
|
}
|
|
4441
4543
|
}
|
|
4544
|
+
/**
|
|
4545
|
+
* Collaborative action which consists of adding or removing sections in a node.
|
|
4546
|
+
* @private
|
|
4547
|
+
* @see AddNodeAction
|
|
4548
|
+
*/
|
|
4549
|
+
class AddSectionCollabAction {
|
|
4550
|
+
constructor(canvas, nodeId, copyColumnIndex, copyRowIndex, removeColumnIndex, removeRowIndex, timestamp) {
|
|
4551
|
+
this.canvas = canvas;
|
|
4552
|
+
this.nodeId = nodeId;
|
|
4553
|
+
this.copyColumnIndex = copyColumnIndex;
|
|
4554
|
+
this.copyRowIndex = copyRowIndex;
|
|
4555
|
+
this.removeColumnIndex = removeColumnIndex;
|
|
4556
|
+
this.removeRowIndex = removeRowIndex;
|
|
4557
|
+
this.timestamp = timestamp;
|
|
4558
|
+
}
|
|
4559
|
+
do() {
|
|
4560
|
+
const node = this.canvas.model.nodes.get(this.nodeId);
|
|
4561
|
+
if (node && timestampWins(this.timestamp, node.geometryTimestamp)) {
|
|
4562
|
+
if (this.copyColumnIndex !== undefined) {
|
|
4563
|
+
node.copySectionColumn(this.copyColumnIndex);
|
|
4564
|
+
}
|
|
4565
|
+
if (this.copyRowIndex !== undefined) {
|
|
4566
|
+
node.copySectionRow(this.copyRowIndex);
|
|
4567
|
+
}
|
|
4568
|
+
if (this.removeColumnIndex !== undefined) {
|
|
4569
|
+
node.removeSectionColumn(this.removeColumnIndex);
|
|
4570
|
+
}
|
|
4571
|
+
if (this.removeRowIndex !== undefined) {
|
|
4572
|
+
node.removeSectionRow(this.removeRowIndex);
|
|
4573
|
+
}
|
|
4574
|
+
node.geometryTimestamp = this.timestamp;
|
|
4575
|
+
}
|
|
4576
|
+
}
|
|
4577
|
+
serialize() {
|
|
4578
|
+
return {
|
|
4579
|
+
type: 'addSection',
|
|
4580
|
+
nodeId: this.nodeId,
|
|
4581
|
+
copyColumnIndex: this.copyColumnIndex,
|
|
4582
|
+
copyRowIndex: this.copyRowIndex,
|
|
4583
|
+
removeColumnIndex: this.removeColumnIndex,
|
|
4584
|
+
removeRowIndex: this.removeRowIndex,
|
|
4585
|
+
timestamp: this.timestamp
|
|
4586
|
+
};
|
|
4587
|
+
}
|
|
4588
|
+
static deserialize(canvas, serialized) {
|
|
4589
|
+
return new AddSectionCollabAction(canvas, serialized.nodeId, serialized.copyColumnIndex, serialized.copyRowIndex, serialized.removeColumnIndex, serialized.removeRowIndex, serialized.timestamp);
|
|
4590
|
+
}
|
|
4591
|
+
}
|
|
4442
4592
|
/**
|
|
4443
4593
|
* Collaborative which consists of applying a layout to the diagram which can change the location of several nodes.
|
|
4444
4594
|
* @private
|
|
@@ -4489,7 +4639,7 @@ class MoveCollabAction {
|
|
|
4489
4639
|
const node = this.canvas.model.nodes.get(nodeId, true);
|
|
4490
4640
|
if (node && timestampWins(this.timestamp, node.geometryTimestamp)) {
|
|
4491
4641
|
node.move([node.coords[0] + this.delta[0], node.coords[1] + this.delta[1]]);
|
|
4492
|
-
(_a = node.parent) === null || _a ===
|
|
4642
|
+
(_a = node.parent) === null || _a === void 0 ? void 0 : _a.fitToChild(node);
|
|
4493
4643
|
node.geometryTimestamp = this.timestamp;
|
|
4494
4644
|
}
|
|
4495
4645
|
}
|
|
@@ -4524,15 +4674,15 @@ class SetGeometryCollabAction {
|
|
|
4524
4674
|
if (node && timestampWins(this.timestamp, node.geometryTimestamp)) {
|
|
4525
4675
|
node.setGeometry(this.to);
|
|
4526
4676
|
// Re-fit the labels, in case their text has changed since `this.to` was measured.
|
|
4527
|
-
if ((_a = node.label) === null || _a ===
|
|
4677
|
+
if ((_a = node.label) === null || _a === void 0 ? void 0 : _a.fit) {
|
|
4528
4678
|
this.canvas.fitFieldRootInView(node.label.id);
|
|
4529
4679
|
}
|
|
4530
4680
|
for (const section of node.sections) {
|
|
4531
|
-
if ((_b = section.label) === null || _b ===
|
|
4681
|
+
if ((_b = section.label) === null || _b === void 0 ? void 0 : _b.fit) {
|
|
4532
4682
|
this.canvas.fitFieldRootInView(section.label.id);
|
|
4533
4683
|
}
|
|
4534
4684
|
}
|
|
4535
|
-
(_c = node.parent) === null || _c ===
|
|
4685
|
+
(_c = node.parent) === null || _c === void 0 ? void 0 : _c.fitToChild(node);
|
|
4536
4686
|
node.geometryTimestamp = this.timestamp;
|
|
4537
4687
|
}
|
|
4538
4688
|
}
|
|
@@ -4566,9 +4716,9 @@ class SetParentCollabAction {
|
|
|
4566
4716
|
const childNode = this.canvas.model.nodes.get(this.childId, true);
|
|
4567
4717
|
const parentNode = this.parentId !== undefined ? this.canvas.model.nodes.get(this.parentId, true) : undefined;
|
|
4568
4718
|
if (childNode && (this.parentId !== undefined ? parentNode : true) && timestampWins(this.timestamp, childNode.geometryTimestamp)) {
|
|
4569
|
-
(_a = childNode.parent) === null || _a ===
|
|
4719
|
+
(_a = childNode.parent) === null || _a === void 0 ? void 0 : _a.removeChild(childNode);
|
|
4570
4720
|
childNode.setGeometry(this.childGeometry);
|
|
4571
|
-
parentNode === null || parentNode ===
|
|
4721
|
+
parentNode === null || parentNode === void 0 ? void 0 : parentNode.addChild(childNode);
|
|
4572
4722
|
}
|
|
4573
4723
|
}
|
|
4574
4724
|
serialize() {
|
|
@@ -4665,12 +4815,12 @@ class UpdateValuesCollabAction {
|
|
|
4665
4815
|
if (this.id === undefined) {
|
|
4666
4816
|
return this.canvas.model.valueSet;
|
|
4667
4817
|
} else {
|
|
4668
|
-
return (_a = this.canvas.model.nodes.get(this.id, true) || this.canvas.model.connections.get(this.id, true)) === null || _a ===
|
|
4818
|
+
return (_a = this.canvas.model.nodes.get(this.id, true) || this.canvas.model.connections.get(this.id, true)) === null || _a === void 0 ? void 0 : _a.valueSet;
|
|
4669
4819
|
}
|
|
4670
4820
|
}
|
|
4671
4821
|
do() {
|
|
4672
4822
|
var _a;
|
|
4673
|
-
(_a = this.getValueSet()) === null || _a ===
|
|
4823
|
+
(_a = this.getValueSet()) === null || _a === void 0 ? void 0 : _a.overwriteValuesLww(this.to, this.timestamp);
|
|
4674
4824
|
}
|
|
4675
4825
|
serialize() {
|
|
4676
4826
|
return {
|
|
@@ -4855,6 +5005,12 @@ class CollabEngine {
|
|
|
4855
5005
|
action.do();
|
|
4856
5006
|
break;
|
|
4857
5007
|
}
|
|
5008
|
+
case 'addSection':
|
|
5009
|
+
{
|
|
5010
|
+
const action = AddSectionCollabAction.deserialize(this.canvas, message);
|
|
5011
|
+
action.do();
|
|
5012
|
+
break;
|
|
5013
|
+
}
|
|
4858
5014
|
case 'applyLayout':
|
|
4859
5015
|
{
|
|
4860
5016
|
const action = ApplyLayoutCollabAction.deserialize(this.canvas, message);
|
|
@@ -5017,6 +5173,12 @@ exports.DiagramActions = void 0;
|
|
|
5017
5173
|
* @see AddNodeAction
|
|
5018
5174
|
*/
|
|
5019
5175
|
DiagramActions["AddNode"] = "add-node";
|
|
5176
|
+
/**
|
|
5177
|
+
* Action that corresponds to the addition or removal of sections in a node.
|
|
5178
|
+
* @public
|
|
5179
|
+
* @see AddSectionAction
|
|
5180
|
+
*/
|
|
5181
|
+
DiagramActions["AddSectionAction"] = "add-section";
|
|
5020
5182
|
/**
|
|
5021
5183
|
* Action that corresponds to applying a layout which changes the location of several nodes.
|
|
5022
5184
|
* @public
|
|
@@ -5658,11 +5820,11 @@ class DiagramDecorator extends DiagramElement {
|
|
|
5658
5820
|
}
|
|
5659
5821
|
updateInView() {
|
|
5660
5822
|
var _a;
|
|
5661
|
-
(_a = this.model.canvas) === null || _a ===
|
|
5823
|
+
(_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateDecoratorsInView(this.id);
|
|
5662
5824
|
}
|
|
5663
5825
|
raise() {
|
|
5664
5826
|
var _a;
|
|
5665
|
-
(_a = this.select()) === null || _a ===
|
|
5827
|
+
(_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
|
|
5666
5828
|
}
|
|
5667
5829
|
/**
|
|
5668
5830
|
* Change the coordinates of this decorator to the given coordinates.
|
|
@@ -5747,11 +5909,11 @@ class DiagramObject extends DiagramElement {
|
|
|
5747
5909
|
}
|
|
5748
5910
|
updateInView() {
|
|
5749
5911
|
var _a;
|
|
5750
|
-
(_a = this.model.canvas) === null || _a ===
|
|
5912
|
+
(_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateObjectsInView(this.id);
|
|
5751
5913
|
}
|
|
5752
5914
|
raise() {
|
|
5753
5915
|
var _a;
|
|
5754
|
-
(_a = this.select()) === null || _a ===
|
|
5916
|
+
(_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
|
|
5755
5917
|
}
|
|
5756
5918
|
/**
|
|
5757
5919
|
* Change the coordinates of this object to the given coordinates.
|
|
@@ -5868,7 +6030,7 @@ class DiagramModel {
|
|
|
5868
6030
|
*/
|
|
5869
6031
|
clear() {
|
|
5870
6032
|
var _a, _b;
|
|
5871
|
-
(_a = this.canvas) === null || _a ===
|
|
6033
|
+
(_a = this.canvas) === null || _a === void 0 ? void 0 : _a.cancelAllUserActions();
|
|
5872
6034
|
this.id = undefined;
|
|
5873
6035
|
this.name = '';
|
|
5874
6036
|
this.description = undefined;
|
|
@@ -5883,7 +6045,7 @@ class DiagramModel {
|
|
|
5883
6045
|
this.objects.clear();
|
|
5884
6046
|
this.decorators.clear();
|
|
5885
6047
|
this.valueSet.resetValues();
|
|
5886
|
-
(_b = this.canvas) === null || _b ===
|
|
6048
|
+
(_b = this.canvas) === null || _b === void 0 ? void 0 : _b.updateModelInView();
|
|
5887
6049
|
}
|
|
5888
6050
|
}
|
|
5889
6051
|
|
|
@@ -5949,7 +6111,6 @@ const updateLook = selection => {
|
|
|
5949
6111
|
selection.filter('.stretchable-image-look').select('image.bottom-right-image').attr('x', d => d.width - d.look.rightMargin).attr('y', d => d.height - d.look.bottomMargin).attr('width', d => d.look.rightMargin).attr('height', d => d.look.bottomMargin).attr('href', d => d.look.backgroundImageBottomRight);
|
|
5950
6112
|
};
|
|
5951
6113
|
const GRID_DEFAULTS = {
|
|
5952
|
-
enabled: true,
|
|
5953
6114
|
style: 'dots',
|
|
5954
6115
|
color: 'rgba(0, 0, 0, 0.1)',
|
|
5955
6116
|
snap: false,
|
|
@@ -6107,7 +6268,7 @@ class DiagramContextMenu {
|
|
|
6107
6268
|
*/
|
|
6108
6269
|
close() {
|
|
6109
6270
|
var _a;
|
|
6110
|
-
(_a = this.contextMenuContainer) === null || _a ===
|
|
6271
|
+
(_a = this.contextMenuContainer) === null || _a === void 0 ? void 0 : _a.remove();
|
|
6111
6272
|
this.contextMenuContainer = undefined;
|
|
6112
6273
|
}
|
|
6113
6274
|
}
|
|
@@ -6243,11 +6404,11 @@ class DagaExporter {
|
|
|
6243
6404
|
for (const port of section.ports) {
|
|
6244
6405
|
ports.push(Object.assign({
|
|
6245
6406
|
id: port.id,
|
|
6246
|
-
type: (_a = port.type) === null || _a ===
|
|
6407
|
+
type: (_a = port.type) === null || _a === void 0 ? void 0 : _a.id,
|
|
6247
6408
|
coords: roundPoint(port.coords),
|
|
6248
6409
|
connectionPoint: roundPoint(port.connectionPoint),
|
|
6249
6410
|
direction: port.direction,
|
|
6250
|
-
label: ((_b = port.label) === null || _b ===
|
|
6411
|
+
label: ((_b = port.label) === null || _b === void 0 ? void 0 : _b.text) || ''
|
|
6251
6412
|
}, includeCollabMeta ? {
|
|
6252
6413
|
collabMeta: Object.assign({
|
|
6253
6414
|
removed: port.removed,
|
|
@@ -6259,7 +6420,7 @@ class DagaExporter {
|
|
|
6259
6420
|
sections.push(Object.assign({
|
|
6260
6421
|
id: section.id,
|
|
6261
6422
|
ports,
|
|
6262
|
-
label: ((_c = section.label) === null || _c ===
|
|
6423
|
+
label: ((_c = section.label) === null || _c === void 0 ? void 0 : _c.text) || '',
|
|
6263
6424
|
indexXInNode: section.indexXInNode,
|
|
6264
6425
|
indexYInNode: section.indexYInNode,
|
|
6265
6426
|
coords: roundPoint(section.coords),
|
|
@@ -6277,11 +6438,11 @@ class DagaExporter {
|
|
|
6277
6438
|
for (const port of node.ports) {
|
|
6278
6439
|
ports.push(Object.assign({
|
|
6279
6440
|
id: port.id,
|
|
6280
|
-
type: (_d = port.type) === null || _d ===
|
|
6441
|
+
type: (_d = port.type) === null || _d === void 0 ? void 0 : _d.id,
|
|
6281
6442
|
coords: roundPoint(port.coords),
|
|
6282
6443
|
connectionPoint: roundPoint(port.connectionPoint),
|
|
6283
6444
|
direction: port.direction,
|
|
6284
|
-
label: ((_e = port.label) === null || _e ===
|
|
6445
|
+
label: ((_e = port.label) === null || _e === void 0 ? void 0 : _e.text) || ''
|
|
6285
6446
|
}, includeCollabMeta ? {
|
|
6286
6447
|
collabMeta: Object.assign({
|
|
6287
6448
|
removed: port.removed,
|
|
@@ -6296,7 +6457,7 @@ class DagaExporter {
|
|
|
6296
6457
|
children,
|
|
6297
6458
|
sections,
|
|
6298
6459
|
ports,
|
|
6299
|
-
label: ((_f = node.label) === null || _f ===
|
|
6460
|
+
label: ((_f = node.label) === null || _f === void 0 ? void 0 : _f.text) || '',
|
|
6300
6461
|
coords: roundPoint(node.coords),
|
|
6301
6462
|
width: node.width,
|
|
6302
6463
|
height: node.height,
|
|
@@ -6316,8 +6477,8 @@ class DagaExporter {
|
|
|
6316
6477
|
return Object.assign({
|
|
6317
6478
|
id: connection.id,
|
|
6318
6479
|
type: connection.type.id,
|
|
6319
|
-
start: ((_a = connection.start) === null || _a ===
|
|
6320
|
-
end: ((_b = connection.end) === null || _b ===
|
|
6480
|
+
start: ((_a = connection.start) === null || _a === void 0 ? void 0 : _a.id) || '',
|
|
6481
|
+
end: ((_b = connection.end) === null || _b === void 0 ? void 0 : _b.id) || '',
|
|
6321
6482
|
startLabel: connection.startLabel,
|
|
6322
6483
|
middleLabel: connection.middleLabel,
|
|
6323
6484
|
endLabel: connection.endLabel,
|
|
@@ -6537,11 +6698,11 @@ class DiagramUserSelection extends DiagramElementSet {
|
|
|
6537
6698
|
openInPropertyEditor(selection) {
|
|
6538
6699
|
var _a;
|
|
6539
6700
|
this.makeUpdateValuesAction();
|
|
6540
|
-
const propertyEditor = (_a = this.canvas.parentComponent) === null || _a ===
|
|
6701
|
+
const propertyEditor = (_a = this.canvas.parentComponent) === null || _a === void 0 ? void 0 : _a.propertyEditor;
|
|
6541
6702
|
if (propertyEditor === undefined) {
|
|
6542
6703
|
return;
|
|
6543
6704
|
}
|
|
6544
|
-
const selectedValueSet = selection === null || selection ===
|
|
6705
|
+
const selectedValueSet = selection === null || selection === void 0 ? void 0 : selection.valueSet;
|
|
6545
6706
|
if (selectedValueSet) {
|
|
6546
6707
|
this.propertyEditorSelection = selection;
|
|
6547
6708
|
this.propertyEditorValues = structuredClone(selectedValueSet.getValues());
|
|
@@ -6583,12 +6744,12 @@ class DiagramUserSelection extends DiagramElementSet {
|
|
|
6583
6744
|
const previousSelectionId = this.propertyEditorSelection instanceof DiagramModel ? undefined : this.propertyEditorSelection.id;
|
|
6584
6745
|
// check if there have been changes in the previously selected ValueSet,
|
|
6585
6746
|
// and create an UpdateValuesAction if there have
|
|
6586
|
-
if (equals(this.propertyEditorValues, (_a = this.propertyEditorSelection) === null || _a ===
|
|
6747
|
+
if (equals(this.propertyEditorValues, (_a = this.propertyEditorSelection) === null || _a === void 0 ? void 0 : _a.valueSet.getValues())) {
|
|
6587
6748
|
return;
|
|
6588
6749
|
}
|
|
6589
6750
|
const from = this.propertyEditorValues;
|
|
6590
|
-
const to = structuredClone((_b = this.propertyEditorSelection) === null || _b ===
|
|
6591
|
-
const [fromDiff, toDiff] = diffProperties(from, to, (_c = this.propertyEditorSelection) === null || _c ===
|
|
6751
|
+
const to = structuredClone((_b = this.propertyEditorSelection) === null || _b === void 0 ? void 0 : _b.valueSet.getValues());
|
|
6752
|
+
const [fromDiff, toDiff] = diffProperties(from, to, (_c = this.propertyEditorSelection) === null || _c === void 0 ? void 0 : _c.valueSet);
|
|
6592
6753
|
const currentAction = new UpdateValuesAction(this.canvas, previousSelectionId, fromDiff, toDiff);
|
|
6593
6754
|
currentAction.do();
|
|
6594
6755
|
this.canvas.actionStack.add(currentAction);
|
|
@@ -6622,7 +6783,7 @@ class DiagramCanvas {
|
|
|
6622
6783
|
var _a, _b;
|
|
6623
6784
|
this._connectionType = value;
|
|
6624
6785
|
// refresh the palette every time connectionType is set so that the palette keeps track of updates to the connectionType
|
|
6625
|
-
(_b = (_a = this.parentComponent) === null || _a ===
|
|
6786
|
+
(_b = (_a = this.parentComponent) === null || _a === void 0 ? void 0 : _a.palette) === null || _b === void 0 ? void 0 : _b.refreshPalette();
|
|
6626
6787
|
}
|
|
6627
6788
|
/**
|
|
6628
6789
|
* Constructs a canvas object.
|
|
@@ -6648,18 +6809,18 @@ class DiagramCanvas {
|
|
|
6648
6809
|
this.model = new DiagramModel(this, undefined, config.name || 'unnamed', '', config.type || '', config.properties || []);
|
|
6649
6810
|
this.userSelection = new DiagramUserSelection(this);
|
|
6650
6811
|
this.userHighlight = new DiagramUserHighlight(this);
|
|
6651
|
-
this.contextMenu = new DiagramContextMenu(this, (_a = config.canvas) === null || _a ===
|
|
6652
|
-
this.backgroundColor = ((_b = config.canvas) === null || _b ===
|
|
6653
|
-
this.gridStyle = (_e = (_d = (_c = config.canvas) === null || _c ===
|
|
6654
|
-
this.gridSize = ((_g = (_f = config.canvas) === null || _f ===
|
|
6655
|
-
this.gridThickness = Math.abs(((_m = (_l = config.canvas) === null || _l ===
|
|
6656
|
-
this.gridColor = ((_p = (_o = config.canvas) === null || _o ===
|
|
6657
|
-
this.snapToGrid = ((_r = (_q = config.canvas) === null || _q ===
|
|
6658
|
-
this.zoomFactor = ((_v = config.canvas) === null || _v ===
|
|
6659
|
-
this.panRate = ((_w = config.canvas) === null || _w ===
|
|
6812
|
+
this.contextMenu = new DiagramContextMenu(this, (_a = config.canvas) === null || _a === void 0 ? void 0 : _a.contextMenu);
|
|
6813
|
+
this.backgroundColor = ((_b = config.canvas) === null || _b === void 0 ? void 0 : _b.backgroundColor) || '#FFFFFF';
|
|
6814
|
+
this.gridStyle = (_e = (_d = (_c = config.canvas) === null || _c === void 0 ? void 0 : _c.grid) === null || _d === void 0 ? void 0 : _d.style) !== null && _e !== void 0 ? _e : GRID_DEFAULTS.style;
|
|
6815
|
+
this.gridSize = ((_g = (_f = config.canvas) === null || _f === void 0 ? void 0 : _f.grid) === null || _g === void 0 ? void 0 : _g.enabled) === false || ((_h = config.canvas) === null || _h === void 0 ? void 0 : _h.grid) === undefined ? 0 : Math.abs(((_k = (_j = config.canvas) === null || _j === void 0 ? void 0 : _j.grid) === null || _k === void 0 ? void 0 : _k.spacing) || GRID_DEFAULTS.spacing);
|
|
6816
|
+
this.gridThickness = Math.abs(((_m = (_l = config.canvas) === null || _l === void 0 ? void 0 : _l.grid) === null || _m === void 0 ? void 0 : _m.thickness) || GRID_DEFAULTS.thickness);
|
|
6817
|
+
this.gridColor = ((_p = (_o = config.canvas) === null || _o === void 0 ? void 0 : _o.grid) === null || _p === void 0 ? void 0 : _p.color) || GRID_DEFAULTS.color;
|
|
6818
|
+
this.snapToGrid = ((_r = (_q = config.canvas) === null || _q === void 0 ? void 0 : _q.grid) === null || _r === void 0 ? void 0 : _r.enabled) === false || ((_s = config.canvas) === null || _s === void 0 ? void 0 : _s.grid) === undefined ? false : ((_u = (_t = config.canvas) === null || _t === void 0 ? void 0 : _t.grid) === null || _u === void 0 ? void 0 : _u.snap) || GRID_DEFAULTS.snap;
|
|
6819
|
+
this.zoomFactor = ((_v = config.canvas) === null || _v === void 0 ? void 0 : _v.zoomFactor) || 2;
|
|
6820
|
+
this.panRate = ((_w = config.canvas) === null || _w === void 0 ? void 0 : _w.panRate) || 100;
|
|
6660
6821
|
this.inferConnectionType = config.inferConnectionType || false;
|
|
6661
6822
|
this.multipleSelectionOn = false;
|
|
6662
|
-
this.priorityThresholds = ((_x = config.canvas) === null || _x ===
|
|
6823
|
+
this.priorityThresholds = ((_x = config.canvas) === null || _x === void 0 ? void 0 : _x.priorityThresholds) || [];
|
|
6663
6824
|
this.priorityThreshold = this.priorityThresholds ? this.priorityThresholds[0] : undefined;
|
|
6664
6825
|
this.layoutFormat = config.layoutFormat;
|
|
6665
6826
|
this.userActions = config.userActions || {};
|
|
@@ -6710,7 +6871,7 @@ class DiagramCanvas {
|
|
|
6710
6871
|
for (const node of this.model.nodes) {
|
|
6711
6872
|
this.fitNodeInView(node.id);
|
|
6712
6873
|
}
|
|
6713
|
-
(_b = (_a = this.parentComponent) === null || _a ===
|
|
6874
|
+
(_b = (_a = this.parentComponent) === null || _a === void 0 ? void 0 : _a.palette) === null || _b === void 0 ? void 0 : _b.refreshPalette();
|
|
6714
6875
|
}
|
|
6715
6876
|
// View methods
|
|
6716
6877
|
initView(appendTo) {
|
|
@@ -6724,7 +6885,7 @@ class DiagramCanvas {
|
|
|
6724
6885
|
var _a;
|
|
6725
6886
|
// focus on the diagram when clicking so that we can focus on the diagram
|
|
6726
6887
|
// keyboard events only work if we're focusing on the diagram
|
|
6727
|
-
(_a = d3__namespace.select(this.diagramRoot).node()) === null || _a ===
|
|
6888
|
+
(_a = d3__namespace.select(this.diagramRoot).node()) === null || _a === void 0 ? void 0 : _a.focus();
|
|
6728
6889
|
}).on(exports.Events.ContextMenu, event => {
|
|
6729
6890
|
if (this.dragging) {
|
|
6730
6891
|
event.preventDefault();
|
|
@@ -6947,7 +7108,7 @@ class DiagramCanvas {
|
|
|
6947
7108
|
var _a;
|
|
6948
7109
|
// if there are no nodes, we have nothing to do here
|
|
6949
7110
|
if (this.model.nodes.length > 0) {
|
|
6950
|
-
const canvasViewBoundingBox = (_a = this.selectCanvasView().select('rect').node()) === null || _a ===
|
|
7111
|
+
const canvasViewBoundingBox = (_a = this.selectCanvasView().select('rect').node()) === null || _a === void 0 ? void 0 : _a.getBBox();
|
|
6951
7112
|
const nonRemovedNodes = this.model.nodes.all();
|
|
6952
7113
|
const minimumX = Math.min(...nonRemovedNodes.map(n => n.coords[0]));
|
|
6953
7114
|
const maximumX = Math.max(...nonRemovedNodes.map(n => n.coords[0] + n.width));
|
|
@@ -6979,8 +7140,8 @@ class DiagramCanvas {
|
|
|
6979
7140
|
}
|
|
6980
7141
|
getCoordinatesOnScreen() {
|
|
6981
7142
|
var _a;
|
|
6982
|
-
const rootBoundingClientRect = (_a = this.selectSVGElement().node()) === null || _a ===
|
|
6983
|
-
const rootDimensions = [(rootBoundingClientRect === null || rootBoundingClientRect ===
|
|
7143
|
+
const rootBoundingClientRect = (_a = this.selectSVGElement().node()) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
7144
|
+
const rootDimensions = [(rootBoundingClientRect === null || rootBoundingClientRect === void 0 ? void 0 : rootBoundingClientRect.width) || 0, (rootBoundingClientRect === null || rootBoundingClientRect === void 0 ? void 0 : rootBoundingClientRect.height) || 0];
|
|
6984
7145
|
return [[-this.zoomTransform.x / this.zoomTransform.k, -this.zoomTransform.y / this.zoomTransform.k], [(rootDimensions[0] - this.zoomTransform.x) / this.zoomTransform.k, (rootDimensions[1] - this.zoomTransform.y) / this.zoomTransform.k]];
|
|
6985
7146
|
}
|
|
6986
7147
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -7235,7 +7396,7 @@ class DiagramCanvas {
|
|
|
7235
7396
|
const exitSelection = updateSelection.exit();
|
|
7236
7397
|
const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', d => {
|
|
7237
7398
|
var _a, _b, _c, _d, _e;
|
|
7238
|
-
return `diagram-section${((_b = (_a = d.node) === null || _a ===
|
|
7399
|
+
return `diagram-section${((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) ? ' resizable-x' : ''}${((_d = (_c = d.node) === null || _c === void 0 ? void 0 : _c.type) === null || _d === void 0 ? void 0 : _d.resizableY) ? ' resizable-y' : ''} ${(_e = d.look) === null || _e === void 0 ? void 0 : _e.lookType}`;
|
|
7239
7400
|
});
|
|
7240
7401
|
if (ids && ids.length > 0) {
|
|
7241
7402
|
updateSelection = updateSelection.filter(d => ids.includes(d.id));
|
|
@@ -7284,7 +7445,7 @@ class DiagramCanvas {
|
|
|
7284
7445
|
if (this.multipleSelectionOn || this.secondaryButton) {
|
|
7285
7446
|
this.startMultipleSelection(event);
|
|
7286
7447
|
} else {
|
|
7287
|
-
const node = d === null || d ===
|
|
7448
|
+
const node = d === null || d === void 0 ? void 0 : d.node;
|
|
7288
7449
|
if (node) {
|
|
7289
7450
|
this.startMovingNode(event, node);
|
|
7290
7451
|
} else {
|
|
@@ -7295,7 +7456,7 @@ class DiagramCanvas {
|
|
|
7295
7456
|
if (this.multipleSelectionOn || this.secondaryButton) {
|
|
7296
7457
|
this.continueMultipleSelection(event);
|
|
7297
7458
|
} else {
|
|
7298
|
-
const node = d === null || d ===
|
|
7459
|
+
const node = d === null || d === void 0 ? void 0 : d.node;
|
|
7299
7460
|
if (node) {
|
|
7300
7461
|
this.continueMovingNode(event, node);
|
|
7301
7462
|
} else {
|
|
@@ -7306,7 +7467,7 @@ class DiagramCanvas {
|
|
|
7306
7467
|
if (this.multipleSelectionOn || this.secondaryButton) {
|
|
7307
7468
|
this.finishMultipleSelection(event);
|
|
7308
7469
|
} else {
|
|
7309
|
-
const node = d === null || d ===
|
|
7470
|
+
const node = d === null || d === void 0 ? void 0 : d.node;
|
|
7310
7471
|
if (node) {
|
|
7311
7472
|
this.finishMovingNode(event, node);
|
|
7312
7473
|
} else {
|
|
@@ -7318,17 +7479,17 @@ class DiagramCanvas {
|
|
|
7318
7479
|
initializeLook(enterSelection);
|
|
7319
7480
|
enterSelection.filter('.resizable-x').append('line').attr('class', 'left-resizer').attr('stroke', 'transparent').attr('stroke-width', `${RESIZER_THICKNESS}px`).on(exports.Events.MouseOver, (_event, d) => {
|
|
7320
7481
|
var _a, _b;
|
|
7321
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
7482
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed) {
|
|
7322
7483
|
setCursorStyle(exports.CursorStyle.EWResize);
|
|
7323
7484
|
}
|
|
7324
7485
|
}).on(exports.Events.MouseOut, (_event, d) => {
|
|
7325
7486
|
var _a, _b;
|
|
7326
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
7487
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed) {
|
|
7327
7488
|
setCursorStyle();
|
|
7328
7489
|
}
|
|
7329
7490
|
}).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
|
|
7330
7491
|
var _a, _b;
|
|
7331
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
7492
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed) {
|
|
7332
7493
|
setCursorStyle(exports.CursorStyle.EWResize);
|
|
7333
7494
|
this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
|
|
7334
7495
|
} else {
|
|
@@ -7336,13 +7497,13 @@ class DiagramCanvas {
|
|
|
7336
7497
|
}
|
|
7337
7498
|
}).on(exports.DragEvents.Drag, (event, d) => {
|
|
7338
7499
|
var _a, _b;
|
|
7339
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
7500
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed) {
|
|
7340
7501
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7341
7502
|
d.node.stretchSections(exports.Side.Left, d.coords[0] - pointerCoords[0], d.indexXInNode, d.indexYInNode);
|
|
7342
7503
|
}
|
|
7343
7504
|
}).on(exports.DragEvents.End, (event, d) => {
|
|
7344
7505
|
var _a, _b;
|
|
7345
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
7506
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection) {
|
|
7346
7507
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7347
7508
|
if (this.snapToGrid) {
|
|
7348
7509
|
pointerCoords = this.getClosestGridPoint(pointerCoords);
|
|
@@ -7357,17 +7518,17 @@ class DiagramCanvas {
|
|
|
7357
7518
|
}));
|
|
7358
7519
|
enterSelection.filter('.resizable-y').append('line').attr('class', 'top-resizer').attr('stroke', 'transparent').attr('stroke-width', `${RESIZER_THICKNESS}px`).on(exports.Events.MouseOver, (_event, d) => {
|
|
7359
7520
|
var _a, _b;
|
|
7360
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
7521
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed) {
|
|
7361
7522
|
setCursorStyle(exports.CursorStyle.NSResize);
|
|
7362
7523
|
}
|
|
7363
7524
|
}).on(exports.Events.MouseOut, (_event, d) => {
|
|
7364
7525
|
var _a, _b;
|
|
7365
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
7526
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed) {
|
|
7366
7527
|
setCursorStyle();
|
|
7367
7528
|
}
|
|
7368
7529
|
}).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
|
|
7369
7530
|
var _a, _b;
|
|
7370
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
7531
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed) {
|
|
7371
7532
|
setCursorStyle(exports.CursorStyle.NSResize);
|
|
7372
7533
|
this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
|
|
7373
7534
|
} else {
|
|
@@ -7375,13 +7536,13 @@ class DiagramCanvas {
|
|
|
7375
7536
|
}
|
|
7376
7537
|
}).on(exports.DragEvents.Drag, (event, d) => {
|
|
7377
7538
|
var _a, _b;
|
|
7378
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
7539
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed) {
|
|
7379
7540
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7380
7541
|
d.node.stretchSections(exports.Side.Top, d.coords[1] - pointerCoords[1], d.indexXInNode, d.indexYInNode);
|
|
7381
7542
|
}
|
|
7382
7543
|
}).on(exports.DragEvents.End, (event, d) => {
|
|
7383
7544
|
var _a, _b;
|
|
7384
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
7545
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection) {
|
|
7385
7546
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7386
7547
|
if (this.snapToGrid) {
|
|
7387
7548
|
pointerCoords = this.getClosestGridPoint(pointerCoords);
|
|
@@ -7396,17 +7557,17 @@ class DiagramCanvas {
|
|
|
7396
7557
|
}));
|
|
7397
7558
|
enterSelection.filter('.resizable-x').append('line').attr('class', 'right-resizer').attr('stroke', 'transparent').attr('stroke-width', `${RESIZER_THICKNESS}px`).on(exports.Events.MouseOver, (_event, d) => {
|
|
7398
7559
|
var _a, _b;
|
|
7399
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
7560
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed) {
|
|
7400
7561
|
setCursorStyle(exports.CursorStyle.EWResize);
|
|
7401
7562
|
}
|
|
7402
7563
|
}).on(exports.Events.MouseOut, (_event, d) => {
|
|
7403
7564
|
var _a, _b;
|
|
7404
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
7565
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed) {
|
|
7405
7566
|
setCursorStyle();
|
|
7406
7567
|
}
|
|
7407
7568
|
}).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
|
|
7408
7569
|
var _a, _b;
|
|
7409
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
7570
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed) {
|
|
7410
7571
|
setCursorStyle(exports.CursorStyle.EWResize);
|
|
7411
7572
|
this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
|
|
7412
7573
|
} else {
|
|
@@ -7414,13 +7575,13 @@ class DiagramCanvas {
|
|
|
7414
7575
|
}
|
|
7415
7576
|
}).on(exports.DragEvents.Drag, (event, d) => {
|
|
7416
7577
|
var _a, _b;
|
|
7417
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
7578
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed) {
|
|
7418
7579
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7419
7580
|
d.node.stretchSections(exports.Side.Right, pointerCoords[0] - (d.coords[0] + d.width), d.indexXInNode, d.indexYInNode);
|
|
7420
7581
|
}
|
|
7421
7582
|
}).on(exports.DragEvents.End, (event, d) => {
|
|
7422
7583
|
var _a, _b;
|
|
7423
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
7584
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection) {
|
|
7424
7585
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7425
7586
|
if (this.snapToGrid) {
|
|
7426
7587
|
pointerCoords = this.getClosestGridPoint(pointerCoords);
|
|
@@ -7435,17 +7596,17 @@ class DiagramCanvas {
|
|
|
7435
7596
|
}));
|
|
7436
7597
|
enterSelection.filter('.resizable-y').append('line').attr('class', 'bottom-resizer').attr('stroke', 'transparent').attr('stroke-width', `${RESIZER_THICKNESS}px`).on(exports.Events.MouseOver, (_event, d) => {
|
|
7437
7598
|
var _a, _b;
|
|
7438
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
7599
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed) {
|
|
7439
7600
|
setCursorStyle(exports.CursorStyle.NSResize);
|
|
7440
7601
|
}
|
|
7441
7602
|
}).on(exports.Events.MouseOut, (_event, d) => {
|
|
7442
7603
|
var _a, _b;
|
|
7443
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
7604
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed) {
|
|
7444
7605
|
setCursorStyle();
|
|
7445
7606
|
}
|
|
7446
7607
|
}).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
|
|
7447
7608
|
var _a, _b;
|
|
7448
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
7609
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed) {
|
|
7449
7610
|
setCursorStyle(exports.CursorStyle.NSResize);
|
|
7450
7611
|
this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
|
|
7451
7612
|
} else {
|
|
@@ -7453,13 +7614,13 @@ class DiagramCanvas {
|
|
|
7453
7614
|
}
|
|
7454
7615
|
}).on(exports.DragEvents.Drag, (event, d) => {
|
|
7455
7616
|
var _a, _b;
|
|
7456
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
7617
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed) {
|
|
7457
7618
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7458
7619
|
d.node.stretchSections(exports.Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height), d.indexXInNode, d.indexYInNode);
|
|
7459
7620
|
}
|
|
7460
7621
|
}).on(exports.DragEvents.End, (event, d) => {
|
|
7461
7622
|
var _a, _b;
|
|
7462
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
7623
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection) {
|
|
7463
7624
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7464
7625
|
if (this.snapToGrid) {
|
|
7465
7626
|
pointerCoords = this.getClosestGridPoint(pointerCoords);
|
|
@@ -7498,13 +7659,13 @@ class DiagramCanvas {
|
|
|
7498
7659
|
if (this.unfinishedConnection) {
|
|
7499
7660
|
const canConnectionFinishAtThisPort =
|
|
7500
7661
|
// can start at the starting port
|
|
7501
|
-
this.unfinishedConnection.type.canStartFromType(((_c = (_b = (_a = this.unfinishedConnection.start) === null || _a ===
|
|
7662
|
+
this.unfinishedConnection.type.canStartFromType(((_c = (_b = (_a = this.unfinishedConnection.start) === null || _a === void 0 ? void 0 : _a.getNode()) === null || _b === void 0 ? void 0 : _b.type) === null || _c === void 0 ? void 0 : _c.id) || '') && ((_d = this.unfinishedConnection.start) === null || _d === void 0 ? void 0 : _d.allowsOutgoing) &&
|
|
7502
7663
|
// can end at the ending port
|
|
7503
|
-
this.unfinishedConnection.type.canFinishOnType(((_f = (_e = d.getNode()) === null || _e ===
|
|
7664
|
+
this.unfinishedConnection.type.canFinishOnType(((_f = (_e = d.getNode()) === null || _e === void 0 ? void 0 : _e.type) === null || _f === void 0 ? void 0 : _f.id) || '') && d.allowsIncoming ||
|
|
7504
7665
|
// can start at the ending port
|
|
7505
|
-
this.unfinishedConnection.type.canStartFromType(((_h = (_g = d.getNode()) === null || _g ===
|
|
7666
|
+
this.unfinishedConnection.type.canStartFromType(((_h = (_g = d.getNode()) === null || _g === void 0 ? void 0 : _g.type) === null || _h === void 0 ? void 0 : _h.id) || '') && d.allowsOutgoing &&
|
|
7506
7667
|
// can end at the starting port
|
|
7507
|
-
this.unfinishedConnection.type.canFinishOnType(((_l = (_k = (_j = this.unfinishedConnection.start) === null || _j ===
|
|
7668
|
+
this.unfinishedConnection.type.canFinishOnType(((_l = (_k = (_j = this.unfinishedConnection.start) === null || _j === void 0 ? void 0 : _j.getNode()) === null || _k === void 0 ? void 0 : _k.type) === null || _l === void 0 ? void 0 : _l.id) || '') && ((_m = this.unfinishedConnection.start) === null || _m === void 0 ? void 0 : _m.allowsIncoming);
|
|
7508
7669
|
if (!canConnectionFinishAtThisPort) {
|
|
7509
7670
|
setCursorStyle(exports.CursorStyle.NoDrop);
|
|
7510
7671
|
}
|
|
@@ -7569,8 +7730,8 @@ class DiagramCanvas {
|
|
|
7569
7730
|
if (this.canUserPerformAction(exports.DiagramActions.AddConnection) && !d.removed) {
|
|
7570
7731
|
if (this.unfinishedConnection !== undefined) {
|
|
7571
7732
|
const endCoords = [event.x, event.y];
|
|
7572
|
-
(_a = this.unfinishedConnectionTracer) === null || _a ===
|
|
7573
|
-
const unfinishedConnectionGhostNode = (_d = this.unfinishedConnectionTracer) === null || _d ===
|
|
7733
|
+
(_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));
|
|
7734
|
+
const unfinishedConnectionGhostNode = (_d = this.unfinishedConnectionTracer) === null || _d === void 0 ? void 0 : _d.node();
|
|
7574
7735
|
if (unfinishedConnectionGhostNode) {
|
|
7575
7736
|
let margin = 2;
|
|
7576
7737
|
const unfinishedConnectionTotalLength = unfinishedConnectionGhostNode.getTotalLength();
|
|
@@ -7611,7 +7772,7 @@ class DiagramCanvas {
|
|
|
7611
7772
|
this.finishMultipleSelection(event);
|
|
7612
7773
|
} else {
|
|
7613
7774
|
if (this.canUserPerformAction(exports.DiagramActions.AddConnection) && !d.removed) {
|
|
7614
|
-
(_a = this.unfinishedConnectionTracer) === null || _a ===
|
|
7775
|
+
(_a = this.unfinishedConnectionTracer) === null || _a === void 0 ? void 0 : _a.remove();
|
|
7615
7776
|
const userHighlight = this.userHighlight.getFocus();
|
|
7616
7777
|
if (userHighlight instanceof DiagramPort) {
|
|
7617
7778
|
this.finishConnection(userHighlight);
|
|
@@ -7717,11 +7878,11 @@ class DiagramCanvas {
|
|
|
7717
7878
|
enterSelection.select('g.diagram-connection-end-label').append('text').style('user-select', 'none');
|
|
7718
7879
|
mergeSelection.attr('opacity', d => d.removed ? 0.5 : 1).select('path.diagram-connection-path').attr('d', d => {
|
|
7719
7880
|
var _a, _b;
|
|
7720
|
-
return getConnectionPath(d.look.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.look.thickness, (_a = d.startMarkerLook) === null || _a ===
|
|
7881
|
+
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);
|
|
7721
7882
|
}).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');
|
|
7722
7883
|
mergeSelection.select('path.diagram-connection-path-box').attr('d', d => {
|
|
7723
7884
|
var _a, _b;
|
|
7724
|
-
return getConnectionPath(d.look.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.look.thickness, (_a = d.startMarkerLook) === null || _a ===
|
|
7885
|
+
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);
|
|
7725
7886
|
}).attr('stroke', 'transparent')
|
|
7726
7887
|
// allow generating pointer events even when it is transparent
|
|
7727
7888
|
.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');
|
|
@@ -7776,8 +7937,12 @@ class DiagramCanvas {
|
|
|
7776
7937
|
this.diagramEvent$.next(diagramEvent);
|
|
7777
7938
|
if (!diagramEvent.defaultPrevented && this.canUserPerformAction(exports.DiagramActions.EditField) && d.editable && !d.removed) {
|
|
7778
7939
|
this.currentAction = new EditFieldAction(this, d.id, d.text, '');
|
|
7779
|
-
this.createInputField(d.text, d.coords, d.width, d.height, d.fontSize, d.fontFamily || DIAGRAM_FIELD_DEFAULTS.fontFamily, text => {
|
|
7780
|
-
|
|
7940
|
+
this.createInputField(d.text, d.coords, d.width, d.height, d.fontSize, d.fontFamily || DIAGRAM_FIELD_DEFAULTS.fontFamily, d.orientation, text => {
|
|
7941
|
+
/*
|
|
7942
|
+
Empty for now
|
|
7943
|
+
We should create a better function to stretch the root element as the text expands
|
|
7944
|
+
Bear in mind that DiagramNode.setGeometry() calls DiagramNode.raise(), which breaks the input field
|
|
7945
|
+
*/
|
|
7781
7946
|
}, text => {
|
|
7782
7947
|
d.text = text;
|
|
7783
7948
|
if (this.currentAction instanceof EditFieldAction) {
|
|
@@ -7841,7 +8006,24 @@ class DiagramCanvas {
|
|
|
7841
8006
|
}
|
|
7842
8007
|
this.secondaryButton = false;
|
|
7843
8008
|
})).append('xhtml:div').style('width', '100%').style('height', '100%').style('display', 'flex').append('xhtml:p').style('box-sizing', 'border-box').style('outline', 0).style('margin', 0).style('border', 0).style('padding', 0).style('user-select', 'none').style('font-kerning', 'none').style('white-space', 'nowrap');
|
|
7844
|
-
mergeSelection.attr('x', 0).attr('y', 0).attr('width', d => `${d.width}px`).attr('height', d => `${d.height}px`).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).attr('opacity', d => d.removed ? 0.5 : 1).select('div').style('justify-content', d => d.horizontalAlign === exports.HorizontalAlign.Center ? 'center' : d.horizontalAlign === exports.HorizontalAlign.Right ? 'flex-end' : 'flex-start').style('align-items', d => d.verticalAlign === exports.VerticalAlign.Center ? 'center' : d.verticalAlign === exports.VerticalAlign.Bottom ? 'end' : 'start').select('p').style('max-width', d => d.fit ? 'default' : '100%').style('max-height', d => d.fit ? 'default' : '100%').style('overflow', d => d.fit ? 'default' : 'hidden').style('text-overflow', d => d.fit ? 'default' : 'ellipsis').style('text-align', d => d.horizontalAlign === exports.HorizontalAlign.Center ? 'center' : d.horizontalAlign === exports.HorizontalAlign.Right ? 'end' : 'start').style('
|
|
8009
|
+
mergeSelection.attr('x', 0).attr('y', 0).attr('width', d => `${d.width}px`).attr('height', d => `${d.height}px`).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).attr('opacity', d => d.removed ? 0.5 : 1).select('div').style('justify-content', d => d.horizontalAlign === exports.HorizontalAlign.Center ? 'center' : d.horizontalAlign === exports.HorizontalAlign.Right ? 'flex-end' : 'flex-start').style('align-items', d => d.verticalAlign === exports.VerticalAlign.Center ? 'center' : d.verticalAlign === exports.VerticalAlign.Bottom ? 'end' : 'start').select('p').style('max-width', d => d.fit ? 'default' : '100%').style('max-height', d => d.fit ? 'default' : '100%').style('overflow', d => d.fit ? 'default' : 'hidden').style('text-overflow', d => d.fit ? 'default' : 'ellipsis').style('text-align', d => d.horizontalAlign === exports.HorizontalAlign.Center ? 'center' : d.horizontalAlign === exports.HorizontalAlign.Right ? 'end' : 'start').style('transform', d => {
|
|
8010
|
+
if (!isNaN(Number(d.orientation))) {
|
|
8011
|
+
return `rotate(${d.orientation}deg)`;
|
|
8012
|
+
} else {
|
|
8013
|
+
switch (d.orientation) {
|
|
8014
|
+
case exports.Side.Top:
|
|
8015
|
+
return 'rotate(0deg)';
|
|
8016
|
+
case exports.Side.Right:
|
|
8017
|
+
return 'rotate(90deg)';
|
|
8018
|
+
case exports.Side.Bottom:
|
|
8019
|
+
return 'rotate(180deg)';
|
|
8020
|
+
case exports.Side.Left:
|
|
8021
|
+
return 'rotate(270deg)';
|
|
8022
|
+
default:
|
|
8023
|
+
return 'rotate(0deg)';
|
|
8024
|
+
}
|
|
8025
|
+
}
|
|
8026
|
+
}).style('font-size', d => `${d.fontSize}px`).style('font-family', d => d.fontFamily || "'Wonder Unit Sans', sans-serif").style('font-weight', d => d.highlighted ? 600 : 400).style('color', d => d.selected ? d.selectedColor || '#000000' : d.color || '#000000').html(d => d.text.replace(/</g, '<').replace(/>/g, '>').replace(/\n/g, '<br/>'));
|
|
7845
8027
|
}
|
|
7846
8028
|
updateObjectsInView(...ids) {
|
|
7847
8029
|
let updateSelection = this.selectCanvasElements().selectAll('foreignObject.diagram-object').data(this.model.objects.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
|
|
@@ -7991,7 +8173,7 @@ class DiagramCanvas {
|
|
|
7991
8173
|
}
|
|
7992
8174
|
updateConnectionLabelsInView(connection) {
|
|
7993
8175
|
var _a, _b, _c;
|
|
7994
|
-
const connectionSelection = this.selectCanvasView().select(`
|
|
8176
|
+
const connectionSelection = this.selectCanvasView().select(`[id='${escapeSelector(connection.id)}']`);
|
|
7995
8177
|
const pathSelection = connectionSelection.select('path');
|
|
7996
8178
|
const pathNode = pathSelection.node();
|
|
7997
8179
|
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), connection.type.label);
|
|
@@ -7999,7 +8181,7 @@ class DiagramCanvas {
|
|
|
7999
8181
|
const pathLength = pathNode.getTotalLength();
|
|
8000
8182
|
// bind start labels
|
|
8001
8183
|
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);
|
|
8002
|
-
const startLabelBoundingRect = (_a = connectionSelection.select('g.diagram-connection-start-label text').node()) === null || _a ===
|
|
8184
|
+
const startLabelBoundingRect = (_a = connectionSelection.select('g.diagram-connection-start-label text').node()) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
8003
8185
|
if (startLabelBoundingRect) {
|
|
8004
8186
|
// don't create space for the label if the label is empty
|
|
8005
8187
|
const boundingWidth = !connection.startLabel ? 0 : startLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
|
|
@@ -8010,7 +8192,7 @@ class DiagramCanvas {
|
|
|
8010
8192
|
}
|
|
8011
8193
|
// bind middle labels
|
|
8012
8194
|
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);
|
|
8013
|
-
const middleLabelBoundingRect = (_b = connectionSelection.select('g.diagram-connection-middle-label text').node()) === null || _b ===
|
|
8195
|
+
const middleLabelBoundingRect = (_b = connectionSelection.select('g.diagram-connection-middle-label text').node()) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect();
|
|
8014
8196
|
if (middleLabelBoundingRect) {
|
|
8015
8197
|
// don't create space for the label if the label is empty
|
|
8016
8198
|
const boundingWidth = !connection.middleLabel ? 0 : middleLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
|
|
@@ -8021,7 +8203,7 @@ class DiagramCanvas {
|
|
|
8021
8203
|
}
|
|
8022
8204
|
// bind end labels
|
|
8023
8205
|
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);
|
|
8024
|
-
const endLabelBoundingRect = (_c = connectionSelection.select('g.diagram-connection-end-label text').node()) === null || _c ===
|
|
8206
|
+
const endLabelBoundingRect = (_c = connectionSelection.select('g.diagram-connection-end-label text').node()) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect();
|
|
8025
8207
|
if (endLabelBoundingRect) {
|
|
8026
8208
|
// don't create space for the label if the label is empty
|
|
8027
8209
|
const boundingWidth = !connection.endLabel ? 0 : endLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
|
|
@@ -8033,7 +8215,7 @@ class DiagramCanvas {
|
|
|
8033
8215
|
}
|
|
8034
8216
|
}
|
|
8035
8217
|
updateConnectionMarkersInView(connection) {
|
|
8036
|
-
const connectionSelection = this.selectCanvasView().select(`
|
|
8218
|
+
const connectionSelection = this.selectCanvasView().select(`[id='${escapeSelector(connection.id)}']`);
|
|
8037
8219
|
const startMarkerSelection = connectionSelection.select('marker.diagram-connection-start-marker');
|
|
8038
8220
|
const endMarkerSelection = connectionSelection.select('marker.diagram-connection-end-marker');
|
|
8039
8221
|
if (connection.startMarkerLook !== null) {
|
|
@@ -8047,13 +8229,27 @@ class DiagramCanvas {
|
|
|
8047
8229
|
endMarkerSelection.attr('orient', 'auto-start-reverse').attr('markerWidth', 0).attr('markerHeight', 0);
|
|
8048
8230
|
}
|
|
8049
8231
|
}
|
|
8050
|
-
|
|
8232
|
+
fieldRootFitsInView(id) {
|
|
8233
|
+
var _a, _b, _c, _d;
|
|
8234
|
+
const field = this.model.fields.get(id);
|
|
8235
|
+
if (!field) {
|
|
8236
|
+
return false;
|
|
8237
|
+
}
|
|
8238
|
+
if (field.rootElement instanceof DiagramNode || field.rootElement instanceof DiagramSection) {
|
|
8239
|
+
const fieldDimensions = this.minimumSizeOfField(field);
|
|
8240
|
+
const stretchX = fieldDimensions[0] + getLeftMargin((_a = field.rootElement.type) === null || _a === void 0 ? void 0 : _a.label) + getRightMargin((_b = field.rootElement.type) === null || _b === void 0 ? void 0 : _b.label) - field.rootElement.width;
|
|
8241
|
+
const stretchY = fieldDimensions[1] + getTopMargin((_c = field.rootElement.type) === null || _c === void 0 ? void 0 : _c.label) + getBottomMargin((_d = field.rootElement.type) === null || _d === void 0 ? void 0 : _d.label) - field.rootElement.height;
|
|
8242
|
+
return stretchX <= 0 && stretchY <= 0;
|
|
8243
|
+
}
|
|
8244
|
+
return true;
|
|
8245
|
+
}
|
|
8246
|
+
fitFieldRootInView(id, shrink) {
|
|
8051
8247
|
var _a, _b, _c;
|
|
8052
8248
|
const field = this.model.fields.get(id);
|
|
8053
8249
|
if (!field) {
|
|
8054
8250
|
return;
|
|
8055
8251
|
}
|
|
8056
|
-
if (field.rootElement instanceof DiagramNode
|
|
8252
|
+
if (field.rootElement instanceof DiagramNode) {
|
|
8057
8253
|
const fieldDimensions = this.minimumSizeOfField(field);
|
|
8058
8254
|
let stretchX = fieldDimensions[0] + getLeftMargin(field.rootElement.type.label) + getRightMargin(field.rootElement.type.label) - field.rootElement.width;
|
|
8059
8255
|
let stretchY = fieldDimensions[1] + getTopMargin(field.rootElement.type.label) + getBottomMargin(field.rootElement.type.label) - field.rootElement.height;
|
|
@@ -8068,14 +8264,18 @@ class DiagramCanvas {
|
|
|
8068
8264
|
if (field.rootElement.height + stretchY < field.rootElement.type.minHeight) {
|
|
8069
8265
|
stretchY = field.rootElement.type.minHeight - field.rootElement.height;
|
|
8070
8266
|
}
|
|
8071
|
-
|
|
8072
|
-
|
|
8267
|
+
if (shrink !== false || stretchX > 0) {
|
|
8268
|
+
field.rootElement.stretch(exports.Side.Right, stretchX);
|
|
8269
|
+
}
|
|
8270
|
+
if (shrink !== false || stretchY > 0) {
|
|
8271
|
+
field.rootElement.stretch(exports.Side.Bottom, stretchY);
|
|
8272
|
+
}
|
|
8073
8273
|
}
|
|
8074
|
-
if (field.rootElement instanceof DiagramSection
|
|
8274
|
+
if (field.rootElement instanceof DiagramSection) {
|
|
8075
8275
|
const fieldDimensions = this.minimumSizeOfField(field);
|
|
8076
8276
|
let minimumFieldWidth = fieldDimensions[0];
|
|
8077
8277
|
let minimumFieldHeight = fieldDimensions[1];
|
|
8078
|
-
for (const section of ((_a = field.rootElement.node) === null || _a ===
|
|
8278
|
+
for (const section of ((_a = field.rootElement.node) === null || _a === void 0 ? void 0 : _a.sections) || []) {
|
|
8079
8279
|
if (section.label) {
|
|
8080
8280
|
if (section.indexXInNode === field.rootElement.indexXInNode && section.indexYInNode !== field.rootElement.indexYInNode) {
|
|
8081
8281
|
minimumFieldWidth = Math.max(minimumFieldWidth, this.minimumSizeOfField(section.label)[0]);
|
|
@@ -8091,8 +8291,8 @@ class DiagramCanvas {
|
|
|
8091
8291
|
fieldDimensions[1] = minimumFieldHeight;
|
|
8092
8292
|
}
|
|
8093
8293
|
const type = field.rootElement.type;
|
|
8094
|
-
let stretchX = fieldDimensions[0] + getLeftMargin(type === null || type ===
|
|
8095
|
-
let stretchY = fieldDimensions[1] + getTopMargin(type === null || type ===
|
|
8294
|
+
let stretchX = fieldDimensions[0] + getLeftMargin(type === null || type === void 0 ? void 0 : type.label) + getRightMargin(type === null || type === void 0 ? void 0 : type.label) - field.rootElement.width;
|
|
8295
|
+
let stretchY = fieldDimensions[1] + getTopMargin(type === null || type === void 0 ? void 0 : type.label) + getBottomMargin(type === null || type === void 0 ? void 0 : type.label) - field.rootElement.height;
|
|
8096
8296
|
if (this.snapToGrid) {
|
|
8097
8297
|
stretchX = Math.ceil(stretchX / this.gridSize) * this.gridSize;
|
|
8098
8298
|
stretchY = Math.ceil(stretchY / this.gridSize) * this.gridSize;
|
|
@@ -8104,8 +8304,12 @@ class DiagramCanvas {
|
|
|
8104
8304
|
if (field.rootElement.height + stretchY < (field.rootElement.getMinHeight() || 0)) {
|
|
8105
8305
|
stretchY = (field.rootElement.getMinHeight() || 0) - field.rootElement.height;
|
|
8106
8306
|
}
|
|
8107
|
-
(
|
|
8108
|
-
|
|
8307
|
+
if (shrink !== false || stretchX > 0) {
|
|
8308
|
+
(_b = field.rootElement.node) === null || _b === void 0 ? void 0 : _b.stretchSections(exports.Side.Right, stretchX, field.rootElement.indexXInNode, field.rootElement.indexYInNode);
|
|
8309
|
+
}
|
|
8310
|
+
if (shrink !== false || stretchY > 0) {
|
|
8311
|
+
(_c = field.rootElement.node) === null || _c === void 0 ? void 0 : _c.stretchSections(exports.Side.Bottom, stretchY, field.rootElement.indexXInNode, field.rootElement.indexYInNode);
|
|
8312
|
+
}
|
|
8109
8313
|
}
|
|
8110
8314
|
}
|
|
8111
8315
|
fitNodeInView(id) {
|
|
@@ -8127,8 +8331,8 @@ class DiagramCanvas {
|
|
|
8127
8331
|
}
|
|
8128
8332
|
}
|
|
8129
8333
|
// add the margin that goes between the rightmost and bottommost points of the sections and the edge of the node
|
|
8130
|
-
newNodeWidth += ((_a = node.type.sectionGrid) === null || _a ===
|
|
8131
|
-
newNodeHeight += ((_b = node.type.sectionGrid) === null || _b ===
|
|
8334
|
+
newNodeWidth += ((_a = node.type.sectionGrid) === null || _a === void 0 ? void 0 : _a.margin) || 0;
|
|
8335
|
+
newNodeHeight += ((_b = node.type.sectionGrid) === null || _b === void 0 ? void 0 : _b.margin) || 0;
|
|
8132
8336
|
node.stretch(exports.Side.Right, newNodeWidth - node.width);
|
|
8133
8337
|
node.stretch(exports.Side.Bottom, newNodeHeight - node.height);
|
|
8134
8338
|
}
|
|
@@ -8149,18 +8353,18 @@ class DiagramCanvas {
|
|
|
8149
8353
|
startConnection(port) {
|
|
8150
8354
|
var _a, _b, _c, _d;
|
|
8151
8355
|
if (port.allowsOutgoing || port.allowsIncoming) {
|
|
8152
|
-
if (this.connectionType && (this.connectionType.canStartFromType(((_b = (_a = port.getNode()) === null || _a ===
|
|
8356
|
+
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)) {
|
|
8153
8357
|
this.unfinishedConnection = new DiagramConnection(this.model, this.connectionType, port, undefined, UNFINISHED_CONNECTION_ID);
|
|
8154
8358
|
} else {
|
|
8155
8359
|
if (this.inferConnectionType) {
|
|
8156
8360
|
let differentConnectionType = this.model.connections.types.all().find(t => {
|
|
8157
8361
|
var _a, _b;
|
|
8158
|
-
return port.allowsOutgoing && t.canStartFromType(((_b = (_a = port.getNode()) === null || _a ===
|
|
8362
|
+
return port.allowsOutgoing && t.canStartFromType(((_b = (_a = port.getNode()) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.id) || '');
|
|
8159
8363
|
});
|
|
8160
8364
|
if (differentConnectionType === undefined) {
|
|
8161
8365
|
differentConnectionType = this.model.connections.types.all().find(t => {
|
|
8162
8366
|
var _a, _b;
|
|
8163
|
-
return port.allowsIncoming && t.canFinishOnType(((_b = (_a = port.getNode()) === null || _a ===
|
|
8367
|
+
return port.allowsIncoming && t.canFinishOnType(((_b = (_a = port.getNode()) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.id) || '');
|
|
8164
8368
|
});
|
|
8165
8369
|
}
|
|
8166
8370
|
if (differentConnectionType !== undefined) {
|
|
@@ -8175,14 +8379,14 @@ class DiagramCanvas {
|
|
|
8175
8379
|
this.userHighlight.clear();
|
|
8176
8380
|
if (this.unfinishedConnection !== undefined) {
|
|
8177
8381
|
if (this.unfinishedConnection.start !== port) {
|
|
8178
|
-
if (this.unfinishedConnection.type.canStartFromType(((_d = (_c = (_b = (_a = this.unfinishedConnection) === null || _a ===
|
|
8179
|
-
const addConnectionAction = new AddConnectionAction(this, this.unfinishedConnection.type, (_j = this.unfinishedConnection.start) === null || _j ===
|
|
8382
|
+
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) {
|
|
8383
|
+
const addConnectionAction = new AddConnectionAction(this, this.unfinishedConnection.type, (_j = this.unfinishedConnection.start) === null || _j === void 0 ? void 0 : _j.id, port.id);
|
|
8180
8384
|
// clean up the previous unfinished connection
|
|
8181
8385
|
this.dropConnection();
|
|
8182
8386
|
addConnectionAction.do();
|
|
8183
8387
|
this.actionStack.add(addConnectionAction);
|
|
8184
|
-
} else if (this.unfinishedConnection.type.canFinishOnType(((_o = (_m = (_l = (_k = this.unfinishedConnection) === null || _k ===
|
|
8185
|
-
const addConnectionAction = new AddConnectionAction(this, this.unfinishedConnection.type, port.id, (_t = this.unfinishedConnection.start) === null || _t ===
|
|
8388
|
+
} 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) {
|
|
8389
|
+
const addConnectionAction = new AddConnectionAction(this, this.unfinishedConnection.type, port.id, (_t = this.unfinishedConnection.start) === null || _t === void 0 ? void 0 : _t.id);
|
|
8186
8390
|
// clean up the previous unfinished connection
|
|
8187
8391
|
this.dropConnection();
|
|
8188
8392
|
addConnectionAction.do();
|
|
@@ -8191,18 +8395,18 @@ class DiagramCanvas {
|
|
|
8191
8395
|
if (this.inferConnectionType) {
|
|
8192
8396
|
let differentConnectionType = this.model.connections.types.all().find(t => {
|
|
8193
8397
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
8194
|
-
return t.canStartFromType(((_d = (_c = (_b = (_a = this.unfinishedConnection) === null || _a ===
|
|
8398
|
+
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;
|
|
8195
8399
|
});
|
|
8196
8400
|
let invertConnection = false;
|
|
8197
8401
|
if (differentConnectionType === undefined) {
|
|
8198
8402
|
differentConnectionType = this.model.connections.types.all().find(t => {
|
|
8199
8403
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
8200
|
-
return t.canFinishOnType(((_d = (_c = (_b = (_a = this.unfinishedConnection) === null || _a ===
|
|
8404
|
+
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;
|
|
8201
8405
|
});
|
|
8202
8406
|
invertConnection = true;
|
|
8203
8407
|
}
|
|
8204
8408
|
if (differentConnectionType !== undefined) {
|
|
8205
|
-
const addConnectionAction = new AddConnectionAction(this, differentConnectionType, invertConnection ? port.id : (_u = this.unfinishedConnection.start) === null || _u ===
|
|
8409
|
+
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);
|
|
8206
8410
|
// clean up the previous unfinished connection
|
|
8207
8411
|
this.dropConnection();
|
|
8208
8412
|
addConnectionAction.do();
|
|
@@ -8224,9 +8428,9 @@ class DiagramCanvas {
|
|
|
8224
8428
|
}
|
|
8225
8429
|
dropConnection() {
|
|
8226
8430
|
var _a, _b, _c, _d;
|
|
8227
|
-
(_a = this.unfinishedConnection) === null || _a ===
|
|
8228
|
-
(_b = this.unfinishedConnection) === null || _b ===
|
|
8229
|
-
(_d = (_c = this.unfinishedConnection) === null || _c ===
|
|
8431
|
+
(_a = this.unfinishedConnection) === null || _a === void 0 ? void 0 : _a.setStart(undefined);
|
|
8432
|
+
(_b = this.unfinishedConnection) === null || _b === void 0 ? void 0 : _b.setEnd(undefined);
|
|
8433
|
+
(_d = (_c = this.unfinishedConnection) === null || _c === void 0 ? void 0 : _c.select()) === null || _d === void 0 ? void 0 : _d.remove();
|
|
8230
8434
|
this.unfinishedConnection = undefined;
|
|
8231
8435
|
}
|
|
8232
8436
|
cancelAllUserActions() {
|
|
@@ -8239,7 +8443,7 @@ class DiagramCanvas {
|
|
|
8239
8443
|
canUserPerformAction(action) {
|
|
8240
8444
|
return this.userActions[action] !== false;
|
|
8241
8445
|
}
|
|
8242
|
-
createInputField(text, coords, width, height, fontSize, fontFamily, changeCallback, finishCallback) {
|
|
8446
|
+
createInputField(text, coords, width, height, fontSize, fontFamily, orientation, changeCallback, finishCallback) {
|
|
8243
8447
|
// if we have a text input open, close it before creating a new one
|
|
8244
8448
|
this.removeInputField();
|
|
8245
8449
|
const inputFieldContainer = this.selectCanvasElements().append('foreignObject').attr('x', `${coords[0]}px`).attr('y', `${coords[1]}px`).attr('width', `${width}px`).attr('height', `${height}px`).style('box-sizing', 'border-box').style('border', '1px solid');
|
|
@@ -8271,9 +8475,9 @@ class DiagramCanvas {
|
|
|
8271
8475
|
// keep the field from shrinking below its original size
|
|
8272
8476
|
const newWidth = Math.max(inputFieldWidth, width);
|
|
8273
8477
|
const newHeight = Math.max(inputFieldHeight, height);
|
|
8274
|
-
inputFieldContainer === null || inputFieldContainer ===
|
|
8478
|
+
inputFieldContainer === null || inputFieldContainer === void 0 ? void 0 : inputFieldContainer.attr('width', `${newWidth}px`);
|
|
8275
8479
|
inputField.style('width', `${newWidth}px`);
|
|
8276
|
-
inputFieldContainer === null || inputFieldContainer ===
|
|
8480
|
+
inputFieldContainer === null || inputFieldContainer === void 0 ? void 0 : inputFieldContainer.attr('height', `${newHeight}px`);
|
|
8277
8481
|
inputField.style('height', `${newHeight}px`);
|
|
8278
8482
|
if (changeCallback) {
|
|
8279
8483
|
changeCallback(value);
|
|
@@ -8295,13 +8499,13 @@ class DiagramCanvas {
|
|
|
8295
8499
|
var _a, _b, _c;
|
|
8296
8500
|
// when removing an element, a blur event is emitted
|
|
8297
8501
|
// we remove the listener for blur so that it doesn't shoot again on element removal
|
|
8298
|
-
(_b = (_a = this.inputFieldContainer) === null || _a ===
|
|
8299
|
-
(_c = this.inputFieldContainer) === null || _c ===
|
|
8502
|
+
(_b = (_a = this.inputFieldContainer) === null || _a === void 0 ? void 0 : _a.select('input')) === null || _b === void 0 ? void 0 : _b.on(exports.Events.Blur, null);
|
|
8503
|
+
(_c = this.inputFieldContainer) === null || _c === void 0 ? void 0 : _c.remove();
|
|
8300
8504
|
this.inputFieldContainer = undefined;
|
|
8301
8505
|
}
|
|
8302
8506
|
minimumSizeOfField(field) {
|
|
8303
8507
|
var _a, _b;
|
|
8304
|
-
const pNode = (_b = (_a = field.select()) === null || _a ===
|
|
8508
|
+
const pNode = (_b = (_a = field.select()) === null || _a === void 0 ? void 0 : _a.select('p')) === null || _b === void 0 ? void 0 : _b.node();
|
|
8305
8509
|
if (!pNode) {
|
|
8306
8510
|
// happens when a field has been created but not updated in view yet
|
|
8307
8511
|
return [0, 0];
|
|
@@ -8320,7 +8524,7 @@ class DiagramCanvas {
|
|
|
8320
8524
|
this.currentAction = new MoveAction(this, this.userSelection.filter(e => e instanceof DiagramNode).map(n => n.id), d.coords);
|
|
8321
8525
|
} else {
|
|
8322
8526
|
const ancestorOfNode = d.getLastAncestor();
|
|
8323
|
-
this.currentAction = new SetGeometryAction(this, exports.DiagramActions.MoveNode, d.id, d.getGeometry(), d.getGeometry(), ancestorOfNode === null || ancestorOfNode ===
|
|
8527
|
+
this.currentAction = new SetGeometryAction(this, exports.DiagramActions.MoveNode, d.id, d.getGeometry(), d.getGeometry(), ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.id, ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.getGeometry(d.id), ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.getGeometry(d.id));
|
|
8324
8528
|
}
|
|
8325
8529
|
} else {
|
|
8326
8530
|
setCursorStyle(exports.CursorStyle.NotAllowed);
|
|
@@ -8373,23 +8577,23 @@ class DiagramCanvas {
|
|
|
8373
8577
|
const filteredNodesAtLocation = filterByOnlyDescendants(nodesAtLocationWhichCanHaveNodeAsAChild);
|
|
8374
8578
|
const droppedOn = filteredNodesAtLocation[filteredNodesAtLocation.length - 1];
|
|
8375
8579
|
if (droppedOn !== d.parent && (d.type.canBeParentless || droppedOn !== undefined)) {
|
|
8376
|
-
const ancestorOfDroppedOn = droppedOn === null || droppedOn ===
|
|
8580
|
+
const ancestorOfDroppedOn = droppedOn === null || droppedOn === void 0 ? void 0 : droppedOn.getLastAncestor();
|
|
8377
8581
|
const fromChildGeometry = this.currentAction.from;
|
|
8378
|
-
const setParentAction = new SetParentAction(this, d.id, (_a = d.parent) === null || _a ===
|
|
8379
|
-
(_b = d.parent) === null || _b ===
|
|
8582
|
+
const setParentAction = new SetParentAction(this, d.id, (_a = d.parent) === null || _a === void 0 ? void 0 : _a.id, droppedOn === null || droppedOn === void 0 ? void 0 : droppedOn.id, fromChildGeometry, d.getGeometry(), ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.id, ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.getGeometry(d.id), ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.getGeometry(d.id));
|
|
8583
|
+
(_b = d.parent) === null || _b === void 0 ? void 0 : _b.removeChild(d);
|
|
8380
8584
|
if (droppedOn !== undefined) {
|
|
8381
8585
|
droppedOn.addChild(d);
|
|
8382
8586
|
}
|
|
8383
8587
|
setParentAction.toChildGeometry = d.getGeometry(d.id);
|
|
8384
|
-
setParentAction.toAncestorGeometry = ancestorOfDroppedOn === null || ancestorOfDroppedOn ===
|
|
8588
|
+
setParentAction.toAncestorGeometry = ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.getGeometry(d.id);
|
|
8385
8589
|
this.currentAction = setParentAction;
|
|
8386
8590
|
} else {
|
|
8387
|
-
const ancestorOfNode = d === null || d ===
|
|
8388
|
-
this.currentAction.ancestorId = ancestorOfNode === null || ancestorOfNode ===
|
|
8389
|
-
this.currentAction.fromAncestorGeometry = ancestorOfNode === null || ancestorOfNode ===
|
|
8390
|
-
(_c = d.parent) === null || _c ===
|
|
8591
|
+
const ancestorOfNode = d === null || d === void 0 ? void 0 : d.getLastAncestor();
|
|
8592
|
+
this.currentAction.ancestorId = ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.id;
|
|
8593
|
+
this.currentAction.fromAncestorGeometry = ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.getGeometry(d.id);
|
|
8594
|
+
(_c = d.parent) === null || _c === void 0 ? void 0 : _c.fitToChild(d);
|
|
8391
8595
|
this.currentAction.to = d.getGeometry(d.id);
|
|
8392
|
-
this.currentAction.toAncestorGeometry = ancestorOfNode === null || ancestorOfNode ===
|
|
8596
|
+
this.currentAction.toAncestorGeometry = ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.getGeometry(d.id);
|
|
8393
8597
|
}
|
|
8394
8598
|
}
|
|
8395
8599
|
if (this.currentAction !== undefined) {
|
|
@@ -8415,14 +8619,14 @@ class DiagramCanvas {
|
|
|
8415
8619
|
setCursorStyle(exports.CursorStyle.Crosshair);
|
|
8416
8620
|
// since the multiple selection rectangle is not affected by zoom,
|
|
8417
8621
|
// we compensate its coordinates based in the zoom transform to draw it
|
|
8418
|
-
(_d = (_c = (_b = (_a = this.multipleSelectionContainer) === null || _a ===
|
|
8622
|
+
(_d = (_c = (_b = (_a = this.multipleSelectionContainer) === null || _a === void 0 ? void 0 : _a.attr('x', Math.min(this.draggingFrom[0], pointerCoords[0]) * this.zoomTransform.k + this.zoomTransform.x)) === null || _b === void 0 ? void 0 : _b.attr('y', Math.min(this.draggingFrom[1], pointerCoords[1]) * this.zoomTransform.k + this.zoomTransform.y)) === null || _c === void 0 ? void 0 : _c.attr('width', Math.abs(this.draggingFrom[0] - pointerCoords[0]) * this.zoomTransform.k)) === null || _d === void 0 ? void 0 : _d.attr('height', Math.abs(this.draggingFrom[1] - pointerCoords[1]) * this.zoomTransform.k);
|
|
8419
8623
|
this.dragging = true;
|
|
8420
8624
|
}
|
|
8421
8625
|
}
|
|
8422
8626
|
finishMultipleSelection(event) {
|
|
8423
8627
|
var _a;
|
|
8424
8628
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
8425
|
-
(_a = this.multipleSelectionContainer) === null || _a ===
|
|
8629
|
+
(_a = this.multipleSelectionContainer) === null || _a === void 0 ? void 0 : _a.remove();
|
|
8426
8630
|
this.multipleSelectionContainer = undefined;
|
|
8427
8631
|
this.userSelection.clear();
|
|
8428
8632
|
for (const node of this.model.nodes) {
|
|
@@ -8516,7 +8720,7 @@ class CollabClient {
|
|
|
8516
8720
|
const initialModel = message.initialModel;
|
|
8517
8721
|
new DagaImporter().import(session.canvas.model, initialModel);
|
|
8518
8722
|
this.startSyncing(session);
|
|
8519
|
-
(_a = session.joinRoomResolve) === null || _a ===
|
|
8723
|
+
(_a = session.joinRoomResolve) === null || _a === void 0 ? void 0 : _a.call(session);
|
|
8520
8724
|
session.joinRoomResolve = undefined;
|
|
8521
8725
|
break;
|
|
8522
8726
|
}
|
|
@@ -8539,7 +8743,7 @@ class CollabClient {
|
|
|
8539
8743
|
session.locator = message.locator;
|
|
8540
8744
|
this.pendingSessions.delete(message.refId);
|
|
8541
8745
|
this.sessions.set(session.locator, session);
|
|
8542
|
-
(_b = session.createRoomResolve) === null || _b ===
|
|
8746
|
+
(_b = session.createRoomResolve) === null || _b === void 0 ? void 0 : _b.call(session, session.locator);
|
|
8543
8747
|
session.createRoomResolve = undefined;
|
|
8544
8748
|
// Deliver queued AddMessages now that we have a locator.
|
|
8545
8749
|
for (const message of session.addQueue) {
|
|
@@ -8794,6 +8998,9 @@ class Grid {
|
|
|
8794
8998
|
* @public
|
|
8795
8999
|
*/
|
|
8796
9000
|
class AdjacencyLayout {
|
|
9001
|
+
constructor(gapSize) {
|
|
9002
|
+
this.gapSize = gapSize;
|
|
9003
|
+
}
|
|
8797
9004
|
apply(model) {
|
|
8798
9005
|
var _a;
|
|
8799
9006
|
if (model.nodes.length === 0) {
|
|
@@ -8809,7 +9016,7 @@ class AdjacencyLayout {
|
|
|
8809
9016
|
// place nodes according to arrangement
|
|
8810
9017
|
const maximumWidth = Math.max(...model.nodes.map(n => n.width));
|
|
8811
9018
|
const maximumHeight = Math.max(...model.nodes.map(n => n.height));
|
|
8812
|
-
const gapSize = (((_a = model.canvas) === null || _a ===
|
|
9019
|
+
const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
|
|
8813
9020
|
for (let y = nodeArrangement.minY(); y <= nodeArrangement.maxY(); ++y) {
|
|
8814
9021
|
for (let x = nodeArrangement.minX(); x <= nodeArrangement.maxX(); ++x) {
|
|
8815
9022
|
const node = nodeArrangement.get([x, y]);
|
|
@@ -8837,6 +9044,9 @@ const arrangeNode = (node, nodeArrangement, coords, nodesToBeArranged) => {
|
|
|
8837
9044
|
* @public
|
|
8838
9045
|
*/
|
|
8839
9046
|
class BreadthAdjacencyLayout {
|
|
9047
|
+
constructor(gapSize) {
|
|
9048
|
+
this.gapSize = gapSize;
|
|
9049
|
+
}
|
|
8840
9050
|
apply(model) {
|
|
8841
9051
|
var _a;
|
|
8842
9052
|
if (model.nodes.length === 0) {
|
|
@@ -8874,7 +9084,7 @@ class BreadthAdjacencyLayout {
|
|
|
8874
9084
|
// place nodes according to arrangement
|
|
8875
9085
|
const maximumWidth = Math.max(...model.nodes.map(n => n.width));
|
|
8876
9086
|
const maximumHeight = Math.max(...model.nodes.map(n => n.height));
|
|
8877
|
-
const gapSize = (((_a = model.canvas) === null || _a ===
|
|
9087
|
+
const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
|
|
8878
9088
|
for (let y = nodeArrangement.minY(); y <= nodeArrangement.maxY(); ++y) {
|
|
8879
9089
|
for (let x = nodeArrangement.minX(); x <= nodeArrangement.maxX(); ++x) {
|
|
8880
9090
|
const node = nodeArrangement.get([x, y]);
|
|
@@ -8892,13 +9102,16 @@ class BreadthAdjacencyLayout {
|
|
|
8892
9102
|
* @public
|
|
8893
9103
|
*/
|
|
8894
9104
|
class BreadthLayout {
|
|
9105
|
+
constructor(gapSize) {
|
|
9106
|
+
this.gapSize = gapSize;
|
|
9107
|
+
}
|
|
8895
9108
|
apply(model) {
|
|
8896
9109
|
var _a;
|
|
8897
9110
|
if (model.nodes.length === 0) {
|
|
8898
9111
|
// nothing to arrange...
|
|
8899
9112
|
return model;
|
|
8900
9113
|
}
|
|
8901
|
-
const gapSize = (((_a = model.canvas) === null || _a ===
|
|
9114
|
+
const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
|
|
8902
9115
|
let nodesToBeArranged = model.nodes.filter(n => !n.parent);
|
|
8903
9116
|
// Arrange nodes by a breadth first search
|
|
8904
9117
|
const firstNode = nodesToBeArranged[0];
|
|
@@ -8954,6 +9167,9 @@ class BreadthLayout {
|
|
|
8954
9167
|
* @public
|
|
8955
9168
|
*/
|
|
8956
9169
|
class ForceLayout {
|
|
9170
|
+
constructor(gapSize) {
|
|
9171
|
+
this.gapSize = gapSize;
|
|
9172
|
+
}
|
|
8957
9173
|
apply(model) {
|
|
8958
9174
|
var _a;
|
|
8959
9175
|
if (model.nodes.length === 0) {
|
|
@@ -8962,7 +9178,7 @@ class ForceLayout {
|
|
|
8962
9178
|
}
|
|
8963
9179
|
// as a starting point, we apply a simple layout
|
|
8964
9180
|
new BreadthLayout().apply(model);
|
|
8965
|
-
const gapSize = (((_a = model.canvas) === null || _a ===
|
|
9181
|
+
const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
|
|
8966
9182
|
const coolingFactor = 0.99;
|
|
8967
9183
|
const minimumTemperature = 1;
|
|
8968
9184
|
const attractionFactor = 0.1;
|
|
@@ -9049,13 +9265,16 @@ class ForceLayout {
|
|
|
9049
9265
|
* @public
|
|
9050
9266
|
*/
|
|
9051
9267
|
class HorizontalLayout {
|
|
9268
|
+
constructor(gapSize) {
|
|
9269
|
+
this.gapSize = gapSize;
|
|
9270
|
+
}
|
|
9052
9271
|
apply(model) {
|
|
9053
9272
|
var _a;
|
|
9054
9273
|
if (model.nodes.length === 0) {
|
|
9055
9274
|
// nothing to arrange...
|
|
9056
9275
|
return model;
|
|
9057
9276
|
}
|
|
9058
|
-
const gapSize = (((_a = model.canvas) === null || _a ===
|
|
9277
|
+
const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
|
|
9059
9278
|
const nodesToBeArranged = model.nodes.filter(n => !n.parent);
|
|
9060
9279
|
nodesToBeArranged.sort((a, b) => b.type.priority - a.type.priority);
|
|
9061
9280
|
let widthAccumulator = 0;
|
|
@@ -9072,6 +9291,9 @@ class HorizontalLayout {
|
|
|
9072
9291
|
* @public
|
|
9073
9292
|
*/
|
|
9074
9293
|
class PriorityLayout {
|
|
9294
|
+
constructor(gapSize) {
|
|
9295
|
+
this.gapSize = gapSize;
|
|
9296
|
+
}
|
|
9075
9297
|
apply(model) {
|
|
9076
9298
|
var _a;
|
|
9077
9299
|
if (model.nodes.length === 0) {
|
|
@@ -9085,7 +9307,7 @@ class PriorityLayout {
|
|
|
9085
9307
|
new BreadthLayout().apply(model);
|
|
9086
9308
|
return model;
|
|
9087
9309
|
}
|
|
9088
|
-
const gapSize = (((_a = model.canvas) === null || _a ===
|
|
9310
|
+
const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
|
|
9089
9311
|
const nodesToBeArranged = model.nodes.filter(n => !n.parent);
|
|
9090
9312
|
const nodeArrangement = [];
|
|
9091
9313
|
const nodesWithMaximumPriorityToBeArranged = model.nodes.filter(n => !n.parent).filter(n => n.getPriority() >= maximumPriority);
|
|
@@ -9179,6 +9401,9 @@ class PriorityLayout {
|
|
|
9179
9401
|
* @public
|
|
9180
9402
|
*/
|
|
9181
9403
|
class TreeLayout {
|
|
9404
|
+
constructor(gapSize) {
|
|
9405
|
+
this.gapSize = gapSize;
|
|
9406
|
+
}
|
|
9182
9407
|
apply(model) {
|
|
9183
9408
|
var _a;
|
|
9184
9409
|
if (model.nodes.length === 0) {
|
|
@@ -9192,7 +9417,7 @@ class TreeLayout {
|
|
|
9192
9417
|
new BreadthLayout().apply(model);
|
|
9193
9418
|
return model;
|
|
9194
9419
|
}
|
|
9195
|
-
const gapSize = (((_a = model.canvas) === null || _a ===
|
|
9420
|
+
const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
|
|
9196
9421
|
const nodesToBeArranged = model.nodes.filter(n => !n.parent).sort((n1, n2) => n2.getPriority() - n1.getPriority());
|
|
9197
9422
|
const branches = [];
|
|
9198
9423
|
while (nodesToBeArranged.length > 0) {
|
|
@@ -9277,13 +9502,16 @@ class Branch {
|
|
|
9277
9502
|
* @public
|
|
9278
9503
|
*/
|
|
9279
9504
|
class VerticalLayout {
|
|
9505
|
+
constructor(gapSize) {
|
|
9506
|
+
this.gapSize = gapSize;
|
|
9507
|
+
}
|
|
9280
9508
|
apply(model) {
|
|
9281
9509
|
var _a;
|
|
9282
9510
|
if (model.nodes.length === 0) {
|
|
9283
9511
|
// nothing to arrange...
|
|
9284
9512
|
return model;
|
|
9285
9513
|
}
|
|
9286
|
-
const gapSize = (((_a = model.canvas) === null || _a ===
|
|
9514
|
+
const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
|
|
9287
9515
|
const nodesToBeArranged = model.nodes.filter(n => !n.parent);
|
|
9288
9516
|
nodesToBeArranged.sort((a, b) => b.type.priority - a.type.priority);
|
|
9289
9517
|
let heightAccumulator = 0;
|