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