@metadev/daga 5.0.3 → 5.0.4
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 +19 -0
- package/index.cjs.js +340 -179
- package/index.esm.js +340 -180
- package/package.json +4 -5
- package/src/index.d.ts +2 -1
- package/src/lib/diagram/canvas/diagram-canvas-util.d.ts +3 -1
- package/src/lib/diagram/canvas/diagram-canvas.d.ts +7 -1
- package/src/lib/diagram/config/diagram-components-config.d.ts +5 -0
- package/src/lib/diagram/config/diagram-config.d.ts +17 -4
- package/src/lib/diagram/diagram-event.d.ts +15 -1
- package/src/lib/diagram/model/diagram-connection.d.ts +1 -1
- package/src/lib/diagram/model/diagram-field.d.ts +8 -2
- package/src/lib/diagram/model/diagram-node.d.ts +13 -3
- package/src/lib/diagram/model/diagram-port.d.ts +1 -1
- package/src/lib/diagram/model/diagram-section.d.ts +3 -3
- package/src/lib/interfaces/canvas.d.ts +27 -3
- package/src/lib/util/browser-util.d.ts +2 -1
- package/src/lib/util/trig.d.ts +0 -9
- package/index.cjs.default.js +0 -1
- package/index.cjs.mjs +0 -2
package/index.cjs.js
CHANGED
|
@@ -1191,6 +1191,9 @@ const numberOfRows = s => {
|
|
|
1191
1191
|
* @private
|
|
1192
1192
|
*/
|
|
1193
1193
|
const clone = o => {
|
|
1194
|
+
if (o === null) {
|
|
1195
|
+
return o;
|
|
1196
|
+
}
|
|
1194
1197
|
if (typeof o !== 'object') {
|
|
1195
1198
|
return o;
|
|
1196
1199
|
}
|
|
@@ -2445,7 +2448,7 @@ class DiagramConnection extends DiagramElement {
|
|
|
2445
2448
|
*/
|
|
2446
2449
|
this.endLabel = '';
|
|
2447
2450
|
/**
|
|
2448
|
-
* Points that this connection
|
|
2451
|
+
* Points that this connection must pass through in its route from its start point to its end point, in order.
|
|
2449
2452
|
* @public
|
|
2450
2453
|
*/
|
|
2451
2454
|
this.points = [];
|
|
@@ -2463,8 +2466,10 @@ class DiagramConnection extends DiagramElement {
|
|
|
2463
2466
|
(_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateConnectionsInView(this.id);
|
|
2464
2467
|
}
|
|
2465
2468
|
raise() {
|
|
2466
|
-
var _a;
|
|
2469
|
+
var _a, _b, _c;
|
|
2467
2470
|
(_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
|
|
2471
|
+
(_b = this.start) === null || _b === void 0 ? void 0 : _b.raise(false);
|
|
2472
|
+
(_c = this.end) === null || _c === void 0 ? void 0 : _c.raise(false);
|
|
2468
2473
|
}
|
|
2469
2474
|
/**
|
|
2470
2475
|
* Set the start of this connection to the given port or reset this connection's starting port if `undefined`.
|
|
@@ -2518,11 +2523,12 @@ class DiagramConnection extends DiagramElement {
|
|
|
2518
2523
|
* @public
|
|
2519
2524
|
*/
|
|
2520
2525
|
tighten() {
|
|
2521
|
-
var _a, _b, _c, _d, _e;
|
|
2526
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2522
2527
|
const allowConnectionLoops = ((_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.allowConnectionLoops) || false;
|
|
2523
2528
|
const allowSharingPorts = ((_b = this.model.canvas) === null || _b === void 0 ? void 0 : _b.allowSharingPorts) !== false;
|
|
2524
2529
|
const allowSharingBothPorts = ((_c = this.model.canvas) === null || _c === void 0 ? void 0 : _c.allowSharingBothPorts) || false;
|
|
2525
|
-
|
|
2530
|
+
const tightenConnectionsAcrossPortTypes = ((_d = this.model.canvas) === null || _d === void 0 ? void 0 : _d.tightenConnectionsAcrossPortTypes) || false;
|
|
2531
|
+
if (((_e = this.start) === null || _e === void 0 ? void 0 : _e.rootElement) && this.end) {
|
|
2526
2532
|
const alternativeStartPortsSortedByDistanceAscending = this.start.rootElement.ports.map(p => [p, p.distanceTo(this.end.coords)]).sort((a, b) => a[1] - b[1]).map(a => a[0]);
|
|
2527
2533
|
checkAlternativeStartPorts: for (const alternativeStartPort of alternativeStartPortsSortedByDistanceAscending) {
|
|
2528
2534
|
if (!allowConnectionLoops && alternativeStartPort === this.end) {
|
|
@@ -2533,6 +2539,10 @@ class DiagramConnection extends DiagramElement {
|
|
|
2533
2539
|
// alternative start port not valid, it doesn't allow outgoing connections
|
|
2534
2540
|
continue checkAlternativeStartPorts;
|
|
2535
2541
|
}
|
|
2542
|
+
if (!tightenConnectionsAcrossPortTypes && alternativeStartPort.type !== this.start.type) {
|
|
2543
|
+
// alternative start port not valid, the port type is different
|
|
2544
|
+
continue checkAlternativeStartPorts;
|
|
2545
|
+
}
|
|
2536
2546
|
if (!allowSharingPorts && (alternativeStartPort.incomingConnections.filter(c => !c.removed && c !== this).length > 0 || alternativeStartPort.outgoingConnections.filter(c => !c.removed && c !== this).length > 0)) {
|
|
2537
2547
|
// alternative start port not valid, it already has other connections
|
|
2538
2548
|
continue checkAlternativeStartPorts;
|
|
@@ -2560,7 +2570,7 @@ class DiagramConnection extends DiagramElement {
|
|
|
2560
2570
|
}
|
|
2561
2571
|
}
|
|
2562
2572
|
}
|
|
2563
|
-
if (((
|
|
2573
|
+
if (((_f = this.end) === null || _f === void 0 ? void 0 : _f.rootElement) && this.start) {
|
|
2564
2574
|
const alternativeEndPortsSortedByDistanceAscending = this.end.rootElement.ports.map(p => [p, p.distanceTo(this.start.coords)]).sort((a, b) => a[1] - b[1]).map(a => a[0]);
|
|
2565
2575
|
checkAlternativeEndPorts: for (const alternativeEndPort of alternativeEndPortsSortedByDistanceAscending) {
|
|
2566
2576
|
if (!allowConnectionLoops && alternativeEndPort === this.start) {
|
|
@@ -2571,6 +2581,10 @@ class DiagramConnection extends DiagramElement {
|
|
|
2571
2581
|
// alternative end port not valid, it doesn't allow incoming connections
|
|
2572
2582
|
continue checkAlternativeEndPorts;
|
|
2573
2583
|
}
|
|
2584
|
+
if (!tightenConnectionsAcrossPortTypes && alternativeEndPort.type !== this.end.type) {
|
|
2585
|
+
// alternative end port not valid, the port type is different
|
|
2586
|
+
continue checkAlternativeEndPorts;
|
|
2587
|
+
}
|
|
2574
2588
|
if (!allowSharingPorts && (alternativeEndPort.incomingConnections.filter(c => !c.removed && c !== this).length > 0 || alternativeEndPort.outgoingConnections.filter(c => !c.removed && c !== this).length > 0)) {
|
|
2575
2589
|
// alternative end port not valid, it already has other connections
|
|
2576
2590
|
continue checkAlternativeEndPorts;
|
|
@@ -2639,6 +2653,7 @@ class DiagramConnectionSet extends DiagramElementSet {
|
|
|
2639
2653
|
* @returns The instanced connection.
|
|
2640
2654
|
*/
|
|
2641
2655
|
new(type, start, end, id) {
|
|
2656
|
+
var _a, _b;
|
|
2642
2657
|
let connectionType;
|
|
2643
2658
|
if (type instanceof DiagramConnectionType) {
|
|
2644
2659
|
connectionType = type;
|
|
@@ -2653,6 +2668,8 @@ class DiagramConnectionSet extends DiagramElementSet {
|
|
|
2653
2668
|
super.add(connection);
|
|
2654
2669
|
connection.updateInView();
|
|
2655
2670
|
connection.valueSet.resetValues();
|
|
2671
|
+
(_a = connection.start) === null || _a === void 0 ? void 0 : _a.raise(false);
|
|
2672
|
+
(_b = connection.end) === null || _b === void 0 ? void 0 : _b.raise(false);
|
|
2656
2673
|
return connection;
|
|
2657
2674
|
}
|
|
2658
2675
|
remove(id) {
|
|
@@ -2687,6 +2704,7 @@ const DIAGRAM_FIELD_DEFAULTS = {
|
|
|
2687
2704
|
horizontalAlign: exports.HorizontalAlign.Center,
|
|
2688
2705
|
verticalAlign: exports.VerticalAlign.Center,
|
|
2689
2706
|
orientation: exports.Side.Top,
|
|
2707
|
+
multiline: false,
|
|
2690
2708
|
fit: false,
|
|
2691
2709
|
shrink: true
|
|
2692
2710
|
};
|
|
@@ -2716,7 +2734,7 @@ class DiagramField extends DiagramElement {
|
|
|
2716
2734
|
(_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.fitFieldRootInView(this.id, this.shrink);
|
|
2717
2735
|
}
|
|
2718
2736
|
}
|
|
2719
|
-
constructor(model, rootElement, coords, width, height, fontSize, fontFamily, color, selectedColor, horizontalAlign, verticalAlign, orientation, text, editable, fit, shrink) {
|
|
2737
|
+
constructor(model, rootElement, coords, width, height, fontSize, fontFamily, color, selectedColor, horizontalAlign, verticalAlign, orientation, multiline, text, editable, fit, shrink) {
|
|
2720
2738
|
const id = `${rootElement === null || rootElement === void 0 ? void 0 : rootElement.id}_field`;
|
|
2721
2739
|
if (model.fields.get(id) !== undefined) {
|
|
2722
2740
|
throw new Error('DiagramField for rootElement already exists');
|
|
@@ -2757,6 +2775,7 @@ class DiagramField extends DiagramElement {
|
|
|
2757
2775
|
this.orientation = 0;
|
|
2758
2776
|
}
|
|
2759
2777
|
}
|
|
2778
|
+
this.multiline = multiline;
|
|
2760
2779
|
this.defaultText = text;
|
|
2761
2780
|
this._text = text;
|
|
2762
2781
|
this.editable = editable;
|
|
@@ -2801,8 +2820,8 @@ class DiagramFieldSet extends DiagramElementSet {
|
|
|
2801
2820
|
* Instance a new field and add it to this set. This method is normally called when instancing an element with a field and it is rarely called by itself.
|
|
2802
2821
|
* @private
|
|
2803
2822
|
*/
|
|
2804
|
-
new(rootElement, coords, fontSize, fontFamily, color, selectedColor, width, height, horizontalAlign, verticalAlign, orientation, text, editable, fit, shrink) {
|
|
2805
|
-
const field = new DiagramField(this.model, rootElement, coords, width, height, fontSize, fontFamily, color, selectedColor, horizontalAlign, verticalAlign, orientation, text, editable, fit, shrink);
|
|
2823
|
+
new(rootElement, coords, fontSize, fontFamily, color, selectedColor, width, height, horizontalAlign, verticalAlign, orientation, multiline, text, editable, fit, shrink) {
|
|
2824
|
+
const field = new DiagramField(this.model, rootElement, coords, width, height, fontSize, fontFamily, color, selectedColor, horizontalAlign, verticalAlign, orientation, multiline, text, editable, fit, shrink);
|
|
2806
2825
|
super.add(field);
|
|
2807
2826
|
field.updateInView();
|
|
2808
2827
|
// add this field to its root element
|
|
@@ -2981,6 +3000,11 @@ const getTopPadding$1 = config => {
|
|
|
2981
3000
|
}
|
|
2982
3001
|
};
|
|
2983
3002
|
|
|
3003
|
+
exports.ResizableMode = void 0;
|
|
3004
|
+
(function (ResizableMode) {
|
|
3005
|
+
ResizableMode[ResizableMode["OnlyWhenSelected"] = 0] = "OnlyWhenSelected";
|
|
3006
|
+
})(exports.ResizableMode || (exports.ResizableMode = {}));
|
|
3007
|
+
|
|
2984
3008
|
/**
|
|
2985
3009
|
* Default value of the default width of a diagram section.
|
|
2986
3010
|
* @private
|
|
@@ -3185,12 +3209,15 @@ class DiagramSection extends DiagramElement {
|
|
|
3185
3209
|
* @public
|
|
3186
3210
|
*/
|
|
3187
3211
|
getResizableX() {
|
|
3188
|
-
var _a
|
|
3212
|
+
var _a;
|
|
3189
3213
|
const sectionType = this.type;
|
|
3190
3214
|
if ((sectionType === null || sectionType === void 0 ? void 0 : sectionType.resizableX) !== undefined) {
|
|
3215
|
+
if (sectionType.resizableX === exports.ResizableMode.OnlyWhenSelected) {
|
|
3216
|
+
return this.selected;
|
|
3217
|
+
}
|
|
3191
3218
|
return sectionType.resizableX;
|
|
3192
3219
|
}
|
|
3193
|
-
return ((
|
|
3220
|
+
return ((_a = this.node) === null || _a === void 0 ? void 0 : _a.getResizableX()) || false;
|
|
3194
3221
|
}
|
|
3195
3222
|
/**
|
|
3196
3223
|
* Returns whether this section can be resized vertically.
|
|
@@ -3199,12 +3226,15 @@ class DiagramSection extends DiagramElement {
|
|
|
3199
3226
|
* @public
|
|
3200
3227
|
*/
|
|
3201
3228
|
getResizableY() {
|
|
3202
|
-
var _a
|
|
3229
|
+
var _a;
|
|
3203
3230
|
const sectionType = this.type;
|
|
3204
3231
|
if ((sectionType === null || sectionType === void 0 ? void 0 : sectionType.resizableY) !== undefined) {
|
|
3232
|
+
if (sectionType.resizableY === exports.ResizableMode.OnlyWhenSelected) {
|
|
3233
|
+
return this.selected;
|
|
3234
|
+
}
|
|
3205
3235
|
return sectionType.resizableY;
|
|
3206
3236
|
}
|
|
3207
|
-
return ((
|
|
3237
|
+
return ((_a = this.node) === null || _a === void 0 ? void 0 : _a.getResizableY()) || false;
|
|
3208
3238
|
}
|
|
3209
3239
|
/**
|
|
3210
3240
|
* Get the port of this section which is closest to the given coordinates.
|
|
@@ -3430,7 +3460,7 @@ class DiagramSectionSet extends DiagramElementSet {
|
|
|
3430
3460
|
default:
|
|
3431
3461
|
labelCoords = port.coords;
|
|
3432
3462
|
}
|
|
3433
|
-
this.model.fields.new(port, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
|
|
3463
|
+
this.model.fields.new(port, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
|
|
3434
3464
|
}
|
|
3435
3465
|
}
|
|
3436
3466
|
}
|
|
@@ -3438,7 +3468,7 @@ class DiagramSectionSet extends DiagramElementSet {
|
|
|
3438
3468
|
const sectionLabel = (_k = (_j = (_h = (_g = node.type.sectionGrid) === null || _g === void 0 ? void 0 : _g.sections) === null || _h === void 0 ? void 0 : _h[indexYInNode]) === null || _j === void 0 ? void 0 : _j[indexXInNode]) === null || _k === void 0 ? void 0 : _k.label;
|
|
3439
3469
|
if (sectionLabel) {
|
|
3440
3470
|
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), sectionLabel);
|
|
3441
|
-
this.model.fields.new(section, [section.coords[0] + getLeftMargin(labelConfiguration), section.coords[1] + getTopMargin(labelConfiguration)], labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, section.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), section.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
|
|
3471
|
+
this.model.fields.new(section, [section.coords[0] + getLeftMargin(labelConfiguration), section.coords[1] + getTopMargin(labelConfiguration)], labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, section.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), section.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
|
|
3442
3472
|
}
|
|
3443
3473
|
return section;
|
|
3444
3474
|
}
|
|
@@ -3715,6 +3745,28 @@ class DiagramNode extends DiagramElement {
|
|
|
3715
3745
|
getPriority() {
|
|
3716
3746
|
return this.type.priority;
|
|
3717
3747
|
}
|
|
3748
|
+
/**
|
|
3749
|
+
* Returns whether this node can be resized horizontally.
|
|
3750
|
+
* @public
|
|
3751
|
+
*/
|
|
3752
|
+
getResizableX() {
|
|
3753
|
+
const resizableX = this.type.resizableX;
|
|
3754
|
+
if (resizableX === exports.ResizableMode.OnlyWhenSelected) {
|
|
3755
|
+
return this.selected;
|
|
3756
|
+
}
|
|
3757
|
+
return resizableX;
|
|
3758
|
+
}
|
|
3759
|
+
/**
|
|
3760
|
+
* Returns whether this node can be resized vertically.
|
|
3761
|
+
* @public
|
|
3762
|
+
*/
|
|
3763
|
+
getResizableY() {
|
|
3764
|
+
const resizableY = this.type.resizableY;
|
|
3765
|
+
if (resizableY === exports.ResizableMode.OnlyWhenSelected) {
|
|
3766
|
+
return this.selected;
|
|
3767
|
+
}
|
|
3768
|
+
return resizableY;
|
|
3769
|
+
}
|
|
3718
3770
|
/**
|
|
3719
3771
|
* Get the port of this node which is closest to the given coordinates.
|
|
3720
3772
|
* @param coords A point in the diagram.
|
|
@@ -4336,14 +4388,14 @@ class DiagramNodeSet extends DiagramElementSet {
|
|
|
4336
4388
|
default:
|
|
4337
4389
|
labelCoords = port.coords;
|
|
4338
4390
|
}
|
|
4339
|
-
this.model.fields.new(port, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
|
|
4391
|
+
this.model.fields.new(port, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
|
|
4340
4392
|
}
|
|
4341
4393
|
}
|
|
4342
4394
|
}
|
|
4343
4395
|
// add node label
|
|
4344
4396
|
if (nodeType.label) {
|
|
4345
4397
|
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), nodeType.label);
|
|
4346
|
-
this.model.fields.new(node, [node.coords[0] + getLeftMargin(labelConfiguration), node.coords[1] + getTopMargin(labelConfiguration)], labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, node.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), node.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
|
|
4398
|
+
this.model.fields.new(node, [node.coords[0] + getLeftMargin(labelConfiguration), node.coords[1] + getTopMargin(labelConfiguration)], labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, node.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), node.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
|
|
4347
4399
|
}
|
|
4348
4400
|
// add node decorators
|
|
4349
4401
|
if (nodeType.decorators.length > 0) {
|
|
@@ -4737,17 +4789,19 @@ class DiagramPort extends DiagramElement {
|
|
|
4737
4789
|
var _a;
|
|
4738
4790
|
(_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updatePortsInView(this.id);
|
|
4739
4791
|
}
|
|
4740
|
-
raise() {
|
|
4792
|
+
raise(raiseConnections = true) {
|
|
4741
4793
|
var _a;
|
|
4742
4794
|
(_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
|
|
4743
4795
|
if (this.label) {
|
|
4744
4796
|
this.label.raise();
|
|
4745
4797
|
}
|
|
4746
|
-
|
|
4747
|
-
connection.
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
connection.
|
|
4798
|
+
if (raiseConnections) {
|
|
4799
|
+
for (const connection of this.incomingConnections) {
|
|
4800
|
+
connection.raise();
|
|
4801
|
+
}
|
|
4802
|
+
for (const connection of this.outgoingConnections) {
|
|
4803
|
+
connection.raise();
|
|
4804
|
+
}
|
|
4751
4805
|
}
|
|
4752
4806
|
}
|
|
4753
4807
|
/**
|
|
@@ -4901,23 +4955,21 @@ class DagaImporter {
|
|
|
4901
4955
|
model.nodes.add(newNode);
|
|
4902
4956
|
newNode.width = node.width;
|
|
4903
4957
|
newNode.height = node.height;
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
newField.updateInView();
|
|
4920
|
-
}
|
|
4958
|
+
// add node decorators
|
|
4959
|
+
if (newNodeType.decorators) {
|
|
4960
|
+
for (let i = 0; i < newNodeType.decorators.length; ++i) {
|
|
4961
|
+
const decoratorConfig = newNodeType.decorators[i];
|
|
4962
|
+
model.decorators.new(newNode, [newNode.coords[0] + decoratorConfig.coords[0], newNode.coords[1] + decoratorConfig.coords[1]], decoratorConfig.width, decoratorConfig.height, newNode.getPriority(), decoratorConfig.html, `${newNode.id}_decorator_${i}`);
|
|
4963
|
+
}
|
|
4964
|
+
}
|
|
4965
|
+
// add node label
|
|
4966
|
+
if (newNodeType.label) {
|
|
4967
|
+
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newNodeType.label);
|
|
4968
|
+
const newField = new DiagramField(model, newNode, [newNode.coords[0] + getLeftMargin(labelConfiguration), newNode.coords[1] + getTopMargin(labelConfiguration)], newNode.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), newNode.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
|
|
4969
|
+
newField.text = node.label;
|
|
4970
|
+
newNode.label = newField;
|
|
4971
|
+
model.fields.add(newField);
|
|
4972
|
+
newField.updateInView();
|
|
4921
4973
|
}
|
|
4922
4974
|
for (const child of node.children || []) {
|
|
4923
4975
|
const newChild = this.importNode(model, child);
|
|
@@ -4930,16 +4982,14 @@ class DagaImporter {
|
|
|
4930
4982
|
const newSection = new DiagramSection(model, newNode, section.indexXInNode, section.indexYInNode, section.coords, section.width, section.height, section.id);
|
|
4931
4983
|
(_b = newNode.sections) === null || _b === void 0 ? void 0 : _b.push(newSection);
|
|
4932
4984
|
model.sections.add(newSection);
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
newField.updateInView();
|
|
4942
|
-
}
|
|
4985
|
+
// add section label
|
|
4986
|
+
if ((_f = (_e = (_d = (_c = newNodeType.sectionGrid) === null || _c === void 0 ? void 0 : _c.sections) === null || _d === void 0 ? void 0 : _d[section.indexYInNode]) === null || _e === void 0 ? void 0 : _e[section.indexXInNode]) === null || _f === void 0 ? void 0 : _f.label) {
|
|
4987
|
+
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_k = (_j = (_h = (_g = newNodeType.sectionGrid) === null || _g === void 0 ? void 0 : _g.sections) === null || _h === void 0 ? void 0 : _h[section.indexYInNode]) === null || _j === void 0 ? void 0 : _j[section.indexXInNode]) === null || _k === void 0 ? void 0 : _k.label);
|
|
4988
|
+
const newField = new DiagramField(model, newSection, [newSection.coords[0] + getLeftMargin(labelConfiguration), newSection.coords[1] + getTopMargin(labelConfiguration)], newSection.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), newSection.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
|
|
4989
|
+
newField.text = section.label;
|
|
4990
|
+
newSection.label = newField;
|
|
4991
|
+
model.fields.add(newField);
|
|
4992
|
+
newField.updateInView();
|
|
4943
4993
|
}
|
|
4944
4994
|
let portCounter = 0;
|
|
4945
4995
|
for (const port of section.ports || []) {
|
|
@@ -4966,7 +5016,7 @@ class DagaImporter {
|
|
|
4966
5016
|
default:
|
|
4967
5017
|
labelCoords = newPort.coords;
|
|
4968
5018
|
}
|
|
4969
|
-
const newField = new DiagramField(model, newPort, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
|
|
5019
|
+
const newField = new DiagramField(model, newPort, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
|
|
4970
5020
|
newField.text = port.label;
|
|
4971
5021
|
newPort.label = newField;
|
|
4972
5022
|
model.fields.add(newField);
|
|
@@ -5013,7 +5063,7 @@ class DagaImporter {
|
|
|
5013
5063
|
default:
|
|
5014
5064
|
labelCoords = newPort.coords;
|
|
5015
5065
|
}
|
|
5016
|
-
const newField = new DiagramField(model, newPort, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
|
|
5066
|
+
const newField = new DiagramField(model, newPort, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
|
|
5017
5067
|
newField.text = port.label;
|
|
5018
5068
|
newPort.label = newField;
|
|
5019
5069
|
model.fields.add(newField);
|
|
@@ -6310,6 +6360,7 @@ exports.DiagramEvents = void 0;
|
|
|
6310
6360
|
DiagramEvents[DiagramEvents["SecondaryClick"] = 2] = "SecondaryClick";
|
|
6311
6361
|
DiagramEvents[DiagramEvents["Selection"] = 3] = "Selection";
|
|
6312
6362
|
DiagramEvents[DiagramEvents["Highlight"] = 4] = "Highlight";
|
|
6363
|
+
DiagramEvents[DiagramEvents["DraggingNode"] = 5] = "DraggingNode";
|
|
6313
6364
|
})(exports.DiagramEvents || (exports.DiagramEvents = {}));
|
|
6314
6365
|
/**
|
|
6315
6366
|
* Diagram event which consists of the user zooming or panning.
|
|
@@ -6393,6 +6444,20 @@ class DiagramHighlightedEvent extends DiagramEvent {
|
|
|
6393
6444
|
this.target = target;
|
|
6394
6445
|
}
|
|
6395
6446
|
}
|
|
6447
|
+
/**
|
|
6448
|
+
* Diagram event which consists of the user dragging a diagram node.
|
|
6449
|
+
*/
|
|
6450
|
+
class DiagramDraggingNodeEvent extends DiagramEvent {
|
|
6451
|
+
/**
|
|
6452
|
+
* Create a diagram dragging node event.
|
|
6453
|
+
*
|
|
6454
|
+
* @param target Diagram node which is targeted by the event.
|
|
6455
|
+
*/
|
|
6456
|
+
constructor(target) {
|
|
6457
|
+
super(exports.DiagramEvents.DraggingNode);
|
|
6458
|
+
this.target = target;
|
|
6459
|
+
}
|
|
6460
|
+
}
|
|
6396
6461
|
|
|
6397
6462
|
/**
|
|
6398
6463
|
* A foreign object which is inserted with arbitrary html into a diagram.
|
|
@@ -6669,8 +6734,8 @@ const isSecondaryButton = event => {
|
|
|
6669
6734
|
* @private
|
|
6670
6735
|
* @see linePath
|
|
6671
6736
|
*/
|
|
6672
|
-
const getConnectionPath = (shape, startCoords, endCoords, startDirection, endDirection, width, startMarkerWidth, endMarkerWidth) => {
|
|
6673
|
-
return linePath(shape, [startCoords, endCoords], startDirection, endDirection, Math.max(
|
|
6737
|
+
const getConnectionPath = (shape, startCoords, endCoords, startDirection, endDirection, points, width, startMarkerWidth, endMarkerWidth) => {
|
|
6738
|
+
return linePath(shape, [startCoords, ...points, endCoords], startDirection, endDirection, Math.max(
|
|
6674
6739
|
// reasonable value for the minimumDistanceBeforeTurn relative to the line width
|
|
6675
6740
|
10, startMarkerWidth || 0, endMarkerWidth || 0) * width);
|
|
6676
6741
|
};
|
|
@@ -6690,6 +6755,34 @@ const getRelatedNodeOrItself = element => {
|
|
|
6690
6755
|
}
|
|
6691
6756
|
return element.rootElement instanceof DiagramNode || element.rootElement instanceof DiagramSection || element.rootElement instanceof DiagramPort ? getRelatedNodeOrItself(element.rootElement) : element;
|
|
6692
6757
|
};
|
|
6758
|
+
const needsResizerX = element => {
|
|
6759
|
+
if (element instanceof DiagramNode) {
|
|
6760
|
+
return element.type.resizableX !== false;
|
|
6761
|
+
}
|
|
6762
|
+
if (element instanceof DiagramSection) {
|
|
6763
|
+
if (element.type !== undefined) {
|
|
6764
|
+
return element.type.resizableX !== false;
|
|
6765
|
+
}
|
|
6766
|
+
if (element.node !== undefined) {
|
|
6767
|
+
return needsResizerX(element.node);
|
|
6768
|
+
}
|
|
6769
|
+
}
|
|
6770
|
+
return false;
|
|
6771
|
+
};
|
|
6772
|
+
const needsResizerY = element => {
|
|
6773
|
+
if (element instanceof DiagramNode) {
|
|
6774
|
+
return element.type.resizableY !== false;
|
|
6775
|
+
}
|
|
6776
|
+
if (element instanceof DiagramSection) {
|
|
6777
|
+
if (element.type !== undefined) {
|
|
6778
|
+
return element.type.resizableY !== false;
|
|
6779
|
+
}
|
|
6780
|
+
if (element.node !== undefined) {
|
|
6781
|
+
return needsResizerY(element.node);
|
|
6782
|
+
}
|
|
6783
|
+
}
|
|
6784
|
+
return false;
|
|
6785
|
+
};
|
|
6693
6786
|
const initializeLook = selection => {
|
|
6694
6787
|
selection.filter('.shaped-look').append('path');
|
|
6695
6788
|
selection.filter('.image-look').append('image').attr('preserveAspectRatio', 'none');
|
|
@@ -7164,6 +7257,7 @@ class DiagramUserSelection extends DiagramElementSet {
|
|
|
7164
7257
|
constructor(canvas, diagramPropertiesText) {
|
|
7165
7258
|
super();
|
|
7166
7259
|
this.canvas = canvas;
|
|
7260
|
+
// TODO: would be a good idea to be able to configure how often this fires, or whether at all
|
|
7167
7261
|
this.canvas.propertyEditorChanges$.pipe(rxjs.debounceTime(2000)).subscribe(() => {
|
|
7168
7262
|
this.makeUpdateValuesAction();
|
|
7169
7263
|
});
|
|
@@ -7398,29 +7492,6 @@ class DiagramUserSelection extends DiagramElementSet {
|
|
|
7398
7492
|
}
|
|
7399
7493
|
}
|
|
7400
7494
|
|
|
7401
|
-
const degreesToRadians = theta => theta * Math.PI / 180;
|
|
7402
|
-
/**
|
|
7403
|
-
* Calculates the original size of the a rectangle that has been rotated by the given number of degrees resulting in a bounding box of the given size.
|
|
7404
|
-
*
|
|
7405
|
-
* @param width The width of a bounding box.
|
|
7406
|
-
* @param height The height of a bounding box.
|
|
7407
|
-
* @param orientation A rotation in degrees.
|
|
7408
|
-
* @returns The size of the original rectangle.
|
|
7409
|
-
*/
|
|
7410
|
-
const unrotate = (width, height, orientation) => {
|
|
7411
|
-
// TODO: this method fails under certain edge cases
|
|
7412
|
-
// like for example, when angle is 45 degrees so sin(theta) == cos(theta)
|
|
7413
|
-
const theta = degreesToRadians(orientation);
|
|
7414
|
-
const orientationSine = Math.sin(theta);
|
|
7415
|
-
const orientationCosine = Math.cos(theta);
|
|
7416
|
-
const oldWidth = (Math.abs(width * orientationCosine) - Math.abs(height * orientationSine)) / (orientationCosine * orientationCosine - orientationSine * orientationSine);
|
|
7417
|
-
const oldHeight = (Math.abs(width * orientationSine) - Math.abs(height * orientationCosine)) / (orientationSine * orientationSine - orientationCosine * orientationCosine);
|
|
7418
|
-
return [oldWidth, oldHeight];
|
|
7419
|
-
};
|
|
7420
|
-
|
|
7421
|
-
var _a;
|
|
7422
|
-
const isWebkit = ((_a = navigator === null || navigator === void 0 ? void 0 : navigator.userAgent) === null || _a === void 0 ? void 0 : _a.indexOf('AppleWebKit')) >= 0;
|
|
7423
|
-
|
|
7424
7495
|
/**
|
|
7425
7496
|
* Thickness of the invisible path around a connection used to make it easier to click on, in diagram units.
|
|
7426
7497
|
* @private
|
|
@@ -7455,7 +7526,7 @@ class DiagramCanvas {
|
|
|
7455
7526
|
* @param config The configuration object used to set the parameters of this canvas.
|
|
7456
7527
|
*/
|
|
7457
7528
|
constructor(parentComponent, config) {
|
|
7458
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
|
|
7529
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
|
|
7459
7530
|
this.backgroundPatternId = `daga-background-pattern-id-${DiagramCanvas.canvasCount++}`;
|
|
7460
7531
|
this.zoomTransform = d3__namespace.zoomIdentity;
|
|
7461
7532
|
// used to distinguish drags from clicks when dragging elements and during multiple selection
|
|
@@ -7483,12 +7554,13 @@ class DiagramCanvas {
|
|
|
7483
7554
|
this.panRate = ((_z = config.canvas) === null || _z === void 0 ? void 0 : _z.panRate) || 100;
|
|
7484
7555
|
this.inferConnectionType = ((_0 = config.connectionSettings) === null || _0 === void 0 ? void 0 : _0.inferConnectionType) || false;
|
|
7485
7556
|
this.autoTightenConnections = ((_1 = config.connectionSettings) === null || _1 === void 0 ? void 0 : _1.autoTighten) !== false;
|
|
7486
|
-
this.
|
|
7487
|
-
this.
|
|
7488
|
-
this.
|
|
7489
|
-
this.
|
|
7557
|
+
this.tightenConnectionsAcrossPortTypes = ((_2 = config.connectionSettings) === null || _2 === void 0 ? void 0 : _2.tightenAcrossPortTypes) || false;
|
|
7558
|
+
this.allowConnectionLoops = ((_3 = config.connectionSettings) === null || _3 === void 0 ? void 0 : _3.allowLoops) || false;
|
|
7559
|
+
this.allowSharingPorts = ((_4 = config.connectionSettings) === null || _4 === void 0 ? void 0 : _4.sharePorts) !== false;
|
|
7560
|
+
this.allowSharingBothPorts = ((_5 = config.connectionSettings) === null || _5 === void 0 ? void 0 : _5.shareBothPorts) || false;
|
|
7561
|
+
this.portHighlightRadius = ((_6 = config.connectionSettings) === null || _6 === void 0 ? void 0 : _6.portHighlightRadius) || 100;
|
|
7490
7562
|
this.multipleSelectionOn = false;
|
|
7491
|
-
this.priorityThresholds = ((
|
|
7563
|
+
this.priorityThresholds = ((_7 = config.canvas) === null || _7 === void 0 ? void 0 : _7.priorityThresholds) || [];
|
|
7492
7564
|
this.priorityThreshold = this.priorityThresholds ? this.priorityThresholds[0] : undefined;
|
|
7493
7565
|
this.layoutFormat = config.layoutFormat;
|
|
7494
7566
|
this.userActions = config.userActions || {};
|
|
@@ -7515,7 +7587,7 @@ class DiagramCanvas {
|
|
|
7515
7587
|
const connectionType = new DiagramConnectionType(Object.assign(Object.assign({}, config.connectionTypeDefaults), connectionTypeConfig));
|
|
7516
7588
|
this.model.connections.types.add(connectionType);
|
|
7517
7589
|
}
|
|
7518
|
-
this._connectionType = ((
|
|
7590
|
+
this._connectionType = ((_8 = config === null || config === void 0 ? void 0 : config.connectionSettings) === null || _8 === void 0 ? void 0 : _8.defaultConnection) !== undefined ? this.model.connections.types.get(config.connectionSettings.defaultConnection) : undefined;
|
|
7519
7591
|
}
|
|
7520
7592
|
}
|
|
7521
7593
|
addValidator(validator) {
|
|
@@ -7718,10 +7790,6 @@ class DiagramCanvas {
|
|
|
7718
7790
|
const transformAttribute = event.transform.toString();
|
|
7719
7791
|
this.selectCanvasElements().attr('transform', transformAttribute);
|
|
7720
7792
|
d3__namespace.select(`#${this.backgroundPatternId}`).attr('patternTransform', transformAttribute);
|
|
7721
|
-
if (isWebkit) {
|
|
7722
|
-
// force update fields to compensate for a rendering bug in webkit
|
|
7723
|
-
this.updateFieldsInView();
|
|
7724
|
-
}
|
|
7725
7793
|
this.contextMenu.close();
|
|
7726
7794
|
this.diagramEvent$.next(new DiagramZoomEvent([this.zoomTransform.x, this.zoomTransform.y], this.zoomTransform.k));
|
|
7727
7795
|
}).on(exports.ZoomEvents.End, () => {
|
|
@@ -7775,7 +7843,14 @@ class DiagramCanvas {
|
|
|
7775
7843
|
}
|
|
7776
7844
|
}
|
|
7777
7845
|
getViewCoordinates() {
|
|
7778
|
-
|
|
7846
|
+
var _a, _b, _c;
|
|
7847
|
+
const canvasViewBoundingBox = (_c = (_b = (_a = this.selectCanvasView()) === null || _a === void 0 ? void 0 : _a.select('rect')) === null || _b === void 0 ? void 0 : _b.node()) === null || _c === void 0 ? void 0 : _c.getBBox();
|
|
7848
|
+
/*
|
|
7849
|
+
transform the coordinates of the zoomTransform to the coordinates
|
|
7850
|
+
needed to point the zoomTransfrom to the center of the screen to
|
|
7851
|
+
ensure that canvas.translateTo(getViewCoordinates()) has no effect
|
|
7852
|
+
*/
|
|
7853
|
+
return [((canvasViewBoundingBox.width + canvasViewBoundingBox.x) / 2 - this.zoomTransform.x) / this.zoomTransform.k, ((canvasViewBoundingBox.height + canvasViewBoundingBox.y) / 2 - this.zoomTransform.y) / this.zoomTransform.k];
|
|
7779
7854
|
}
|
|
7780
7855
|
translateBy(x, y) {
|
|
7781
7856
|
if (!isNaN(x) && !isNaN(y)) {
|
|
@@ -7787,12 +7862,42 @@ class DiagramCanvas {
|
|
|
7787
7862
|
this.zoomBehavior.translateTo(this.selectCanvasView(), x, y);
|
|
7788
7863
|
}
|
|
7789
7864
|
}
|
|
7790
|
-
|
|
7865
|
+
zoomAndPanTo(x, y, z, duration) {
|
|
7866
|
+
if (!duration || duration <= 0) {
|
|
7867
|
+
this.zoomBehavior.scaleTo(this.selectCanvasView(), z);
|
|
7868
|
+
this.zoomBehavior.translateTo(this.selectCanvasView(), x, y);
|
|
7869
|
+
return;
|
|
7870
|
+
}
|
|
7871
|
+
this.zoomBehavior.interpolate(d3__namespace.interpolate);
|
|
7872
|
+
const [startingX, startingY] = this.getViewCoordinates();
|
|
7873
|
+
const startingZoom = this.getZoomLevel();
|
|
7874
|
+
const targetX = x,
|
|
7875
|
+
targetY = y,
|
|
7876
|
+
targetZoom = z;
|
|
7877
|
+
this.selectCanvasElements().transition().duration(duration).ease(d3__namespace.easeCubicInOut).tween('progress', () => {
|
|
7878
|
+
let animationInterrupted = false;
|
|
7879
|
+
return value => {
|
|
7880
|
+
try {
|
|
7881
|
+
if (!animationInterrupted) {
|
|
7882
|
+
const currentX = value * (targetX - startingX) + startingX;
|
|
7883
|
+
const currentY = value * (targetY - startingY) + startingY;
|
|
7884
|
+
const currentZoom = value * (targetZoom - startingZoom) + startingZoom;
|
|
7885
|
+
this.zoomBehavior.scaleTo(this.selectCanvasView(), currentZoom);
|
|
7886
|
+
this.zoomBehavior.translateTo(this.selectCanvasView(), currentX, currentY);
|
|
7887
|
+
}
|
|
7888
|
+
} catch (e) {
|
|
7889
|
+
console.warn('Animation has been interrupted');
|
|
7890
|
+
animationInterrupted = true;
|
|
7891
|
+
}
|
|
7892
|
+
};
|
|
7893
|
+
});
|
|
7894
|
+
}
|
|
7895
|
+
center(nodeIds, maxZoomLevel, duration) {
|
|
7791
7896
|
var _a;
|
|
7792
7897
|
// if there are no nodes, we have nothing to do here
|
|
7793
7898
|
if (this.model.nodes.length > 0) {
|
|
7794
7899
|
const canvasViewBoundingBox = (_a = this.selectCanvasView().select('rect').node()) === null || _a === void 0 ? void 0 : _a.getBBox();
|
|
7795
|
-
const nonRemovedNodes = this.model.nodes.all();
|
|
7900
|
+
const nonRemovedNodes = (nodeIds === null || nodeIds === void 0 ? void 0 : nodeIds.map(i => this.model.nodes.get(i)).filter(n => !!n)) || this.model.nodes.all();
|
|
7796
7901
|
const minimumX = Math.min(...nonRemovedNodes.map(n => n.coords[0]));
|
|
7797
7902
|
const maximumX = Math.max(...nonRemovedNodes.map(n => n.coords[0] + n.width));
|
|
7798
7903
|
const averageX = (minimumX + maximumX) / 2;
|
|
@@ -7807,12 +7912,12 @@ class DiagramCanvas {
|
|
|
7807
7912
|
* (windowRangeX / rangeX) is the zoom level to fit everything horizontally
|
|
7808
7913
|
* (windowRangeY / rangeY) is the zoom level to fit everything vertically
|
|
7809
7914
|
* the minimum between them is the zoom to fit everything in the screen both horizontally and vertically
|
|
7810
|
-
* we also add
|
|
7915
|
+
* we also add maxZoomLevel to the list so that if the zoom exceeds maxZoomLevel it is set to maxZoomLevel
|
|
7916
|
+
* or 1 if maxZoomLevel is undefined
|
|
7811
7917
|
* a zoom bigger than 1 means zooming in instead of out, and we don't want to zoom in if it's not necessary
|
|
7812
7918
|
*/
|
|
7813
|
-
const zoom = Math.min(windowRangeX / rangeX, windowRangeY / rangeY, 1);
|
|
7814
|
-
this.
|
|
7815
|
-
this.zoomTo(zoom);
|
|
7919
|
+
const zoom = Math.min(windowRangeX / rangeX, windowRangeY / rangeY, maxZoomLevel !== undefined ? maxZoomLevel : 1);
|
|
7920
|
+
this.zoomAndPanTo(averageX, averageY, zoom, duration);
|
|
7816
7921
|
}
|
|
7817
7922
|
}
|
|
7818
7923
|
getClosestGridPoint(point) {
|
|
@@ -7868,7 +7973,7 @@ class DiagramCanvas {
|
|
|
7868
7973
|
updateNodesInView(...ids) {
|
|
7869
7974
|
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);
|
|
7870
7975
|
const exitSelection = updateSelection.exit();
|
|
7871
|
-
const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', d => `diagram-node${d
|
|
7976
|
+
const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', d => `diagram-node${needsResizerX(d) ? ' resizable-x' : ''}${needsResizerY(d) ? ' resizable-y' : ''} ${d.type.defaultLook.lookType}`);
|
|
7872
7977
|
if (ids && ids.length > 0) {
|
|
7873
7978
|
updateSelection = updateSelection.filter(d => ids.includes(d.id));
|
|
7874
7979
|
}
|
|
@@ -7931,28 +8036,28 @@ class DiagramCanvas {
|
|
|
7931
8036
|
this.secondaryButton = false;
|
|
7932
8037
|
}));
|
|
7933
8038
|
initializeLook(enterSelection);
|
|
7934
|
-
enterSelection.filter('.resizable-x').append('line').attr('class', 'left-resizer').attr('stroke', 'transparent').attr('stroke-width',
|
|
7935
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8039
|
+
enterSelection.filter('.resizable-x').append('line').attr('class', 'left-resizer').attr('stroke', 'transparent').attr('stroke-width', RESIZER_THICKNESS).on(exports.Events.MouseOver, (_event, d) => {
|
|
8040
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
|
|
7936
8041
|
setCursorStyle(exports.CursorStyle.EWResize);
|
|
7937
8042
|
}
|
|
7938
8043
|
}).on(exports.Events.MouseOut, (_event, d) => {
|
|
7939
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8044
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
|
|
7940
8045
|
setCursorStyle();
|
|
7941
8046
|
}
|
|
7942
8047
|
}).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
|
|
7943
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8048
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
|
|
7944
8049
|
setCursorStyle(exports.CursorStyle.EWResize);
|
|
7945
8050
|
this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
|
|
7946
8051
|
} else {
|
|
7947
8052
|
setCursorStyle(exports.CursorStyle.NotAllowed);
|
|
7948
8053
|
}
|
|
7949
8054
|
}).on(exports.DragEvents.Drag, (event, d) => {
|
|
7950
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8055
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
|
|
7951
8056
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7952
8057
|
d.stretch(exports.Side.Left, d.coords[0] - pointerCoords[0]);
|
|
7953
8058
|
}
|
|
7954
8059
|
}).on(exports.DragEvents.End, (event, d) => {
|
|
7955
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8060
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchNode) {
|
|
7956
8061
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7957
8062
|
if (this.snapToGrid) {
|
|
7958
8063
|
pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
|
|
@@ -7967,28 +8072,28 @@ class DiagramCanvas {
|
|
|
7967
8072
|
}
|
|
7968
8073
|
setCursorStyle();
|
|
7969
8074
|
}));
|
|
7970
|
-
enterSelection.filter('.resizable-y').append('line').attr('class', 'top-resizer').attr('stroke', 'transparent').attr('stroke-width',
|
|
7971
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8075
|
+
enterSelection.filter('.resizable-y').append('line').attr('class', 'top-resizer').attr('stroke', 'transparent').attr('stroke-width', RESIZER_THICKNESS).on(exports.Events.MouseOver, (_event, d) => {
|
|
8076
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
|
|
7972
8077
|
setCursorStyle(exports.CursorStyle.NSResize);
|
|
7973
8078
|
}
|
|
7974
8079
|
}).on(exports.Events.MouseOut, (_event, d) => {
|
|
7975
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8080
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
|
|
7976
8081
|
setCursorStyle();
|
|
7977
8082
|
}
|
|
7978
8083
|
}).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
|
|
7979
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8084
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
|
|
7980
8085
|
setCursorStyle(exports.CursorStyle.NSResize);
|
|
7981
8086
|
this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
|
|
7982
8087
|
} else {
|
|
7983
8088
|
setCursorStyle(exports.CursorStyle.NotAllowed);
|
|
7984
8089
|
}
|
|
7985
8090
|
}).on(exports.DragEvents.Drag, (event, d) => {
|
|
7986
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8091
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
|
|
7987
8092
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7988
8093
|
d.stretch(exports.Side.Top, d.coords[1] - pointerCoords[1]);
|
|
7989
8094
|
}
|
|
7990
8095
|
}).on(exports.DragEvents.End, (event, d) => {
|
|
7991
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8096
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchNode) {
|
|
7992
8097
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7993
8098
|
if (this.snapToGrid) {
|
|
7994
8099
|
pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
|
|
@@ -8003,28 +8108,28 @@ class DiagramCanvas {
|
|
|
8003
8108
|
}
|
|
8004
8109
|
setCursorStyle();
|
|
8005
8110
|
}));
|
|
8006
|
-
enterSelection.filter('.resizable-x').append('line').attr('class', 'right-resizer').attr('stroke', 'transparent').attr('stroke-width',
|
|
8007
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8111
|
+
enterSelection.filter('.resizable-x').append('line').attr('class', 'right-resizer').attr('stroke', 'transparent').attr('stroke-width', RESIZER_THICKNESS).on(exports.Events.MouseOver, (_event, d) => {
|
|
8112
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
|
|
8008
8113
|
setCursorStyle(exports.CursorStyle.EWResize);
|
|
8009
8114
|
}
|
|
8010
8115
|
}).on(exports.Events.MouseOut, (_event, d) => {
|
|
8011
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8116
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
|
|
8012
8117
|
setCursorStyle();
|
|
8013
8118
|
}
|
|
8014
8119
|
}).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
|
|
8015
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8120
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
|
|
8016
8121
|
setCursorStyle(exports.CursorStyle.EWResize);
|
|
8017
8122
|
this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
|
|
8018
8123
|
} else {
|
|
8019
8124
|
setCursorStyle(exports.CursorStyle.NotAllowed);
|
|
8020
8125
|
}
|
|
8021
8126
|
}).on(exports.DragEvents.Drag, (event, d) => {
|
|
8022
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8127
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
|
|
8023
8128
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
8024
8129
|
d.stretch(exports.Side.Right, pointerCoords[0] - (d.coords[0] + d.width));
|
|
8025
8130
|
}
|
|
8026
8131
|
}).on(exports.DragEvents.End, (event, d) => {
|
|
8027
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8132
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchNode) {
|
|
8028
8133
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
8029
8134
|
if (this.snapToGrid) {
|
|
8030
8135
|
pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[2], pointerCoords[1] - d.type.snapToGridOffset[3]]);
|
|
@@ -8039,28 +8144,28 @@ class DiagramCanvas {
|
|
|
8039
8144
|
}
|
|
8040
8145
|
setCursorStyle();
|
|
8041
8146
|
}));
|
|
8042
|
-
enterSelection.filter('.resizable-y').append('line').attr('class', 'bottom-resizer').attr('stroke', 'transparent').attr('stroke-width',
|
|
8043
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8147
|
+
enterSelection.filter('.resizable-y').append('line').attr('class', 'bottom-resizer').attr('stroke', 'transparent').attr('stroke-width', RESIZER_THICKNESS).on(exports.Events.MouseOver, (_event, d) => {
|
|
8148
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
|
|
8044
8149
|
setCursorStyle(exports.CursorStyle.NSResize);
|
|
8045
8150
|
}
|
|
8046
8151
|
}).on(exports.Events.MouseOut, (_event, d) => {
|
|
8047
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8152
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
|
|
8048
8153
|
setCursorStyle();
|
|
8049
8154
|
}
|
|
8050
8155
|
}).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
|
|
8051
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8156
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
|
|
8052
8157
|
setCursorStyle(exports.CursorStyle.NSResize);
|
|
8053
8158
|
this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
|
|
8054
8159
|
} else {
|
|
8055
8160
|
setCursorStyle(exports.CursorStyle.NotAllowed);
|
|
8056
8161
|
}
|
|
8057
8162
|
}).on(exports.DragEvents.Drag, (event, d) => {
|
|
8058
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8163
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
|
|
8059
8164
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
8060
8165
|
d.stretch(exports.Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height));
|
|
8061
8166
|
}
|
|
8062
8167
|
}).on(exports.DragEvents.End, (event, d) => {
|
|
8063
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8168
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchNode) {
|
|
8064
8169
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
8065
8170
|
if (this.snapToGrid) {
|
|
8066
8171
|
if (this.snapToGrid) {
|
|
@@ -8079,17 +8184,17 @@ class DiagramCanvas {
|
|
|
8079
8184
|
}));
|
|
8080
8185
|
mergeSelection.attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).attr('opacity', d => d.removed ? 0.5 : 1);
|
|
8081
8186
|
updateLook(mergeSelection);
|
|
8082
|
-
mergeSelection.filter('.resizable-x').select('line.left-resizer').attr('x1', RESIZER_THICKNESS / 2).attr('x2', RESIZER_THICKNESS / 2).attr('y1', 0).attr('y2', d => d.height);
|
|
8083
|
-
mergeSelection.filter('.resizable-y').select('line.top-resizer').attr('x1', 0).attr('x2', d => d.width).attr('y1', RESIZER_THICKNESS / 2).attr('y2', RESIZER_THICKNESS / 2);
|
|
8084
|
-
mergeSelection.filter('.resizable-x').select('line.right-resizer').attr('x1', d => d.width - RESIZER_THICKNESS / 2).attr('x2', d => d.width - RESIZER_THICKNESS / 2).attr('y1', 0).attr('y2', d => d.height);
|
|
8085
|
-
mergeSelection.filter('.resizable-y').select('line.bottom-resizer').attr('x1', 0).attr('x2', d => d.width).attr('y1', d => d.height - RESIZER_THICKNESS / 2).attr('y2', d => d.height - RESIZER_THICKNESS / 2);
|
|
8187
|
+
mergeSelection.filter('.resizable-x').select('line.left-resizer').style('pointer-events', d => d.getResizableX() ? 'initial' : 'none').attr('x1', RESIZER_THICKNESS / 2).attr('x2', RESIZER_THICKNESS / 2).attr('y1', 0).attr('y2', d => d.height);
|
|
8188
|
+
mergeSelection.filter('.resizable-y').select('line.top-resizer').style('pointer-events', d => d.getResizableY() ? 'initial' : 'none').attr('x1', 0).attr('x2', d => d.width).attr('y1', RESIZER_THICKNESS / 2).attr('y2', RESIZER_THICKNESS / 2);
|
|
8189
|
+
mergeSelection.filter('.resizable-x').select('line.right-resizer').style('pointer-events', d => d.getResizableX() ? 'initial' : 'none').attr('x1', d => d.width - RESIZER_THICKNESS / 2).attr('x2', d => d.width - RESIZER_THICKNESS / 2).attr('y1', 0).attr('y2', d => d.height);
|
|
8190
|
+
mergeSelection.filter('.resizable-y').select('line.bottom-resizer').style('pointer-events', d => d.getResizableY() ? 'initial' : 'none').attr('x1', 0).attr('x2', d => d.width).attr('y1', d => d.height - RESIZER_THICKNESS / 2).attr('y2', d => d.height - RESIZER_THICKNESS / 2);
|
|
8086
8191
|
}
|
|
8087
8192
|
updateSectionsInView(...ids) {
|
|
8088
8193
|
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);
|
|
8089
8194
|
const exitSelection = updateSelection.exit();
|
|
8090
8195
|
const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', d => {
|
|
8091
8196
|
var _a;
|
|
8092
|
-
return `diagram-section${d
|
|
8197
|
+
return `diagram-section${needsResizerX(d) ? ' resizable-x' : ''}${needsResizerY(d) ? ' resizable-y' : ''} ${(_a = d.look) === null || _a === void 0 ? void 0 : _a.lookType}`;
|
|
8093
8198
|
});
|
|
8094
8199
|
if (ids && ids.length > 0) {
|
|
8095
8200
|
updateSelection = updateSelection.filter(d => ids.includes(d.id));
|
|
@@ -8170,7 +8275,7 @@ class DiagramCanvas {
|
|
|
8170
8275
|
this.secondaryButton = false;
|
|
8171
8276
|
}));
|
|
8172
8277
|
initializeLook(enterSelection);
|
|
8173
|
-
enterSelection.filter('.resizable-x').append('line').attr('class', 'left-resizer').attr('stroke', 'transparent').attr('stroke-width',
|
|
8278
|
+
enterSelection.filter('.resizable-x').append('line').attr('class', 'left-resizer').attr('stroke', 'transparent').attr('stroke-width', RESIZER_THICKNESS).on(exports.Events.MouseOver, (_event, d) => {
|
|
8174
8279
|
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
|
|
8175
8280
|
setCursorStyle(exports.CursorStyle.EWResize);
|
|
8176
8281
|
}
|
|
@@ -8204,7 +8309,7 @@ class DiagramCanvas {
|
|
|
8204
8309
|
}
|
|
8205
8310
|
setCursorStyle();
|
|
8206
8311
|
}));
|
|
8207
|
-
enterSelection.filter('.resizable-y').append('line').attr('class', 'top-resizer').attr('stroke', 'transparent').attr('stroke-width',
|
|
8312
|
+
enterSelection.filter('.resizable-y').append('line').attr('class', 'top-resizer').attr('stroke', 'transparent').attr('stroke-width', RESIZER_THICKNESS).on(exports.Events.MouseOver, (_event, d) => {
|
|
8208
8313
|
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
|
|
8209
8314
|
setCursorStyle(exports.CursorStyle.NSResize);
|
|
8210
8315
|
}
|
|
@@ -8238,7 +8343,7 @@ class DiagramCanvas {
|
|
|
8238
8343
|
}
|
|
8239
8344
|
setCursorStyle();
|
|
8240
8345
|
}));
|
|
8241
|
-
enterSelection.filter('.resizable-x').append('line').attr('class', 'right-resizer').attr('stroke', 'transparent').attr('stroke-width',
|
|
8346
|
+
enterSelection.filter('.resizable-x').append('line').attr('class', 'right-resizer').attr('stroke', 'transparent').attr('stroke-width', RESIZER_THICKNESS).on(exports.Events.MouseOver, (_event, d) => {
|
|
8242
8347
|
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
|
|
8243
8348
|
setCursorStyle(exports.CursorStyle.EWResize);
|
|
8244
8349
|
}
|
|
@@ -8272,7 +8377,7 @@ class DiagramCanvas {
|
|
|
8272
8377
|
}
|
|
8273
8378
|
setCursorStyle();
|
|
8274
8379
|
}));
|
|
8275
|
-
enterSelection.filter('.resizable-y').append('line').attr('class', 'bottom-resizer').attr('stroke', 'transparent').attr('stroke-width',
|
|
8380
|
+
enterSelection.filter('.resizable-y').append('line').attr('class', 'bottom-resizer').attr('stroke', 'transparent').attr('stroke-width', RESIZER_THICKNESS).on(exports.Events.MouseOver, (_event, d) => {
|
|
8276
8381
|
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
|
|
8277
8382
|
setCursorStyle(exports.CursorStyle.NSResize);
|
|
8278
8383
|
}
|
|
@@ -8308,10 +8413,10 @@ class DiagramCanvas {
|
|
|
8308
8413
|
}));
|
|
8309
8414
|
mergeSelection.attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).attr('opacity', d => d.removed ? 0.5 : 1);
|
|
8310
8415
|
updateLook(mergeSelection);
|
|
8311
|
-
mergeSelection.filter('.resizable-x').select('line.left-resizer').attr('x1', RESIZER_THICKNESS / 2).attr('x2', RESIZER_THICKNESS / 2).attr('y1', 0).attr('y2', d => d.height);
|
|
8312
|
-
mergeSelection.filter('.resizable-y').select('line.top-resizer').attr('x1', 0).attr('x2', d => d.width).attr('y1', RESIZER_THICKNESS / 2).attr('y2', RESIZER_THICKNESS / 2);
|
|
8313
|
-
mergeSelection.filter('.resizable-x').select('line.right-resizer').attr('x1', d => d.width - RESIZER_THICKNESS / 2).attr('x2', d => d.width - RESIZER_THICKNESS / 2).attr('y1', 0).attr('y2', d => d.height);
|
|
8314
|
-
mergeSelection.filter('.resizable-y').select('line.bottom-resizer').attr('x1', 0).attr('x2', d => d.width).attr('y1', d => d.height - RESIZER_THICKNESS / 2).attr('y2', d => d.height - RESIZER_THICKNESS / 2);
|
|
8416
|
+
mergeSelection.filter('.resizable-x').select('line.left-resizer').style('pointer-events', d => d.getResizableX() ? 'initial' : 'none').attr('x1', RESIZER_THICKNESS / 2).attr('x2', RESIZER_THICKNESS / 2).attr('y1', 0).attr('y2', d => d.height);
|
|
8417
|
+
mergeSelection.filter('.resizable-y').select('line.top-resizer').style('pointer-events', d => d.getResizableY() ? 'initial' : 'none').attr('x1', 0).attr('x2', d => d.width).attr('y1', RESIZER_THICKNESS / 2).attr('y2', RESIZER_THICKNESS / 2);
|
|
8418
|
+
mergeSelection.filter('.resizable-x').select('line.right-resizer').style('pointer-events', d => d.getResizableX() ? 'initial' : 'none').attr('x1', d => d.width - RESIZER_THICKNESS / 2).attr('x2', d => d.width - RESIZER_THICKNESS / 2).attr('y1', 0).attr('y2', d => d.height);
|
|
8419
|
+
mergeSelection.filter('.resizable-y').select('line.bottom-resizer').style('pointer-events', d => d.getResizableY() ? 'initial' : 'none').attr('x1', 0).attr('x2', d => d.width).attr('y1', d => d.height - RESIZER_THICKNESS / 2).attr('y2', d => d.height - RESIZER_THICKNESS / 2);
|
|
8315
8420
|
}
|
|
8316
8421
|
updatePortsInView(...ids) {
|
|
8317
8422
|
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);
|
|
@@ -8396,14 +8501,14 @@ class DiagramCanvas {
|
|
|
8396
8501
|
}
|
|
8397
8502
|
}
|
|
8398
8503
|
}).on(exports.DragEvents.Drag, (event, d) => {
|
|
8399
|
-
var _a, _b, _c, _d;
|
|
8504
|
+
var _a, _b, _c, _d, _e;
|
|
8400
8505
|
if (this.multipleSelectionOn || this.secondaryButton) {
|
|
8401
8506
|
this.continueMultipleSelection(event);
|
|
8402
8507
|
} else {
|
|
8403
8508
|
if (this.canUserPerformAction(exports.DiagramActions.AddConnection) && !d.removed) {
|
|
8404
8509
|
if (this.unfinishedConnection !== undefined) {
|
|
8405
8510
|
const endCoords = [event.x, event.y];
|
|
8406
|
-
(_a = this.unfinishedConnectionTracer) === null || _a === void 0 ? void 0 : _a.attr('d', getConnectionPath(this.unfinishedConnection.look.shape || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.shape, this.unfinishedConnection.startCoords, endCoords, this.unfinishedConnection.startDirection, this.unfinishedConnection.endDirection, this.unfinishedConnection.type.defaultLook.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness, (_b = this.unfinishedConnection.type.defaultStartMarkerLook) === null || _b === void 0 ? void 0 : _b.width, (_c = this.unfinishedConnection.type.defaultEndMarkerLook) === null || _c === void 0 ? void 0 : _c.width));
|
|
8511
|
+
(_a = this.unfinishedConnectionTracer) === null || _a === void 0 ? void 0 : _a.attr('d', getConnectionPath(this.unfinishedConnection.look.shape || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.shape, this.unfinishedConnection.startCoords, endCoords, this.unfinishedConnection.startDirection, this.unfinishedConnection.endDirection, this.unfinishedConnection.points, this.unfinishedConnection.type.defaultLook.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness, (_b = this.unfinishedConnection.type.defaultStartMarkerLook) === null || _b === void 0 ? void 0 : _b.width, (_c = this.unfinishedConnection.type.defaultEndMarkerLook) === null || _c === void 0 ? void 0 : _c.width));
|
|
8407
8512
|
const unfinishedConnectionGhostNode = (_d = this.unfinishedConnectionTracer) === null || _d === void 0 ? void 0 : _d.node();
|
|
8408
8513
|
if (unfinishedConnectionGhostNode) {
|
|
8409
8514
|
let margin = 2;
|
|
@@ -8418,6 +8523,7 @@ class DiagramCanvas {
|
|
|
8418
8523
|
this.unfinishedConnection.endCoords = endCoords;
|
|
8419
8524
|
}
|
|
8420
8525
|
this.updateConnectionsInView(UNFINISHED_CONNECTION_ID);
|
|
8526
|
+
(_e = this.unfinishedConnectionPort) === null || _e === void 0 ? void 0 : _e.raise(false);
|
|
8421
8527
|
// highlight closest target port
|
|
8422
8528
|
if (this.model.ports.length > 0) {
|
|
8423
8529
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
@@ -8551,29 +8657,29 @@ class DiagramCanvas {
|
|
|
8551
8657
|
enterSelection.select('g.diagram-connection-end-label').append('text').style('user-select', 'none');
|
|
8552
8658
|
mergeSelection.attr('opacity', d => d.removed ? 0.5 : 1).select('path.diagram-connection-path').attr('d', d => {
|
|
8553
8659
|
var _a, _b;
|
|
8554
|
-
return getConnectionPath(d.look.shape || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.type.defaultLook.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness, (_a = d.type.defaultStartMarkerLook) === null || _a === void 0 ? void 0 : _a.width, (_b = d.type.defaultEndMarkerLook) === null || _b === void 0 ? void 0 : _b.width);
|
|
8555
|
-
}).attr('marker-start', d => `url(#${d.id}-start-marker)`).attr('marker-end', d => `url(#${d.id}-end-marker)`).attr('stroke', d => d.look.color || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.color).attr('stroke-width', d =>
|
|
8660
|
+
return getConnectionPath(d.look.shape || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.points, d.type.defaultLook.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness, (_a = d.type.defaultStartMarkerLook) === null || _a === void 0 ? void 0 : _a.width, (_b = d.type.defaultEndMarkerLook) === null || _b === void 0 ? void 0 : _b.width);
|
|
8661
|
+
}).attr('marker-start', d => `url(#${d.id}-start-marker)`).attr('marker-end', d => `url(#${d.id}-end-marker)`).attr('stroke', d => d.look.color || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.color).attr('stroke-width', d => d.look.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness).attr('stroke-dasharray', d => lineStyleDasharray(d.look.style || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.style, d.type.defaultLook.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness)).attr('fill', 'none');
|
|
8556
8662
|
mergeSelection.select('path.diagram-connection-path-box').attr('d', d => {
|
|
8557
8663
|
var _a, _b;
|
|
8558
|
-
return getConnectionPath(d.look.shape || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.type.defaultLook.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness, (_a = d.type.defaultStartMarkerLook) === null || _a === void 0 ? void 0 : _a.width, (_b = d.type.defaultEndMarkerLook) === null || _b === void 0 ? void 0 : _b.width);
|
|
8664
|
+
return getConnectionPath(d.look.shape || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.points, d.type.defaultLook.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness, (_a = d.type.defaultStartMarkerLook) === null || _a === void 0 ? void 0 : _a.width, (_b = d.type.defaultEndMarkerLook) === null || _b === void 0 ? void 0 : _b.width);
|
|
8559
8665
|
}).attr('stroke', 'transparent')
|
|
8560
8666
|
// allow generating pointer events even when it is transparent
|
|
8561
|
-
.attr('pointer-events', 'stroke').attr('stroke-width', d =>
|
|
8667
|
+
.attr('pointer-events', 'stroke').attr('stroke-width', d => (d.look.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness) + CONNECTION_PATH_BOX_THICKNESS).attr('stroke-dasharray', d => lineStyleDasharray(d.look.style || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.style, d.type.defaultLook.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness)).attr('fill', 'none');
|
|
8562
8668
|
mergeSelection.data().forEach(connection => {
|
|
8563
8669
|
this.updateConnectionLabelsInView(connection);
|
|
8564
8670
|
this.updateConnectionMarkersInView(connection);
|
|
8565
8671
|
});
|
|
8566
8672
|
}
|
|
8567
8673
|
updateFieldsInView(...ids) {
|
|
8568
|
-
let updateSelection = this.selectCanvasElements().selectAll('
|
|
8674
|
+
let updateSelection = this.selectCanvasElements().selectAll('g.diagram-field').data(this.model.fields.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
|
|
8569
8675
|
const exitSelection = updateSelection.exit();
|
|
8570
|
-
const enterSelection = updateSelection.enter().append('
|
|
8676
|
+
const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', 'diagram-field');
|
|
8571
8677
|
if (ids && ids.length > 0) {
|
|
8572
8678
|
updateSelection = updateSelection.filter(d => ids.includes(d.id));
|
|
8573
8679
|
}
|
|
8574
8680
|
const mergeSelection = enterSelection.merge(updateSelection);
|
|
8575
8681
|
exitSelection.remove();
|
|
8576
|
-
enterSelection.
|
|
8682
|
+
enterSelection.on(exports.Events.MouseOver, (_event, d) => {
|
|
8577
8683
|
if (!this.dragging) {
|
|
8578
8684
|
this.userHighlight.focusOn(d);
|
|
8579
8685
|
this.diagramEvent$.next(new DiagramHighlightedEvent(d));
|
|
@@ -8610,22 +8716,7 @@ class DiagramCanvas {
|
|
|
8610
8716
|
this.diagramEvent$.next(diagramEvent);
|
|
8611
8717
|
if (!diagramEvent.defaultPrevented && this.canUserPerformAction(exports.DiagramActions.EditField) && d.editable && !d.removed) {
|
|
8612
8718
|
this.currentAction = new EditFieldAction(this, d.id, d.text, '');
|
|
8613
|
-
this.
|
|
8614
|
-
// (_text)
|
|
8615
|
-
/*
|
|
8616
|
-
Empty for now
|
|
8617
|
-
We should create a better function to stretch the root element as the text expands
|
|
8618
|
-
Bear in mind that DiagramNode.setGeometry() calls DiagramNode.raise(), which breaks the input field
|
|
8619
|
-
*/
|
|
8620
|
-
}, text => {
|
|
8621
|
-
d.text = text;
|
|
8622
|
-
if (this.currentAction instanceof EditFieldAction) {
|
|
8623
|
-
this.currentAction.to = text;
|
|
8624
|
-
this.currentAction.do();
|
|
8625
|
-
this.actionStack.add(this.currentAction);
|
|
8626
|
-
this.currentAction = undefined;
|
|
8627
|
-
}
|
|
8628
|
-
});
|
|
8719
|
+
this.openTextInput(d.id);
|
|
8629
8720
|
}
|
|
8630
8721
|
}).call(d3__namespace.drag().filter(event => {
|
|
8631
8722
|
this.secondaryButton = isSecondaryButton(event);
|
|
@@ -8679,12 +8770,15 @@ class DiagramCanvas {
|
|
|
8679
8770
|
}
|
|
8680
8771
|
}
|
|
8681
8772
|
this.secondaryButton = false;
|
|
8682
|
-
}))
|
|
8683
|
-
|
|
8684
|
-
|
|
8685
|
-
|
|
8686
|
-
|
|
8687
|
-
}
|
|
8773
|
+
}));
|
|
8774
|
+
enterSelection.append('text');
|
|
8775
|
+
enterSelection.append('rect');
|
|
8776
|
+
mergeSelection.attr('x', 0).attr('y', 0).attr('width', d => d.width).attr('height', d => d.height).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]}) rotate(${d.orientation} ${d.width / 2} ${d.height / 2})`).attr('opacity', d => d.removed ? 0.5 : 1).select('text').attr('x', d => d.horizontalAlign === exports.HorizontalAlign.Center ? d.width / 2 : d.horizontalAlign === exports.HorizontalAlign.Right ? d.width : 0).attr('text-anchor', d => d.horizontalAlign === exports.HorizontalAlign.Center ? 'middle' : d.horizontalAlign === exports.HorizontalAlign.Right ? 'end' : 'start').attr('y', d => d.verticalAlign === exports.VerticalAlign.Center ? d.height / 2 : d.verticalAlign === exports.VerticalAlign.Bottom ? d.height : 0).attr('dominant-baseline', d => d.verticalAlign === exports.VerticalAlign.Center ? 'middle' : d.verticalAlign === exports.VerticalAlign.Bottom ? 'auto' : 'hanging').attr('font-size', d => d.fontSize).attr('font-family', d => d.fontFamily || "'Wonder Unit Sans', sans-serif").attr('font-weight', d => d.highlighted ? 600 : 400).attr('fill', d => d.selected ? d.selectedColor || '#000000' : d.color || '#000000').each(d => {
|
|
8777
|
+
this.setFieldTextAndWrap(d);
|
|
8778
|
+
});
|
|
8779
|
+
mergeSelection
|
|
8780
|
+
// add a transparent rectangle to capture pointer events on the text
|
|
8781
|
+
.select('rect').attr('x', 0).attr('y', 0).attr('width', d => d.width).attr('height', d => d.height).attr('fill', 'transparent');
|
|
8688
8782
|
}
|
|
8689
8783
|
updateObjectsInView(...ids) {
|
|
8690
8784
|
let updateSelection = this.selectCanvasElements().selectAll('g.diagram-object').data(this.model.objects.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
|
|
@@ -8694,7 +8788,7 @@ class DiagramCanvas {
|
|
|
8694
8788
|
updateSelection = updateSelection.filter(d => ids.includes(d.id));
|
|
8695
8789
|
}
|
|
8696
8790
|
const mergeSelection = enterSelection.merge(updateSelection);
|
|
8697
|
-
mergeSelection.attr('width', d =>
|
|
8791
|
+
mergeSelection.attr('width', d => d.width).attr('height', d => d.height).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).html(d => d.html);
|
|
8698
8792
|
exitSelection.remove();
|
|
8699
8793
|
enterSelection.on(exports.Events.ContextMenu, (event, d) => {
|
|
8700
8794
|
if (this.dragging) {
|
|
@@ -8737,7 +8831,7 @@ class DiagramCanvas {
|
|
|
8737
8831
|
updateSelection = updateSelection.filter(d => ids.includes(d.id));
|
|
8738
8832
|
}
|
|
8739
8833
|
const mergeSelection = enterSelection.merge(updateSelection);
|
|
8740
|
-
mergeSelection.attr('width', d =>
|
|
8834
|
+
mergeSelection.attr('width', d => d.width).attr('height', d => d.height).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).html(d => d.html);
|
|
8741
8835
|
exitSelection.remove();
|
|
8742
8836
|
enterSelection.on(exports.Events.MouseOver, (_event, d) => {
|
|
8743
8837
|
if (!this.dragging) {
|
|
@@ -8916,10 +9010,10 @@ class DiagramCanvas {
|
|
|
8916
9010
|
pathStartLabelPoint = pathNode.getPointAtLength(getLeftMargin(labelConfiguration) + boundingWidth / 2);
|
|
8917
9011
|
break;
|
|
8918
9012
|
case exports.Side.Top:
|
|
8919
|
-
pathStartLabelPoint = pathNode.getPointAtLength(getBottomMargin(labelConfiguration) +
|
|
9013
|
+
pathStartLabelPoint = pathNode.getPointAtLength(getBottomMargin(labelConfiguration) + boundingHeight / 2);
|
|
8920
9014
|
break;
|
|
8921
9015
|
case exports.Side.Bottom:
|
|
8922
|
-
pathStartLabelPoint = pathNode.getPointAtLength(getTopMargin(labelConfiguration) +
|
|
9016
|
+
pathStartLabelPoint = pathNode.getPointAtLength(getTopMargin(labelConfiguration) + boundingHeight / 2);
|
|
8923
9017
|
break;
|
|
8924
9018
|
default:
|
|
8925
9019
|
pathStartLabelPoint = pathNode.getPointAtLength(Math.max(getLeftMargin(labelConfiguration) + boundingWidth / 2, getRightMargin(labelConfiguration) + boundingWidth / 2, getTopMargin(labelConfiguration) + boundingHeight / 2, getBottomMargin(labelConfiguration) + boundingHeight / 2));
|
|
@@ -8954,10 +9048,10 @@ class DiagramCanvas {
|
|
|
8954
9048
|
pathEndLabelPoint = pathNode.getPointAtLength(pathLength - (getLeftMargin(labelConfiguration) + boundingWidth / 2));
|
|
8955
9049
|
break;
|
|
8956
9050
|
case exports.Side.Top:
|
|
8957
|
-
pathEndLabelPoint = pathNode.getPointAtLength(pathLength - (getBottomMargin(labelConfiguration) +
|
|
9051
|
+
pathEndLabelPoint = pathNode.getPointAtLength(pathLength - (getBottomMargin(labelConfiguration) + boundingHeight / 2));
|
|
8958
9052
|
break;
|
|
8959
9053
|
case exports.Side.Bottom:
|
|
8960
|
-
pathEndLabelPoint = pathNode.getPointAtLength(pathLength - (getTopMargin(labelConfiguration) +
|
|
9054
|
+
pathEndLabelPoint = pathNode.getPointAtLength(pathLength - (getTopMargin(labelConfiguration) + boundingHeight / 2));
|
|
8961
9055
|
break;
|
|
8962
9056
|
default:
|
|
8963
9057
|
pathEndLabelPoint = pathNode.getPointAtLength(pathLength - Math.max(getLeftMargin(labelConfiguration) + boundingWidth / 2, getRightMargin(labelConfiguration) + boundingWidth / 2, getTopMargin(labelConfiguration) + boundingHeight / 2, getBottomMargin(labelConfiguration) + boundingHeight / 2));
|
|
@@ -9112,6 +9206,7 @@ class DiagramCanvas {
|
|
|
9112
9206
|
if (port.allowsOutgoing || port.allowsIncoming) {
|
|
9113
9207
|
if (this.connectionType && (this.connectionType.canStartFromType(((_b = (_a = port.getNode()) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.id) || '') && port.allowsOutgoing || this.connectionType.canFinishOnType(((_d = (_c = port.getNode()) === null || _c === void 0 ? void 0 : _c.type) === null || _d === void 0 ? void 0 : _d.id) || '') && port.allowsIncoming)) {
|
|
9114
9208
|
this.unfinishedConnection = new DiagramConnection(this.model, this.connectionType, port, undefined, UNFINISHED_CONNECTION_ID);
|
|
9209
|
+
this.unfinishedConnectionPort = port;
|
|
9115
9210
|
} else {
|
|
9116
9211
|
if (this.inferConnectionType) {
|
|
9117
9212
|
let differentConnectionType = this.model.connections.types.all().find(t => {
|
|
@@ -9126,6 +9221,7 @@ class DiagramCanvas {
|
|
|
9126
9221
|
}
|
|
9127
9222
|
if (differentConnectionType !== undefined) {
|
|
9128
9223
|
this.unfinishedConnection = new DiagramConnection(this.model, differentConnectionType, port, undefined, UNFINISHED_CONNECTION_ID);
|
|
9224
|
+
this.unfinishedConnectionPort = port;
|
|
9129
9225
|
}
|
|
9130
9226
|
}
|
|
9131
9227
|
}
|
|
@@ -9199,6 +9295,7 @@ class DiagramCanvas {
|
|
|
9199
9295
|
(_b = this.unfinishedConnection) === null || _b === void 0 ? void 0 : _b.setEnd(undefined);
|
|
9200
9296
|
(_d = (_c = this.unfinishedConnection) === null || _c === void 0 ? void 0 : _c.select()) === null || _d === void 0 ? void 0 : _d.remove();
|
|
9201
9297
|
this.unfinishedConnection = undefined;
|
|
9298
|
+
this.unfinishedConnectionPort = undefined;
|
|
9202
9299
|
}
|
|
9203
9300
|
cancelAllUserActions() {
|
|
9204
9301
|
this.currentAction = undefined;
|
|
@@ -9210,7 +9307,28 @@ class DiagramCanvas {
|
|
|
9210
9307
|
canUserPerformAction(action) {
|
|
9211
9308
|
return this.userActions[action] !== false;
|
|
9212
9309
|
}
|
|
9213
|
-
|
|
9310
|
+
openTextInput(id) {
|
|
9311
|
+
const field = this.model.fields.get(id);
|
|
9312
|
+
if (field) {
|
|
9313
|
+
this.createInputField(field.text, field.coords, field.width, field.height, field.fontSize, field.fontFamily || DIAGRAM_FIELD_DEFAULTS.fontFamily, field.orientation, field.multiline, () => {
|
|
9314
|
+
// (_text)
|
|
9315
|
+
/*
|
|
9316
|
+
Empty for now
|
|
9317
|
+
We should create a better function to stretch the root element as the text expands
|
|
9318
|
+
Bear in mind that DiagramNode.setGeometry() calls DiagramNode.raise(), which breaks the input field
|
|
9319
|
+
*/
|
|
9320
|
+
}, text => {
|
|
9321
|
+
field.text = text;
|
|
9322
|
+
if (this.currentAction instanceof EditFieldAction) {
|
|
9323
|
+
this.currentAction.to = text;
|
|
9324
|
+
this.currentAction.do();
|
|
9325
|
+
this.actionStack.add(this.currentAction);
|
|
9326
|
+
this.currentAction = undefined;
|
|
9327
|
+
}
|
|
9328
|
+
});
|
|
9329
|
+
}
|
|
9330
|
+
}
|
|
9331
|
+
createInputField(text, coords, width, height, fontSize, fontFamily, orientation, multiline, changeCallback, finishCallback) {
|
|
9214
9332
|
// if we have a text input open, close it before creating a new one
|
|
9215
9333
|
this.removeInputField();
|
|
9216
9334
|
const inputFieldContainer = this.selectCanvasElements().append('foreignObject').attr('x', `${coords[0]}px`).attr('y', `${coords[1]}px`).attr('width', `${width}px`).attr('height', `${height}px`).style('box-sizing', 'border-box').style('border', '1px solid');
|
|
@@ -9220,16 +9338,16 @@ class DiagramCanvas {
|
|
|
9220
9338
|
let inputFieldHeight;
|
|
9221
9339
|
inputField.text(text).style('box-sizing', 'border-box').style('width', `${width}px`).style('height', `${height}px`).style('font-size', `${fontSize}px`).style('font-family', fontFamily).style('resize', 'none').style('outline', 0).style('border', 0).style('margin', 0).style('padding', 0).on(exports.Events.KeyDown, event => {
|
|
9222
9340
|
event.stopPropagation();
|
|
9223
|
-
|
|
9224
|
-
|
|
9225
|
-
if (event.key === exports.Keys.Escape) {
|
|
9226
|
-
const value = inputField.property('value');
|
|
9341
|
+
if (event.key === exports.Keys.Escape || event.key === exports.Keys.Enter && !multiline) {
|
|
9342
|
+
const value = inputField.property('value') || '';
|
|
9227
9343
|
this.removeInputField();
|
|
9228
9344
|
if (finishCallback) {
|
|
9229
9345
|
finishCallback(value);
|
|
9230
9346
|
}
|
|
9231
9347
|
}
|
|
9232
|
-
}).on(exports.Events.
|
|
9348
|
+
}).on(exports.Events.KeyUp, event => {
|
|
9349
|
+
event.stopPropagation();
|
|
9350
|
+
}).on(exports.Events.Input, event => {
|
|
9233
9351
|
const value = inputField.property('value');
|
|
9234
9352
|
inputField.attr('cols', numberOfColumns(value) + 1);
|
|
9235
9353
|
inputField.attr('rows', numberOfRows(value) + 1);
|
|
@@ -9272,13 +9390,54 @@ class DiagramCanvas {
|
|
|
9272
9390
|
}
|
|
9273
9391
|
minimumSizeOfField(field) {
|
|
9274
9392
|
var _a, _b;
|
|
9275
|
-
const
|
|
9276
|
-
if (!
|
|
9393
|
+
const textNode = (_b = (_a = field.select()) === null || _a === void 0 ? void 0 : _a.select('text')) === null || _b === void 0 ? void 0 : _b.node();
|
|
9394
|
+
if (!textNode) {
|
|
9277
9395
|
// happens when a field has been created but not updated in view yet
|
|
9278
9396
|
return [0, 0];
|
|
9279
9397
|
}
|
|
9280
|
-
const
|
|
9281
|
-
return [
|
|
9398
|
+
const textBoundingBox = textNode.getBoundingClientRect();
|
|
9399
|
+
return [textBoundingBox.width / this.zoomTransform.k, textBoundingBox.height / this.zoomTransform.k];
|
|
9400
|
+
}
|
|
9401
|
+
setFieldTextAndWrap(field) {
|
|
9402
|
+
var _a, _b, _c, _d;
|
|
9403
|
+
const textSelection = (_a = field.select()) === null || _a === void 0 ? void 0 : _a.select('text');
|
|
9404
|
+
const textNode = textSelection === null || textSelection === void 0 ? void 0 : textSelection.node();
|
|
9405
|
+
if (textSelection && textNode) {
|
|
9406
|
+
this.setFieldText(field, textSelection, field.text);
|
|
9407
|
+
} else {
|
|
9408
|
+
// can happen if a field has been created but not updated in view yet
|
|
9409
|
+
// not sure if this still happens but should check just in case
|
|
9410
|
+
return;
|
|
9411
|
+
}
|
|
9412
|
+
if (field.fit) {
|
|
9413
|
+
// no need to wrap
|
|
9414
|
+
return;
|
|
9415
|
+
}
|
|
9416
|
+
let minimumSize = this.minimumSizeOfField(field);
|
|
9417
|
+
while (minimumSize[0] > field.width || minimumSize[1] > field.height) {
|
|
9418
|
+
const textString = ((_d = (_c = (_b = textSelection === null || textSelection === void 0 ? void 0 : textSelection.html()) === null || _b === void 0 ? void 0 : _b.replace(/<\/tspan>/g, '\n')) === null || _c === void 0 ? void 0 : _c.replace(/<tspan[^>]*>/g, '')) === null || _d === void 0 ? void 0 : _d.slice(0, -1)) || '';
|
|
9419
|
+
let newTextString = '...';
|
|
9420
|
+
if (textString.endsWith('...')) {
|
|
9421
|
+
newTextString = textString.slice(0, -4) + '...';
|
|
9422
|
+
} else {
|
|
9423
|
+
newTextString = textString.slice(0, -1) + '...';
|
|
9424
|
+
}
|
|
9425
|
+
if (textSelection) {
|
|
9426
|
+
this.setFieldText(field, textSelection, newTextString);
|
|
9427
|
+
}
|
|
9428
|
+
if (newTextString === '...') {
|
|
9429
|
+
// if no more characters can be removed and the new text is a bare ellipsis, stop the execution
|
|
9430
|
+
return;
|
|
9431
|
+
}
|
|
9432
|
+
minimumSize = this.minimumSizeOfField(field);
|
|
9433
|
+
}
|
|
9434
|
+
}
|
|
9435
|
+
setFieldText(field, textSelection, text) {
|
|
9436
|
+
const lines = text.split('\n');
|
|
9437
|
+
textSelection.html('');
|
|
9438
|
+
for (let i = 0; i < lines.length; ++i) {
|
|
9439
|
+
textSelection.append('tspan').attr('x', field.horizontalAlign === exports.HorizontalAlign.Center ? field.width / 2 : field.horizontalAlign === exports.HorizontalAlign.Right ? field.width : 0).attr('y', field.verticalAlign === exports.VerticalAlign.Center ? (i + 0.5 - lines.length / 2) * field.fontSize + field.height / 2 : field.verticalAlign === exports.VerticalAlign.Bottom ? field.height - (lines.length - i - 1) * field.fontSize : i * field.fontSize).text(lines[i]);
|
|
9440
|
+
}
|
|
9282
9441
|
}
|
|
9283
9442
|
/**
|
|
9284
9443
|
* Method to call to start the moving of a node triggered by a user drag event.
|
|
@@ -9310,6 +9469,7 @@ class DiagramCanvas {
|
|
|
9310
9469
|
}
|
|
9311
9470
|
this.userHighlight.clear();
|
|
9312
9471
|
this.dragging = true;
|
|
9472
|
+
this.diagramEvent$.next(new DiagramDraggingNodeEvent(d));
|
|
9313
9473
|
}
|
|
9314
9474
|
}
|
|
9315
9475
|
/**
|
|
@@ -10335,6 +10495,7 @@ exports.DiagramContextMenu = DiagramContextMenu;
|
|
|
10335
10495
|
exports.DiagramDecorator = DiagramDecorator;
|
|
10336
10496
|
exports.DiagramDecoratorSet = DiagramDecoratorSet;
|
|
10337
10497
|
exports.DiagramDoubleClickEvent = DiagramDoubleClickEvent;
|
|
10498
|
+
exports.DiagramDraggingNodeEvent = DiagramDraggingNodeEvent;
|
|
10338
10499
|
exports.DiagramElement = DiagramElement;
|
|
10339
10500
|
exports.DiagramElementSet = DiagramElementSet;
|
|
10340
10501
|
exports.DiagramEntitySet = DiagramEntitySet;
|