@metadev/daga 3.0.0 → 3.1.1
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 +20 -1
- package/README.md +11 -1
- package/index.cjs.js +1056 -351
- package/index.esm.js +1044 -348
- package/package.json +1 -1
- package/src/index.d.ts +27 -21
- package/src/lib/diagram/canvas/diagram-canvas.d.ts +6 -12
- package/src/lib/diagram/collab/collab-action.d.ts +58 -2
- package/src/lib/diagram/converters/daga-model.d.ts +1 -0
- package/src/lib/diagram/diagram-action.d.ts +67 -4
- package/src/lib/diagram/diagram-config.d.ts +23 -4
- package/src/lib/diagram/diagram-event.d.ts +74 -8
- package/src/lib/diagram/layout/diagram-layout.d.ts +4 -0
- package/src/lib/diagram/model/diagram-connection.d.ts +3 -2
- package/src/lib/diagram/model/diagram-decorator.d.ts +1 -0
- package/src/lib/diagram/model/diagram-element.d.ts +5 -0
- package/src/lib/diagram/model/diagram-field.d.ts +1 -0
- package/src/lib/diagram/model/diagram-node.d.ts +69 -2
- package/src/lib/diagram/model/diagram-object.d.ts +1 -0
- package/src/lib/diagram/model/diagram-port.d.ts +1 -0
- package/src/lib/diagram/model/diagram-property.d.ts +3 -1
- package/src/lib/diagram/model/diagram-section.d.ts +1 -0
- package/src/lib/interfaces/canvas.d.ts +8 -16
- package/src/lib/util/line.d.ts +6 -1
- package/src/lib/util/shape.d.ts +6 -1
package/index.cjs.js
CHANGED
|
@@ -324,6 +324,9 @@ const MINIMUM_DISTANCE_BEFORE_TURN = 20;
|
|
|
324
324
|
* @private
|
|
325
325
|
*/
|
|
326
326
|
const linePath = (shape, points, startDirection, endDirection, minimumDistanceBeforeTurn) => {
|
|
327
|
+
if (typeof shape === 'function') {
|
|
328
|
+
return shape(points, startDirection, endDirection, minimumDistanceBeforeTurn);
|
|
329
|
+
}
|
|
327
330
|
if (points.length === 0) {
|
|
328
331
|
return '';
|
|
329
332
|
} else if (points.length === 1) {
|
|
@@ -686,6 +689,9 @@ exports.ClosedShape = void 0;
|
|
|
686
689
|
* @private
|
|
687
690
|
*/
|
|
688
691
|
const generalClosedPath = (shape, x, y, width, height) => {
|
|
692
|
+
if (typeof shape === 'function') {
|
|
693
|
+
return shape(x, y, width, height);
|
|
694
|
+
}
|
|
689
695
|
switch (shape) {
|
|
690
696
|
case exports.ClosedShape.Ellipse:
|
|
691
697
|
return ellipsePath(x, y, width, height);
|
|
@@ -819,7 +825,7 @@ const numberOfColumns = s => {
|
|
|
819
825
|
};
|
|
820
826
|
const numberOfRows = s => {
|
|
821
827
|
var _a;
|
|
822
|
-
return ((_a = s.match(/\n/g)) === null || _a ===
|
|
828
|
+
return ((_a = s.match(/\n/g)) === null || _a === undefined ? undefined : _a.length) || 0;
|
|
823
829
|
};
|
|
824
830
|
|
|
825
831
|
/**
|
|
@@ -979,14 +985,14 @@ class DiagramElement {
|
|
|
979
985
|
*/
|
|
980
986
|
get highlighted() {
|
|
981
987
|
var _a, _b;
|
|
982
|
-
return ((_b = (_a = this.model.canvas) === null || _a ===
|
|
988
|
+
return ((_b = (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.userHighlight) === null || _b === undefined ? undefined : _b.contains(this.id)) || false;
|
|
983
989
|
}
|
|
984
990
|
/**
|
|
985
991
|
* Whether this diagram element is currently in the user selection.
|
|
986
992
|
*/
|
|
987
993
|
get selected() {
|
|
988
994
|
var _a, _b;
|
|
989
|
-
return ((_b = (_a = this.model.canvas) === null || _a ===
|
|
995
|
+
return ((_b = (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.userSelection) === null || _b === undefined ? undefined : _b.contains(this.id)) || false;
|
|
990
996
|
}
|
|
991
997
|
constructor(model, id) {
|
|
992
998
|
/**
|
|
@@ -1015,7 +1021,7 @@ class DiagramElement {
|
|
|
1015
1021
|
*/
|
|
1016
1022
|
select() {
|
|
1017
1023
|
var _a, _b;
|
|
1018
|
-
return (_b = (_a = this.model.canvas) === null || _a ===
|
|
1024
|
+
return (_b = (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.selectCanvasView()) === null || _b === undefined ? undefined : _b.select(`g#${this.id}`);
|
|
1019
1025
|
}
|
|
1020
1026
|
}
|
|
1021
1027
|
class DiagramElementSet extends DiagramEntitySet {
|
|
@@ -1238,6 +1244,7 @@ class ValueSet {
|
|
|
1238
1244
|
constructor(propertySet, rootElement) {
|
|
1239
1245
|
this.displayedProperties = [];
|
|
1240
1246
|
this.hiddenProperties = [];
|
|
1247
|
+
// TODO JC: make this private after reviewing how it's used from React
|
|
1241
1248
|
this.values = {};
|
|
1242
1249
|
this.valueSets = {};
|
|
1243
1250
|
/**
|
|
@@ -1316,7 +1323,7 @@ class ValueSet {
|
|
|
1316
1323
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1317
1324
|
getValue(key) {
|
|
1318
1325
|
var _a;
|
|
1319
|
-
const rootAttribute = (_a = this.propertySet.getProperty(key)) === null || _a ===
|
|
1326
|
+
const rootAttribute = (_a = this.propertySet.getProperty(key)) === null || _a === undefined ? undefined : _a.rootAttribute;
|
|
1320
1327
|
if (rootAttribute !== undefined && rootAttribute !== null) {
|
|
1321
1328
|
this.values[key] = this.getRootElementValue(rootAttribute);
|
|
1322
1329
|
}
|
|
@@ -1401,7 +1408,7 @@ class ValueSet {
|
|
|
1401
1408
|
if (property && property.type === exports.Type.Object) {
|
|
1402
1409
|
return this.getSubValueSet(key).hasAnySetValue();
|
|
1403
1410
|
}
|
|
1404
|
-
return !empty(value) && !equals(value, property === null || property ===
|
|
1411
|
+
return !empty(value) && !equals(value, property === null || property === undefined ? undefined : property.defaultValue);
|
|
1405
1412
|
}
|
|
1406
1413
|
/**
|
|
1407
1414
|
* Checks if any of the values in the set are not empty or the default value.
|
|
@@ -1760,7 +1767,11 @@ class DiagramConnection extends DiagramElement {
|
|
|
1760
1767
|
}
|
|
1761
1768
|
updateInView() {
|
|
1762
1769
|
var _a;
|
|
1763
|
-
(_a = this.model.canvas) === null || _a ===
|
|
1770
|
+
(_a = this.model.canvas) === null || _a === undefined ? undefined : _a.updateConnectionsInView(this.id);
|
|
1771
|
+
}
|
|
1772
|
+
raise() {
|
|
1773
|
+
var _a;
|
|
1774
|
+
(_a = this.select()) === null || _a === undefined ? undefined : _a.raise();
|
|
1764
1775
|
}
|
|
1765
1776
|
/**
|
|
1766
1777
|
* Set the start of this connection to the given port or reset this connection's starting port if `undefined`.
|
|
@@ -1776,12 +1787,12 @@ class DiagramConnection extends DiagramElement {
|
|
|
1776
1787
|
this.start = start;
|
|
1777
1788
|
if (start !== undefined) {
|
|
1778
1789
|
start.outgoingConnections.push(this);
|
|
1779
|
-
this.startDirection = start === null || start ===
|
|
1780
|
-
this.startCoords = (start === null || start ===
|
|
1790
|
+
this.startDirection = start === null || start === undefined ? undefined : start.direction;
|
|
1791
|
+
this.startCoords = (start === null || start === undefined ? undefined : start.coords) || [0, 0];
|
|
1781
1792
|
}
|
|
1782
1793
|
} else {
|
|
1783
|
-
this.startDirection = start === null || start ===
|
|
1784
|
-
this.startCoords = (start === null || start ===
|
|
1794
|
+
this.startDirection = start === null || start === undefined ? undefined : start.direction;
|
|
1795
|
+
this.startCoords = (start === null || start === undefined ? undefined : start.coords) || [0, 0];
|
|
1785
1796
|
}
|
|
1786
1797
|
this.updateInView();
|
|
1787
1798
|
}
|
|
@@ -1799,12 +1810,12 @@ class DiagramConnection extends DiagramElement {
|
|
|
1799
1810
|
this.end = end;
|
|
1800
1811
|
if (end !== undefined) {
|
|
1801
1812
|
end.incomingConnections.push(this);
|
|
1802
|
-
this.endDirection = end === null || end ===
|
|
1803
|
-
this.endCoords = (end === null || end ===
|
|
1813
|
+
this.endDirection = end === null || end === undefined ? undefined : end.direction;
|
|
1814
|
+
this.endCoords = (end === null || end === undefined ? undefined : end.coords) || [0, 0];
|
|
1804
1815
|
}
|
|
1805
1816
|
} else {
|
|
1806
|
-
this.endDirection = end === null || end ===
|
|
1807
|
-
this.endCoords = (end === null || end ===
|
|
1817
|
+
this.endDirection = end === null || end === undefined ? undefined : end.direction;
|
|
1818
|
+
this.endCoords = (end === null || end === undefined ? undefined : end.coords) || [0, 0];
|
|
1808
1819
|
}
|
|
1809
1820
|
this.updateInView();
|
|
1810
1821
|
}
|
|
@@ -1815,7 +1826,7 @@ class DiagramConnection extends DiagramElement {
|
|
|
1815
1826
|
*/
|
|
1816
1827
|
tighten() {
|
|
1817
1828
|
var _a, _b;
|
|
1818
|
-
if (((_a = this.start) === null || _a ===
|
|
1829
|
+
if (((_a = this.start) === null || _a === undefined ? undefined : _a.rootElement) && this.end) {
|
|
1819
1830
|
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]);
|
|
1820
1831
|
checkAlternativeStartPorts: for (const alternativeStartPort of alternativeStartPortsSortedByDistanceAscending) {
|
|
1821
1832
|
if (alternativeStartPort === this.end) {
|
|
@@ -1845,7 +1856,7 @@ class DiagramConnection extends DiagramElement {
|
|
|
1845
1856
|
}
|
|
1846
1857
|
}
|
|
1847
1858
|
}
|
|
1848
|
-
if (((_b = this.end) === null || _b ===
|
|
1859
|
+
if (((_b = this.end) === null || _b === undefined ? undefined : _b.rootElement) && this.start) {
|
|
1849
1860
|
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]);
|
|
1850
1861
|
checkAlternativeEndPorts: for (const alternativeEndPort of alternativeEndPortsSortedByDistanceAscending) {
|
|
1851
1862
|
if (alternativeEndPort === this.start) {
|
|
@@ -1937,8 +1948,8 @@ class DiagramConnectionSet extends DiagramElementSet {
|
|
|
1937
1948
|
const connection = this.get(id, true);
|
|
1938
1949
|
if (connection) {
|
|
1939
1950
|
// remove from ports
|
|
1940
|
-
removeIfExists(((_a = connection.start) === null || _a ===
|
|
1941
|
-
removeIfExists(((_b = connection.end) === null || _b ===
|
|
1951
|
+
removeIfExists(((_a = connection.start) === null || _a === undefined ? undefined : _a.outgoingConnections) || [], connection);
|
|
1952
|
+
removeIfExists(((_b = connection.end) === null || _b === undefined ? undefined : _b.incomingConnections) || [], connection);
|
|
1942
1953
|
// remove from set of connections
|
|
1943
1954
|
super.remove(id);
|
|
1944
1955
|
// remove from canvas
|
|
@@ -1987,11 +1998,11 @@ class DiagramField extends DiagramElement {
|
|
|
1987
1998
|
this._text = value;
|
|
1988
1999
|
this.updateInView();
|
|
1989
2000
|
if (this.fit) {
|
|
1990
|
-
(_a = this.model.canvas) === null || _a ===
|
|
2001
|
+
(_a = this.model.canvas) === null || _a === undefined ? undefined : _a.fitFieldRootInView(this.id);
|
|
1991
2002
|
}
|
|
1992
2003
|
}
|
|
1993
2004
|
constructor(model, rootElement, coords, width, height, fontSize, fontFamily, color, selectedColor, horizontalAlign, verticalAlign, text, editable, fit) {
|
|
1994
|
-
const id = `${rootElement === null || rootElement ===
|
|
2005
|
+
const id = `${rootElement === null || rootElement === undefined ? undefined : rootElement.id}_field`;
|
|
1995
2006
|
if (model.fields.get(id) !== undefined) {
|
|
1996
2007
|
throw new Error('DiagramField for rootElement already exists');
|
|
1997
2008
|
}
|
|
@@ -2018,14 +2029,18 @@ class DiagramField extends DiagramElement {
|
|
|
2018
2029
|
}
|
|
2019
2030
|
select() {
|
|
2020
2031
|
var _a, _b;
|
|
2021
|
-
return (_b = (_a = this.model.canvas) === null || _a ===
|
|
2032
|
+
return (_b = (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.selectCanvasView()) === null || _b === undefined ? undefined : _b.select(`foreignObject#${this.id}`);
|
|
2022
2033
|
}
|
|
2023
2034
|
get removed() {
|
|
2024
2035
|
return this.selfRemoved || this.rootElement !== undefined && this.rootElement.removed;
|
|
2025
2036
|
}
|
|
2026
2037
|
updateInView() {
|
|
2027
2038
|
var _a;
|
|
2028
|
-
(_a = this.model.canvas) === null || _a ===
|
|
2039
|
+
(_a = this.model.canvas) === null || _a === undefined ? undefined : _a.updateFieldsInView(this.id);
|
|
2040
|
+
}
|
|
2041
|
+
raise() {
|
|
2042
|
+
var _a;
|
|
2043
|
+
(_a = this.select()) === null || _a === undefined ? undefined : _a.raise();
|
|
2029
2044
|
}
|
|
2030
2045
|
/**
|
|
2031
2046
|
* Change the coordinates of this field to the given coordinates.
|
|
@@ -2038,7 +2053,7 @@ class DiagramField extends DiagramElement {
|
|
|
2038
2053
|
}
|
|
2039
2054
|
getPriority() {
|
|
2040
2055
|
var _a;
|
|
2041
|
-
return ((_a = this.rootElement) === null || _a ===
|
|
2056
|
+
return ((_a = this.rootElement) === null || _a === undefined ? undefined : _a.getPriority()) || DEFAULT_PRIORITY;
|
|
2042
2057
|
}
|
|
2043
2058
|
}
|
|
2044
2059
|
class DiagramFieldSet extends DiagramElementSet {
|
|
@@ -2069,7 +2084,7 @@ class DiagramFieldSet extends DiagramElementSet {
|
|
|
2069
2084
|
const field = this.get(id, true);
|
|
2070
2085
|
if (field) {
|
|
2071
2086
|
// remove from root element
|
|
2072
|
-
if (((_a = field.rootElement) === null || _a ===
|
|
2087
|
+
if (((_a = field.rootElement) === null || _a === undefined ? undefined : _a.label) !== undefined) {
|
|
2073
2088
|
if (field.rootElement.label === field) {
|
|
2074
2089
|
field.rootElement.label = undefined;
|
|
2075
2090
|
}
|
|
@@ -2082,7 +2097,7 @@ class DiagramFieldSet extends DiagramElementSet {
|
|
|
2082
2097
|
}
|
|
2083
2098
|
}
|
|
2084
2099
|
const getBottomMargin = config => {
|
|
2085
|
-
if ((config === null || config ===
|
|
2100
|
+
if ((config === null || config === undefined ? undefined : config.margin) === null || (config === null || config === undefined ? undefined : config.margin) === undefined) {
|
|
2086
2101
|
return DIAGRAM_FIELD_DEFAULTS.margin;
|
|
2087
2102
|
} else if (typeof config.margin === 'number') {
|
|
2088
2103
|
return config.margin;
|
|
@@ -2101,7 +2116,7 @@ const getBottomMargin = config => {
|
|
|
2101
2116
|
}
|
|
2102
2117
|
};
|
|
2103
2118
|
const getLeftMargin = config => {
|
|
2104
|
-
if ((config === null || config ===
|
|
2119
|
+
if ((config === null || config === undefined ? undefined : config.margin) === null || (config === null || config === undefined ? undefined : config.margin) === undefined) {
|
|
2105
2120
|
return DIAGRAM_FIELD_DEFAULTS.margin;
|
|
2106
2121
|
} else if (typeof config.margin === 'number') {
|
|
2107
2122
|
return config.margin;
|
|
@@ -2120,7 +2135,7 @@ const getLeftMargin = config => {
|
|
|
2120
2135
|
}
|
|
2121
2136
|
};
|
|
2122
2137
|
const getRightMargin = config => {
|
|
2123
|
-
if ((config === null || config ===
|
|
2138
|
+
if ((config === null || config === undefined ? undefined : config.margin) === null || (config === null || config === undefined ? undefined : config.margin) === undefined) {
|
|
2124
2139
|
return DIAGRAM_FIELD_DEFAULTS.margin;
|
|
2125
2140
|
} else if (typeof config.margin === 'number') {
|
|
2126
2141
|
return config.margin;
|
|
@@ -2139,7 +2154,7 @@ const getRightMargin = config => {
|
|
|
2139
2154
|
}
|
|
2140
2155
|
};
|
|
2141
2156
|
const getTopMargin = config => {
|
|
2142
|
-
if ((config === null || config ===
|
|
2157
|
+
if ((config === null || config === undefined ? undefined : config.margin) === null || (config === null || config === undefined ? undefined : config.margin) === undefined) {
|
|
2143
2158
|
return DIAGRAM_FIELD_DEFAULTS.margin;
|
|
2144
2159
|
} else if (typeof config.margin === 'number') {
|
|
2145
2160
|
return config.margin;
|
|
@@ -2157,8 +2172,8 @@ const getTopMargin = config => {
|
|
|
2157
2172
|
}
|
|
2158
2173
|
}
|
|
2159
2174
|
};
|
|
2160
|
-
const getBottomPadding = config => {
|
|
2161
|
-
if ((config === null || config ===
|
|
2175
|
+
const getBottomPadding$1 = config => {
|
|
2176
|
+
if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
|
|
2162
2177
|
return DIAGRAM_FIELD_DEFAULTS.padding;
|
|
2163
2178
|
} else if (typeof config.padding === 'number') {
|
|
2164
2179
|
return config.padding;
|
|
@@ -2176,8 +2191,8 @@ const getBottomPadding = config => {
|
|
|
2176
2191
|
}
|
|
2177
2192
|
}
|
|
2178
2193
|
};
|
|
2179
|
-
const getLeftPadding = config => {
|
|
2180
|
-
if ((config === null || config ===
|
|
2194
|
+
const getLeftPadding$1 = config => {
|
|
2195
|
+
if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
|
|
2181
2196
|
return DIAGRAM_FIELD_DEFAULTS.padding;
|
|
2182
2197
|
} else if (typeof config.padding === 'number') {
|
|
2183
2198
|
return config.padding;
|
|
@@ -2195,8 +2210,8 @@ const getLeftPadding = config => {
|
|
|
2195
2210
|
}
|
|
2196
2211
|
}
|
|
2197
2212
|
};
|
|
2198
|
-
const getRightPadding = config => {
|
|
2199
|
-
if ((config === null || config ===
|
|
2213
|
+
const getRightPadding$1 = config => {
|
|
2214
|
+
if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
|
|
2200
2215
|
return DIAGRAM_FIELD_DEFAULTS.padding;
|
|
2201
2216
|
} else if (typeof config.padding === 'number') {
|
|
2202
2217
|
return config.padding;
|
|
@@ -2214,8 +2229,8 @@ const getRightPadding = config => {
|
|
|
2214
2229
|
}
|
|
2215
2230
|
}
|
|
2216
2231
|
};
|
|
2217
|
-
const getTopPadding = config => {
|
|
2218
|
-
if ((config === null || config ===
|
|
2232
|
+
const getTopPadding$1 = config => {
|
|
2233
|
+
if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
|
|
2219
2234
|
return DIAGRAM_FIELD_DEFAULTS.padding;
|
|
2220
2235
|
} else if (typeof config.padding === 'number') {
|
|
2221
2236
|
return config.padding;
|
|
@@ -2296,7 +2311,7 @@ class DiagramSection extends DiagramElement {
|
|
|
2296
2311
|
*/
|
|
2297
2312
|
get name() {
|
|
2298
2313
|
var _a;
|
|
2299
|
-
return ((_a = this.label) === null || _a ===
|
|
2314
|
+
return ((_a = this.label) === null || _a === undefined ? undefined : _a.text) || '';
|
|
2300
2315
|
}
|
|
2301
2316
|
set name(name) {
|
|
2302
2317
|
if (this.label) {
|
|
@@ -2330,23 +2345,36 @@ class DiagramSection extends DiagramElement {
|
|
|
2330
2345
|
}
|
|
2331
2346
|
updateInView() {
|
|
2332
2347
|
var _a;
|
|
2333
|
-
(_a = this.model.canvas) === null || _a ===
|
|
2348
|
+
(_a = this.model.canvas) === null || _a === undefined ? undefined : _a.updateSectionsInView(this.id);
|
|
2349
|
+
}
|
|
2350
|
+
raise() {
|
|
2351
|
+
var _a;
|
|
2352
|
+
(_a = this.select()) === null || _a === undefined ? undefined : _a.raise();
|
|
2353
|
+
if (this.label) {
|
|
2354
|
+
this.label.raise();
|
|
2355
|
+
}
|
|
2356
|
+
for (const port of this.ports) {
|
|
2357
|
+
port.raise();
|
|
2358
|
+
}
|
|
2359
|
+
for (const decorator of this.decorators) {
|
|
2360
|
+
decorator.raise();
|
|
2361
|
+
}
|
|
2334
2362
|
}
|
|
2335
2363
|
getConfig() {
|
|
2336
2364
|
var _a, _b, _c, _d, _e;
|
|
2337
|
-
return (_e = (_d = (_c = (_b = (_a = this.node) === null || _a ===
|
|
2365
|
+
return (_e = (_d = (_c = (_b = (_a = this.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.sectionGrid) === null || _c === undefined ? undefined : _c.sections) === null || _d === undefined ? undefined : _d[this.indexYInNode]) === null || _e === undefined ? undefined : _e[this.indexXInNode];
|
|
2338
2366
|
}
|
|
2339
2367
|
getMinWidth() {
|
|
2340
2368
|
var _a, _b, _c, _d;
|
|
2341
|
-
return ((_d = (_c = (_b = (_a = this.node) === null || _a ===
|
|
2369
|
+
return ((_d = (_c = (_b = (_a = this.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.sectionGrid) === null || _c === undefined ? undefined : _c.minWidths) === null || _d === undefined ? undefined : _d[this.indexXInNode]) || DIAGRAM_SECTION_MIN_WIDTH;
|
|
2342
2370
|
}
|
|
2343
2371
|
getMinHeight() {
|
|
2344
2372
|
var _a, _b, _c, _d;
|
|
2345
|
-
return ((_d = (_c = (_b = (_a = this.node) === null || _a ===
|
|
2373
|
+
return ((_d = (_c = (_b = (_a = this.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.sectionGrid) === null || _c === undefined ? undefined : _c.minHeights) === null || _d === undefined ? undefined : _d[this.indexYInNode]) || DIAGRAM_SECTION_MIN_HEIGHT;
|
|
2346
2374
|
}
|
|
2347
2375
|
getPriority() {
|
|
2348
2376
|
var _a, _b, _c, _d, _e, _f;
|
|
2349
|
-
return ((_f = (_e = (_d = (_c = (_b = (_a = this.node) === null || _a ===
|
|
2377
|
+
return ((_f = (_e = (_d = (_c = (_b = (_a = this.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.sectionGrid) === null || _c === undefined ? undefined : _c.sections) === null || _d === undefined ? undefined : _d[this.indexYInNode]) === null || _e === undefined ? undefined : _e[this.indexXInNode]) === null || _f === undefined ? undefined : _f.priority) || DIAGRAM_SECTION_DEFAULTS.priority;
|
|
2350
2378
|
}
|
|
2351
2379
|
/**
|
|
2352
2380
|
* Get the port of this section which is closest to the given coordinates.
|
|
@@ -2511,9 +2539,9 @@ class DiagramSection extends DiagramElement {
|
|
|
2511
2539
|
}
|
|
2512
2540
|
// Set label's dimensions as a function of ours.
|
|
2513
2541
|
if (this.label) {
|
|
2514
|
-
this.label.coords = [this.coords[0] + getLeftMargin((_a = this.getConfig()) === null || _a ===
|
|
2515
|
-
this.label.width = this.width - getLeftMargin((_c = this.getConfig()) === null || _c ===
|
|
2516
|
-
this.label.height = this.height - getTopMargin((_e = this.getConfig()) === null || _e ===
|
|
2542
|
+
this.label.coords = [this.coords[0] + getLeftMargin((_a = this.getConfig()) === null || _a === undefined ? undefined : _a.label), this.coords[1] + getTopMargin((_b = this.getConfig()) === null || _b === undefined ? undefined : _b.label)];
|
|
2543
|
+
this.label.width = this.width - getLeftMargin((_c = this.getConfig()) === null || _c === undefined ? undefined : _c.label) - getRightMargin((_d = this.getConfig()) === null || _d === undefined ? undefined : _d.label);
|
|
2544
|
+
this.label.height = this.height - getTopMargin((_e = this.getConfig()) === null || _e === undefined ? undefined : _e.label) - getBottomMargin((_f = this.getConfig()) === null || _f === undefined ? undefined : _f.label);
|
|
2517
2545
|
this.label.updateInView();
|
|
2518
2546
|
}
|
|
2519
2547
|
// Move decorators to match the new coords.
|
|
@@ -2547,11 +2575,11 @@ class DiagramSectionSet extends DiagramElementSet {
|
|
|
2547
2575
|
node.sections.push(section);
|
|
2548
2576
|
node.updateInView();
|
|
2549
2577
|
// add section ports
|
|
2550
|
-
const sectionPorts = (_d = (_c = (_b = (_a = node.type.sectionGrid) === null || _a ===
|
|
2578
|
+
const sectionPorts = (_d = (_c = (_b = (_a = node.type.sectionGrid) === null || _a === undefined ? undefined : _a.sections) === null || _b === undefined ? undefined : _b[indexYInNode]) === null || _c === undefined ? undefined : _c[indexXInNode]) === null || _d === undefined ? undefined : _d.ports;
|
|
2551
2579
|
if (sectionPorts && sectionPorts.length > 0) {
|
|
2552
2580
|
for (let i = 0; i < sectionPorts.length; ++i) {
|
|
2553
2581
|
const portConfig = sectionPorts[i];
|
|
2554
|
-
const port = this.model.ports.new(section, [section.coords[0] + (((_e = portConfig === null || portConfig ===
|
|
2582
|
+
const port = this.model.ports.new(section, [section.coords[0] + (((_e = portConfig === null || portConfig === undefined ? undefined : portConfig.coords) === null || _e === undefined ? undefined : _e[0]) || 0), section.coords[1] + (((_f = portConfig === null || portConfig === undefined ? undefined : portConfig.coords) === null || _f === undefined ? undefined : _f[1]) || 0)], portConfig === null || portConfig === undefined ? undefined : portConfig.direction, `${section.id}_${i}`);
|
|
2555
2583
|
if (portConfig.label) {
|
|
2556
2584
|
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), portConfig.label);
|
|
2557
2585
|
let labelCoords;
|
|
@@ -2574,7 +2602,7 @@ class DiagramSectionSet extends DiagramElementSet {
|
|
|
2574
2602
|
}
|
|
2575
2603
|
}
|
|
2576
2604
|
// add section label
|
|
2577
|
-
const sectionLabel = (_k = (_j = (_h = (_g = node.type.sectionGrid) === null || _g ===
|
|
2605
|
+
const sectionLabel = (_k = (_j = (_h = (_g = node.type.sectionGrid) === null || _g === undefined ? undefined : _g.sections) === null || _h === undefined ? undefined : _h[indexYInNode]) === null || _j === undefined ? undefined : _j[indexXInNode]) === null || _k === undefined ? undefined : _k.label;
|
|
2578
2606
|
if (sectionLabel) {
|
|
2579
2607
|
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), sectionLabel);
|
|
2580
2608
|
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);
|
|
@@ -2630,11 +2658,14 @@ const DIAGRAM_NODE_TYPE_DEFAULTS = {
|
|
|
2630
2658
|
minHeight: 1,
|
|
2631
2659
|
resizableX: false,
|
|
2632
2660
|
resizableY: false,
|
|
2661
|
+
padding: 0,
|
|
2633
2662
|
label: null,
|
|
2634
2663
|
ports: [],
|
|
2635
2664
|
sectionGrid: null,
|
|
2636
2665
|
look: DIAGRAM_NODE_LOOK_DEFAULTS,
|
|
2637
2666
|
isUnique: false,
|
|
2667
|
+
canBeParentless: true,
|
|
2668
|
+
childrenTypes: [],
|
|
2638
2669
|
priority: DEFAULT_PRIORITY,
|
|
2639
2670
|
properties: []
|
|
2640
2671
|
};
|
|
@@ -2654,13 +2685,19 @@ class DiagramNodeType {
|
|
|
2654
2685
|
this.minHeight = values.minHeight;
|
|
2655
2686
|
this.resizableX = values.resizableX;
|
|
2656
2687
|
this.resizableY = values.resizableY;
|
|
2688
|
+
this.bottomPadding = getBottomPadding(values);
|
|
2689
|
+
this.leftPadding = getLeftPadding(values);
|
|
2690
|
+
this.rightPadding = getRightPadding(values);
|
|
2691
|
+
this.topPadding = getTopPadding(values);
|
|
2657
2692
|
this.label = values.label;
|
|
2658
2693
|
this.ports = values.ports;
|
|
2659
2694
|
this.sectionGrid = values.sectionGrid;
|
|
2660
2695
|
this.look = values.look;
|
|
2661
2696
|
this.isUnique = values.isUnique;
|
|
2697
|
+
this.canBeParentless = values.canBeParentless;
|
|
2698
|
+
this.childrenTypes = values.childrenTypes;
|
|
2662
2699
|
this.priority = values.priority;
|
|
2663
|
-
this.propertySet = new PropertySet((options === null || options ===
|
|
2700
|
+
this.propertySet = new PropertySet((options === null || options === undefined ? undefined : options.properties) || []);
|
|
2664
2701
|
}
|
|
2665
2702
|
}
|
|
2666
2703
|
/**
|
|
@@ -2677,7 +2714,7 @@ class DiagramNode extends DiagramElement {
|
|
|
2677
2714
|
*/
|
|
2678
2715
|
get name() {
|
|
2679
2716
|
var _a;
|
|
2680
|
-
return ((_a = this.label) === null || _a ===
|
|
2717
|
+
return ((_a = this.label) === null || _a === undefined ? undefined : _a.text) || '';
|
|
2681
2718
|
}
|
|
2682
2719
|
set name(name) {
|
|
2683
2720
|
if (this.label) {
|
|
@@ -2689,6 +2726,11 @@ class DiagramNode extends DiagramElement {
|
|
|
2689
2726
|
throw new Error(`DiagramNode with id "${id}" already exists`);
|
|
2690
2727
|
}
|
|
2691
2728
|
super(model, id);
|
|
2729
|
+
/**
|
|
2730
|
+
* Nodes contained within this node.
|
|
2731
|
+
* @public
|
|
2732
|
+
*/
|
|
2733
|
+
this.children = [];
|
|
2692
2734
|
/**
|
|
2693
2735
|
* Sections of this node.
|
|
2694
2736
|
* @public
|
|
@@ -2705,7 +2747,7 @@ class DiagramNode extends DiagramElement {
|
|
|
2705
2747
|
*/
|
|
2706
2748
|
this.decorators = [];
|
|
2707
2749
|
/**
|
|
2708
|
-
* Collaborative timestamp for
|
|
2750
|
+
* Collaborative timestamp for MoveCollabAction, SetGeometryCollabAction and SetParentCollabAction.
|
|
2709
2751
|
* @public
|
|
2710
2752
|
*/
|
|
2711
2753
|
this.geometryTimestamp = null;
|
|
@@ -2721,7 +2763,26 @@ class DiagramNode extends DiagramElement {
|
|
|
2721
2763
|
}
|
|
2722
2764
|
updateInView() {
|
|
2723
2765
|
var _a;
|
|
2724
|
-
(_a = this.model.canvas) === null || _a ===
|
|
2766
|
+
(_a = this.model.canvas) === null || _a === undefined ? undefined : _a.updateNodesInView(this.id);
|
|
2767
|
+
}
|
|
2768
|
+
raise() {
|
|
2769
|
+
var _a;
|
|
2770
|
+
(_a = this.select()) === null || _a === undefined ? undefined : _a.raise();
|
|
2771
|
+
if (this.label) {
|
|
2772
|
+
this.label.raise();
|
|
2773
|
+
}
|
|
2774
|
+
for (const port of this.ports) {
|
|
2775
|
+
port.raise();
|
|
2776
|
+
}
|
|
2777
|
+
for (const section of this.sections) {
|
|
2778
|
+
section.raise();
|
|
2779
|
+
}
|
|
2780
|
+
for (const decorator of this.decorators) {
|
|
2781
|
+
decorator.raise();
|
|
2782
|
+
}
|
|
2783
|
+
for (const child of this.children) {
|
|
2784
|
+
child.raise();
|
|
2785
|
+
}
|
|
2725
2786
|
}
|
|
2726
2787
|
getPriority() {
|
|
2727
2788
|
return this.type.priority;
|
|
@@ -2813,7 +2874,7 @@ class DiagramNode extends DiagramElement {
|
|
|
2813
2874
|
if (!includeRemoved && incomingConnection.removed) {
|
|
2814
2875
|
continue;
|
|
2815
2876
|
}
|
|
2816
|
-
const otherNode = (_a = incomingConnection.start) === null || _a ===
|
|
2877
|
+
const otherNode = (_a = incomingConnection.start) === null || _a === undefined ? undefined : _a.getNode();
|
|
2817
2878
|
if (otherNode) {
|
|
2818
2879
|
if (!includeRemoved && otherNode.removed) {
|
|
2819
2880
|
continue;
|
|
@@ -2825,7 +2886,7 @@ class DiagramNode extends DiagramElement {
|
|
|
2825
2886
|
if (!includeRemoved && outgoingConnection.removed) {
|
|
2826
2887
|
continue;
|
|
2827
2888
|
}
|
|
2828
|
-
const otherNode = (_b = outgoingConnection.end) === null || _b ===
|
|
2889
|
+
const otherNode = (_b = outgoingConnection.end) === null || _b === undefined ? undefined : _b.getNode();
|
|
2829
2890
|
if (otherNode) {
|
|
2830
2891
|
if (!includeRemoved && otherNode.removed) {
|
|
2831
2892
|
continue;
|
|
@@ -2836,6 +2897,94 @@ class DiagramNode extends DiagramElement {
|
|
|
2836
2897
|
}
|
|
2837
2898
|
return result;
|
|
2838
2899
|
}
|
|
2900
|
+
/**
|
|
2901
|
+
* Return the ancestor of this node which has no ancestors. If this node has no ancestors, returns itself.
|
|
2902
|
+
* @returns The ancestor of this node which has no ancestors.
|
|
2903
|
+
*/
|
|
2904
|
+
getLastAncestor() {
|
|
2905
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
2906
|
+
let node = this;
|
|
2907
|
+
while (node.parent !== undefined) {
|
|
2908
|
+
node = node === null || node === undefined ? undefined : node.parent;
|
|
2909
|
+
}
|
|
2910
|
+
return node;
|
|
2911
|
+
}
|
|
2912
|
+
/**
|
|
2913
|
+
* Return true if this node is among the ancestors of the given node.
|
|
2914
|
+
* @param child A node.
|
|
2915
|
+
* @returns `true` if this node is among the ancestors of the given node, `false` otherwise.
|
|
2916
|
+
*/
|
|
2917
|
+
isAncestorOf(child) {
|
|
2918
|
+
let node = child;
|
|
2919
|
+
while (node !== undefined) {
|
|
2920
|
+
if (this.id === node.id) {
|
|
2921
|
+
return true;
|
|
2922
|
+
}
|
|
2923
|
+
node = node.parent;
|
|
2924
|
+
}
|
|
2925
|
+
return false;
|
|
2926
|
+
}
|
|
2927
|
+
/**
|
|
2928
|
+
* Return true if the given node is among the ancestors of this node.
|
|
2929
|
+
* @param child A node.
|
|
2930
|
+
* @returns `true` if the given node is among the ancestors of this node, `false` otherwise.
|
|
2931
|
+
*/
|
|
2932
|
+
isDescendantOf(child) {
|
|
2933
|
+
return child.isAncestorOf(this);
|
|
2934
|
+
}
|
|
2935
|
+
addChild(child) {
|
|
2936
|
+
if (child.id === this.id) {
|
|
2937
|
+
// do nothing; a node can't be its own child
|
|
2938
|
+
return;
|
|
2939
|
+
}
|
|
2940
|
+
let node = this.parent;
|
|
2941
|
+
let isChildParentOfThis = false;
|
|
2942
|
+
while (node !== undefined) {
|
|
2943
|
+
if (node.id === child.id) {
|
|
2944
|
+
isChildParentOfThis = true;
|
|
2945
|
+
break;
|
|
2946
|
+
}
|
|
2947
|
+
node = node.parent;
|
|
2948
|
+
}
|
|
2949
|
+
if (isChildParentOfThis) {
|
|
2950
|
+
// do nothing; a node can't be its own ancestor
|
|
2951
|
+
return;
|
|
2952
|
+
}
|
|
2953
|
+
if (this.children.indexOf(child) >= 0) {
|
|
2954
|
+
// do nothing, child is already among the node's children
|
|
2955
|
+
return;
|
|
2956
|
+
}
|
|
2957
|
+
this.fitToChild(child);
|
|
2958
|
+
this.children.push(child);
|
|
2959
|
+
child.parent = this;
|
|
2960
|
+
child.raise();
|
|
2961
|
+
}
|
|
2962
|
+
removeChild(child) {
|
|
2963
|
+
removeIfExists(this.children, child);
|
|
2964
|
+
child.parent = undefined;
|
|
2965
|
+
}
|
|
2966
|
+
fitToChild(child) {
|
|
2967
|
+
const excessLeft = this.coords[0] - child.coords[0] + this.type.leftPadding;
|
|
2968
|
+
if (excessLeft >= 0) {
|
|
2969
|
+
this.stretch(exports.Side.Left, excessLeft);
|
|
2970
|
+
}
|
|
2971
|
+
const excessTop = this.coords[1] - child.coords[1] + this.type.topPadding;
|
|
2972
|
+
if (excessTop >= 0) {
|
|
2973
|
+
this.stretch(exports.Side.Top, excessTop);
|
|
2974
|
+
}
|
|
2975
|
+
const excessRight = child.coords[0] + child.width - (this.coords[0] + this.width) + this.type.rightPadding;
|
|
2976
|
+
if (excessRight >= 0) {
|
|
2977
|
+
this.stretch(exports.Side.Right, excessRight);
|
|
2978
|
+
}
|
|
2979
|
+
const excessBottom = child.coords[1] + child.height - (this.coords[1] + this.height) + this.type.bottomPadding;
|
|
2980
|
+
if (excessBottom >= 0) {
|
|
2981
|
+
this.stretch(exports.Side.Bottom, excessBottom);
|
|
2982
|
+
}
|
|
2983
|
+
if (this.parent) {
|
|
2984
|
+
// ensure this node also fits inside its parent after stretching
|
|
2985
|
+
this.parent.fitToChild(this);
|
|
2986
|
+
}
|
|
2987
|
+
}
|
|
2839
2988
|
/**
|
|
2840
2989
|
* Change the coordinates of this node to the given coordinates and move its sections, ports and labels correspondingly.
|
|
2841
2990
|
* @public
|
|
@@ -2843,6 +2992,9 @@ class DiagramNode extends DiagramElement {
|
|
|
2843
2992
|
*/
|
|
2844
2993
|
move(coords) {
|
|
2845
2994
|
const coordDifferences = [coords[0] - this.coords[0], coords[1] - this.coords[1]];
|
|
2995
|
+
for (const child of this.children) {
|
|
2996
|
+
child.move([child.coords[0] + coordDifferences[0], child.coords[1] + coordDifferences[1]]);
|
|
2997
|
+
}
|
|
2846
2998
|
for (const section of this.sections) {
|
|
2847
2999
|
section.move([section.coords[0] + coordDifferences[0], section.coords[1] + coordDifferences[1]]);
|
|
2848
3000
|
}
|
|
@@ -2851,7 +3003,9 @@ class DiagramNode extends DiagramElement {
|
|
|
2851
3003
|
width: this.width,
|
|
2852
3004
|
height: this.height,
|
|
2853
3005
|
// We already moved the sections above - skip changing them in setDimensions.
|
|
2854
|
-
sections: {}
|
|
3006
|
+
sections: {},
|
|
3007
|
+
// We don't change the children when stretching
|
|
3008
|
+
children: {}
|
|
2855
3009
|
});
|
|
2856
3010
|
}
|
|
2857
3011
|
/**
|
|
@@ -2900,7 +3054,9 @@ class DiagramNode extends DiagramElement {
|
|
|
2900
3054
|
width: newCoordsX[1] - newCoordsX[0],
|
|
2901
3055
|
height: newCoordsY[1] - newCoordsY[0],
|
|
2902
3056
|
// we ignore this.sections, the stretching of a node with sections is handled in the stretchSections method
|
|
2903
|
-
sections: {}
|
|
3057
|
+
sections: {},
|
|
3058
|
+
// we ignore this.children
|
|
3059
|
+
children: {}
|
|
2904
3060
|
});
|
|
2905
3061
|
}
|
|
2906
3062
|
/**
|
|
@@ -2989,16 +3145,23 @@ class DiagramNode extends DiagramElement {
|
|
|
2989
3145
|
* Returns the current values of all geometric properties (coordinates and dimensions) of this node and its sections.
|
|
2990
3146
|
* @public
|
|
2991
3147
|
*/
|
|
2992
|
-
getGeometry() {
|
|
3148
|
+
getGeometry(excludeId) {
|
|
2993
3149
|
const sections = {};
|
|
2994
3150
|
for (const section of this.sections) {
|
|
2995
3151
|
sections[section.id] = section.getGeometry();
|
|
2996
3152
|
}
|
|
3153
|
+
const children = {};
|
|
3154
|
+
for (const child of this.children) {
|
|
3155
|
+
if (child.id !== excludeId) {
|
|
3156
|
+
children[child.id] = child.getGeometry(excludeId);
|
|
3157
|
+
}
|
|
3158
|
+
}
|
|
2997
3159
|
return {
|
|
2998
3160
|
coords: [...this.coords],
|
|
2999
3161
|
width: this.width,
|
|
3000
3162
|
height: this.height,
|
|
3001
|
-
sections
|
|
3163
|
+
sections,
|
|
3164
|
+
children
|
|
3002
3165
|
};
|
|
3003
3166
|
}
|
|
3004
3167
|
/**
|
|
@@ -3006,6 +3169,7 @@ class DiagramNode extends DiagramElement {
|
|
|
3006
3169
|
* @public
|
|
3007
3170
|
*/
|
|
3008
3171
|
setGeometry(geometry) {
|
|
3172
|
+
this.raise();
|
|
3009
3173
|
const oldCoordsX = [this.coords[0], this.coords[0] + this.width];
|
|
3010
3174
|
const oldCoordsY = [this.coords[1], this.coords[1] + this.height];
|
|
3011
3175
|
this.coords = [...geometry.coords];
|
|
@@ -3013,6 +3177,13 @@ class DiagramNode extends DiagramElement {
|
|
|
3013
3177
|
this.height = geometry.height;
|
|
3014
3178
|
const newCoordsX = [this.coords[0], this.coords[0] + this.width];
|
|
3015
3179
|
const newCoordsY = [this.coords[1], this.coords[1] + this.height];
|
|
3180
|
+
// Update children, if supplied.
|
|
3181
|
+
for (const child of this.children) {
|
|
3182
|
+
const childGeometry = geometry.children[child.id];
|
|
3183
|
+
if (childGeometry) {
|
|
3184
|
+
child.setGeometry(childGeometry);
|
|
3185
|
+
}
|
|
3186
|
+
}
|
|
3016
3187
|
// Update sections, if supplied.
|
|
3017
3188
|
for (const section of this.sections) {
|
|
3018
3189
|
const sectionGeometry = geometry.sections[section.id];
|
|
@@ -3084,10 +3255,10 @@ class DiagramNodeSet extends DiagramElementSet {
|
|
|
3084
3255
|
for (let j = 0; j < nodeType.sectionGrid.sections.length; ++j) {
|
|
3085
3256
|
let widthAccumulator = node.coords[0] + (nodeType.sectionGrid.margin || 0);
|
|
3086
3257
|
for (let i = 0; i < nodeType.sectionGrid.sections[j].length; ++i) {
|
|
3087
|
-
this.model.sections.new(node, i, j, [widthAccumulator, heightAccumulator], ((_a = nodeType.sectionGrid.defaultWidths) === null || _a ===
|
|
3088
|
-
widthAccumulator += (((_c = nodeType.sectionGrid.defaultWidths) === null || _c ===
|
|
3258
|
+
this.model.sections.new(node, i, j, [widthAccumulator, heightAccumulator], ((_a = nodeType.sectionGrid.defaultWidths) === null || _a === undefined ? undefined : _a[i]) || DIAGRAM_SECTION_DEFAULT_WIDTH, ((_b = nodeType.sectionGrid.defaultHeights) === null || _b === undefined ? undefined : _b[j]) || DIAGRAM_SECTION_DEFAULT_HEIGHT, `${node.id}_${j}_${i}`);
|
|
3259
|
+
widthAccumulator += (((_c = nodeType.sectionGrid.defaultWidths) === null || _c === undefined ? undefined : _c[i]) || DIAGRAM_SECTION_DEFAULT_WIDTH) + (nodeType.sectionGrid.margin || 0);
|
|
3089
3260
|
}
|
|
3090
|
-
heightAccumulator += (((_d = nodeType.sectionGrid.defaultHeights) === null || _d ===
|
|
3261
|
+
heightAccumulator += (((_d = nodeType.sectionGrid.defaultHeights) === null || _d === undefined ? undefined : _d[j]) || DIAGRAM_SECTION_DEFAULT_HEIGHT) + (nodeType.sectionGrid.margin || 0);
|
|
3091
3262
|
}
|
|
3092
3263
|
}
|
|
3093
3264
|
// add node ports
|
|
@@ -3122,12 +3293,20 @@ class DiagramNodeSet extends DiagramElementSet {
|
|
|
3122
3293
|
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);
|
|
3123
3294
|
}
|
|
3124
3295
|
node.valueSet.resetValues();
|
|
3125
|
-
(_e = node.model.canvas) === null || _e ===
|
|
3296
|
+
(_e = node.model.canvas) === null || _e === undefined ? undefined : _e.fitNodeInView(node.id);
|
|
3126
3297
|
return node;
|
|
3127
3298
|
}
|
|
3128
3299
|
remove(id) {
|
|
3129
3300
|
const node = this.get(id, true);
|
|
3130
3301
|
if (node) {
|
|
3302
|
+
// remove from parent
|
|
3303
|
+
if (node.parent) {
|
|
3304
|
+
removeIfExists(node.parent.children, node);
|
|
3305
|
+
}
|
|
3306
|
+
// remove all children
|
|
3307
|
+
while (node.children.length > 0) {
|
|
3308
|
+
this.model.nodes.remove(node.children[0].id);
|
|
3309
|
+
}
|
|
3131
3310
|
// remove all sections
|
|
3132
3311
|
while (node.sections.length > 0) {
|
|
3133
3312
|
this.model.sections.remove(node.sections[0].id);
|
|
@@ -3150,7 +3329,137 @@ class DiagramNodeSet extends DiagramElementSet {
|
|
|
3150
3329
|
node.updateInView();
|
|
3151
3330
|
}
|
|
3152
3331
|
}
|
|
3332
|
+
/**
|
|
3333
|
+
* Gets all the nodes that overlap with the given coordinates.
|
|
3334
|
+
* @public
|
|
3335
|
+
* @param x A coordinate along the x axis.
|
|
3336
|
+
* @param y A coordinate along the y axis.
|
|
3337
|
+
* @returns All the nodes that overlap with the given coordinates.
|
|
3338
|
+
*/
|
|
3339
|
+
getAtCoordinates(x, y) {
|
|
3340
|
+
const nodesAtLocation = [];
|
|
3341
|
+
for (const node of this) {
|
|
3342
|
+
if (node.coords[0] < x && x < node.coords[0] + node.width && node.coords[1] < y && y < node.coords[1] + node.height) {
|
|
3343
|
+
nodesAtLocation.push(node);
|
|
3344
|
+
}
|
|
3345
|
+
}
|
|
3346
|
+
return nodesAtLocation;
|
|
3347
|
+
}
|
|
3153
3348
|
}
|
|
3349
|
+
/**
|
|
3350
|
+
* Removes any nodes from the given list which are a descendant of another node in the list.
|
|
3351
|
+
* @param nodes A list of nodes.
|
|
3352
|
+
* @returns The given list of nodes minus any node that is a descendant of another node in the list.
|
|
3353
|
+
*/
|
|
3354
|
+
const filterByOnlyAncestors = nodes => {
|
|
3355
|
+
for (let i = 0; i < nodes.length; ++i) {
|
|
3356
|
+
for (let j = 0; j < nodes.length; ++j) {
|
|
3357
|
+
if (j !== i && nodes[j].isDescendantOf(nodes[i])) {
|
|
3358
|
+
nodes.splice(j, 1);
|
|
3359
|
+
--j;
|
|
3360
|
+
if (i > j) {
|
|
3361
|
+
--i;
|
|
3362
|
+
}
|
|
3363
|
+
}
|
|
3364
|
+
}
|
|
3365
|
+
}
|
|
3366
|
+
return nodes;
|
|
3367
|
+
};
|
|
3368
|
+
/**
|
|
3369
|
+
* Removes any nodes from the given list which are an ancestor of another node in the list.
|
|
3370
|
+
* @param nodes A list of nodes.
|
|
3371
|
+
* @returns The given list of nodes minus any node that is an ancestor of another node in the list.
|
|
3372
|
+
*/
|
|
3373
|
+
const filterByOnlyDescendants = nodes => {
|
|
3374
|
+
for (let i = 0; i < nodes.length; ++i) {
|
|
3375
|
+
for (let j = 0; j < nodes.length; ++j) {
|
|
3376
|
+
if (j !== i && nodes[j].isAncestorOf(nodes[i])) {
|
|
3377
|
+
nodes.splice(j, 1);
|
|
3378
|
+
--j;
|
|
3379
|
+
if (i > j) {
|
|
3380
|
+
--i;
|
|
3381
|
+
}
|
|
3382
|
+
}
|
|
3383
|
+
}
|
|
3384
|
+
}
|
|
3385
|
+
return nodes;
|
|
3386
|
+
};
|
|
3387
|
+
const getBottomPadding = config => {
|
|
3388
|
+
if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
|
|
3389
|
+
return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
|
|
3390
|
+
} else if (typeof config.padding === 'number') {
|
|
3391
|
+
return config.padding;
|
|
3392
|
+
} else {
|
|
3393
|
+
if (config.padding.length === 0) {
|
|
3394
|
+
return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
|
|
3395
|
+
} else if (config.padding.length === 1) {
|
|
3396
|
+
return config.padding[0];
|
|
3397
|
+
} else if (config.padding.length === 2) {
|
|
3398
|
+
return config.padding[0];
|
|
3399
|
+
} else if (config.padding.length === 3) {
|
|
3400
|
+
return config.padding[2];
|
|
3401
|
+
} else {
|
|
3402
|
+
return config.padding[2];
|
|
3403
|
+
}
|
|
3404
|
+
}
|
|
3405
|
+
};
|
|
3406
|
+
const getLeftPadding = config => {
|
|
3407
|
+
if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
|
|
3408
|
+
return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
|
|
3409
|
+
} else if (typeof config.padding === 'number') {
|
|
3410
|
+
return config.padding;
|
|
3411
|
+
} else {
|
|
3412
|
+
if (config.padding.length === 0) {
|
|
3413
|
+
return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
|
|
3414
|
+
} else if (config.padding.length === 1) {
|
|
3415
|
+
return config.padding[0];
|
|
3416
|
+
} else if (config.padding.length === 2) {
|
|
3417
|
+
return config.padding[1];
|
|
3418
|
+
} else if (config.padding.length === 3) {
|
|
3419
|
+
return config.padding[1];
|
|
3420
|
+
} else {
|
|
3421
|
+
return config.padding[3];
|
|
3422
|
+
}
|
|
3423
|
+
}
|
|
3424
|
+
};
|
|
3425
|
+
const getRightPadding = config => {
|
|
3426
|
+
if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
|
|
3427
|
+
return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
|
|
3428
|
+
} else if (typeof config.padding === 'number') {
|
|
3429
|
+
return config.padding;
|
|
3430
|
+
} else {
|
|
3431
|
+
if (config.padding.length === 0) {
|
|
3432
|
+
return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
|
|
3433
|
+
} else if (config.padding.length === 1) {
|
|
3434
|
+
return config.padding[0];
|
|
3435
|
+
} else if (config.padding.length === 2) {
|
|
3436
|
+
return config.padding[1];
|
|
3437
|
+
} else if (config.padding.length === 3) {
|
|
3438
|
+
return config.padding[1];
|
|
3439
|
+
} else {
|
|
3440
|
+
return config.padding[1];
|
|
3441
|
+
}
|
|
3442
|
+
}
|
|
3443
|
+
};
|
|
3444
|
+
const getTopPadding = config => {
|
|
3445
|
+
if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
|
|
3446
|
+
return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
|
|
3447
|
+
} else if (typeof config.padding === 'number') {
|
|
3448
|
+
return config.padding;
|
|
3449
|
+
} else {
|
|
3450
|
+
if (config.padding.length === 0) {
|
|
3451
|
+
return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
|
|
3452
|
+
} else if (config.padding.length === 1) {
|
|
3453
|
+
return config.padding[0];
|
|
3454
|
+
} else if (config.padding.length === 2) {
|
|
3455
|
+
return config.padding[0];
|
|
3456
|
+
} else if (config.padding.length === 3) {
|
|
3457
|
+
return config.padding[0];
|
|
3458
|
+
} else {
|
|
3459
|
+
return config.padding[0];
|
|
3460
|
+
}
|
|
3461
|
+
}
|
|
3462
|
+
};
|
|
3154
3463
|
|
|
3155
3464
|
/**
|
|
3156
3465
|
* Default values of the parameters of a diagram port.
|
|
@@ -3194,7 +3503,17 @@ class DiagramPort extends DiagramElement {
|
|
|
3194
3503
|
}
|
|
3195
3504
|
updateInView() {
|
|
3196
3505
|
var _a;
|
|
3197
|
-
(_a = this.model.canvas) === null || _a ===
|
|
3506
|
+
(_a = this.model.canvas) === null || _a === undefined ? undefined : _a.updatePortsInView(this.id);
|
|
3507
|
+
}
|
|
3508
|
+
raise() {
|
|
3509
|
+
var _a;
|
|
3510
|
+
(_a = this.select()) === null || _a === undefined ? undefined : _a.raise();
|
|
3511
|
+
for (const connection of this.incomingConnections) {
|
|
3512
|
+
connection.raise();
|
|
3513
|
+
}
|
|
3514
|
+
for (const connection of this.outgoingConnections) {
|
|
3515
|
+
connection.raise();
|
|
3516
|
+
}
|
|
3198
3517
|
}
|
|
3199
3518
|
/**
|
|
3200
3519
|
* Add a connection to this port's list of outgoing connections.
|
|
@@ -3227,7 +3546,7 @@ class DiagramPort extends DiagramElement {
|
|
|
3227
3546
|
}
|
|
3228
3547
|
getPriority() {
|
|
3229
3548
|
var _a;
|
|
3230
|
-
return ((_a = this.rootElement) === null || _a ===
|
|
3549
|
+
return ((_a = this.rootElement) === null || _a === undefined ? undefined : _a.getPriority()) || DEFAULT_PRIORITY;
|
|
3231
3550
|
}
|
|
3232
3551
|
/**
|
|
3233
3552
|
* Change the coordinates of this port to the given coordinates and move its labels correspondingly.
|
|
@@ -3333,7 +3652,7 @@ class DagaImporter {
|
|
|
3333
3652
|
return model;
|
|
3334
3653
|
}
|
|
3335
3654
|
importNode(model, node) {
|
|
3336
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
3655
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
3337
3656
|
const newNodeType = model.nodes.types.get(node.type);
|
|
3338
3657
|
if (newNodeType) {
|
|
3339
3658
|
const newNode = new DiagramNode(model, newNodeType, node.coords, node.id);
|
|
@@ -3351,14 +3670,21 @@ class DagaImporter {
|
|
|
3351
3670
|
newField.updateInView();
|
|
3352
3671
|
}
|
|
3353
3672
|
}
|
|
3673
|
+
for (const child of node.children || []) {
|
|
3674
|
+
const newChild = this.importNode(model, child);
|
|
3675
|
+
if (newChild !== undefined) {
|
|
3676
|
+
(_a = newNode.children) === null || _a === undefined ? undefined : _a.push(newChild);
|
|
3677
|
+
newChild.parent = newNode;
|
|
3678
|
+
}
|
|
3679
|
+
}
|
|
3354
3680
|
for (const section of node.sections || []) {
|
|
3355
3681
|
const newSection = new DiagramSection(model, newNode, section.indexXInNode, section.indexYInNode, section.coords, section.width, section.height, section.id);
|
|
3356
|
-
(
|
|
3682
|
+
(_b = newNode.sections) === null || _b === undefined ? undefined : _b.push(newSection);
|
|
3357
3683
|
model.sections.add(newSection);
|
|
3358
3684
|
if (section.label) {
|
|
3359
3685
|
// add section label
|
|
3360
|
-
if ((
|
|
3361
|
-
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (
|
|
3686
|
+
if ((_f = (_e = (_d = (_c = newNodeType.sectionGrid) === null || _c === undefined ? undefined : _c.sections) === null || _d === undefined ? undefined : _d[section.indexYInNode]) === null || _e === undefined ? undefined : _e[section.indexXInNode]) === null || _f === undefined ? undefined : _f.label) {
|
|
3687
|
+
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_k = (_j = (_h = (_g = newNodeType.sectionGrid) === null || _g === undefined ? undefined : _g.sections) === null || _h === undefined ? undefined : _h[section.indexYInNode]) === null || _j === undefined ? undefined : _j[section.indexXInNode]) === null || _k === undefined ? undefined : _k.label);
|
|
3362
3688
|
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);
|
|
3363
3689
|
newField.text = section.label;
|
|
3364
3690
|
newSection.label = newField;
|
|
@@ -3503,16 +3829,21 @@ class DagaImporter {
|
|
|
3503
3829
|
* @see AddNodeAction
|
|
3504
3830
|
*/
|
|
3505
3831
|
class AddNodeCollabAction {
|
|
3506
|
-
constructor(canvas, id, typeId, coords, label, values) {
|
|
3832
|
+
constructor(canvas, id, typeId, coords, parentId, label, values) {
|
|
3507
3833
|
this.canvas = canvas;
|
|
3508
3834
|
this.id = id;
|
|
3509
3835
|
this.typeId = typeId;
|
|
3510
3836
|
this.coords = coords;
|
|
3837
|
+
this.parentId = parentId;
|
|
3511
3838
|
this.label = label;
|
|
3512
3839
|
this.values = values;
|
|
3513
3840
|
}
|
|
3514
3841
|
do() {
|
|
3842
|
+
var _a;
|
|
3515
3843
|
const node = this.canvas.model.nodes.new(this.typeId, this.coords, this.id);
|
|
3844
|
+
if (this.parentId !== undefined) {
|
|
3845
|
+
(_a = this.canvas.model.nodes.get(this.parentId)) === null || _a === undefined ? undefined : _a.addChild(node);
|
|
3846
|
+
}
|
|
3516
3847
|
if (this.values !== undefined) {
|
|
3517
3848
|
node.valueSet.setValues(structuredClone(Object.assign(Object.assign({}, node.valueSet.getValues()), this.values)));
|
|
3518
3849
|
}
|
|
@@ -3526,12 +3857,45 @@ class AddNodeCollabAction {
|
|
|
3526
3857
|
id: this.id,
|
|
3527
3858
|
typeId: this.typeId,
|
|
3528
3859
|
coords: this.coords,
|
|
3860
|
+
parentId: this.parentId,
|
|
3529
3861
|
label: this.label,
|
|
3530
3862
|
values: this.values
|
|
3531
3863
|
};
|
|
3532
3864
|
}
|
|
3533
3865
|
static deserialize(canvas, serialized) {
|
|
3534
|
-
return new AddNodeCollabAction(canvas, serialized.id, serialized.typeId, serialized.coords, serialized.label, serialized.values);
|
|
3866
|
+
return new AddNodeCollabAction(canvas, serialized.id, serialized.typeId, serialized.coords, serialized.parentId, serialized.label, serialized.values);
|
|
3867
|
+
}
|
|
3868
|
+
}
|
|
3869
|
+
/**
|
|
3870
|
+
* Collaborative which consists of applying a layout to the diagram which can change the location of several nodes.
|
|
3871
|
+
* @private
|
|
3872
|
+
* @see ApplyLayoutAction
|
|
3873
|
+
*/
|
|
3874
|
+
class ApplyLayoutCollabAction {
|
|
3875
|
+
constructor(canvas, to, timestamp) {
|
|
3876
|
+
this.canvas = canvas;
|
|
3877
|
+
this.to = to;
|
|
3878
|
+
this.timestamp = timestamp;
|
|
3879
|
+
}
|
|
3880
|
+
do() {
|
|
3881
|
+
for (const nodeId in this.to) {
|
|
3882
|
+
const node = this.canvas.model.nodes.get(nodeId, true);
|
|
3883
|
+
if (node && timestampWins(this.timestamp, node.geometryTimestamp)) {
|
|
3884
|
+
const point = this.to[nodeId];
|
|
3885
|
+
node.move([point[0], point[1]]);
|
|
3886
|
+
node.geometryTimestamp = this.timestamp;
|
|
3887
|
+
}
|
|
3888
|
+
}
|
|
3889
|
+
}
|
|
3890
|
+
serialize() {
|
|
3891
|
+
return {
|
|
3892
|
+
type: 'applyLayout',
|
|
3893
|
+
to: this.to,
|
|
3894
|
+
timestamp: this.timestamp
|
|
3895
|
+
};
|
|
3896
|
+
}
|
|
3897
|
+
static deserialize(canvas, serialized) {
|
|
3898
|
+
return new ApplyLayoutCollabAction(canvas, serialized.to, serialized.timestamp);
|
|
3535
3899
|
}
|
|
3536
3900
|
}
|
|
3537
3901
|
/**
|
|
@@ -3547,10 +3911,12 @@ class MoveCollabAction {
|
|
|
3547
3911
|
this.timestamp = timestamp;
|
|
3548
3912
|
}
|
|
3549
3913
|
do() {
|
|
3914
|
+
var _a;
|
|
3550
3915
|
for (const nodeId of this.nodeIds) {
|
|
3551
3916
|
const node = this.canvas.model.nodes.get(nodeId, true);
|
|
3552
3917
|
if (node && timestampWins(this.timestamp, node.geometryTimestamp)) {
|
|
3553
3918
|
node.move([node.coords[0] + this.delta[0], node.coords[1] + this.delta[1]]);
|
|
3919
|
+
(_a = node.parent) === null || _a === undefined ? undefined : _a.fitToChild(node);
|
|
3554
3920
|
node.geometryTimestamp = this.timestamp;
|
|
3555
3921
|
}
|
|
3556
3922
|
}
|
|
@@ -3580,19 +3946,20 @@ class SetGeometryCollabAction {
|
|
|
3580
3946
|
this.timestamp = timestamp;
|
|
3581
3947
|
}
|
|
3582
3948
|
do() {
|
|
3583
|
-
var _a, _b;
|
|
3949
|
+
var _a, _b, _c;
|
|
3584
3950
|
const node = this.canvas.model.nodes.get(this.nodeId, true);
|
|
3585
3951
|
if (node && timestampWins(this.timestamp, node.geometryTimestamp)) {
|
|
3586
3952
|
node.setGeometry(this.to);
|
|
3587
3953
|
// Re-fit the labels, in case their text has changed since `this.to` was measured.
|
|
3588
|
-
if ((_a = node.label) === null || _a ===
|
|
3954
|
+
if ((_a = node.label) === null || _a === undefined ? undefined : _a.fit) {
|
|
3589
3955
|
this.canvas.fitFieldRootInView(node.label.id);
|
|
3590
3956
|
}
|
|
3591
3957
|
for (const section of node.sections) {
|
|
3592
|
-
if ((_b = section.label) === null || _b ===
|
|
3958
|
+
if ((_b = section.label) === null || _b === undefined ? undefined : _b.fit) {
|
|
3593
3959
|
this.canvas.fitFieldRootInView(section.label.id);
|
|
3594
3960
|
}
|
|
3595
3961
|
}
|
|
3962
|
+
(_c = node.parent) === null || _c === undefined ? undefined : _c.fitToChild(node);
|
|
3596
3963
|
node.geometryTimestamp = this.timestamp;
|
|
3597
3964
|
}
|
|
3598
3965
|
}
|
|
@@ -3608,6 +3975,42 @@ class SetGeometryCollabAction {
|
|
|
3608
3975
|
return new SetGeometryCollabAction(canvas, serialized.nodeId, serialized.to, serialized.timestamp);
|
|
3609
3976
|
}
|
|
3610
3977
|
}
|
|
3978
|
+
/**
|
|
3979
|
+
* Collaborative action which consists of setting a node's parent.
|
|
3980
|
+
* @private
|
|
3981
|
+
* @see SetParentAction
|
|
3982
|
+
*/
|
|
3983
|
+
class SetParentCollabAction {
|
|
3984
|
+
constructor(canvas, childId, parentId, childGeometry, timestamp) {
|
|
3985
|
+
this.canvas = canvas;
|
|
3986
|
+
this.childId = childId;
|
|
3987
|
+
this.parentId = parentId;
|
|
3988
|
+
this.childGeometry = childGeometry;
|
|
3989
|
+
this.timestamp = timestamp;
|
|
3990
|
+
}
|
|
3991
|
+
do() {
|
|
3992
|
+
var _a;
|
|
3993
|
+
const childNode = this.canvas.model.nodes.get(this.childId, true);
|
|
3994
|
+
const parentNode = this.parentId !== undefined ? this.canvas.model.nodes.get(this.parentId, true) : undefined;
|
|
3995
|
+
if (childNode && (this.parentId !== undefined ? parentNode : true) && timestampWins(this.timestamp, childNode.geometryTimestamp)) {
|
|
3996
|
+
(_a = childNode.parent) === null || _a === undefined ? undefined : _a.removeChild(childNode);
|
|
3997
|
+
childNode.setGeometry(this.childGeometry);
|
|
3998
|
+
parentNode === null || parentNode === undefined ? undefined : parentNode.addChild(childNode);
|
|
3999
|
+
}
|
|
4000
|
+
}
|
|
4001
|
+
serialize() {
|
|
4002
|
+
return {
|
|
4003
|
+
type: 'setParent',
|
|
4004
|
+
childId: this.childId,
|
|
4005
|
+
parentId: this.parentId,
|
|
4006
|
+
childGeometry: this.childGeometry,
|
|
4007
|
+
timestamp: this.timestamp
|
|
4008
|
+
};
|
|
4009
|
+
}
|
|
4010
|
+
static deserialize(canvas, serialized) {
|
|
4011
|
+
return new SetParentCollabAction(canvas, serialized.childId, serialized.parentId, serialized.childGeometry, serialized.timestamp);
|
|
4012
|
+
}
|
|
4013
|
+
}
|
|
3611
4014
|
/**
|
|
3612
4015
|
* Collaborative action which consists of adding a connection.
|
|
3613
4016
|
* @private
|
|
@@ -3689,12 +4092,12 @@ class UpdateValuesCollabAction {
|
|
|
3689
4092
|
if (this.id === undefined) {
|
|
3690
4093
|
return this.canvas.model.valueSet;
|
|
3691
4094
|
} else {
|
|
3692
|
-
return (_a = this.canvas.model.nodes.get(this.id, true) || this.canvas.model.connections.get(this.id, true)) === null || _a ===
|
|
4095
|
+
return (_a = this.canvas.model.nodes.get(this.id, true) || this.canvas.model.connections.get(this.id, true)) === null || _a === undefined ? undefined : _a.valueSet;
|
|
3693
4096
|
}
|
|
3694
4097
|
}
|
|
3695
4098
|
do() {
|
|
3696
4099
|
var _a;
|
|
3697
|
-
(_a = this.getValueSet()) === null || _a ===
|
|
4100
|
+
(_a = this.getValueSet()) === null || _a === undefined ? undefined : _a.overwriteValuesLww(this.to, this.timestamp);
|
|
3698
4101
|
}
|
|
3699
4102
|
serialize() {
|
|
3700
4103
|
return {
|
|
@@ -3879,6 +4282,12 @@ class CollabEngine {
|
|
|
3879
4282
|
action.do();
|
|
3880
4283
|
break;
|
|
3881
4284
|
}
|
|
4285
|
+
case 'applyLayout':
|
|
4286
|
+
{
|
|
4287
|
+
const action = ApplyLayoutCollabAction.deserialize(this.canvas, message);
|
|
4288
|
+
action.do();
|
|
4289
|
+
break;
|
|
4290
|
+
}
|
|
3882
4291
|
case 'move':
|
|
3883
4292
|
{
|
|
3884
4293
|
const action = MoveCollabAction.deserialize(this.canvas, message);
|
|
@@ -3891,6 +4300,12 @@ class CollabEngine {
|
|
|
3891
4300
|
action.do();
|
|
3892
4301
|
break;
|
|
3893
4302
|
}
|
|
4303
|
+
case 'setParent':
|
|
4304
|
+
{
|
|
4305
|
+
const action = SetParentCollabAction.deserialize(this.canvas, message);
|
|
4306
|
+
action.do();
|
|
4307
|
+
break;
|
|
4308
|
+
}
|
|
3894
4309
|
case 'addConnection':
|
|
3895
4310
|
{
|
|
3896
4311
|
const action = AddConnectionCollabAction.deserialize(this.canvas, message);
|
|
@@ -3931,7 +4346,7 @@ class CollabEngine {
|
|
|
3931
4346
|
}
|
|
3932
4347
|
|
|
3933
4348
|
/**
|
|
3934
|
-
* A stack of recent actions taken by the user
|
|
4349
|
+
* A stack of recent actions taken by the user.
|
|
3935
4350
|
* @private
|
|
3936
4351
|
*/
|
|
3937
4352
|
class ActionStack {
|
|
@@ -3956,37 +4371,60 @@ class ActionStack {
|
|
|
3956
4371
|
this.history.push(action);
|
|
3957
4372
|
++this.index;
|
|
3958
4373
|
}
|
|
3959
|
-
this.canvas.diagramChange$.next(
|
|
4374
|
+
this.canvas.diagramChange$.next({
|
|
4375
|
+
action,
|
|
4376
|
+
method: exports.DiagramActionMethod.Do
|
|
4377
|
+
});
|
|
3960
4378
|
}
|
|
3961
4379
|
/**
|
|
3962
4380
|
* Undoes the last action in the history, not counting undone actions.
|
|
3963
4381
|
* @private
|
|
3964
4382
|
*/
|
|
3965
4383
|
undo() {
|
|
4384
|
+
let action;
|
|
3966
4385
|
if (this.index > 0) {
|
|
3967
4386
|
let hasEffect;
|
|
3968
4387
|
do {
|
|
3969
4388
|
--this.index;
|
|
3970
|
-
|
|
4389
|
+
action = this.history[this.index];
|
|
4390
|
+
hasEffect = action.undo();
|
|
3971
4391
|
} while (!hasEffect && this.index > 0);
|
|
3972
4392
|
}
|
|
3973
|
-
this.canvas.diagramChange$.next(
|
|
4393
|
+
this.canvas.diagramChange$.next({
|
|
4394
|
+
action,
|
|
4395
|
+
method: exports.DiagramActionMethod.Undo
|
|
4396
|
+
});
|
|
3974
4397
|
}
|
|
3975
4398
|
/**
|
|
3976
4399
|
* Redoes the last undone action in the history.
|
|
3977
4400
|
* @private
|
|
3978
4401
|
*/
|
|
3979
4402
|
redo() {
|
|
4403
|
+
let action;
|
|
3980
4404
|
if (this.index < this.history.length) {
|
|
3981
4405
|
let hasEffect;
|
|
3982
4406
|
do {
|
|
3983
|
-
|
|
4407
|
+
action = this.history[this.index];
|
|
4408
|
+
hasEffect = action.redo();
|
|
3984
4409
|
++this.index;
|
|
3985
4410
|
} while (!hasEffect && this.index < this.history.length);
|
|
3986
4411
|
}
|
|
3987
|
-
this.canvas.diagramChange$.next(
|
|
4412
|
+
this.canvas.diagramChange$.next({
|
|
4413
|
+
action,
|
|
4414
|
+
method: exports.DiagramActionMethod.Redo
|
|
4415
|
+
});
|
|
3988
4416
|
}
|
|
3989
4417
|
}
|
|
4418
|
+
/**
|
|
4419
|
+
* The different methods of an action.
|
|
4420
|
+
* @private
|
|
4421
|
+
*/
|
|
4422
|
+
exports.DiagramActionMethod = void 0;
|
|
4423
|
+
(function (DiagramActionMethod) {
|
|
4424
|
+
DiagramActionMethod[DiagramActionMethod["Do"] = 0] = "Do";
|
|
4425
|
+
DiagramActionMethod[DiagramActionMethod["Undo"] = 1] = "Undo";
|
|
4426
|
+
DiagramActionMethod[DiagramActionMethod["Redo"] = 2] = "Redo";
|
|
4427
|
+
})(exports.DiagramActionMethod || (exports.DiagramActionMethod = {}));
|
|
3990
4428
|
/**
|
|
3991
4429
|
* Enum listing the actions that can be taken by the user.
|
|
3992
4430
|
* The actions can correspond to a DiagramAction that can be recorded in the action stack of a diagram or they may not correspond to any DiagramAction implementations.
|
|
@@ -4006,6 +4444,12 @@ exports.DiagramActions = void 0;
|
|
|
4006
4444
|
* @see AddNodeAction
|
|
4007
4445
|
*/
|
|
4008
4446
|
DiagramActions["AddNode"] = "add-node";
|
|
4447
|
+
/**
|
|
4448
|
+
* Action that corresponds to applying a layout which changes the location of several nodes.
|
|
4449
|
+
* @public
|
|
4450
|
+
* @see ApplyLayoutAction
|
|
4451
|
+
*/
|
|
4452
|
+
DiagramActions["ApplyLayout"] = "apply-layout";
|
|
4009
4453
|
/**
|
|
4010
4454
|
* Action that corresponds to copying diagram elements to the clipboard.
|
|
4011
4455
|
* @public
|
|
@@ -4071,17 +4515,25 @@ exports.DiagramActions = void 0;
|
|
|
4071
4515
|
* @see DiagramNode
|
|
4072
4516
|
*/
|
|
4073
4517
|
class AddNodeAction {
|
|
4074
|
-
constructor(canvas, type, coords, label, values) {
|
|
4518
|
+
constructor(canvas, type, coords, parentId, ancestorId, fromAncestorGeometry, toAncestorGeometry, label, values) {
|
|
4075
4519
|
this.canvas = canvas;
|
|
4076
4520
|
this.type = type;
|
|
4077
4521
|
this.coords = coords;
|
|
4522
|
+
this.parentId = parentId;
|
|
4523
|
+
this.ancestorId = ancestorId;
|
|
4524
|
+
this.fromAncestorGeometry = fromAncestorGeometry;
|
|
4525
|
+
this.toAncestorGeometry = toAncestorGeometry;
|
|
4078
4526
|
this.label = label;
|
|
4079
4527
|
this.values = values;
|
|
4080
4528
|
this.id = this.canvas.collabEngine.freshId();
|
|
4081
4529
|
}
|
|
4082
4530
|
do() {
|
|
4083
|
-
const collabAction = new AddNodeCollabAction(this.canvas, this.id, this.type.id, this.coords, this.label, this.values);
|
|
4531
|
+
const collabAction = new AddNodeCollabAction(this.canvas, this.id, this.type.id, this.coords, this.parentId, this.label, this.values);
|
|
4084
4532
|
this.canvas.collabEngine.doCollaboratively(collabAction);
|
|
4533
|
+
if (this.ancestorId !== undefined && this.toAncestorGeometry !== undefined) {
|
|
4534
|
+
const collabAction2 = new SetGeometryCollabAction(this.canvas, this.ancestorId, this.toAncestorGeometry, this.canvas.collabEngine.freshTimestamp());
|
|
4535
|
+
this.canvas.collabEngine.doCollaboratively(collabAction2);
|
|
4536
|
+
}
|
|
4085
4537
|
// creating a node always has an effect
|
|
4086
4538
|
return true;
|
|
4087
4539
|
}
|
|
@@ -4089,6 +4541,10 @@ class AddNodeAction {
|
|
|
4089
4541
|
const node = this.canvas.model.nodes.get(this.id);
|
|
4090
4542
|
const collabAction = new SetSelfRemovedCollabAction(this.canvas, [this.id], [], [], [], [], true, this.canvas.collabEngine.freshTimestamp());
|
|
4091
4543
|
this.canvas.collabEngine.doCollaboratively(collabAction);
|
|
4544
|
+
if (this.ancestorId !== undefined && this.fromAncestorGeometry !== undefined) {
|
|
4545
|
+
const collabAction2 = new SetGeometryCollabAction(this.canvas, this.ancestorId, this.fromAncestorGeometry, this.canvas.collabEngine.freshTimestamp());
|
|
4546
|
+
this.canvas.collabEngine.doCollaboratively(collabAction2);
|
|
4547
|
+
}
|
|
4092
4548
|
// undoing creating a node has an effect if the node was not already removed
|
|
4093
4549
|
return node !== undefined;
|
|
4094
4550
|
}
|
|
@@ -4096,10 +4552,38 @@ class AddNodeAction {
|
|
|
4096
4552
|
const node = this.canvas.model.nodes.get(this.id);
|
|
4097
4553
|
const collabAction = new SetSelfRemovedCollabAction(this.canvas, [this.id], [], [], [], [], false, this.canvas.collabEngine.freshTimestamp());
|
|
4098
4554
|
this.canvas.collabEngine.doCollaboratively(collabAction);
|
|
4555
|
+
if (this.ancestorId !== undefined && this.toAncestorGeometry !== undefined) {
|
|
4556
|
+
const collabAction2 = new SetGeometryCollabAction(this.canvas, this.ancestorId, this.toAncestorGeometry, this.canvas.collabEngine.freshTimestamp());
|
|
4557
|
+
this.canvas.collabEngine.doCollaboratively(collabAction2);
|
|
4558
|
+
}
|
|
4099
4559
|
// redoing creating a node has an effect if the node was removed
|
|
4100
4560
|
return node === undefined;
|
|
4101
4561
|
}
|
|
4102
4562
|
}
|
|
4563
|
+
/**
|
|
4564
|
+
* Action which consists of applying a layout to the diagram which can change the location of several nodes.
|
|
4565
|
+
* @private
|
|
4566
|
+
*/
|
|
4567
|
+
class ApplyLayoutAction {
|
|
4568
|
+
constructor(canvas, from, to) {
|
|
4569
|
+
this.canvas = canvas;
|
|
4570
|
+
this.from = from;
|
|
4571
|
+
this.to = to;
|
|
4572
|
+
}
|
|
4573
|
+
do() {
|
|
4574
|
+
const collabAction = new ApplyLayoutCollabAction(this.canvas, this.to, this.canvas.collabEngine.freshTimestamp());
|
|
4575
|
+
this.canvas.collabEngine.doCollaboratively(collabAction);
|
|
4576
|
+
return true;
|
|
4577
|
+
}
|
|
4578
|
+
undo() {
|
|
4579
|
+
const collabAction = new ApplyLayoutCollabAction(this.canvas, this.from, this.canvas.collabEngine.freshTimestamp());
|
|
4580
|
+
this.canvas.collabEngine.doCollaboratively(collabAction);
|
|
4581
|
+
return true;
|
|
4582
|
+
}
|
|
4583
|
+
redo() {
|
|
4584
|
+
return this.do();
|
|
4585
|
+
}
|
|
4586
|
+
}
|
|
4103
4587
|
/**
|
|
4104
4588
|
* Action which consists of changing the coordinates of diagram elements by a fixed amount.
|
|
4105
4589
|
* @private
|
|
@@ -4130,17 +4614,26 @@ class MoveAction {
|
|
|
4130
4614
|
* @see DiagramNode
|
|
4131
4615
|
*/
|
|
4132
4616
|
class SetGeometryAction {
|
|
4133
|
-
constructor(canvas, intent, nodeId, from, to) {
|
|
4617
|
+
constructor(canvas, intent, nodeId, from, to, ancestorId, fromAncestorGeometry, toAncestorGeometry) {
|
|
4134
4618
|
this.canvas = canvas;
|
|
4135
4619
|
this.intent = intent;
|
|
4136
4620
|
this.nodeId = nodeId;
|
|
4137
4621
|
this.from = from;
|
|
4138
4622
|
this.to = to;
|
|
4623
|
+
this.ancestorId = ancestorId;
|
|
4624
|
+
this.fromAncestorGeometry = fromAncestorGeometry;
|
|
4625
|
+
this.toAncestorGeometry = toAncestorGeometry;
|
|
4139
4626
|
}
|
|
4140
4627
|
do() {
|
|
4141
4628
|
const node = this.canvas.model.nodes.get(this.nodeId);
|
|
4142
|
-
|
|
4143
|
-
|
|
4629
|
+
if (node) {
|
|
4630
|
+
const collabAction = new SetGeometryCollabAction(this.canvas, this.nodeId, this.to, this.canvas.collabEngine.freshTimestamp());
|
|
4631
|
+
this.canvas.collabEngine.doCollaboratively(collabAction);
|
|
4632
|
+
if (this.ancestorId !== undefined && this.toAncestorGeometry !== undefined) {
|
|
4633
|
+
const collabAction2 = new SetGeometryCollabAction(this.canvas, this.ancestorId, this.toAncestorGeometry, this.canvas.collabEngine.freshTimestamp());
|
|
4634
|
+
this.canvas.collabEngine.doCollaboratively(collabAction2);
|
|
4635
|
+
}
|
|
4636
|
+
}
|
|
4144
4637
|
return node !== undefined;
|
|
4145
4638
|
}
|
|
4146
4639
|
undo() {
|
|
@@ -4149,6 +4642,10 @@ class SetGeometryAction {
|
|
|
4149
4642
|
this.to = node.getGeometry();
|
|
4150
4643
|
const collabAction = new SetGeometryCollabAction(this.canvas, this.nodeId, this.from, this.canvas.collabEngine.freshTimestamp());
|
|
4151
4644
|
this.canvas.collabEngine.doCollaboratively(collabAction);
|
|
4645
|
+
if (this.ancestorId !== undefined && this.fromAncestorGeometry !== undefined) {
|
|
4646
|
+
const collabAction2 = new SetGeometryCollabAction(this.canvas, this.ancestorId, this.fromAncestorGeometry, this.canvas.collabEngine.freshTimestamp());
|
|
4647
|
+
this.canvas.collabEngine.doCollaboratively(collabAction2);
|
|
4648
|
+
}
|
|
4152
4649
|
}
|
|
4153
4650
|
return node !== undefined;
|
|
4154
4651
|
}
|
|
@@ -4162,6 +4659,46 @@ class SetGeometryAction {
|
|
|
4162
4659
|
return node !== undefined;
|
|
4163
4660
|
}
|
|
4164
4661
|
}
|
|
4662
|
+
/**
|
|
4663
|
+
* Action which consists of setting a node's parent.
|
|
4664
|
+
* @private
|
|
4665
|
+
*/
|
|
4666
|
+
class SetParentAction {
|
|
4667
|
+
constructor(canvas, childId, fromParentId, toParentId, fromChildGeometry, toChildGeometry, ancestorId, fromAncestorGeometry, toAncestorGeometry) {
|
|
4668
|
+
this.canvas = canvas;
|
|
4669
|
+
this.childId = childId;
|
|
4670
|
+
this.fromParentId = fromParentId;
|
|
4671
|
+
this.toParentId = toParentId;
|
|
4672
|
+
this.fromChildGeometry = fromChildGeometry;
|
|
4673
|
+
this.toChildGeometry = toChildGeometry;
|
|
4674
|
+
this.ancestorId = ancestorId;
|
|
4675
|
+
this.fromAncestorGeometry = fromAncestorGeometry;
|
|
4676
|
+
this.toAncestorGeometry = toAncestorGeometry;
|
|
4677
|
+
}
|
|
4678
|
+
do() {
|
|
4679
|
+
const childNode = this.canvas.model.nodes.get(this.childId);
|
|
4680
|
+
const collabAction1 = new SetParentCollabAction(this.canvas, this.childId, this.toParentId, this.toChildGeometry, this.canvas.collabEngine.freshTimestamp());
|
|
4681
|
+
this.canvas.collabEngine.doCollaboratively(collabAction1);
|
|
4682
|
+
if (this.ancestorId !== undefined && this.toAncestorGeometry !== undefined) {
|
|
4683
|
+
const collabAction2 = new SetGeometryCollabAction(this.canvas, this.ancestorId, this.toAncestorGeometry, this.canvas.collabEngine.freshTimestamp());
|
|
4684
|
+
this.canvas.collabEngine.doCollaboratively(collabAction2);
|
|
4685
|
+
}
|
|
4686
|
+
return childNode !== undefined;
|
|
4687
|
+
}
|
|
4688
|
+
undo() {
|
|
4689
|
+
const childNode = this.canvas.model.nodes.get(this.childId);
|
|
4690
|
+
const collabAction1 = new SetParentCollabAction(this.canvas, this.childId, this.fromParentId, this.fromChildGeometry, this.canvas.collabEngine.freshTimestamp());
|
|
4691
|
+
this.canvas.collabEngine.doCollaboratively(collabAction1);
|
|
4692
|
+
if (this.ancestorId !== undefined && this.fromAncestorGeometry !== undefined) {
|
|
4693
|
+
const collabAction2 = new SetGeometryCollabAction(this.canvas, this.ancestorId, this.fromAncestorGeometry, this.canvas.collabEngine.freshTimestamp());
|
|
4694
|
+
this.canvas.collabEngine.doCollaboratively(collabAction2);
|
|
4695
|
+
}
|
|
4696
|
+
return childNode !== undefined;
|
|
4697
|
+
}
|
|
4698
|
+
redo() {
|
|
4699
|
+
return this.do();
|
|
4700
|
+
}
|
|
4701
|
+
}
|
|
4165
4702
|
/**
|
|
4166
4703
|
* Action which consists of adding a connection.
|
|
4167
4704
|
* @private
|
|
@@ -4426,21 +4963,97 @@ class PasteAction {
|
|
|
4426
4963
|
}
|
|
4427
4964
|
|
|
4428
4965
|
/**
|
|
4429
|
-
* Represents an action taken by the user on the diagram.
|
|
4966
|
+
* Represents an action taken by the user on the diagram which doesn't have an impact on the diagram's model.
|
|
4967
|
+
* Contrast with {@link DiagramAction} which does have an impact on the diagram's model.
|
|
4430
4968
|
* @public
|
|
4431
4969
|
*/
|
|
4432
4970
|
class DiagramEvent {
|
|
4433
|
-
constructor(
|
|
4434
|
-
this.cause = cause;
|
|
4971
|
+
constructor(type) {
|
|
4435
4972
|
this.type = type;
|
|
4436
|
-
this.target = target;
|
|
4437
|
-
this.coords = coords;
|
|
4438
4973
|
this.defaultPrevented = false;
|
|
4439
4974
|
}
|
|
4440
4975
|
preventDefault() {
|
|
4441
4976
|
this.defaultPrevented = true;
|
|
4442
4977
|
}
|
|
4443
4978
|
}
|
|
4979
|
+
/**
|
|
4980
|
+
* Diagram user events.
|
|
4981
|
+
* @public
|
|
4982
|
+
*/
|
|
4983
|
+
exports.DiagramEvents = void 0;
|
|
4984
|
+
(function (DiagramEvents) {
|
|
4985
|
+
DiagramEvents[DiagramEvents["DoubleClick"] = 0] = "DoubleClick";
|
|
4986
|
+
DiagramEvents[DiagramEvents["SecondaryClick"] = 1] = "SecondaryClick";
|
|
4987
|
+
DiagramEvents[DiagramEvents["Selection"] = 2] = "Selection";
|
|
4988
|
+
DiagramEvents[DiagramEvents["Highlight"] = 3] = "Highlight";
|
|
4989
|
+
})(exports.DiagramEvents || (exports.DiagramEvents = {}));
|
|
4990
|
+
/**
|
|
4991
|
+
* Diagram event which consists of the user performing a double click on the diagram.
|
|
4992
|
+
*/
|
|
4993
|
+
class DiagramDoubleClickEvent extends DiagramEvent {
|
|
4994
|
+
/**
|
|
4995
|
+
* Create a diagram double click event.
|
|
4996
|
+
*
|
|
4997
|
+
* @param cause Mouse event which triggered this event.
|
|
4998
|
+
* @param target Diagram element which is targeted by the event, or null if no element was targeted (the diagram background was targeted).
|
|
4999
|
+
* @param coords Optionally, coordinates of the point of the diagram where the event happened.
|
|
5000
|
+
*/
|
|
5001
|
+
constructor(cause, target, coords) {
|
|
5002
|
+
super(exports.DiagramEvents.DoubleClick);
|
|
5003
|
+
this.cause = cause;
|
|
5004
|
+
this.target = target;
|
|
5005
|
+
this.coords = coords;
|
|
5006
|
+
}
|
|
5007
|
+
}
|
|
5008
|
+
/**
|
|
5009
|
+
* Diagram event which consists of the user performing a secondary click on the diagram.
|
|
5010
|
+
*/
|
|
5011
|
+
class DiagramSecondaryClickEvent extends DiagramEvent {
|
|
5012
|
+
/**
|
|
5013
|
+
* Create a diagram secondary click event.
|
|
5014
|
+
*
|
|
5015
|
+
* @param cause Mouse event which triggered this event.
|
|
5016
|
+
* @param target Diagram element which is targeted by the event, or null if no element was targeted (the diagram background was targeted).
|
|
5017
|
+
* @param coords Optionally, coordinates of the point of the diagram where the event happened.
|
|
5018
|
+
*/
|
|
5019
|
+
constructor(cause, target, coords) {
|
|
5020
|
+
super(exports.DiagramEvents.SecondaryClick);
|
|
5021
|
+
this.cause = cause;
|
|
5022
|
+
this.target = target;
|
|
5023
|
+
this.coords = coords;
|
|
5024
|
+
}
|
|
5025
|
+
}
|
|
5026
|
+
/**
|
|
5027
|
+
* Diagram event which consists of the user either adding or removing one or several diagram elements from the user selection.
|
|
5028
|
+
*/
|
|
5029
|
+
class DiagramSelectionEvent extends DiagramEvent {
|
|
5030
|
+
/**
|
|
5031
|
+
* Create a diagram selection event.
|
|
5032
|
+
*
|
|
5033
|
+
* @param targets Diagram elements which are targeted by the event.
|
|
5034
|
+
* @param selected `true` if the targets were selected, `false` if the targets were deselected.
|
|
5035
|
+
*/
|
|
5036
|
+
constructor(targets, selected) {
|
|
5037
|
+
super(exports.DiagramEvents.Selection);
|
|
5038
|
+
this.targets = targets;
|
|
5039
|
+
this.selected = selected;
|
|
5040
|
+
}
|
|
5041
|
+
}
|
|
5042
|
+
/**
|
|
5043
|
+
* Diagram event which consists of the user highlighting a diagram element.
|
|
5044
|
+
* If the target is `null`, that means that the previously highlighted element was unhighlighted.
|
|
5045
|
+
*/
|
|
5046
|
+
class DiagramHighlightedEvent extends DiagramEvent {
|
|
5047
|
+
/**
|
|
5048
|
+
* Create a diagram highlight event.
|
|
5049
|
+
*
|
|
5050
|
+
* @param target Diagram element which is targeted by the event.
|
|
5051
|
+
*/
|
|
5052
|
+
constructor(target) {
|
|
5053
|
+
super(exports.DiagramEvents.Highlight);
|
|
5054
|
+
this.target = target;
|
|
5055
|
+
}
|
|
5056
|
+
}
|
|
4444
5057
|
|
|
4445
5058
|
/**
|
|
4446
5059
|
* A foreign object which is inserted with arbitrary html into a diagram.
|
|
@@ -4466,14 +5079,18 @@ class DiagramDecorator extends DiagramElement {
|
|
|
4466
5079
|
}
|
|
4467
5080
|
select() {
|
|
4468
5081
|
var _a, _b;
|
|
4469
|
-
return (_b = (_a = this.model.canvas) === null || _a ===
|
|
5082
|
+
return (_b = (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.selectCanvasView()) === null || _b === undefined ? undefined : _b.select(`foreignObject#${this.id}`);
|
|
4470
5083
|
}
|
|
4471
5084
|
get removed() {
|
|
4472
5085
|
return this.selfRemoved || this.rootElement !== undefined && this.rootElement.removed;
|
|
4473
5086
|
}
|
|
4474
5087
|
updateInView() {
|
|
4475
5088
|
var _a;
|
|
4476
|
-
(_a = this.model.canvas) === null || _a ===
|
|
5089
|
+
(_a = this.model.canvas) === null || _a === undefined ? undefined : _a.updateDecoratorsInView(this.id);
|
|
5090
|
+
}
|
|
5091
|
+
raise() {
|
|
5092
|
+
var _a;
|
|
5093
|
+
(_a = this.select()) === null || _a === undefined ? undefined : _a.raise();
|
|
4477
5094
|
}
|
|
4478
5095
|
/**
|
|
4479
5096
|
* Change the coordinates of this decorator to the given coordinates.
|
|
@@ -4545,14 +5162,18 @@ class DiagramObject extends DiagramElement {
|
|
|
4545
5162
|
}
|
|
4546
5163
|
select() {
|
|
4547
5164
|
var _a, _b;
|
|
4548
|
-
return (_b = (_a = this.model.canvas) === null || _a ===
|
|
5165
|
+
return (_b = (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.selectCanvasView()) === null || _b === undefined ? undefined : _b.select(`foreignObject#${this.id}`);
|
|
4549
5166
|
}
|
|
4550
5167
|
get removed() {
|
|
4551
5168
|
return this.selfRemoved;
|
|
4552
5169
|
}
|
|
4553
5170
|
updateInView() {
|
|
4554
5171
|
var _a;
|
|
4555
|
-
(_a = this.model.canvas) === null || _a ===
|
|
5172
|
+
(_a = this.model.canvas) === null || _a === undefined ? undefined : _a.updateObjectsInView(this.id);
|
|
5173
|
+
}
|
|
5174
|
+
raise() {
|
|
5175
|
+
var _a;
|
|
5176
|
+
(_a = this.select()) === null || _a === undefined ? undefined : _a.raise();
|
|
4556
5177
|
}
|
|
4557
5178
|
/**
|
|
4558
5179
|
* Change the coordinates of this object to the given coordinates.
|
|
@@ -4662,7 +5283,7 @@ class DiagramModel {
|
|
|
4662
5283
|
*/
|
|
4663
5284
|
clear() {
|
|
4664
5285
|
var _a, _b;
|
|
4665
|
-
(_a = this.canvas) === null || _a ===
|
|
5286
|
+
(_a = this.canvas) === null || _a === undefined ? undefined : _a.cancelAllUserActions();
|
|
4666
5287
|
this.id = undefined;
|
|
4667
5288
|
this.name = '';
|
|
4668
5289
|
this.description = undefined;
|
|
@@ -4677,7 +5298,7 @@ class DiagramModel {
|
|
|
4677
5298
|
this.objects.clear();
|
|
4678
5299
|
this.decorators.clear();
|
|
4679
5300
|
this.valueSet.resetValues();
|
|
4680
|
-
(_b = this.canvas) === null || _b ===
|
|
5301
|
+
(_b = this.canvas) === null || _b === undefined ? undefined : _b.updateModelInView();
|
|
4681
5302
|
}
|
|
4682
5303
|
}
|
|
4683
5304
|
|
|
@@ -4806,7 +5427,7 @@ class DiagramContextMenu {
|
|
|
4806
5427
|
*/
|
|
4807
5428
|
close() {
|
|
4808
5429
|
var _a;
|
|
4809
|
-
(_a = this.contextMenuContainer) === null || _a ===
|
|
5430
|
+
(_a = this.contextMenuContainer) === null || _a === undefined ? undefined : _a.remove();
|
|
4810
5431
|
this.contextMenuContainer = undefined;
|
|
4811
5432
|
}
|
|
4812
5433
|
}
|
|
@@ -4921,6 +5542,7 @@ class DagaExporter {
|
|
|
4921
5542
|
}
|
|
4922
5543
|
for (const node of model.nodes.all(true)) {
|
|
4923
5544
|
if (!includeCollabMeta && node.removed) continue;
|
|
5545
|
+
if (node.parent !== undefined) continue;
|
|
4924
5546
|
result.nodes.push(this.exportNode(node, includeCollabMeta));
|
|
4925
5547
|
}
|
|
4926
5548
|
for (const connection of model.connections.all(true)) {
|
|
@@ -4931,6 +5553,10 @@ class DagaExporter {
|
|
|
4931
5553
|
}
|
|
4932
5554
|
exportNode(node, includeCollabMeta = false) {
|
|
4933
5555
|
var _a, _b, _c, _d;
|
|
5556
|
+
const children = [];
|
|
5557
|
+
for (const child of node.children) {
|
|
5558
|
+
children.push(this.exportNode(child, includeCollabMeta));
|
|
5559
|
+
}
|
|
4934
5560
|
const sections = [];
|
|
4935
5561
|
for (const section of node.sections) {
|
|
4936
5562
|
const ports = [];
|
|
@@ -4939,7 +5565,7 @@ class DagaExporter {
|
|
|
4939
5565
|
id: port.id,
|
|
4940
5566
|
coords: roundPoint(port.coords),
|
|
4941
5567
|
direction: port.direction,
|
|
4942
|
-
label: ((_a = port.label) === null || _a ===
|
|
5568
|
+
label: ((_a = port.label) === null || _a === undefined ? undefined : _a.text) || ''
|
|
4943
5569
|
}, includeCollabMeta ? {
|
|
4944
5570
|
collabMeta: Object.assign({
|
|
4945
5571
|
removed: port.removed,
|
|
@@ -4951,7 +5577,7 @@ class DagaExporter {
|
|
|
4951
5577
|
sections.push(Object.assign({
|
|
4952
5578
|
id: section.id,
|
|
4953
5579
|
ports,
|
|
4954
|
-
label: ((_b = section.label) === null || _b ===
|
|
5580
|
+
label: ((_b = section.label) === null || _b === undefined ? undefined : _b.text) || '',
|
|
4955
5581
|
indexXInNode: section.indexXInNode,
|
|
4956
5582
|
indexYInNode: section.indexYInNode,
|
|
4957
5583
|
coords: roundPoint(section.coords),
|
|
@@ -4971,7 +5597,7 @@ class DagaExporter {
|
|
|
4971
5597
|
id: port.id,
|
|
4972
5598
|
coords: roundPoint(port.coords),
|
|
4973
5599
|
direction: port.direction,
|
|
4974
|
-
label: ((_c = port.label) === null || _c ===
|
|
5600
|
+
label: ((_c = port.label) === null || _c === undefined ? undefined : _c.text) || ''
|
|
4975
5601
|
}, includeCollabMeta ? {
|
|
4976
5602
|
collabMeta: Object.assign({
|
|
4977
5603
|
removed: port.removed,
|
|
@@ -4983,9 +5609,10 @@ class DagaExporter {
|
|
|
4983
5609
|
return Object.assign({
|
|
4984
5610
|
id: node.id,
|
|
4985
5611
|
type: node.type.id,
|
|
5612
|
+
children,
|
|
4986
5613
|
sections,
|
|
4987
5614
|
ports,
|
|
4988
|
-
label: ((_d = node.label) === null || _d ===
|
|
5615
|
+
label: ((_d = node.label) === null || _d === undefined ? undefined : _d.text) || '',
|
|
4989
5616
|
coords: roundPoint(node.coords),
|
|
4990
5617
|
width: node.width,
|
|
4991
5618
|
height: node.height,
|
|
@@ -5005,8 +5632,8 @@ class DagaExporter {
|
|
|
5005
5632
|
return Object.assign({
|
|
5006
5633
|
id: connection.id,
|
|
5007
5634
|
type: connection.type.id,
|
|
5008
|
-
start: ((_a = connection.start) === null || _a ===
|
|
5009
|
-
end: ((_b = connection.end) === null || _b ===
|
|
5635
|
+
start: ((_a = connection.start) === null || _a === undefined ? undefined : _a.id) || '',
|
|
5636
|
+
end: ((_b = connection.end) === null || _b === undefined ? undefined : _b.id) || '',
|
|
5010
5637
|
startLabel: connection.startLabel,
|
|
5011
5638
|
middleLabel: connection.middleLabel,
|
|
5012
5639
|
endLabel: connection.endLabel,
|
|
@@ -5226,11 +5853,11 @@ class DiagramUserSelection extends DiagramElementSet {
|
|
|
5226
5853
|
openInPropertyEditor(selection) {
|
|
5227
5854
|
var _a;
|
|
5228
5855
|
this.makeUpdateValuesAction();
|
|
5229
|
-
const propertyEditor = (_a = this.canvas.parentComponent) === null || _a ===
|
|
5856
|
+
const propertyEditor = (_a = this.canvas.parentComponent) === null || _a === undefined ? undefined : _a.propertyEditor;
|
|
5230
5857
|
if (propertyEditor === undefined) {
|
|
5231
5858
|
return;
|
|
5232
5859
|
}
|
|
5233
|
-
const selectedValueSet = selection === null || selection ===
|
|
5860
|
+
const selectedValueSet = selection === null || selection === undefined ? undefined : selection.valueSet;
|
|
5234
5861
|
if (selectedValueSet) {
|
|
5235
5862
|
this.propertyEditorSelection = selection;
|
|
5236
5863
|
this.propertyEditorValues = structuredClone(selectedValueSet.getValues());
|
|
@@ -5272,11 +5899,11 @@ class DiagramUserSelection extends DiagramElementSet {
|
|
|
5272
5899
|
const previousSelectionId = this.propertyEditorSelection instanceof DiagramModel ? undefined : this.propertyEditorSelection.id;
|
|
5273
5900
|
// check if there have been changes in the previously selected ValueSet,
|
|
5274
5901
|
// and create an UpdateValuesAction if there have
|
|
5275
|
-
if (equals(this.propertyEditorValues, (_a = this.propertyEditorSelection) === null || _a ===
|
|
5902
|
+
if (equals(this.propertyEditorValues, (_a = this.propertyEditorSelection) === null || _a === undefined ? undefined : _a.valueSet.getValues())) {
|
|
5276
5903
|
return;
|
|
5277
5904
|
}
|
|
5278
5905
|
const from = this.propertyEditorValues;
|
|
5279
|
-
const to = structuredClone((_b = this.propertyEditorSelection) === null || _b ===
|
|
5906
|
+
const to = structuredClone((_b = this.propertyEditorSelection) === null || _b === undefined ? undefined : _b.valueSet.getValues());
|
|
5280
5907
|
const [fromDiff, toDiff] = diff(from, to);
|
|
5281
5908
|
const currentAction = new UpdateValuesAction(this.canvas, previousSelectionId, fromDiff, toDiff);
|
|
5282
5909
|
currentAction.do();
|
|
@@ -5311,7 +5938,7 @@ class DiagramCanvas {
|
|
|
5311
5938
|
var _a, _b;
|
|
5312
5939
|
this._connectionType = value;
|
|
5313
5940
|
// refresh the palette every time connectionType is set so that the palette keeps track of updates to the connectionType
|
|
5314
|
-
(_b = (_a = this.parentComponent) === null || _a ===
|
|
5941
|
+
(_b = (_a = this.parentComponent) === null || _a === undefined ? undefined : _a.palette) === null || _b === undefined ? undefined : _b.refreshPalette();
|
|
5315
5942
|
}
|
|
5316
5943
|
/**
|
|
5317
5944
|
* Constructs a canvas object.
|
|
@@ -5329,27 +5956,25 @@ class DiagramCanvas {
|
|
|
5329
5956
|
this.dragging = false;
|
|
5330
5957
|
// used to track whether a click is secondary or primary
|
|
5331
5958
|
this.secondaryButton = false;
|
|
5332
|
-
this.viewInitialized$ = new rxjs.Subject();
|
|
5333
5959
|
this.validatorChange$ = new rxjs.Subject();
|
|
5334
5960
|
this.diagramChange$ = new rxjs.Subject();
|
|
5335
|
-
this.diagramImportantChange$ = new rxjs.Subject();
|
|
5336
|
-
this.propertyEditorChanges$ = new rxjs.Subject();
|
|
5337
5961
|
this.diagramEvent$ = new rxjs.Subject();
|
|
5962
|
+
this.propertyEditorChanges$ = new rxjs.Subject();
|
|
5338
5963
|
this.parentComponent = parentComponent;
|
|
5339
5964
|
this.model = new DiagramModel(this, undefined, config.name || 'unnamed', '', config.type || '', config.properties || []);
|
|
5340
5965
|
this.userSelection = new DiagramUserSelection(this);
|
|
5341
5966
|
this.userHighlight = new DiagramUserHighlight(this);
|
|
5342
5967
|
this.contextMenu = new DiagramContextMenu(this);
|
|
5343
|
-
this.backgroundColor = ((_a = config.canvas) === null || _a ===
|
|
5344
|
-
this.gridSize = ((_c = (_b = config.canvas) === null || _b ===
|
|
5345
|
-
this.gridThickness = Math.abs(((_h = (_g = config.canvas) === null || _g ===
|
|
5346
|
-
this.gridColor = ((_k = (_j = config.canvas) === null || _j ===
|
|
5347
|
-
this.snapToGrid = ((_m = (_l = config.canvas) === null || _l ===
|
|
5348
|
-
this.zoomFactor = ((_r = config.canvas) === null || _r ===
|
|
5349
|
-
this.panRate = ((_s = config.canvas) === null || _s ===
|
|
5968
|
+
this.backgroundColor = ((_a = config.canvas) === null || _a === undefined ? undefined : _a.backgroundColor) || '#FFFFFF';
|
|
5969
|
+
this.gridSize = ((_c = (_b = config.canvas) === null || _b === undefined ? undefined : _b.grid) === null || _c === undefined ? undefined : _c.enabled) === false || ((_d = config.canvas) === null || _d === undefined ? undefined : _d.grid) === undefined ? 0 : Math.abs(((_f = (_e = config.canvas) === null || _e === undefined ? undefined : _e.grid) === null || _f === undefined ? undefined : _f.spacing) || 10);
|
|
5970
|
+
this.gridThickness = Math.abs(((_h = (_g = config.canvas) === null || _g === undefined ? undefined : _g.grid) === null || _h === undefined ? undefined : _h.thickness) || 0.05);
|
|
5971
|
+
this.gridColor = ((_k = (_j = config.canvas) === null || _j === undefined ? undefined : _j.grid) === null || _k === undefined ? undefined : _k.color) || 'rgba(0, 0, 0, 0.1)';
|
|
5972
|
+
this.snapToGrid = ((_m = (_l = config.canvas) === null || _l === undefined ? undefined : _l.grid) === null || _m === undefined ? undefined : _m.enabled) === false || ((_o = config.canvas) === null || _o === undefined ? undefined : _o.grid) === undefined ? false : ((_q = (_p = config.canvas) === null || _p === undefined ? undefined : _p.grid) === null || _q === undefined ? undefined : _q.snap) || false;
|
|
5973
|
+
this.zoomFactor = ((_r = config.canvas) === null || _r === undefined ? undefined : _r.zoomFactor) || 2;
|
|
5974
|
+
this.panRate = ((_s = config.canvas) === null || _s === undefined ? undefined : _s.panRate) || 100;
|
|
5350
5975
|
this.inferConnectionType = config.inferConnectionType || false;
|
|
5351
5976
|
this.multipleSelectionOn = false;
|
|
5352
|
-
this.priorityThresholds = ((_t = config.canvas) === null || _t ===
|
|
5977
|
+
this.priorityThresholds = ((_t = config.canvas) === null || _t === undefined ? undefined : _t.priorityThresholds) || [];
|
|
5353
5978
|
this.priorityThreshold = this.priorityThresholds ? this.priorityThresholds[0] : undefined;
|
|
5354
5979
|
this.layoutFormat = config.layoutFormat;
|
|
5355
5980
|
this.userActions = config.userActions || {};
|
|
@@ -5393,18 +6018,21 @@ class DiagramCanvas {
|
|
|
5393
6018
|
for (const node of this.model.nodes) {
|
|
5394
6019
|
this.fitNodeInView(node.id);
|
|
5395
6020
|
}
|
|
5396
|
-
(_b = (_a = this.parentComponent) === null || _a ===
|
|
6021
|
+
(_b = (_a = this.parentComponent) === null || _a === undefined ? undefined : _a.palette) === null || _b === undefined ? undefined : _b.refreshPalette();
|
|
5397
6022
|
}
|
|
5398
6023
|
// View methods
|
|
5399
6024
|
initView(appendTo) {
|
|
5400
|
-
|
|
6025
|
+
const appendToSelection = d3__namespace.select(appendTo);
|
|
6026
|
+
// remove all children
|
|
6027
|
+
appendToSelection.html('');
|
|
6028
|
+
this.diagramRoot = appendToSelection.append('div').node();
|
|
5401
6029
|
d3__namespace.select(this.diagramRoot).attr('tabindex', 0) // make element focusable
|
|
5402
6030
|
.style('width', '100%').style('height', '100%').append('svg').style('width', '100%').style('height', '100%');
|
|
5403
6031
|
d3__namespace.select(this.diagramRoot).on(exports.Events.Click, () => {
|
|
5404
6032
|
var _a;
|
|
5405
6033
|
// focus on the diagram when clicking so that we can focus on the diagram
|
|
5406
6034
|
// keyboard events only work if we're focusing on the diagram
|
|
5407
|
-
(_a = d3__namespace.select(this.diagramRoot).node()) === null || _a ===
|
|
6035
|
+
(_a = d3__namespace.select(this.diagramRoot).node()) === null || _a === undefined ? undefined : _a.focus();
|
|
5408
6036
|
}).on(exports.Events.ContextMenu, event => {
|
|
5409
6037
|
if (this.dragging) {
|
|
5410
6038
|
event.preventDefault();
|
|
@@ -5412,14 +6040,14 @@ class DiagramCanvas {
|
|
|
5412
6040
|
this.dragging = false;
|
|
5413
6041
|
return;
|
|
5414
6042
|
}
|
|
5415
|
-
const diagramEvent = new
|
|
6043
|
+
const diagramEvent = new DiagramSecondaryClickEvent(event, null);
|
|
5416
6044
|
this.diagramEvent$.next(diagramEvent);
|
|
5417
6045
|
if (!diagramEvent.defaultPrevented && this.canUserPerformAction(exports.DiagramActions.ContextMenu)) {
|
|
5418
6046
|
event.preventDefault();
|
|
5419
6047
|
this.contextMenu.open(event);
|
|
5420
6048
|
}
|
|
5421
6049
|
}).on(exports.Events.DoubleClick, event => {
|
|
5422
|
-
const diagramEvent = new
|
|
6050
|
+
const diagramEvent = new DiagramDoubleClickEvent(event, null);
|
|
5423
6051
|
this.diagramEvent$.next(diagramEvent);
|
|
5424
6052
|
}).on(exports.Events.KeyDown, event => {
|
|
5425
6053
|
if (!event.ctrlKey && (event.key === exports.Keys.Delete || event.key === exports.Keys.Backspace) && this.canUserPerformAction(exports.DiagramActions.Remove)) {
|
|
@@ -5435,15 +6063,34 @@ class DiagramCanvas {
|
|
|
5435
6063
|
for (const connection of this.model.connections) {
|
|
5436
6064
|
this.userSelection.add(connection);
|
|
5437
6065
|
}
|
|
6066
|
+
this.diagramEvent$.next(new DiagramSelectionEvent(this.userSelection.all(), true));
|
|
5438
6067
|
}
|
|
5439
6068
|
if (event.ctrlKey && event.key === 'i') {
|
|
5440
6069
|
event.preventDefault();
|
|
5441
6070
|
// invert selection
|
|
6071
|
+
const selectedElements = [];
|
|
6072
|
+
const deselectedElements = [];
|
|
5442
6073
|
for (const node of this.model.nodes) {
|
|
5443
6074
|
this.userSelection.toggle(node);
|
|
6075
|
+
if (node.selected) {
|
|
6076
|
+
selectedElements.push(node);
|
|
6077
|
+
} else {
|
|
6078
|
+
deselectedElements.push(node);
|
|
6079
|
+
}
|
|
5444
6080
|
}
|
|
5445
6081
|
for (const connection of this.model.connections) {
|
|
5446
6082
|
this.userSelection.toggle(connection);
|
|
6083
|
+
if (connection.selected) {
|
|
6084
|
+
selectedElements.push(connection);
|
|
6085
|
+
} else {
|
|
6086
|
+
deselectedElements.push(connection);
|
|
6087
|
+
}
|
|
6088
|
+
}
|
|
6089
|
+
if (selectedElements.length > 0) {
|
|
6090
|
+
this.diagramEvent$.next(new DiagramSelectionEvent(selectedElements, true));
|
|
6091
|
+
}
|
|
6092
|
+
if (deselectedElements.length > 0) {
|
|
6093
|
+
this.diagramEvent$.next(new DiagramSelectionEvent(deselectedElements, false));
|
|
5447
6094
|
}
|
|
5448
6095
|
}
|
|
5449
6096
|
if (event.ctrlKey && event.key === 'c') {
|
|
@@ -5488,12 +6135,12 @@ class DiagramCanvas {
|
|
|
5488
6135
|
if (event.key === exports.Keys.ArrowLeft) {
|
|
5489
6136
|
event.preventDefault();
|
|
5490
6137
|
// move left, faster if we're zoomed out and slower if we're zoomed in
|
|
5491
|
-
this.translateBy(
|
|
6138
|
+
this.translateBy(this.panRate / this.zoomTransform.k, 0);
|
|
5492
6139
|
}
|
|
5493
6140
|
if (event.key === exports.Keys.ArrowRight) {
|
|
5494
6141
|
event.preventDefault();
|
|
5495
6142
|
// move right, faster if we're zoomed out and slower if we're zoomed in
|
|
5496
|
-
this.translateBy(this.panRate / this.zoomTransform.k, 0);
|
|
6143
|
+
this.translateBy(-this.panRate / this.zoomTransform.k, 0);
|
|
5497
6144
|
}
|
|
5498
6145
|
if (event.key === exports.Keys.ArrowDown) {
|
|
5499
6146
|
event.preventDefault();
|
|
@@ -5513,12 +6160,22 @@ class DiagramCanvas {
|
|
|
5513
6160
|
this.unfinishedConnection.endCoords = pointerCoords;
|
|
5514
6161
|
}
|
|
5515
6162
|
}).on(exports.Events.MouseOver, () => {
|
|
5516
|
-
this.userHighlight.
|
|
6163
|
+
if (this.userHighlight.size() > 0) {
|
|
6164
|
+
this.userHighlight.clear();
|
|
6165
|
+
this.diagramEvent$.next(new DiagramHighlightedEvent(null));
|
|
6166
|
+
}
|
|
5517
6167
|
}).on(exports.Events.Click, () => {
|
|
5518
|
-
this.userHighlight.
|
|
6168
|
+
if (this.userHighlight.size() > 0) {
|
|
6169
|
+
this.userHighlight.clear();
|
|
6170
|
+
this.diagramEvent$.next(new DiagramHighlightedEvent(null));
|
|
6171
|
+
}
|
|
5519
6172
|
this.contextMenu.close();
|
|
5520
|
-
this.userSelection.
|
|
5521
|
-
|
|
6173
|
+
if (this.userSelection.size() > 0) {
|
|
6174
|
+
const deselectedElements = this.userSelection.all();
|
|
6175
|
+
this.userSelection.clear();
|
|
6176
|
+
this.diagramEvent$.next(new DiagramSelectionEvent(deselectedElements, false));
|
|
6177
|
+
this.userSelection.openInPropertyEditor(this.model);
|
|
6178
|
+
}
|
|
5522
6179
|
}).call(d3__namespace.drag().filter(event => {
|
|
5523
6180
|
return this.multipleSelectionOn || isSecondaryButton(event);
|
|
5524
6181
|
}).on(exports.DragEvents.Start, event => {
|
|
@@ -5560,15 +6217,7 @@ class DiagramCanvas {
|
|
|
5560
6217
|
canvasBackgroundPattern.append('circle').attr('cx', this.gridSize / 2).attr('cy', this.gridSize / 2).attr('r', this.gridSize * this.gridThickness).attr('fill', this.gridColor);
|
|
5561
6218
|
canvasBackground.attr('fill', `url(#${this.backgroundPatternId})`);
|
|
5562
6219
|
}
|
|
5563
|
-
|
|
5564
|
-
canvasElements.append('g').attr('class', 'daga-canvas-nodes');
|
|
5565
|
-
canvasElements.append('g').attr('class', 'daga-canvas-sections');
|
|
5566
|
-
canvasElements.append('g').attr('class', 'daga-canvas-ports');
|
|
5567
|
-
canvasElements.append('g').attr('class', 'daga-canvas-connections');
|
|
5568
|
-
canvasElements.append('g').attr('class', 'daga-canvas-fields');
|
|
5569
|
-
canvasElements.append('g').attr('class', 'daga-canvas-objects');
|
|
5570
|
-
canvasElements.append('g').attr('class', 'daga-canvas-decorators');
|
|
5571
|
-
this.viewInitialized$.next();
|
|
6220
|
+
canvasView.append('g').attr('class', 'daga-canvas-elements');
|
|
5572
6221
|
}
|
|
5573
6222
|
zoomBy(factor) {
|
|
5574
6223
|
if (!isNaN(factor)) {
|
|
@@ -5625,8 +6274,8 @@ class DiagramCanvas {
|
|
|
5625
6274
|
}
|
|
5626
6275
|
getCoordinatesOnScreen() {
|
|
5627
6276
|
var _a;
|
|
5628
|
-
const rootBoundingClientRect = (_a = this.selectRoot().node()) === null || _a ===
|
|
5629
|
-
const rootDimensions = [(rootBoundingClientRect === null || rootBoundingClientRect ===
|
|
6277
|
+
const rootBoundingClientRect = (_a = this.selectRoot().node()) === null || _a === undefined ? undefined : _a.getBoundingClientRect();
|
|
6278
|
+
const rootDimensions = [(rootBoundingClientRect === null || rootBoundingClientRect === undefined ? undefined : rootBoundingClientRect.width) || 0, (rootBoundingClientRect === null || rootBoundingClientRect === undefined ? undefined : rootBoundingClientRect.height) || 0];
|
|
5630
6279
|
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]];
|
|
5631
6280
|
}
|
|
5632
6281
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -5668,7 +6317,7 @@ class DiagramCanvas {
|
|
|
5668
6317
|
this.updateDecoratorsInView();
|
|
5669
6318
|
}
|
|
5670
6319
|
updateNodesInView(...ids) {
|
|
5671
|
-
let updateSelection = this.
|
|
6320
|
+
let updateSelection = this.selectCanvasElements().selectAll('g.diagram-node').data(this.model.nodes.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
|
|
5672
6321
|
const exitSelection = updateSelection.exit();
|
|
5673
6322
|
const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', d => `diagram-node${d.type.resizableX ? ' resizable-x' : ''}${d.type.resizableY ? ' resizable-y' : ''} ${d.type.look.lookType}`);
|
|
5674
6323
|
if (ids && ids.length > 0) {
|
|
@@ -5679,12 +6328,16 @@ class DiagramCanvas {
|
|
|
5679
6328
|
enterSelection.on(exports.Events.MouseOver, (_event, d) => {
|
|
5680
6329
|
if (!this.dragging) {
|
|
5681
6330
|
this.userHighlight.focusOn(d);
|
|
6331
|
+
this.diagramEvent$.next(new DiagramHighlightedEvent(d));
|
|
5682
6332
|
}
|
|
5683
6333
|
}).on(exports.Events.Click, (event, d) => {
|
|
5684
6334
|
if (!event.ctrlKey && !event.shiftKey) {
|
|
6335
|
+
const deselectedElements = this.userSelection.all();
|
|
5685
6336
|
this.userSelection.clear();
|
|
6337
|
+
this.diagramEvent$.next(new DiagramSelectionEvent(deselectedElements, false));
|
|
5686
6338
|
}
|
|
5687
6339
|
this.userSelection.toggle(d);
|
|
6340
|
+
this.diagramEvent$.next(new DiagramSelectionEvent([d], d.selected));
|
|
5688
6341
|
}).on(exports.Events.ContextMenu, (event, d) => {
|
|
5689
6342
|
if (this.dragging) {
|
|
5690
6343
|
event.preventDefault();
|
|
@@ -5692,16 +6345,18 @@ class DiagramCanvas {
|
|
|
5692
6345
|
this.dragging = false;
|
|
5693
6346
|
return;
|
|
5694
6347
|
}
|
|
5695
|
-
const diagramEvent = new
|
|
6348
|
+
const diagramEvent = new DiagramSecondaryClickEvent(event, d);
|
|
5696
6349
|
this.diagramEvent$.next(diagramEvent);
|
|
5697
6350
|
if (!diagramEvent.defaultPrevented && this.canUserPerformAction(exports.DiagramActions.ContextMenu)) {
|
|
5698
6351
|
event.preventDefault();
|
|
5699
6352
|
this.userHighlight.focusOn(d);
|
|
6353
|
+
this.diagramEvent$.next(new DiagramHighlightedEvent(d));
|
|
5700
6354
|
this.userSelection.add(d);
|
|
6355
|
+
this.diagramEvent$.next(new DiagramSelectionEvent([d], true));
|
|
5701
6356
|
this.contextMenu.open(event);
|
|
5702
6357
|
}
|
|
5703
6358
|
}).on(exports.Events.DoubleClick, (event, d) => {
|
|
5704
|
-
const diagramEvent = new
|
|
6359
|
+
const diagramEvent = new DiagramDoubleClickEvent(event, d);
|
|
5705
6360
|
this.diagramEvent$.next(diagramEvent);
|
|
5706
6361
|
}).call(d3__namespace.drag().filter(event => {
|
|
5707
6362
|
this.secondaryButton = isSecondaryButton(event);
|
|
@@ -5891,11 +6546,11 @@ class DiagramCanvas {
|
|
|
5891
6546
|
mergeSelection.filter('.resizable-y').select('line.bottom-resizer').attr('x1', 0).attr('x2', d => d.width).attr('y1', d => d.height - RESIZER_THICKNESS / 2).attr('y2', d => d.height - RESIZER_THICKNESS / 2);
|
|
5892
6547
|
}
|
|
5893
6548
|
updateSectionsInView(...ids) {
|
|
5894
|
-
let updateSelection = this.
|
|
6549
|
+
let updateSelection = this.selectCanvasElements().selectAll('g.diagram-section').data(this.model.sections.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
|
|
5895
6550
|
const exitSelection = updateSelection.exit();
|
|
5896
6551
|
const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', d => {
|
|
5897
6552
|
var _a, _b, _c, _d, _e, _f;
|
|
5898
|
-
return `diagram-section${((_b = (_a = d.node) === null || _a ===
|
|
6553
|
+
return `diagram-section${((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) ? ' resizable-x' : ''}${((_d = (_c = d.node) === null || _c === undefined ? undefined : _c.type) === null || _d === undefined ? undefined : _d.resizableY) ? ' resizable-y' : ''} ${(_f = (_e = d.getConfig()) === null || _e === undefined ? undefined : _e.look) === null || _f === undefined ? undefined : _f.lookType}`;
|
|
5899
6554
|
});
|
|
5900
6555
|
if (ids && ids.length > 0) {
|
|
5901
6556
|
updateSelection = updateSelection.filter(d => ids.includes(d.id));
|
|
@@ -5905,12 +6560,17 @@ class DiagramCanvas {
|
|
|
5905
6560
|
enterSelection.on(exports.Events.MouseOver, (_event, d) => {
|
|
5906
6561
|
if (!this.dragging) {
|
|
5907
6562
|
this.userHighlight.focusOn(d);
|
|
6563
|
+
this.diagramEvent$.next(new DiagramHighlightedEvent(d));
|
|
5908
6564
|
}
|
|
5909
6565
|
}).on(exports.Events.Click, (event, d) => {
|
|
5910
6566
|
if (!event.ctrlKey && !event.shiftKey) {
|
|
6567
|
+
const deselectedElements = this.userSelection.all();
|
|
5911
6568
|
this.userSelection.clear();
|
|
6569
|
+
this.diagramEvent$.next(new DiagramSelectionEvent(deselectedElements, false));
|
|
5912
6570
|
}
|
|
5913
|
-
|
|
6571
|
+
const elementToBeToggled = getRelatedNodeOrItself(d);
|
|
6572
|
+
this.userSelection.toggle(elementToBeToggled);
|
|
6573
|
+
this.diagramEvent$.next(new DiagramSelectionEvent([elementToBeToggled], elementToBeToggled.selected));
|
|
5914
6574
|
}).on(exports.Events.ContextMenu, (event, d) => {
|
|
5915
6575
|
if (this.dragging) {
|
|
5916
6576
|
event.preventDefault();
|
|
@@ -5918,17 +6578,19 @@ class DiagramCanvas {
|
|
|
5918
6578
|
this.dragging = false;
|
|
5919
6579
|
return;
|
|
5920
6580
|
}
|
|
5921
|
-
const diagramEvent = new
|
|
6581
|
+
const diagramEvent = new DiagramSecondaryClickEvent(event, d);
|
|
5922
6582
|
this.diagramEvent$.next(diagramEvent);
|
|
5923
6583
|
if (!diagramEvent.defaultPrevented && this.canUserPerformAction(exports.DiagramActions.ContextMenu)) {
|
|
5924
6584
|
event.preventDefault();
|
|
5925
6585
|
const elementToSelect = getRelatedNodeOrItself(d);
|
|
5926
6586
|
this.userHighlight.focusOn(elementToSelect);
|
|
6587
|
+
this.diagramEvent$.next(new DiagramHighlightedEvent(elementToSelect));
|
|
5927
6588
|
this.userSelection.add(elementToSelect);
|
|
6589
|
+
this.diagramEvent$.next(new DiagramSelectionEvent([elementToSelect], true));
|
|
5928
6590
|
this.contextMenu.open(event);
|
|
5929
6591
|
}
|
|
5930
6592
|
}).on(exports.Events.DoubleClick, (event, d) => {
|
|
5931
|
-
const diagramEvent = new
|
|
6593
|
+
const diagramEvent = new DiagramDoubleClickEvent(event, d);
|
|
5932
6594
|
this.diagramEvent$.next(diagramEvent);
|
|
5933
6595
|
}).call(d3__namespace.drag().filter(event => {
|
|
5934
6596
|
this.secondaryButton = isSecondaryButton(event);
|
|
@@ -5937,7 +6599,7 @@ class DiagramCanvas {
|
|
|
5937
6599
|
if (this.multipleSelectionOn || this.secondaryButton) {
|
|
5938
6600
|
this.startMultipleSelection(event);
|
|
5939
6601
|
} else {
|
|
5940
|
-
const node = d === null || d ===
|
|
6602
|
+
const node = d === null || d === undefined ? undefined : d.node;
|
|
5941
6603
|
if (node) {
|
|
5942
6604
|
this.startMovingNode(event, node);
|
|
5943
6605
|
} else {
|
|
@@ -5948,7 +6610,7 @@ class DiagramCanvas {
|
|
|
5948
6610
|
if (this.multipleSelectionOn || this.secondaryButton) {
|
|
5949
6611
|
this.continueMultipleSelection(event);
|
|
5950
6612
|
} else {
|
|
5951
|
-
const node = d === null || d ===
|
|
6613
|
+
const node = d === null || d === undefined ? undefined : d.node;
|
|
5952
6614
|
if (node) {
|
|
5953
6615
|
this.continueMovingNode(event, node);
|
|
5954
6616
|
} else {
|
|
@@ -5959,7 +6621,7 @@ class DiagramCanvas {
|
|
|
5959
6621
|
if (this.multipleSelectionOn || this.secondaryButton) {
|
|
5960
6622
|
this.finishMultipleSelection(event);
|
|
5961
6623
|
} else {
|
|
5962
|
-
const node = d === null || d ===
|
|
6624
|
+
const node = d === null || d === undefined ? undefined : d.node;
|
|
5963
6625
|
if (node) {
|
|
5964
6626
|
this.finishMovingNode(event, node);
|
|
5965
6627
|
} else {
|
|
@@ -5981,17 +6643,17 @@ class DiagramCanvas {
|
|
|
5981
6643
|
enterSelection.filter('.stretchable-image-look').append('image').attr('class', 'bottom-right-image').attr('preserveAspectRatio', 'none');
|
|
5982
6644
|
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) => {
|
|
5983
6645
|
var _a, _b;
|
|
5984
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
6646
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
|
|
5985
6647
|
setCursorStyle(exports.CursorStyle.EWResize);
|
|
5986
6648
|
}
|
|
5987
6649
|
}).on(exports.Events.MouseOut, (_event, d) => {
|
|
5988
6650
|
var _a, _b;
|
|
5989
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
6651
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
|
|
5990
6652
|
setCursorStyle();
|
|
5991
6653
|
}
|
|
5992
6654
|
}).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
|
|
5993
6655
|
var _a, _b;
|
|
5994
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
6656
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
|
|
5995
6657
|
setCursorStyle(exports.CursorStyle.EWResize);
|
|
5996
6658
|
this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
|
|
5997
6659
|
} else {
|
|
@@ -5999,13 +6661,13 @@ class DiagramCanvas {
|
|
|
5999
6661
|
}
|
|
6000
6662
|
}).on(exports.DragEvents.Drag, (event, d) => {
|
|
6001
6663
|
var _a, _b;
|
|
6002
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
6664
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
|
|
6003
6665
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
6004
6666
|
d.node.stretchSections(exports.Side.Left, d.coords[0] - pointerCoords[0], d.indexXInNode, d.indexYInNode);
|
|
6005
6667
|
}
|
|
6006
6668
|
}).on(exports.DragEvents.End, (event, d) => {
|
|
6007
6669
|
var _a, _b;
|
|
6008
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
6670
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection) {
|
|
6009
6671
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
6010
6672
|
if (this.snapToGrid) {
|
|
6011
6673
|
pointerCoords = this.getClosestGridPoint(pointerCoords);
|
|
@@ -6020,17 +6682,17 @@ class DiagramCanvas {
|
|
|
6020
6682
|
}));
|
|
6021
6683
|
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) => {
|
|
6022
6684
|
var _a, _b;
|
|
6023
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
6685
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
|
|
6024
6686
|
setCursorStyle(exports.CursorStyle.NSResize);
|
|
6025
6687
|
}
|
|
6026
6688
|
}).on(exports.Events.MouseOut, (_event, d) => {
|
|
6027
6689
|
var _a, _b;
|
|
6028
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
6690
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
|
|
6029
6691
|
setCursorStyle();
|
|
6030
6692
|
}
|
|
6031
6693
|
}).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
|
|
6032
6694
|
var _a, _b;
|
|
6033
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
6695
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
|
|
6034
6696
|
setCursorStyle(exports.CursorStyle.NSResize);
|
|
6035
6697
|
this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
|
|
6036
6698
|
} else {
|
|
@@ -6038,13 +6700,13 @@ class DiagramCanvas {
|
|
|
6038
6700
|
}
|
|
6039
6701
|
}).on(exports.DragEvents.Drag, (event, d) => {
|
|
6040
6702
|
var _a, _b;
|
|
6041
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
6703
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
|
|
6042
6704
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
6043
6705
|
d.node.stretchSections(exports.Side.Top, d.coords[1] - pointerCoords[1], d.indexXInNode, d.indexYInNode);
|
|
6044
6706
|
}
|
|
6045
6707
|
}).on(exports.DragEvents.End, (event, d) => {
|
|
6046
6708
|
var _a, _b;
|
|
6047
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
6709
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection) {
|
|
6048
6710
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
6049
6711
|
if (this.snapToGrid) {
|
|
6050
6712
|
pointerCoords = this.getClosestGridPoint(pointerCoords);
|
|
@@ -6059,17 +6721,17 @@ class DiagramCanvas {
|
|
|
6059
6721
|
}));
|
|
6060
6722
|
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) => {
|
|
6061
6723
|
var _a, _b;
|
|
6062
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
6724
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
|
|
6063
6725
|
setCursorStyle(exports.CursorStyle.EWResize);
|
|
6064
6726
|
}
|
|
6065
6727
|
}).on(exports.Events.MouseOut, (_event, d) => {
|
|
6066
6728
|
var _a, _b;
|
|
6067
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
6729
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
|
|
6068
6730
|
setCursorStyle();
|
|
6069
6731
|
}
|
|
6070
6732
|
}).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
|
|
6071
6733
|
var _a, _b;
|
|
6072
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
6734
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
|
|
6073
6735
|
setCursorStyle(exports.CursorStyle.EWResize);
|
|
6074
6736
|
this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
|
|
6075
6737
|
} else {
|
|
@@ -6077,13 +6739,13 @@ class DiagramCanvas {
|
|
|
6077
6739
|
}
|
|
6078
6740
|
}).on(exports.DragEvents.Drag, (event, d) => {
|
|
6079
6741
|
var _a, _b;
|
|
6080
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
6742
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
|
|
6081
6743
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
6082
6744
|
d.node.stretchSections(exports.Side.Right, pointerCoords[0] - (d.coords[0] + d.width), d.indexXInNode, d.indexYInNode);
|
|
6083
6745
|
}
|
|
6084
6746
|
}).on(exports.DragEvents.End, (event, d) => {
|
|
6085
6747
|
var _a, _b;
|
|
6086
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
6748
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection) {
|
|
6087
6749
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
6088
6750
|
if (this.snapToGrid) {
|
|
6089
6751
|
pointerCoords = this.getClosestGridPoint(pointerCoords);
|
|
@@ -6098,17 +6760,17 @@ class DiagramCanvas {
|
|
|
6098
6760
|
}));
|
|
6099
6761
|
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) => {
|
|
6100
6762
|
var _a, _b;
|
|
6101
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
6763
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
|
|
6102
6764
|
setCursorStyle(exports.CursorStyle.NSResize);
|
|
6103
6765
|
}
|
|
6104
6766
|
}).on(exports.Events.MouseOut, (_event, d) => {
|
|
6105
6767
|
var _a, _b;
|
|
6106
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
6768
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
|
|
6107
6769
|
setCursorStyle();
|
|
6108
6770
|
}
|
|
6109
6771
|
}).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
|
|
6110
6772
|
var _a, _b;
|
|
6111
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
6773
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
|
|
6112
6774
|
setCursorStyle(exports.CursorStyle.NSResize);
|
|
6113
6775
|
this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
|
|
6114
6776
|
} else {
|
|
@@ -6116,13 +6778,13 @@ class DiagramCanvas {
|
|
|
6116
6778
|
}
|
|
6117
6779
|
}).on(exports.DragEvents.Drag, (event, d) => {
|
|
6118
6780
|
var _a, _b;
|
|
6119
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
6781
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
|
|
6120
6782
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
6121
6783
|
d.node.stretchSections(exports.Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height), d.indexXInNode, d.indexYInNode);
|
|
6122
6784
|
}
|
|
6123
6785
|
}).on(exports.DragEvents.End, (event, d) => {
|
|
6124
6786
|
var _a, _b;
|
|
6125
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a ===
|
|
6787
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection) {
|
|
6126
6788
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
6127
6789
|
if (this.snapToGrid) {
|
|
6128
6790
|
pointerCoords = this.getClosestGridPoint(pointerCoords);
|
|
@@ -6138,143 +6800,143 @@ class DiagramCanvas {
|
|
|
6138
6800
|
mergeSelection.attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).attr('opacity', d => d.removed ? 0.5 : 1);
|
|
6139
6801
|
mergeSelection.filter('.shaped-look').select('path').attr('d', d => {
|
|
6140
6802
|
var _a;
|
|
6141
|
-
return generalClosedPath(((_a = d.getConfig()) === null || _a ===
|
|
6803
|
+
return generalClosedPath(((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).shape, 0, 0, d.width, d.height);
|
|
6142
6804
|
}).attr('fill', d => {
|
|
6143
6805
|
var _a, _b;
|
|
6144
|
-
return d.selected ? ((_a = d.getConfig()) === null || _a ===
|
|
6806
|
+
return d.selected ? ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).selectedFillColor : ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).fillColor;
|
|
6145
6807
|
}).attr('stroke', d => {
|
|
6146
6808
|
var _a, _b;
|
|
6147
|
-
return d.selected ? ((_a = d.getConfig()) === null || _a ===
|
|
6809
|
+
return d.selected ? ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).selectedBorderColor : ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).borderColor;
|
|
6148
6810
|
}).attr('stroke-width', d => `${d.highlighted ? 3 : 1}px`);
|
|
6149
6811
|
mergeSelection.filter('.image-look').select('image').attr('x', 0).attr('y', 0).attr('width', d => d.width).attr('height', d => d.height).attr('href', d => {
|
|
6150
6812
|
var _a, _b;
|
|
6151
|
-
return d.selected ? ((_a = d.getConfig()) === null || _a ===
|
|
6813
|
+
return d.selected ? ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).selectedBackgroundImage : ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).backgroundImage;
|
|
6152
6814
|
});
|
|
6153
6815
|
mergeSelection.filter('.stretchable-image-look').select('image.top-left-image').attr('x', 0).attr('y', 0).attr('width', d => {
|
|
6154
6816
|
var _a;
|
|
6155
|
-
return ((_a = d.getConfig()) === null || _a ===
|
|
6817
|
+
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).leftMargin;
|
|
6156
6818
|
}).attr('height', d => {
|
|
6157
6819
|
var _a;
|
|
6158
|
-
return ((_a = d.getConfig()) === null || _a ===
|
|
6820
|
+
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).topMargin;
|
|
6159
6821
|
}).attr('href', d => {
|
|
6160
6822
|
var _a, _b;
|
|
6161
|
-
return d.selected ? ((_a = d.getConfig()) === null || _a ===
|
|
6823
|
+
return d.selected ? ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).selectedBackgroundImageTopLeft : ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).backgroundImageTopLeft;
|
|
6162
6824
|
});
|
|
6163
6825
|
mergeSelection.filter('.stretchable-image-look').select('image.top-image').attr('x', d => {
|
|
6164
6826
|
var _a;
|
|
6165
|
-
return ((_a = d.getConfig()) === null || _a ===
|
|
6827
|
+
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).leftMargin;
|
|
6166
6828
|
}).attr('y', 0).attr('width', d => {
|
|
6167
6829
|
var _a, _b;
|
|
6168
|
-
return d.width - ((_a = d.getConfig()) === null || _a ===
|
|
6830
|
+
return d.width - ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).rightMargin - ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).leftMargin;
|
|
6169
6831
|
}).attr('height', d => {
|
|
6170
6832
|
var _a;
|
|
6171
|
-
return ((_a = d.getConfig()) === null || _a ===
|
|
6833
|
+
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).topMargin;
|
|
6172
6834
|
}).attr('href', d => {
|
|
6173
6835
|
var _a, _b;
|
|
6174
|
-
return d.selected ? ((_a = d.getConfig()) === null || _a ===
|
|
6836
|
+
return d.selected ? ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).selectedBackgroundImageTop : ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).backgroundImageTop;
|
|
6175
6837
|
});
|
|
6176
6838
|
mergeSelection.filter('.stretchable-image-look').select('image.top-right-image').attr('x', d => {
|
|
6177
6839
|
var _a;
|
|
6178
|
-
return d.width - ((_a = d.getConfig()) === null || _a ===
|
|
6840
|
+
return d.width - ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).rightMargin;
|
|
6179
6841
|
}).attr('y', 0).attr('width', d => {
|
|
6180
6842
|
var _a;
|
|
6181
|
-
return ((_a = d.getConfig()) === null || _a ===
|
|
6843
|
+
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).rightMargin;
|
|
6182
6844
|
}).attr('height', d => {
|
|
6183
6845
|
var _a;
|
|
6184
|
-
return ((_a = d.getConfig()) === null || _a ===
|
|
6846
|
+
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).topMargin;
|
|
6185
6847
|
}).attr('href', d => {
|
|
6186
6848
|
var _a, _b;
|
|
6187
|
-
return d.selected ? ((_a = d.getConfig()) === null || _a ===
|
|
6849
|
+
return d.selected ? ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).selectedBackgroundImageTopRight : ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).backgroundImageTopRight;
|
|
6188
6850
|
});
|
|
6189
6851
|
mergeSelection.filter('.stretchable-image-look').select('image.left-image').attr('x', 0).attr('y', d => {
|
|
6190
6852
|
var _a;
|
|
6191
|
-
return ((_a = d.getConfig()) === null || _a ===
|
|
6853
|
+
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).topMargin;
|
|
6192
6854
|
}).attr('width', d => {
|
|
6193
6855
|
var _a;
|
|
6194
|
-
return ((_a = d.getConfig()) === null || _a ===
|
|
6856
|
+
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).leftMargin;
|
|
6195
6857
|
}).attr('height', d => {
|
|
6196
6858
|
var _a, _b;
|
|
6197
|
-
return d.height - ((_a = d.getConfig()) === null || _a ===
|
|
6859
|
+
return d.height - ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).bottomMargin - ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).topMargin;
|
|
6198
6860
|
}).attr('href', d => {
|
|
6199
6861
|
var _a, _b;
|
|
6200
|
-
return d.selected ? ((_a = d.getConfig()) === null || _a ===
|
|
6862
|
+
return d.selected ? ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).selectedBackgroundImageLeft : ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).backgroundImageLeft;
|
|
6201
6863
|
});
|
|
6202
6864
|
mergeSelection.filter('.stretchable-image-look').select('image.center-image').attr('x', d => {
|
|
6203
6865
|
var _a;
|
|
6204
|
-
return ((_a = d.getConfig()) === null || _a ===
|
|
6866
|
+
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).leftMargin;
|
|
6205
6867
|
}).attr('y', d => {
|
|
6206
6868
|
var _a;
|
|
6207
|
-
return ((_a = d.getConfig()) === null || _a ===
|
|
6869
|
+
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).topMargin;
|
|
6208
6870
|
}).attr('width', d => {
|
|
6209
6871
|
var _a, _b;
|
|
6210
|
-
return d.width - ((_a = d.getConfig()) === null || _a ===
|
|
6872
|
+
return d.width - ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).rightMargin - ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).leftMargin;
|
|
6211
6873
|
}).attr('height', d => {
|
|
6212
6874
|
var _a, _b;
|
|
6213
|
-
return d.height - ((_a = d.getConfig()) === null || _a ===
|
|
6875
|
+
return d.height - ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).bottomMargin - ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).topMargin;
|
|
6214
6876
|
}).attr('href', d => {
|
|
6215
6877
|
var _a, _b;
|
|
6216
|
-
return d.selected ? ((_a = d.getConfig()) === null || _a ===
|
|
6878
|
+
return d.selected ? ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).selectedBackgroundImageCenter : ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).backgroundImageCenter;
|
|
6217
6879
|
});
|
|
6218
6880
|
mergeSelection.filter('.stretchable-image-look').select('image.right-image').attr('x', d => {
|
|
6219
6881
|
var _a;
|
|
6220
|
-
return d.width - ((_a = d.getConfig()) === null || _a ===
|
|
6882
|
+
return d.width - ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).rightMargin;
|
|
6221
6883
|
}).attr('y', d => {
|
|
6222
6884
|
var _a;
|
|
6223
|
-
return ((_a = d.getConfig()) === null || _a ===
|
|
6885
|
+
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).topMargin;
|
|
6224
6886
|
}).attr('width', d => {
|
|
6225
6887
|
var _a;
|
|
6226
|
-
return ((_a = d.getConfig()) === null || _a ===
|
|
6888
|
+
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).rightMargin;
|
|
6227
6889
|
}).attr('height', d => {
|
|
6228
6890
|
var _a, _b;
|
|
6229
|
-
return d.height - ((_a = d.getConfig()) === null || _a ===
|
|
6891
|
+
return d.height - ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).bottomMargin - ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).topMargin;
|
|
6230
6892
|
}).attr('href', d => {
|
|
6231
6893
|
var _a, _b;
|
|
6232
|
-
return d.selected ? ((_a = d.getConfig()) === null || _a ===
|
|
6894
|
+
return d.selected ? ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).selectedBackgroundImageRight : ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).backgroundImageRight;
|
|
6233
6895
|
});
|
|
6234
6896
|
mergeSelection.filter('.stretchable-image-look').select('image.bottom-left-image').attr('x', 0).attr('y', d => {
|
|
6235
6897
|
var _a;
|
|
6236
|
-
return d.height - ((_a = d.getConfig()) === null || _a ===
|
|
6898
|
+
return d.height - ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).bottomMargin;
|
|
6237
6899
|
}).attr('width', d => {
|
|
6238
6900
|
var _a;
|
|
6239
|
-
return ((_a = d.getConfig()) === null || _a ===
|
|
6901
|
+
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).leftMargin;
|
|
6240
6902
|
}).attr('height', d => {
|
|
6241
6903
|
var _a;
|
|
6242
|
-
return ((_a = d.getConfig()) === null || _a ===
|
|
6904
|
+
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).bottomMargin;
|
|
6243
6905
|
}).attr('href', d => {
|
|
6244
6906
|
var _a, _b;
|
|
6245
|
-
return d.selected ? ((_a = d.getConfig()) === null || _a ===
|
|
6907
|
+
return d.selected ? ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).selectedBackgroundImageBottomLeft : ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).backgroundImageBottomLeft;
|
|
6246
6908
|
});
|
|
6247
6909
|
mergeSelection.filter('.stretchable-image-look').select('image.bottom-image').attr('x', d => {
|
|
6248
6910
|
var _a;
|
|
6249
|
-
return ((_a = d.getConfig()) === null || _a ===
|
|
6911
|
+
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).leftMargin;
|
|
6250
6912
|
}).attr('y', d => {
|
|
6251
6913
|
var _a;
|
|
6252
|
-
return d.height - ((_a = d.getConfig()) === null || _a ===
|
|
6914
|
+
return d.height - ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).bottomMargin;
|
|
6253
6915
|
}).attr('width', d => {
|
|
6254
6916
|
var _a, _b;
|
|
6255
|
-
return d.width - ((_a = d.getConfig()) === null || _a ===
|
|
6917
|
+
return d.width - ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).rightMargin - ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).leftMargin;
|
|
6256
6918
|
}).attr('height', d => {
|
|
6257
6919
|
var _a;
|
|
6258
|
-
return ((_a = d.getConfig()) === null || _a ===
|
|
6920
|
+
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).bottomMargin;
|
|
6259
6921
|
}).attr('href', d => {
|
|
6260
6922
|
var _a, _b;
|
|
6261
|
-
return d.selected ? ((_a = d.getConfig()) === null || _a ===
|
|
6923
|
+
return d.selected ? ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).selectedBackgroundImageBottom : ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).backgroundImageBottom;
|
|
6262
6924
|
});
|
|
6263
6925
|
mergeSelection.filter('.stretchable-image-look').select('image.bottom-right-image').attr('x', d => {
|
|
6264
6926
|
var _a;
|
|
6265
|
-
return d.width - ((_a = d.getConfig()) === null || _a ===
|
|
6927
|
+
return d.width - ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).rightMargin;
|
|
6266
6928
|
}).attr('y', d => {
|
|
6267
6929
|
var _a;
|
|
6268
|
-
return d.height - ((_a = d.getConfig()) === null || _a ===
|
|
6930
|
+
return d.height - ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).bottomMargin;
|
|
6269
6931
|
}).attr('width', d => {
|
|
6270
6932
|
var _a;
|
|
6271
|
-
return ((_a = d.getConfig()) === null || _a ===
|
|
6933
|
+
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).rightMargin;
|
|
6272
6934
|
}).attr('height', d => {
|
|
6273
6935
|
var _a;
|
|
6274
|
-
return ((_a = d.getConfig()) === null || _a ===
|
|
6936
|
+
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).bottomMargin;
|
|
6275
6937
|
}).attr('href', d => {
|
|
6276
6938
|
var _a, _b;
|
|
6277
|
-
return d.selected ? ((_a = d.getConfig()) === null || _a ===
|
|
6939
|
+
return d.selected ? ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).selectedBackgroundImageBottomRight : ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).backgroundImageBottomRight;
|
|
6278
6940
|
});
|
|
6279
6941
|
mergeSelection.filter('.resizable-x').select('line.left-resizer').attr('x1', RESIZER_THICKNESS / 2).attr('x2', RESIZER_THICKNESS / 2).attr('y1', 0).attr('y2', d => d.height);
|
|
6280
6942
|
mergeSelection.filter('.resizable-y').select('line.top-resizer').attr('x1', 0).attr('x2', d => d.width).attr('y1', RESIZER_THICKNESS / 2).attr('y2', RESIZER_THICKNESS / 2);
|
|
@@ -6282,7 +6944,7 @@ class DiagramCanvas {
|
|
|
6282
6944
|
mergeSelection.filter('.resizable-y').select('line.bottom-resizer').attr('x1', 0).attr('x2', d => d.width).attr('y1', d => d.height - RESIZER_THICKNESS / 2).attr('y2', d => d.height - RESIZER_THICKNESS / 2);
|
|
6283
6945
|
}
|
|
6284
6946
|
updatePortsInView(...ids) {
|
|
6285
|
-
let updateSelection = this.
|
|
6947
|
+
let updateSelection = this.selectCanvasElements().selectAll('g.diagram-port').data(this.model.ports.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
|
|
6286
6948
|
const exitSelection = updateSelection.exit();
|
|
6287
6949
|
const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', 'diagram-port');
|
|
6288
6950
|
if (ids && ids.length > 0) {
|
|
@@ -6295,9 +6957,10 @@ class DiagramCanvas {
|
|
|
6295
6957
|
if (!this.unfinishedConnection && !this.dragging) {
|
|
6296
6958
|
// if there is an unfinished connection, the port will be highlighted automatically if the pointer is close
|
|
6297
6959
|
this.userHighlight.focusOn(d);
|
|
6960
|
+
this.diagramEvent$.next(new DiagramHighlightedEvent(d));
|
|
6298
6961
|
}
|
|
6299
6962
|
if (this.unfinishedConnection) {
|
|
6300
|
-
const canConnectionFinishAtThisPort = this.unfinishedConnection.type.canStartFromType(((_c = (_b = (_a = this.unfinishedConnection.start) === null || _a ===
|
|
6963
|
+
const canConnectionFinishAtThisPort = this.unfinishedConnection.type.canStartFromType(((_c = (_b = (_a = this.unfinishedConnection.start) === null || _a === undefined ? undefined : _a.getNode()) === null || _b === undefined ? undefined : _b.type) === null || _c === undefined ? undefined : _c.id) || '') && this.unfinishedConnection.type.canFinishOnType(((_e = (_d = d.getNode()) === null || _d === undefined ? undefined : _d.type) === null || _e === undefined ? undefined : _e.id) || '') || this.unfinishedConnection.type.canStartFromType(((_g = (_f = d.getNode()) === null || _f === undefined ? undefined : _f.type) === null || _g === undefined ? undefined : _g.id) || '') && this.unfinishedConnection.type.canFinishOnType(((_k = (_j = (_h = this.unfinishedConnection.start) === null || _h === undefined ? undefined : _h.getNode()) === null || _j === undefined ? undefined : _j.type) === null || _k === undefined ? undefined : _k.id) || '');
|
|
6301
6964
|
if (!canConnectionFinishAtThisPort) {
|
|
6302
6965
|
setCursorStyle(exports.CursorStyle.NoDrop);
|
|
6303
6966
|
}
|
|
@@ -6308,9 +6971,13 @@ class DiagramCanvas {
|
|
|
6308
6971
|
}
|
|
6309
6972
|
}).on(exports.Events.Click, (event, d) => {
|
|
6310
6973
|
if (!event.ctrlKey && !event.shiftKey) {
|
|
6974
|
+
const deselectedElements = this.userSelection.all();
|
|
6311
6975
|
this.userSelection.clear();
|
|
6976
|
+
this.diagramEvent$.next(new DiagramSelectionEvent(deselectedElements, false));
|
|
6312
6977
|
}
|
|
6313
|
-
|
|
6978
|
+
const elementToBeToggled = getRelatedNodeOrItself(d);
|
|
6979
|
+
this.userSelection.toggle(elementToBeToggled);
|
|
6980
|
+
this.diagramEvent$.next(new DiagramSelectionEvent([elementToBeToggled], elementToBeToggled.selected));
|
|
6314
6981
|
}).on(exports.Events.ContextMenu, (event, d) => {
|
|
6315
6982
|
if (this.dragging) {
|
|
6316
6983
|
event.preventDefault();
|
|
@@ -6318,17 +6985,19 @@ class DiagramCanvas {
|
|
|
6318
6985
|
this.dragging = false;
|
|
6319
6986
|
return;
|
|
6320
6987
|
}
|
|
6321
|
-
const diagramEvent = new
|
|
6988
|
+
const diagramEvent = new DiagramSecondaryClickEvent(event, d);
|
|
6322
6989
|
this.diagramEvent$.next(diagramEvent);
|
|
6323
6990
|
if (!diagramEvent.defaultPrevented && this.canUserPerformAction(exports.DiagramActions.ContextMenu)) {
|
|
6324
6991
|
event.preventDefault();
|
|
6325
6992
|
const elementToSelect = getRelatedNodeOrItself(d);
|
|
6326
6993
|
this.userHighlight.focusOn(elementToSelect);
|
|
6994
|
+
this.diagramEvent$.next(new DiagramHighlightedEvent(elementToSelect));
|
|
6327
6995
|
this.userSelection.add(elementToSelect);
|
|
6996
|
+
this.diagramEvent$.next(new DiagramSelectionEvent([elementToSelect], true));
|
|
6328
6997
|
this.contextMenu.open(event);
|
|
6329
6998
|
}
|
|
6330
6999
|
}).on(exports.Events.DoubleClick, (event, d) => {
|
|
6331
|
-
const diagramEvent = new
|
|
7000
|
+
const diagramEvent = new DiagramDoubleClickEvent(event, d);
|
|
6332
7001
|
this.diagramEvent$.next(diagramEvent);
|
|
6333
7002
|
}).call(d3__namespace.drag().filter(event => {
|
|
6334
7003
|
this.secondaryButton = isSecondaryButton(event);
|
|
@@ -6356,8 +7025,8 @@ class DiagramCanvas {
|
|
|
6356
7025
|
if (this.canUserPerformAction(exports.DiagramActions.AddConnection) && !d.removed) {
|
|
6357
7026
|
if (this.unfinishedConnection !== undefined) {
|
|
6358
7027
|
const endCoords = [event.x, event.y];
|
|
6359
|
-
(_a = this.unfinishedConnectionTracer) === null || _a ===
|
|
6360
|
-
const unfinishedConnectionGhostNode = (_d = this.unfinishedConnectionTracer) === null || _d ===
|
|
7028
|
+
(_a = this.unfinishedConnectionTracer) === null || _a === undefined ? undefined : _a.attr('d', getConnectionPath(this.unfinishedConnection.type.shape, this.unfinishedConnection.startCoords, endCoords, this.unfinishedConnection.startDirection, this.unfinishedConnection.endDirection, this.unfinishedConnection.type.width, (_b = this.unfinishedConnection.startMarkerLook) === null || _b === undefined ? undefined : _b.markerWidth, (_c = this.unfinishedConnection.endMarkerLook) === null || _c === undefined ? undefined : _c.markerWidth));
|
|
7029
|
+
const unfinishedConnectionGhostNode = (_d = this.unfinishedConnectionTracer) === null || _d === undefined ? undefined : _d.node();
|
|
6361
7030
|
if (unfinishedConnectionGhostNode) {
|
|
6362
7031
|
let margin = 2;
|
|
6363
7032
|
const unfinishedConnectionTotalLength = unfinishedConnectionGhostNode.getTotalLength();
|
|
@@ -6398,7 +7067,7 @@ class DiagramCanvas {
|
|
|
6398
7067
|
this.finishMultipleSelection(event);
|
|
6399
7068
|
} else {
|
|
6400
7069
|
if (this.canUserPerformAction(exports.DiagramActions.AddConnection) && !d.removed) {
|
|
6401
|
-
(_a = this.unfinishedConnectionTracer) === null || _a ===
|
|
7070
|
+
(_a = this.unfinishedConnectionTracer) === null || _a === undefined ? undefined : _a.remove();
|
|
6402
7071
|
const userHighlight = this.userHighlight.getFocus();
|
|
6403
7072
|
if (userHighlight instanceof DiagramPort) {
|
|
6404
7073
|
this.finishConnection(userHighlight);
|
|
@@ -6436,7 +7105,7 @@ class DiagramCanvas {
|
|
|
6436
7105
|
if (this.unfinishedConnection) {
|
|
6437
7106
|
connectionList.push(this.unfinishedConnection);
|
|
6438
7107
|
}
|
|
6439
|
-
let updateSelection = this.
|
|
7108
|
+
let updateSelection = this.selectCanvasElements().selectAll('g.diagram-connection').data(connectionList, d => d.id);
|
|
6440
7109
|
const exitSelection = updateSelection.exit();
|
|
6441
7110
|
const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', 'diagram-connection');
|
|
6442
7111
|
if (ids && ids.length > 0) {
|
|
@@ -6447,12 +7116,16 @@ class DiagramCanvas {
|
|
|
6447
7116
|
enterSelection.on(exports.Events.MouseOver, (_event, d) => {
|
|
6448
7117
|
if (d.end !== undefined && !this.dragging) {
|
|
6449
7118
|
this.userHighlight.focusOn(d);
|
|
7119
|
+
this.diagramEvent$.next(new DiagramHighlightedEvent(d));
|
|
6450
7120
|
}
|
|
6451
7121
|
}).on(exports.Events.Click, (event, d) => {
|
|
6452
7122
|
if (!event.ctrlKey && !event.shiftKey) {
|
|
7123
|
+
const deselectedElements = this.userSelection.all();
|
|
6453
7124
|
this.userSelection.clear();
|
|
7125
|
+
this.diagramEvent$.next(new DiagramSelectionEvent(deselectedElements, false));
|
|
6454
7126
|
}
|
|
6455
7127
|
this.userSelection.toggle(d);
|
|
7128
|
+
this.diagramEvent$.next(new DiagramSelectionEvent([d], d.selected));
|
|
6456
7129
|
}).on(exports.Events.ContextMenu, (event, d) => {
|
|
6457
7130
|
if (this.dragging) {
|
|
6458
7131
|
event.preventDefault();
|
|
@@ -6460,16 +7133,18 @@ class DiagramCanvas {
|
|
|
6460
7133
|
this.dragging = false;
|
|
6461
7134
|
return;
|
|
6462
7135
|
}
|
|
6463
|
-
const diagramEvent = new
|
|
7136
|
+
const diagramEvent = new DiagramSecondaryClickEvent(event, d);
|
|
6464
7137
|
this.diagramEvent$.next(diagramEvent);
|
|
6465
7138
|
if (!diagramEvent.defaultPrevented && this.canUserPerformAction(exports.DiagramActions.ContextMenu)) {
|
|
6466
7139
|
event.preventDefault();
|
|
6467
7140
|
this.userHighlight.focusOn(d);
|
|
7141
|
+
this.diagramEvent$.next(new DiagramHighlightedEvent(d));
|
|
6468
7142
|
this.userSelection.add(d);
|
|
7143
|
+
this.diagramEvent$.next(new DiagramSelectionEvent([d], true));
|
|
6469
7144
|
this.contextMenu.open(event);
|
|
6470
7145
|
}
|
|
6471
7146
|
}).on(exports.Events.DoubleClick, (event, d) => {
|
|
6472
|
-
const diagramEvent = new
|
|
7147
|
+
const diagramEvent = new DiagramDoubleClickEvent(event, d);
|
|
6473
7148
|
this.diagramEvent$.next(diagramEvent);
|
|
6474
7149
|
}).call(d3__namespace.drag().filter(event => {
|
|
6475
7150
|
this.secondaryButton = isSecondaryButton(event);
|
|
@@ -6496,11 +7171,11 @@ class DiagramCanvas {
|
|
|
6496
7171
|
enterSelection.select('g.diagram-connection-end-label').append('text').style('user-select', 'none');
|
|
6497
7172
|
mergeSelection.attr('opacity', d => d.removed ? 0.5 : 1).select('path.diagram-connection-path').attr('d', d => {
|
|
6498
7173
|
var _a, _b;
|
|
6499
|
-
return getConnectionPath(d.type.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.type.width, (_a = d.startMarkerLook) === null || _a ===
|
|
7174
|
+
return getConnectionPath(d.type.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.type.width, (_a = d.startMarkerLook) === null || _a === undefined ? undefined : _a.markerWidth, (_b = d.endMarkerLook) === null || _b === undefined ? undefined : _b.markerWidth);
|
|
6500
7175
|
}).attr('marker-start', d => `url(#${d.id}-start-marker)`).attr('marker-end', d => `url(#${d.id}-end-marker)`).attr('stroke', d => d.selected ? d.type.selectedColor : d.type.color).attr('stroke-width', d => `${d.highlighted ? d.type.width + 1 : d.type.width}px`).attr('stroke-dasharray', d => lineStyleDasharray(d.type.style, d.type.width)).attr('fill', 'none');
|
|
6501
7176
|
mergeSelection.select('path.diagram-connection-path-box').attr('d', d => {
|
|
6502
7177
|
var _a, _b;
|
|
6503
|
-
return getConnectionPath(d.type.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.type.width, (_a = d.startMarkerLook) === null || _a ===
|
|
7178
|
+
return getConnectionPath(d.type.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.type.width, (_a = d.startMarkerLook) === null || _a === undefined ? undefined : _a.markerWidth, (_b = d.endMarkerLook) === null || _b === undefined ? undefined : _b.markerWidth);
|
|
6504
7179
|
}).attr('stroke', 'transparent')
|
|
6505
7180
|
// allow generating pointer events even when it is transparent
|
|
6506
7181
|
.attr('pointer-events', 'stroke').attr('stroke-width', d => `${d.type.width + CONNECTION_PATH_BOX_THICKNESS}px`).attr('stroke-dasharray', d => lineStyleDasharray(d.type.style, d.type.width)).attr('fill', 'none');
|
|
@@ -6510,7 +7185,7 @@ class DiagramCanvas {
|
|
|
6510
7185
|
});
|
|
6511
7186
|
}
|
|
6512
7187
|
updateFieldsInView(...ids) {
|
|
6513
|
-
let updateSelection = this.
|
|
7188
|
+
let updateSelection = this.selectCanvasElements().selectAll('foreignObject.diagram-field').data(this.model.fields.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
|
|
6514
7189
|
const exitSelection = updateSelection.exit();
|
|
6515
7190
|
const enterSelection = updateSelection.enter().append('foreignObject').attr('id', d => d.id).attr('class', 'diagram-field');
|
|
6516
7191
|
if (ids && ids.length > 0) {
|
|
@@ -6521,12 +7196,17 @@ class DiagramCanvas {
|
|
|
6521
7196
|
enterSelection.style('box-sizing', 'border-box').on(exports.Events.MouseOver, (_event, d) => {
|
|
6522
7197
|
if (!this.dragging) {
|
|
6523
7198
|
this.userHighlight.focusOn(d);
|
|
7199
|
+
this.diagramEvent$.next(new DiagramHighlightedEvent(d));
|
|
6524
7200
|
}
|
|
6525
7201
|
}).on(exports.Events.Click, (event, d) => {
|
|
6526
7202
|
if (!event.ctrlKey && !event.shiftKey) {
|
|
7203
|
+
const deselectedElements = this.userSelection.all();
|
|
6527
7204
|
this.userSelection.clear();
|
|
7205
|
+
this.diagramEvent$.next(new DiagramSelectionEvent(deselectedElements, false));
|
|
6528
7206
|
}
|
|
6529
|
-
|
|
7207
|
+
const elementToBeToggled = getRelatedNodeOrItself(d);
|
|
7208
|
+
this.userSelection.toggle(elementToBeToggled);
|
|
7209
|
+
this.diagramEvent$.next(new DiagramSelectionEvent([elementToBeToggled], elementToBeToggled.selected));
|
|
6530
7210
|
}).on(exports.Events.ContextMenu, (event, d) => {
|
|
6531
7211
|
if (this.dragging) {
|
|
6532
7212
|
event.preventDefault();
|
|
@@ -6534,17 +7214,19 @@ class DiagramCanvas {
|
|
|
6534
7214
|
this.dragging = false;
|
|
6535
7215
|
return;
|
|
6536
7216
|
}
|
|
6537
|
-
const diagramEvent = new
|
|
7217
|
+
const diagramEvent = new DiagramSecondaryClickEvent(event, d);
|
|
6538
7218
|
this.diagramEvent$.next(diagramEvent);
|
|
6539
7219
|
if (!diagramEvent.defaultPrevented && this.canUserPerformAction(exports.DiagramActions.ContextMenu)) {
|
|
6540
7220
|
event.preventDefault();
|
|
6541
7221
|
const elementToSelect = getRelatedNodeOrItself(d);
|
|
6542
7222
|
this.userHighlight.focusOn(elementToSelect);
|
|
7223
|
+
this.diagramEvent$.next(new DiagramHighlightedEvent(elementToSelect));
|
|
6543
7224
|
this.userSelection.add(elementToSelect);
|
|
7225
|
+
this.diagramEvent$.next(new DiagramSelectionEvent([elementToSelect], true));
|
|
6544
7226
|
this.contextMenu.open(event);
|
|
6545
7227
|
}
|
|
6546
7228
|
}).on(exports.Events.DoubleClick, (event, d) => {
|
|
6547
|
-
const diagramEvent = new
|
|
7229
|
+
const diagramEvent = new DiagramDoubleClickEvent(event, d);
|
|
6548
7230
|
this.diagramEvent$.next(diagramEvent);
|
|
6549
7231
|
if (!diagramEvent.defaultPrevented && this.canUserPerformAction(exports.DiagramActions.EditField) && d.editable && !d.removed) {
|
|
6550
7232
|
this.currentAction = new EditFieldAction(this, d.id, d.text, '');
|
|
@@ -6616,7 +7298,7 @@ class DiagramCanvas {
|
|
|
6616
7298
|
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('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/>'));
|
|
6617
7299
|
}
|
|
6618
7300
|
updateObjectsInView(...ids) {
|
|
6619
|
-
let updateSelection = this.
|
|
7301
|
+
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);
|
|
6620
7302
|
const exitSelection = updateSelection.exit();
|
|
6621
7303
|
const enterSelection = updateSelection.enter().append('foreignObject').attr('id', d => d.id).attr('class', 'diagram-object');
|
|
6622
7304
|
if (ids && ids.length > 0) {
|
|
@@ -6625,21 +7307,21 @@ class DiagramCanvas {
|
|
|
6625
7307
|
const mergeSelection = enterSelection.merge(updateSelection);
|
|
6626
7308
|
mergeSelection.attr('width', d => `${d.width}px`).attr('height', d => `${d.height}px`).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).html(d => d.html);
|
|
6627
7309
|
exitSelection.remove();
|
|
6628
|
-
enterSelection.on(exports.Events.ContextMenu, event => {
|
|
7310
|
+
enterSelection.on(exports.Events.ContextMenu, (event, d) => {
|
|
6629
7311
|
if (this.dragging) {
|
|
6630
7312
|
event.preventDefault();
|
|
6631
7313
|
event.stopPropagation();
|
|
6632
7314
|
this.dragging = false;
|
|
6633
7315
|
return;
|
|
6634
7316
|
}
|
|
6635
|
-
const diagramEvent = new
|
|
7317
|
+
const diagramEvent = new DiagramSecondaryClickEvent(event, d);
|
|
6636
7318
|
this.diagramEvent$.next(diagramEvent);
|
|
6637
7319
|
if (!diagramEvent.defaultPrevented && this.canUserPerformAction(exports.DiagramActions.ContextMenu)) {
|
|
6638
7320
|
event.preventDefault();
|
|
6639
7321
|
this.contextMenu.open(event);
|
|
6640
7322
|
}
|
|
6641
7323
|
}).on(exports.Events.DoubleClick, (event, d) => {
|
|
6642
|
-
const diagramEvent = new
|
|
7324
|
+
const diagramEvent = new DiagramDoubleClickEvent(event, d);
|
|
6643
7325
|
this.diagramEvent$.next(diagramEvent);
|
|
6644
7326
|
}).call(d3__namespace.drag().filter(event => {
|
|
6645
7327
|
this.secondaryButton = isSecondaryButton(event);
|
|
@@ -6653,7 +7335,7 @@ class DiagramCanvas {
|
|
|
6653
7335
|
}));
|
|
6654
7336
|
}
|
|
6655
7337
|
updateDecoratorsInView(...ids) {
|
|
6656
|
-
let updateSelection = this.
|
|
7338
|
+
let updateSelection = this.selectCanvasElements().selectAll('foreignObject.diagram-decorator').data(this.model.decorators.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
|
|
6657
7339
|
const exitSelection = updateSelection.exit();
|
|
6658
7340
|
const enterSelection = updateSelection.enter().append('foreignObject').attr('id', d => d.id).attr('class', 'diagram-decorator');
|
|
6659
7341
|
if (ids && ids.length > 0) {
|
|
@@ -6662,21 +7344,21 @@ class DiagramCanvas {
|
|
|
6662
7344
|
const mergeSelection = enterSelection.merge(updateSelection);
|
|
6663
7345
|
mergeSelection.attr('width', d => `${d.width}px`).attr('height', d => `${d.height}px`).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).html(d => d.html);
|
|
6664
7346
|
exitSelection.remove();
|
|
6665
|
-
enterSelection.on(exports.Events.ContextMenu, event => {
|
|
7347
|
+
enterSelection.on(exports.Events.ContextMenu, (event, d) => {
|
|
6666
7348
|
if (this.dragging) {
|
|
6667
7349
|
event.preventDefault();
|
|
6668
7350
|
event.stopPropagation();
|
|
6669
7351
|
this.dragging = false;
|
|
6670
7352
|
return;
|
|
6671
7353
|
}
|
|
6672
|
-
const diagramEvent = new
|
|
7354
|
+
const diagramEvent = new DiagramSecondaryClickEvent(event, d);
|
|
6673
7355
|
this.diagramEvent$.next(diagramEvent);
|
|
6674
7356
|
if (!diagramEvent.defaultPrevented && this.canUserPerformAction(exports.DiagramActions.ContextMenu)) {
|
|
6675
7357
|
event.preventDefault();
|
|
6676
7358
|
this.contextMenu.open(event);
|
|
6677
7359
|
}
|
|
6678
7360
|
}).on(exports.Events.DoubleClick, (event, d) => {
|
|
6679
|
-
const diagramEvent = new
|
|
7361
|
+
const diagramEvent = new DiagramDoubleClickEvent(event, d);
|
|
6680
7362
|
this.diagramEvent$.next(diagramEvent);
|
|
6681
7363
|
}).call(d3__namespace.drag().filter(event => {
|
|
6682
7364
|
this.secondaryButton = isSecondaryButton(event);
|
|
@@ -6699,33 +7381,33 @@ class DiagramCanvas {
|
|
|
6699
7381
|
const pathLength = pathNode.getTotalLength();
|
|
6700
7382
|
// bind start labels
|
|
6701
7383
|
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);
|
|
6702
|
-
const startLabelBoundingRect = (_a = connectionSelection.select('g.diagram-connection-start-label text').node()) === null || _a ===
|
|
7384
|
+
const startLabelBoundingRect = (_a = connectionSelection.select('g.diagram-connection-start-label text').node()) === null || _a === undefined ? undefined : _a.getBoundingClientRect();
|
|
6703
7385
|
if (startLabelBoundingRect) {
|
|
6704
7386
|
// don't create space for the label if the label is empty
|
|
6705
|
-
const boundingWidth = !connection.startLabel ? 0 : startLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding(labelConfiguration) + getRightPadding(labelConfiguration);
|
|
6706
|
-
const boundingHeight = !connection.startLabel ? 0 : startLabelBoundingRect.height / this.zoomTransform.k + getTopPadding(labelConfiguration) + getBottomPadding(labelConfiguration);
|
|
7387
|
+
const boundingWidth = !connection.startLabel ? 0 : startLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
|
|
7388
|
+
const boundingHeight = !connection.startLabel ? 0 : startLabelBoundingRect.height / this.zoomTransform.k + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
|
|
6707
7389
|
const pathStartLabelPoint = pathNode.getPointAtLength(Math.max(getLeftMargin(labelConfiguration) + boundingWidth / 2, getRightMargin(labelConfiguration) + boundingWidth / 2, getTopMargin(labelConfiguration) + boundingHeight / 2, getBottomMargin(labelConfiguration) + boundingHeight / 2));
|
|
6708
7390
|
connectionSelection.select('g.diagram-connection-start-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', connection.selected ? connection.type.selectedColor : connection.type.color).attr('stroke', 'none');
|
|
6709
7391
|
connectionSelection.select('g.diagram-connection-start-label').attr('transform', `translate(${pathStartLabelPoint.x},${pathStartLabelPoint.y})`);
|
|
6710
7392
|
}
|
|
6711
7393
|
// bind middle labels
|
|
6712
7394
|
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);
|
|
6713
|
-
const middleLabelBoundingRect = (_b = connectionSelection.select('g.diagram-connection-middle-label text').node()) === null || _b ===
|
|
7395
|
+
const middleLabelBoundingRect = (_b = connectionSelection.select('g.diagram-connection-middle-label text').node()) === null || _b === undefined ? undefined : _b.getBoundingClientRect();
|
|
6714
7396
|
if (middleLabelBoundingRect) {
|
|
6715
7397
|
// don't create space for the label if the label is empty
|
|
6716
|
-
const boundingWidth = !connection.middleLabel ? 0 : middleLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding(labelConfiguration) + getRightPadding(labelConfiguration);
|
|
6717
|
-
const boundingHeight = !connection.middleLabel ? 0 : middleLabelBoundingRect.height / this.zoomTransform.k + getTopPadding(labelConfiguration) + getBottomPadding(labelConfiguration);
|
|
7398
|
+
const boundingWidth = !connection.middleLabel ? 0 : middleLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
|
|
7399
|
+
const boundingHeight = !connection.middleLabel ? 0 : middleLabelBoundingRect.height / this.zoomTransform.k + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
|
|
6718
7400
|
const pathMiddleLabelPoint = pathNode.getPointAtLength(pathLength / 2);
|
|
6719
7401
|
connectionSelection.select('g.diagram-connection-middle-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', connection.selected ? connection.type.selectedColor : connection.type.color).attr('stroke', 'none');
|
|
6720
7402
|
connectionSelection.select('g.diagram-connection-middle-label').attr('transform', `translate(${pathMiddleLabelPoint.x},${pathMiddleLabelPoint.y})`);
|
|
6721
7403
|
}
|
|
6722
7404
|
// bind end labels
|
|
6723
7405
|
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);
|
|
6724
|
-
const endLabelBoundingRect = (_c = connectionSelection.select('g.diagram-connection-end-label text').node()) === null || _c ===
|
|
7406
|
+
const endLabelBoundingRect = (_c = connectionSelection.select('g.diagram-connection-end-label text').node()) === null || _c === undefined ? undefined : _c.getBoundingClientRect();
|
|
6725
7407
|
if (endLabelBoundingRect) {
|
|
6726
7408
|
// don't create space for the label if the label is empty
|
|
6727
|
-
const boundingWidth = !connection.endLabel ? 0 : endLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding(labelConfiguration) + getRightPadding(labelConfiguration);
|
|
6728
|
-
const boundingHeight = !connection.endLabel ? 0 : endLabelBoundingRect.height / this.zoomTransform.k + getTopPadding(labelConfiguration) + getBottomPadding(labelConfiguration);
|
|
7409
|
+
const boundingWidth = !connection.endLabel ? 0 : endLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
|
|
7410
|
+
const boundingHeight = !connection.endLabel ? 0 : endLabelBoundingRect.height / this.zoomTransform.k + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
|
|
6729
7411
|
const pathEndLabelPoint = pathNode.getPointAtLength(pathLength - Math.max(getLeftMargin(labelConfiguration) + boundingWidth / 2, getRightMargin(labelConfiguration) + boundingWidth / 2, getTopMargin(labelConfiguration) + boundingHeight / 2, getBottomMargin(labelConfiguration) + boundingHeight / 2));
|
|
6730
7412
|
connectionSelection.select('g.diagram-connection-end-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', connection.selected ? connection.type.selectedColor : connection.type.color).attr('stroke', 'none');
|
|
6731
7413
|
connectionSelection.select('g.diagram-connection-end-label').attr('transform', `translate(${pathEndLabelPoint.x},${pathEndLabelPoint.y})`);
|
|
@@ -6775,7 +7457,7 @@ class DiagramCanvas {
|
|
|
6775
7457
|
const fieldDimensions = this.minimumSizeOfField(field);
|
|
6776
7458
|
let minimumFieldWidth = fieldDimensions[0];
|
|
6777
7459
|
let minimumFieldHeight = fieldDimensions[1];
|
|
6778
|
-
for (const section of ((_a = field.rootElement.node) === null || _a ===
|
|
7460
|
+
for (const section of ((_a = field.rootElement.node) === null || _a === undefined ? undefined : _a.sections) || []) {
|
|
6779
7461
|
if (section.label) {
|
|
6780
7462
|
if (section.indexXInNode === field.rootElement.indexXInNode && section.indexYInNode !== field.rootElement.indexYInNode) {
|
|
6781
7463
|
minimumFieldWidth = Math.max(minimumFieldWidth, this.minimumSizeOfField(section.label)[0]);
|
|
@@ -6790,8 +7472,8 @@ class DiagramCanvas {
|
|
|
6790
7472
|
if (fieldDimensions[1] < minimumFieldHeight) {
|
|
6791
7473
|
fieldDimensions[1] = minimumFieldHeight;
|
|
6792
7474
|
}
|
|
6793
|
-
let stretchX = fieldDimensions[0] + getLeftMargin((_c = (_b = field.rootElement) === null || _b ===
|
|
6794
|
-
let stretchY = fieldDimensions[1] + getTopMargin((_g = (_f = field.rootElement) === null || _f ===
|
|
7475
|
+
let stretchX = fieldDimensions[0] + getLeftMargin((_c = (_b = field.rootElement) === null || _b === undefined ? undefined : _b.getConfig()) === null || _c === undefined ? undefined : _c.label) + getRightMargin((_e = (_d = field.rootElement) === null || _d === undefined ? undefined : _d.getConfig()) === null || _e === undefined ? undefined : _e.label) - field.rootElement.width;
|
|
7476
|
+
let stretchY = fieldDimensions[1] + getTopMargin((_g = (_f = field.rootElement) === null || _f === undefined ? undefined : _f.getConfig()) === null || _g === undefined ? undefined : _g.label) + getBottomMargin((_j = (_h = field.rootElement) === null || _h === undefined ? undefined : _h.getConfig()) === null || _j === undefined ? undefined : _j.label) - field.rootElement.height;
|
|
6795
7477
|
if (this.snapToGrid) {
|
|
6796
7478
|
stretchX = Math.ceil(stretchX / this.gridSize) * this.gridSize;
|
|
6797
7479
|
stretchY = Math.ceil(stretchY / this.gridSize) * this.gridSize;
|
|
@@ -6803,8 +7485,8 @@ class DiagramCanvas {
|
|
|
6803
7485
|
if (field.rootElement.height + stretchY < (field.rootElement.getMinHeight() || 0)) {
|
|
6804
7486
|
stretchY = (field.rootElement.getMinHeight() || 0) - field.rootElement.height;
|
|
6805
7487
|
}
|
|
6806
|
-
(_k = field.rootElement.node) === null || _k ===
|
|
6807
|
-
(_l = field.rootElement.node) === null || _l ===
|
|
7488
|
+
(_k = field.rootElement.node) === null || _k === undefined ? undefined : _k.stretchSections(exports.Side.Right, stretchX, field.rootElement.indexXInNode, field.rootElement.indexYInNode);
|
|
7489
|
+
(_l = field.rootElement.node) === null || _l === undefined ? undefined : _l.stretchSections(exports.Side.Bottom, stretchY, field.rootElement.indexXInNode, field.rootElement.indexYInNode);
|
|
6808
7490
|
}
|
|
6809
7491
|
}
|
|
6810
7492
|
fitNodeInView(id) {
|
|
@@ -6826,8 +7508,8 @@ class DiagramCanvas {
|
|
|
6826
7508
|
}
|
|
6827
7509
|
}
|
|
6828
7510
|
// add the margin that goes between the rightmost and bottommost points of the sections and the edge of the node
|
|
6829
|
-
newNodeWidth += ((_a = node.type.sectionGrid) === null || _a ===
|
|
6830
|
-
newNodeHeight += ((_b = node.type.sectionGrid) === null || _b ===
|
|
7511
|
+
newNodeWidth += ((_a = node.type.sectionGrid) === null || _a === undefined ? undefined : _a.margin) || 0;
|
|
7512
|
+
newNodeHeight += ((_b = node.type.sectionGrid) === null || _b === undefined ? undefined : _b.margin) || 0;
|
|
6831
7513
|
node.stretch(exports.Side.Right, newNodeWidth - node.width);
|
|
6832
7514
|
node.stretch(exports.Side.Bottom, newNodeHeight - node.height);
|
|
6833
7515
|
}
|
|
@@ -6841,42 +7523,21 @@ class DiagramCanvas {
|
|
|
6841
7523
|
selectCanvasElements() {
|
|
6842
7524
|
return this.selectRoot().select(`.daga-canvas-elements`);
|
|
6843
7525
|
}
|
|
6844
|
-
selectCanvasNodes() {
|
|
6845
|
-
return this.selectRoot().select(`.daga-canvas-nodes`);
|
|
6846
|
-
}
|
|
6847
|
-
selectCanvasSections() {
|
|
6848
|
-
return this.selectRoot().select(`.daga-canvas-sections`);
|
|
6849
|
-
}
|
|
6850
|
-
selectCanvasPorts() {
|
|
6851
|
-
return this.selectRoot().select(`.daga-canvas-ports`);
|
|
6852
|
-
}
|
|
6853
|
-
selectCanvasConnections() {
|
|
6854
|
-
return this.selectRoot().select(`.daga-canvas-connections`);
|
|
6855
|
-
}
|
|
6856
|
-
selectCanvasFields() {
|
|
6857
|
-
return this.selectRoot().select(`.daga-canvas-fields`);
|
|
6858
|
-
}
|
|
6859
|
-
selectCanvasObjects() {
|
|
6860
|
-
return this.selectRoot().select(`.daga-canvas-objects`);
|
|
6861
|
-
}
|
|
6862
|
-
selectCanvasDecorators() {
|
|
6863
|
-
return this.selectRoot().select(`.daga-canvas-decorators`);
|
|
6864
|
-
}
|
|
6865
7526
|
// User actions
|
|
6866
7527
|
startConnection(port) {
|
|
6867
7528
|
var _a, _b, _c, _d;
|
|
6868
|
-
if (this.connectionType && (this.connectionType.canStartFromType(((_b = (_a = port.getNode()) === null || _a ===
|
|
7529
|
+
if (this.connectionType && (this.connectionType.canStartFromType(((_b = (_a = port.getNode()) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.id) || '') || this.connectionType.canFinishOnType(((_d = (_c = port.getNode()) === null || _c === undefined ? undefined : _c.type) === null || _d === undefined ? undefined : _d.id) || ''))) {
|
|
6869
7530
|
this.unfinishedConnection = new DiagramConnection(this.model, this.connectionType, port, undefined, UNFINISHED_CONNECTION_ID);
|
|
6870
7531
|
} else {
|
|
6871
7532
|
if (this.inferConnectionType) {
|
|
6872
7533
|
let differentConnectionType = this.model.connections.types.all().find(t => {
|
|
6873
7534
|
var _a, _b;
|
|
6874
|
-
return t.canStartFromType(((_b = (_a = port.getNode()) === null || _a ===
|
|
7535
|
+
return t.canStartFromType(((_b = (_a = port.getNode()) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.id) || '');
|
|
6875
7536
|
});
|
|
6876
7537
|
if (differentConnectionType === undefined) {
|
|
6877
7538
|
differentConnectionType = this.model.connections.types.all().find(t => {
|
|
6878
7539
|
var _a, _b;
|
|
6879
|
-
return t.canFinishOnType(((_b = (_a = port.getNode()) === null || _a ===
|
|
7540
|
+
return t.canFinishOnType(((_b = (_a = port.getNode()) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.id) || '');
|
|
6880
7541
|
});
|
|
6881
7542
|
}
|
|
6882
7543
|
if (differentConnectionType !== undefined) {
|
|
@@ -6890,14 +7551,14 @@ class DiagramCanvas {
|
|
|
6890
7551
|
this.userHighlight.clear();
|
|
6891
7552
|
if (this.unfinishedConnection !== undefined) {
|
|
6892
7553
|
if (this.unfinishedConnection.start !== port) {
|
|
6893
|
-
if (this.unfinishedConnection.type.canStartFromType(((_d = (_c = (_b = (_a = this.unfinishedConnection) === null || _a ===
|
|
6894
|
-
const addConnectionAction = new AddConnectionAction(this, this.unfinishedConnection.type, (_g = this.unfinishedConnection.start) === null || _g ===
|
|
7554
|
+
if (this.unfinishedConnection.type.canStartFromType(((_d = (_c = (_b = (_a = this.unfinishedConnection) === null || _a === undefined ? undefined : _a.start) === null || _b === undefined ? undefined : _b.getNode()) === null || _c === undefined ? undefined : _c.type) === null || _d === undefined ? undefined : _d.id) || '') && this.unfinishedConnection.type.canFinishOnType(((_f = (_e = port.getNode()) === null || _e === undefined ? undefined : _e.type) === null || _f === undefined ? undefined : _f.id) || '')) {
|
|
7555
|
+
const addConnectionAction = new AddConnectionAction(this, this.unfinishedConnection.type, (_g = this.unfinishedConnection.start) === null || _g === undefined ? undefined : _g.id, port.id);
|
|
6895
7556
|
// clean up the previous unfinished connection
|
|
6896
7557
|
this.dropConnection();
|
|
6897
7558
|
addConnectionAction.do();
|
|
6898
7559
|
this.actionStack.add(addConnectionAction);
|
|
6899
|
-
} else if (this.unfinishedConnection.type.canFinishOnType(((_l = (_k = (_j = (_h = this.unfinishedConnection) === null || _h ===
|
|
6900
|
-
const addConnectionAction = new AddConnectionAction(this, this.unfinishedConnection.type, port.id, (_p = this.unfinishedConnection.start) === null || _p ===
|
|
7560
|
+
} else if (this.unfinishedConnection.type.canFinishOnType(((_l = (_k = (_j = (_h = this.unfinishedConnection) === null || _h === undefined ? undefined : _h.start) === null || _j === undefined ? undefined : _j.getNode()) === null || _k === undefined ? undefined : _k.type) === null || _l === undefined ? undefined : _l.id) || '') && this.unfinishedConnection.type.canStartFromType(((_o = (_m = port.getNode()) === null || _m === undefined ? undefined : _m.type) === null || _o === undefined ? undefined : _o.id) || '')) {
|
|
7561
|
+
const addConnectionAction = new AddConnectionAction(this, this.unfinishedConnection.type, port.id, (_p = this.unfinishedConnection.start) === null || _p === undefined ? undefined : _p.id);
|
|
6901
7562
|
// clean up the previous unfinished connection
|
|
6902
7563
|
this.dropConnection();
|
|
6903
7564
|
addConnectionAction.do();
|
|
@@ -6906,18 +7567,18 @@ class DiagramCanvas {
|
|
|
6906
7567
|
if (this.inferConnectionType) {
|
|
6907
7568
|
let differentConnectionType = this.model.connections.types.all().find(t => {
|
|
6908
7569
|
var _a, _b, _c, _d, _e, _f;
|
|
6909
|
-
return t.canStartFromType(((_d = (_c = (_b = (_a = this.unfinishedConnection) === null || _a ===
|
|
7570
|
+
return t.canStartFromType(((_d = (_c = (_b = (_a = this.unfinishedConnection) === null || _a === undefined ? undefined : _a.start) === null || _b === undefined ? undefined : _b.getNode()) === null || _c === undefined ? undefined : _c.type) === null || _d === undefined ? undefined : _d.id) || '') && t.canFinishOnType(((_f = (_e = port.getNode()) === null || _e === undefined ? undefined : _e.type) === null || _f === undefined ? undefined : _f.id) || '');
|
|
6910
7571
|
});
|
|
6911
7572
|
let invertConnection = false;
|
|
6912
7573
|
if (differentConnectionType === undefined) {
|
|
6913
7574
|
differentConnectionType = this.model.connections.types.all().find(t => {
|
|
6914
7575
|
var _a, _b, _c, _d, _e, _f;
|
|
6915
|
-
return t.canFinishOnType(((_d = (_c = (_b = (_a = this.unfinishedConnection) === null || _a ===
|
|
7576
|
+
return t.canFinishOnType(((_d = (_c = (_b = (_a = this.unfinishedConnection) === null || _a === undefined ? undefined : _a.start) === null || _b === undefined ? undefined : _b.getNode()) === null || _c === undefined ? undefined : _c.type) === null || _d === undefined ? undefined : _d.id) || '') && t.canStartFromType(((_f = (_e = port.getNode()) === null || _e === undefined ? undefined : _e.type) === null || _f === undefined ? undefined : _f.id) || '');
|
|
6916
7577
|
});
|
|
6917
7578
|
invertConnection = true;
|
|
6918
7579
|
}
|
|
6919
7580
|
if (differentConnectionType !== undefined) {
|
|
6920
|
-
const addConnectionAction = new AddConnectionAction(this, differentConnectionType, invertConnection ? port.id : (_q = this.unfinishedConnection.start) === null || _q ===
|
|
7581
|
+
const addConnectionAction = new AddConnectionAction(this, differentConnectionType, invertConnection ? port.id : (_q = this.unfinishedConnection.start) === null || _q === undefined ? undefined : _q.id, invertConnection ? (_r = this.unfinishedConnection.start) === null || _r === undefined ? undefined : _r.id : port.id);
|
|
6921
7582
|
// clean up the previous unfinished connection
|
|
6922
7583
|
this.dropConnection();
|
|
6923
7584
|
addConnectionAction.do();
|
|
@@ -6939,9 +7600,9 @@ class DiagramCanvas {
|
|
|
6939
7600
|
}
|
|
6940
7601
|
dropConnection() {
|
|
6941
7602
|
var _a, _b, _c, _d;
|
|
6942
|
-
(_a = this.unfinishedConnection) === null || _a ===
|
|
6943
|
-
(_b = this.unfinishedConnection) === null || _b ===
|
|
6944
|
-
(_d = (_c = this.unfinishedConnection) === null || _c ===
|
|
7603
|
+
(_a = this.unfinishedConnection) === null || _a === undefined ? undefined : _a.setStart(undefined);
|
|
7604
|
+
(_b = this.unfinishedConnection) === null || _b === undefined ? undefined : _b.setEnd(undefined);
|
|
7605
|
+
(_d = (_c = this.unfinishedConnection) === null || _c === undefined ? undefined : _c.select()) === null || _d === undefined ? undefined : _d.remove();
|
|
6945
7606
|
this.unfinishedConnection = undefined;
|
|
6946
7607
|
}
|
|
6947
7608
|
cancelAllUserActions() {
|
|
@@ -6986,9 +7647,9 @@ class DiagramCanvas {
|
|
|
6986
7647
|
// keep the field from shrinking below its original size
|
|
6987
7648
|
const newWidth = Math.max(inputFieldWidth, width);
|
|
6988
7649
|
const newHeight = Math.max(inputFieldHeight, height);
|
|
6989
|
-
inputFieldContainer === null || inputFieldContainer ===
|
|
7650
|
+
inputFieldContainer === null || inputFieldContainer === undefined ? undefined : inputFieldContainer.attr('width', `${newWidth}px`);
|
|
6990
7651
|
inputField.style('width', `${newWidth}px`);
|
|
6991
|
-
inputFieldContainer === null || inputFieldContainer ===
|
|
7652
|
+
inputFieldContainer === null || inputFieldContainer === undefined ? undefined : inputFieldContainer.attr('height', `${newHeight}px`);
|
|
6992
7653
|
inputField.style('height', `${newHeight}px`);
|
|
6993
7654
|
if (changeCallback) {
|
|
6994
7655
|
changeCallback(value);
|
|
@@ -7010,13 +7671,13 @@ class DiagramCanvas {
|
|
|
7010
7671
|
var _a, _b, _c;
|
|
7011
7672
|
// when removing an element, a blur event is emitted
|
|
7012
7673
|
// we remove the listener for blur so that it doesn't shoot again on element removal
|
|
7013
|
-
(_b = (_a = this.inputFieldContainer) === null || _a ===
|
|
7014
|
-
(_c = this.inputFieldContainer) === null || _c ===
|
|
7674
|
+
(_b = (_a = this.inputFieldContainer) === null || _a === undefined ? undefined : _a.select('input')) === null || _b === undefined ? undefined : _b.on(exports.Events.Blur, null);
|
|
7675
|
+
(_c = this.inputFieldContainer) === null || _c === undefined ? undefined : _c.remove();
|
|
7015
7676
|
this.inputFieldContainer = undefined;
|
|
7016
7677
|
}
|
|
7017
7678
|
minimumSizeOfField(field) {
|
|
7018
7679
|
var _a, _b;
|
|
7019
|
-
const pNode = (_b = (_a = field.select()) === null || _a ===
|
|
7680
|
+
const pNode = (_b = (_a = field.select()) === null || _a === undefined ? undefined : _a.select('p')) === null || _b === undefined ? undefined : _b.node();
|
|
7020
7681
|
if (!pNode) {
|
|
7021
7682
|
// happens when a field has been created but not updated in view yet
|
|
7022
7683
|
return [0, 0];
|
|
@@ -7031,10 +7692,11 @@ class DiagramCanvas {
|
|
|
7031
7692
|
if (this.canUserPerformAction(exports.DiagramActions.MoveNode) && !d.removed) {
|
|
7032
7693
|
setCursorStyle(exports.CursorStyle.Grabbing);
|
|
7033
7694
|
this.draggingFrom = [event.x, event.y];
|
|
7034
|
-
if (d.selected) {
|
|
7695
|
+
if (d.selected && this.userSelection.count(e => e instanceof DiagramNode) > 1) {
|
|
7035
7696
|
this.currentAction = new MoveAction(this, this.userSelection.filter(e => e instanceof DiagramNode).map(n => n.id), d.coords);
|
|
7036
7697
|
} else {
|
|
7037
|
-
|
|
7698
|
+
const ancestorOfNode = d.getLastAncestor();
|
|
7699
|
+
this.currentAction = new SetGeometryAction(this, exports.DiagramActions.MoveNode, d.id, d.getGeometry(), d.getGeometry(), ancestorOfNode === null || ancestorOfNode === undefined ? undefined : ancestorOfNode.id, ancestorOfNode === null || ancestorOfNode === undefined ? undefined : ancestorOfNode.getGeometry(d.id), ancestorOfNode === null || ancestorOfNode === undefined ? undefined : ancestorOfNode.getGeometry(d.id));
|
|
7038
7700
|
}
|
|
7039
7701
|
} else {
|
|
7040
7702
|
setCursorStyle(exports.CursorStyle.NotAllowed);
|
|
@@ -7044,7 +7706,7 @@ class DiagramCanvas {
|
|
|
7044
7706
|
* Method to call to continue the moving of a node triggered by a user drag event.
|
|
7045
7707
|
*/
|
|
7046
7708
|
continueMovingNode(event, d) {
|
|
7047
|
-
if (this.canUserPerformAction(exports.DiagramActions.MoveNode) && this.currentAction instanceof MoveAction && !d.removed) {
|
|
7709
|
+
if (this.canUserPerformAction(exports.DiagramActions.MoveNode) && (this.currentAction instanceof MoveAction || this.currentAction instanceof SetGeometryAction) && !d.removed) {
|
|
7048
7710
|
const newNodeCoords = [event.x - d.width / 2, event.y - d.height / 2];
|
|
7049
7711
|
if (d.selected) {
|
|
7050
7712
|
this.userSelection.move([newNodeCoords[0] - d.coords[0], newNodeCoords[1] - d.coords[1]]);
|
|
@@ -7059,24 +7721,58 @@ class DiagramCanvas {
|
|
|
7059
7721
|
* Method to call to finish the moving of a node triggered by a user drag event.
|
|
7060
7722
|
*/
|
|
7061
7723
|
finishMovingNode(event, d) {
|
|
7724
|
+
var _a, _b, _c;
|
|
7062
7725
|
if (this.canUserPerformAction(exports.DiagramActions.MoveNode) && !d.removed) {
|
|
7063
7726
|
// prevent drag behavior if mouse hasn't moved
|
|
7064
|
-
if (
|
|
7727
|
+
if (this.draggingFrom[0] !== event.x || this.draggingFrom[1] !== event.y) {
|
|
7065
7728
|
let newNodeCoords = [event.x - d.width / 2, event.y - d.height / 2];
|
|
7066
7729
|
if (this.snapToGrid) {
|
|
7067
7730
|
newNodeCoords = this.getClosestGridPoint(newNodeCoords);
|
|
7068
7731
|
}
|
|
7069
|
-
|
|
7070
|
-
|
|
7071
|
-
|
|
7072
|
-
|
|
7073
|
-
|
|
7074
|
-
|
|
7075
|
-
|
|
7732
|
+
if (this.currentAction instanceof MoveAction) {
|
|
7733
|
+
const movingFrom = this.currentAction.delta;
|
|
7734
|
+
this.currentAction.delta = [newNodeCoords[0] - movingFrom[0], newNodeCoords[1] - movingFrom[1]];
|
|
7735
|
+
// reset position of node prior to moving it again
|
|
7736
|
+
if (d.selected) {
|
|
7737
|
+
this.userSelection.move([movingFrom[0] - d.coords[0], movingFrom[1] - d.coords[1]]);
|
|
7738
|
+
} else {
|
|
7739
|
+
d.move(movingFrom);
|
|
7740
|
+
}
|
|
7741
|
+
} else if (this.currentAction instanceof SetGeometryAction) {
|
|
7742
|
+
d.move(newNodeCoords);
|
|
7743
|
+
// if moving a single node, we can change the node's parent,
|
|
7744
|
+
// so we check whether we dropped this node on a potential parent
|
|
7745
|
+
const nodesAtLocation = this.model.nodes.getAtCoordinates(event.x, event.y).filter(n => n.id !== d.id && !n.isDescendantOf(d));
|
|
7746
|
+
// filter by which nodes can have this node as a child
|
|
7747
|
+
const nodesAtLocationWhichCanHaveNodeAsAChild = nodesAtLocation.filter(n => n.type.childrenTypes.includes(d.type.id));
|
|
7748
|
+
// filter by which nodes don't have descendants in this collection
|
|
7749
|
+
const filteredNodesAtLocation = filterByOnlyDescendants(nodesAtLocationWhichCanHaveNodeAsAChild);
|
|
7750
|
+
const droppedOn = filteredNodesAtLocation[filteredNodesAtLocation.length - 1];
|
|
7751
|
+
if (droppedOn !== d.parent && (d.type.canBeParentless || droppedOn !== undefined)) {
|
|
7752
|
+
const ancestorOfDroppedOn = droppedOn === null || droppedOn === undefined ? undefined : droppedOn.getLastAncestor();
|
|
7753
|
+
const fromChildGeometry = this.currentAction.from;
|
|
7754
|
+
const setParentAction = new SetParentAction(this, d.id, (_a = d.parent) === null || _a === undefined ? undefined : _a.id, droppedOn === null || droppedOn === undefined ? undefined : droppedOn.id, fromChildGeometry, d.getGeometry(), ancestorOfDroppedOn === null || ancestorOfDroppedOn === undefined ? undefined : ancestorOfDroppedOn.id, ancestorOfDroppedOn === null || ancestorOfDroppedOn === undefined ? undefined : ancestorOfDroppedOn.getGeometry(d.id), ancestorOfDroppedOn === null || ancestorOfDroppedOn === undefined ? undefined : ancestorOfDroppedOn.getGeometry(d.id));
|
|
7755
|
+
(_b = d.parent) === null || _b === undefined ? undefined : _b.removeChild(d);
|
|
7756
|
+
if (droppedOn !== undefined) {
|
|
7757
|
+
droppedOn.addChild(d);
|
|
7758
|
+
}
|
|
7759
|
+
setParentAction.toChildGeometry = d.getGeometry(d.id);
|
|
7760
|
+
setParentAction.toAncestorGeometry = ancestorOfDroppedOn === null || ancestorOfDroppedOn === undefined ? undefined : ancestorOfDroppedOn.getGeometry(d.id);
|
|
7761
|
+
this.currentAction = setParentAction;
|
|
7762
|
+
} else {
|
|
7763
|
+
const ancestorOfNode = d === null || d === undefined ? undefined : d.getLastAncestor();
|
|
7764
|
+
this.currentAction.ancestorId = ancestorOfNode === null || ancestorOfNode === undefined ? undefined : ancestorOfNode.id;
|
|
7765
|
+
this.currentAction.fromAncestorGeometry = ancestorOfNode === null || ancestorOfNode === undefined ? undefined : ancestorOfNode.getGeometry(d.id);
|
|
7766
|
+
(_c = d.parent) === null || _c === undefined ? undefined : _c.fitToChild(d);
|
|
7767
|
+
this.currentAction.to = d.getGeometry(d.id);
|
|
7768
|
+
this.currentAction.toAncestorGeometry = ancestorOfNode === null || ancestorOfNode === undefined ? undefined : ancestorOfNode.getGeometry(d.id);
|
|
7769
|
+
}
|
|
7770
|
+
}
|
|
7771
|
+
if (this.currentAction !== undefined) {
|
|
7772
|
+
this.currentAction.do();
|
|
7773
|
+
this.actionStack.add(this.currentAction);
|
|
7774
|
+
this.currentAction = undefined;
|
|
7076
7775
|
}
|
|
7077
|
-
this.currentAction.do();
|
|
7078
|
-
this.actionStack.add(this.currentAction);
|
|
7079
|
-
this.currentAction = undefined;
|
|
7080
7776
|
}
|
|
7081
7777
|
}
|
|
7082
7778
|
setCursorStyle();
|
|
@@ -7095,14 +7791,14 @@ class DiagramCanvas {
|
|
|
7095
7791
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7096
7792
|
if (this.draggingFrom[0] !== pointerCoords[0] || this.draggingFrom[1] !== pointerCoords[1]) {
|
|
7097
7793
|
setCursorStyle(exports.CursorStyle.Crosshair);
|
|
7098
|
-
(_d = (_c = (_b = (_a = this.multipleSelectionContainer) === null || _a ===
|
|
7794
|
+
(_d = (_c = (_b = (_a = this.multipleSelectionContainer) === null || _a === undefined ? undefined : _a.attr('x', Math.min(this.draggingFrom[0], pointerCoords[0]))) === null || _b === undefined ? undefined : _b.attr('y', Math.min(this.draggingFrom[1], pointerCoords[1]))) === null || _c === undefined ? undefined : _c.attr('width', Math.abs(this.draggingFrom[0] - pointerCoords[0]))) === null || _d === undefined ? undefined : _d.attr('height', Math.abs(this.draggingFrom[1] - pointerCoords[1]));
|
|
7099
7795
|
this.dragging = true;
|
|
7100
7796
|
}
|
|
7101
7797
|
}
|
|
7102
7798
|
finishMultipleSelection(event) {
|
|
7103
7799
|
var _a;
|
|
7104
7800
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7105
|
-
(_a = this.multipleSelectionContainer) === null || _a ===
|
|
7801
|
+
(_a = this.multipleSelectionContainer) === null || _a === undefined ? undefined : _a.remove();
|
|
7106
7802
|
this.multipleSelectionContainer = undefined;
|
|
7107
7803
|
this.userSelection.clear();
|
|
7108
7804
|
for (const node of this.model.nodes) {
|
|
@@ -7111,6 +7807,7 @@ class DiagramCanvas {
|
|
|
7111
7807
|
}
|
|
7112
7808
|
}
|
|
7113
7809
|
this.multipleSelectionOn = false;
|
|
7810
|
+
this.diagramEvent$.next(new DiagramSelectionEvent(this.userSelection.all(), true));
|
|
7114
7811
|
setCursorStyle();
|
|
7115
7812
|
}
|
|
7116
7813
|
}
|
|
@@ -7230,7 +7927,7 @@ class CollabClient {
|
|
|
7230
7927
|
const initialModel = message.initialModel;
|
|
7231
7928
|
new DagaImporter().import(session.canvas.model, initialModel);
|
|
7232
7929
|
this.startSyncing(session);
|
|
7233
|
-
(_a = session.joinRoomResolve) === null || _a ===
|
|
7930
|
+
(_a = session.joinRoomResolve) === null || _a === undefined ? undefined : _a.call(session);
|
|
7234
7931
|
session.joinRoomResolve = undefined;
|
|
7235
7932
|
break;
|
|
7236
7933
|
}
|
|
@@ -7253,7 +7950,7 @@ class CollabClient {
|
|
|
7253
7950
|
session.locator = message.locator;
|
|
7254
7951
|
this.pendingSessions.delete(message.refId);
|
|
7255
7952
|
this.sessions.set(session.locator, session);
|
|
7256
|
-
(_b = session.createRoomResolve) === null || _b ===
|
|
7953
|
+
(_b = session.createRoomResolve) === null || _b === undefined ? undefined : _b.call(session, session.locator);
|
|
7257
7954
|
session.createRoomResolve = undefined;
|
|
7258
7955
|
// Deliver queued AddMessages now that we have a locator.
|
|
7259
7956
|
for (const message of session.addQueue) {
|
|
@@ -7509,21 +8206,21 @@ class Grid {
|
|
|
7509
8206
|
*/
|
|
7510
8207
|
class AdjacencyLayout {
|
|
7511
8208
|
apply(model) {
|
|
7512
|
-
var _a
|
|
8209
|
+
var _a;
|
|
7513
8210
|
if (model.nodes.length === 0) {
|
|
7514
8211
|
// nothing to arrange...
|
|
7515
8212
|
return model;
|
|
7516
8213
|
}
|
|
7517
8214
|
// arrange nodes
|
|
7518
8215
|
const nodeArrangement = new Grid();
|
|
7519
|
-
const nodesToBeArranged = model.nodes.
|
|
8216
|
+
const nodesToBeArranged = model.nodes.filter(n => !n.parent);
|
|
7520
8217
|
while (nodesToBeArranged.length > 0) {
|
|
7521
8218
|
arrangeNode(nodesToBeArranged[0], nodeArrangement, [0, 0], nodesToBeArranged);
|
|
7522
8219
|
}
|
|
7523
8220
|
// place nodes according to arrangement
|
|
7524
8221
|
const maximumWidth = Math.max(...model.nodes.map(n => n.width));
|
|
7525
8222
|
const maximumHeight = Math.max(...model.nodes.map(n => n.height));
|
|
7526
|
-
const gapSize = (((_a = model.canvas) === null || _a ===
|
|
8223
|
+
const gapSize = (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
|
|
7527
8224
|
for (let y = nodeArrangement.minY(); y <= nodeArrangement.maxY(); ++y) {
|
|
7528
8225
|
for (let x = nodeArrangement.minX(); x <= nodeArrangement.maxX(); ++x) {
|
|
7529
8226
|
const node = nodeArrangement.get([x, y]);
|
|
@@ -7532,7 +8229,6 @@ class AdjacencyLayout {
|
|
|
7532
8229
|
}
|
|
7533
8230
|
}
|
|
7534
8231
|
}
|
|
7535
|
-
(_b = model.canvas) === null || _b === void 0 ? void 0 : _b.diagramChange$.next();
|
|
7536
8232
|
return model;
|
|
7537
8233
|
}
|
|
7538
8234
|
}
|
|
@@ -7553,14 +8249,14 @@ const arrangeNode = (node, nodeArrangement, coords, nodesToBeArranged) => {
|
|
|
7553
8249
|
*/
|
|
7554
8250
|
class BreadthAdjacencyLayout {
|
|
7555
8251
|
apply(model) {
|
|
7556
|
-
var _a
|
|
8252
|
+
var _a;
|
|
7557
8253
|
if (model.nodes.length === 0) {
|
|
7558
8254
|
// nothing to arrange...
|
|
7559
8255
|
return model;
|
|
7560
8256
|
}
|
|
7561
8257
|
// arrange nodes
|
|
7562
8258
|
const nodeArrangement = new Grid();
|
|
7563
|
-
const nodesToBeArranged = model.nodes.
|
|
8259
|
+
const nodesToBeArranged = model.nodes.filter(n => !n.parent);
|
|
7564
8260
|
const nodeGridIndices = {};
|
|
7565
8261
|
const firstNode = nodesToBeArranged[0];
|
|
7566
8262
|
let currentNodeLevel = [firstNode];
|
|
@@ -7589,7 +8285,7 @@ class BreadthAdjacencyLayout {
|
|
|
7589
8285
|
// place nodes according to arrangement
|
|
7590
8286
|
const maximumWidth = Math.max(...model.nodes.map(n => n.width));
|
|
7591
8287
|
const maximumHeight = Math.max(...model.nodes.map(n => n.height));
|
|
7592
|
-
const gapSize = (((_a = model.canvas) === null || _a ===
|
|
8288
|
+
const gapSize = (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
|
|
7593
8289
|
for (let y = nodeArrangement.minY(); y <= nodeArrangement.maxY(); ++y) {
|
|
7594
8290
|
for (let x = nodeArrangement.minX(); x <= nodeArrangement.maxX(); ++x) {
|
|
7595
8291
|
const node = nodeArrangement.get([x, y]);
|
|
@@ -7598,7 +8294,6 @@ class BreadthAdjacencyLayout {
|
|
|
7598
8294
|
}
|
|
7599
8295
|
}
|
|
7600
8296
|
}
|
|
7601
|
-
(_b = model.canvas) === null || _b === void 0 ? void 0 : _b.diagramChange$.next();
|
|
7602
8297
|
return model;
|
|
7603
8298
|
}
|
|
7604
8299
|
}
|
|
@@ -7609,13 +8304,13 @@ class BreadthAdjacencyLayout {
|
|
|
7609
8304
|
*/
|
|
7610
8305
|
class BreadthLayout {
|
|
7611
8306
|
apply(model) {
|
|
7612
|
-
var _a
|
|
8307
|
+
var _a;
|
|
7613
8308
|
if (model.nodes.length === 0) {
|
|
7614
8309
|
// nothing to arrange...
|
|
7615
8310
|
return model;
|
|
7616
8311
|
}
|
|
7617
|
-
const gapSize = (((_a = model.canvas) === null || _a ===
|
|
7618
|
-
let nodesToBeArranged = model.nodes.
|
|
8312
|
+
const gapSize = (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
|
|
8313
|
+
let nodesToBeArranged = model.nodes.filter(n => !n.parent);
|
|
7619
8314
|
// Arrange nodes by a breadth first search
|
|
7620
8315
|
const firstNode = nodesToBeArranged[0];
|
|
7621
8316
|
removeIfExists(nodesToBeArranged, firstNode);
|
|
@@ -7661,7 +8356,6 @@ class BreadthLayout {
|
|
|
7661
8356
|
for (const connection of model.connections) {
|
|
7662
8357
|
connection.tighten();
|
|
7663
8358
|
}
|
|
7664
|
-
(_b = model.canvas) === null || _b === void 0 ? void 0 : _b.diagramChange$.next();
|
|
7665
8359
|
return model;
|
|
7666
8360
|
}
|
|
7667
8361
|
}
|
|
@@ -7672,14 +8366,14 @@ class BreadthLayout {
|
|
|
7672
8366
|
*/
|
|
7673
8367
|
class ForceLayout {
|
|
7674
8368
|
apply(model) {
|
|
7675
|
-
var _a
|
|
8369
|
+
var _a;
|
|
7676
8370
|
if (model.nodes.length === 0) {
|
|
7677
8371
|
// nothing to arrange...
|
|
7678
8372
|
return model;
|
|
7679
8373
|
}
|
|
7680
8374
|
// as a starting point, we apply a simple layout
|
|
7681
8375
|
new BreadthLayout().apply(model);
|
|
7682
|
-
const gapSize = (((_a = model.canvas) === null || _a ===
|
|
8376
|
+
const gapSize = (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
|
|
7683
8377
|
const coolingFactor = 0.99;
|
|
7684
8378
|
const minimumTemperature = 1;
|
|
7685
8379
|
const attractionFactor = 0.1;
|
|
@@ -7757,7 +8451,6 @@ class ForceLayout {
|
|
|
7757
8451
|
for (const connection of model.connections) {
|
|
7758
8452
|
connection.tighten();
|
|
7759
8453
|
}
|
|
7760
|
-
(_b = model.canvas) === null || _b === void 0 ? void 0 : _b.diagramChange$.next();
|
|
7761
8454
|
return model;
|
|
7762
8455
|
}
|
|
7763
8456
|
}
|
|
@@ -7768,20 +8461,19 @@ class ForceLayout {
|
|
|
7768
8461
|
*/
|
|
7769
8462
|
class HorizontalLayout {
|
|
7770
8463
|
apply(model) {
|
|
7771
|
-
var _a
|
|
8464
|
+
var _a;
|
|
7772
8465
|
if (model.nodes.length === 0) {
|
|
7773
8466
|
// nothing to arrange...
|
|
7774
8467
|
return model;
|
|
7775
8468
|
}
|
|
7776
|
-
const gapSize = (((_a = model.canvas) === null || _a ===
|
|
7777
|
-
const nodesToBeArranged = model.nodes.
|
|
8469
|
+
const gapSize = (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
|
|
8470
|
+
const nodesToBeArranged = model.nodes.filter(n => !n.parent);
|
|
7778
8471
|
nodesToBeArranged.sort((a, b) => b.type.priority - a.type.priority);
|
|
7779
8472
|
let widthAccumulator = 0;
|
|
7780
8473
|
for (const node of nodesToBeArranged) {
|
|
7781
8474
|
node.move([widthAccumulator, 0]);
|
|
7782
8475
|
widthAccumulator += node.width + gapSize;
|
|
7783
8476
|
}
|
|
7784
|
-
(_b = model.canvas) === null || _b === void 0 ? void 0 : _b.diagramChange$.next();
|
|
7785
8477
|
return model;
|
|
7786
8478
|
}
|
|
7787
8479
|
}
|
|
@@ -7792,7 +8484,7 @@ class HorizontalLayout {
|
|
|
7792
8484
|
*/
|
|
7793
8485
|
class PriorityLayout {
|
|
7794
8486
|
apply(model) {
|
|
7795
|
-
var _a
|
|
8487
|
+
var _a;
|
|
7796
8488
|
if (model.nodes.length === 0) {
|
|
7797
8489
|
// nothing to arrange...
|
|
7798
8490
|
return model;
|
|
@@ -7804,10 +8496,10 @@ class PriorityLayout {
|
|
|
7804
8496
|
new BreadthLayout().apply(model);
|
|
7805
8497
|
return model;
|
|
7806
8498
|
}
|
|
7807
|
-
const gapSize = (((_a = model.canvas) === null || _a ===
|
|
7808
|
-
const nodesToBeArranged = model.nodes.
|
|
8499
|
+
const gapSize = (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
|
|
8500
|
+
const nodesToBeArranged = model.nodes.filter(n => !n.parent);
|
|
7809
8501
|
const nodeArrangement = [];
|
|
7810
|
-
const nodesWithMaximumPriorityToBeArranged = model.nodes.filter(n => n.getPriority() >= maximumPriority);
|
|
8502
|
+
const nodesWithMaximumPriorityToBeArranged = model.nodes.filter(n => !n.parent).filter(n => n.getPriority() >= maximumPriority);
|
|
7811
8503
|
const nodesWithMaximumPriority = [];
|
|
7812
8504
|
if (nodesWithMaximumPriorityToBeArranged.length > 1) {
|
|
7813
8505
|
// use bfs to sort nodes by distance to the first node
|
|
@@ -7889,7 +8581,6 @@ class PriorityLayout {
|
|
|
7889
8581
|
for (const connection of model.connections) {
|
|
7890
8582
|
connection.tighten();
|
|
7891
8583
|
}
|
|
7892
|
-
(_b = model.canvas) === null || _b === void 0 ? void 0 : _b.diagramChange$.next();
|
|
7893
8584
|
return model;
|
|
7894
8585
|
}
|
|
7895
8586
|
}
|
|
@@ -7900,7 +8591,7 @@ class PriorityLayout {
|
|
|
7900
8591
|
*/
|
|
7901
8592
|
class TreeLayout {
|
|
7902
8593
|
apply(model) {
|
|
7903
|
-
var _a
|
|
8594
|
+
var _a;
|
|
7904
8595
|
if (model.nodes.length === 0) {
|
|
7905
8596
|
// nothing to arrange...
|
|
7906
8597
|
return model;
|
|
@@ -7912,8 +8603,8 @@ class TreeLayout {
|
|
|
7912
8603
|
new BreadthLayout().apply(model);
|
|
7913
8604
|
return model;
|
|
7914
8605
|
}
|
|
7915
|
-
const gapSize = (((_a = model.canvas) === null || _a ===
|
|
7916
|
-
const nodesToBeArranged =
|
|
8606
|
+
const gapSize = (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
|
|
8607
|
+
const nodesToBeArranged = model.nodes.filter(n => !n.parent).sort((n1, n2) => n2.getPriority() - n1.getPriority());
|
|
7917
8608
|
const branches = [];
|
|
7918
8609
|
while (nodesToBeArranged.length > 0) {
|
|
7919
8610
|
const nodeToBeArranged = nodesToBeArranged[0];
|
|
@@ -7942,7 +8633,6 @@ class TreeLayout {
|
|
|
7942
8633
|
for (const connection of model.connections) {
|
|
7943
8634
|
connection.tighten();
|
|
7944
8635
|
}
|
|
7945
|
-
(_b = model.canvas) === null || _b === void 0 ? void 0 : _b.diagramChange$.next();
|
|
7946
8636
|
return model;
|
|
7947
8637
|
}
|
|
7948
8638
|
}
|
|
@@ -7999,20 +8689,19 @@ class Branch {
|
|
|
7999
8689
|
*/
|
|
8000
8690
|
class VerticalLayout {
|
|
8001
8691
|
apply(model) {
|
|
8002
|
-
var _a
|
|
8692
|
+
var _a;
|
|
8003
8693
|
if (model.nodes.length === 0) {
|
|
8004
8694
|
// nothing to arrange...
|
|
8005
8695
|
return model;
|
|
8006
8696
|
}
|
|
8007
|
-
const gapSize = (((_a = model.canvas) === null || _a ===
|
|
8008
|
-
const nodesToBeArranged = model.nodes.
|
|
8697
|
+
const gapSize = (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
|
|
8698
|
+
const nodesToBeArranged = model.nodes.filter(n => !n.parent);
|
|
8009
8699
|
nodesToBeArranged.sort((a, b) => b.type.priority - a.type.priority);
|
|
8010
8700
|
let heightAccumulator = 0;
|
|
8011
8701
|
for (const node of nodesToBeArranged) {
|
|
8012
8702
|
node.move([0, heightAccumulator]);
|
|
8013
8703
|
heightAccumulator += node.height + gapSize;
|
|
8014
8704
|
}
|
|
8015
|
-
(_b = model.canvas) === null || _b === void 0 ? void 0 : _b.diagramChange$.next();
|
|
8016
8705
|
return model;
|
|
8017
8706
|
}
|
|
8018
8707
|
}
|
|
@@ -8030,12 +8719,20 @@ const layouts = {
|
|
|
8030
8719
|
tree: new TreeLayout(),
|
|
8031
8720
|
vertical: new VerticalLayout()
|
|
8032
8721
|
};
|
|
8722
|
+
const getLocationsOfNodes = model => {
|
|
8723
|
+
const locations = {};
|
|
8724
|
+
for (const node of model.nodes) {
|
|
8725
|
+
locations[node.id] = node.coords;
|
|
8726
|
+
}
|
|
8727
|
+
return locations;
|
|
8728
|
+
};
|
|
8033
8729
|
|
|
8034
8730
|
exports.ACTION_STACK_SIZE = ACTION_STACK_SIZE;
|
|
8035
8731
|
exports.ActionStack = ActionStack;
|
|
8036
8732
|
exports.AddConnectionAction = AddConnectionAction;
|
|
8037
8733
|
exports.AddNodeAction = AddNodeAction;
|
|
8038
8734
|
exports.AdjacencyLayout = AdjacencyLayout;
|
|
8735
|
+
exports.ApplyLayoutAction = ApplyLayoutAction;
|
|
8039
8736
|
exports.BreadthAdjacencyLayout = BreadthAdjacencyLayout;
|
|
8040
8737
|
exports.BreadthLayout = BreadthLayout;
|
|
8041
8738
|
exports.CollabClient = CollabClient;
|
|
@@ -8049,6 +8746,7 @@ exports.DiagramConnectionType = DiagramConnectionType;
|
|
|
8049
8746
|
exports.DiagramContextMenu = DiagramContextMenu;
|
|
8050
8747
|
exports.DiagramDecorator = DiagramDecorator;
|
|
8051
8748
|
exports.DiagramDecoratorSet = DiagramDecoratorSet;
|
|
8749
|
+
exports.DiagramDoubleClickEvent = DiagramDoubleClickEvent;
|
|
8052
8750
|
exports.DiagramElement = DiagramElement;
|
|
8053
8751
|
exports.DiagramElementSet = DiagramElementSet;
|
|
8054
8752
|
exports.DiagramEntitySet = DiagramEntitySet;
|
|
@@ -8063,6 +8761,7 @@ exports.DiagramObject = DiagramObject;
|
|
|
8063
8761
|
exports.DiagramObjectSet = DiagramObjectSet;
|
|
8064
8762
|
exports.DiagramPort = DiagramPort;
|
|
8065
8763
|
exports.DiagramPortSet = DiagramPortSet;
|
|
8764
|
+
exports.DiagramSecondaryClickEvent = DiagramSecondaryClickEvent;
|
|
8066
8765
|
exports.DiagramSection = DiagramSection;
|
|
8067
8766
|
exports.DiagramSectionSet = DiagramSectionSet;
|
|
8068
8767
|
exports.DiagramUserHighlight = DiagramUserHighlight;
|
|
@@ -8070,11 +8769,14 @@ exports.DiagramUserSelection = DiagramUserSelection;
|
|
|
8070
8769
|
exports.EditFieldAction = EditFieldAction;
|
|
8071
8770
|
exports.ForceLayout = ForceLayout;
|
|
8072
8771
|
exports.HorizontalLayout = HorizontalLayout;
|
|
8772
|
+
exports.MoveAction = MoveAction;
|
|
8773
|
+
exports.PasteAction = PasteAction;
|
|
8073
8774
|
exports.PriorityLayout = PriorityLayout;
|
|
8074
8775
|
exports.Property = Property;
|
|
8075
8776
|
exports.PropertySet = PropertySet;
|
|
8076
8777
|
exports.RemoveAction = RemoveAction;
|
|
8077
8778
|
exports.SetGeometryAction = SetGeometryAction;
|
|
8779
|
+
exports.SetParentAction = SetParentAction;
|
|
8078
8780
|
exports.TreeLayout = TreeLayout;
|
|
8079
8781
|
exports.UpdateValuesAction = UpdateValuesAction;
|
|
8080
8782
|
exports.ValueSet = ValueSet;
|
|
@@ -8082,15 +8784,18 @@ exports.VerticalLayout = VerticalLayout;
|
|
|
8082
8784
|
exports.addIfNotExists = addIfNotExists;
|
|
8083
8785
|
exports.diff = diff;
|
|
8084
8786
|
exports.equals = equals;
|
|
8787
|
+
exports.filterByOnlyAncestors = filterByOnlyAncestors;
|
|
8788
|
+
exports.filterByOnlyDescendants = filterByOnlyDescendants;
|
|
8085
8789
|
exports.generalClosedPath = generalClosedPath;
|
|
8086
8790
|
exports.getBottomMargin = getBottomMargin;
|
|
8087
|
-
exports.getBottomPadding = getBottomPadding;
|
|
8791
|
+
exports.getBottomPadding = getBottomPadding$1;
|
|
8088
8792
|
exports.getLeftMargin = getLeftMargin;
|
|
8089
|
-
exports.getLeftPadding = getLeftPadding;
|
|
8793
|
+
exports.getLeftPadding = getLeftPadding$1;
|
|
8794
|
+
exports.getLocationsOfNodes = getLocationsOfNodes;
|
|
8090
8795
|
exports.getRightMargin = getRightMargin;
|
|
8091
|
-
exports.getRightPadding = getRightPadding;
|
|
8796
|
+
exports.getRightPadding = getRightPadding$1;
|
|
8092
8797
|
exports.getTopMargin = getTopMargin;
|
|
8093
|
-
exports.getTopPadding = getTopPadding;
|
|
8798
|
+
exports.getTopPadding = getTopPadding$1;
|
|
8094
8799
|
exports.isObject = isObject;
|
|
8095
8800
|
exports.layouts = layouts;
|
|
8096
8801
|
exports.linePath = linePath;
|