@metadev/daga 5.0.5 → 5.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js CHANGED
@@ -1172,7 +1172,9 @@ exports.CursorStyle = void 0;
1172
1172
  CursorStyle["Grabbing"] = "grabbing";
1173
1173
  CursorStyle["Move"] = "move";
1174
1174
  CursorStyle["NoDrop"] = "no-drop";
1175
+ CursorStyle["NESWResize"] = "nesw-resize";
1175
1176
  CursorStyle["NSResize"] = "ns-resize";
1177
+ CursorStyle["NWSEResize"] = "nwse-resize";
1176
1178
  CursorStyle["NotAllowed"] = "not-allowed";
1177
1179
  CursorStyle["ZoomIn"] = "zoom-in";
1178
1180
  CursorStyle["ZoomOut"] = "zoom-out";
@@ -1271,283 +1273,6 @@ const extractLooksFromConfig = lookConfig => {
1271
1273
  };
1272
1274
  };
1273
1275
 
1274
- /**
1275
- * Represents a collection of diagram entities of a type that exists as part of a diagram model.
1276
- * @public
1277
- * @see DiagramEntity
1278
- * @see DiagramModel
1279
- */
1280
- class DiagramEntitySet {
1281
- constructor() {
1282
- /**
1283
- * The list of entities contained in this set.
1284
- * @private
1285
- */
1286
- this.entities = [];
1287
- /**
1288
- * A mapping of entity ids to their corresponding entity in this set for quickly fetching entities based on their id.
1289
- * @private
1290
- */
1291
- this.entityMap = {};
1292
- }
1293
- /**
1294
- * The number of entities in this set.
1295
- * @public
1296
- */
1297
- get length() {
1298
- return this.size();
1299
- }
1300
- /**
1301
- * Gets all of the entities of this set.
1302
- * @public
1303
- * @returns An array containing all of the entities of this set.
1304
- */
1305
- all() {
1306
- return [...this.entities];
1307
- }
1308
- /**
1309
- * 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.
1310
- * 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.
1311
- * @private
1312
- * @param entity An entity to be added to this set.
1313
- */
1314
- add(entity) {
1315
- if (this.entityMap[entity.id] === undefined) {
1316
- this.entityMap[entity.id] = entity;
1317
- this.entities.push(entity);
1318
- }
1319
- }
1320
- /**
1321
- * Removes all the entities in this set.
1322
- * @public
1323
- */
1324
- clear() {
1325
- // remove each entity individually in case classes that extend this implement their own specific cleanup
1326
- while (this.entities.length > 0) {
1327
- this.remove(this.entities[0].id);
1328
- }
1329
- }
1330
- /**
1331
- * Checks if this set contains an entity with the given id.
1332
- * @public
1333
- * @param id An id.
1334
- * @returns `true` if this set contains an entity with the given id, `false` otherwise.
1335
- */
1336
- contains(id) {
1337
- return this.entityMap[id] !== undefined;
1338
- }
1339
- /**
1340
- * Counts the number of entities of this set following the given criteria.
1341
- * @public
1342
- * @returns The number of entities of this set following the given criteria.
1343
- */
1344
- count(predicate) {
1345
- return this.entities.filter(predicate).length;
1346
- }
1347
- /**
1348
- * Gets all of the entities of this set filtered following given criteria.
1349
- * @public
1350
- * @returns An array containing the entities of this set that meet the given criteria.
1351
- */
1352
- filter(predicate) {
1353
- return this.entities.filter(predicate);
1354
- }
1355
- /**
1356
- * Gets an entity of this set matching specific criteria.
1357
- * @public
1358
- * @returns An entity of this set.
1359
- */
1360
- find(predicate) {
1361
- return this.entities.find(predicate);
1362
- }
1363
- /**
1364
- * Gets an entity from this set.
1365
- * @public
1366
- * @param id An id.
1367
- * @returns An entity with the given id, or `undefined` if there are no entities with the given id.
1368
- */
1369
- get(id) {
1370
- return this.entityMap[id];
1371
- }
1372
- /**
1373
- * Gets all of the entities of this set mapped to the result of the given function applied to them.
1374
- * @public
1375
- * @returns An array containing the entities of this set that meet the given criteria.
1376
- */
1377
- map(callback) {
1378
- return this.entities.map(callback);
1379
- }
1380
- /**
1381
- * Attempts to find and remove an entity with the given id. Has no effect if there are no entities with the given id.
1382
- * @public
1383
- * @param id An id.
1384
- */
1385
- remove(id) {
1386
- const entity = this.get(id);
1387
- if (entity !== undefined) {
1388
- delete this.entityMap[id];
1389
- removeIfExists(this.entities, entity);
1390
- }
1391
- }
1392
- /**
1393
- * Gets the number of entities in this set.
1394
- * @public
1395
- */
1396
- size() {
1397
- return this.entities.length;
1398
- }
1399
- /**
1400
- * Iterator to iterate over the entities of this set.
1401
- * @public
1402
- */
1403
- *[Symbol.iterator]() {
1404
- for (const entity of this.entities) {
1405
- yield entity;
1406
- }
1407
- }
1408
- }
1409
-
1410
- /**
1411
- * Default priority value for diagram elements.
1412
- * @private
1413
- */
1414
- const DEFAULT_PRIORITY = 0;
1415
- /**
1416
- * Represents an object which exists as part of a specific diagram model and has a visual representation in a diagram canvas.
1417
- * @public
1418
- * @see DiagramModel
1419
- * @see DiagramCanvas
1420
- */
1421
- class DiagramElement {
1422
- /**
1423
- * Identifier that uniquely identifies this element within its diagram model. Cannot be an empty string.
1424
- * @public
1425
- */
1426
- get id() {
1427
- return this._id;
1428
- }
1429
- /**
1430
- * Whether this diagram element is currently in the user highlight.
1431
- * @private
1432
- */
1433
- get highlighted() {
1434
- var _a, _b;
1435
- 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;
1436
- }
1437
- /**
1438
- * Whether this diagram element is currently in the user selection.
1439
- */
1440
- get selected() {
1441
- var _a, _b;
1442
- 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;
1443
- }
1444
- constructor(model, id) {
1445
- /**
1446
- * Whether this diagram element has itself been explicitly removed.
1447
- *
1448
- * Override the `removed` getter so that it returns true if and only if:
1449
- * - `selfRemoved` is true, or
1450
- * - `removed` is true for any of this element's dependencies.
1451
- *
1452
- * For example, a DiagramConnection is removed if either of its ports are removed,
1453
- * even if the connection's own `selfRemoved` field is false.
1454
- * @private
1455
- */
1456
- this.selfRemoved = false;
1457
- /**
1458
- * Collaborative timestamp for selfRemoved.
1459
- * @private
1460
- */
1461
- this.selfRemovedTimestamp = null;
1462
- this.model = model;
1463
- this._id = id;
1464
- }
1465
- /**
1466
- * Obtain the selection of this element.
1467
- * @private
1468
- */
1469
- select() {
1470
- var _a, _b;
1471
- 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)}']`);
1472
- }
1473
- }
1474
- class DiagramElementSet extends DiagramEntitySet {
1475
- all(includeRemoved = false) {
1476
- if (includeRemoved) {
1477
- return super.all();
1478
- } else {
1479
- return super.filter(e => !e.removed);
1480
- }
1481
- }
1482
- contains(id, includeRemoved = false) {
1483
- if (includeRemoved) {
1484
- return super.contains(id);
1485
- } else {
1486
- return super.contains(id) && !this.entityMap[id].removed;
1487
- }
1488
- }
1489
- count(predicate, includeRemoved = false) {
1490
- if (includeRemoved) {
1491
- return super.count(predicate);
1492
- } else {
1493
- return super.count((e, i, a) => predicate(e, i, a) && !e.removed);
1494
- }
1495
- }
1496
- filter(predicate, includeRemoved = false) {
1497
- if (includeRemoved) {
1498
- return super.filter(predicate);
1499
- } else {
1500
- return super.filter((e, i, a) => predicate(e, i, a) && !e.removed);
1501
- }
1502
- }
1503
- find(predicate, includeRemoved = false) {
1504
- if (includeRemoved) {
1505
- return super.find(predicate);
1506
- } else {
1507
- return super.find((e, i, a) => predicate(e, i, a) && !e.removed);
1508
- }
1509
- }
1510
- get(id, includeRemoved = false) {
1511
- if (includeRemoved) {
1512
- return super.get(id);
1513
- } else {
1514
- return this.contains(id) ? super.get(id) : undefined;
1515
- }
1516
- }
1517
- map(callback, includeRemoved = false) {
1518
- if (includeRemoved) {
1519
- return super.map(callback);
1520
- } else {
1521
- return super.filter(e => !e.removed).map(callback);
1522
- }
1523
- }
1524
- remove(id) {
1525
- const entity = this.get(id, true);
1526
- if (entity !== undefined) {
1527
- delete this.entityMap[id];
1528
- removeIfExists(this.entities, entity);
1529
- }
1530
- }
1531
- size(includeRemoved = false) {
1532
- if (includeRemoved) {
1533
- return super.size();
1534
- } else {
1535
- return super.filter(e => !e.removed).length;
1536
- }
1537
- }
1538
- *[Symbol.iterator](includeRemoved = false) {
1539
- if (includeRemoved) {
1540
- for (const entity of this.entities) {
1541
- yield entity;
1542
- }
1543
- } else {
1544
- for (const entity of this.entities.filter(e => !e.removed)) {
1545
- yield entity;
1546
- }
1547
- }
1548
- }
1549
- }
1550
-
1551
1276
  /**
1552
1277
  * A property which is part of a property set and defines what values a value in a value set can take.
1553
1278
  * @public
@@ -2062,76 +1787,353 @@ class ValueSet {
2062
1787
  }
2063
1788
  }
2064
1789
  /**
2065
- * Sets all the values of this set to the defaults.
2066
- * 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.
2067
- * @private
1790
+ * Sets all the values of this set to the defaults.
1791
+ * 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.
1792
+ * @private
1793
+ */
1794
+ resetValues() {
1795
+ this.displayedProperties = [];
1796
+ this.hiddenProperties = [];
1797
+ this.ownTimestamps = {};
1798
+ for (const key in this.propertySet.propertyMap) {
1799
+ const property = this.propertySet.getProperty(key);
1800
+ const rootAttribute = property.rootAttribute;
1801
+ if (property.type === exports.Type.Object) {
1802
+ this.valueSets[key] = this.constructSubValueSet(key);
1803
+ } else {
1804
+ this.values[key] = clone(property.defaultValue);
1805
+ }
1806
+ if (rootAttribute !== undefined && rootAttribute !== null) {
1807
+ if (property.defaultValue !== undefined && !equals(this.getRootElementValue(rootAttribute), property.defaultValue)) {
1808
+ this.setRootElementValue(rootAttribute, this.values[key]);
1809
+ }
1810
+ }
1811
+ if (property.basic !== false) {
1812
+ this.displayedProperties.push(property);
1813
+ } else {
1814
+ this.hiddenProperties.push(property);
1815
+ }
1816
+ }
1817
+ }
1818
+ /**
1819
+ * Constructs a ValueSet with its corresponding PropertySet representing the values of the object.
1820
+ * @private
1821
+ * @param key Key that the ValueSet is under.
1822
+ * @returns The constructed ValueSet.
1823
+ */
1824
+ constructSubValueSet(key) {
1825
+ const property = this.propertySet.getProperty(key);
1826
+ const propertySet = new PropertySet(property.properties);
1827
+ const valueSet = new ValueSet(propertySet, this.rootElement);
1828
+ valueSet.overwriteValues(clone(property.defaultValue));
1829
+ return valueSet;
1830
+ }
1831
+ /**
1832
+ * Gets the ValueSet under the given key when there are nested ValueSets.
1833
+ * @private
1834
+ * @param key A key.
1835
+ * @returns A ValueSet.
1836
+ */
1837
+ getSubValueSet(key) {
1838
+ return this.valueSets[key];
1839
+ }
1840
+ /**
1841
+ * Moves the given property to the list of displayed properties.
1842
+ * @private
1843
+ * @param property A property.
1844
+ */
1845
+ displayProperty(property) {
1846
+ if (!this.displayedProperties.includes(property)) {
1847
+ this.displayedProperties.push(property);
1848
+ removeIfExists(this.hiddenProperties, property);
1849
+ }
1850
+ }
1851
+ /**
1852
+ * Moves the given property to the list of hidden properties.
1853
+ * @private
1854
+ * @param property A property.
1855
+ */
1856
+ hideProperty(property) {
1857
+ if (!this.hiddenProperties.includes(property)) {
1858
+ this.hiddenProperties.push(property);
1859
+ removeIfExists(this.displayedProperties, property);
1860
+ }
1861
+ }
1862
+ }
1863
+
1864
+ /**
1865
+ * Represents a collection of diagram entities of a type that exists as part of a diagram model.
1866
+ * @public
1867
+ * @see DiagramEntity
1868
+ * @see DiagramModel
1869
+ */
1870
+ class DiagramEntitySet {
1871
+ constructor() {
1872
+ /**
1873
+ * The list of entities contained in this set.
1874
+ * @private
1875
+ */
1876
+ this.entities = [];
1877
+ /**
1878
+ * A mapping of entity ids to their corresponding entity in this set for quickly fetching entities based on their id.
1879
+ * @private
1880
+ */
1881
+ this.entityMap = {};
1882
+ }
1883
+ /**
1884
+ * The number of entities in this set.
1885
+ * @public
1886
+ */
1887
+ get length() {
1888
+ return this.size();
1889
+ }
1890
+ /**
1891
+ * Gets all of the entities of this set.
1892
+ * @public
1893
+ * @returns An array containing all of the entities of this set.
1894
+ */
1895
+ all() {
1896
+ return [...this.entities];
1897
+ }
1898
+ /**
1899
+ * 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.
1900
+ * 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.
1901
+ * @private
1902
+ * @param entity An entity to be added to this set.
1903
+ */
1904
+ add(entity) {
1905
+ if (this.entityMap[entity.id] === undefined) {
1906
+ this.entityMap[entity.id] = entity;
1907
+ this.entities.push(entity);
1908
+ }
1909
+ }
1910
+ /**
1911
+ * Removes all the entities in this set.
1912
+ * @public
1913
+ */
1914
+ clear() {
1915
+ // remove each entity individually in case classes that extend this implement their own specific cleanup
1916
+ while (this.entities.length > 0) {
1917
+ this.remove(this.entities[0].id);
1918
+ }
1919
+ }
1920
+ /**
1921
+ * Checks if this set contains an entity with the given id.
1922
+ * @public
1923
+ * @param id An id.
1924
+ * @returns `true` if this set contains an entity with the given id, `false` otherwise.
1925
+ */
1926
+ contains(id) {
1927
+ return this.entityMap[id] !== undefined;
1928
+ }
1929
+ /**
1930
+ * Counts the number of entities of this set following the given criteria.
1931
+ * @public
1932
+ * @returns The number of entities of this set following the given criteria.
1933
+ */
1934
+ count(predicate) {
1935
+ return this.entities.filter(predicate).length;
1936
+ }
1937
+ /**
1938
+ * Gets all of the entities of this set filtered following given criteria.
1939
+ * @public
1940
+ * @returns An array containing the entities of this set that meet the given criteria.
1941
+ */
1942
+ filter(predicate) {
1943
+ return this.entities.filter(predicate);
1944
+ }
1945
+ /**
1946
+ * Gets an entity of this set matching specific criteria.
1947
+ * @public
1948
+ * @returns An entity of this set.
1949
+ */
1950
+ find(predicate) {
1951
+ return this.entities.find(predicate);
1952
+ }
1953
+ /**
1954
+ * Gets an entity from this set.
1955
+ * @public
1956
+ * @param id An id.
1957
+ * @returns An entity with the given id, or `undefined` if there are no entities with the given id.
1958
+ */
1959
+ get(id) {
1960
+ return this.entityMap[id];
1961
+ }
1962
+ /**
1963
+ * Gets all of the entities of this set mapped to the result of the given function applied to them.
1964
+ * @public
1965
+ * @returns An array containing the entities of this set that meet the given criteria.
1966
+ */
1967
+ map(callback) {
1968
+ return this.entities.map(callback);
1969
+ }
1970
+ /**
1971
+ * Attempts to find and remove an entity with the given id. Has no effect if there are no entities with the given id.
1972
+ * @public
1973
+ * @param id An id.
1974
+ */
1975
+ remove(id) {
1976
+ const entity = this.get(id);
1977
+ if (entity !== undefined) {
1978
+ delete this.entityMap[id];
1979
+ removeIfExists(this.entities, entity);
1980
+ }
1981
+ }
1982
+ /**
1983
+ * Gets the number of entities in this set.
1984
+ * @public
2068
1985
  */
2069
- resetValues() {
2070
- this.displayedProperties = [];
2071
- this.hiddenProperties = [];
2072
- this.ownTimestamps = {};
2073
- for (const key in this.propertySet.propertyMap) {
2074
- const property = this.propertySet.getProperty(key);
2075
- const rootAttribute = property.rootAttribute;
2076
- if (property.type === exports.Type.Object) {
2077
- this.valueSets[key] = this.constructSubValueSet(key);
2078
- } else {
2079
- this.values[key] = clone(property.defaultValue);
2080
- }
2081
- if (rootAttribute !== undefined && rootAttribute !== null) {
2082
- if (property.defaultValue !== undefined && !equals(this.getRootElementValue(rootAttribute), property.defaultValue)) {
2083
- this.setRootElementValue(rootAttribute, this.values[key]);
2084
- }
2085
- }
2086
- if (property.basic !== false) {
2087
- this.displayedProperties.push(property);
2088
- } else {
2089
- this.hiddenProperties.push(property);
2090
- }
1986
+ size() {
1987
+ return this.entities.length;
1988
+ }
1989
+ /**
1990
+ * Iterator to iterate over the entities of this set.
1991
+ * @public
1992
+ */
1993
+ *[Symbol.iterator]() {
1994
+ for (const entity of this.entities) {
1995
+ yield entity;
2091
1996
  }
2092
1997
  }
1998
+ }
1999
+
2000
+ /**
2001
+ * Default priority value for diagram elements.
2002
+ * @private
2003
+ */
2004
+ const DEFAULT_PRIORITY = 0;
2005
+ /**
2006
+ * Represents an object which exists as part of a specific diagram model and has a visual representation in a diagram canvas.
2007
+ * @public
2008
+ * @see DiagramModel
2009
+ * @see DiagramCanvas
2010
+ */
2011
+ class DiagramElement {
2093
2012
  /**
2094
- * Constructs a ValueSet with its corresponding PropertySet representing the values of the object.
2095
- * @private
2096
- * @param key Key that the ValueSet is under.
2097
- * @returns The constructed ValueSet.
2013
+ * Identifier that uniquely identifies this element within its diagram model. Cannot be an empty string.
2014
+ * @public
2098
2015
  */
2099
- constructSubValueSet(key) {
2100
- const property = this.propertySet.getProperty(key);
2101
- const propertySet = new PropertySet(property.properties);
2102
- const valueSet = new ValueSet(propertySet, this.rootElement);
2103
- valueSet.overwriteValues(clone(property.defaultValue));
2104
- return valueSet;
2016
+ get id() {
2017
+ return this._id;
2105
2018
  }
2106
2019
  /**
2107
- * Gets the ValueSet under the given key when there are nested ValueSets.
2020
+ * Whether this diagram element is currently in the user highlight.
2108
2021
  * @private
2109
- * @param key A key.
2110
- * @returns A ValueSet.
2111
2022
  */
2112
- getSubValueSet(key) {
2113
- return this.valueSets[key];
2023
+ get highlighted() {
2024
+ var _a, _b;
2025
+ 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;
2114
2026
  }
2115
2027
  /**
2116
- * Moves the given property to the list of displayed properties.
2117
- * @private
2118
- * @param property A property.
2028
+ * Whether this diagram element is currently in the user selection.
2119
2029
  */
2120
- displayProperty(property) {
2121
- if (!this.displayedProperties.includes(property)) {
2122
- this.displayedProperties.push(property);
2123
- removeIfExists(this.hiddenProperties, property);
2124
- }
2030
+ get selected() {
2031
+ var _a, _b;
2032
+ 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;
2033
+ }
2034
+ constructor(model, id) {
2035
+ /**
2036
+ * Whether this diagram element has itself been explicitly removed.
2037
+ *
2038
+ * Override the `removed` getter so that it returns true if and only if:
2039
+ * - `selfRemoved` is true, or
2040
+ * - `removed` is true for any of this element's dependencies.
2041
+ *
2042
+ * For example, a DiagramConnection is removed if either of its ports are removed,
2043
+ * even if the connection's own `selfRemoved` field is false.
2044
+ * @private
2045
+ */
2046
+ this.selfRemoved = false;
2047
+ /**
2048
+ * Collaborative timestamp for selfRemoved.
2049
+ * @private
2050
+ */
2051
+ this.selfRemovedTimestamp = null;
2052
+ this.model = model;
2053
+ this._id = id;
2125
2054
  }
2126
2055
  /**
2127
- * Moves the given property to the list of hidden properties.
2056
+ * Obtain the selection of this element.
2128
2057
  * @private
2129
- * @param property A property.
2130
2058
  */
2131
- hideProperty(property) {
2132
- if (!this.hiddenProperties.includes(property)) {
2133
- this.hiddenProperties.push(property);
2134
- removeIfExists(this.displayedProperties, property);
2059
+ select() {
2060
+ var _a, _b;
2061
+ 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)}']`);
2062
+ }
2063
+ }
2064
+ class DiagramElementSet extends DiagramEntitySet {
2065
+ all(includeRemoved = false) {
2066
+ if (includeRemoved) {
2067
+ return super.all();
2068
+ } else {
2069
+ return super.filter(e => !e.removed);
2070
+ }
2071
+ }
2072
+ contains(id, includeRemoved = false) {
2073
+ if (includeRemoved) {
2074
+ return super.contains(id);
2075
+ } else {
2076
+ return super.contains(id) && !this.entityMap[id].removed;
2077
+ }
2078
+ }
2079
+ count(predicate, includeRemoved = false) {
2080
+ if (includeRemoved) {
2081
+ return super.count(predicate);
2082
+ } else {
2083
+ return super.count((e, i, a) => predicate(e, i, a) && !e.removed);
2084
+ }
2085
+ }
2086
+ filter(predicate, includeRemoved = false) {
2087
+ if (includeRemoved) {
2088
+ return super.filter(predicate);
2089
+ } else {
2090
+ return super.filter((e, i, a) => predicate(e, i, a) && !e.removed);
2091
+ }
2092
+ }
2093
+ find(predicate, includeRemoved = false) {
2094
+ if (includeRemoved) {
2095
+ return super.find(predicate);
2096
+ } else {
2097
+ return super.find((e, i, a) => predicate(e, i, a) && !e.removed);
2098
+ }
2099
+ }
2100
+ get(id, includeRemoved = false) {
2101
+ if (includeRemoved) {
2102
+ return super.get(id);
2103
+ } else {
2104
+ return this.contains(id) ? super.get(id) : undefined;
2105
+ }
2106
+ }
2107
+ map(callback, includeRemoved = false) {
2108
+ if (includeRemoved) {
2109
+ return super.map(callback);
2110
+ } else {
2111
+ return super.filter(e => !e.removed).map(callback);
2112
+ }
2113
+ }
2114
+ remove(id) {
2115
+ const entity = this.get(id, true);
2116
+ if (entity !== undefined) {
2117
+ delete this.entityMap[id];
2118
+ removeIfExists(this.entities, entity);
2119
+ }
2120
+ }
2121
+ size(includeRemoved = false) {
2122
+ if (includeRemoved) {
2123
+ return super.size();
2124
+ } else {
2125
+ return super.filter(e => !e.removed).length;
2126
+ }
2127
+ }
2128
+ *[Symbol.iterator](includeRemoved = false) {
2129
+ if (includeRemoved) {
2130
+ for (const entity of this.entities) {
2131
+ yield entity;
2132
+ }
2133
+ } else {
2134
+ for (const entity of this.entities.filter(e => !e.removed)) {
2135
+ yield entity;
2136
+ }
2135
2137
  }
2136
2138
  }
2137
2139
  }
@@ -2145,7 +2147,6 @@ const DIAGRAM_CONNECTION_TYPE_DEFAULTS = {
2145
2147
  name: '',
2146
2148
  label: null,
2147
2149
  look: {
2148
- lookType: 'connection-look',
2149
2150
  color: '#000000',
2150
2151
  thickness: 1,
2151
2152
  shape: exports.LineShape.Straight,
@@ -2687,6 +2688,28 @@ class DiagramConnectionSet extends DiagramElementSet {
2687
2688
  }
2688
2689
  }
2689
2690
 
2691
+ /**
2692
+ * The different modes for when a node or section can be resized.
2693
+ * @public
2694
+ * @see DiagramNode
2695
+ * @see DiagramSection
2696
+ */
2697
+ exports.ResizableMode = void 0;
2698
+ (function (ResizableMode) {
2699
+ /**
2700
+ * Resizable mode for always being resizable.
2701
+ */
2702
+ ResizableMode[ResizableMode["Always"] = 0] = "Always";
2703
+ /**
2704
+ * Resizable mode for only being resizable while selected.
2705
+ */
2706
+ ResizableMode[ResizableMode["OnlyWhenSelected"] = 1] = "OnlyWhenSelected";
2707
+ /**
2708
+ * Resizable mode for never being resizable.
2709
+ */
2710
+ ResizableMode[ResizableMode["Never"] = 2] = "Never";
2711
+ })(exports.ResizableMode || (exports.ResizableMode = {}));
2712
+
2690
2713
  /**
2691
2714
  * Default values of the parameters of a diagram field.
2692
2715
  * @private
@@ -2694,19 +2717,21 @@ class DiagramConnectionSet extends DiagramElementSet {
2694
2717
  */
2695
2718
  const DIAGRAM_FIELD_DEFAULTS = {
2696
2719
  editable: true,
2697
- fontSize: 0,
2698
2720
  margin: 0,
2699
2721
  padding: 0,
2700
- fontFamily: "'Wonder Unit Sans', sans-serif",
2701
- color: '#000000',
2702
- selectedColor: '#000000',
2703
- backgroundColor: 'transparent',
2704
2722
  horizontalAlign: exports.HorizontalAlign.Center,
2705
2723
  verticalAlign: exports.VerticalAlign.Center,
2706
2724
  orientation: exports.Side.Top,
2707
2725
  multiline: false,
2708
2726
  fit: false,
2709
- shrink: true
2727
+ shrink: true,
2728
+ look: {
2729
+ fillColor: 'transparent',
2730
+ fontColor: '#000000',
2731
+ fontFamily: "'Wonder Unit Sans', sans-serif",
2732
+ fontSize: 10,
2733
+ fontWeight: 400
2734
+ }
2710
2735
  };
2711
2736
  /**
2712
2737
  * A field which displays text and is part of a diagram element.
@@ -2734,7 +2759,26 @@ class DiagramField extends DiagramElement {
2734
2759
  (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.fitFieldRootInView(this.id, this.shrink);
2735
2760
  }
2736
2761
  }
2737
- constructor(model, rootElement, coords, width, height, fontSize, fontFamily, color, selectedColor, horizontalAlign, verticalAlign, orientation, multiline, text, editable, fit, shrink) {
2762
+ /**
2763
+ * Current look of this field.
2764
+ * @private
2765
+ */
2766
+ get look() {
2767
+ if (this.selected) {
2768
+ if (this.highlighted) {
2769
+ return this.selectedAndHighlightedLook;
2770
+ } else {
2771
+ return this.selectedLook;
2772
+ }
2773
+ } else {
2774
+ if (this.highlighted) {
2775
+ return this.highlightedLook;
2776
+ } else {
2777
+ return this.defaultLook;
2778
+ }
2779
+ }
2780
+ }
2781
+ constructor(model, rootElement, coords, width, height, horizontalAlign, verticalAlign, orientation, multiline, look, text, editable, fit, shrink) {
2738
2782
  const id = `${rootElement === null || rootElement === void 0 ? void 0 : rootElement.id}_field`;
2739
2783
  if (model.fields.get(id) !== undefined) {
2740
2784
  throw new Error('DiagramField for rootElement already exists');
@@ -2749,12 +2793,9 @@ class DiagramField extends DiagramElement {
2749
2793
  this.coords = coords;
2750
2794
  this.width = width;
2751
2795
  this.height = height;
2752
- this.fontSize = fontSize;
2753
- this.fontFamily = fontFamily;
2754
- this.color = color;
2755
- this.selectedColor = selectedColor;
2756
2796
  this.horizontalAlign = horizontalAlign;
2757
2797
  this.verticalAlign = verticalAlign;
2798
+ this.multiline = multiline;
2758
2799
  if (!isNaN(Number(orientation))) {
2759
2800
  this.orientation = Number(orientation);
2760
2801
  } else {
@@ -2775,7 +2816,11 @@ class DiagramField extends DiagramElement {
2775
2816
  this.orientation = 0;
2776
2817
  }
2777
2818
  }
2778
- this.multiline = multiline;
2819
+ const looks = extractLooksFromConfig(look);
2820
+ this.defaultLook = looks.defaultLook;
2821
+ this.selectedLook = looks.selectedLook;
2822
+ this.highlightedLook = looks.highlightedLook;
2823
+ this.selectedAndHighlightedLook = looks.selectedAndHighlightedLook;
2779
2824
  this.defaultText = text;
2780
2825
  this._text = text;
2781
2826
  this.editable = editable;
@@ -2820,8 +2865,8 @@ class DiagramFieldSet extends DiagramElementSet {
2820
2865
  * Instance a new field and add it to this set. This method is normally called when instancing an element with a field and it is rarely called by itself.
2821
2866
  * @private
2822
2867
  */
2823
- new(rootElement, coords, fontSize, fontFamily, color, selectedColor, width, height, horizontalAlign, verticalAlign, orientation, multiline, text, editable, fit, shrink) {
2824
- const field = new DiagramField(this.model, rootElement, coords, width, height, fontSize, fontFamily, color, selectedColor, horizontalAlign, verticalAlign, orientation, multiline, text, editable, fit, shrink);
2868
+ new(rootElement, coords, width, height, horizontalAlign, verticalAlign, orientation, multiline, look, text, editable, fit, shrink) {
2869
+ const field = new DiagramField(this.model, rootElement, coords, width, height, horizontalAlign, verticalAlign, orientation, multiline, look, text, editable, fit, shrink);
2825
2870
  super.add(field);
2826
2871
  field.updateInView();
2827
2872
  // add this field to its root element
@@ -2853,9 +2898,7 @@ const getBottomMargin = config => {
2853
2898
  } else if (typeof config.margin === 'number') {
2854
2899
  return config.margin;
2855
2900
  } else {
2856
- if (config.margin.length === 0) {
2857
- return DIAGRAM_FIELD_DEFAULTS.margin;
2858
- } else if (config.margin.length === 1) {
2901
+ if (config.margin.length === 1) {
2859
2902
  return config.margin[0];
2860
2903
  } else if (config.margin.length === 2) {
2861
2904
  return config.margin[0];
@@ -2872,9 +2915,7 @@ const getLeftMargin = config => {
2872
2915
  } else if (typeof config.margin === 'number') {
2873
2916
  return config.margin;
2874
2917
  } else {
2875
- if (config.margin.length === 0) {
2876
- return DIAGRAM_FIELD_DEFAULTS.margin;
2877
- } else if (config.margin.length === 1) {
2918
+ if (config.margin.length === 1) {
2878
2919
  return config.margin[0];
2879
2920
  } else if (config.margin.length === 2) {
2880
2921
  return config.margin[1];
@@ -2891,9 +2932,7 @@ const getRightMargin = config => {
2891
2932
  } else if (typeof config.margin === 'number') {
2892
2933
  return config.margin;
2893
2934
  } else {
2894
- if (config.margin.length === 0) {
2895
- return DIAGRAM_FIELD_DEFAULTS.margin;
2896
- } else if (config.margin.length === 1) {
2935
+ if (config.margin.length === 1) {
2897
2936
  return config.margin[0];
2898
2937
  } else if (config.margin.length === 2) {
2899
2938
  return config.margin[1];
@@ -2910,9 +2949,7 @@ const getTopMargin = config => {
2910
2949
  } else if (typeof config.margin === 'number') {
2911
2950
  return config.margin;
2912
2951
  } else {
2913
- if (config.margin.length === 0) {
2914
- return DIAGRAM_FIELD_DEFAULTS.margin;
2915
- } else if (config.margin.length === 1) {
2952
+ if (config.margin.length === 1) {
2916
2953
  return config.margin[0];
2917
2954
  } else if (config.margin.length === 2) {
2918
2955
  return config.margin[0];
@@ -2929,9 +2966,7 @@ const getBottomPadding$1 = config => {
2929
2966
  } else if (typeof config.padding === 'number') {
2930
2967
  return config.padding;
2931
2968
  } else {
2932
- if (config.padding.length === 0) {
2933
- return DIAGRAM_FIELD_DEFAULTS.padding;
2934
- } else if (config.padding.length === 1) {
2969
+ if (config.padding.length === 1) {
2935
2970
  return config.padding[0];
2936
2971
  } else if (config.padding.length === 2) {
2937
2972
  return config.padding[0];
@@ -2948,9 +2983,7 @@ const getLeftPadding$1 = config => {
2948
2983
  } else if (typeof config.padding === 'number') {
2949
2984
  return config.padding;
2950
2985
  } else {
2951
- if (config.padding.length === 0) {
2952
- return DIAGRAM_FIELD_DEFAULTS.padding;
2953
- } else if (config.padding.length === 1) {
2986
+ if (config.padding.length === 1) {
2954
2987
  return config.padding[0];
2955
2988
  } else if (config.padding.length === 2) {
2956
2989
  return config.padding[1];
@@ -2967,9 +3000,7 @@ const getRightPadding$1 = config => {
2967
3000
  } else if (typeof config.padding === 'number') {
2968
3001
  return config.padding;
2969
3002
  } else {
2970
- if (config.padding.length === 0) {
2971
- return DIAGRAM_FIELD_DEFAULTS.padding;
2972
- } else if (config.padding.length === 1) {
3003
+ if (config.padding.length === 1) {
2973
3004
  return config.padding[0];
2974
3005
  } else if (config.padding.length === 2) {
2975
3006
  return config.padding[1];
@@ -2986,24 +3017,88 @@ const getTopPadding$1 = config => {
2986
3017
  } else if (typeof config.padding === 'number') {
2987
3018
  return config.padding;
2988
3019
  } else {
2989
- if (config.padding.length === 0) {
2990
- return DIAGRAM_FIELD_DEFAULTS.padding;
2991
- } else if (config.padding.length === 1) {
3020
+ if (config.padding.length === 1) {
2992
3021
  return config.padding[0];
2993
3022
  } else if (config.padding.length === 2) {
2994
3023
  return config.padding[0];
2995
3024
  } else if (config.padding.length === 3) {
2996
3025
  return config.padding[0];
2997
3026
  } else {
2998
- return config.padding[0];
3027
+ return config.padding[0];
3028
+ }
3029
+ }
3030
+ };
3031
+
3032
+ /**
3033
+ * Default values of the parameters of a diagram field.
3034
+ * @private
3035
+ * @see ResizerConfig
3036
+ */
3037
+ const DIAGRAM_RESIZER_DEFAULTS = {
3038
+ mode: exports.ResizableMode.Never,
3039
+ thickness: 10,
3040
+ outerMargin: 0,
3041
+ look: {
3042
+ fillColor: 'transparent',
3043
+ borderColor: 'transparent',
3044
+ borderThickness: 0
3045
+ }
3046
+ };
3047
+ /**
3048
+ * Holds the data for the resizers of a type of node or section.
3049
+ * @public
3050
+ * @see DiagramNode
3051
+ * @see DiagramSection
3052
+ */
3053
+ class DiagramResizer {
3054
+ constructor(options) {
3055
+ var _a;
3056
+ let config;
3057
+ if (typeof options === 'boolean') {
3058
+ config = {
3059
+ mode: options ? exports.ResizableMode.Always : exports.ResizableMode.Never
3060
+ };
3061
+ } else if (typeof options === 'string' || typeof options === 'number') {
3062
+ config = {
3063
+ mode: options
3064
+ };
3065
+ } else {
3066
+ config = options;
3067
+ }
3068
+ config = Object.assign(Object.assign({}, DIAGRAM_RESIZER_DEFAULTS), config);
3069
+ this.mode = config.mode;
3070
+ this.thickness = config.thickness;
3071
+ this.outerMargin = config.outerMargin;
3072
+ const looks = extractLooksFromConfig((_a = config.look) !== null && _a !== void 0 ? _a : DIAGRAM_RESIZER_DEFAULTS.look);
3073
+ this.defaultLook = looks.defaultLook;
3074
+ this.selectedLook = looks.selectedLook;
3075
+ this.highlightedLook = looks.highlightedLook;
3076
+ this.selectedAndHighlightedLook = looks.selectedAndHighlightedLook;
3077
+ }
3078
+ /**
3079
+ * Current look of this resizer.
3080
+ * @private
3081
+ */
3082
+ getLook(rootElement) {
3083
+ if (!rootElement) {
3084
+ return this.defaultLook;
3085
+ }
3086
+ if (rootElement.selected) {
3087
+ if (rootElement.highlighted) {
3088
+ return this.selectedAndHighlightedLook;
3089
+ } else {
3090
+ return this.selectedLook;
3091
+ }
3092
+ } else {
3093
+ if (rootElement.highlighted) {
3094
+ return this.highlightedLook;
3095
+ } else {
3096
+ return this.defaultLook;
3097
+ }
2999
3098
  }
3000
3099
  }
3001
- };
3002
-
3003
- exports.ResizableMode = void 0;
3004
- (function (ResizableMode) {
3005
- ResizableMode[ResizableMode["OnlyWhenSelected"] = 0] = "OnlyWhenSelected";
3006
- })(exports.ResizableMode || (exports.ResizableMode = {}));
3100
+ }
3101
+ const DIAGRAM_DEFAULT_RESIZER = new DiagramResizer(DIAGRAM_RESIZER_DEFAULTS);
3007
3102
 
3008
3103
  /**
3009
3104
  * Default value of the default width of a diagram section.
@@ -3057,8 +3152,21 @@ class DiagramSectionType {
3057
3152
  this.label = options.label || null;
3058
3153
  this.ports = options.ports || [];
3059
3154
  this.priority = options.priority || DEFAULT_PRIORITY;
3060
- this.resizableX = options.resizableX;
3061
- this.resizableY = options.resizableY;
3155
+ if (typeof options.resizableX === 'undefined') {
3156
+ this.resizerX = undefined;
3157
+ } else {
3158
+ this.resizerX = new DiagramResizer(options.resizableX);
3159
+ }
3160
+ if (typeof options.resizableY === 'undefined') {
3161
+ this.resizerY = undefined;
3162
+ } else {
3163
+ this.resizerY = new DiagramResizer(options.resizableY);
3164
+ }
3165
+ if (typeof options.resizableXY === 'undefined') {
3166
+ this.resizerXY = undefined;
3167
+ } else {
3168
+ this.resizerXY = new DiagramResizer(options.resizableXY);
3169
+ }
3062
3170
  const looks = extractLooksFromConfig(options.look || DIAGRAM_NODE_LOOK_DEFAULTS);
3063
3171
  this.defaultLook = looks.defaultLook;
3064
3172
  this.selectedLook = looks.selectedLook;
@@ -3202,6 +3310,30 @@ class DiagramSection extends DiagramElement {
3202
3310
  var _a, _b, _c, _d, _e, _f;
3203
3311
  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;
3204
3312
  }
3313
+ /**
3314
+ * Returns the horizontal resizer of this section.
3315
+ * @public
3316
+ */
3317
+ getResizerX() {
3318
+ var _a, _b, _c, _d;
3319
+ 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;
3320
+ }
3321
+ /**
3322
+ * Returns the vertical resizer of this section.
3323
+ * @public
3324
+ */
3325
+ getResizerY() {
3326
+ var _a, _b, _c, _d;
3327
+ 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;
3328
+ }
3329
+ /**
3330
+ * Returns the diagonal resizer of this section.
3331
+ * @public
3332
+ */
3333
+ getResizerXY() {
3334
+ var _a, _b, _c, _d;
3335
+ 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;
3336
+ }
3205
3337
  /**
3206
3338
  * Returns whether this section can be resized horizontally.
3207
3339
  * If the section has a specific resizableX setting, it uses that.
@@ -3211,11 +3343,16 @@ class DiagramSection extends DiagramElement {
3211
3343
  getResizableX() {
3212
3344
  var _a;
3213
3345
  const sectionType = this.type;
3214
- if ((sectionType === null || sectionType === void 0 ? void 0 : sectionType.resizableX) !== undefined) {
3215
- if (sectionType.resizableX === exports.ResizableMode.OnlyWhenSelected) {
3216
- return this.selected;
3346
+ if ((sectionType === null || sectionType === void 0 ? void 0 : sectionType.resizerX) !== undefined) {
3347
+ switch (sectionType.resizerX.mode) {
3348
+ case exports.ResizableMode.OnlyWhenSelected:
3349
+ return this.selected;
3350
+ case exports.ResizableMode.Always:
3351
+ return true;
3352
+ case exports.ResizableMode.Never:
3353
+ default:
3354
+ return false;
3217
3355
  }
3218
- return sectionType.resizableX;
3219
3356
  }
3220
3357
  return ((_a = this.node) === null || _a === void 0 ? void 0 : _a.getResizableX()) || false;
3221
3358
  }
@@ -3228,14 +3365,41 @@ class DiagramSection extends DiagramElement {
3228
3365
  getResizableY() {
3229
3366
  var _a;
3230
3367
  const sectionType = this.type;
3231
- if ((sectionType === null || sectionType === void 0 ? void 0 : sectionType.resizableY) !== undefined) {
3232
- if (sectionType.resizableY === exports.ResizableMode.OnlyWhenSelected) {
3233
- return this.selected;
3368
+ if ((sectionType === null || sectionType === void 0 ? void 0 : sectionType.resizerY) !== undefined) {
3369
+ switch (sectionType.resizerY.mode) {
3370
+ case exports.ResizableMode.OnlyWhenSelected:
3371
+ return this.selected;
3372
+ case exports.ResizableMode.Always:
3373
+ return true;
3374
+ case exports.ResizableMode.Never:
3375
+ default:
3376
+ return false;
3234
3377
  }
3235
- return sectionType.resizableY;
3236
3378
  }
3237
3379
  return ((_a = this.node) === null || _a === void 0 ? void 0 : _a.getResizableY()) || false;
3238
3380
  }
3381
+ /**
3382
+ * Returns whether this section can be resized diagonally.
3383
+ * If the section has a specific resizableXY setting, it uses that.
3384
+ * Otherwise, it inherits from the parent node's resizableXY setting.
3385
+ * @public
3386
+ */
3387
+ getResizableXY() {
3388
+ var _a;
3389
+ const sectionType = this.type;
3390
+ if ((sectionType === null || sectionType === void 0 ? void 0 : sectionType.resizerXY) !== undefined) {
3391
+ switch (sectionType.resizerXY.mode) {
3392
+ case exports.ResizableMode.OnlyWhenSelected:
3393
+ return this.selected;
3394
+ case exports.ResizableMode.Always:
3395
+ return true;
3396
+ case exports.ResizableMode.Never:
3397
+ default:
3398
+ return false;
3399
+ }
3400
+ }
3401
+ return ((_a = this.node) === null || _a === void 0 ? void 0 : _a.getResizableXY()) || false;
3402
+ }
3239
3403
  /**
3240
3404
  * Get the port of this section which is closest to the given coordinates.
3241
3405
  * @param coords A point in the diagram.
@@ -3445,8 +3609,9 @@ class DiagramSectionSet extends DiagramElementSet {
3445
3609
  const port = this.model.ports.new(portConfig.type !== undefined ? this.model.ports.types.get(portConfig.type) : undefined, section, [section.coords[0] + (portConfig.coords[0] || 0), section.coords[1] + (portConfig.coords[1] || 0)], portConfig.connectionPoint !== undefined ? [section.coords[0] + (portConfig.connectionPoint[0] || 0), section.coords[1] + (portConfig.connectionPoint[1] || 0)] : undefined, portConfig === null || portConfig === void 0 ? void 0 : portConfig.direction, `${section.id}_${i}`, portConfig.anchorPointX || 'floating', portConfig.anchorPointY || 'floating');
3446
3610
  if ((_e = port.type) === null || _e === void 0 ? void 0 : _e.label) {
3447
3611
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_f = port.type) === null || _f === void 0 ? void 0 : _f.label);
3448
- const labelWidth = 6 * labelConfiguration.fontSize + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
3449
- const labelHeight = labelConfiguration.fontSize + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
3612
+ labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
3613
+ const labelWidth = 6 * (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
3614
+ const labelHeight = (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
3450
3615
  let labelCoords;
3451
3616
  switch (port.direction) {
3452
3617
  case exports.Side.Bottom:
@@ -3460,7 +3625,7 @@ class DiagramSectionSet extends DiagramElementSet {
3460
3625
  default:
3461
3626
  labelCoords = port.coords;
3462
3627
  }
3463
- this.model.fields.new(port, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
3628
+ this.model.fields.new(port, labelCoords, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
3464
3629
  }
3465
3630
  }
3466
3631
  }
@@ -3468,7 +3633,8 @@ class DiagramSectionSet extends DiagramElementSet {
3468
3633
  const sectionLabel = (_k = (_j = (_h = (_g = node.type.sectionGrid) === null || _g === void 0 ? void 0 : _g.sections) === null || _h === void 0 ? void 0 : _h[indexYInNode]) === null || _j === void 0 ? void 0 : _j[indexXInNode]) === null || _k === void 0 ? void 0 : _k.label;
3469
3634
  if (sectionLabel) {
3470
3635
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), sectionLabel);
3471
- this.model.fields.new(section, [section.coords[0] + getLeftMargin(labelConfiguration), section.coords[1] + getTopMargin(labelConfiguration)], labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, section.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), section.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
3636
+ labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
3637
+ this.model.fields.new(section, [section.coords[0] + getLeftMargin(labelConfiguration), section.coords[1] + getTopMargin(labelConfiguration)], section.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), section.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
3472
3638
  }
3473
3639
  return section;
3474
3640
  }
@@ -3554,8 +3720,27 @@ class DiagramNodeType {
3554
3720
  this.defaultHeight = values.defaultHeight;
3555
3721
  this.minWidth = values.minWidth;
3556
3722
  this.minHeight = values.minHeight;
3557
- this.resizableX = values.resizableX;
3558
- this.resizableY = values.resizableY;
3723
+ if (typeof options.resizableX === 'undefined') {
3724
+ this.resizerX = new DiagramResizer({
3725
+ mode: exports.ResizableMode.Never
3726
+ });
3727
+ } else {
3728
+ this.resizerX = new DiagramResizer(options.resizableX);
3729
+ }
3730
+ if (typeof options.resizableY === 'undefined') {
3731
+ this.resizerY = new DiagramResizer({
3732
+ mode: exports.ResizableMode.Never
3733
+ });
3734
+ } else {
3735
+ this.resizerY = new DiagramResizer(options.resizableY);
3736
+ }
3737
+ if (typeof options.resizableXY === 'undefined') {
3738
+ this.resizerXY = new DiagramResizer({
3739
+ mode: exports.ResizableMode.Never
3740
+ });
3741
+ } else {
3742
+ this.resizerXY = new DiagramResizer(options.resizableXY);
3743
+ }
3559
3744
  this.snapToGridOffset = values.snapToGridOffset;
3560
3745
  this.bottomPadding = getBottomPadding(values);
3561
3746
  this.leftPadding = getLeftPadding(values);
@@ -3624,7 +3809,7 @@ class DiagramNode extends DiagramElement {
3624
3809
  }
3625
3810
  }
3626
3811
  /**
3627
- * Current look of this port.
3812
+ * Current look of this node.
3628
3813
  * @private
3629
3814
  */
3630
3815
  get look() {
@@ -3745,27 +3930,71 @@ class DiagramNode extends DiagramElement {
3745
3930
  getPriority() {
3746
3931
  return this.type.priority;
3747
3932
  }
3933
+ /**
3934
+ * Returns the horizontal resizer of this node.
3935
+ * @public
3936
+ */
3937
+ getResizerX() {
3938
+ return this.type.resizerX;
3939
+ }
3940
+ /**
3941
+ * Returns the vertical resizer of this node.
3942
+ * @public
3943
+ */
3944
+ getResizerY() {
3945
+ return this.type.resizerY;
3946
+ }
3947
+ /**
3948
+ * Returns the diagonal resizer of this node.
3949
+ * @public
3950
+ */
3951
+ getResizerXY() {
3952
+ return this.type.resizerXY;
3953
+ }
3748
3954
  /**
3749
3955
  * Returns whether this node can be resized horizontally.
3750
3956
  * @public
3751
3957
  */
3752
3958
  getResizableX() {
3753
- const resizableX = this.type.resizableX;
3754
- if (resizableX === exports.ResizableMode.OnlyWhenSelected) {
3755
- return this.selected;
3959
+ switch (this.type.resizerX.mode) {
3960
+ case exports.ResizableMode.OnlyWhenSelected:
3961
+ return this.selected;
3962
+ case exports.ResizableMode.Always:
3963
+ return true;
3964
+ case exports.ResizableMode.Never:
3965
+ default:
3966
+ return false;
3756
3967
  }
3757
- return resizableX;
3758
3968
  }
3759
3969
  /**
3760
3970
  * Returns whether this node can be resized vertically.
3761
3971
  * @public
3762
3972
  */
3763
3973
  getResizableY() {
3764
- const resizableY = this.type.resizableY;
3765
- if (resizableY === exports.ResizableMode.OnlyWhenSelected) {
3766
- return this.selected;
3974
+ switch (this.type.resizerY.mode) {
3975
+ case exports.ResizableMode.OnlyWhenSelected:
3976
+ return this.selected;
3977
+ case exports.ResizableMode.Always:
3978
+ return true;
3979
+ case exports.ResizableMode.Never:
3980
+ default:
3981
+ return false;
3982
+ }
3983
+ }
3984
+ /**
3985
+ * Returns whether this node can be resized diagonally.
3986
+ * @public
3987
+ */
3988
+ getResizableXY() {
3989
+ switch (this.type.resizerXY.mode) {
3990
+ case exports.ResizableMode.OnlyWhenSelected:
3991
+ return this.selected;
3992
+ case exports.ResizableMode.Always:
3993
+ return true;
3994
+ case exports.ResizableMode.Never:
3995
+ default:
3996
+ return false;
3767
3997
  }
3768
- return resizableY;
3769
3998
  }
3770
3999
  /**
3771
4000
  * Get the port of this node which is closest to the given coordinates.
@@ -4373,8 +4602,9 @@ class DiagramNodeSet extends DiagramElementSet {
4373
4602
  const port = this.model.ports.new(portType, node, [node.coords[0] + portConfig.coords[0], node.coords[1] + portConfig.coords[1]], portConfig.connectionPoint !== undefined ? [node.coords[0] + (portConfig.connectionPoint[0] || 0), node.coords[1] + (portConfig.connectionPoint[1] || 0)] : undefined, portConfig.direction, `${node.id}_port_${i}`, portConfig.anchorPointX || 'floating', portConfig.anchorPointY || 'floating');
4374
4603
  if ((_e = port.type) === null || _e === void 0 ? void 0 : _e.label) {
4375
4604
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_f = port.type) === null || _f === void 0 ? void 0 : _f.label);
4376
- const labelWidth = 6 * labelConfiguration.fontSize + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
4377
- const labelHeight = labelConfiguration.fontSize + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
4605
+ labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
4606
+ const labelWidth = 6 * (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
4607
+ const labelHeight = (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
4378
4608
  let labelCoords;
4379
4609
  switch (port.direction) {
4380
4610
  case exports.Side.Bottom:
@@ -4388,20 +4618,21 @@ class DiagramNodeSet extends DiagramElementSet {
4388
4618
  default:
4389
4619
  labelCoords = port.coords;
4390
4620
  }
4391
- this.model.fields.new(port, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
4621
+ this.model.fields.new(port, labelCoords, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
4392
4622
  }
4393
4623
  }
4394
4624
  }
4395
4625
  // add node label
4396
4626
  if (nodeType.label) {
4397
4627
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), nodeType.label);
4398
- this.model.fields.new(node, [node.coords[0] + getLeftMargin(labelConfiguration), node.coords[1] + getTopMargin(labelConfiguration)], labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, node.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), node.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
4628
+ labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
4629
+ this.model.fields.new(node, [node.coords[0] + getLeftMargin(labelConfiguration), node.coords[1] + getTopMargin(labelConfiguration)], node.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), node.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
4399
4630
  }
4400
4631
  // add node decorators
4401
4632
  if (nodeType.decorators.length > 0) {
4402
4633
  for (let i = 0; i < nodeType.decorators.length; ++i) {
4403
4634
  const decoratorConfig = nodeType.decorators[i];
4404
- this.model.decorators.new(node, [node.coords[0] + decoratorConfig.coords[0], node.coords[1] + decoratorConfig.coords[1]], decoratorConfig.width, decoratorConfig.height, node.getPriority(), decoratorConfig.html, `${node.id}_decorator_${i}`, decoratorConfig.anchorPointX || 'floating', decoratorConfig.anchorPointY || 'floating');
4635
+ this.model.decorators.new(node, [node.coords[0] + decoratorConfig.coords[0], node.coords[1] + decoratorConfig.coords[1]], decoratorConfig.width, decoratorConfig.height, node.getPriority(), decoratorConfig.svg, `${node.id}_decorator_${i}`, decoratorConfig.anchorPointX || 'floating', decoratorConfig.anchorPointY || 'floating');
4405
4636
  }
4406
4637
  }
4407
4638
  node.valueSet.resetValues();
@@ -4502,9 +4733,7 @@ const getBottomPadding = config => {
4502
4733
  } else if (typeof config.padding === 'number') {
4503
4734
  return config.padding;
4504
4735
  } else {
4505
- if (config.padding.length === 0) {
4506
- return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
4507
- } else if (config.padding.length === 1) {
4736
+ if (config.padding.length === 1) {
4508
4737
  return config.padding[0];
4509
4738
  } else if (config.padding.length === 2) {
4510
4739
  return config.padding[0];
@@ -4514,64 +4743,235 @@ const getBottomPadding = config => {
4514
4743
  return config.padding[2];
4515
4744
  }
4516
4745
  }
4517
- };
4518
- const getLeftPadding = config => {
4519
- if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
4520
- return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
4521
- } else if (typeof config.padding === 'number') {
4522
- return config.padding;
4523
- } else {
4524
- if (config.padding.length === 0) {
4525
- return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
4526
- } else if (config.padding.length === 1) {
4527
- return config.padding[0];
4528
- } else if (config.padding.length === 2) {
4529
- return config.padding[1];
4530
- } else if (config.padding.length === 3) {
4531
- return config.padding[1];
4532
- } else {
4533
- return config.padding[3];
4534
- }
4746
+ };
4747
+ const getLeftPadding = config => {
4748
+ if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
4749
+ return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
4750
+ } else if (typeof config.padding === 'number') {
4751
+ return config.padding;
4752
+ } else {
4753
+ if (config.padding.length === 1) {
4754
+ return config.padding[0];
4755
+ } else if (config.padding.length === 2) {
4756
+ return config.padding[1];
4757
+ } else if (config.padding.length === 3) {
4758
+ return config.padding[1];
4759
+ } else {
4760
+ return config.padding[3];
4761
+ }
4762
+ }
4763
+ };
4764
+ const getRightPadding = config => {
4765
+ if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
4766
+ return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
4767
+ } else if (typeof config.padding === 'number') {
4768
+ return config.padding;
4769
+ } else {
4770
+ if (config.padding.length === 1) {
4771
+ return config.padding[0];
4772
+ } else if (config.padding.length === 2) {
4773
+ return config.padding[1];
4774
+ } else if (config.padding.length === 3) {
4775
+ return config.padding[1];
4776
+ } else {
4777
+ return config.padding[1];
4778
+ }
4779
+ }
4780
+ };
4781
+ const getTopPadding = config => {
4782
+ if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
4783
+ return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
4784
+ } else if (typeof config.padding === 'number') {
4785
+ return config.padding;
4786
+ } else {
4787
+ if (config.padding.length === 1) {
4788
+ return config.padding[0];
4789
+ } else if (config.padding.length === 2) {
4790
+ return config.padding[0];
4791
+ } else if (config.padding.length === 3) {
4792
+ return config.padding[0];
4793
+ } else {
4794
+ return config.padding[0];
4795
+ }
4796
+ }
4797
+ };
4798
+
4799
+ /**
4800
+ * A foreign object which is inserted with arbitrary SVG code into a diagram.
4801
+ * Similar to a diagram object, but it's part of a node or section and it moves and stretches as its geometry changes.
4802
+ * Diagram decorators are not serialized with other diagram elements.
4803
+ * @public
4804
+ * @see DiagramNode
4805
+ * @see DiagramObject
4806
+ * @see DiagramSection
4807
+ */
4808
+ class DiagramDecorator extends DiagramElement {
4809
+ constructor(model, rootElement, coords, width, height, priority, svg, id, anchorPointX = 'floating', anchorPointY = 'floating') {
4810
+ if (model.objects.get(id) !== undefined) {
4811
+ throw new Error(`DiagramDecorator with id "${id}" already exists`);
4812
+ }
4813
+ if (!id) {
4814
+ throw new Error(`DiagramDecorator cannot have an empty or null id`);
4815
+ }
4816
+ super(model, id);
4817
+ this.rootElement = rootElement;
4818
+ this.coords = coords;
4819
+ this.width = width;
4820
+ this.height = height;
4821
+ this.priority = priority;
4822
+ this.svg = svg;
4823
+ this.anchorPointX = anchorPointX;
4824
+ this.anchorPointY = anchorPointY;
4825
+ }
4826
+ get removed() {
4827
+ return this.selfRemoved || this.rootElement !== undefined && this.rootElement.removed;
4828
+ }
4829
+ updateInView() {
4830
+ var _a;
4831
+ (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateDecoratorsInView(this.id);
4832
+ }
4833
+ raise() {
4834
+ var _a;
4835
+ (_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
4836
+ }
4837
+ /**
4838
+ * Change the coordinates of this decorator to the given coordinates.
4839
+ * @public
4840
+ * @param coords A point in the diagram.
4841
+ */
4842
+ move(coords) {
4843
+ this.coords = coords;
4844
+ this.updateInView();
4845
+ }
4846
+ getPriority() {
4847
+ return this.priority;
4848
+ }
4849
+ }
4850
+ class DiagramDecoratorSet extends DiagramElementSet {
4851
+ /**
4852
+ * Instance a set of decorators for the given model. This method is used internally.
4853
+ * @private
4854
+ */
4855
+ constructor(model) {
4856
+ super();
4857
+ this.model = model;
4858
+ }
4859
+ /**
4860
+ * Instance a new decorator and add it to this set.
4861
+ * @public
4862
+ * @param coords The coordinates of the top left corner of the decorator in the diagram.
4863
+ * @param width The dimension of the decorator along the x axis.
4864
+ * @param height The dimension of the decorator along the y axis.
4865
+ * @param priority The priority of the decorator. Used when filtering by priority.
4866
+ * @param svg The SVG contents of the decorator.
4867
+ * @param id The id of the decorator. Cannot be an empty string.
4868
+ * @returns The instanced decorator.
4869
+ */
4870
+ new(rootElement, coords, width, height, priority, svg, id, anchorPointX = 'floating', anchorPointY = 'floating') {
4871
+ const decorator = new DiagramDecorator(this.model, rootElement, coords, width, height, priority, svg, id, anchorPointX, anchorPointY);
4872
+ super.add(decorator);
4873
+ decorator.updateInView();
4874
+ // add this port to its root element
4875
+ if (rootElement !== undefined) {
4876
+ rootElement.decorators.push(decorator);
4877
+ }
4878
+ return decorator;
4879
+ }
4880
+ remove(id) {
4881
+ const decorator = this.get(id, true);
4882
+ if (decorator) {
4883
+ // remove from root element
4884
+ if (decorator.rootElement instanceof DiagramNode || decorator.rootElement instanceof DiagramSection) {
4885
+ removeIfExists(decorator.rootElement.decorators, decorator);
4886
+ }
4887
+ // remove from set of objects
4888
+ super.remove(id);
4889
+ // remove from canvas
4890
+ decorator.updateInView();
4891
+ }
4892
+ }
4893
+ }
4894
+
4895
+ /**
4896
+ * A foreign object which is inserted with arbitrary SVG code into a diagram.
4897
+ * Diagram objects are not serialized with other diagram elements.
4898
+ * @public
4899
+ */
4900
+ class DiagramObject extends DiagramElement {
4901
+ constructor(model, coords, width, height, priority, svg, id) {
4902
+ if (model.objects.get(id) !== undefined) {
4903
+ throw new Error(`DiagramObject with id "${id}" already exists`);
4904
+ }
4905
+ if (!id) {
4906
+ throw new Error(`DiagramObject cannot have an empty or null id`);
4907
+ }
4908
+ super(model, id);
4909
+ this.coords = coords;
4910
+ this.width = width;
4911
+ this.height = height;
4912
+ this.priority = priority;
4913
+ this.svg = svg;
4914
+ }
4915
+ get removed() {
4916
+ return this.selfRemoved;
4917
+ }
4918
+ updateInView() {
4919
+ var _a;
4920
+ (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateObjectsInView(this.id);
4921
+ }
4922
+ raise() {
4923
+ var _a;
4924
+ (_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
4925
+ }
4926
+ /**
4927
+ * Change the coordinates of this object to the given coordinates.
4928
+ * @public
4929
+ * @param coords A point in the diagram.
4930
+ */
4931
+ move(coords) {
4932
+ this.coords = coords;
4933
+ this.updateInView();
4535
4934
  }
4536
- };
4537
- const getRightPadding = config => {
4538
- if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
4539
- return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
4540
- } else if (typeof config.padding === 'number') {
4541
- return config.padding;
4542
- } else {
4543
- if (config.padding.length === 0) {
4544
- return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
4545
- } else if (config.padding.length === 1) {
4546
- return config.padding[0];
4547
- } else if (config.padding.length === 2) {
4548
- return config.padding[1];
4549
- } else if (config.padding.length === 3) {
4550
- return config.padding[1];
4551
- } else {
4552
- return config.padding[1];
4553
- }
4935
+ getPriority() {
4936
+ return this.priority;
4554
4937
  }
4555
- };
4556
- const getTopPadding = config => {
4557
- if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
4558
- return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
4559
- } else if (typeof config.padding === 'number') {
4560
- return config.padding;
4561
- } else {
4562
- if (config.padding.length === 0) {
4563
- return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
4564
- } else if (config.padding.length === 1) {
4565
- return config.padding[0];
4566
- } else if (config.padding.length === 2) {
4567
- return config.padding[0];
4568
- } else if (config.padding.length === 3) {
4569
- return config.padding[0];
4570
- } else {
4571
- return config.padding[0];
4938
+ }
4939
+ class DiagramObjectSet extends DiagramElementSet {
4940
+ /**
4941
+ * Instance a set of objects for the given model. This method is used internally.
4942
+ * @private
4943
+ */
4944
+ constructor(model) {
4945
+ super();
4946
+ this.model = model;
4947
+ }
4948
+ /**
4949
+ * Instance a new object and add it to this set.
4950
+ * @public
4951
+ * @param coords The coordinates of the top left corner of the object in the diagram.
4952
+ * @param width The dimension of the object along the x axis.
4953
+ * @param height The dimension of the object along the y axis.
4954
+ * @param priority The priority of the object. Used when filtering by priority.
4955
+ * @param svg The SVG contents of the object.
4956
+ * @param id The id of the object. Cannot be an empty string.
4957
+ * @returns The instanced object.
4958
+ */
4959
+ new(coords, width, height, priority, svg, id) {
4960
+ const object = new DiagramObject(this.model, coords, width, height, priority, svg, id);
4961
+ super.add(object);
4962
+ object.updateInView();
4963
+ return object;
4964
+ }
4965
+ remove(id) {
4966
+ const object = this.get(id, true);
4967
+ if (object) {
4968
+ // remove from set of objects
4969
+ super.remove(id);
4970
+ // remove from canvas
4971
+ object.updateInView();
4572
4972
  }
4573
4973
  }
4574
- };
4974
+ }
4575
4975
 
4576
4976
  /**
4577
4977
  * Default values of the look of a diagram port.
@@ -4938,6 +5338,14 @@ class DagaImporter {
4938
5338
  for (const connection of data.connections || []) {
4939
5339
  this.importConnection(model, connection);
4940
5340
  }
5341
+ for (const object of data.objects || []) {
5342
+ const newObject = new DiagramObject(model, object.coords, object.width, object.height, object.priority, object.svg, object.id);
5343
+ if (object.collabMeta) {
5344
+ newObject.selfRemoved = object.collabMeta.selfRemoved;
5345
+ }
5346
+ model.objects.add(newObject);
5347
+ newObject.updateInView();
5348
+ }
4941
5349
  if (data.data) {
4942
5350
  model.valueSet.setValues(data.data);
4943
5351
  }
@@ -4955,17 +5363,11 @@ class DagaImporter {
4955
5363
  model.nodes.add(newNode);
4956
5364
  newNode.width = node.width;
4957
5365
  newNode.height = node.height;
4958
- // add node decorators
4959
- if (newNodeType.decorators) {
4960
- for (let i = 0; i < newNodeType.decorators.length; ++i) {
4961
- const decoratorConfig = newNodeType.decorators[i];
4962
- model.decorators.new(newNode, [newNode.coords[0] + decoratorConfig.coords[0], newNode.coords[1] + decoratorConfig.coords[1]], decoratorConfig.width, decoratorConfig.height, newNode.getPriority(), decoratorConfig.html, `${newNode.id}_decorator_${i}`);
4963
- }
4964
- }
4965
5366
  // add node label
4966
5367
  if (newNodeType.label) {
4967
5368
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newNodeType.label);
4968
- const newField = new DiagramField(model, newNode, [newNode.coords[0] + getLeftMargin(labelConfiguration), newNode.coords[1] + getTopMargin(labelConfiguration)], newNode.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), newNode.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
5369
+ labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
5370
+ const newField = new DiagramField(model, newNode, [newNode.coords[0] + getLeftMargin(labelConfiguration), newNode.coords[1] + getTopMargin(labelConfiguration)], newNode.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), newNode.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
4969
5371
  newField.text = node.label;
4970
5372
  newNode.label = newField;
4971
5373
  model.fields.add(newField);
@@ -4985,7 +5387,8 @@ class DagaImporter {
4985
5387
  // add section label
4986
5388
  if ((_f = (_e = (_d = (_c = newNodeType.sectionGrid) === null || _c === void 0 ? void 0 : _c.sections) === null || _d === void 0 ? void 0 : _d[section.indexYInNode]) === null || _e === void 0 ? void 0 : _e[section.indexXInNode]) === null || _f === void 0 ? void 0 : _f.label) {
4987
5389
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_k = (_j = (_h = (_g = newNodeType.sectionGrid) === null || _g === void 0 ? void 0 : _g.sections) === null || _h === void 0 ? void 0 : _h[section.indexYInNode]) === null || _j === void 0 ? void 0 : _j[section.indexXInNode]) === null || _k === void 0 ? void 0 : _k.label);
4988
- const newField = new DiagramField(model, newSection, [newSection.coords[0] + getLeftMargin(labelConfiguration), newSection.coords[1] + getTopMargin(labelConfiguration)], newSection.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), newSection.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
5390
+ labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
5391
+ const newField = new DiagramField(model, newSection, [newSection.coords[0] + getLeftMargin(labelConfiguration), newSection.coords[1] + getTopMargin(labelConfiguration)], newSection.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), newSection.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
4989
5392
  newField.text = section.label;
4990
5393
  newSection.label = newField;
4991
5394
  model.fields.add(newField);
@@ -5001,22 +5404,23 @@ class DagaImporter {
5001
5404
  // add port label
5002
5405
  if (newNodeType.ports.length > portCounter && (newPortType === null || newPortType === void 0 ? void 0 : newPortType.label)) {
5003
5406
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newPortType === null || newPortType === void 0 ? void 0 : newPortType.label);
5407
+ labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
5004
5408
  let labelCoords;
5005
5409
  switch (newPort.direction) {
5006
5410
  case exports.Side.Top:
5007
5411
  case exports.Side.Left:
5008
- labelCoords = [newPort.coords[0] - labelConfiguration.fontSize, newPort.coords[1] - labelConfiguration.fontSize];
5412
+ labelCoords = [newPort.coords[0] - (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize), newPort.coords[1] - (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize)];
5009
5413
  break;
5010
5414
  case exports.Side.Bottom:
5011
- labelCoords = [newPort.coords[0] - labelConfiguration.fontSize, newPort.coords[1] + labelConfiguration.fontSize];
5415
+ labelCoords = [newPort.coords[0] - (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize), newPort.coords[1] + (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize)];
5012
5416
  break;
5013
5417
  case exports.Side.Right:
5014
- labelCoords = [newPort.coords[0] + labelConfiguration.fontSize, newPort.coords[1] - labelConfiguration.fontSize];
5418
+ labelCoords = [newPort.coords[0] + (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize), newPort.coords[1] - (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize)];
5015
5419
  break;
5016
5420
  default:
5017
5421
  labelCoords = newPort.coords;
5018
5422
  }
5019
- const newField = new DiagramField(model, newPort, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
5423
+ const newField = new DiagramField(model, newPort, labelCoords, labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize, labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
5020
5424
  newField.text = port.label;
5021
5425
  newPort.label = newField;
5022
5426
  model.fields.add(newField);
@@ -5031,6 +5435,15 @@ class DagaImporter {
5031
5435
  }
5032
5436
  newPort.updateInView();
5033
5437
  }
5438
+ for (const decorator of section.decorators || []) {
5439
+ const newDecorator = new DiagramDecorator(model, newSection, decorator.coords, decorator.width, decorator.height, decorator.priority, decorator.svg, decorator.id, decorator.anchorPoints[0], decorator.anchorPoints[1]);
5440
+ if (decorator.collabMeta) {
5441
+ newDecorator.selfRemoved = decorator.collabMeta.selfRemoved;
5442
+ }
5443
+ newNode.decorators.push(newDecorator);
5444
+ model.decorators.add(newDecorator);
5445
+ newDecorator.updateInView();
5446
+ }
5034
5447
  if (section.collabMeta) {
5035
5448
  newSection.selfRemoved = section.collabMeta.selfRemoved;
5036
5449
  newSection.selfRemovedTimestamp = section.collabMeta.selfRemovedTimestamp;
@@ -5048,22 +5461,23 @@ class DagaImporter {
5048
5461
  // add port label
5049
5462
  if (newNodeType.ports.length > portCounter && (newPortType === null || newPortType === void 0 ? void 0 : newPortType.label)) {
5050
5463
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newPortType === null || newPortType === void 0 ? void 0 : newPortType.label);
5464
+ labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
5051
5465
  let labelCoords;
5052
5466
  switch (newPort.direction) {
5053
5467
  case exports.Side.Top:
5054
5468
  case exports.Side.Left:
5055
- labelCoords = [newPort.coords[0] - labelConfiguration.fontSize, newPort.coords[1] - labelConfiguration.fontSize];
5469
+ labelCoords = [newPort.coords[0] - (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize), newPort.coords[1] - (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize)];
5056
5470
  break;
5057
5471
  case exports.Side.Bottom:
5058
- labelCoords = [newPort.coords[0] - labelConfiguration.fontSize, newPort.coords[1] + labelConfiguration.fontSize];
5472
+ labelCoords = [newPort.coords[0] - (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize), newPort.coords[1] + (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize)];
5059
5473
  break;
5060
5474
  case exports.Side.Right:
5061
- labelCoords = [newPort.coords[0] + labelConfiguration.fontSize, newPort.coords[1] - labelConfiguration.fontSize];
5475
+ labelCoords = [newPort.coords[0] + (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize), newPort.coords[1] - (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize)];
5062
5476
  break;
5063
5477
  default:
5064
5478
  labelCoords = newPort.coords;
5065
5479
  }
5066
- const newField = new DiagramField(model, newPort, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
5480
+ const newField = new DiagramField(model, newPort, labelCoords, labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize, labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
5067
5481
  newField.text = port.label;
5068
5482
  newPort.label = newField;
5069
5483
  model.fields.add(newField);
@@ -5078,6 +5492,15 @@ class DagaImporter {
5078
5492
  }
5079
5493
  newPort.updateInView();
5080
5494
  }
5495
+ for (const decorator of node.decorators || []) {
5496
+ const newDecorator = new DiagramDecorator(model, newNode, decorator.coords, decorator.width, decorator.height, decorator.priority, decorator.svg, decorator.id, decorator.anchorPoints[0], decorator.anchorPoints[1]);
5497
+ if (decorator.collabMeta) {
5498
+ newDecorator.selfRemoved = decorator.collabMeta.selfRemoved;
5499
+ }
5500
+ newNode.decorators.push(newDecorator);
5501
+ model.decorators.add(newDecorator);
5502
+ newDecorator.updateInView();
5503
+ }
5081
5504
  if (node.data) {
5082
5505
  newNode.valueSet.setValues(node.data);
5083
5506
  }
@@ -6369,7 +6792,8 @@ class DiagramZoomEvent extends DiagramEvent {
6369
6792
  /**
6370
6793
  * Create a diagram zoom event.
6371
6794
  *
6372
- * @param coords .
6795
+ * @param coords Coordinates to which the user panned. Calling the method `canvas.translateTo()` with these coordinates after this event should cause no changes.
6796
+ * @param zoom Zoom level to which the user zoomed. Calling the method `canvas.zoomTo()` with this zoom level after this event should cause no changes.
6373
6797
  */
6374
6798
  constructor(coords, zoom) {
6375
6799
  super(exports.DiagramEvents.Zoom);
@@ -6429,210 +6853,33 @@ class DiagramSelectionEvent extends DiagramEvent {
6429
6853
  this.selected = selected;
6430
6854
  }
6431
6855
  }
6432
- /**
6433
- * Diagram event which consists of the user highlighting a diagram element.
6434
- * If the target is `null`, that means that the previously highlighted element was unhighlighted.
6435
- */
6436
- class DiagramHighlightedEvent extends DiagramEvent {
6437
- /**
6438
- * Create a diagram highlight event.
6439
- *
6440
- * @param target Diagram element which is targeted by the event.
6441
- */
6442
- constructor(target) {
6443
- super(exports.DiagramEvents.Highlight);
6444
- this.target = target;
6445
- }
6446
- }
6447
- /**
6448
- * Diagram event which consists of the user dragging a diagram node.
6449
- */
6450
- class DiagramDraggingNodeEvent extends DiagramEvent {
6451
- /**
6452
- * Create a diagram dragging node event.
6453
- *
6454
- * @param target Diagram node which is targeted by the event.
6455
- */
6456
- constructor(target) {
6457
- super(exports.DiagramEvents.DraggingNode);
6458
- this.target = target;
6459
- }
6460
- }
6461
-
6462
- /**
6463
- * A foreign object which is inserted with arbitrary html into a diagram.
6464
- * Similar to a diagram object, but it's part of a node or section and it moves and stretches as its geometry changes.
6465
- * Diagram decorators are not serialized with other diagram elements.
6466
- * @public
6467
- * @see DiagramNode
6468
- * @see DiagramObject
6469
- * @see DiagramSection
6470
- */
6471
- class DiagramDecorator extends DiagramElement {
6472
- constructor(model, rootElement, coords, width, height, priority, html, id, anchorPointX = 'floating', anchorPointY = 'floating') {
6473
- if (model.objects.get(id) !== undefined) {
6474
- throw new Error(`DiagramDecorator with id "${id}" already exists`);
6475
- }
6476
- if (!id) {
6477
- throw new Error(`DiagramDecorator cannot have an empty or null id`);
6478
- }
6479
- super(model, id);
6480
- this.rootElement = rootElement;
6481
- this.coords = coords;
6482
- this.width = width;
6483
- this.height = height;
6484
- this.priority = priority;
6485
- this.html = html;
6486
- this.anchorPointX = anchorPointX;
6487
- this.anchorPointY = anchorPointY;
6488
- }
6489
- get removed() {
6490
- return this.selfRemoved || this.rootElement !== undefined && this.rootElement.removed;
6491
- }
6492
- updateInView() {
6493
- var _a;
6494
- (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateDecoratorsInView(this.id);
6495
- }
6496
- raise() {
6497
- var _a;
6498
- (_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
6499
- }
6500
- /**
6501
- * Change the coordinates of this decorator to the given coordinates.
6502
- * @public
6503
- * @param coords A point in the diagram.
6504
- */
6505
- move(coords) {
6506
- this.coords = coords;
6507
- this.updateInView();
6508
- }
6509
- getPriority() {
6510
- return this.priority;
6511
- }
6512
- }
6513
- class DiagramDecoratorSet extends DiagramElementSet {
6514
- /**
6515
- * Instance a set of decorators for the given model. This method is used internally.
6516
- * @private
6517
- */
6518
- constructor(model) {
6519
- super();
6520
- this.model = model;
6521
- }
6522
- /**
6523
- * Instance a new decorator and add it to this set.
6524
- * @public
6525
- * @param coords The coordinates of the top left corner of the decorator in the diagram.
6526
- * @param width The dimension of the decorator along the x axis.
6527
- * @param height The dimension of the decorator along the y axis.
6528
- * @param priority The priority of the decorator. Used when filtering by priority.
6529
- * @param html The html contents of the decorator.
6530
- * @param id The id of the decorator. Cannot be an empty string.
6531
- * @returns The instanced decorator.
6532
- */
6533
- new(rootElement, coords, width, height, priority, html, id, anchorPointX = 'floating', anchorPointY = 'floating') {
6534
- const decorator = new DiagramDecorator(this.model, rootElement, coords, width, height, priority, html, id, anchorPointX, anchorPointY);
6535
- super.add(decorator);
6536
- decorator.updateInView();
6537
- // add this port to its root element
6538
- if (rootElement !== undefined) {
6539
- rootElement.decorators.push(decorator);
6540
- }
6541
- return decorator;
6542
- }
6543
- remove(id) {
6544
- const decorator = this.get(id, true);
6545
- if (decorator) {
6546
- // remove from root element
6547
- if (decorator.rootElement instanceof DiagramNode || decorator.rootElement instanceof DiagramSection) {
6548
- removeIfExists(decorator.rootElement.decorators, decorator);
6549
- }
6550
- // remove from set of objects
6551
- super.remove(id);
6552
- // remove from canvas
6553
- decorator.updateInView();
6554
- }
6555
- }
6556
- }
6557
-
6558
- /**
6559
- * A foreign object which is inserted with arbitrary html into a diagram.
6560
- * Diagram objects are not serialized with other diagram elements.
6561
- * @public
6562
- */
6563
- class DiagramObject extends DiagramElement {
6564
- constructor(model, coords, width, height, priority, html, id) {
6565
- if (model.objects.get(id) !== undefined) {
6566
- throw new Error(`DiagramObject with id "${id}" already exists`);
6567
- }
6568
- if (!id) {
6569
- throw new Error(`DiagramObject cannot have an empty or null id`);
6570
- }
6571
- super(model, id);
6572
- this.coords = coords;
6573
- this.width = width;
6574
- this.height = height;
6575
- this.priority = priority;
6576
- this.html = html;
6577
- }
6578
- get removed() {
6579
- return this.selfRemoved;
6580
- }
6581
- updateInView() {
6582
- var _a;
6583
- (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateObjectsInView(this.id);
6584
- }
6585
- raise() {
6586
- var _a;
6587
- (_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
6588
- }
6589
- /**
6590
- * Change the coordinates of this object to the given coordinates.
6591
- * @public
6592
- * @param coords A point in the diagram.
6593
- */
6594
- move(coords) {
6595
- this.coords = coords;
6596
- this.updateInView();
6597
- }
6598
- getPriority() {
6599
- return this.priority;
6600
- }
6601
- }
6602
- class DiagramObjectSet extends DiagramElementSet {
6856
+ /**
6857
+ * Diagram event which consists of the user highlighting a diagram element.
6858
+ * If the target is `null`, that means that the previously highlighted element was unhighlighted.
6859
+ */
6860
+ class DiagramHighlightedEvent extends DiagramEvent {
6603
6861
  /**
6604
- * Instance a set of objects for the given model. This method is used internally.
6605
- * @private
6862
+ * Create a diagram highlight event.
6863
+ *
6864
+ * @param target Diagram element which is targeted by the event.
6606
6865
  */
6607
- constructor(model) {
6608
- super();
6609
- this.model = model;
6866
+ constructor(target) {
6867
+ super(exports.DiagramEvents.Highlight);
6868
+ this.target = target;
6610
6869
  }
6870
+ }
6871
+ /**
6872
+ * Diagram event which consists of the user dragging a diagram node.
6873
+ */
6874
+ class DiagramDraggingNodeEvent extends DiagramEvent {
6611
6875
  /**
6612
- * Instance a new object and add it to this set.
6613
- * @public
6614
- * @param coords The coordinates of the top left corner of the object in the diagram.
6615
- * @param width The dimension of the object along the x axis.
6616
- * @param height The dimension of the object along the y axis.
6617
- * @param priority The priority of the object. Used when filtering by priority.
6618
- * @param html The html contents of the object.
6619
- * @param id The id of the object. Cannot be an empty string.
6620
- * @returns The instanced object.
6876
+ * Create a diagram dragging node event.
6877
+ *
6878
+ * @param target Diagram node which is targeted by the event.
6621
6879
  */
6622
- new(coords, width, height, priority, html, id) {
6623
- const object = new DiagramObject(this.model, coords, width, height, priority, html, id);
6624
- super.add(object);
6625
- object.updateInView();
6626
- return object;
6627
- }
6628
- remove(id) {
6629
- const object = this.get(id, true);
6630
- if (object) {
6631
- // remove from set of objects
6632
- super.remove(id);
6633
- // remove from canvas
6634
- object.updateInView();
6635
- }
6880
+ constructor(target) {
6881
+ super(exports.DiagramEvents.DraggingNode);
6882
+ this.target = target;
6636
6883
  }
6637
6884
  }
6638
6885
 
@@ -6737,7 +6984,7 @@ const isSecondaryButton = event => {
6737
6984
  const getConnectionPath = (shape, startCoords, endCoords, startDirection, endDirection, points, width, startMarkerWidth, endMarkerWidth) => {
6738
6985
  return linePath(shape, [startCoords, ...points, endCoords], startDirection, endDirection, Math.max(
6739
6986
  // reasonable value for the minimumDistanceBeforeTurn relative to the line width
6740
- 10, startMarkerWidth || 0, endMarkerWidth || 0) * width);
6987
+ 10, startMarkerWidth !== null && startMarkerWidth !== void 0 ? startMarkerWidth : 0, endMarkerWidth !== null && endMarkerWidth !== void 0 ? endMarkerWidth : 0) * width);
6741
6988
  };
6742
6989
  const setCursorStyle = style => {
6743
6990
  if (!style) {
@@ -6747,21 +6994,23 @@ const setCursorStyle = style => {
6747
6994
  }
6748
6995
  };
6749
6996
  const getRelatedNodeOrItself = element => {
6997
+ var _a;
6750
6998
  if (element instanceof DiagramNode) {
6751
6999
  return element;
6752
7000
  }
6753
7001
  if (element instanceof DiagramSection) {
6754
- return element.node || element;
7002
+ return (_a = element.node) !== null && _a !== void 0 ? _a : element;
6755
7003
  }
6756
7004
  return element.rootElement instanceof DiagramNode || element.rootElement instanceof DiagramSection || element.rootElement instanceof DiagramPort ? getRelatedNodeOrItself(element.rootElement) : element;
6757
7005
  };
6758
7006
  const needsResizerX = element => {
7007
+ var _a;
6759
7008
  if (element instanceof DiagramNode) {
6760
- return element.type.resizableX !== false;
7009
+ return element.type.resizerX.mode !== exports.ResizableMode.Never;
6761
7010
  }
6762
7011
  if (element instanceof DiagramSection) {
6763
- if (element.type !== undefined) {
6764
- return element.type.resizableX !== false;
7012
+ if (((_a = element.type) === null || _a === void 0 ? void 0 : _a.resizerX) !== undefined) {
7013
+ return element.type.resizerX.mode !== exports.ResizableMode.Never;
6765
7014
  }
6766
7015
  if (element.node !== undefined) {
6767
7016
  return needsResizerX(element.node);
@@ -6770,12 +7019,13 @@ const needsResizerX = element => {
6770
7019
  return false;
6771
7020
  };
6772
7021
  const needsResizerY = element => {
7022
+ var _a;
6773
7023
  if (element instanceof DiagramNode) {
6774
- return element.type.resizableY !== false;
7024
+ return element.type.resizerY.mode !== exports.ResizableMode.Never;
6775
7025
  }
6776
7026
  if (element instanceof DiagramSection) {
6777
- if (element.type !== undefined) {
6778
- return element.type.resizableY !== false;
7027
+ if (((_a = element.type) === null || _a === void 0 ? void 0 : _a.resizerY) !== undefined) {
7028
+ return element.type.resizerY.mode !== exports.ResizableMode.Never;
6779
7029
  }
6780
7030
  if (element.node !== undefined) {
6781
7031
  return needsResizerY(element.node);
@@ -6783,6 +7033,21 @@ const needsResizerY = element => {
6783
7033
  }
6784
7034
  return false;
6785
7035
  };
7036
+ const needsResizerXY = element => {
7037
+ var _a;
7038
+ if (element instanceof DiagramNode) {
7039
+ return element.type.resizerXY.mode !== exports.ResizableMode.Never;
7040
+ }
7041
+ if (element instanceof DiagramSection) {
7042
+ if (((_a = element.type) === null || _a === void 0 ? void 0 : _a.resizerXY) !== undefined) {
7043
+ return element.type.resizerXY.mode !== exports.ResizableMode.Never;
7044
+ }
7045
+ if (element.node !== undefined) {
7046
+ return needsResizerXY(element.node);
7047
+ }
7048
+ }
7049
+ return false;
7050
+ };
6786
7051
  const initializeLook = selection => {
6787
7052
  selection.filter('.shaped-look').append('path');
6788
7053
  selection.filter('.image-look').append('image').attr('preserveAspectRatio', 'none');
@@ -6803,9 +7068,21 @@ const SHAPED_LOOK_DEFAULTS = {
6803
7068
  borderStyle: exports.LineStyle.Solid
6804
7069
  };
6805
7070
  const updateLook = selection => {
6806
- selection.filter('.shaped-look').select('path').attr('d', d => generalClosedPath(d.look.shape || exports.ClosedShape.Rectangle, 0, 0, d.width, d.height)).attr('fill', d => d.look.fillColor || SHAPED_LOOK_DEFAULTS.fillColor).attr('stroke', d => d.look.borderColor || SHAPED_LOOK_DEFAULTS.borderColor).attr('stroke-width', d => `${d.look.borderThickness || SHAPED_LOOK_DEFAULTS.borderThickness}px`).attr('stroke-dasharray', d => {
6807
- var _a, _b, _c;
6808
- return lineStyleDasharray(d.look.borderStyle || SHAPED_LOOK_DEFAULTS.borderStyle, ((_b = (_a = d.type) === null || _a === void 0 ? void 0 : _a.defaultLook) === null || _b === void 0 ? void 0 : _b.borderThickness) || ((_c = d.look) === null || _c === void 0 ? void 0 : _c.borderThickness) || SHAPED_LOOK_DEFAULTS.borderThickness);
7071
+ selection.filter('.shaped-look').select('path').attr('d', d => {
7072
+ var _a;
7073
+ return generalClosedPath((_a = d.look.shape) !== null && _a !== void 0 ? _a : exports.ClosedShape.Rectangle, 0, 0, d.width, d.height);
7074
+ }).attr('fill', d => {
7075
+ var _a;
7076
+ return (_a = d.look.fillColor) !== null && _a !== void 0 ? _a : SHAPED_LOOK_DEFAULTS.fillColor;
7077
+ }).attr('stroke', d => {
7078
+ var _a;
7079
+ return (_a = d.look.borderColor) !== null && _a !== void 0 ? _a : SHAPED_LOOK_DEFAULTS.borderColor;
7080
+ }).attr('stroke-width', d => {
7081
+ var _a;
7082
+ return `${(_a = d.look.borderThickness) !== null && _a !== void 0 ? _a : SHAPED_LOOK_DEFAULTS.borderThickness}px`;
7083
+ }).attr('stroke-dasharray', d => {
7084
+ var _a, _b, _c, _d, _e, _f;
7085
+ return lineStyleDasharray((_a = d.look.borderStyle) !== null && _a !== void 0 ? _a : SHAPED_LOOK_DEFAULTS.borderStyle, (_f = (_d = (_c = (_b = d.type) === null || _b === void 0 ? void 0 : _b.defaultLook) === null || _c === void 0 ? void 0 : _c.borderThickness) !== null && _d !== void 0 ? _d : (_e = d.look) === null || _e === void 0 ? void 0 : _e.borderThickness) !== null && _f !== void 0 ? _f : SHAPED_LOOK_DEFAULTS.borderThickness);
6809
7086
  });
6810
7087
  selection.filter('.image-look').select('image').attr('x', 0).attr('y', 0).attr('width', d => d.width).attr('height', d => d.height).attr('href', d => d.look.backgroundImage);
6811
7088
  selection.filter('.stretchable-image-look').select('image.top-left-image').attr('x', 0).attr('y', 0).attr('width', d => d.look.leftMargin).attr('height', d => d.look.topMargin).attr('href', d => d.look.backgroundImageTopLeft);
@@ -6818,30 +7095,91 @@ const updateLook = selection => {
6818
7095
  selection.filter('.stretchable-image-look').select('image.bottom-image').attr('x', d => d.look.leftMargin).attr('y', d => d.height - d.look.bottomMargin).attr('width', d => d.width - d.look.rightMargin - d.look.leftMargin).attr('height', d => d.look.bottomMargin).attr('href', d => d.look.backgroundImageBottom);
6819
7096
  selection.filter('.stretchable-image-look').select('image.bottom-right-image').attr('x', d => d.width - d.look.rightMargin).attr('y', d => d.height - d.look.bottomMargin).attr('width', d => d.look.rightMargin).attr('height', d => d.look.bottomMargin).attr('href', d => d.look.backgroundImageBottomRight);
6820
7097
  };
7098
+ const BACKGROUND_DEFAULTS = {
7099
+ style: 'solid',
7100
+ color: '#FFFFFF'
7101
+ };
6821
7102
  const GRID_DEFAULTS = {
7103
+ enabled: true,
7104
+ style: 'none',
7105
+ snap: false,
7106
+ spacing: 1
7107
+ };
7108
+ const DOTS_GRID_DEFAULTS = Object.assign(Object.assign({}, GRID_DEFAULTS), {
6822
7109
  style: 'dots',
6823
- color: 'rgba(0, 0, 0, 0.1)',
6824
7110
  snap: false,
6825
7111
  spacing: 10,
6826
- thickness: 0.05
7112
+ thickness: 0.05,
7113
+ color: 'rgba(0, 0, 0, 0.1)'
7114
+ });
7115
+ const initializeBackground = (canvasView, backgroundConfig) => {
7116
+ var _a, _b;
7117
+ switch ((_a = backgroundConfig === null || backgroundConfig === void 0 ? void 0 : backgroundConfig.style) !== null && _a !== void 0 ? _a : '') {
7118
+ case 'image':
7119
+ return canvasView.append('image').attr('x', 0).attr('y', 0).attr('width', `100%`).attr('height', `100%`).attr('href', backgroundConfig.image).attr('preserveAspectRatio', 'none');
7120
+ case 'solid':
7121
+ default:
7122
+ return canvasView.append('rect').attr('x', 0).attr('y', 0).attr('width', `100%`).attr('height', `100%`).attr('fill', (_b = backgroundConfig.color) !== null && _b !== void 0 ? _b : '#FFFFFF').attr('stroke-width', '0');
7123
+ }
6827
7124
  };
6828
- const initializeGrid = (canvas, canvasView, backgroundPatternId) => {
6829
- const canvasDefs = canvasView.append('defs');
6830
- if (canvas.gridSize > 0 && isFinite(canvas.gridSize)) {
6831
- const canvasBackgroundPattern = canvasDefs.append('pattern').attr('id', backgroundPatternId).attr('x', -canvas.gridSize / 2).attr('y', -canvas.gridSize / 2).attr('width', canvas.gridSize).attr('height', canvas.gridSize).attr('patternUnits', 'userSpaceOnUse');
6832
- canvasBackgroundPattern.append('rect').attr('x', 0).attr('y', 0).attr('width', canvas.gridSize).attr('height', canvas.gridSize).attr('fill', canvas.backgroundColor);
6833
- switch (canvas.gridStyle) {
7125
+ const applyGridDefaults = gridConfig => {
7126
+ if (!gridConfig) {
7127
+ return DOTS_GRID_DEFAULTS;
7128
+ }
7129
+ switch (gridConfig.style) {
7130
+ case 'dots':
7131
+ case 'lines':
7132
+ // lines has the same parameters as dots
7133
+ return Object.assign(Object.assign({}, DOTS_GRID_DEFAULTS), gridConfig);
7134
+ default:
7135
+ return Object.assign(Object.assign({}, GRID_DEFAULTS), gridConfig);
7136
+ }
7137
+ };
7138
+ const initializeGrid = (canvas, canvasView, canvasDefs, gridPatternId, gridConfig) => {
7139
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
7140
+ if (getGridSpacingX(gridConfig) !== 0 && getGridSpacingY(gridConfig) !== 0) {
7141
+ const canvasBackgroundPattern = canvasDefs.append('pattern').attr('id', gridPatternId).attr('x', -getGridSpacingX(gridConfig) / 2).attr('y', -getGridSpacingY(gridConfig) / 2).attr('width', getGridSpacingX(gridConfig)).attr('height', getGridSpacingY(gridConfig)).attr('patternUnits', 'userSpaceOnUse');
7142
+ canvasBackgroundPattern.append('rect').attr('x', 0).attr('y', 0).attr('width', getGridSpacingX(gridConfig)).attr('height', getGridSpacingY(gridConfig)).attr('fill', 'transparent');
7143
+ switch (gridConfig.style) {
6834
7144
  case 'dots':
6835
- canvasBackgroundPattern.append('circle').attr('cx', canvas.gridSize / 2).attr('cy', canvas.gridSize / 2).attr('r', canvas.gridSize * canvas.gridThickness).attr('fill', canvas.gridColor);
7145
+ canvasBackgroundPattern.append('circle').attr('cx', getGridSpacingX(gridConfig) / 2).attr('cy', getGridSpacingY(gridConfig) / 2).attr('r', Math.min(getGridSpacingX(gridConfig), getGridSpacingY(gridConfig)) * ((_a = gridConfig.thickness) !== null && _a !== void 0 ? _a : 0)).attr('fill', (_b = gridConfig.color) !== null && _b !== void 0 ? _b : '');
6836
7146
  break;
6837
7147
  case 'lines':
6838
- canvasBackgroundPattern.append('line').attr('x1', canvas.gridSize / 2).attr('x2', canvas.gridSize / 2).attr('y1', 0).attr('y2', canvas.gridSize).attr('stroke-width', canvas.gridSize * canvas.gridThickness).attr('stroke', canvas.gridColor);
6839
- canvasBackgroundPattern.append('line').attr('x1', 0).attr('x2', (canvas.gridSize - canvas.gridSize * canvas.gridThickness) / 2).attr('y1', canvas.gridSize / 2).attr('y2', canvas.gridSize / 2).attr('stroke-width', canvas.gridSize * canvas.gridThickness).attr('stroke', canvas.gridColor);
6840
- canvasBackgroundPattern.append('line').attr('x1', (canvas.gridSize + canvas.gridSize * canvas.gridThickness) / 2).attr('x2', canvas.gridSize).attr('y1', canvas.gridSize / 2).attr('y2', canvas.gridSize / 2).attr('stroke-width', canvas.gridSize * canvas.gridThickness).attr('stroke', canvas.gridColor);
7148
+ canvasBackgroundPattern.append('line').attr('x1', getGridSpacingX(gridConfig) / 2).attr('x2', getGridSpacingX(gridConfig) / 2).attr('y1', 0).attr('y2', getGridSpacingY(gridConfig)).attr('stroke-width', Math.min(getGridSpacingX(gridConfig), getGridSpacingY(gridConfig)) * ((_c = gridConfig.thickness) !== null && _c !== void 0 ? _c : 0)).attr('stroke', (_d = gridConfig.color) !== null && _d !== void 0 ? _d : '');
7149
+ canvasBackgroundPattern.append('line').attr('x1', 0).attr('x2', (getGridSpacingX(gridConfig) - getGridSpacingX(gridConfig) * ((_e = gridConfig.thickness) !== null && _e !== void 0 ? _e : 0)) / 2).attr('y1', getGridSpacingY(gridConfig) / 2).attr('y2', getGridSpacingY(gridConfig) / 2).attr('stroke-width', Math.min(getGridSpacingX(gridConfig), getGridSpacingY(gridConfig)) * ((_f = gridConfig.thickness) !== null && _f !== void 0 ? _f : 0)).attr('stroke', (_g = gridConfig.color) !== null && _g !== void 0 ? _g : '');
7150
+ canvasBackgroundPattern.append('line').attr('x1', (getGridSpacingX(gridConfig) + getGridSpacingX(gridConfig) * ((_h = gridConfig.thickness) !== null && _h !== void 0 ? _h : 0)) / 2).attr('x2', getGridSpacingX(gridConfig)).attr('y1', getGridSpacingY(gridConfig) / 2).attr('y2', getGridSpacingY(gridConfig) / 2).attr('stroke-width', Math.min(getGridSpacingX(gridConfig), getGridSpacingY(gridConfig)) * ((_j = gridConfig.thickness) !== null && _j !== void 0 ? _j : 0)).attr('stroke', (_k = gridConfig.color) !== null && _k !== void 0 ? _k : '');
7151
+ break;
7152
+ case 'image':
7153
+ canvasBackgroundPattern.append('image').attr('x', 0).attr('y', 0).attr('width', getGridSpacingX(gridConfig)).attr('height', getGridSpacingY(gridConfig)).attr('href', gridConfig.image).attr('preserveAspectRatio', 'none');
6841
7154
  break;
6842
7155
  }
6843
- canvasView.select('rect').attr('fill', `url(#${backgroundPatternId})`);
7156
+ return canvasView.append('rect').attr('x', 0).attr('y', 0).attr('width', `100%`).attr('height', `100%`).attr('fill', `url(#${gridPatternId})`).attr('stroke-width', '0');
7157
+ }
7158
+ return undefined;
7159
+ };
7160
+ const getGridSpacingX = gridConfig => {
7161
+ let value = 0;
7162
+ if (typeof gridConfig.spacing === 'number') {
7163
+ value = gridConfig.spacing;
7164
+ } else if (Array.isArray(gridConfig.spacing) && typeof gridConfig.spacing[0] === 'number') {
7165
+ value = gridConfig.spacing[0];
7166
+ }
7167
+ if (!isFinite(value)) {
7168
+ return 0;
7169
+ }
7170
+ return value;
7171
+ };
7172
+ const getGridSpacingY = gridConfig => {
7173
+ let value = 0;
7174
+ if (typeof gridConfig.spacing === 'number') {
7175
+ value = gridConfig.spacing;
7176
+ } else if (Array.isArray(gridConfig.spacing) && typeof gridConfig.spacing[1] === 'number') {
7177
+ value = gridConfig.spacing[1];
7178
+ }
7179
+ if (!isFinite(value)) {
7180
+ return 0;
6844
7181
  }
7182
+ return value;
6845
7183
  };
6846
7184
 
6847
7185
  const CONTEXT_MENU_MENU_RADIUS = 96;
@@ -7087,6 +7425,7 @@ const DAGA_FILE_VERSION = 1;
7087
7425
  */
7088
7426
  class DagaExporter {
7089
7427
  export(model, includeCollabMeta = false) {
7428
+ var _a;
7090
7429
  const result = Object.assign({
7091
7430
  name: model.name,
7092
7431
  type: model.type,
@@ -7095,6 +7434,7 @@ class DagaExporter {
7095
7434
  updatedAt: model.updatedAt,
7096
7435
  nodes: [],
7097
7436
  connections: [],
7437
+ objects: [],
7098
7438
  data: model.valueSet.getValues()
7099
7439
  }, includeCollabMeta ? {
7100
7440
  collabMeta: {
@@ -7117,6 +7457,21 @@ class DagaExporter {
7117
7457
  if (!includeCollabMeta && connection.removed) continue;
7118
7458
  result.connections.push(this.exportConnection(connection, includeCollabMeta));
7119
7459
  }
7460
+ for (const object of model.objects.all(true)) {
7461
+ (_a = result.objects) === null || _a === void 0 ? void 0 : _a.push(Object.assign({
7462
+ id: object.id,
7463
+ coords: roundPoint(object.coords),
7464
+ width: object.width,
7465
+ height: object.height,
7466
+ priority: object.priority,
7467
+ svg: object.svg
7468
+ }, includeCollabMeta ? {
7469
+ collabMeta: {
7470
+ removed: object.removed,
7471
+ selfRemoved: object.selfRemoved
7472
+ }
7473
+ } : {}));
7474
+ }
7120
7475
  return result;
7121
7476
  }
7122
7477
  exportNode(node, includeCollabMeta = false) {
@@ -7144,9 +7499,27 @@ class DagaExporter {
7144
7499
  }, this.exportLabelCollabMeta(port))
7145
7500
  } : {}));
7146
7501
  }
7502
+ const decorators = [];
7503
+ for (const decorator of section.decorators) {
7504
+ decorators.push(Object.assign({
7505
+ id: decorator.id,
7506
+ coords: roundPoint(decorator.coords),
7507
+ width: decorator.width,
7508
+ height: decorator.height,
7509
+ priority: decorator.priority,
7510
+ svg: decorator.svg,
7511
+ anchorPoints: [decorator.anchorPointX, decorator.anchorPointY]
7512
+ }, includeCollabMeta ? {
7513
+ collabMeta: {
7514
+ removed: decorator.removed,
7515
+ selfRemoved: decorator.selfRemoved
7516
+ }
7517
+ } : {}));
7518
+ }
7147
7519
  sections.push(Object.assign({
7148
7520
  id: section.id,
7149
7521
  ports,
7522
+ decorators,
7150
7523
  label: ((_c = section.label) === null || _c === void 0 ? void 0 : _c.text) || '',
7151
7524
  indexXInNode: section.indexXInNode,
7152
7525
  indexYInNode: section.indexYInNode,
@@ -7178,12 +7551,30 @@ class DagaExporter {
7178
7551
  }, this.exportLabelCollabMeta(port))
7179
7552
  } : {}));
7180
7553
  }
7554
+ const decorators = [];
7555
+ for (const decorator of node.decorators) {
7556
+ decorators.push(Object.assign({
7557
+ id: decorator.id,
7558
+ coords: roundPoint(decorator.coords),
7559
+ width: decorator.width,
7560
+ height: decorator.height,
7561
+ priority: decorator.priority,
7562
+ svg: decorator.svg,
7563
+ anchorPoints: [decorator.anchorPointX, decorator.anchorPointY]
7564
+ }, includeCollabMeta ? {
7565
+ collabMeta: {
7566
+ removed: decorator.removed,
7567
+ selfRemoved: decorator.selfRemoved
7568
+ }
7569
+ } : {}));
7570
+ }
7181
7571
  return Object.assign({
7182
7572
  id: node.id,
7183
7573
  type: node.type.id,
7184
7574
  children,
7185
7575
  sections,
7186
7576
  ports,
7577
+ decorators,
7187
7578
  label: ((_f = node.label) === null || _f === void 0 ? void 0 : _f.text) || '',
7188
7579
  coords: roundPoint(node.coords),
7189
7580
  width: node.width,
@@ -7497,11 +7888,6 @@ class DiagramUserSelection extends DiagramElementSet {
7497
7888
  * @private
7498
7889
  */
7499
7890
  const CONNECTION_PATH_BOX_THICKNESS = 12;
7500
- /**
7501
- * Thickness of the resizer line used to resize nodes and sections on drag, in diagram units.
7502
- * @private
7503
- */
7504
- const RESIZER_THICKNESS = 6;
7505
7891
  /**
7506
7892
  * Maximum number of user actions that can be recorded in the user action stack.
7507
7893
  * @private
@@ -7526,8 +7912,9 @@ class DiagramCanvas {
7526
7912
  * @param config The configuration object used to set the parameters of this canvas.
7527
7913
  */
7528
7914
  constructor(parentComponent, config) {
7529
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
7530
- this.backgroundPatternId = `daga-background-pattern-id-${DiagramCanvas.canvasCount++}`;
7915
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
7916
+ this.gridPatternId = `daga-grid-pattern-id-${++DiagramCanvas.canvasCount}`;
7917
+ this.ancillaryGridPatternIds = [];
7531
7918
  this.zoomTransform = d3__namespace.zoomIdentity;
7532
7919
  // used to distinguish drags from clicks when dragging elements and during multiple selection
7533
7920
  this.draggingFrom = [0, 0];
@@ -7544,23 +7931,25 @@ class DiagramCanvas {
7544
7931
  this.userSelection = new DiagramUserSelection(this, (_b = (_a = config.components) === null || _a === void 0 ? void 0 : _a.propertyEditor) === null || _b === void 0 ? void 0 : _b.title);
7545
7932
  this.userHighlight = new DiagramUserHighlight(this, ((_c = config.canvas) === null || _c === void 0 ? void 0 : _c.highlightSections) !== false);
7546
7933
  this.contextMenu = new DiagramContextMenu(this, (_d = config.canvas) === null || _d === void 0 ? void 0 : _d.contextMenu);
7547
- this.backgroundColor = ((_e = config.canvas) === null || _e === void 0 ? void 0 : _e.backgroundColor) || '#FFFFFF';
7548
- this.gridStyle = (_h = (_g = (_f = config.canvas) === null || _f === void 0 ? void 0 : _f.grid) === null || _g === void 0 ? void 0 : _g.style) !== null && _h !== void 0 ? _h : GRID_DEFAULTS.style;
7549
- this.gridSize = ((_k = (_j = config.canvas) === null || _j === void 0 ? void 0 : _j.grid) === null || _k === void 0 ? void 0 : _k.enabled) === false || ((_l = config.canvas) === null || _l === void 0 ? void 0 : _l.grid) === undefined ? 0 : Math.abs(((_o = (_m = config.canvas) === null || _m === void 0 ? void 0 : _m.grid) === null || _o === void 0 ? void 0 : _o.spacing) || GRID_DEFAULTS.spacing);
7550
- this.gridThickness = Math.abs(((_q = (_p = config.canvas) === null || _p === void 0 ? void 0 : _p.grid) === null || _q === void 0 ? void 0 : _q.thickness) || GRID_DEFAULTS.thickness);
7551
- this.gridColor = ((_s = (_r = config.canvas) === null || _r === void 0 ? void 0 : _r.grid) === null || _s === void 0 ? void 0 : _s.color) || GRID_DEFAULTS.color;
7552
- this.snapToGrid = ((_u = (_t = config.canvas) === null || _t === void 0 ? void 0 : _t.grid) === null || _u === void 0 ? void 0 : _u.enabled) === false || ((_v = config.canvas) === null || _v === void 0 ? void 0 : _v.grid) === undefined ? false : ((_x = (_w = config.canvas) === null || _w === void 0 ? void 0 : _w.grid) === null || _x === void 0 ? void 0 : _x.snap) || GRID_DEFAULTS.snap;
7553
- this.zoomFactor = ((_y = config.canvas) === null || _y === void 0 ? void 0 : _y.zoomFactor) || 2;
7554
- this.panRate = ((_z = config.canvas) === null || _z === void 0 ? void 0 : _z.panRate) || 100;
7555
- this.inferConnectionType = ((_0 = config.connectionSettings) === null || _0 === void 0 ? void 0 : _0.inferConnectionType) || false;
7556
- this.autoTightenConnections = ((_1 = config.connectionSettings) === null || _1 === void 0 ? void 0 : _1.autoTighten) !== false;
7557
- this.tightenConnectionsAcrossPortTypes = ((_2 = config.connectionSettings) === null || _2 === void 0 ? void 0 : _2.tightenAcrossPortTypes) || false;
7558
- this.allowConnectionLoops = ((_3 = config.connectionSettings) === null || _3 === void 0 ? void 0 : _3.allowLoops) || false;
7559
- this.allowSharingPorts = ((_4 = config.connectionSettings) === null || _4 === void 0 ? void 0 : _4.sharePorts) !== false;
7560
- this.allowSharingBothPorts = ((_5 = config.connectionSettings) === null || _5 === void 0 ? void 0 : _5.shareBothPorts) || false;
7561
- this.portHighlightRadius = ((_6 = config.connectionSettings) === null || _6 === void 0 ? void 0 : _6.portHighlightRadius) || 100;
7934
+ // TODO
7935
+ this.backgroundConfig = (_f = (_e = config.canvas) === null || _e === void 0 ? void 0 : _e.background) !== null && _f !== void 0 ? _f : BACKGROUND_DEFAULTS;
7936
+ this.gridConfig = applyGridDefaults((_g = config.canvas) === null || _g === void 0 ? void 0 : _g.grid);
7937
+ this.ancillaryGridsConfig = [];
7938
+ for (let i = 0; i < (((_j = (_h = config.canvas) === null || _h === void 0 ? void 0 : _h.ancillaryGrids) === null || _j === void 0 ? void 0 : _j.length) || 0); ++i) {
7939
+ this.ancillaryGridsConfig.push(applyGridDefaults((_l = (_k = config.canvas) === null || _k === void 0 ? void 0 : _k.ancillaryGrids) === null || _l === void 0 ? void 0 : _l[i]));
7940
+ this.ancillaryGridPatternIds.push(`${this.gridPatternId}-ancillary-${i}`);
7941
+ }
7942
+ this.zoomFactor = ((_m = config.canvas) === null || _m === void 0 ? void 0 : _m.zoomFactor) || 2;
7943
+ this.panRate = ((_o = config.canvas) === null || _o === void 0 ? void 0 : _o.panRate) || 100;
7944
+ this.inferConnectionType = ((_p = config.connectionSettings) === null || _p === void 0 ? void 0 : _p.inferConnectionType) || false;
7945
+ this.autoTightenConnections = ((_q = config.connectionSettings) === null || _q === void 0 ? void 0 : _q.autoTighten) !== false;
7946
+ this.tightenConnectionsAcrossPortTypes = ((_r = config.connectionSettings) === null || _r === void 0 ? void 0 : _r.tightenAcrossPortTypes) || false;
7947
+ this.allowConnectionLoops = ((_s = config.connectionSettings) === null || _s === void 0 ? void 0 : _s.allowLoops) || false;
7948
+ this.allowSharingPorts = ((_t = config.connectionSettings) === null || _t === void 0 ? void 0 : _t.sharePorts) !== false;
7949
+ this.allowSharingBothPorts = ((_u = config.connectionSettings) === null || _u === void 0 ? void 0 : _u.shareBothPorts) || false;
7950
+ this.portHighlightRadius = ((_v = config.connectionSettings) === null || _v === void 0 ? void 0 : _v.portHighlightRadius) || 100;
7562
7951
  this.multipleSelectionOn = false;
7563
- this.priorityThresholds = ((_7 = config.canvas) === null || _7 === void 0 ? void 0 : _7.priorityThresholds) || [];
7952
+ this.priorityThresholds = ((_w = config.canvas) === null || _w === void 0 ? void 0 : _w.priorityThresholds) || [];
7564
7953
  this.priorityThreshold = this.priorityThresholds ? this.priorityThresholds[0] : undefined;
7565
7954
  this.layoutFormat = config.layoutFormat;
7566
7955
  this.userActions = config.userActions || {};
@@ -7587,7 +7976,7 @@ class DiagramCanvas {
7587
7976
  const connectionType = new DiagramConnectionType(Object.assign(Object.assign({}, config.connectionTypeDefaults), connectionTypeConfig));
7588
7977
  this.model.connections.types.add(connectionType);
7589
7978
  }
7590
- this._connectionType = ((_8 = config === null || config === void 0 ? void 0 : config.connectionSettings) === null || _8 === void 0 ? void 0 : _8.defaultConnection) !== undefined ? this.model.connections.types.get(config.connectionSettings.defaultConnection) : undefined;
7979
+ this._connectionType = ((_x = config === null || config === void 0 ? void 0 : config.connectionSettings) === null || _x === void 0 ? void 0 : _x.defaultConnection) !== undefined ? this.model.connections.types.get(config.connectionSettings.defaultConnection) : undefined;
7591
7980
  }
7592
7981
  }
7593
7982
  addValidator(validator) {
@@ -7619,13 +8008,13 @@ class DiagramCanvas {
7619
8008
  // remove all children
7620
8009
  appendToSelection.html('');
7621
8010
  this.diagramRoot = appendToSelection.append('div').node();
7622
- d3__namespace.select(this.diagramRoot).attr('tabindex', 0) // make element focusable
8011
+ this.selectRoot().attr('tabindex', 0) // make element focusable
7623
8012
  .style('width', '100%').style('height', '100%').append('svg').style('width', '100%').style('height', '100%');
7624
- d3__namespace.select(this.diagramRoot).on(exports.Events.Click, () => {
8013
+ this.selectRoot().on(exports.Events.Click, () => {
7625
8014
  var _a;
7626
8015
  // focus on the diagram when clicking so that we can focus on the diagram
7627
8016
  // keyboard events only work if we're focusing on the diagram
7628
- (_a = d3__namespace.select(this.diagramRoot).node()) === null || _a === void 0 ? void 0 : _a.focus();
8017
+ (_a = this.selectRoot().node()) === null || _a === void 0 ? void 0 : _a.focus();
7629
8018
  }).on(exports.Events.ContextMenu, event => {
7630
8019
  if (this.dragging) {
7631
8020
  event.preventDefault();
@@ -7789,44 +8178,57 @@ class DiagramCanvas {
7789
8178
  this.zoomTransform = event.transform;
7790
8179
  const transformAttribute = event.transform.toString();
7791
8180
  this.selectCanvasElements().attr('transform', transformAttribute);
7792
- d3__namespace.select(`#${this.backgroundPatternId}`).attr('patternTransform', transformAttribute);
8181
+ for (const gridPatternId of [this.gridPatternId, ...this.ancillaryGridPatternIds]) {
8182
+ this.selectCanvasView().select(`#${gridPatternId}`).attr('patternTransform', transformAttribute);
8183
+ }
7793
8184
  this.contextMenu.close();
7794
8185
  this.diagramEvent$.next(new DiagramZoomEvent([this.zoomTransform.x, this.zoomTransform.y], this.zoomTransform.k));
7795
8186
  }).on(exports.ZoomEvents.End, () => {
7796
8187
  setCursorStyle();
7797
8188
  }));
7798
- canvasView.append('rect').attr('x', 0).attr('y', 0).attr('width', `100%`).attr('height', `100%`).attr('fill', this.backgroundColor).attr('stroke-width', '0').on(exports.Events.MouseMove, event => {
7799
- if (this.unfinishedConnection !== undefined) {
7800
- const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7801
- this.unfinishedConnection.endCoords = pointerCoords;
7802
- }
7803
- }).on(exports.Events.MouseOver, () => {
7804
- if (this.userHighlight.size() > 0) {
7805
- this.userHighlight.clear();
7806
- this.diagramEvent$.next(new DiagramHighlightedEvent(null));
7807
- }
7808
- }).on(exports.Events.Click, () => {
7809
- if (this.userHighlight.size() > 0) {
7810
- this.userHighlight.clear();
7811
- this.diagramEvent$.next(new DiagramHighlightedEvent(null));
7812
- }
7813
- this.contextMenu.close();
7814
- if (this.userSelection.size() > 0) {
7815
- const deselectedElements = this.userSelection.all();
7816
- this.userSelection.clear();
7817
- this.diagramEvent$.next(new DiagramSelectionEvent(deselectedElements, false));
7818
- }
7819
- this.userSelection.openInPropertyEditor(this.model);
7820
- }).call(d3__namespace.drag().filter(event => {
7821
- return this.multipleSelectionOn || isSecondaryButton(event);
7822
- }).on(exports.DragEvents.Start, event => {
7823
- this.startMultipleSelection(event);
7824
- }).on(exports.DragEvents.Drag, event => {
7825
- this.continueMultipleSelection(event);
7826
- }).on(exports.DragEvents.End, event => {
7827
- this.finishMultipleSelection(event);
7828
- }));
7829
- initializeGrid(this, canvasView, this.backgroundPatternId);
8189
+ const canvasDefs = canvasView.append('defs');
8190
+ const canvasBackground = [];
8191
+ canvasBackground.push(initializeBackground(canvasView, this.backgroundConfig).attr('class', 'daga-background'));
8192
+ for (let i = 0; i < this.ancillaryGridsConfig.length; ++i) {
8193
+ canvasBackground.push(initializeGrid(this, canvasView, canvasDefs, this.ancillaryGridPatternIds[i], this.ancillaryGridsConfig[i]));
8194
+ }
8195
+ canvasBackground.push(initializeGrid(this, canvasView, canvasDefs, this.gridPatternId, this.gridConfig));
8196
+ for (const canvasBackgroundElement of canvasBackground) {
8197
+ canvasBackgroundElement.on(exports.Events.MouseMove, event => {
8198
+ if (this.unfinishedConnection !== undefined) {
8199
+ const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8200
+ this.unfinishedConnection.endCoords = pointerCoords;
8201
+ }
8202
+ });
8203
+ canvasBackgroundElement.on(exports.Events.MouseOver, () => {
8204
+ if (this.userHighlight.size() > 0) {
8205
+ this.userHighlight.clear();
8206
+ this.diagramEvent$.next(new DiagramHighlightedEvent(null));
8207
+ }
8208
+ });
8209
+ canvasBackgroundElement.on(exports.Events.Click, () => {
8210
+ if (this.userHighlight.size() > 0) {
8211
+ this.userHighlight.clear();
8212
+ this.diagramEvent$.next(new DiagramHighlightedEvent(null));
8213
+ }
8214
+ this.contextMenu.close();
8215
+ if (this.userSelection.size() > 0) {
8216
+ const deselectedElements = this.userSelection.all();
8217
+ this.userSelection.clear();
8218
+ this.diagramEvent$.next(new DiagramSelectionEvent(deselectedElements, false));
8219
+ }
8220
+ this.userSelection.openInPropertyEditor(this.model);
8221
+ });
8222
+ canvasBackgroundElement.call(d3__namespace.drag().filter(event => {
8223
+ return this.multipleSelectionOn || isSecondaryButton(event);
8224
+ }).on(exports.DragEvents.Start, event => {
8225
+ this.startMultipleSelection(event);
8226
+ }).on(exports.DragEvents.Drag, event => {
8227
+ this.continueMultipleSelection(event);
8228
+ }).on(exports.DragEvents.End, event => {
8229
+ this.finishMultipleSelection(event);
8230
+ }));
8231
+ }
7830
8232
  canvasView.append('g').attr('class', 'daga-canvas-elements');
7831
8233
  }
7832
8234
  getZoomLevel() {
@@ -7844,7 +8246,7 @@ class DiagramCanvas {
7844
8246
  }
7845
8247
  getViewCoordinates() {
7846
8248
  var _a, _b, _c;
7847
- 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();
8249
+ 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();
7848
8250
  /*
7849
8251
  transform the coordinates of the zoomTransform to the coordinates
7850
8252
  needed to point the zoomTransfrom to the center of the screen to
@@ -7896,7 +8298,11 @@ class DiagramCanvas {
7896
8298
  var _a;
7897
8299
  // if there are no nodes, we have nothing to do here
7898
8300
  if (this.model.nodes.length > 0) {
7899
- const canvasViewBoundingBox = (_a = this.selectCanvasView().select('rect').node()) === null || _a === void 0 ? void 0 : _a.getBBox();
8301
+ const canvasViewBoundingBox = (_a = this.selectCanvasView().select('.daga-background').node()) === null || _a === void 0 ? void 0 : _a.getBBox();
8302
+ if (!canvasViewBoundingBox.width || !canvasViewBoundingBox.height) {
8303
+ // prevent errors if the width or height is invalid
8304
+ return;
8305
+ }
7900
8306
  const nonRemovedNodes = (nodeIds === null || nodeIds === void 0 ? void 0 : nodeIds.map(i => this.model.nodes.get(i)).filter(n => !!n)) || this.model.nodes.all();
7901
8307
  const minimumX = Math.min(...nonRemovedNodes.map(n => n.coords[0]));
7902
8308
  const maximumX = Math.max(...nonRemovedNodes.map(n => n.coords[0] + n.width));
@@ -7921,10 +8327,17 @@ class DiagramCanvas {
7921
8327
  }
7922
8328
  }
7923
8329
  getClosestGridPoint(point) {
7924
- if (this.gridSize === 0 || !isFinite(this.gridSize)) {
7925
- return point;
8330
+ let pointX = point[0];
8331
+ const spacingX = getGridSpacingX(this.gridConfig);
8332
+ if (spacingX !== 0) {
8333
+ pointX = Math.round(pointX / spacingX) * spacingX;
8334
+ }
8335
+ let pointY = point[1];
8336
+ const spacingY = getGridSpacingY(this.gridConfig);
8337
+ if (spacingY !== 0) {
8338
+ pointY = Math.round(pointY / spacingY) * spacingY;
7926
8339
  }
7927
- return [Math.round(point[0] / this.gridSize) * this.gridSize, Math.round(point[1] / this.gridSize) * this.gridSize];
8340
+ return [pointX, pointY];
7928
8341
  }
7929
8342
  getCoordinatesOnScreen() {
7930
8343
  var _a;
@@ -7973,7 +8386,7 @@ class DiagramCanvas {
7973
8386
  updateNodesInView(...ids) {
7974
8387
  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);
7975
8388
  const exitSelection = updateSelection.exit();
7976
- 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}`);
8389
+ 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}`);
7977
8390
  if (ids && ids.length > 0) {
7978
8391
  updateSelection = updateSelection.filter(d => ids.includes(d.id));
7979
8392
  }
@@ -8009,62 +8422,208 @@ class DiagramCanvas {
8009
8422
  this.diagramEvent$.next(new DiagramSelectionEvent([d], true));
8010
8423
  this.contextMenu.open(event);
8011
8424
  }
8012
- }).on(exports.Events.DoubleClick, (event, d) => {
8013
- const diagramEvent = new DiagramDoubleClickEvent(event, d);
8014
- this.diagramEvent$.next(diagramEvent);
8015
- }).call(d3__namespace.drag().filter(event => {
8016
- this.secondaryButton = isSecondaryButton(event);
8017
- return true;
8018
- }).on(exports.DragEvents.Start, (event, d) => {
8019
- if (this.multipleSelectionOn || this.secondaryButton) {
8020
- this.startMultipleSelection(event);
8425
+ }).on(exports.Events.DoubleClick, (event, d) => {
8426
+ const diagramEvent = new DiagramDoubleClickEvent(event, d);
8427
+ this.diagramEvent$.next(diagramEvent);
8428
+ }).call(d3__namespace.drag().filter(event => {
8429
+ this.secondaryButton = isSecondaryButton(event);
8430
+ return true;
8431
+ }).on(exports.DragEvents.Start, (event, d) => {
8432
+ if (this.multipleSelectionOn || this.secondaryButton) {
8433
+ this.startMultipleSelection(event);
8434
+ } else {
8435
+ this.startMovingNode(event, d);
8436
+ }
8437
+ }).on(exports.DragEvents.Drag, (event, d) => {
8438
+ if (this.multipleSelectionOn || this.secondaryButton) {
8439
+ this.continueMultipleSelection(event);
8440
+ } else {
8441
+ this.continueMovingNode(event, d);
8442
+ }
8443
+ }).on(exports.DragEvents.End, (event, d) => {
8444
+ if (this.multipleSelectionOn || this.secondaryButton) {
8445
+ this.finishMultipleSelection(event);
8446
+ } else {
8447
+ this.finishMovingNode(event, d);
8448
+ }
8449
+ this.secondaryButton = false;
8450
+ }));
8451
+ initializeLook(enterSelection);
8452
+ enterSelection.filter('.resizable-x').append('rect').attr('class', 'left-resizer').on(exports.Events.MouseOver, (_event, d) => {
8453
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8454
+ setCursorStyle(exports.CursorStyle.EWResize);
8455
+ }
8456
+ }).on(exports.Events.MouseOut, (_event, d) => {
8457
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8458
+ setCursorStyle();
8459
+ }
8460
+ }).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
8461
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8462
+ setCursorStyle(exports.CursorStyle.EWResize);
8463
+ this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
8464
+ } else {
8465
+ setCursorStyle(exports.CursorStyle.NotAllowed);
8466
+ }
8467
+ }).on(exports.DragEvents.Drag, (event, d) => {
8468
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8469
+ const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8470
+ d.stretch(exports.Side.Left, d.coords[0] - pointerCoords[0]);
8471
+ }
8472
+ }).on(exports.DragEvents.End, (event, d) => {
8473
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchNode) {
8474
+ let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8475
+ if (this.gridConfig.snap) {
8476
+ pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
8477
+ pointerCoords[0] += d.type.snapToGridOffset[0];
8478
+ pointerCoords[1] += d.type.snapToGridOffset[1];
8479
+ }
8480
+ d.stretch(exports.Side.Left, d.coords[0] - pointerCoords[0]);
8481
+ this.currentAction.to = d.getGeometry();
8482
+ this.currentAction.do();
8483
+ this.actionStack.add(this.currentAction);
8484
+ this.currentAction = undefined;
8485
+ }
8486
+ setCursorStyle();
8487
+ }));
8488
+ enterSelection.filter('.resizable-x').append('rect').attr('class', 'right-resizer').on(exports.Events.MouseOver, (_event, d) => {
8489
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8490
+ setCursorStyle(exports.CursorStyle.EWResize);
8491
+ }
8492
+ }).on(exports.Events.MouseOut, (_event, d) => {
8493
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8494
+ setCursorStyle();
8495
+ }
8496
+ }).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
8497
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8498
+ setCursorStyle(exports.CursorStyle.EWResize);
8499
+ this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
8500
+ } else {
8501
+ setCursorStyle(exports.CursorStyle.NotAllowed);
8502
+ }
8503
+ }).on(exports.DragEvents.Drag, (event, d) => {
8504
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8505
+ const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8506
+ d.stretch(exports.Side.Right, pointerCoords[0] - (d.coords[0] + d.width));
8507
+ }
8508
+ }).on(exports.DragEvents.End, (event, d) => {
8509
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchNode) {
8510
+ let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8511
+ if (this.gridConfig.snap) {
8512
+ pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[2], pointerCoords[1] - d.type.snapToGridOffset[3]]);
8513
+ pointerCoords[0] += d.type.snapToGridOffset[2];
8514
+ pointerCoords[1] += d.type.snapToGridOffset[3];
8515
+ }
8516
+ d.stretch(exports.Side.Right, pointerCoords[0] - (d.coords[0] + d.width));
8517
+ this.currentAction.to = d.getGeometry();
8518
+ this.currentAction.do();
8519
+ this.actionStack.add(this.currentAction);
8520
+ this.currentAction = undefined;
8521
+ }
8522
+ setCursorStyle();
8523
+ }));
8524
+ enterSelection.filter('.resizable-y').append('rect').attr('class', 'top-resizer').on(exports.Events.MouseOver, (_event, d) => {
8525
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8526
+ setCursorStyle(exports.CursorStyle.NSResize);
8527
+ }
8528
+ }).on(exports.Events.MouseOut, (_event, d) => {
8529
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8530
+ setCursorStyle();
8531
+ }
8532
+ }).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
8533
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8534
+ setCursorStyle(exports.CursorStyle.NSResize);
8535
+ this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
8536
+ } else {
8537
+ setCursorStyle(exports.CursorStyle.NotAllowed);
8538
+ }
8539
+ }).on(exports.DragEvents.Drag, (event, d) => {
8540
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8541
+ const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8542
+ d.stretch(exports.Side.Top, d.coords[1] - pointerCoords[1]);
8543
+ }
8544
+ }).on(exports.DragEvents.End, (event, d) => {
8545
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchNode) {
8546
+ let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8547
+ if (this.gridConfig.snap) {
8548
+ pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
8549
+ pointerCoords[0] += d.type.snapToGridOffset[0];
8550
+ pointerCoords[1] += d.type.snapToGridOffset[1];
8551
+ }
8552
+ d.stretch(exports.Side.Top, d.coords[1] - pointerCoords[1]);
8553
+ this.currentAction.to = d.getGeometry();
8554
+ this.currentAction.do();
8555
+ this.actionStack.add(this.currentAction);
8556
+ this.currentAction = undefined;
8557
+ }
8558
+ setCursorStyle();
8559
+ }));
8560
+ enterSelection.filter('.resizable-y').append('rect').attr('class', 'bottom-resizer').on(exports.Events.MouseOver, (_event, d) => {
8561
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8562
+ setCursorStyle(exports.CursorStyle.NSResize);
8563
+ }
8564
+ }).on(exports.Events.MouseOut, (_event, d) => {
8565
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8566
+ setCursorStyle();
8567
+ }
8568
+ }).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
8569
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8570
+ setCursorStyle(exports.CursorStyle.NSResize);
8571
+ this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
8021
8572
  } else {
8022
- this.startMovingNode(event, d);
8573
+ setCursorStyle(exports.CursorStyle.NotAllowed);
8023
8574
  }
8024
8575
  }).on(exports.DragEvents.Drag, (event, d) => {
8025
- if (this.multipleSelectionOn || this.secondaryButton) {
8026
- this.continueMultipleSelection(event);
8027
- } else {
8028
- this.continueMovingNode(event, d);
8576
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8577
+ const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8578
+ d.stretch(exports.Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height));
8029
8579
  }
8030
8580
  }).on(exports.DragEvents.End, (event, d) => {
8031
- if (this.multipleSelectionOn || this.secondaryButton) {
8032
- this.finishMultipleSelection(event);
8033
- } else {
8034
- this.finishMovingNode(event, d);
8581
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchNode) {
8582
+ let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8583
+ if (this.gridConfig.snap) {
8584
+ pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[2], pointerCoords[1] - d.type.snapToGridOffset[3]]);
8585
+ pointerCoords[0] += d.type.snapToGridOffset[2];
8586
+ pointerCoords[1] += d.type.snapToGridOffset[3];
8587
+ }
8588
+ d.stretch(exports.Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height));
8589
+ this.currentAction.to = d.getGeometry();
8590
+ this.currentAction.do();
8591
+ this.actionStack.add(this.currentAction);
8592
+ this.currentAction = undefined;
8035
8593
  }
8036
- this.secondaryButton = false;
8594
+ setCursorStyle();
8037
8595
  }));
8038
- initializeLook(enterSelection);
8039
- enterSelection.filter('.resizable-x').append('line').attr('class', 'left-resizer').attr('stroke', 'transparent').attr('stroke-width', RESIZER_THICKNESS).on(exports.Events.MouseOver, (_event, d) => {
8040
- if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8041
- setCursorStyle(exports.CursorStyle.EWResize);
8596
+ enterSelection.filter('.resizable-xy').append('rect').attr('class', 'top-left-resizer').on(exports.Events.MouseOver, (_event, d) => {
8597
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8598
+ setCursorStyle(exports.CursorStyle.NWSEResize);
8042
8599
  }
8043
8600
  }).on(exports.Events.MouseOut, (_event, d) => {
8044
- if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8601
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8045
8602
  setCursorStyle();
8046
8603
  }
8047
8604
  }).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
8048
- if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8049
- setCursorStyle(exports.CursorStyle.EWResize);
8605
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8606
+ setCursorStyle(exports.CursorStyle.NWSEResize);
8050
8607
  this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
8051
8608
  } else {
8052
8609
  setCursorStyle(exports.CursorStyle.NotAllowed);
8053
8610
  }
8054
8611
  }).on(exports.DragEvents.Drag, (event, d) => {
8055
- if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8612
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8056
8613
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8057
8614
  d.stretch(exports.Side.Left, d.coords[0] - pointerCoords[0]);
8615
+ d.stretch(exports.Side.Top, d.coords[1] - pointerCoords[1]);
8058
8616
  }
8059
8617
  }).on(exports.DragEvents.End, (event, d) => {
8060
- if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchNode) {
8618
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableXY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchNode) {
8061
8619
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8062
- if (this.snapToGrid) {
8620
+ if (this.gridConfig.snap) {
8063
8621
  pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
8064
8622
  pointerCoords[0] += d.type.snapToGridOffset[0];
8065
8623
  pointerCoords[1] += d.type.snapToGridOffset[1];
8066
8624
  }
8067
8625
  d.stretch(exports.Side.Left, d.coords[0] - pointerCoords[0]);
8626
+ d.stretch(exports.Side.Top, d.coords[1] - pointerCoords[1]);
8068
8627
  this.currentAction.to = d.getGeometry();
8069
8628
  this.currentAction.do();
8070
8629
  this.actionStack.add(this.currentAction);
@@ -8072,34 +8631,36 @@ class DiagramCanvas {
8072
8631
  }
8073
8632
  setCursorStyle();
8074
8633
  }));
8075
- enterSelection.filter('.resizable-y').append('line').attr('class', 'top-resizer').attr('stroke', 'transparent').attr('stroke-width', RESIZER_THICKNESS).on(exports.Events.MouseOver, (_event, d) => {
8076
- if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8077
- setCursorStyle(exports.CursorStyle.NSResize);
8634
+ enterSelection.filter('.resizable-xy').append('rect').attr('class', 'top-right-resizer').on(exports.Events.MouseOver, (_event, d) => {
8635
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8636
+ setCursorStyle(exports.CursorStyle.NESWResize);
8078
8637
  }
8079
8638
  }).on(exports.Events.MouseOut, (_event, d) => {
8080
- if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8639
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8081
8640
  setCursorStyle();
8082
8641
  }
8083
8642
  }).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
8084
- if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8085
- setCursorStyle(exports.CursorStyle.NSResize);
8643
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8644
+ setCursorStyle(exports.CursorStyle.NESWResize);
8086
8645
  this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
8087
8646
  } else {
8088
8647
  setCursorStyle(exports.CursorStyle.NotAllowed);
8089
8648
  }
8090
8649
  }).on(exports.DragEvents.Drag, (event, d) => {
8091
- if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8650
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8092
8651
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8652
+ d.stretch(exports.Side.Right, pointerCoords[0] - (d.coords[0] + d.width));
8093
8653
  d.stretch(exports.Side.Top, d.coords[1] - pointerCoords[1]);
8094
8654
  }
8095
8655
  }).on(exports.DragEvents.End, (event, d) => {
8096
- if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchNode) {
8656
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableXY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchNode) {
8097
8657
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8098
- if (this.snapToGrid) {
8658
+ if (this.gridConfig.snap) {
8099
8659
  pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
8100
8660
  pointerCoords[0] += d.type.snapToGridOffset[0];
8101
8661
  pointerCoords[1] += d.type.snapToGridOffset[1];
8102
8662
  }
8663
+ d.stretch(exports.Side.Right, pointerCoords[0] - (d.coords[0] + d.width));
8103
8664
  d.stretch(exports.Side.Top, d.coords[1] - pointerCoords[1]);
8104
8665
  this.currentAction.to = d.getGeometry();
8105
8666
  this.currentAction.do();
@@ -8108,35 +8669,37 @@ class DiagramCanvas {
8108
8669
  }
8109
8670
  setCursorStyle();
8110
8671
  }));
8111
- enterSelection.filter('.resizable-x').append('line').attr('class', 'right-resizer').attr('stroke', 'transparent').attr('stroke-width', RESIZER_THICKNESS).on(exports.Events.MouseOver, (_event, d) => {
8112
- if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8113
- setCursorStyle(exports.CursorStyle.EWResize);
8672
+ enterSelection.filter('.resizable-xy').append('rect').attr('class', 'bottom-left-resizer').on(exports.Events.MouseOver, (_event, d) => {
8673
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8674
+ setCursorStyle(exports.CursorStyle.NESWResize);
8114
8675
  }
8115
8676
  }).on(exports.Events.MouseOut, (_event, d) => {
8116
- if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8677
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8117
8678
  setCursorStyle();
8118
8679
  }
8119
8680
  }).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
8120
- if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8121
- setCursorStyle(exports.CursorStyle.EWResize);
8681
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8682
+ setCursorStyle(exports.CursorStyle.NESWResize);
8122
8683
  this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
8123
8684
  } else {
8124
8685
  setCursorStyle(exports.CursorStyle.NotAllowed);
8125
8686
  }
8126
8687
  }).on(exports.DragEvents.Drag, (event, d) => {
8127
- if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8688
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8128
8689
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8129
- d.stretch(exports.Side.Right, pointerCoords[0] - (d.coords[0] + d.width));
8690
+ d.stretch(exports.Side.Left, d.coords[0] - pointerCoords[0]);
8691
+ d.stretch(exports.Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height));
8130
8692
  }
8131
8693
  }).on(exports.DragEvents.End, (event, d) => {
8132
- if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchNode) {
8694
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableXY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchNode) {
8133
8695
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8134
- if (this.snapToGrid) {
8135
- pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[2], pointerCoords[1] - d.type.snapToGridOffset[3]]);
8136
- pointerCoords[0] += d.type.snapToGridOffset[2];
8137
- pointerCoords[1] += d.type.snapToGridOffset[3];
8696
+ if (this.gridConfig.snap) {
8697
+ pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
8698
+ pointerCoords[0] += d.type.snapToGridOffset[0];
8699
+ pointerCoords[1] += d.type.snapToGridOffset[1];
8138
8700
  }
8139
- d.stretch(exports.Side.Right, pointerCoords[0] - (d.coords[0] + d.width));
8701
+ d.stretch(exports.Side.Left, d.coords[0] - pointerCoords[0]);
8702
+ d.stretch(exports.Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height));
8140
8703
  this.currentAction.to = d.getGeometry();
8141
8704
  this.currentAction.do();
8142
8705
  this.actionStack.add(this.currentAction);
@@ -8144,36 +8707,36 @@ class DiagramCanvas {
8144
8707
  }
8145
8708
  setCursorStyle();
8146
8709
  }));
8147
- enterSelection.filter('.resizable-y').append('line').attr('class', 'bottom-resizer').attr('stroke', 'transparent').attr('stroke-width', RESIZER_THICKNESS).on(exports.Events.MouseOver, (_event, d) => {
8148
- if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8149
- setCursorStyle(exports.CursorStyle.NSResize);
8710
+ enterSelection.filter('.resizable-xy').append('rect').attr('class', 'bottom-right-resizer').on(exports.Events.MouseOver, (_event, d) => {
8711
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8712
+ setCursorStyle(exports.CursorStyle.NWSEResize);
8150
8713
  }
8151
8714
  }).on(exports.Events.MouseOut, (_event, d) => {
8152
- if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8715
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8153
8716
  setCursorStyle();
8154
8717
  }
8155
8718
  }).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
8156
- if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8157
- setCursorStyle(exports.CursorStyle.NSResize);
8719
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8720
+ setCursorStyle(exports.CursorStyle.NWSEResize);
8158
8721
  this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
8159
8722
  } else {
8160
8723
  setCursorStyle(exports.CursorStyle.NotAllowed);
8161
8724
  }
8162
8725
  }).on(exports.DragEvents.Drag, (event, d) => {
8163
- if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8726
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8164
8727
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8728
+ d.stretch(exports.Side.Right, pointerCoords[0] - (d.coords[0] + d.width));
8165
8729
  d.stretch(exports.Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height));
8166
8730
  }
8167
8731
  }).on(exports.DragEvents.End, (event, d) => {
8168
- if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchNode) {
8732
+ if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableXY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchNode) {
8169
8733
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8170
- if (this.snapToGrid) {
8171
- if (this.snapToGrid) {
8172
- pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[2], pointerCoords[1] - d.type.snapToGridOffset[3]]);
8173
- pointerCoords[0] += d.type.snapToGridOffset[2];
8174
- pointerCoords[1] += d.type.snapToGridOffset[3];
8175
- }
8734
+ if (this.gridConfig.snap) {
8735
+ pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
8736
+ pointerCoords[0] += d.type.snapToGridOffset[0];
8737
+ pointerCoords[1] += d.type.snapToGridOffset[1];
8176
8738
  }
8739
+ d.stretch(exports.Side.Right, pointerCoords[0] - (d.coords[0] + d.width));
8177
8740
  d.stretch(exports.Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height));
8178
8741
  this.currentAction.to = d.getGeometry();
8179
8742
  this.currentAction.do();
@@ -8184,17 +8747,21 @@ class DiagramCanvas {
8184
8747
  }));
8185
8748
  mergeSelection.attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).attr('opacity', d => d.removed ? 0.5 : 1);
8186
8749
  updateLook(mergeSelection);
8187
- 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);
8188
- 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);
8189
- 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);
8190
- 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);
8750
+ 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);
8751
+ 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);
8752
+ 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);
8753
+ 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);
8754
+ 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);
8755
+ 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);
8756
+ 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);
8757
+ 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);
8191
8758
  }
8192
8759
  updateSectionsInView(...ids) {
8193
8760
  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);
8194
8761
  const exitSelection = updateSelection.exit();
8195
8762
  const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', d => {
8196
8763
  var _a;
8197
- return `diagram-section${needsResizerX(d) ? ' resizable-x' : ''}${needsResizerY(d) ? ' resizable-y' : ''} ${(_a = d.look) === null || _a === void 0 ? void 0 : _a.lookType}`;
8764
+ 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}`;
8198
8765
  });
8199
8766
  if (ids && ids.length > 0) {
8200
8767
  updateSelection = updateSelection.filter(d => ids.includes(d.id));
@@ -8275,7 +8842,7 @@ class DiagramCanvas {
8275
8842
  this.secondaryButton = false;
8276
8843
  }));
8277
8844
  initializeLook(enterSelection);
8278
- enterSelection.filter('.resizable-x').append('line').attr('class', 'left-resizer').attr('stroke', 'transparent').attr('stroke-width', RESIZER_THICKNESS).on(exports.Events.MouseOver, (_event, d) => {
8845
+ enterSelection.filter('.resizable-x').append('rect').attr('class', 'left-resizer').on(exports.Events.MouseOver, (_event, d) => {
8279
8846
  if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
8280
8847
  setCursorStyle(exports.CursorStyle.EWResize);
8281
8848
  }
@@ -8298,7 +8865,7 @@ class DiagramCanvas {
8298
8865
  }).on(exports.DragEvents.End, (event, d) => {
8299
8866
  if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection && d.node) {
8300
8867
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8301
- if (this.snapToGrid) {
8868
+ if (this.gridConfig.snap) {
8302
8869
  pointerCoords = this.getClosestGridPoint(pointerCoords);
8303
8870
  }
8304
8871
  d.node.stretchSections(exports.Side.Left, d.coords[0] - pointerCoords[0], d.indexXInNode, d.indexYInNode);
@@ -8309,7 +8876,41 @@ class DiagramCanvas {
8309
8876
  }
8310
8877
  setCursorStyle();
8311
8878
  }));
8312
- enterSelection.filter('.resizable-y').append('line').attr('class', 'top-resizer').attr('stroke', 'transparent').attr('stroke-width', RESIZER_THICKNESS).on(exports.Events.MouseOver, (_event, d) => {
8879
+ enterSelection.filter('.resizable-x').append('rect').attr('class', 'right-resizer').on(exports.Events.MouseOver, (_event, d) => {
8880
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
8881
+ setCursorStyle(exports.CursorStyle.EWResize);
8882
+ }
8883
+ }).on(exports.Events.MouseOut, (_event, d) => {
8884
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
8885
+ setCursorStyle();
8886
+ }
8887
+ }).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
8888
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed && d.node) {
8889
+ setCursorStyle(exports.CursorStyle.EWResize);
8890
+ this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
8891
+ } else {
8892
+ setCursorStyle(exports.CursorStyle.NotAllowed);
8893
+ }
8894
+ }).on(exports.DragEvents.Drag, (event, d) => {
8895
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed && d.node) {
8896
+ const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8897
+ d.node.stretchSections(exports.Side.Right, pointerCoords[0] - (d.coords[0] + d.width), d.indexXInNode, d.indexYInNode);
8898
+ }
8899
+ }).on(exports.DragEvents.End, (event, d) => {
8900
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection && d.node) {
8901
+ let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8902
+ if (this.gridConfig.snap) {
8903
+ pointerCoords = this.getClosestGridPoint(pointerCoords);
8904
+ }
8905
+ d.node.stretchSections(exports.Side.Right, pointerCoords[0] - (d.coords[0] + d.width), d.indexXInNode, d.indexYInNode);
8906
+ this.currentAction.to = d.node.getGeometry();
8907
+ this.currentAction.do();
8908
+ this.actionStack.add(this.currentAction);
8909
+ this.currentAction = undefined;
8910
+ }
8911
+ setCursorStyle();
8912
+ }));
8913
+ enterSelection.filter('.resizable-y').append('rect').attr('class', 'top-resizer').on(exports.Events.MouseOver, (_event, d) => {
8313
8914
  if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
8314
8915
  setCursorStyle(exports.CursorStyle.NSResize);
8315
8916
  }
@@ -8332,7 +8933,7 @@ class DiagramCanvas {
8332
8933
  }).on(exports.DragEvents.End, (event, d) => {
8333
8934
  if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection && d.node) {
8334
8935
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8335
- if (this.snapToGrid) {
8936
+ if (this.gridConfig.snap) {
8336
8937
  pointerCoords = this.getClosestGridPoint(pointerCoords);
8337
8938
  }
8338
8939
  d.node.stretchSections(exports.Side.Top, d.coords[1] - pointerCoords[1], d.indexXInNode, d.indexYInNode);
@@ -8343,33 +8944,105 @@ class DiagramCanvas {
8343
8944
  }
8344
8945
  setCursorStyle();
8345
8946
  }));
8346
- enterSelection.filter('.resizable-x').append('line').attr('class', 'right-resizer').attr('stroke', 'transparent').attr('stroke-width', RESIZER_THICKNESS).on(exports.Events.MouseOver, (_event, d) => {
8347
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
8348
- setCursorStyle(exports.CursorStyle.EWResize);
8947
+ enterSelection.filter('.resizable-y').append('rect').attr('class', 'bottom-resizer').on(exports.Events.MouseOver, (_event, d) => {
8948
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
8949
+ setCursorStyle(exports.CursorStyle.NSResize);
8349
8950
  }
8350
8951
  }).on(exports.Events.MouseOut, (_event, d) => {
8351
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
8952
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
8352
8953
  setCursorStyle();
8353
8954
  }
8354
8955
  }).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
8355
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed && d.node) {
8356
- setCursorStyle(exports.CursorStyle.EWResize);
8956
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed && d.node) {
8957
+ setCursorStyle(exports.CursorStyle.NSResize);
8357
8958
  this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
8358
8959
  } else {
8359
8960
  setCursorStyle(exports.CursorStyle.NotAllowed);
8360
8961
  }
8361
8962
  }).on(exports.DragEvents.Drag, (event, d) => {
8362
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed && d.node) {
8963
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed && d.node) {
8964
+ const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8965
+ d.node.stretchSections(exports.Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height), d.indexXInNode, d.indexYInNode);
8966
+ }
8967
+ }).on(exports.DragEvents.End, (event, d) => {
8968
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection && d.node) {
8969
+ let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8970
+ if (this.gridConfig.snap) {
8971
+ pointerCoords = this.getClosestGridPoint(pointerCoords);
8972
+ }
8973
+ d.node.stretchSections(exports.Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height), d.indexXInNode, d.indexYInNode);
8974
+ this.currentAction.to = d.node.getGeometry();
8975
+ this.currentAction.do();
8976
+ this.actionStack.add(this.currentAction);
8977
+ this.currentAction = undefined;
8978
+ }
8979
+ setCursorStyle();
8980
+ }));
8981
+ enterSelection.filter('.resizable-xy').append('rect').attr('class', 'top-left-resizer').on(exports.Events.MouseOver, (_event, d) => {
8982
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableXY() && !d.removed) {
8983
+ setCursorStyle(exports.CursorStyle.NWSEResize);
8984
+ }
8985
+ }).on(exports.Events.MouseOut, (_event, d) => {
8986
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableXY() && !d.removed) {
8987
+ setCursorStyle();
8988
+ }
8989
+ }).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
8990
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && d.node) {
8991
+ setCursorStyle(exports.CursorStyle.NWSEResize);
8992
+ this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
8993
+ } else {
8994
+ setCursorStyle(exports.CursorStyle.NotAllowed);
8995
+ }
8996
+ }).on(exports.DragEvents.Drag, (event, d) => {
8997
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && d.node) {
8998
+ const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8999
+ d.node.stretchSections(exports.Side.Left, d.coords[0] - pointerCoords[0], d.indexXInNode, d.indexYInNode);
9000
+ d.node.stretchSections(exports.Side.Top, d.coords[1] - pointerCoords[1], d.indexXInNode, d.indexYInNode);
9001
+ }
9002
+ }).on(exports.DragEvents.End, (event, d) => {
9003
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection && d.node) {
9004
+ let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
9005
+ if (this.gridConfig.snap) {
9006
+ pointerCoords = this.getClosestGridPoint(pointerCoords);
9007
+ }
9008
+ d.node.stretchSections(exports.Side.Left, d.coords[0] - pointerCoords[0], d.indexXInNode, d.indexYInNode);
9009
+ d.node.stretchSections(exports.Side.Top, d.coords[1] - pointerCoords[1], d.indexXInNode, d.indexYInNode);
9010
+ this.currentAction.to = d.node.getGeometry();
9011
+ this.currentAction.do();
9012
+ this.actionStack.add(this.currentAction);
9013
+ this.currentAction = undefined;
9014
+ }
9015
+ setCursorStyle();
9016
+ }));
9017
+ enterSelection.filter('.resizable-xy').append('rect').attr('class', 'top-right-resizer').on(exports.Events.MouseOver, (_event, d) => {
9018
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableXY() && !d.removed) {
9019
+ setCursorStyle(exports.CursorStyle.NESWResize);
9020
+ }
9021
+ }).on(exports.Events.MouseOut, (_event, d) => {
9022
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableXY() && !d.removed) {
9023
+ setCursorStyle();
9024
+ }
9025
+ }).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
9026
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && d.node) {
9027
+ setCursorStyle(exports.CursorStyle.NESWResize);
9028
+ this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
9029
+ } else {
9030
+ setCursorStyle(exports.CursorStyle.NotAllowed);
9031
+ }
9032
+ }).on(exports.DragEvents.Drag, (event, d) => {
9033
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && d.node) {
8363
9034
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8364
9035
  d.node.stretchSections(exports.Side.Right, pointerCoords[0] - (d.coords[0] + d.width), d.indexXInNode, d.indexYInNode);
9036
+ d.node.stretchSections(exports.Side.Top, d.coords[1] - pointerCoords[1], d.indexXInNode, d.indexYInNode);
8365
9037
  }
8366
9038
  }).on(exports.DragEvents.End, (event, d) => {
8367
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection && d.node) {
9039
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection && d.node) {
8368
9040
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8369
- if (this.snapToGrid) {
9041
+ if (this.gridConfig.snap) {
8370
9042
  pointerCoords = this.getClosestGridPoint(pointerCoords);
8371
9043
  }
8372
9044
  d.node.stretchSections(exports.Side.Right, pointerCoords[0] - (d.coords[0] + d.width), d.indexXInNode, d.indexYInNode);
9045
+ d.node.stretchSections(exports.Side.Top, d.coords[1] - pointerCoords[1], d.indexXInNode, d.indexYInNode);
8373
9046
  this.currentAction.to = d.node.getGeometry();
8374
9047
  this.currentAction.do();
8375
9048
  this.actionStack.add(this.currentAction);
@@ -8377,32 +9050,70 @@ class DiagramCanvas {
8377
9050
  }
8378
9051
  setCursorStyle();
8379
9052
  }));
8380
- enterSelection.filter('.resizable-y').append('line').attr('class', 'bottom-resizer').attr('stroke', 'transparent').attr('stroke-width', RESIZER_THICKNESS).on(exports.Events.MouseOver, (_event, d) => {
8381
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
8382
- setCursorStyle(exports.CursorStyle.NSResize);
9053
+ enterSelection.filter('.resizable-xy').append('rect').attr('class', 'bottom-left-resizer').on(exports.Events.MouseOver, (_event, d) => {
9054
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableXY() && !d.removed) {
9055
+ setCursorStyle(exports.CursorStyle.NESWResize);
8383
9056
  }
8384
9057
  }).on(exports.Events.MouseOut, (_event, d) => {
8385
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
9058
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableXY() && !d.removed) {
8386
9059
  setCursorStyle();
8387
9060
  }
8388
9061
  }).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
8389
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed && d.node) {
8390
- setCursorStyle(exports.CursorStyle.NSResize);
9062
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && d.node) {
9063
+ setCursorStyle(exports.CursorStyle.NESWResize);
8391
9064
  this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
8392
9065
  } else {
8393
9066
  setCursorStyle(exports.CursorStyle.NotAllowed);
8394
9067
  }
8395
9068
  }).on(exports.DragEvents.Drag, (event, d) => {
8396
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed && d.node) {
9069
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && d.node) {
8397
9070
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
9071
+ d.node.stretchSections(exports.Side.Left, d.coords[0] - pointerCoords[0], d.indexXInNode, d.indexYInNode);
8398
9072
  d.node.stretchSections(exports.Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height), d.indexXInNode, d.indexYInNode);
8399
9073
  }
8400
9074
  }).on(exports.DragEvents.End, (event, d) => {
8401
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection && d.node) {
9075
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection && d.node) {
9076
+ let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
9077
+ if (this.gridConfig.snap) {
9078
+ pointerCoords = this.getClosestGridPoint(pointerCoords);
9079
+ }
9080
+ d.node.stretchSections(exports.Side.Left, d.coords[0] - pointerCoords[0], d.indexXInNode, d.indexYInNode);
9081
+ d.node.stretchSections(exports.Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height), d.indexXInNode, d.indexYInNode);
9082
+ this.currentAction.to = d.node.getGeometry();
9083
+ this.currentAction.do();
9084
+ this.actionStack.add(this.currentAction);
9085
+ this.currentAction = undefined;
9086
+ }
9087
+ setCursorStyle();
9088
+ }));
9089
+ enterSelection.filter('.resizable-xy').append('rect').attr('class', 'bottom-right-resizer').on(exports.Events.MouseOver, (_event, d) => {
9090
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableXY() && !d.removed) {
9091
+ setCursorStyle(exports.CursorStyle.NWSEResize);
9092
+ }
9093
+ }).on(exports.Events.MouseOut, (_event, d) => {
9094
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableXY() && !d.removed) {
9095
+ setCursorStyle();
9096
+ }
9097
+ }).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
9098
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && d.node) {
9099
+ setCursorStyle(exports.CursorStyle.NWSEResize);
9100
+ this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
9101
+ } else {
9102
+ setCursorStyle(exports.CursorStyle.NotAllowed);
9103
+ }
9104
+ }).on(exports.DragEvents.Drag, (event, d) => {
9105
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && d.node) {
9106
+ const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
9107
+ d.node.stretchSections(exports.Side.Right, pointerCoords[0] - (d.coords[0] + d.width), d.indexXInNode, d.indexYInNode);
9108
+ d.node.stretchSections(exports.Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height), d.indexXInNode, d.indexYInNode);
9109
+ }
9110
+ }).on(exports.DragEvents.End, (event, d) => {
9111
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection && d.node) {
8402
9112
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8403
- if (this.snapToGrid) {
9113
+ if (this.gridConfig.snap) {
8404
9114
  pointerCoords = this.getClosestGridPoint(pointerCoords);
8405
9115
  }
9116
+ d.node.stretchSections(exports.Side.Right, pointerCoords[0] - (d.coords[0] + d.width), d.indexXInNode, d.indexYInNode);
8406
9117
  d.node.stretchSections(exports.Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height), d.indexXInNode, d.indexYInNode);
8407
9118
  this.currentAction.to = d.node.getGeometry();
8408
9119
  this.currentAction.do();
@@ -8413,10 +9124,14 @@ class DiagramCanvas {
8413
9124
  }));
8414
9125
  mergeSelection.attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).attr('opacity', d => d.removed ? 0.5 : 1);
8415
9126
  updateLook(mergeSelection);
8416
- 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);
8417
- 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);
8418
- 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);
8419
- 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);
9127
+ 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);
9128
+ 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);
9129
+ 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);
9130
+ 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);
9131
+ 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);
9132
+ 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);
9133
+ 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);
9134
+ 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);
8420
9135
  }
8421
9136
  updatePortsInView(...ids) {
8422
9137
  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);
@@ -8771,9 +9486,9 @@ class DiagramCanvas {
8771
9486
  }
8772
9487
  this.secondaryButton = false;
8773
9488
  }));
8774
- enterSelection.append('text');
9489
+ enterSelection.append('text').style('user-select', 'none').style('font-kerning', 'none').style('white-space', 'nowrap');
8775
9490
  enterSelection.append('rect');
8776
- mergeSelection.attr('x', 0).attr('y', 0).attr('width', d => d.width).attr('height', d => d.height).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]}) rotate(${d.orientation} ${d.width / 2} ${d.height / 2})`).attr('opacity', d => d.removed ? 0.5 : 1).select('text').attr('x', d => d.horizontalAlign === exports.HorizontalAlign.Center ? d.width / 2 : d.horizontalAlign === exports.HorizontalAlign.Right ? d.width : 0).attr('text-anchor', d => d.horizontalAlign === exports.HorizontalAlign.Center ? 'middle' : d.horizontalAlign === exports.HorizontalAlign.Right ? 'end' : 'start').attr('y', d => d.verticalAlign === exports.VerticalAlign.Center ? d.height / 2 : d.verticalAlign === exports.VerticalAlign.Bottom ? d.height : 0).attr('dominant-baseline', d => d.verticalAlign === exports.VerticalAlign.Center ? 'middle' : d.verticalAlign === exports.VerticalAlign.Bottom ? 'auto' : 'hanging').attr('font-size', d => d.fontSize).attr('font-family', d => d.fontFamily || "'Wonder Unit Sans', sans-serif").attr('font-weight', d => d.highlighted ? 600 : 400).attr('fill', d => d.selected ? d.selectedColor || '#000000' : d.color || '#000000').each(d => {
9491
+ mergeSelection.attr('x', 0).attr('y', 0).attr('width', d => d.width).attr('height', d => d.height).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]}) rotate(${d.orientation} ${d.width / 2} ${d.height / 2})`).attr('opacity', d => d.removed ? 0.5 : 1).select('text').attr('x', d => d.horizontalAlign === exports.HorizontalAlign.Center ? d.width / 2 : d.horizontalAlign === exports.HorizontalAlign.Right ? d.width : 0).attr('text-anchor', d => d.horizontalAlign === exports.HorizontalAlign.Center ? 'middle' : d.horizontalAlign === exports.HorizontalAlign.Right ? 'end' : 'start').attr('y', d => d.verticalAlign === exports.VerticalAlign.Center ? d.height / 2 : d.verticalAlign === exports.VerticalAlign.Bottom ? d.height : 0).attr('dominant-baseline', d => d.verticalAlign === exports.VerticalAlign.Center ? 'middle' : d.verticalAlign === exports.VerticalAlign.Bottom ? 'auto' : 'hanging').attr('font-size', d => d.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize).attr('font-family', d => d.look.fontFamily || "'Wonder Unit Sans', sans-serif").attr('font-weight', d => d.look.fontWeight || DIAGRAM_FIELD_DEFAULTS.look.fontWeight).attr('fill', d => d.look.fontColor || DIAGRAM_FIELD_DEFAULTS.look.fontColor).style('font-kerning', 'none').each(d => {
8777
9492
  this.setFieldTextAndWrap(d);
8778
9493
  });
8779
9494
  mergeSelection
@@ -8788,7 +9503,7 @@ class DiagramCanvas {
8788
9503
  updateSelection = updateSelection.filter(d => ids.includes(d.id));
8789
9504
  }
8790
9505
  const mergeSelection = enterSelection.merge(updateSelection);
8791
- mergeSelection.attr('width', d => d.width).attr('height', d => d.height).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).html(d => d.html);
9506
+ mergeSelection.attr('width', d => d.width).attr('height', d => d.height).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).html(d => d.svg);
8792
9507
  exitSelection.remove();
8793
9508
  enterSelection.on(exports.Events.ContextMenu, (event, d) => {
8794
9509
  if (this.dragging) {
@@ -8831,7 +9546,7 @@ class DiagramCanvas {
8831
9546
  updateSelection = updateSelection.filter(d => ids.includes(d.id));
8832
9547
  }
8833
9548
  const mergeSelection = enterSelection.merge(updateSelection);
8834
- mergeSelection.attr('width', d => d.width).attr('height', d => d.height).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).html(d => d.html);
9549
+ mergeSelection.attr('width', d => d.width).attr('height', d => d.height).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).html(d => d.svg);
8835
9550
  exitSelection.remove();
8836
9551
  enterSelection.on(exports.Events.MouseOver, (_event, d) => {
8837
9552
  if (!this.dragging) {
@@ -8932,6 +9647,7 @@ class DiagramCanvas {
8932
9647
  const pathSelection = connectionSelection.select('path');
8933
9648
  const pathNode = pathSelection.node();
8934
9649
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), connection.type.label);
9650
+ labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
8935
9651
  if (pathNode) {
8936
9652
  const pathLength = pathNode.getTotalLength();
8937
9653
  let startLabelShiftX = 0;
@@ -8940,7 +9656,7 @@ class DiagramCanvas {
8940
9656
  let middleLabelShiftY = 0;
8941
9657
  let endLabelShiftX = 0;
8942
9658
  let endLabelShiftY = 0;
8943
- if (labelConfiguration.backgroundColor === 'transparent') {
9659
+ if (labelConfiguration.look.fillColor === 'transparent') {
8944
9660
  // background color is transparent / not set, so we find an alternative position for the label
8945
9661
  const deltaX = connection.endCoords[0] - connection.startCoords[0];
8946
9662
  const deltaY = connection.endCoords[1] - connection.startCoords[1];
@@ -8995,7 +9711,7 @@ class DiagramCanvas {
8995
9711
  }
8996
9712
  }
8997
9713
  // bind start labels
8998
- connectionSelection.select('g.diagram-connection-start-label text').attr('x', 0).attr('y', labelConfiguration.fontSize / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.fontFamily).attr('font-size', labelConfiguration.fontSize).attr('fill', connection.selected ? labelConfiguration.selectedColor : labelConfiguration.color).style('font-kerning', 'none').text(connection.startLabel);
9714
+ connectionSelection.select('g.diagram-connection-start-label text').attr('x', 0).attr('y', (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.look.fontFamily || DIAGRAM_FIELD_DEFAULTS.look.fontFamily).attr('font-size', labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize).attr('fill', labelConfiguration.look.fontColor || DIAGRAM_FIELD_DEFAULTS.look.fontColor).text(connection.startLabel);
8999
9715
  const startLabelBoundingRect = (_a = connectionSelection.select('g.diagram-connection-start-label text').node()) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
9000
9716
  if (startLabelBoundingRect) {
9001
9717
  // don't create space for the label if the label is empty
@@ -9018,22 +9734,22 @@ class DiagramCanvas {
9018
9734
  default:
9019
9735
  pathStartLabelPoint = pathNode.getPointAtLength(Math.max(getLeftMargin(labelConfiguration) + boundingWidth / 2, getRightMargin(labelConfiguration) + boundingWidth / 2, getTopMargin(labelConfiguration) + boundingHeight / 2, getBottomMargin(labelConfiguration) + boundingHeight / 2));
9020
9736
  }
9021
- connectionSelection.select('g.diagram-connection-start-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.backgroundColor).attr('stroke', 'none');
9737
+ connectionSelection.select('g.diagram-connection-start-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.look.fillColor || DIAGRAM_FIELD_DEFAULTS.look.fillColor).attr('stroke', 'none');
9022
9738
  connectionSelection.select('g.diagram-connection-start-label').attr('transform', `translate(${pathStartLabelPoint.x + startLabelShiftX * boundingWidth},${pathStartLabelPoint.y + startLabelShiftY * boundingHeight})`);
9023
9739
  }
9024
9740
  // bind middle labels
9025
- connectionSelection.select('g.diagram-connection-middle-label text').attr('x', 0).attr('y', labelConfiguration.fontSize / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.fontFamily).attr('font-size', labelConfiguration.fontSize).attr('fill', connection.selected ? labelConfiguration.selectedColor : labelConfiguration.color).style('font-kerning', 'none').text(connection.middleLabel);
9741
+ connectionSelection.select('g.diagram-connection-middle-label text').attr('x', 0).attr('y', (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.look.fontFamily || DIAGRAM_FIELD_DEFAULTS.look.fontFamily).attr('font-size', labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize).attr('fill', labelConfiguration.look.fontColor || DIAGRAM_FIELD_DEFAULTS.look.fillColor).style('font-kerning', 'none').text(connection.middleLabel);
9026
9742
  const middleLabelBoundingRect = (_b = connectionSelection.select('g.diagram-connection-middle-label text').node()) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect();
9027
9743
  if (middleLabelBoundingRect) {
9028
9744
  // don't create space for the label if the label is empty
9029
9745
  const boundingWidth = !connection.middleLabel ? 0 : middleLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
9030
9746
  const boundingHeight = !connection.middleLabel ? 0 : middleLabelBoundingRect.height / this.zoomTransform.k + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
9031
9747
  const pathMiddleLabelPoint = pathNode.getPointAtLength(pathLength / 2);
9032
- connectionSelection.select('g.diagram-connection-middle-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.backgroundColor).attr('stroke', 'none');
9748
+ connectionSelection.select('g.diagram-connection-middle-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.look.fillColor || DIAGRAM_FIELD_DEFAULTS.look.fillColor).attr('stroke', 'none');
9033
9749
  connectionSelection.select('g.diagram-connection-middle-label').attr('transform', `translate(${pathMiddleLabelPoint.x + middleLabelShiftX * boundingWidth},${pathMiddleLabelPoint.y + middleLabelShiftY * boundingHeight})`);
9034
9750
  }
9035
9751
  // bind end labels
9036
- connectionSelection.select('g.diagram-connection-end-label text').attr('x', 0).attr('y', labelConfiguration.fontSize / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.fontFamily).attr('font-size', labelConfiguration.fontSize).attr('fill', connection.selected ? labelConfiguration.selectedColor : labelConfiguration.color).style('font-kerning', 'none').text(connection.endLabel);
9752
+ connectionSelection.select('g.diagram-connection-end-label text').attr('x', 0).attr('y', (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.look.fontFamily || DIAGRAM_FIELD_DEFAULTS.look.fontFamily).attr('font-size', labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize).attr('fill', labelConfiguration.look.fontColor || DIAGRAM_FIELD_DEFAULTS.look.fontColor).style('font-kerning', 'none').text(connection.endLabel);
9037
9753
  const endLabelBoundingRect = (_c = connectionSelection.select('g.diagram-connection-end-label text').node()) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect();
9038
9754
  if (endLabelBoundingRect) {
9039
9755
  // don't create space for the label if the label is empty
@@ -9056,7 +9772,7 @@ class DiagramCanvas {
9056
9772
  default:
9057
9773
  pathEndLabelPoint = pathNode.getPointAtLength(pathLength - Math.max(getLeftMargin(labelConfiguration) + boundingWidth / 2, getRightMargin(labelConfiguration) + boundingWidth / 2, getTopMargin(labelConfiguration) + boundingHeight / 2, getBottomMargin(labelConfiguration) + boundingHeight / 2));
9058
9774
  }
9059
- connectionSelection.select('g.diagram-connection-end-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.backgroundColor).attr('stroke', 'none');
9775
+ connectionSelection.select('g.diagram-connection-end-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.look.fillColor || DIAGRAM_FIELD_DEFAULTS.look.fillColor).attr('stroke', 'none');
9060
9776
  connectionSelection.select('g.diagram-connection-end-label').attr('transform', `translate(${pathEndLabelPoint.x + endLabelShiftX * boundingWidth},${pathEndLabelPoint.y + endLabelShiftY * boundingHeight})`);
9061
9777
  }
9062
9778
  }
@@ -9100,9 +9816,13 @@ class DiagramCanvas {
9100
9816
  const fieldDimensions = this.minimumSizeOfField(field);
9101
9817
  let stretchX = fieldDimensions[0] + getLeftMargin(field.rootElement.type.label) + getRightMargin(field.rootElement.type.label) - field.rootElement.width;
9102
9818
  let stretchY = fieldDimensions[1] + getTopMargin(field.rootElement.type.label) + getBottomMargin(field.rootElement.type.label) - field.rootElement.height;
9103
- if (this.snapToGrid) {
9104
- stretchX = Math.ceil(stretchX / this.gridSize) * this.gridSize;
9105
- stretchY = Math.ceil(stretchY / this.gridSize) * this.gridSize;
9819
+ const spacingX = getGridSpacingX(this.gridConfig);
9820
+ const spacingY = getGridSpacingY(this.gridConfig);
9821
+ if (this.gridConfig.snap && spacingX !== 0) {
9822
+ stretchX = Math.ceil(stretchX / spacingX) * spacingX;
9823
+ }
9824
+ if (this.gridConfig.snap && spacingY !== 0) {
9825
+ stretchY = Math.ceil(stretchY / spacingY) * spacingY;
9106
9826
  }
9107
9827
  // ensure node is not stretched under its minimum dimensions
9108
9828
  if (field.rootElement.width + stretchX < field.rootElement.type.minWidth) {
@@ -9140,9 +9860,13 @@ class DiagramCanvas {
9140
9860
  const type = field.rootElement.type;
9141
9861
  let stretchX = fieldDimensions[0] + getLeftMargin(type === null || type === void 0 ? void 0 : type.label) + getRightMargin(type === null || type === void 0 ? void 0 : type.label) - field.rootElement.width;
9142
9862
  let stretchY = fieldDimensions[1] + getTopMargin(type === null || type === void 0 ? void 0 : type.label) + getBottomMargin(type === null || type === void 0 ? void 0 : type.label) - field.rootElement.height;
9143
- if (this.snapToGrid) {
9144
- stretchX = Math.ceil(stretchX / this.gridSize) * this.gridSize;
9145
- stretchY = Math.ceil(stretchY / this.gridSize) * this.gridSize;
9863
+ const spacingX = getGridSpacingX(this.gridConfig);
9864
+ const spacingY = getGridSpacingY(this.gridConfig);
9865
+ if (this.gridConfig.snap && spacingX !== 0) {
9866
+ stretchX = Math.ceil(stretchX / spacingX) * spacingX;
9867
+ }
9868
+ if (this.gridConfig.snap && spacingY !== 0) {
9869
+ stretchY = Math.ceil(stretchY / spacingY) * spacingY;
9146
9870
  }
9147
9871
  // ensure section is not stretched under its minimum dimensions
9148
9872
  if (field.rootElement.width + stretchX < (field.rootElement.getMinWidth() || 0)) {
@@ -9192,13 +9916,13 @@ class DiagramCanvas {
9192
9916
  return d3__namespace.select(this.diagramRoot);
9193
9917
  }
9194
9918
  selectSVGElement() {
9195
- return d3__namespace.select(this.diagramRoot).select('svg');
9919
+ return this.selectRoot().select('svg');
9196
9920
  }
9197
9921
  selectCanvasView() {
9198
9922
  return this.selectSVGElement().select(`.daga-canvas-view`);
9199
9923
  }
9200
9924
  selectCanvasElements() {
9201
- return this.selectSVGElement().select(`.daga-canvas-elements`);
9925
+ return this.selectCanvasView().select(`.daga-canvas-elements`);
9202
9926
  }
9203
9927
  // User actions
9204
9928
  startConnection(port) {
@@ -9310,7 +10034,7 @@ class DiagramCanvas {
9310
10034
  openTextInput(id) {
9311
10035
  const field = this.model.fields.get(id);
9312
10036
  if (field) {
9313
- this.createInputField(field.text, field.coords, field.width, field.height, field.fontSize, field.fontFamily || DIAGRAM_FIELD_DEFAULTS.fontFamily, field.orientation, field.multiline, () => {
10037
+ this.createInputField(field.text, field.coords, field.width, field.height, field.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize, field.look.fontFamily || DIAGRAM_FIELD_DEFAULTS.look.fontFamily, field.orientation, field.multiline, () => {
9314
10038
  // (_text)
9315
10039
  /*
9316
10040
  Empty for now
@@ -9347,7 +10071,7 @@ class DiagramCanvas {
9347
10071
  }
9348
10072
  }).on(exports.Events.KeyUp, event => {
9349
10073
  event.stopPropagation();
9350
- }).on(exports.Events.Input, _event => {
10074
+ }).on(exports.Events.Input, () => {
9351
10075
  const value = inputField.property('value');
9352
10076
  inputField.attr('cols', numberOfColumns(value) + 1);
9353
10077
  inputField.attr('rows', numberOfRows(value) + 1);
@@ -9436,7 +10160,7 @@ class DiagramCanvas {
9436
10160
  const lines = text.split('\n');
9437
10161
  textSelection.html('');
9438
10162
  for (let i = 0; i < lines.length; ++i) {
9439
- textSelection.append('tspan').attr('x', field.horizontalAlign === exports.HorizontalAlign.Center ? field.width / 2 : field.horizontalAlign === exports.HorizontalAlign.Right ? field.width : 0).attr('y', field.verticalAlign === exports.VerticalAlign.Center ? (i + 0.5 - lines.length / 2) * field.fontSize + field.height / 2 : field.verticalAlign === exports.VerticalAlign.Bottom ? field.height - (lines.length - i - 1) * field.fontSize : i * field.fontSize).text(lines[i]);
10163
+ textSelection.append('tspan').attr('x', field.horizontalAlign === exports.HorizontalAlign.Center ? field.width / 2 : field.horizontalAlign === exports.HorizontalAlign.Right ? field.width : 0).attr('y', field.verticalAlign === exports.VerticalAlign.Center ? (i + 0.5 - lines.length / 2) * (field.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) + field.height / 2 : field.verticalAlign === exports.VerticalAlign.Bottom ? field.height - (lines.length - i - 1) * (field.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) : i * (field.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize)).text(lines[i]);
9440
10164
  }
9441
10165
  }
9442
10166
  /**
@@ -9476,12 +10200,12 @@ class DiagramCanvas {
9476
10200
  * Method to call to finish the moving of a node triggered by a user drag event.
9477
10201
  */
9478
10202
  finishMovingNode(event, d) {
9479
- var _a, _b, _c;
10203
+ var _a, _b, _c, _d;
9480
10204
  if (this.canUserPerformAction(exports.DiagramActions.MoveNode) && !d.removed) {
9481
10205
  // prevent drag behavior if mouse hasn't moved
9482
10206
  if (this.draggingFrom[0] !== event.x || this.draggingFrom[1] !== event.y) {
9483
10207
  let newNodeCoords = [event.x - d.width / 2, event.y - d.height / 2];
9484
- if (this.snapToGrid) {
10208
+ if ((_a = this.gridConfig) === null || _a === void 0 ? void 0 : _a.snap) {
9485
10209
  newNodeCoords = this.getClosestGridPoint([newNodeCoords[0] - d.type.snapToGridOffset[0], newNodeCoords[1] - d.type.snapToGridOffset[1]]);
9486
10210
  newNodeCoords[0] += d.type.snapToGridOffset[0];
9487
10211
  newNodeCoords[1] += d.type.snapToGridOffset[1];
@@ -9508,8 +10232,8 @@ class DiagramCanvas {
9508
10232
  if (droppedOn !== d.parent && (d.type.canBeParentless || droppedOn !== undefined)) {
9509
10233
  const ancestorOfDroppedOn = droppedOn === null || droppedOn === void 0 ? void 0 : droppedOn.getLastAncestor();
9510
10234
  const fromChildGeometry = this.currentAction.from;
9511
- const setParentAction = new SetParentAction(this, d.id, (_a = d.parent) === null || _a === void 0 ? void 0 : _a.id, droppedOn === null || droppedOn === void 0 ? void 0 : droppedOn.id, fromChildGeometry, d.getGeometry(), ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.id, ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.getGeometry(d.id), ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.getGeometry(d.id));
9512
- (_b = d.parent) === null || _b === void 0 ? void 0 : _b.removeChild(d);
10235
+ const setParentAction = new SetParentAction(this, d.id, (_b = d.parent) === null || _b === void 0 ? void 0 : _b.id, droppedOn === null || droppedOn === void 0 ? void 0 : droppedOn.id, fromChildGeometry, d.getGeometry(), ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.id, ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.getGeometry(d.id), ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.getGeometry(d.id));
10236
+ (_c = d.parent) === null || _c === void 0 ? void 0 : _c.removeChild(d);
9513
10237
  if (droppedOn !== undefined) {
9514
10238
  droppedOn.addChild(d);
9515
10239
  }
@@ -9520,7 +10244,7 @@ class DiagramCanvas {
9520
10244
  const ancestorOfNode = d === null || d === void 0 ? void 0 : d.getLastAncestor();
9521
10245
  this.currentAction.ancestorId = ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.id;
9522
10246
  this.currentAction.fromAncestorGeometry = ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.getGeometry(d.id);
9523
- (_c = d.parent) === null || _c === void 0 ? void 0 : _c.fitToChild(d);
10247
+ (_d = d.parent) === null || _d === void 0 ? void 0 : _d.fitToChild(d);
9524
10248
  this.currentAction.to = d.getGeometry(d.id);
9525
10249
  this.currentAction.toAncestorGeometry = ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.getGeometry(d.id);
9526
10250
  }
@@ -9931,7 +10655,7 @@ class AdjacencyLayout {
9931
10655
  this.gapSize = gapSize;
9932
10656
  }
9933
10657
  apply(model) {
9934
- var _a;
10658
+ var _a, _b, _c, _d;
9935
10659
  if (model.nodes.length === 0) {
9936
10660
  // nothing to arrange...
9937
10661
  return model;
@@ -9945,12 +10669,13 @@ class AdjacencyLayout {
9945
10669
  // place nodes according to arrangement
9946
10670
  const maximumWidth = Math.max(...model.nodes.map(n => n.width));
9947
10671
  const maximumHeight = Math.max(...model.nodes.map(n => n.height));
9948
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
10672
+ const gapSizeX = this.gapSize !== undefined ? this.gapSize : ((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridConfig) ? getGridSpacingX((_b = model.canvas) === null || _b === void 0 ? void 0 : _b.gridConfig) * 2 : 0;
10673
+ const gapSizeY = this.gapSize !== undefined ? this.gapSize : ((_c = model.canvas) === null || _c === void 0 ? void 0 : _c.gridConfig) ? getGridSpacingY((_d = model.canvas) === null || _d === void 0 ? void 0 : _d.gridConfig) * 2 : 0;
9949
10674
  for (let y = nodeArrangement.minY(); y <= nodeArrangement.maxY(); ++y) {
9950
10675
  for (let x = nodeArrangement.minX(); x <= nodeArrangement.maxX(); ++x) {
9951
10676
  const node = nodeArrangement.get([x, y]);
9952
10677
  if (node !== undefined) {
9953
- node.move([x * (maximumWidth + gapSize), y * (maximumHeight + gapSize)]);
10678
+ node.move([x * (maximumWidth + gapSizeX), y * (maximumHeight + gapSizeY)]);
9954
10679
  }
9955
10680
  }
9956
10681
  }
@@ -9977,7 +10702,7 @@ class BreadthAdjacencyLayout {
9977
10702
  this.gapSize = gapSize;
9978
10703
  }
9979
10704
  apply(model) {
9980
- var _a;
10705
+ var _a, _b, _c, _d;
9981
10706
  if (model.nodes.length === 0) {
9982
10707
  // nothing to arrange...
9983
10708
  return model;
@@ -10013,12 +10738,13 @@ class BreadthAdjacencyLayout {
10013
10738
  // place nodes according to arrangement
10014
10739
  const maximumWidth = Math.max(...model.nodes.map(n => n.width));
10015
10740
  const maximumHeight = Math.max(...model.nodes.map(n => n.height));
10016
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
10741
+ const gapSizeX = this.gapSize !== undefined ? this.gapSize : ((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridConfig) ? getGridSpacingX((_b = model.canvas) === null || _b === void 0 ? void 0 : _b.gridConfig) * 2 : 0;
10742
+ const gapSizeY = this.gapSize !== undefined ? this.gapSize : ((_c = model.canvas) === null || _c === void 0 ? void 0 : _c.gridConfig) ? getGridSpacingY((_d = model.canvas) === null || _d === void 0 ? void 0 : _d.gridConfig) * 2 : 0;
10017
10743
  for (let y = nodeArrangement.minY(); y <= nodeArrangement.maxY(); ++y) {
10018
10744
  for (let x = nodeArrangement.minX(); x <= nodeArrangement.maxX(); ++x) {
10019
10745
  const node = nodeArrangement.get([x, y]);
10020
10746
  if (node !== undefined) {
10021
- node.move([x * (maximumWidth + gapSize), y * (maximumHeight + gapSize)]);
10747
+ node.move([x * (maximumWidth + gapSizeX), y * (maximumHeight + gapSizeY)]);
10022
10748
  }
10023
10749
  }
10024
10750
  }
@@ -10035,12 +10761,13 @@ class BreadthLayout {
10035
10761
  this.gapSize = gapSize;
10036
10762
  }
10037
10763
  apply(model) {
10038
- var _a;
10764
+ var _a, _b, _c, _d;
10039
10765
  if (model.nodes.length === 0) {
10040
10766
  // nothing to arrange...
10041
10767
  return model;
10042
10768
  }
10043
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
10769
+ const gapSizeX = this.gapSize !== undefined ? this.gapSize : ((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridConfig) ? getGridSpacingX((_b = model.canvas) === null || _b === void 0 ? void 0 : _b.gridConfig) * 2 : 0;
10770
+ const gapSizeY = this.gapSize !== undefined ? this.gapSize : ((_c = model.canvas) === null || _c === void 0 ? void 0 : _c.gridConfig) ? getGridSpacingY((_d = model.canvas) === null || _d === void 0 ? void 0 : _d.gridConfig) * 2 : 0;
10044
10771
  let nodesToBeArranged = model.nodes.filter(n => !n.parent);
10045
10772
  // Arrange nodes by a breadth first search
10046
10773
  const firstNode = nodesToBeArranged[0];
@@ -10079,10 +10806,10 @@ class BreadthLayout {
10079
10806
  let heightAccumulator = 0;
10080
10807
  for (const node of nodeArrangementRow) {
10081
10808
  node.move([widthAccumulator, heightAccumulator]);
10082
- heightAccumulator += gapSize + node.height;
10809
+ heightAccumulator += gapSizeY + node.height;
10083
10810
  }
10084
10811
  const maximumWidth = Math.max(...nodeArrangementRow.map(n => n.width));
10085
- widthAccumulator += gapSize + maximumWidth;
10812
+ widthAccumulator += gapSizeX + maximumWidth;
10086
10813
  }
10087
10814
  for (const connection of model.connections) {
10088
10815
  connection.tighten();
@@ -10100,14 +10827,16 @@ class ForceLayout {
10100
10827
  this.gapSize = gapSize;
10101
10828
  }
10102
10829
  apply(model) {
10103
- var _a;
10830
+ var _a, _b, _c, _d;
10104
10831
  if (model.nodes.length === 0) {
10105
10832
  // nothing to arrange...
10106
10833
  return model;
10107
10834
  }
10108
10835
  // as a starting point, we apply a simple layout
10109
10836
  new BreadthLayout(this.gapSize).apply(model);
10110
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
10837
+ const gapSizeX = this.gapSize !== undefined ? this.gapSize : ((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridConfig) ? getGridSpacingX((_b = model.canvas) === null || _b === void 0 ? void 0 : _b.gridConfig) * 2 : 0;
10838
+ const gapSizeY = this.gapSize !== undefined ? this.gapSize : ((_c = model.canvas) === null || _c === void 0 ? void 0 : _c.gridConfig) ? getGridSpacingY((_d = model.canvas) === null || _d === void 0 ? void 0 : _d.gridConfig) * 2 : 0;
10839
+ const gapSize = Math.max(gapSizeX, gapSizeY);
10111
10840
  const coolingFactor = 0.99;
10112
10841
  const minimumTemperature = 1;
10113
10842
  const attractionFactor = 0.1;
@@ -10176,7 +10905,7 @@ class ForceLayout {
10176
10905
  }
10177
10906
  }
10178
10907
  }
10179
- if (model.canvas && model.canvas.snapToGrid) {
10908
+ if (model.canvas && model.canvas.gridConfig.snap) {
10180
10909
  for (const node of model.nodes) {
10181
10910
  const snappedCoords = model.canvas.getClosestGridPoint([node.coords[0] - node.type.snapToGridOffset[0], node.coords[1] - node.type.snapToGridOffset[1]]);
10182
10911
  snappedCoords[0] += node.type.snapToGridOffset[0];
@@ -10200,18 +10929,18 @@ class HorizontalLayout {
10200
10929
  this.gapSize = gapSize;
10201
10930
  }
10202
10931
  apply(model) {
10203
- var _a;
10932
+ var _a, _b;
10204
10933
  if (model.nodes.length === 0) {
10205
10934
  // nothing to arrange...
10206
10935
  return model;
10207
10936
  }
10208
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
10937
+ const gapSizeX = this.gapSize !== undefined ? this.gapSize : ((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridConfig) ? getGridSpacingX((_b = model.canvas) === null || _b === void 0 ? void 0 : _b.gridConfig) * 2 : 0;
10209
10938
  const nodesToBeArranged = model.nodes.filter(n => !n.parent);
10210
10939
  nodesToBeArranged.sort((a, b) => b.type.priority - a.type.priority);
10211
10940
  let widthAccumulator = 0;
10212
10941
  for (const node of nodesToBeArranged) {
10213
10942
  node.move([widthAccumulator, 0]);
10214
- widthAccumulator += node.width + gapSize;
10943
+ widthAccumulator += node.width + gapSizeX;
10215
10944
  }
10216
10945
  return model;
10217
10946
  }
@@ -10226,7 +10955,7 @@ class PriorityLayout {
10226
10955
  this.gapSize = gapSize;
10227
10956
  }
10228
10957
  apply(model) {
10229
- var _a;
10958
+ var _a, _b, _c, _d;
10230
10959
  if (model.nodes.length === 0) {
10231
10960
  // nothing to arrange...
10232
10961
  return model;
@@ -10238,7 +10967,8 @@ class PriorityLayout {
10238
10967
  new BreadthLayout(this.gapSize).apply(model);
10239
10968
  return model;
10240
10969
  }
10241
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
10970
+ const gapSizeX = this.gapSize !== undefined ? this.gapSize : ((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridConfig) ? getGridSpacingX((_b = model.canvas) === null || _b === void 0 ? void 0 : _b.gridConfig) * 2 : 0;
10971
+ const gapSizeY = this.gapSize !== undefined ? this.gapSize : ((_c = model.canvas) === null || _c === void 0 ? void 0 : _c.gridConfig) ? getGridSpacingY((_d = model.canvas) === null || _d === void 0 ? void 0 : _d.gridConfig) * 2 : 0;
10242
10972
  const nodesToBeArranged = model.nodes.filter(n => !n.parent);
10243
10973
  const nodeArrangement = [];
10244
10974
  const nodesWithMaximumPriorityToBeArranged = model.nodes.filter(n => !n.parent).filter(n => n.getPriority() >= maximumPriority);
@@ -10315,10 +11045,10 @@ class PriorityLayout {
10315
11045
  for (let j = 0; j < nodeArrangement[i].length; ++j) {
10316
11046
  const node = nodeArrangement[i][j];
10317
11047
  node.move([widthAccumulator, heightAccumulator]);
10318
- heightAccumulator += gapSize + node.height;
11048
+ heightAccumulator += gapSizeY + node.height;
10319
11049
  }
10320
11050
  const maximumWidth = Math.max(...nodeArrangement[i].map(n => n.width));
10321
- widthAccumulator += gapSize + maximumWidth;
11051
+ widthAccumulator += gapSizeX + maximumWidth;
10322
11052
  }
10323
11053
  for (const connection of model.connections) {
10324
11054
  connection.tighten();
@@ -10336,7 +11066,7 @@ class TreeLayout {
10336
11066
  this.gapSize = gapSize;
10337
11067
  }
10338
11068
  apply(model) {
10339
- var _a;
11069
+ var _a, _b, _c, _d;
10340
11070
  if (model.nodes.length === 0) {
10341
11071
  // nothing to arrange...
10342
11072
  return model;
@@ -10348,7 +11078,8 @@ class TreeLayout {
10348
11078
  new BreadthLayout(this.gapSize).apply(model);
10349
11079
  return model;
10350
11080
  }
10351
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
11081
+ const gapSizeX = this.gapSize !== undefined ? this.gapSize : ((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridConfig) ? getGridSpacingX((_b = model.canvas) === null || _b === void 0 ? void 0 : _b.gridConfig) * 2 : 0;
11082
+ const gapSizeY = this.gapSize !== undefined ? this.gapSize : ((_c = model.canvas) === null || _c === void 0 ? void 0 : _c.gridConfig) ? getGridSpacingY((_d = model.canvas) === null || _d === void 0 ? void 0 : _d.gridConfig) * 2 : 0;
10352
11083
  const nodesToBeArranged = model.nodes.filter(n => !n.parent).sort((n1, n2) => n2.getPriority() - n1.getPriority());
10353
11084
  const branches = [];
10354
11085
  while (nodesToBeArranged.length > 0) {
@@ -10370,10 +11101,10 @@ class TreeLayout {
10370
11101
  for (let j = 0; j < branchArrangement[i].length; ++j) {
10371
11102
  const branch = branchArrangement[i][j];
10372
11103
  branch.node.move([widthAccumulator, heightAccumulator]);
10373
- heightAccumulator += (gapSize + maximumHeight) * branch.countBranchHeight();
11104
+ heightAccumulator += (gapSizeY + maximumHeight) * branch.countBranchHeight();
10374
11105
  }
10375
11106
  const maximumWidth = Math.max(...branchArrangement[i].map(b => b.node.width));
10376
- widthAccumulator += gapSize + maximumWidth;
11107
+ widthAccumulator += gapSizeX + maximumWidth;
10377
11108
  }
10378
11109
  for (const connection of model.connections) {
10379
11110
  connection.tighten();
@@ -10437,18 +11168,18 @@ class VerticalLayout {
10437
11168
  this.gapSize = gapSize;
10438
11169
  }
10439
11170
  apply(model) {
10440
- var _a;
11171
+ var _a, _b;
10441
11172
  if (model.nodes.length === 0) {
10442
11173
  // nothing to arrange...
10443
11174
  return model;
10444
11175
  }
10445
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
11176
+ const gapSizeY = this.gapSize !== undefined ? this.gapSize : ((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridConfig) ? getGridSpacingY((_b = model.canvas) === null || _b === void 0 ? void 0 : _b.gridConfig) * 2 : 0;
10446
11177
  const nodesToBeArranged = model.nodes.filter(n => !n.parent);
10447
11178
  nodesToBeArranged.sort((a, b) => b.type.priority - a.type.priority);
10448
11179
  let heightAccumulator = 0;
10449
11180
  for (const node of nodesToBeArranged) {
10450
11181
  node.move([0, heightAccumulator]);
10451
- heightAccumulator += node.height + gapSize;
11182
+ heightAccumulator += node.height + gapSizeY;
10452
11183
  }
10453
11184
  return model;
10454
11185
  }