@metadev/daga 5.1.0 → 5.1.2

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/index.esm.js CHANGED
@@ -1151,7 +1151,9 @@ var CursorStyle;
1151
1151
  CursorStyle["Grabbing"] = "grabbing";
1152
1152
  CursorStyle["Move"] = "move";
1153
1153
  CursorStyle["NoDrop"] = "no-drop";
1154
+ CursorStyle["NESWResize"] = "nesw-resize";
1154
1155
  CursorStyle["NSResize"] = "ns-resize";
1156
+ CursorStyle["NWSEResize"] = "nwse-resize";
1155
1157
  CursorStyle["NotAllowed"] = "not-allowed";
1156
1158
  CursorStyle["ZoomIn"] = "zoom-in";
1157
1159
  CursorStyle["ZoomOut"] = "zoom-out";
@@ -1250,283 +1252,6 @@ const extractLooksFromConfig = lookConfig => {
1250
1252
  };
1251
1253
  };
1252
1254
 
1253
- /**
1254
- * Represents a collection of diagram entities of a type that exists as part of a diagram model.
1255
- * @public
1256
- * @see DiagramEntity
1257
- * @see DiagramModel
1258
- */
1259
- class DiagramEntitySet {
1260
- constructor() {
1261
- /**
1262
- * The list of entities contained in this set.
1263
- * @private
1264
- */
1265
- this.entities = [];
1266
- /**
1267
- * A mapping of entity ids to their corresponding entity in this set for quickly fetching entities based on their id.
1268
- * @private
1269
- */
1270
- this.entityMap = {};
1271
- }
1272
- /**
1273
- * The number of entities in this set.
1274
- * @public
1275
- */
1276
- get length() {
1277
- return this.size();
1278
- }
1279
- /**
1280
- * Gets all of the entities of this set.
1281
- * @public
1282
- * @returns An array containing all of the entities of this set.
1283
- */
1284
- all() {
1285
- return [...this.entities];
1286
- }
1287
- /**
1288
- * Adds an entity to this set if there are no entities with the same id. Has no effect if there already exists an entity with the same id as the given entity.
1289
- * For creating entities with relationships with other entities, the new() method should be used instead. The add() method adds an entity but doesn't take care of setting that entity's relationships with other entities.
1290
- * @private
1291
- * @param entity An entity to be added to this set.
1292
- */
1293
- add(entity) {
1294
- if (this.entityMap[entity.id] === undefined) {
1295
- this.entityMap[entity.id] = entity;
1296
- this.entities.push(entity);
1297
- }
1298
- }
1299
- /**
1300
- * Removes all the entities in this set.
1301
- * @public
1302
- */
1303
- clear() {
1304
- // remove each entity individually in case classes that extend this implement their own specific cleanup
1305
- while (this.entities.length > 0) {
1306
- this.remove(this.entities[0].id);
1307
- }
1308
- }
1309
- /**
1310
- * Checks if this set contains an entity with the given id.
1311
- * @public
1312
- * @param id An id.
1313
- * @returns `true` if this set contains an entity with the given id, `false` otherwise.
1314
- */
1315
- contains(id) {
1316
- return this.entityMap[id] !== undefined;
1317
- }
1318
- /**
1319
- * Counts the number of entities of this set following the given criteria.
1320
- * @public
1321
- * @returns The number of entities of this set following the given criteria.
1322
- */
1323
- count(predicate) {
1324
- return this.entities.filter(predicate).length;
1325
- }
1326
- /**
1327
- * Gets all of the entities of this set filtered following given criteria.
1328
- * @public
1329
- * @returns An array containing the entities of this set that meet the given criteria.
1330
- */
1331
- filter(predicate) {
1332
- return this.entities.filter(predicate);
1333
- }
1334
- /**
1335
- * Gets an entity of this set matching specific criteria.
1336
- * @public
1337
- * @returns An entity of this set.
1338
- */
1339
- find(predicate) {
1340
- return this.entities.find(predicate);
1341
- }
1342
- /**
1343
- * Gets an entity from this set.
1344
- * @public
1345
- * @param id An id.
1346
- * @returns An entity with the given id, or `undefined` if there are no entities with the given id.
1347
- */
1348
- get(id) {
1349
- return this.entityMap[id];
1350
- }
1351
- /**
1352
- * Gets all of the entities of this set mapped to the result of the given function applied to them.
1353
- * @public
1354
- * @returns An array containing the entities of this set that meet the given criteria.
1355
- */
1356
- map(callback) {
1357
- return this.entities.map(callback);
1358
- }
1359
- /**
1360
- * Attempts to find and remove an entity with the given id. Has no effect if there are no entities with the given id.
1361
- * @public
1362
- * @param id An id.
1363
- */
1364
- remove(id) {
1365
- const entity = this.get(id);
1366
- if (entity !== undefined) {
1367
- delete this.entityMap[id];
1368
- removeIfExists(this.entities, entity);
1369
- }
1370
- }
1371
- /**
1372
- * Gets the number of entities in this set.
1373
- * @public
1374
- */
1375
- size() {
1376
- return this.entities.length;
1377
- }
1378
- /**
1379
- * Iterator to iterate over the entities of this set.
1380
- * @public
1381
- */
1382
- *[Symbol.iterator]() {
1383
- for (const entity of this.entities) {
1384
- yield entity;
1385
- }
1386
- }
1387
- }
1388
-
1389
- /**
1390
- * Default priority value for diagram elements.
1391
- * @private
1392
- */
1393
- const DEFAULT_PRIORITY = 0;
1394
- /**
1395
- * Represents an object which exists as part of a specific diagram model and has a visual representation in a diagram canvas.
1396
- * @public
1397
- * @see DiagramModel
1398
- * @see DiagramCanvas
1399
- */
1400
- class DiagramElement {
1401
- /**
1402
- * Identifier that uniquely identifies this element within its diagram model. Cannot be an empty string.
1403
- * @public
1404
- */
1405
- get id() {
1406
- return this._id;
1407
- }
1408
- /**
1409
- * Whether this diagram element is currently in the user highlight.
1410
- * @private
1411
- */
1412
- get highlighted() {
1413
- var _a, _b;
1414
- return ((_b = (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.userHighlight) === null || _b === void 0 ? void 0 : _b.contains(this.id)) || false;
1415
- }
1416
- /**
1417
- * Whether this diagram element is currently in the user selection.
1418
- */
1419
- get selected() {
1420
- var _a, _b;
1421
- return ((_b = (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.userSelection) === null || _b === void 0 ? void 0 : _b.contains(this.id)) || false;
1422
- }
1423
- constructor(model, id) {
1424
- /**
1425
- * Whether this diagram element has itself been explicitly removed.
1426
- *
1427
- * Override the `removed` getter so that it returns true if and only if:
1428
- * - `selfRemoved` is true, or
1429
- * - `removed` is true for any of this element's dependencies.
1430
- *
1431
- * For example, a DiagramConnection is removed if either of its ports are removed,
1432
- * even if the connection's own `selfRemoved` field is false.
1433
- * @private
1434
- */
1435
- this.selfRemoved = false;
1436
- /**
1437
- * Collaborative timestamp for selfRemoved.
1438
- * @private
1439
- */
1440
- this.selfRemovedTimestamp = null;
1441
- this.model = model;
1442
- this._id = id;
1443
- }
1444
- /**
1445
- * Obtain the selection of this element.
1446
- * @private
1447
- */
1448
- select() {
1449
- var _a, _b;
1450
- return (_b = (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.selectCanvasView()) === null || _b === void 0 ? void 0 : _b.select(`[id='${escapeSelector(this.id)}']`);
1451
- }
1452
- }
1453
- class DiagramElementSet extends DiagramEntitySet {
1454
- all(includeRemoved = false) {
1455
- if (includeRemoved) {
1456
- return super.all();
1457
- } else {
1458
- return super.filter(e => !e.removed);
1459
- }
1460
- }
1461
- contains(id, includeRemoved = false) {
1462
- if (includeRemoved) {
1463
- return super.contains(id);
1464
- } else {
1465
- return super.contains(id) && !this.entityMap[id].removed;
1466
- }
1467
- }
1468
- count(predicate, includeRemoved = false) {
1469
- if (includeRemoved) {
1470
- return super.count(predicate);
1471
- } else {
1472
- return super.count((e, i, a) => predicate(e, i, a) && !e.removed);
1473
- }
1474
- }
1475
- filter(predicate, includeRemoved = false) {
1476
- if (includeRemoved) {
1477
- return super.filter(predicate);
1478
- } else {
1479
- return super.filter((e, i, a) => predicate(e, i, a) && !e.removed);
1480
- }
1481
- }
1482
- find(predicate, includeRemoved = false) {
1483
- if (includeRemoved) {
1484
- return super.find(predicate);
1485
- } else {
1486
- return super.find((e, i, a) => predicate(e, i, a) && !e.removed);
1487
- }
1488
- }
1489
- get(id, includeRemoved = false) {
1490
- if (includeRemoved) {
1491
- return super.get(id);
1492
- } else {
1493
- return this.contains(id) ? super.get(id) : undefined;
1494
- }
1495
- }
1496
- map(callback, includeRemoved = false) {
1497
- if (includeRemoved) {
1498
- return super.map(callback);
1499
- } else {
1500
- return super.filter(e => !e.removed).map(callback);
1501
- }
1502
- }
1503
- remove(id) {
1504
- const entity = this.get(id, true);
1505
- if (entity !== undefined) {
1506
- delete this.entityMap[id];
1507
- removeIfExists(this.entities, entity);
1508
- }
1509
- }
1510
- size(includeRemoved = false) {
1511
- if (includeRemoved) {
1512
- return super.size();
1513
- } else {
1514
- return super.filter(e => !e.removed).length;
1515
- }
1516
- }
1517
- *[Symbol.iterator](includeRemoved = false) {
1518
- if (includeRemoved) {
1519
- for (const entity of this.entities) {
1520
- yield entity;
1521
- }
1522
- } else {
1523
- for (const entity of this.entities.filter(e => !e.removed)) {
1524
- yield entity;
1525
- }
1526
- }
1527
- }
1528
- }
1529
-
1530
1255
  /**
1531
1256
  * A property which is part of a property set and defines what values a value in a value set can take.
1532
1257
  * @public
@@ -2023,94 +1748,371 @@ class ValueSet {
2023
1748
  }
2024
1749
  }
2025
1750
  /**
2026
- * Variant of `overwriteValues` that applies last-writer-wins to each key, updating timestamps if appropriate.
2027
- * @private
2028
- * @param values An object containing all values to set the values to.
1751
+ * Variant of `overwriteValues` that applies last-writer-wins to each key, updating timestamps if appropriate.
1752
+ * @private
1753
+ * @param values An object containing all values to set the values to.
1754
+ */
1755
+ overwriteValuesLww(values, timestamp) {
1756
+ for (const key in values) {
1757
+ const property = this.propertySet.getProperty(key);
1758
+ if (property.type === Type.Object) {
1759
+ this.valueSets[key].overwriteValuesLww(values[key], timestamp);
1760
+ } else {
1761
+ if (timestampWins(timestamp, this.ownTimestamps[key])) {
1762
+ this.setValue(key, values[key]);
1763
+ this.ownTimestamps[key] = timestamp;
1764
+ }
1765
+ }
1766
+ }
1767
+ }
1768
+ /**
1769
+ * Sets all the values of this set to the defaults.
1770
+ * If this set has a root element and any of its properties have root attributes, the root element's attributes are also set to the property's default value if one is provided.
1771
+ * @private
1772
+ */
1773
+ resetValues() {
1774
+ this.displayedProperties = [];
1775
+ this.hiddenProperties = [];
1776
+ this.ownTimestamps = {};
1777
+ for (const key in this.propertySet.propertyMap) {
1778
+ const property = this.propertySet.getProperty(key);
1779
+ const rootAttribute = property.rootAttribute;
1780
+ if (property.type === Type.Object) {
1781
+ this.valueSets[key] = this.constructSubValueSet(key);
1782
+ } else {
1783
+ this.values[key] = clone(property.defaultValue);
1784
+ }
1785
+ if (rootAttribute !== undefined && rootAttribute !== null) {
1786
+ if (property.defaultValue !== undefined && !equals(this.getRootElementValue(rootAttribute), property.defaultValue)) {
1787
+ this.setRootElementValue(rootAttribute, this.values[key]);
1788
+ }
1789
+ }
1790
+ if (property.basic !== false) {
1791
+ this.displayedProperties.push(property);
1792
+ } else {
1793
+ this.hiddenProperties.push(property);
1794
+ }
1795
+ }
1796
+ }
1797
+ /**
1798
+ * Constructs a ValueSet with its corresponding PropertySet representing the values of the object.
1799
+ * @private
1800
+ * @param key Key that the ValueSet is under.
1801
+ * @returns The constructed ValueSet.
1802
+ */
1803
+ constructSubValueSet(key) {
1804
+ const property = this.propertySet.getProperty(key);
1805
+ const propertySet = new PropertySet(property.properties);
1806
+ const valueSet = new ValueSet(propertySet, this.rootElement);
1807
+ valueSet.overwriteValues(clone(property.defaultValue));
1808
+ return valueSet;
1809
+ }
1810
+ /**
1811
+ * Gets the ValueSet under the given key when there are nested ValueSets.
1812
+ * @private
1813
+ * @param key A key.
1814
+ * @returns A ValueSet.
1815
+ */
1816
+ getSubValueSet(key) {
1817
+ return this.valueSets[key];
1818
+ }
1819
+ /**
1820
+ * Moves the given property to the list of displayed properties.
1821
+ * @private
1822
+ * @param property A property.
1823
+ */
1824
+ displayProperty(property) {
1825
+ if (!this.displayedProperties.includes(property)) {
1826
+ this.displayedProperties.push(property);
1827
+ removeIfExists(this.hiddenProperties, property);
1828
+ }
1829
+ }
1830
+ /**
1831
+ * Moves the given property to the list of hidden properties.
1832
+ * @private
1833
+ * @param property A property.
1834
+ */
1835
+ hideProperty(property) {
1836
+ if (!this.hiddenProperties.includes(property)) {
1837
+ this.hiddenProperties.push(property);
1838
+ removeIfExists(this.displayedProperties, property);
1839
+ }
1840
+ }
1841
+ }
1842
+
1843
+ /**
1844
+ * Represents a collection of diagram entities of a type that exists as part of a diagram model.
1845
+ * @public
1846
+ * @see DiagramEntity
1847
+ * @see DiagramModel
1848
+ */
1849
+ class DiagramEntitySet {
1850
+ constructor() {
1851
+ /**
1852
+ * The list of entities contained in this set.
1853
+ * @private
1854
+ */
1855
+ this.entities = [];
1856
+ /**
1857
+ * A mapping of entity ids to their corresponding entity in this set for quickly fetching entities based on their id.
1858
+ * @private
1859
+ */
1860
+ this.entityMap = {};
1861
+ }
1862
+ /**
1863
+ * The number of entities in this set.
1864
+ * @public
1865
+ */
1866
+ get length() {
1867
+ return this.size();
1868
+ }
1869
+ /**
1870
+ * Gets all of the entities of this set.
1871
+ * @public
1872
+ * @returns An array containing all of the entities of this set.
1873
+ */
1874
+ all() {
1875
+ return [...this.entities];
1876
+ }
1877
+ /**
1878
+ * Adds an entity to this set if there are no entities with the same id. Has no effect if there already exists an entity with the same id as the given entity.
1879
+ * For creating entities with relationships with other entities, the new() method should be used instead. The add() method adds an entity but doesn't take care of setting that entity's relationships with other entities.
1880
+ * @private
1881
+ * @param entity An entity to be added to this set.
1882
+ */
1883
+ add(entity) {
1884
+ if (this.entityMap[entity.id] === undefined) {
1885
+ this.entityMap[entity.id] = entity;
1886
+ this.entities.push(entity);
1887
+ }
1888
+ }
1889
+ /**
1890
+ * Removes all the entities in this set.
1891
+ * @public
1892
+ */
1893
+ clear() {
1894
+ // remove each entity individually in case classes that extend this implement their own specific cleanup
1895
+ while (this.entities.length > 0) {
1896
+ this.remove(this.entities[0].id);
1897
+ }
1898
+ }
1899
+ /**
1900
+ * Checks if this set contains an entity with the given id.
1901
+ * @public
1902
+ * @param id An id.
1903
+ * @returns `true` if this set contains an entity with the given id, `false` otherwise.
1904
+ */
1905
+ contains(id) {
1906
+ return this.entityMap[id] !== undefined;
1907
+ }
1908
+ /**
1909
+ * Counts the number of entities of this set following the given criteria.
1910
+ * @public
1911
+ * @returns The number of entities of this set following the given criteria.
1912
+ */
1913
+ count(predicate) {
1914
+ return this.entities.filter(predicate).length;
1915
+ }
1916
+ /**
1917
+ * Gets all of the entities of this set filtered following given criteria.
1918
+ * @public
1919
+ * @returns An array containing the entities of this set that meet the given criteria.
1920
+ */
1921
+ filter(predicate) {
1922
+ return this.entities.filter(predicate);
1923
+ }
1924
+ /**
1925
+ * Gets an entity of this set matching specific criteria.
1926
+ * @public
1927
+ * @returns An entity of this set.
1928
+ */
1929
+ find(predicate) {
1930
+ return this.entities.find(predicate);
1931
+ }
1932
+ /**
1933
+ * Gets an entity from this set.
1934
+ * @public
1935
+ * @param id An id.
1936
+ * @returns An entity with the given id, or `undefined` if there are no entities with the given id.
1937
+ */
1938
+ get(id) {
1939
+ return this.entityMap[id];
1940
+ }
1941
+ /**
1942
+ * Gets all of the entities of this set mapped to the result of the given function applied to them.
1943
+ * @public
1944
+ * @returns An array containing the entities of this set that meet the given criteria.
1945
+ */
1946
+ map(callback) {
1947
+ return this.entities.map(callback);
1948
+ }
1949
+ /**
1950
+ * Attempts to find and remove an entity with the given id. Has no effect if there are no entities with the given id.
1951
+ * @public
1952
+ * @param id An id.
1953
+ */
1954
+ remove(id) {
1955
+ const entity = this.get(id);
1956
+ if (entity !== undefined) {
1957
+ delete this.entityMap[id];
1958
+ removeIfExists(this.entities, entity);
1959
+ }
1960
+ }
1961
+ /**
1962
+ * Gets the number of entities in this set.
1963
+ * @public
2029
1964
  */
2030
- overwriteValuesLww(values, timestamp) {
2031
- for (const key in values) {
2032
- const property = this.propertySet.getProperty(key);
2033
- if (property.type === Type.Object) {
2034
- this.valueSets[key].overwriteValuesLww(values[key], timestamp);
2035
- } else {
2036
- if (timestampWins(timestamp, this.ownTimestamps[key])) {
2037
- this.setValue(key, values[key]);
2038
- this.ownTimestamps[key] = timestamp;
2039
- }
2040
- }
2041
- }
1965
+ size() {
1966
+ return this.entities.length;
2042
1967
  }
2043
1968
  /**
2044
- * Sets all the values of this set to the defaults.
2045
- * If this set has a root element and any of its properties have root attributes, the root element's attributes are also set to the property's default value if one is provided.
2046
- * @private
1969
+ * Iterator to iterate over the entities of this set.
1970
+ * @public
2047
1971
  */
2048
- resetValues() {
2049
- this.displayedProperties = [];
2050
- this.hiddenProperties = [];
2051
- this.ownTimestamps = {};
2052
- for (const key in this.propertySet.propertyMap) {
2053
- const property = this.propertySet.getProperty(key);
2054
- const rootAttribute = property.rootAttribute;
2055
- if (property.type === Type.Object) {
2056
- this.valueSets[key] = this.constructSubValueSet(key);
2057
- } else {
2058
- this.values[key] = clone(property.defaultValue);
2059
- }
2060
- if (rootAttribute !== undefined && rootAttribute !== null) {
2061
- if (property.defaultValue !== undefined && !equals(this.getRootElementValue(rootAttribute), property.defaultValue)) {
2062
- this.setRootElementValue(rootAttribute, this.values[key]);
2063
- }
2064
- }
2065
- if (property.basic !== false) {
2066
- this.displayedProperties.push(property);
2067
- } else {
2068
- this.hiddenProperties.push(property);
2069
- }
1972
+ *[Symbol.iterator]() {
1973
+ for (const entity of this.entities) {
1974
+ yield entity;
2070
1975
  }
2071
1976
  }
1977
+ }
1978
+
1979
+ /**
1980
+ * Default priority value for diagram elements.
1981
+ * @private
1982
+ */
1983
+ const DEFAULT_PRIORITY = 0;
1984
+ /**
1985
+ * Represents an object which exists as part of a specific diagram model and has a visual representation in a diagram canvas.
1986
+ * @public
1987
+ * @see DiagramModel
1988
+ * @see DiagramCanvas
1989
+ */
1990
+ class DiagramElement {
2072
1991
  /**
2073
- * Constructs a ValueSet with its corresponding PropertySet representing the values of the object.
2074
- * @private
2075
- * @param key Key that the ValueSet is under.
2076
- * @returns The constructed ValueSet.
1992
+ * Identifier that uniquely identifies this element within its diagram model. Cannot be an empty string.
1993
+ * @public
2077
1994
  */
2078
- constructSubValueSet(key) {
2079
- const property = this.propertySet.getProperty(key);
2080
- const propertySet = new PropertySet(property.properties);
2081
- const valueSet = new ValueSet(propertySet, this.rootElement);
2082
- valueSet.overwriteValues(clone(property.defaultValue));
2083
- return valueSet;
1995
+ get id() {
1996
+ return this._id;
2084
1997
  }
2085
1998
  /**
2086
- * Gets the ValueSet under the given key when there are nested ValueSets.
1999
+ * Whether this diagram element is currently in the user highlight.
2087
2000
  * @private
2088
- * @param key A key.
2089
- * @returns A ValueSet.
2090
2001
  */
2091
- getSubValueSet(key) {
2092
- return this.valueSets[key];
2002
+ get highlighted() {
2003
+ var _a, _b;
2004
+ return ((_b = (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.userHighlight) === null || _b === void 0 ? void 0 : _b.contains(this.id)) || false;
2093
2005
  }
2094
2006
  /**
2095
- * Moves the given property to the list of displayed properties.
2096
- * @private
2097
- * @param property A property.
2007
+ * Whether this diagram element is currently in the user selection.
2098
2008
  */
2099
- displayProperty(property) {
2100
- if (!this.displayedProperties.includes(property)) {
2101
- this.displayedProperties.push(property);
2102
- removeIfExists(this.hiddenProperties, property);
2103
- }
2009
+ get selected() {
2010
+ var _a, _b;
2011
+ return ((_b = (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.userSelection) === null || _b === void 0 ? void 0 : _b.contains(this.id)) || false;
2012
+ }
2013
+ constructor(model, id) {
2014
+ /**
2015
+ * Whether this diagram element has itself been explicitly removed.
2016
+ *
2017
+ * Override the `removed` getter so that it returns true if and only if:
2018
+ * - `selfRemoved` is true, or
2019
+ * - `removed` is true for any of this element's dependencies.
2020
+ *
2021
+ * For example, a DiagramConnection is removed if either of its ports are removed,
2022
+ * even if the connection's own `selfRemoved` field is false.
2023
+ * @private
2024
+ */
2025
+ this.selfRemoved = false;
2026
+ /**
2027
+ * Collaborative timestamp for selfRemoved.
2028
+ * @private
2029
+ */
2030
+ this.selfRemovedTimestamp = null;
2031
+ this.model = model;
2032
+ this._id = id;
2104
2033
  }
2105
2034
  /**
2106
- * Moves the given property to the list of hidden properties.
2035
+ * Obtain the selection of this element.
2107
2036
  * @private
2108
- * @param property A property.
2109
2037
  */
2110
- hideProperty(property) {
2111
- if (!this.hiddenProperties.includes(property)) {
2112
- this.hiddenProperties.push(property);
2113
- removeIfExists(this.displayedProperties, property);
2038
+ select() {
2039
+ var _a, _b;
2040
+ return (_b = (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.selectCanvasView()) === null || _b === void 0 ? void 0 : _b.select(`[id='${escapeSelector(this.id)}']`);
2041
+ }
2042
+ }
2043
+ class DiagramElementSet extends DiagramEntitySet {
2044
+ all(includeRemoved = false) {
2045
+ if (includeRemoved) {
2046
+ return super.all();
2047
+ } else {
2048
+ return super.filter(e => !e.removed);
2049
+ }
2050
+ }
2051
+ contains(id, includeRemoved = false) {
2052
+ if (includeRemoved) {
2053
+ return super.contains(id);
2054
+ } else {
2055
+ return super.contains(id) && !this.entityMap[id].removed;
2056
+ }
2057
+ }
2058
+ count(predicate, includeRemoved = false) {
2059
+ if (includeRemoved) {
2060
+ return super.count(predicate);
2061
+ } else {
2062
+ return super.count((e, i, a) => predicate(e, i, a) && !e.removed);
2063
+ }
2064
+ }
2065
+ filter(predicate, includeRemoved = false) {
2066
+ if (includeRemoved) {
2067
+ return super.filter(predicate);
2068
+ } else {
2069
+ return super.filter((e, i, a) => predicate(e, i, a) && !e.removed);
2070
+ }
2071
+ }
2072
+ find(predicate, includeRemoved = false) {
2073
+ if (includeRemoved) {
2074
+ return super.find(predicate);
2075
+ } else {
2076
+ return super.find((e, i, a) => predicate(e, i, a) && !e.removed);
2077
+ }
2078
+ }
2079
+ get(id, includeRemoved = false) {
2080
+ if (includeRemoved) {
2081
+ return super.get(id);
2082
+ } else {
2083
+ return this.contains(id) ? super.get(id) : undefined;
2084
+ }
2085
+ }
2086
+ map(callback, includeRemoved = false) {
2087
+ if (includeRemoved) {
2088
+ return super.map(callback);
2089
+ } else {
2090
+ return super.filter(e => !e.removed).map(callback);
2091
+ }
2092
+ }
2093
+ remove(id) {
2094
+ const entity = this.get(id, true);
2095
+ if (entity !== undefined) {
2096
+ delete this.entityMap[id];
2097
+ removeIfExists(this.entities, entity);
2098
+ }
2099
+ }
2100
+ size(includeRemoved = false) {
2101
+ if (includeRemoved) {
2102
+ return super.size();
2103
+ } else {
2104
+ return super.filter(e => !e.removed).length;
2105
+ }
2106
+ }
2107
+ *[Symbol.iterator](includeRemoved = false) {
2108
+ if (includeRemoved) {
2109
+ for (const entity of this.entities) {
2110
+ yield entity;
2111
+ }
2112
+ } else {
2113
+ for (const entity of this.entities.filter(e => !e.removed)) {
2114
+ yield entity;
2115
+ }
2114
2116
  }
2115
2117
  }
2116
2118
  }
@@ -2124,7 +2126,6 @@ const DIAGRAM_CONNECTION_TYPE_DEFAULTS = {
2124
2126
  name: '',
2125
2127
  label: null,
2126
2128
  look: {
2127
- lookType: 'connection-look',
2128
2129
  color: '#000000',
2129
2130
  thickness: 1,
2130
2131
  shape: LineShape.Straight,
@@ -2666,9 +2667,26 @@ class DiagramConnectionSet extends DiagramElementSet {
2666
2667
  }
2667
2668
  }
2668
2669
 
2670
+ /**
2671
+ * The different modes for when a node or section can be resized.
2672
+ * @public
2673
+ * @see DiagramNode
2674
+ * @see DiagramSection
2675
+ */
2669
2676
  var ResizableMode;
2670
2677
  (function (ResizableMode) {
2671
- ResizableMode[ResizableMode["OnlyWhenSelected"] = 0] = "OnlyWhenSelected";
2678
+ /**
2679
+ * Resizable mode for always being resizable.
2680
+ */
2681
+ ResizableMode[ResizableMode["Always"] = 0] = "Always";
2682
+ /**
2683
+ * Resizable mode for only being resizable while selected.
2684
+ */
2685
+ ResizableMode[ResizableMode["OnlyWhenSelected"] = 1] = "OnlyWhenSelected";
2686
+ /**
2687
+ * Resizable mode for never being resizable.
2688
+ */
2689
+ ResizableMode[ResizableMode["Never"] = 2] = "Never";
2672
2690
  })(ResizableMode || (ResizableMode = {}));
2673
2691
 
2674
2692
  /**
@@ -2687,7 +2705,6 @@ const DIAGRAM_FIELD_DEFAULTS = {
2687
2705
  fit: false,
2688
2706
  shrink: true,
2689
2707
  look: {
2690
- lookType: 'field-look',
2691
2708
  fillColor: 'transparent',
2692
2709
  fontColor: '#000000',
2693
2710
  fontFamily: "'Wonder Unit Sans', sans-serif",
@@ -2860,9 +2877,7 @@ const getBottomMargin = config => {
2860
2877
  } else if (typeof config.margin === 'number') {
2861
2878
  return config.margin;
2862
2879
  } else {
2863
- if (config.margin.length === 0) {
2864
- return DIAGRAM_FIELD_DEFAULTS.margin;
2865
- } else if (config.margin.length === 1) {
2880
+ if (config.margin.length === 1) {
2866
2881
  return config.margin[0];
2867
2882
  } else if (config.margin.length === 2) {
2868
2883
  return config.margin[0];
@@ -2879,9 +2894,7 @@ const getLeftMargin = config => {
2879
2894
  } else if (typeof config.margin === 'number') {
2880
2895
  return config.margin;
2881
2896
  } else {
2882
- if (config.margin.length === 0) {
2883
- return DIAGRAM_FIELD_DEFAULTS.margin;
2884
- } else if (config.margin.length === 1) {
2897
+ if (config.margin.length === 1) {
2885
2898
  return config.margin[0];
2886
2899
  } else if (config.margin.length === 2) {
2887
2900
  return config.margin[1];
@@ -2898,9 +2911,7 @@ const getRightMargin = config => {
2898
2911
  } else if (typeof config.margin === 'number') {
2899
2912
  return config.margin;
2900
2913
  } else {
2901
- if (config.margin.length === 0) {
2902
- return DIAGRAM_FIELD_DEFAULTS.margin;
2903
- } else if (config.margin.length === 1) {
2914
+ if (config.margin.length === 1) {
2904
2915
  return config.margin[0];
2905
2916
  } else if (config.margin.length === 2) {
2906
2917
  return config.margin[1];
@@ -2917,9 +2928,7 @@ const getTopMargin = config => {
2917
2928
  } else if (typeof config.margin === 'number') {
2918
2929
  return config.margin;
2919
2930
  } else {
2920
- if (config.margin.length === 0) {
2921
- return DIAGRAM_FIELD_DEFAULTS.margin;
2922
- } else if (config.margin.length === 1) {
2931
+ if (config.margin.length === 1) {
2923
2932
  return config.margin[0];
2924
2933
  } else if (config.margin.length === 2) {
2925
2934
  return config.margin[0];
@@ -2936,9 +2945,7 @@ const getBottomPadding$1 = config => {
2936
2945
  } else if (typeof config.padding === 'number') {
2937
2946
  return config.padding;
2938
2947
  } else {
2939
- if (config.padding.length === 0) {
2940
- return DIAGRAM_FIELD_DEFAULTS.padding;
2941
- } else if (config.padding.length === 1) {
2948
+ if (config.padding.length === 1) {
2942
2949
  return config.padding[0];
2943
2950
  } else if (config.padding.length === 2) {
2944
2951
  return config.padding[0];
@@ -2955,9 +2962,7 @@ const getLeftPadding$1 = config => {
2955
2962
  } else if (typeof config.padding === 'number') {
2956
2963
  return config.padding;
2957
2964
  } else {
2958
- if (config.padding.length === 0) {
2959
- return DIAGRAM_FIELD_DEFAULTS.padding;
2960
- } else if (config.padding.length === 1) {
2965
+ if (config.padding.length === 1) {
2961
2966
  return config.padding[0];
2962
2967
  } else if (config.padding.length === 2) {
2963
2968
  return config.padding[1];
@@ -2974,9 +2979,7 @@ const getRightPadding$1 = config => {
2974
2979
  } else if (typeof config.padding === 'number') {
2975
2980
  return config.padding;
2976
2981
  } else {
2977
- if (config.padding.length === 0) {
2978
- return DIAGRAM_FIELD_DEFAULTS.padding;
2979
- } else if (config.padding.length === 1) {
2982
+ if (config.padding.length === 1) {
2980
2983
  return config.padding[0];
2981
2984
  } else if (config.padding.length === 2) {
2982
2985
  return config.padding[1];
@@ -2993,19 +2996,88 @@ const getTopPadding$1 = config => {
2993
2996
  } else if (typeof config.padding === 'number') {
2994
2997
  return config.padding;
2995
2998
  } else {
2996
- if (config.padding.length === 0) {
2997
- return DIAGRAM_FIELD_DEFAULTS.padding;
2998
- } else if (config.padding.length === 1) {
2999
+ if (config.padding.length === 1) {
2999
3000
  return config.padding[0];
3000
3001
  } else if (config.padding.length === 2) {
3001
3002
  return config.padding[0];
3002
3003
  } else if (config.padding.length === 3) {
3003
3004
  return config.padding[0];
3004
3005
  } else {
3005
- return config.padding[0];
3006
+ return config.padding[0];
3007
+ }
3008
+ }
3009
+ };
3010
+
3011
+ /**
3012
+ * Default values of the parameters of a diagram field.
3013
+ * @private
3014
+ * @see ResizerConfig
3015
+ */
3016
+ const DIAGRAM_RESIZER_DEFAULTS = {
3017
+ mode: ResizableMode.Never,
3018
+ thickness: 10,
3019
+ outerMargin: 0,
3020
+ look: {
3021
+ fillColor: 'transparent',
3022
+ borderColor: 'transparent',
3023
+ borderThickness: 0
3024
+ }
3025
+ };
3026
+ /**
3027
+ * Holds the data for the resizers of a type of node or section.
3028
+ * @public
3029
+ * @see DiagramNode
3030
+ * @see DiagramSection
3031
+ */
3032
+ class DiagramResizer {
3033
+ constructor(options) {
3034
+ var _a;
3035
+ let config;
3036
+ if (typeof options === 'boolean') {
3037
+ config = {
3038
+ mode: options ? ResizableMode.Always : ResizableMode.Never
3039
+ };
3040
+ } else if (typeof options === 'string' || typeof options === 'number') {
3041
+ config = {
3042
+ mode: options
3043
+ };
3044
+ } else {
3045
+ config = options;
3046
+ }
3047
+ config = Object.assign(Object.assign({}, DIAGRAM_RESIZER_DEFAULTS), config);
3048
+ this.mode = config.mode;
3049
+ this.thickness = config.thickness;
3050
+ this.outerMargin = config.outerMargin;
3051
+ const looks = extractLooksFromConfig((_a = config.look) !== null && _a !== void 0 ? _a : DIAGRAM_RESIZER_DEFAULTS.look);
3052
+ this.defaultLook = looks.defaultLook;
3053
+ this.selectedLook = looks.selectedLook;
3054
+ this.highlightedLook = looks.highlightedLook;
3055
+ this.selectedAndHighlightedLook = looks.selectedAndHighlightedLook;
3056
+ }
3057
+ /**
3058
+ * Current look of this resizer.
3059
+ * @private
3060
+ */
3061
+ getLook(rootElement) {
3062
+ if (!rootElement) {
3063
+ return this.defaultLook;
3064
+ }
3065
+ if (rootElement.selected) {
3066
+ if (rootElement.highlighted) {
3067
+ return this.selectedAndHighlightedLook;
3068
+ } else {
3069
+ return this.selectedLook;
3070
+ }
3071
+ } else {
3072
+ if (rootElement.highlighted) {
3073
+ return this.highlightedLook;
3074
+ } else {
3075
+ return this.defaultLook;
3076
+ }
3006
3077
  }
3007
3078
  }
3008
- };
3079
+ }
3080
+ const DIAGRAM_DEFAULT_RESIZER = new DiagramResizer(DIAGRAM_RESIZER_DEFAULTS);
3009
3081
 
3010
3082
  /**
3011
3083
  * Default value of the default width of a diagram section.
@@ -3059,8 +3131,21 @@ class DiagramSectionType {
3059
3131
  this.label = options.label || null;
3060
3132
  this.ports = options.ports || [];
3061
3133
  this.priority = options.priority || DEFAULT_PRIORITY;
3062
- this.resizableX = options.resizableX;
3063
- this.resizableY = options.resizableY;
3134
+ if (typeof options.resizableX === 'undefined') {
3135
+ this.resizerX = undefined;
3136
+ } else {
3137
+ this.resizerX = new DiagramResizer(options.resizableX);
3138
+ }
3139
+ if (typeof options.resizableY === 'undefined') {
3140
+ this.resizerY = undefined;
3141
+ } else {
3142
+ this.resizerY = new DiagramResizer(options.resizableY);
3143
+ }
3144
+ if (typeof options.resizableXY === 'undefined') {
3145
+ this.resizerXY = undefined;
3146
+ } else {
3147
+ this.resizerXY = new DiagramResizer(options.resizableXY);
3148
+ }
3064
3149
  const looks = extractLooksFromConfig(options.look || DIAGRAM_NODE_LOOK_DEFAULTS);
3065
3150
  this.defaultLook = looks.defaultLook;
3066
3151
  this.selectedLook = looks.selectedLook;
@@ -3204,6 +3289,30 @@ class DiagramSection extends DiagramElement {
3204
3289
  var _a, _b, _c, _d, _e, _f;
3205
3290
  return ((_f = (_e = (_d = (_c = (_b = (_a = this.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.sectionGrid) === null || _c === void 0 ? void 0 : _c.sections) === null || _d === void 0 ? void 0 : _d[this.indexYInNode]) === null || _e === void 0 ? void 0 : _e[this.indexXInNode]) === null || _f === void 0 ? void 0 : _f.priority) || DEFAULT_PRIORITY;
3206
3291
  }
3292
+ /**
3293
+ * Returns the horizontal resizer of this section.
3294
+ * @public
3295
+ */
3296
+ getResizerX() {
3297
+ var _a, _b, _c, _d;
3298
+ return (_d = (_b = (_a = this.type) === null || _a === void 0 ? void 0 : _a.resizerX) !== null && _b !== void 0 ? _b : (_c = this.node) === null || _c === void 0 ? void 0 : _c.getResizerX()) !== null && _d !== void 0 ? _d : DIAGRAM_DEFAULT_RESIZER;
3299
+ }
3300
+ /**
3301
+ * Returns the vertical resizer of this section.
3302
+ * @public
3303
+ */
3304
+ getResizerY() {
3305
+ var _a, _b, _c, _d;
3306
+ return (_d = (_b = (_a = this.type) === null || _a === void 0 ? void 0 : _a.resizerY) !== null && _b !== void 0 ? _b : (_c = this.node) === null || _c === void 0 ? void 0 : _c.getResizerY()) !== null && _d !== void 0 ? _d : DIAGRAM_DEFAULT_RESIZER;
3307
+ }
3308
+ /**
3309
+ * Returns the diagonal resizer of this section.
3310
+ * @public
3311
+ */
3312
+ getResizerXY() {
3313
+ var _a, _b, _c, _d;
3314
+ return (_d = (_b = (_a = this.type) === null || _a === void 0 ? void 0 : _a.resizerXY) !== null && _b !== void 0 ? _b : (_c = this.node) === null || _c === void 0 ? void 0 : _c.getResizerXY()) !== null && _d !== void 0 ? _d : DIAGRAM_DEFAULT_RESIZER;
3315
+ }
3207
3316
  /**
3208
3317
  * Returns whether this section can be resized horizontally.
3209
3318
  * If the section has a specific resizableX setting, it uses that.
@@ -3213,11 +3322,16 @@ class DiagramSection extends DiagramElement {
3213
3322
  getResizableX() {
3214
3323
  var _a;
3215
3324
  const sectionType = this.type;
3216
- if ((sectionType === null || sectionType === void 0 ? void 0 : sectionType.resizableX) !== undefined) {
3217
- if (sectionType.resizableX === ResizableMode.OnlyWhenSelected) {
3218
- return this.selected;
3325
+ if ((sectionType === null || sectionType === void 0 ? void 0 : sectionType.resizerX) !== undefined) {
3326
+ switch (sectionType.resizerX.mode) {
3327
+ case ResizableMode.OnlyWhenSelected:
3328
+ return this.selected;
3329
+ case ResizableMode.Always:
3330
+ return true;
3331
+ case ResizableMode.Never:
3332
+ default:
3333
+ return false;
3219
3334
  }
3220
- return sectionType.resizableX;
3221
3335
  }
3222
3336
  return ((_a = this.node) === null || _a === void 0 ? void 0 : _a.getResizableX()) || false;
3223
3337
  }
@@ -3230,14 +3344,41 @@ class DiagramSection extends DiagramElement {
3230
3344
  getResizableY() {
3231
3345
  var _a;
3232
3346
  const sectionType = this.type;
3233
- if ((sectionType === null || sectionType === void 0 ? void 0 : sectionType.resizableY) !== undefined) {
3234
- if (sectionType.resizableY === ResizableMode.OnlyWhenSelected) {
3235
- return this.selected;
3347
+ if ((sectionType === null || sectionType === void 0 ? void 0 : sectionType.resizerY) !== undefined) {
3348
+ switch (sectionType.resizerY.mode) {
3349
+ case ResizableMode.OnlyWhenSelected:
3350
+ return this.selected;
3351
+ case ResizableMode.Always:
3352
+ return true;
3353
+ case ResizableMode.Never:
3354
+ default:
3355
+ return false;
3236
3356
  }
3237
- return sectionType.resizableY;
3238
3357
  }
3239
3358
  return ((_a = this.node) === null || _a === void 0 ? void 0 : _a.getResizableY()) || false;
3240
3359
  }
3360
+ /**
3361
+ * Returns whether this section can be resized diagonally.
3362
+ * If the section has a specific resizableXY setting, it uses that.
3363
+ * Otherwise, it inherits from the parent node's resizableXY setting.
3364
+ * @public
3365
+ */
3366
+ getResizableXY() {
3367
+ var _a;
3368
+ const sectionType = this.type;
3369
+ if ((sectionType === null || sectionType === void 0 ? void 0 : sectionType.resizerXY) !== undefined) {
3370
+ switch (sectionType.resizerXY.mode) {
3371
+ case ResizableMode.OnlyWhenSelected:
3372
+ return this.selected;
3373
+ case ResizableMode.Always:
3374
+ return true;
3375
+ case ResizableMode.Never:
3376
+ default:
3377
+ return false;
3378
+ }
3379
+ }
3380
+ return ((_a = this.node) === null || _a === void 0 ? void 0 : _a.getResizableXY()) || false;
3381
+ }
3241
3382
  /**
3242
3383
  * Get the port of this section which is closest to the given coordinates.
3243
3384
  * @param coords A point in the diagram.
@@ -3529,6 +3670,7 @@ const DIAGRAM_NODE_TYPE_DEFAULTS = {
3529
3670
  defaultHeight: 1,
3530
3671
  minWidth: 1,
3531
3672
  minHeight: 1,
3673
+ defaultZ: 0,
3532
3674
  resizableX: false,
3533
3675
  resizableY: false,
3534
3676
  snapToGridOffset: [0, 0, 0, 0],
@@ -3558,8 +3700,28 @@ class DiagramNodeType {
3558
3700
  this.defaultHeight = values.defaultHeight;
3559
3701
  this.minWidth = values.minWidth;
3560
3702
  this.minHeight = values.minHeight;
3561
- this.resizableX = values.resizableX;
3562
- this.resizableY = values.resizableY;
3703
+ this.defaultZ = values.defaultZ;
3704
+ if (typeof options.resizableX === 'undefined') {
3705
+ this.resizerX = new DiagramResizer({
3706
+ mode: ResizableMode.Never
3707
+ });
3708
+ } else {
3709
+ this.resizerX = new DiagramResizer(options.resizableX);
3710
+ }
3711
+ if (typeof options.resizableY === 'undefined') {
3712
+ this.resizerY = new DiagramResizer({
3713
+ mode: ResizableMode.Never
3714
+ });
3715
+ } else {
3716
+ this.resizerY = new DiagramResizer(options.resizableY);
3717
+ }
3718
+ if (typeof options.resizableXY === 'undefined') {
3719
+ this.resizerXY = new DiagramResizer({
3720
+ mode: ResizableMode.Never
3721
+ });
3722
+ } else {
3723
+ this.resizerXY = new DiagramResizer(options.resizableXY);
3724
+ }
3563
3725
  this.snapToGridOffset = values.snapToGridOffset;
3564
3726
  this.bottomPadding = getBottomPadding(values);
3565
3727
  this.leftPadding = getLeftPadding(values);
@@ -3628,7 +3790,7 @@ class DiagramNode extends DiagramElement {
3628
3790
  }
3629
3791
  }
3630
3792
  /**
3631
- * Current look of this port.
3793
+ * Current look of this node.
3632
3794
  * @private
3633
3795
  */
3634
3796
  get look() {
@@ -3719,6 +3881,7 @@ class DiagramNode extends DiagramElement {
3719
3881
  this.coords = coords;
3720
3882
  this.width = type.defaultWidth;
3721
3883
  this.height = type.defaultHeight;
3884
+ this.z = type.defaultZ;
3722
3885
  }
3723
3886
  get removed() {
3724
3887
  return this.selfRemoved;
@@ -3746,30 +3909,84 @@ class DiagramNode extends DiagramElement {
3746
3909
  child.raise();
3747
3910
  }
3748
3911
  }
3912
+ /**
3913
+ * Put this element above other elements in the view if they have a lower z coordinate.
3914
+ */
3915
+ raiseWithZ() {
3916
+ this.raise();
3917
+ const overlappingNodesWithHigherPriority = this.model.nodes.filter(n => n.id !== this.id && n.z > this.z && rectanglesIntersect([n.coords, [n.coords[0] + n.width, n.coords[1] + n.height]], [this.coords, [this.coords[0] + this.width, this.coords[1] + this.height]]));
3918
+ for (const n of overlappingNodesWithHigherPriority) {
3919
+ n.raiseWithZ();
3920
+ }
3921
+ }
3749
3922
  getPriority() {
3750
3923
  return this.type.priority;
3751
3924
  }
3925
+ /**
3926
+ * Returns the horizontal resizer of this node.
3927
+ * @public
3928
+ */
3929
+ getResizerX() {
3930
+ return this.type.resizerX;
3931
+ }
3932
+ /**
3933
+ * Returns the vertical resizer of this node.
3934
+ * @public
3935
+ */
3936
+ getResizerY() {
3937
+ return this.type.resizerY;
3938
+ }
3939
+ /**
3940
+ * Returns the diagonal resizer of this node.
3941
+ * @public
3942
+ */
3943
+ getResizerXY() {
3944
+ return this.type.resizerXY;
3945
+ }
3752
3946
  /**
3753
3947
  * Returns whether this node can be resized horizontally.
3754
3948
  * @public
3755
3949
  */
3756
3950
  getResizableX() {
3757
- const resizableX = this.type.resizableX;
3758
- if (resizableX === ResizableMode.OnlyWhenSelected) {
3759
- return this.selected;
3951
+ switch (this.type.resizerX.mode) {
3952
+ case ResizableMode.OnlyWhenSelected:
3953
+ return this.selected;
3954
+ case ResizableMode.Always:
3955
+ return true;
3956
+ case ResizableMode.Never:
3957
+ default:
3958
+ return false;
3760
3959
  }
3761
- return resizableX;
3762
3960
  }
3763
3961
  /**
3764
3962
  * Returns whether this node can be resized vertically.
3765
3963
  * @public
3766
3964
  */
3767
3965
  getResizableY() {
3768
- const resizableY = this.type.resizableY;
3769
- if (resizableY === ResizableMode.OnlyWhenSelected) {
3770
- return this.selected;
3966
+ switch (this.type.resizerY.mode) {
3967
+ case ResizableMode.OnlyWhenSelected:
3968
+ return this.selected;
3969
+ case ResizableMode.Always:
3970
+ return true;
3971
+ case ResizableMode.Never:
3972
+ default:
3973
+ return false;
3974
+ }
3975
+ }
3976
+ /**
3977
+ * Returns whether this node can be resized diagonally.
3978
+ * @public
3979
+ */
3980
+ getResizableXY() {
3981
+ switch (this.type.resizerXY.mode) {
3982
+ case ResizableMode.OnlyWhenSelected:
3983
+ return this.selected;
3984
+ case ResizableMode.Always:
3985
+ return true;
3986
+ case ResizableMode.Never:
3987
+ default:
3988
+ return false;
3771
3989
  }
3772
- return resizableY;
3773
3990
  }
3774
3991
  /**
3775
3992
  * Get the port of this node which is closest to the given coordinates.
@@ -4005,6 +4222,7 @@ class DiagramNode extends DiagramElement {
4005
4222
  }
4006
4223
  this.setGeometry({
4007
4224
  coords,
4225
+ z: this.z,
4008
4226
  width: this.width,
4009
4227
  height: this.height,
4010
4228
  // We already moved the sections above - skip changing them in setDimensions.
@@ -4056,6 +4274,7 @@ class DiagramNode extends DiagramElement {
4056
4274
  }
4057
4275
  this.setGeometry({
4058
4276
  coords: [newCoordsX[0], newCoordsY[0]],
4277
+ z: this.z,
4059
4278
  width: newCoordsX[1] - newCoordsX[0],
4060
4279
  height: newCoordsY[1] - newCoordsY[0],
4061
4280
  // we ignore this.sections, the stretching of a node with sections is handled in the stretchSections method
@@ -4163,6 +4382,7 @@ class DiagramNode extends DiagramElement {
4163
4382
  }
4164
4383
  return {
4165
4384
  coords: [...this.coords],
4385
+ z: this.z,
4166
4386
  width: this.width,
4167
4387
  height: this.height,
4168
4388
  sections,
@@ -4179,6 +4399,7 @@ class DiagramNode extends DiagramElement {
4179
4399
  const oldCoordsX = [this.coords[0], this.coords[0] + this.width];
4180
4400
  const oldCoordsY = [this.coords[1], this.coords[1] + this.height];
4181
4401
  this.coords = [...geometry.coords];
4402
+ this.z = geometry.z;
4182
4403
  this.width = geometry.width;
4183
4404
  this.height = geometry.height;
4184
4405
  const newCoordsX = [this.coords[0], this.coords[0] + this.width];
@@ -4508,9 +4729,7 @@ const getBottomPadding = config => {
4508
4729
  } else if (typeof config.padding === 'number') {
4509
4730
  return config.padding;
4510
4731
  } else {
4511
- if (config.padding.length === 0) {
4512
- return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
4513
- } else if (config.padding.length === 1) {
4732
+ if (config.padding.length === 1) {
4514
4733
  return config.padding[0];
4515
4734
  } else if (config.padding.length === 2) {
4516
4735
  return config.padding[0];
@@ -4527,9 +4746,7 @@ const getLeftPadding = config => {
4527
4746
  } else if (typeof config.padding === 'number') {
4528
4747
  return config.padding;
4529
4748
  } else {
4530
- if (config.padding.length === 0) {
4531
- return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
4532
- } else if (config.padding.length === 1) {
4749
+ if (config.padding.length === 1) {
4533
4750
  return config.padding[0];
4534
4751
  } else if (config.padding.length === 2) {
4535
4752
  return config.padding[1];
@@ -4546,9 +4763,7 @@ const getRightPadding = config => {
4546
4763
  } else if (typeof config.padding === 'number') {
4547
4764
  return config.padding;
4548
4765
  } else {
4549
- if (config.padding.length === 0) {
4550
- return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
4551
- } else if (config.padding.length === 1) {
4766
+ if (config.padding.length === 1) {
4552
4767
  return config.padding[0];
4553
4768
  } else if (config.padding.length === 2) {
4554
4769
  return config.padding[1];
@@ -4565,9 +4780,7 @@ const getTopPadding = config => {
4565
4780
  } else if (typeof config.padding === 'number') {
4566
4781
  return config.padding;
4567
4782
  } else {
4568
- if (config.padding.length === 0) {
4569
- return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
4570
- } else if (config.padding.length === 1) {
4783
+ if (config.padding.length === 1) {
4571
4784
  return config.padding[0];
4572
4785
  } else if (config.padding.length === 2) {
4573
4786
  return config.padding[0];
@@ -5363,6 +5576,7 @@ class AddNodeCollabAction {
5363
5576
  } else {
5364
5577
  node.valueSet.resetValues();
5365
5578
  }
5579
+ node.raiseWithZ();
5366
5580
  }
5367
5581
  serialize() {
5368
5582
  return {
@@ -5521,6 +5735,7 @@ class SetGeometryCollabAction {
5521
5735
  }
5522
5736
  }
5523
5737
  (_c = node.parent) === null || _c === void 0 ? void 0 : _c.fitToChild(node);
5738
+ node.raiseWithZ();
5524
5739
  node.geometryTimestamp = this.timestamp;
5525
5740
  }
5526
5741
  }
@@ -6751,14 +6966,28 @@ class DiagramModel {
6751
6966
  }
6752
6967
 
6753
6968
  /**
6754
- * Checks if the given mouse event was produced with a secondary button press.
6969
+ * Checks if the given pointer event was produced with a secondary button press.
6755
6970
  * @private
6756
- * @param event A mouse event.
6757
- * @returns `true` if the given mouse event was produced with a secondary button press, `false` otherwise.
6971
+ * @param event A pointer event.
6972
+ * @returns `true` if the given pointer event was produced with a secondary button press, `false` otherwise.
6758
6973
  */
6759
6974
  const isSecondaryButton = event => {
6760
6975
  return !!event.button;
6761
6976
  };
6977
+ /**
6978
+ * Obtain the pointer event which is valid for passing to the `d3.pointer()` function.
6979
+ * @param event A pointer event.
6980
+ * @returns A pointer event which can be passed to the `d3.pointer()` function.
6981
+ */
6982
+ const getEventHoldingCoordinates = event => {
6983
+ if (event.type === 'drag' || event.type === 'start' || event.type === 'end') {
6984
+ const sourceEvent = event.sourceEvent;
6985
+ if (sourceEvent && (sourceEvent.type === 'touchmove' || sourceEvent.type === 'touchstart' || sourceEvent.type === 'touchend')) {
6986
+ return sourceEvent.touches[0] || sourceEvent.changedTouches[0];
6987
+ }
6988
+ }
6989
+ return event;
6990
+ };
6762
6991
  /**
6763
6992
  * Get the SVG path of a diagram connection.
6764
6993
  * @private
@@ -6787,12 +7016,13 @@ const getRelatedNodeOrItself = element => {
6787
7016
  return element.rootElement instanceof DiagramNode || element.rootElement instanceof DiagramSection || element.rootElement instanceof DiagramPort ? getRelatedNodeOrItself(element.rootElement) : element;
6788
7017
  };
6789
7018
  const needsResizerX = element => {
7019
+ var _a;
6790
7020
  if (element instanceof DiagramNode) {
6791
- return element.type.resizableX !== false;
7021
+ return element.type.resizerX.mode !== ResizableMode.Never;
6792
7022
  }
6793
7023
  if (element instanceof DiagramSection) {
6794
- if (element.type !== undefined) {
6795
- return element.type.resizableX !== false;
7024
+ if (((_a = element.type) === null || _a === void 0 ? void 0 : _a.resizerX) !== undefined) {
7025
+ return element.type.resizerX.mode !== ResizableMode.Never;
6796
7026
  }
6797
7027
  if (element.node !== undefined) {
6798
7028
  return needsResizerX(element.node);
@@ -6801,12 +7031,13 @@ const needsResizerX = element => {
6801
7031
  return false;
6802
7032
  };
6803
7033
  const needsResizerY = element => {
7034
+ var _a;
6804
7035
  if (element instanceof DiagramNode) {
6805
- return element.type.resizableY !== false;
7036
+ return element.type.resizerY.mode !== ResizableMode.Never;
6806
7037
  }
6807
7038
  if (element instanceof DiagramSection) {
6808
- if (element.type !== undefined) {
6809
- return element.type.resizableY !== false;
7039
+ if (((_a = element.type) === null || _a === void 0 ? void 0 : _a.resizerY) !== undefined) {
7040
+ return element.type.resizerY.mode !== ResizableMode.Never;
6810
7041
  }
6811
7042
  if (element.node !== undefined) {
6812
7043
  return needsResizerY(element.node);
@@ -6814,6 +7045,21 @@ const needsResizerY = element => {
6814
7045
  }
6815
7046
  return false;
6816
7047
  };
7048
+ const needsResizerXY = element => {
7049
+ var _a;
7050
+ if (element instanceof DiagramNode) {
7051
+ return element.type.resizerXY.mode !== ResizableMode.Never;
7052
+ }
7053
+ if (element instanceof DiagramSection) {
7054
+ if (((_a = element.type) === null || _a === void 0 ? void 0 : _a.resizerXY) !== undefined) {
7055
+ return element.type.resizerXY.mode !== ResizableMode.Never;
7056
+ }
7057
+ if (element.node !== undefined) {
7058
+ return needsResizerXY(element.node);
7059
+ }
7060
+ }
7061
+ return false;
7062
+ };
6817
7063
  const initializeLook = selection => {
6818
7064
  selection.filter('.shaped-look').append('path');
6819
7065
  selection.filter('.image-look').append('image').attr('preserveAspectRatio', 'none');
@@ -6878,7 +7124,7 @@ const DOTS_GRID_DEFAULTS = Object.assign(Object.assign({}, GRID_DEFAULTS), {
6878
7124
  thickness: 0.05,
6879
7125
  color: 'rgba(0, 0, 0, 0.1)'
6880
7126
  });
6881
- const initializeBackground = (canvas, canvasView, backgroundConfig) => {
7127
+ const initializeBackground = (canvasView, backgroundConfig) => {
6882
7128
  var _a, _b;
6883
7129
  switch ((_a = backgroundConfig === null || backgroundConfig === void 0 ? void 0 : backgroundConfig.style) !== null && _a !== void 0 ? _a : '') {
6884
7130
  case 'image':
@@ -7654,11 +7900,6 @@ class DiagramUserSelection extends DiagramElementSet {
7654
7900
  * @private
7655
7901
  */
7656
7902
  const CONNECTION_PATH_BOX_THICKNESS = 12;
7657
- /**
7658
- * Thickness of the resizer line used to resize nodes and sections on drag, in diagram units.
7659
- * @private
7660
- */
7661
- const RESIZER_THICKNESS = 6;
7662
7903
  /**
7663
7904
  * Maximum number of user actions that can be recorded in the user action stack.
7664
7905
  * @private
@@ -7959,7 +8200,7 @@ class DiagramCanvas {
7959
8200
  }));
7960
8201
  const canvasDefs = canvasView.append('defs');
7961
8202
  const canvasBackground = [];
7962
- canvasBackground.push(initializeBackground(this, canvasView, this.backgroundConfig));
8203
+ canvasBackground.push(initializeBackground(canvasView, this.backgroundConfig).attr('class', 'daga-background'));
7963
8204
  for (let i = 0; i < this.ancillaryGridsConfig.length; ++i) {
7964
8205
  canvasBackground.push(initializeGrid(this, canvasView, canvasDefs, this.ancillaryGridPatternIds[i], this.ancillaryGridsConfig[i]));
7965
8206
  }
@@ -8017,7 +8258,7 @@ class DiagramCanvas {
8017
8258
  }
8018
8259
  getViewCoordinates() {
8019
8260
  var _a, _b, _c;
8020
- const canvasViewBoundingBox = (_c = (_b = (_a = this.selectCanvasView()) === null || _a === void 0 ? void 0 : _a.select('rect')) === null || _b === void 0 ? void 0 : _b.node()) === null || _c === void 0 ? void 0 : _c.getBBox();
8261
+ const canvasViewBoundingBox = (_c = (_b = (_a = this.selectCanvasView()) === null || _a === void 0 ? void 0 : _a.select('.daga-background')) === null || _b === void 0 ? void 0 : _b.node()) === null || _c === void 0 ? void 0 : _c.getBBox();
8021
8262
  /*
8022
8263
  transform the coordinates of the zoomTransform to the coordinates
8023
8264
  needed to point the zoomTransfrom to the center of the screen to
@@ -8069,7 +8310,11 @@ class DiagramCanvas {
8069
8310
  var _a;
8070
8311
  // if there are no nodes, we have nothing to do here
8071
8312
  if (this.model.nodes.length > 0) {
8072
- const canvasViewBoundingBox = (_a = this.selectCanvasView().select('rect').node()) === null || _a === void 0 ? void 0 : _a.getBBox();
8313
+ const canvasViewBoundingBox = (_a = this.selectCanvasView().select('.daga-background').node()) === null || _a === void 0 ? void 0 : _a.getBBox();
8314
+ if (!canvasViewBoundingBox.width || !canvasViewBoundingBox.height) {
8315
+ // prevent errors if the width or height is invalid
8316
+ return;
8317
+ }
8073
8318
  const nonRemovedNodes = (nodeIds === null || nodeIds === void 0 ? void 0 : nodeIds.map(i => this.model.nodes.get(i)).filter(n => !!n)) || this.model.nodes.all();
8074
8319
  const minimumX = Math.min(...nonRemovedNodes.map(n => n.coords[0]));
8075
8320
  const maximumX = Math.max(...nonRemovedNodes.map(n => n.coords[0] + n.width));
@@ -8112,30 +8357,14 @@ class DiagramCanvas {
8112
8357
  const rootDimensions = [(rootBoundingClientRect === null || rootBoundingClientRect === void 0 ? void 0 : rootBoundingClientRect.width) || 0, (rootBoundingClientRect === null || rootBoundingClientRect === void 0 ? void 0 : rootBoundingClientRect.height) || 0];
8113
8358
  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]];
8114
8359
  }
8115
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8116
- getEventHoldingCoordinates(event) {
8117
- if (event.type === 'drag' || event.type === 'start' || event.type === 'end') {
8118
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8119
- const sourceEvent = event.sourceEvent;
8120
- if (sourceEvent && (sourceEvent.type === 'touchmove' || sourceEvent.type === 'touchstart' || sourceEvent.type === 'touchend')) {
8121
- return (
8122
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8123
- event.sourceEvent.touches[0] ||
8124
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8125
- event.sourceEvent.changedTouches[0]
8126
- );
8127
- }
8128
- }
8129
- return event;
8130
- }
8131
8360
  getPointerLocationRelativeToCanvas(event) {
8132
- return d3.pointer(this.getEventHoldingCoordinates(event), this.selectCanvasElements().node());
8361
+ return d3.pointer(getEventHoldingCoordinates(event), this.selectCanvasElements().node());
8133
8362
  }
8134
8363
  getPointerLocationRelativeToRoot(event) {
8135
- return d3.pointer(this.getEventHoldingCoordinates(event), this.selectSVGElement().node());
8364
+ return d3.pointer(getEventHoldingCoordinates(event), this.selectSVGElement().node());
8136
8365
  }
8137
8366
  getPointerLocationRelativeToBody(event) {
8138
- return d3.pointer(this.getEventHoldingCoordinates(event), d3.select('body').node());
8367
+ return d3.pointer(getEventHoldingCoordinates(event), d3.select('body').node());
8139
8368
  }
8140
8369
  getPointerLocationRelativeToScreen(event) {
8141
8370
  const pointerLocationRelativeToBody = this.getPointerLocationRelativeToBody(event);
@@ -8153,7 +8382,7 @@ class DiagramCanvas {
8153
8382
  updateNodesInView(...ids) {
8154
8383
  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);
8155
8384
  const exitSelection = updateSelection.exit();
8156
- const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', d => `diagram-node${needsResizerX(d) ? ' resizable-x' : ''}${needsResizerY(d) ? ' resizable-y' : ''} ${d.type.defaultLook.lookType}`);
8385
+ const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', d => `diagram-node${needsResizerX(d) ? ' resizable-x' : ''}${needsResizerY(d) ? ' resizable-y' : ''}${needsResizerXY(d) ? ' resizable-xy' : ''} ${d.type.defaultLook.lookType}`);
8157
8386
  if (ids && ids.length > 0) {
8158
8387
  updateSelection = updateSelection.filter(d => ids.includes(d.id));
8159
8388
  }
@@ -8179,65 +8408,210 @@ class DiagramCanvas {
8179
8408
  this.dragging = false;
8180
8409
  return;
8181
8410
  }
8182
- const diagramEvent = new DiagramSecondaryClickEvent(event, d);
8183
- this.diagramEvent$.next(diagramEvent);
8184
- if (!diagramEvent.defaultPrevented && this.canUserPerformAction(DiagramActions.ContextMenu)) {
8185
- event.preventDefault();
8186
- this.userHighlight.focusOn(d);
8187
- this.diagramEvent$.next(new DiagramHighlightedEvent(d));
8188
- this.userSelection.add(d);
8189
- this.diagramEvent$.next(new DiagramSelectionEvent([d], true));
8190
- this.contextMenu.open(event);
8411
+ const diagramEvent = new DiagramSecondaryClickEvent(event, d);
8412
+ this.diagramEvent$.next(diagramEvent);
8413
+ if (!diagramEvent.defaultPrevented && this.canUserPerformAction(DiagramActions.ContextMenu)) {
8414
+ event.preventDefault();
8415
+ this.userHighlight.focusOn(d);
8416
+ this.diagramEvent$.next(new DiagramHighlightedEvent(d));
8417
+ this.userSelection.add(d);
8418
+ this.diagramEvent$.next(new DiagramSelectionEvent([d], true));
8419
+ this.contextMenu.open(event);
8420
+ }
8421
+ }).on(Events.DoubleClick, (event, d) => {
8422
+ const diagramEvent = new DiagramDoubleClickEvent(event, d);
8423
+ this.diagramEvent$.next(diagramEvent);
8424
+ }).call(d3.drag().filter(event => {
8425
+ this.secondaryButton = isSecondaryButton(event);
8426
+ return true;
8427
+ }).on(DragEvents.Start, (event, d) => {
8428
+ if (this.multipleSelectionOn || this.secondaryButton) {
8429
+ this.startMultipleSelection(event);
8430
+ } else {
8431
+ this.startMovingNode(event, d);
8432
+ }
8433
+ }).on(DragEvents.Drag, (event, d) => {
8434
+ if (this.multipleSelectionOn || this.secondaryButton) {
8435
+ this.continueMultipleSelection(event);
8436
+ } else {
8437
+ this.continueMovingNode(event, d);
8438
+ }
8439
+ }).on(DragEvents.End, (event, d) => {
8440
+ if (this.multipleSelectionOn || this.secondaryButton) {
8441
+ this.finishMultipleSelection(event);
8442
+ } else {
8443
+ this.finishMovingNode(event, d);
8444
+ }
8445
+ this.secondaryButton = false;
8446
+ }));
8447
+ initializeLook(enterSelection);
8448
+ enterSelection.filter('.resizable-x').append('rect').attr('class', 'left-resizer').on(Events.MouseOver, (_event, d) => {
8449
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8450
+ setCursorStyle(CursorStyle.EWResize);
8451
+ }
8452
+ }).on(Events.MouseOut, (_event, d) => {
8453
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8454
+ setCursorStyle();
8455
+ }
8456
+ }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
8457
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8458
+ setCursorStyle(CursorStyle.EWResize);
8459
+ this.currentAction = new SetGeometryAction(this, DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
8460
+ } else {
8461
+ setCursorStyle(CursorStyle.NotAllowed);
8462
+ }
8463
+ }).on(DragEvents.Drag, (event, d) => {
8464
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8465
+ const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8466
+ d.stretch(Side.Left, d.coords[0] - pointerCoords[0]);
8467
+ }
8468
+ }).on(DragEvents.End, (event, d) => {
8469
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
8470
+ let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8471
+ if (this.gridConfig.snap) {
8472
+ pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
8473
+ pointerCoords[0] += d.type.snapToGridOffset[0];
8474
+ pointerCoords[1] += d.type.snapToGridOffset[1];
8475
+ }
8476
+ d.stretch(Side.Left, d.coords[0] - pointerCoords[0]);
8477
+ this.currentAction.to = d.getGeometry();
8478
+ this.currentAction.do();
8479
+ this.actionStack.add(this.currentAction);
8480
+ this.currentAction = undefined;
8481
+ }
8482
+ setCursorStyle();
8483
+ }));
8484
+ enterSelection.filter('.resizable-x').append('rect').attr('class', 'right-resizer').on(Events.MouseOver, (_event, d) => {
8485
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8486
+ setCursorStyle(CursorStyle.EWResize);
8487
+ }
8488
+ }).on(Events.MouseOut, (_event, d) => {
8489
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8490
+ setCursorStyle();
8491
+ }
8492
+ }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
8493
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8494
+ setCursorStyle(CursorStyle.EWResize);
8495
+ this.currentAction = new SetGeometryAction(this, DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
8496
+ } else {
8497
+ setCursorStyle(CursorStyle.NotAllowed);
8498
+ }
8499
+ }).on(DragEvents.Drag, (event, d) => {
8500
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8501
+ const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8502
+ d.stretch(Side.Right, pointerCoords[0] - (d.coords[0] + d.width));
8503
+ }
8504
+ }).on(DragEvents.End, (event, d) => {
8505
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
8506
+ let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8507
+ if (this.gridConfig.snap) {
8508
+ pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[2], pointerCoords[1] - d.type.snapToGridOffset[3]]);
8509
+ pointerCoords[0] += d.type.snapToGridOffset[2];
8510
+ pointerCoords[1] += d.type.snapToGridOffset[3];
8511
+ }
8512
+ d.stretch(Side.Right, pointerCoords[0] - (d.coords[0] + d.width));
8513
+ this.currentAction.to = d.getGeometry();
8514
+ this.currentAction.do();
8515
+ this.actionStack.add(this.currentAction);
8516
+ this.currentAction = undefined;
8517
+ }
8518
+ setCursorStyle();
8519
+ }));
8520
+ enterSelection.filter('.resizable-y').append('rect').attr('class', 'top-resizer').on(Events.MouseOver, (_event, d) => {
8521
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8522
+ setCursorStyle(CursorStyle.NSResize);
8523
+ }
8524
+ }).on(Events.MouseOut, (_event, d) => {
8525
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8526
+ setCursorStyle();
8527
+ }
8528
+ }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
8529
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8530
+ setCursorStyle(CursorStyle.NSResize);
8531
+ this.currentAction = new SetGeometryAction(this, DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
8532
+ } else {
8533
+ setCursorStyle(CursorStyle.NotAllowed);
8534
+ }
8535
+ }).on(DragEvents.Drag, (event, d) => {
8536
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8537
+ const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8538
+ d.stretch(Side.Top, d.coords[1] - pointerCoords[1]);
8539
+ }
8540
+ }).on(DragEvents.End, (event, d) => {
8541
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
8542
+ let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8543
+ if (this.gridConfig.snap) {
8544
+ pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
8545
+ pointerCoords[0] += d.type.snapToGridOffset[0];
8546
+ pointerCoords[1] += d.type.snapToGridOffset[1];
8547
+ }
8548
+ d.stretch(Side.Top, d.coords[1] - pointerCoords[1]);
8549
+ this.currentAction.to = d.getGeometry();
8550
+ this.currentAction.do();
8551
+ this.actionStack.add(this.currentAction);
8552
+ this.currentAction = undefined;
8553
+ }
8554
+ setCursorStyle();
8555
+ }));
8556
+ enterSelection.filter('.resizable-y').append('rect').attr('class', 'bottom-resizer').on(Events.MouseOver, (_event, d) => {
8557
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8558
+ setCursorStyle(CursorStyle.NSResize);
8559
+ }
8560
+ }).on(Events.MouseOut, (_event, d) => {
8561
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8562
+ setCursorStyle();
8191
8563
  }
8192
- }).on(Events.DoubleClick, (event, d) => {
8193
- const diagramEvent = new DiagramDoubleClickEvent(event, d);
8194
- this.diagramEvent$.next(diagramEvent);
8195
- }).call(d3.drag().filter(event => {
8196
- this.secondaryButton = isSecondaryButton(event);
8197
- return true;
8198
- }).on(DragEvents.Start, (event, d) => {
8199
- if (this.multipleSelectionOn || this.secondaryButton) {
8200
- this.startMultipleSelection(event);
8564
+ }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
8565
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8566
+ setCursorStyle(CursorStyle.NSResize);
8567
+ this.currentAction = new SetGeometryAction(this, DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
8201
8568
  } else {
8202
- this.startMovingNode(event, d);
8569
+ setCursorStyle(CursorStyle.NotAllowed);
8203
8570
  }
8204
8571
  }).on(DragEvents.Drag, (event, d) => {
8205
- if (this.multipleSelectionOn || this.secondaryButton) {
8206
- this.continueMultipleSelection(event);
8207
- } else {
8208
- this.continueMovingNode(event, d);
8572
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8573
+ const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8574
+ d.stretch(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height));
8209
8575
  }
8210
8576
  }).on(DragEvents.End, (event, d) => {
8211
- if (this.multipleSelectionOn || this.secondaryButton) {
8212
- this.finishMultipleSelection(event);
8213
- } else {
8214
- this.finishMovingNode(event, d);
8577
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
8578
+ let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8579
+ if (this.gridConfig.snap) {
8580
+ pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[2], pointerCoords[1] - d.type.snapToGridOffset[3]]);
8581
+ pointerCoords[0] += d.type.snapToGridOffset[2];
8582
+ pointerCoords[1] += d.type.snapToGridOffset[3];
8583
+ }
8584
+ d.stretch(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height));
8585
+ this.currentAction.to = d.getGeometry();
8586
+ this.currentAction.do();
8587
+ this.actionStack.add(this.currentAction);
8588
+ this.currentAction = undefined;
8215
8589
  }
8216
- this.secondaryButton = false;
8590
+ setCursorStyle();
8217
8591
  }));
8218
- initializeLook(enterSelection);
8219
- enterSelection.filter('.resizable-x').append('line').attr('class', 'left-resizer').attr('stroke', 'transparent').attr('stroke-width', RESIZER_THICKNESS).on(Events.MouseOver, (_event, d) => {
8220
- if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8221
- setCursorStyle(CursorStyle.EWResize);
8592
+ enterSelection.filter('.resizable-xy').append('rect').attr('class', 'top-left-resizer').on(Events.MouseOver, (_event, d) => {
8593
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8594
+ setCursorStyle(CursorStyle.NWSEResize);
8222
8595
  }
8223
8596
  }).on(Events.MouseOut, (_event, d) => {
8224
- if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8597
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8225
8598
  setCursorStyle();
8226
8599
  }
8227
8600
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
8228
- if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8229
- setCursorStyle(CursorStyle.EWResize);
8601
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8602
+ setCursorStyle(CursorStyle.NWSEResize);
8230
8603
  this.currentAction = new SetGeometryAction(this, DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
8231
8604
  } else {
8232
8605
  setCursorStyle(CursorStyle.NotAllowed);
8233
8606
  }
8234
8607
  }).on(DragEvents.Drag, (event, d) => {
8235
- if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8608
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8236
8609
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8237
8610
  d.stretch(Side.Left, d.coords[0] - pointerCoords[0]);
8611
+ d.stretch(Side.Top, d.coords[1] - pointerCoords[1]);
8238
8612
  }
8239
8613
  }).on(DragEvents.End, (event, d) => {
8240
- if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
8614
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
8241
8615
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8242
8616
  if (this.gridConfig.snap) {
8243
8617
  pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
@@ -8245,6 +8619,7 @@ class DiagramCanvas {
8245
8619
  pointerCoords[1] += d.type.snapToGridOffset[1];
8246
8620
  }
8247
8621
  d.stretch(Side.Left, d.coords[0] - pointerCoords[0]);
8622
+ d.stretch(Side.Top, d.coords[1] - pointerCoords[1]);
8248
8623
  this.currentAction.to = d.getGeometry();
8249
8624
  this.currentAction.do();
8250
8625
  this.actionStack.add(this.currentAction);
@@ -8252,34 +8627,36 @@ class DiagramCanvas {
8252
8627
  }
8253
8628
  setCursorStyle();
8254
8629
  }));
8255
- enterSelection.filter('.resizable-y').append('line').attr('class', 'top-resizer').attr('stroke', 'transparent').attr('stroke-width', RESIZER_THICKNESS).on(Events.MouseOver, (_event, d) => {
8256
- if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8257
- setCursorStyle(CursorStyle.NSResize);
8630
+ enterSelection.filter('.resizable-xy').append('rect').attr('class', 'top-right-resizer').on(Events.MouseOver, (_event, d) => {
8631
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8632
+ setCursorStyle(CursorStyle.NESWResize);
8258
8633
  }
8259
8634
  }).on(Events.MouseOut, (_event, d) => {
8260
- if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8635
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8261
8636
  setCursorStyle();
8262
8637
  }
8263
8638
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
8264
- if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8265
- setCursorStyle(CursorStyle.NSResize);
8639
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8640
+ setCursorStyle(CursorStyle.NESWResize);
8266
8641
  this.currentAction = new SetGeometryAction(this, DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
8267
8642
  } else {
8268
8643
  setCursorStyle(CursorStyle.NotAllowed);
8269
8644
  }
8270
8645
  }).on(DragEvents.Drag, (event, d) => {
8271
- if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8646
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8272
8647
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8648
+ d.stretch(Side.Right, pointerCoords[0] - (d.coords[0] + d.width));
8273
8649
  d.stretch(Side.Top, d.coords[1] - pointerCoords[1]);
8274
8650
  }
8275
8651
  }).on(DragEvents.End, (event, d) => {
8276
- if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
8652
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
8277
8653
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8278
8654
  if (this.gridConfig.snap) {
8279
8655
  pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
8280
8656
  pointerCoords[0] += d.type.snapToGridOffset[0];
8281
8657
  pointerCoords[1] += d.type.snapToGridOffset[1];
8282
8658
  }
8659
+ d.stretch(Side.Right, pointerCoords[0] - (d.coords[0] + d.width));
8283
8660
  d.stretch(Side.Top, d.coords[1] - pointerCoords[1]);
8284
8661
  this.currentAction.to = d.getGeometry();
8285
8662
  this.currentAction.do();
@@ -8288,35 +8665,37 @@ class DiagramCanvas {
8288
8665
  }
8289
8666
  setCursorStyle();
8290
8667
  }));
8291
- enterSelection.filter('.resizable-x').append('line').attr('class', 'right-resizer').attr('stroke', 'transparent').attr('stroke-width', RESIZER_THICKNESS).on(Events.MouseOver, (_event, d) => {
8292
- if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8293
- setCursorStyle(CursorStyle.EWResize);
8668
+ enterSelection.filter('.resizable-xy').append('rect').attr('class', 'bottom-left-resizer').on(Events.MouseOver, (_event, d) => {
8669
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8670
+ setCursorStyle(CursorStyle.NESWResize);
8294
8671
  }
8295
8672
  }).on(Events.MouseOut, (_event, d) => {
8296
- if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8673
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8297
8674
  setCursorStyle();
8298
8675
  }
8299
8676
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
8300
- if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8301
- setCursorStyle(CursorStyle.EWResize);
8677
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8678
+ setCursorStyle(CursorStyle.NESWResize);
8302
8679
  this.currentAction = new SetGeometryAction(this, DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
8303
8680
  } else {
8304
8681
  setCursorStyle(CursorStyle.NotAllowed);
8305
8682
  }
8306
8683
  }).on(DragEvents.Drag, (event, d) => {
8307
- if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8684
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8308
8685
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8309
- d.stretch(Side.Right, pointerCoords[0] - (d.coords[0] + d.width));
8686
+ d.stretch(Side.Left, d.coords[0] - pointerCoords[0]);
8687
+ d.stretch(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height));
8310
8688
  }
8311
8689
  }).on(DragEvents.End, (event, d) => {
8312
- if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
8690
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
8313
8691
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8314
8692
  if (this.gridConfig.snap) {
8315
- pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[2], pointerCoords[1] - d.type.snapToGridOffset[3]]);
8316
- pointerCoords[0] += d.type.snapToGridOffset[2];
8317
- pointerCoords[1] += d.type.snapToGridOffset[3];
8693
+ pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
8694
+ pointerCoords[0] += d.type.snapToGridOffset[0];
8695
+ pointerCoords[1] += d.type.snapToGridOffset[1];
8318
8696
  }
8319
- d.stretch(Side.Right, pointerCoords[0] - (d.coords[0] + d.width));
8697
+ d.stretch(Side.Left, d.coords[0] - pointerCoords[0]);
8698
+ d.stretch(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height));
8320
8699
  this.currentAction.to = d.getGeometry();
8321
8700
  this.currentAction.do();
8322
8701
  this.actionStack.add(this.currentAction);
@@ -8324,34 +8703,36 @@ class DiagramCanvas {
8324
8703
  }
8325
8704
  setCursorStyle();
8326
8705
  }));
8327
- enterSelection.filter('.resizable-y').append('line').attr('class', 'bottom-resizer').attr('stroke', 'transparent').attr('stroke-width', RESIZER_THICKNESS).on(Events.MouseOver, (_event, d) => {
8328
- if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8329
- setCursorStyle(CursorStyle.NSResize);
8706
+ enterSelection.filter('.resizable-xy').append('rect').attr('class', 'bottom-right-resizer').on(Events.MouseOver, (_event, d) => {
8707
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8708
+ setCursorStyle(CursorStyle.NWSEResize);
8330
8709
  }
8331
8710
  }).on(Events.MouseOut, (_event, d) => {
8332
- if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8711
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8333
8712
  setCursorStyle();
8334
8713
  }
8335
8714
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
8336
- if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8337
- setCursorStyle(CursorStyle.NSResize);
8715
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8716
+ setCursorStyle(CursorStyle.NWSEResize);
8338
8717
  this.currentAction = new SetGeometryAction(this, DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
8339
8718
  } else {
8340
8719
  setCursorStyle(CursorStyle.NotAllowed);
8341
8720
  }
8342
8721
  }).on(DragEvents.Drag, (event, d) => {
8343
- if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8722
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8344
8723
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8724
+ d.stretch(Side.Right, pointerCoords[0] - (d.coords[0] + d.width));
8345
8725
  d.stretch(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height));
8346
8726
  }
8347
8727
  }).on(DragEvents.End, (event, d) => {
8348
- if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
8728
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
8349
8729
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8350
8730
  if (this.gridConfig.snap) {
8351
- pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[2], pointerCoords[1] - d.type.snapToGridOffset[3]]);
8352
- pointerCoords[0] += d.type.snapToGridOffset[2];
8353
- pointerCoords[1] += d.type.snapToGridOffset[3];
8731
+ pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
8732
+ pointerCoords[0] += d.type.snapToGridOffset[0];
8733
+ pointerCoords[1] += d.type.snapToGridOffset[1];
8354
8734
  }
8735
+ d.stretch(Side.Right, pointerCoords[0] - (d.coords[0] + d.width));
8355
8736
  d.stretch(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height));
8356
8737
  this.currentAction.to = d.getGeometry();
8357
8738
  this.currentAction.do();
@@ -8362,17 +8743,21 @@ class DiagramCanvas {
8362
8743
  }));
8363
8744
  mergeSelection.attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).attr('opacity', d => d.removed ? 0.5 : 1);
8364
8745
  updateLook(mergeSelection);
8365
- mergeSelection.filter('.resizable-x').select('line.left-resizer').style('pointer-events', d => d.getResizableX() ? 'initial' : 'none').attr('x1', RESIZER_THICKNESS / 2).attr('x2', RESIZER_THICKNESS / 2).attr('y1', 0).attr('y2', d => d.height);
8366
- mergeSelection.filter('.resizable-y').select('line.top-resizer').style('pointer-events', d => d.getResizableY() ? 'initial' : 'none').attr('x1', 0).attr('x2', d => d.width).attr('y1', RESIZER_THICKNESS / 2).attr('y2', RESIZER_THICKNESS / 2);
8367
- mergeSelection.filter('.resizable-x').select('line.right-resizer').style('pointer-events', d => d.getResizableX() ? 'initial' : 'none').attr('x1', d => d.width - RESIZER_THICKNESS / 2).attr('x2', d => d.width - RESIZER_THICKNESS / 2).attr('y1', 0).attr('y2', d => d.height);
8368
- mergeSelection.filter('.resizable-y').select('line.bottom-resizer').style('pointer-events', d => d.getResizableY() ? 'initial' : 'none').attr('x1', 0).attr('x2', d => d.width).attr('y1', d => d.height - RESIZER_THICKNESS / 2).attr('y2', d => d.height - RESIZER_THICKNESS / 2);
8746
+ mergeSelection.filter('.resizable-x').select('rect.left-resizer').style('pointer-events', d => d.getResizableX() ? 'initial' : 'none').attr('x', d => -d.getResizerX().outerMargin).attr('y', d => d.getResizerXY().thickness - d.getResizerXY().outerMargin).attr('width', d => d.getResizerX().thickness).attr('height', d => d.height - d.getResizerXY().thickness * 2 + d.getResizerXY().outerMargin * 2).attr('fill', d => d.getResizerX().getLook(d).fillColor || 'transparent').attr('stroke', d => d.getResizerX().getLook(d).borderColor || 'transparent').attr('stroke-width', d => d.getResizerX().getLook(d).borderThickness || 0);
8747
+ mergeSelection.filter('.resizable-x').select('rect.right-resizer').style('pointer-events', d => d.getResizableX() ? 'initial' : 'none').attr('x', d => d.width - d.getResizerX().thickness + d.getResizerX().outerMargin).attr('y', d => d.getResizerXY().thickness - d.getResizerXY().outerMargin).attr('width', d => d.getResizerX().thickness).attr('height', d => d.height - d.getResizerXY().thickness * 2 + d.getResizerXY().outerMargin * 2).attr('fill', d => d.getResizerX().getLook(d).fillColor || 'transparent').attr('stroke', d => d.getResizerX().getLook(d).borderColor || 'transparent').attr('stroke-width', d => d.getResizerX().getLook(d).borderThickness || 0);
8748
+ mergeSelection.filter('.resizable-y').select('rect.top-resizer').style('pointer-events', d => d.getResizableY() ? 'initial' : 'none').attr('x', d => d.getResizerXY().thickness - d.getResizerXY().outerMargin).attr('y', d => -d.getResizerY().outerMargin).attr('width', d => d.width - d.getResizerXY().thickness * 2 + d.getResizerXY().outerMargin * 2).attr('height', d => d.getResizerY().thickness).attr('fill', d => d.getResizerY().getLook(d).fillColor || 'transparent').attr('stroke', d => d.getResizerY().getLook(d).borderColor || 'transparent').attr('stroke-width', d => d.getResizerY().getLook(d).borderThickness || 0);
8749
+ mergeSelection.filter('.resizable-y').select('rect.bottom-resizer').style('pointer-events', d => d.getResizableY() ? 'initial' : 'none').attr('x', d => d.getResizerXY().thickness - d.getResizerXY().outerMargin).attr('y', d => d.height - d.getResizerY().thickness + d.getResizerY().outerMargin).attr('width', d => d.width - d.getResizerXY().thickness * 2 + d.getResizerXY().outerMargin * 2).attr('height', d => d.getResizerY().thickness).attr('fill', d => d.getResizerY().getLook(d).fillColor || 'transparent').attr('stroke', d => d.getResizerY().getLook(d).borderColor || 'transparent').attr('stroke-width', d => d.getResizerY().getLook(d).borderThickness || 0);
8750
+ mergeSelection.filter('.resizable-xy').select('rect.top-left-resizer').style('pointer-events', d => d.getResizableXY() ? 'initial' : 'none').attr('x', d => -d.getResizerXY().outerMargin).attr('y', d => -d.getResizerXY().outerMargin).attr('width', d => d.getResizerXY().thickness).attr('height', d => d.getResizerXY().thickness).attr('fill', d => d.getResizerXY().getLook(d).fillColor || 'transparent').attr('stroke', d => d.getResizerXY().getLook(d).borderColor || 'transparent').attr('stroke-width', d => d.getResizerXY().getLook(d).borderThickness || 0);
8751
+ mergeSelection.filter('.resizable-xy').select('rect.top-right-resizer').style('pointer-events', d => d.getResizableXY() ? 'initial' : 'none').attr('x', d => d.width - d.getResizerXY().thickness + d.getResizerXY().outerMargin).attr('y', d => -d.getResizerXY().outerMargin).attr('width', d => d.getResizerXY().thickness).attr('height', d => d.getResizerXY().thickness).attr('fill', d => d.getResizerXY().getLook(d).fillColor || 'transparent').attr('stroke', d => d.getResizerXY().getLook(d).borderColor || 'transparent').attr('stroke-width', d => d.getResizerXY().getLook(d).borderThickness || 0);
8752
+ mergeSelection.filter('.resizable-xy').select('rect.bottom-left-resizer').style('pointer-events', d => d.getResizableXY() ? 'initial' : 'none').attr('x', d => -d.getResizerXY().outerMargin).attr('y', d => d.height - d.getResizerXY().thickness + d.getResizerXY().outerMargin).attr('width', d => d.getResizerXY().thickness).attr('height', d => d.getResizerXY().thickness).attr('fill', d => d.getResizerXY().getLook(d).fillColor || 'transparent').attr('stroke', d => d.getResizerXY().getLook(d).borderColor || 'transparent').attr('stroke-width', d => d.getResizerXY().getLook(d).borderThickness || 0);
8753
+ mergeSelection.filter('.resizable-xy').select('rect.bottom-right-resizer').style('pointer-events', d => d.getResizableXY() ? 'initial' : 'none').attr('x', d => d.width - d.getResizerXY().thickness + d.getResizerXY().outerMargin).attr('y', d => d.height - d.getResizerXY().thickness + d.getResizerXY().outerMargin).attr('width', d => d.getResizerXY().thickness).attr('height', d => d.getResizerXY().thickness).attr('fill', d => d.getResizerXY().getLook(d).fillColor || 'transparent').attr('stroke', d => d.getResizerXY().getLook(d).borderColor || 'transparent').attr('stroke-width', d => d.getResizerXY().getLook(d).borderThickness || 0);
8369
8754
  }
8370
8755
  updateSectionsInView(...ids) {
8371
8756
  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);
8372
8757
  const exitSelection = updateSelection.exit();
8373
8758
  const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', d => {
8374
8759
  var _a;
8375
- return `diagram-section${needsResizerX(d) ? ' resizable-x' : ''}${needsResizerY(d) ? ' resizable-y' : ''} ${(_a = d.look) === null || _a === void 0 ? void 0 : _a.lookType}`;
8760
+ return `diagram-section${needsResizerX(d) ? ' resizable-x' : ''}${needsResizerY(d) ? ' resizable-y' : ''}${needsResizerXY(d) ? ' resizable-xy' : ''} ${(_a = d.look) === null || _a === void 0 ? void 0 : _a.lookType}`;
8376
8761
  });
8377
8762
  if (ids && ids.length > 0) {
8378
8763
  updateSelection = updateSelection.filter(d => ids.includes(d.id));
@@ -8453,7 +8838,7 @@ class DiagramCanvas {
8453
8838
  this.secondaryButton = false;
8454
8839
  }));
8455
8840
  initializeLook(enterSelection);
8456
- enterSelection.filter('.resizable-x').append('line').attr('class', 'left-resizer').attr('stroke', 'transparent').attr('stroke-width', RESIZER_THICKNESS).on(Events.MouseOver, (_event, d) => {
8841
+ enterSelection.filter('.resizable-x').append('rect').attr('class', 'left-resizer').on(Events.MouseOver, (_event, d) => {
8457
8842
  if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
8458
8843
  setCursorStyle(CursorStyle.EWResize);
8459
8844
  }
@@ -8487,7 +8872,41 @@ class DiagramCanvas {
8487
8872
  }
8488
8873
  setCursorStyle();
8489
8874
  }));
8490
- enterSelection.filter('.resizable-y').append('line').attr('class', 'top-resizer').attr('stroke', 'transparent').attr('stroke-width', RESIZER_THICKNESS).on(Events.MouseOver, (_event, d) => {
8875
+ enterSelection.filter('.resizable-x').append('rect').attr('class', 'right-resizer').on(Events.MouseOver, (_event, d) => {
8876
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
8877
+ setCursorStyle(CursorStyle.EWResize);
8878
+ }
8879
+ }).on(Events.MouseOut, (_event, d) => {
8880
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
8881
+ setCursorStyle();
8882
+ }
8883
+ }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
8884
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableX() && !d.removed && d.node) {
8885
+ setCursorStyle(CursorStyle.EWResize);
8886
+ this.currentAction = new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
8887
+ } else {
8888
+ setCursorStyle(CursorStyle.NotAllowed);
8889
+ }
8890
+ }).on(DragEvents.Drag, (event, d) => {
8891
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableX() && !d.removed && d.node) {
8892
+ const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8893
+ d.node.stretchSections(Side.Right, pointerCoords[0] - (d.coords[0] + d.width), d.indexXInNode, d.indexYInNode);
8894
+ }
8895
+ }).on(DragEvents.End, (event, d) => {
8896
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection && d.node) {
8897
+ let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8898
+ if (this.gridConfig.snap) {
8899
+ pointerCoords = this.getClosestGridPoint(pointerCoords);
8900
+ }
8901
+ d.node.stretchSections(Side.Right, pointerCoords[0] - (d.coords[0] + d.width), d.indexXInNode, d.indexYInNode);
8902
+ this.currentAction.to = d.node.getGeometry();
8903
+ this.currentAction.do();
8904
+ this.actionStack.add(this.currentAction);
8905
+ this.currentAction = undefined;
8906
+ }
8907
+ setCursorStyle();
8908
+ }));
8909
+ enterSelection.filter('.resizable-y').append('rect').attr('class', 'top-resizer').on(Events.MouseOver, (_event, d) => {
8491
8910
  if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
8492
8911
  setCursorStyle(CursorStyle.NSResize);
8493
8912
  }
@@ -8521,33 +8940,105 @@ class DiagramCanvas {
8521
8940
  }
8522
8941
  setCursorStyle();
8523
8942
  }));
8524
- enterSelection.filter('.resizable-x').append('line').attr('class', 'right-resizer').attr('stroke', 'transparent').attr('stroke-width', RESIZER_THICKNESS).on(Events.MouseOver, (_event, d) => {
8525
- if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
8526
- setCursorStyle(CursorStyle.EWResize);
8943
+ enterSelection.filter('.resizable-y').append('rect').attr('class', 'bottom-resizer').on(Events.MouseOver, (_event, d) => {
8944
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
8945
+ setCursorStyle(CursorStyle.NSResize);
8527
8946
  }
8528
8947
  }).on(Events.MouseOut, (_event, d) => {
8529
- if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
8948
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
8530
8949
  setCursorStyle();
8531
8950
  }
8532
8951
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
8533
- if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableX() && !d.removed && d.node) {
8534
- setCursorStyle(CursorStyle.EWResize);
8952
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableY() && !d.removed && d.node) {
8953
+ setCursorStyle(CursorStyle.NSResize);
8535
8954
  this.currentAction = new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
8536
8955
  } else {
8537
8956
  setCursorStyle(CursorStyle.NotAllowed);
8538
8957
  }
8539
8958
  }).on(DragEvents.Drag, (event, d) => {
8540
- if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableX() && !d.removed && d.node) {
8959
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableY() && !d.removed && d.node) {
8960
+ const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8961
+ d.node.stretchSections(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height), d.indexXInNode, d.indexYInNode);
8962
+ }
8963
+ }).on(DragEvents.End, (event, d) => {
8964
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection && d.node) {
8965
+ let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8966
+ if (this.gridConfig.snap) {
8967
+ pointerCoords = this.getClosestGridPoint(pointerCoords);
8968
+ }
8969
+ d.node.stretchSections(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height), d.indexXInNode, d.indexYInNode);
8970
+ this.currentAction.to = d.node.getGeometry();
8971
+ this.currentAction.do();
8972
+ this.actionStack.add(this.currentAction);
8973
+ this.currentAction = undefined;
8974
+ }
8975
+ setCursorStyle();
8976
+ }));
8977
+ enterSelection.filter('.resizable-xy').append('rect').attr('class', 'top-left-resizer').on(Events.MouseOver, (_event, d) => {
8978
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed) {
8979
+ setCursorStyle(CursorStyle.NWSEResize);
8980
+ }
8981
+ }).on(Events.MouseOut, (_event, d) => {
8982
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed) {
8983
+ setCursorStyle();
8984
+ }
8985
+ }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
8986
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && d.node) {
8987
+ setCursorStyle(CursorStyle.NWSEResize);
8988
+ this.currentAction = new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
8989
+ } else {
8990
+ setCursorStyle(CursorStyle.NotAllowed);
8991
+ }
8992
+ }).on(DragEvents.Drag, (event, d) => {
8993
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && d.node) {
8994
+ const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8995
+ d.node.stretchSections(Side.Left, d.coords[0] - pointerCoords[0], d.indexXInNode, d.indexYInNode);
8996
+ d.node.stretchSections(Side.Top, d.coords[1] - pointerCoords[1], d.indexXInNode, d.indexYInNode);
8997
+ }
8998
+ }).on(DragEvents.End, (event, d) => {
8999
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection && d.node) {
9000
+ let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
9001
+ if (this.gridConfig.snap) {
9002
+ pointerCoords = this.getClosestGridPoint(pointerCoords);
9003
+ }
9004
+ d.node.stretchSections(Side.Left, d.coords[0] - pointerCoords[0], d.indexXInNode, d.indexYInNode);
9005
+ d.node.stretchSections(Side.Top, d.coords[1] - pointerCoords[1], d.indexXInNode, d.indexYInNode);
9006
+ this.currentAction.to = d.node.getGeometry();
9007
+ this.currentAction.do();
9008
+ this.actionStack.add(this.currentAction);
9009
+ this.currentAction = undefined;
9010
+ }
9011
+ setCursorStyle();
9012
+ }));
9013
+ enterSelection.filter('.resizable-xy').append('rect').attr('class', 'top-right-resizer').on(Events.MouseOver, (_event, d) => {
9014
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed) {
9015
+ setCursorStyle(CursorStyle.NESWResize);
9016
+ }
9017
+ }).on(Events.MouseOut, (_event, d) => {
9018
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed) {
9019
+ setCursorStyle();
9020
+ }
9021
+ }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
9022
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && d.node) {
9023
+ setCursorStyle(CursorStyle.NESWResize);
9024
+ this.currentAction = new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
9025
+ } else {
9026
+ setCursorStyle(CursorStyle.NotAllowed);
9027
+ }
9028
+ }).on(DragEvents.Drag, (event, d) => {
9029
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && d.node) {
8541
9030
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8542
9031
  d.node.stretchSections(Side.Right, pointerCoords[0] - (d.coords[0] + d.width), d.indexXInNode, d.indexYInNode);
9032
+ d.node.stretchSections(Side.Top, d.coords[1] - pointerCoords[1], d.indexXInNode, d.indexYInNode);
8543
9033
  }
8544
9034
  }).on(DragEvents.End, (event, d) => {
8545
- if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection && d.node) {
9035
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection && d.node) {
8546
9036
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8547
9037
  if (this.gridConfig.snap) {
8548
9038
  pointerCoords = this.getClosestGridPoint(pointerCoords);
8549
9039
  }
8550
9040
  d.node.stretchSections(Side.Right, pointerCoords[0] - (d.coords[0] + d.width), d.indexXInNode, d.indexYInNode);
9041
+ d.node.stretchSections(Side.Top, d.coords[1] - pointerCoords[1], d.indexXInNode, d.indexYInNode);
8551
9042
  this.currentAction.to = d.node.getGeometry();
8552
9043
  this.currentAction.do();
8553
9044
  this.actionStack.add(this.currentAction);
@@ -8555,32 +9046,70 @@ class DiagramCanvas {
8555
9046
  }
8556
9047
  setCursorStyle();
8557
9048
  }));
8558
- enterSelection.filter('.resizable-y').append('line').attr('class', 'bottom-resizer').attr('stroke', 'transparent').attr('stroke-width', RESIZER_THICKNESS).on(Events.MouseOver, (_event, d) => {
8559
- if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
8560
- setCursorStyle(CursorStyle.NSResize);
9049
+ enterSelection.filter('.resizable-xy').append('rect').attr('class', 'bottom-left-resizer').on(Events.MouseOver, (_event, d) => {
9050
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed) {
9051
+ setCursorStyle(CursorStyle.NESWResize);
8561
9052
  }
8562
9053
  }).on(Events.MouseOut, (_event, d) => {
8563
- if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
9054
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed) {
8564
9055
  setCursorStyle();
8565
9056
  }
8566
9057
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
8567
- if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableY() && !d.removed && d.node) {
8568
- setCursorStyle(CursorStyle.NSResize);
9058
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && d.node) {
9059
+ setCursorStyle(CursorStyle.NESWResize);
8569
9060
  this.currentAction = new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
8570
9061
  } else {
8571
9062
  setCursorStyle(CursorStyle.NotAllowed);
8572
9063
  }
8573
9064
  }).on(DragEvents.Drag, (event, d) => {
8574
- if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableY() && !d.removed && d.node) {
9065
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && d.node) {
8575
9066
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
9067
+ d.node.stretchSections(Side.Left, d.coords[0] - pointerCoords[0], d.indexXInNode, d.indexYInNode);
8576
9068
  d.node.stretchSections(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height), d.indexXInNode, d.indexYInNode);
8577
9069
  }
8578
9070
  }).on(DragEvents.End, (event, d) => {
8579
- if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection && d.node) {
9071
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection && d.node) {
9072
+ let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
9073
+ if (this.gridConfig.snap) {
9074
+ pointerCoords = this.getClosestGridPoint(pointerCoords);
9075
+ }
9076
+ d.node.stretchSections(Side.Left, d.coords[0] - pointerCoords[0], d.indexXInNode, d.indexYInNode);
9077
+ d.node.stretchSections(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height), d.indexXInNode, d.indexYInNode);
9078
+ this.currentAction.to = d.node.getGeometry();
9079
+ this.currentAction.do();
9080
+ this.actionStack.add(this.currentAction);
9081
+ this.currentAction = undefined;
9082
+ }
9083
+ setCursorStyle();
9084
+ }));
9085
+ enterSelection.filter('.resizable-xy').append('rect').attr('class', 'bottom-right-resizer').on(Events.MouseOver, (_event, d) => {
9086
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed) {
9087
+ setCursorStyle(CursorStyle.NWSEResize);
9088
+ }
9089
+ }).on(Events.MouseOut, (_event, d) => {
9090
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed) {
9091
+ setCursorStyle();
9092
+ }
9093
+ }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
9094
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && d.node) {
9095
+ setCursorStyle(CursorStyle.NWSEResize);
9096
+ this.currentAction = new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
9097
+ } else {
9098
+ setCursorStyle(CursorStyle.NotAllowed);
9099
+ }
9100
+ }).on(DragEvents.Drag, (event, d) => {
9101
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && d.node) {
9102
+ const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
9103
+ d.node.stretchSections(Side.Right, pointerCoords[0] - (d.coords[0] + d.width), d.indexXInNode, d.indexYInNode);
9104
+ d.node.stretchSections(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height), d.indexXInNode, d.indexYInNode);
9105
+ }
9106
+ }).on(DragEvents.End, (event, d) => {
9107
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection && d.node) {
8580
9108
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8581
9109
  if (this.gridConfig.snap) {
8582
9110
  pointerCoords = this.getClosestGridPoint(pointerCoords);
8583
9111
  }
9112
+ d.node.stretchSections(Side.Right, pointerCoords[0] - (d.coords[0] + d.width), d.indexXInNode, d.indexYInNode);
8584
9113
  d.node.stretchSections(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height), d.indexXInNode, d.indexYInNode);
8585
9114
  this.currentAction.to = d.node.getGeometry();
8586
9115
  this.currentAction.do();
@@ -8591,10 +9120,14 @@ class DiagramCanvas {
8591
9120
  }));
8592
9121
  mergeSelection.attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).attr('opacity', d => d.removed ? 0.5 : 1);
8593
9122
  updateLook(mergeSelection);
8594
- mergeSelection.filter('.resizable-x').select('line.left-resizer').style('pointer-events', d => d.getResizableX() ? 'initial' : 'none').attr('x1', RESIZER_THICKNESS / 2).attr('x2', RESIZER_THICKNESS / 2).attr('y1', 0).attr('y2', d => d.height);
8595
- mergeSelection.filter('.resizable-y').select('line.top-resizer').style('pointer-events', d => d.getResizableY() ? 'initial' : 'none').attr('x1', 0).attr('x2', d => d.width).attr('y1', RESIZER_THICKNESS / 2).attr('y2', RESIZER_THICKNESS / 2);
8596
- mergeSelection.filter('.resizable-x').select('line.right-resizer').style('pointer-events', d => d.getResizableX() ? 'initial' : 'none').attr('x1', d => d.width - RESIZER_THICKNESS / 2).attr('x2', d => d.width - RESIZER_THICKNESS / 2).attr('y1', 0).attr('y2', d => d.height);
8597
- mergeSelection.filter('.resizable-y').select('line.bottom-resizer').style('pointer-events', d => d.getResizableY() ? 'initial' : 'none').attr('x1', 0).attr('x2', d => d.width).attr('y1', d => d.height - RESIZER_THICKNESS / 2).attr('y2', d => d.height - RESIZER_THICKNESS / 2);
9123
+ mergeSelection.filter('.resizable-x').select('rect.left-resizer').style('pointer-events', d => d.getResizableX() ? 'initial' : 'none').attr('x', d => -d.getResizerX().outerMargin).attr('y', d => d.getResizerXY().thickness - d.getResizerXY().outerMargin).attr('width', d => d.getResizerX().thickness).attr('height', d => d.height - d.getResizerXY().thickness * 2 + d.getResizerXY().outerMargin * 2).attr('fill', d => d.getResizerX().getLook(d).fillColor || 'transparent').attr('stroke', d => d.getResizerX().getLook(d).borderColor || 'transparent').attr('stroke-width', d => d.getResizerX().getLook(d).borderThickness || 0);
9124
+ mergeSelection.filter('.resizable-x').select('rect.right-resizer').style('pointer-events', d => d.getResizableX() ? 'initial' : 'none').attr('x', d => d.width - d.getResizerX().thickness + d.getResizerX().outerMargin).attr('y', d => d.getResizerXY().thickness - d.getResizerXY().outerMargin).attr('width', d => d.getResizerX().thickness).attr('height', d => d.height - d.getResizerXY().thickness * 2 + d.getResizerXY().outerMargin * 2).attr('fill', d => d.getResizerX().getLook(d).fillColor || 'transparent').attr('stroke', d => d.getResizerX().getLook(d).borderColor || 'transparent').attr('stroke-width', d => d.getResizerX().getLook(d).borderThickness || 0);
9125
+ mergeSelection.filter('.resizable-y').select('rect.top-resizer').style('pointer-events', d => d.getResizableY() ? 'initial' : 'none').attr('x', d => d.getResizerXY().thickness - d.getResizerXY().outerMargin).attr('y', d => -d.getResizerY().outerMargin).attr('width', d => d.width - d.getResizerXY().thickness * 2 + d.getResizerXY().outerMargin * 2).attr('height', d => d.getResizerY().thickness).attr('fill', d => d.getResizerY().getLook(d).fillColor || 'transparent').attr('stroke', d => d.getResizerY().getLook(d).borderColor || 'transparent').attr('stroke-width', d => d.getResizerY().getLook(d).borderThickness || 0);
9126
+ mergeSelection.filter('.resizable-y').select('rect.bottom-resizer').style('pointer-events', d => d.getResizableY() ? 'initial' : 'none').attr('x', d => d.getResizerXY().thickness - d.getResizerXY().outerMargin).attr('y', d => d.height - d.getResizerY().thickness + d.getResizerY().outerMargin).attr('width', d => d.width - d.getResizerXY().thickness * 2 + d.getResizerXY().outerMargin * 2).attr('height', d => d.getResizerY().thickness).attr('fill', d => d.getResizerY().getLook(d).fillColor || 'transparent').attr('stroke', d => d.getResizerY().getLook(d).borderColor || 'transparent').attr('stroke-width', d => d.getResizerY().getLook(d).borderThickness || 0);
9127
+ mergeSelection.filter('.resizable-xy').select('rect.top-left-resizer').style('pointer-events', d => d.getResizableXY() ? 'initial' : 'none').attr('x', d => -d.getResizerXY().outerMargin).attr('y', d => -d.getResizerXY().outerMargin).attr('width', d => d.getResizerXY().thickness).attr('height', d => d.getResizerXY().thickness).attr('fill', d => d.getResizerXY().getLook(d).fillColor || 'transparent').attr('stroke', d => d.getResizerXY().getLook(d).borderColor || 'transparent').attr('stroke-width', d => d.getResizerXY().getLook(d).borderThickness || 0);
9128
+ mergeSelection.filter('.resizable-xy').select('rect.top-right-resizer').style('pointer-events', d => d.getResizableXY() ? 'initial' : 'none').attr('x', d => d.width - d.getResizerXY().thickness + d.getResizerXY().outerMargin).attr('y', d => -d.getResizerXY().outerMargin).attr('width', d => d.getResizerXY().thickness).attr('height', d => d.getResizerXY().thickness).attr('fill', d => d.getResizerXY().getLook(d).fillColor || 'transparent').attr('stroke', d => d.getResizerXY().getLook(d).borderColor || 'transparent').attr('stroke-width', d => d.getResizerXY().getLook(d).borderThickness || 0);
9129
+ mergeSelection.filter('.resizable-xy').select('rect.bottom-left-resizer').style('pointer-events', d => d.getResizableXY() ? 'initial' : 'none').attr('x', d => -d.getResizerXY().outerMargin).attr('y', d => d.height - d.getResizerXY().thickness + d.getResizerXY().outerMargin).attr('width', d => d.getResizerXY().thickness).attr('height', d => d.getResizerXY().thickness).attr('fill', d => d.getResizerXY().getLook(d).fillColor || 'transparent').attr('stroke', d => d.getResizerXY().getLook(d).borderColor || 'transparent').attr('stroke-width', d => d.getResizerXY().getLook(d).borderThickness || 0);
9130
+ mergeSelection.filter('.resizable-xy').select('rect.bottom-right-resizer').style('pointer-events', d => d.getResizableXY() ? 'initial' : 'none').attr('x', d => d.width - d.getResizerXY().thickness + d.getResizerXY().outerMargin).attr('y', d => d.height - d.getResizerXY().thickness + d.getResizerXY().outerMargin).attr('width', d => d.getResizerXY().thickness).attr('height', d => d.getResizerXY().thickness).attr('fill', d => d.getResizerXY().getLook(d).fillColor || 'transparent').attr('stroke', d => d.getResizerXY().getLook(d).borderColor || 'transparent').attr('stroke-width', d => d.getResizerXY().getLook(d).borderThickness || 0);
8598
9131
  }
8599
9132
  updatePortsInView(...ids) {
8600
9133
  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);
@@ -9255,6 +9788,46 @@ class DiagramCanvas {
9255
9788
  endMarkerSelection.attr('orient', 'auto-start-reverse').attr('markerWidth', 0).attr('markerHeight', 0);
9256
9789
  }
9257
9790
  }
9791
+ bringToFront(node) {
9792
+ const overlappingNodes = this.model.nodes.filter(n => n.id !== node.id && rectanglesIntersect([n.coords, [n.coords[0] + n.width, n.coords[1] + n.height]], [node.coords, [node.coords[0] + node.width, node.coords[1] + node.height]]));
9793
+ let maximumZ = node.z;
9794
+ for (const n of overlappingNodes) {
9795
+ if (n.z > maximumZ) {
9796
+ maximumZ = n.z;
9797
+ }
9798
+ }
9799
+ maximumZ += 1;
9800
+ const action = new SetGeometryAction(this, DiagramActions.MoveNode, node.id, node.getGeometry(), node.getGeometry());
9801
+ node.setGeometry(Object.assign(Object.assign({}, node.getGeometry()), {
9802
+ z: maximumZ
9803
+ }));
9804
+ node.raiseWithZ();
9805
+ action.to = node.getGeometry();
9806
+ this.currentAction = action;
9807
+ this.currentAction.do();
9808
+ this.actionStack.add(this.currentAction);
9809
+ this.currentAction = undefined;
9810
+ }
9811
+ sendToBack(node) {
9812
+ const overlappingNodes = this.model.nodes.filter(n => n.id !== node.id && rectanglesIntersect([n.coords, [n.coords[0] + n.width, n.coords[1] + n.height]], [node.coords, [node.coords[0] + node.width, node.coords[1] + node.height]]));
9813
+ let minimumZ = node.z;
9814
+ for (const n of overlappingNodes) {
9815
+ if (n.z < minimumZ) {
9816
+ minimumZ = n.z;
9817
+ }
9818
+ }
9819
+ minimumZ -= 1;
9820
+ const action = new SetGeometryAction(this, DiagramActions.MoveNode, node.id, node.getGeometry(), node.getGeometry());
9821
+ node.setGeometry(Object.assign(Object.assign({}, node.getGeometry()), {
9822
+ z: minimumZ
9823
+ }));
9824
+ node.raiseWithZ();
9825
+ action.to = node.getGeometry();
9826
+ this.currentAction = action;
9827
+ this.currentAction.do();
9828
+ this.actionStack.add(this.currentAction);
9829
+ this.currentAction = undefined;
9830
+ }
9258
9831
  fieldRootFitsInView(id) {
9259
9832
  var _a, _b, _c, _d;
9260
9833
  const field = this.model.fields.get(id);