@metadev/daga 5.0.2 → 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 +24 -0
- package/index.cjs.js +345 -174
- package/index.esm.js +345 -175
- 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 -0
- package/src/lib/util/canvas-util.d.ts +1 -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
|
@@ -231,7 +231,7 @@ const distanceBetweenPoints = (point1, point2) => {
|
|
|
231
231
|
return Math.pow(Math.pow(point1[0] - point2[0], 2) + Math.pow(point1[1] - point2[1], 2), 0.5);
|
|
232
232
|
};
|
|
233
233
|
/**
|
|
234
|
-
* Checks whether the two given
|
|
234
|
+
* Checks whether the two given rectangles share at least one point.
|
|
235
235
|
* @public
|
|
236
236
|
* @param rectangle1 A rectangle.
|
|
237
237
|
* @param rectangle2 A rectangle.
|
|
@@ -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,10 +7257,10 @@ 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
|
});
|
|
7170
|
-
//console.log(diagramPropertiesText);
|
|
7171
7264
|
this.diagramPropertiesText = diagramPropertiesText !== undefined ? diagramPropertiesText : DIAGRAM_PROPERTIES_DEFAULT_TEXT;
|
|
7172
7265
|
}
|
|
7173
7266
|
add(element) {
|
|
@@ -7399,26 +7492,6 @@ class DiagramUserSelection extends DiagramElementSet {
|
|
|
7399
7492
|
}
|
|
7400
7493
|
}
|
|
7401
7494
|
|
|
7402
|
-
const degreesToRadians = theta => theta * Math.PI / 180;
|
|
7403
|
-
/**
|
|
7404
|
-
* 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.
|
|
7405
|
-
*
|
|
7406
|
-
* @param width The width of a bounding box.
|
|
7407
|
-
* @param height The height of a bounding box.
|
|
7408
|
-
* @param orientation A rotation in degrees.
|
|
7409
|
-
* @returns The size of the original rectangle.
|
|
7410
|
-
*/
|
|
7411
|
-
const unrotate = (width, height, orientation) => {
|
|
7412
|
-
// TODO: this method fails under certain edge cases
|
|
7413
|
-
// like for example, when angle is 45 degrees so sin(theta) == cos(theta)
|
|
7414
|
-
const theta = degreesToRadians(orientation);
|
|
7415
|
-
const orientationSine = Math.sin(theta);
|
|
7416
|
-
const orientationCosine = Math.cos(theta);
|
|
7417
|
-
const oldWidth = (Math.abs(width * orientationCosine) - Math.abs(height * orientationSine)) / (orientationCosine * orientationCosine - orientationSine * orientationSine);
|
|
7418
|
-
const oldHeight = (Math.abs(width * orientationSine) - Math.abs(height * orientationCosine)) / (orientationSine * orientationSine - orientationCosine * orientationCosine);
|
|
7419
|
-
return [oldWidth, oldHeight];
|
|
7420
|
-
};
|
|
7421
|
-
|
|
7422
7495
|
/**
|
|
7423
7496
|
* Thickness of the invisible path around a connection used to make it easier to click on, in diagram units.
|
|
7424
7497
|
* @private
|
|
@@ -7453,7 +7526,7 @@ class DiagramCanvas {
|
|
|
7453
7526
|
* @param config The configuration object used to set the parameters of this canvas.
|
|
7454
7527
|
*/
|
|
7455
7528
|
constructor(parentComponent, config) {
|
|
7456
|
-
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;
|
|
7457
7530
|
this.backgroundPatternId = `daga-background-pattern-id-${DiagramCanvas.canvasCount++}`;
|
|
7458
7531
|
this.zoomTransform = d3__namespace.zoomIdentity;
|
|
7459
7532
|
// used to distinguish drags from clicks when dragging elements and during multiple selection
|
|
@@ -7481,12 +7554,13 @@ class DiagramCanvas {
|
|
|
7481
7554
|
this.panRate = ((_z = config.canvas) === null || _z === void 0 ? void 0 : _z.panRate) || 100;
|
|
7482
7555
|
this.inferConnectionType = ((_0 = config.connectionSettings) === null || _0 === void 0 ? void 0 : _0.inferConnectionType) || false;
|
|
7483
7556
|
this.autoTightenConnections = ((_1 = config.connectionSettings) === null || _1 === void 0 ? void 0 : _1.autoTighten) !== false;
|
|
7484
|
-
this.
|
|
7485
|
-
this.
|
|
7486
|
-
this.
|
|
7487
|
-
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;
|
|
7488
7562
|
this.multipleSelectionOn = false;
|
|
7489
|
-
this.priorityThresholds = ((
|
|
7563
|
+
this.priorityThresholds = ((_7 = config.canvas) === null || _7 === void 0 ? void 0 : _7.priorityThresholds) || [];
|
|
7490
7564
|
this.priorityThreshold = this.priorityThresholds ? this.priorityThresholds[0] : undefined;
|
|
7491
7565
|
this.layoutFormat = config.layoutFormat;
|
|
7492
7566
|
this.userActions = config.userActions || {};
|
|
@@ -7513,7 +7587,7 @@ class DiagramCanvas {
|
|
|
7513
7587
|
const connectionType = new DiagramConnectionType(Object.assign(Object.assign({}, config.connectionTypeDefaults), connectionTypeConfig));
|
|
7514
7588
|
this.model.connections.types.add(connectionType);
|
|
7515
7589
|
}
|
|
7516
|
-
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;
|
|
7517
7591
|
}
|
|
7518
7592
|
}
|
|
7519
7593
|
addValidator(validator) {
|
|
@@ -7769,7 +7843,14 @@ class DiagramCanvas {
|
|
|
7769
7843
|
}
|
|
7770
7844
|
}
|
|
7771
7845
|
getViewCoordinates() {
|
|
7772
|
-
|
|
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];
|
|
7773
7854
|
}
|
|
7774
7855
|
translateBy(x, y) {
|
|
7775
7856
|
if (!isNaN(x) && !isNaN(y)) {
|
|
@@ -7781,12 +7862,42 @@ class DiagramCanvas {
|
|
|
7781
7862
|
this.zoomBehavior.translateTo(this.selectCanvasView(), x, y);
|
|
7782
7863
|
}
|
|
7783
7864
|
}
|
|
7784
|
-
|
|
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) {
|
|
7785
7896
|
var _a;
|
|
7786
7897
|
// if there are no nodes, we have nothing to do here
|
|
7787
7898
|
if (this.model.nodes.length > 0) {
|
|
7788
7899
|
const canvasViewBoundingBox = (_a = this.selectCanvasView().select('rect').node()) === null || _a === void 0 ? void 0 : _a.getBBox();
|
|
7789
|
-
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();
|
|
7790
7901
|
const minimumX = Math.min(...nonRemovedNodes.map(n => n.coords[0]));
|
|
7791
7902
|
const maximumX = Math.max(...nonRemovedNodes.map(n => n.coords[0] + n.width));
|
|
7792
7903
|
const averageX = (minimumX + maximumX) / 2;
|
|
@@ -7801,12 +7912,12 @@ class DiagramCanvas {
|
|
|
7801
7912
|
* (windowRangeX / rangeX) is the zoom level to fit everything horizontally
|
|
7802
7913
|
* (windowRangeY / rangeY) is the zoom level to fit everything vertically
|
|
7803
7914
|
* the minimum between them is the zoom to fit everything in the screen both horizontally and vertically
|
|
7804
|
-
* 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
|
|
7805
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
|
|
7806
7918
|
*/
|
|
7807
|
-
const zoom = Math.min(windowRangeX / rangeX, windowRangeY / rangeY, 1);
|
|
7808
|
-
this.
|
|
7809
|
-
this.zoomTo(zoom);
|
|
7919
|
+
const zoom = Math.min(windowRangeX / rangeX, windowRangeY / rangeY, maxZoomLevel !== undefined ? maxZoomLevel : 1);
|
|
7920
|
+
this.zoomAndPanTo(averageX, averageY, zoom, duration);
|
|
7810
7921
|
}
|
|
7811
7922
|
}
|
|
7812
7923
|
getClosestGridPoint(point) {
|
|
@@ -7862,7 +7973,7 @@ class DiagramCanvas {
|
|
|
7862
7973
|
updateNodesInView(...ids) {
|
|
7863
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);
|
|
7864
7975
|
const exitSelection = updateSelection.exit();
|
|
7865
|
-
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}`);
|
|
7866
7977
|
if (ids && ids.length > 0) {
|
|
7867
7978
|
updateSelection = updateSelection.filter(d => ids.includes(d.id));
|
|
7868
7979
|
}
|
|
@@ -7925,28 +8036,28 @@ class DiagramCanvas {
|
|
|
7925
8036
|
this.secondaryButton = false;
|
|
7926
8037
|
}));
|
|
7927
8038
|
initializeLook(enterSelection);
|
|
7928
|
-
enterSelection.filter('.resizable-x').append('line').attr('class', 'left-resizer').attr('stroke', 'transparent').attr('stroke-width',
|
|
7929
|
-
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) {
|
|
7930
8041
|
setCursorStyle(exports.CursorStyle.EWResize);
|
|
7931
8042
|
}
|
|
7932
8043
|
}).on(exports.Events.MouseOut, (_event, d) => {
|
|
7933
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8044
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
|
|
7934
8045
|
setCursorStyle();
|
|
7935
8046
|
}
|
|
7936
8047
|
}).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
|
|
7937
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8048
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
|
|
7938
8049
|
setCursorStyle(exports.CursorStyle.EWResize);
|
|
7939
8050
|
this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
|
|
7940
8051
|
} else {
|
|
7941
8052
|
setCursorStyle(exports.CursorStyle.NotAllowed);
|
|
7942
8053
|
}
|
|
7943
8054
|
}).on(exports.DragEvents.Drag, (event, d) => {
|
|
7944
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8055
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
|
|
7945
8056
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7946
8057
|
d.stretch(exports.Side.Left, d.coords[0] - pointerCoords[0]);
|
|
7947
8058
|
}
|
|
7948
8059
|
}).on(exports.DragEvents.End, (event, d) => {
|
|
7949
|
-
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) {
|
|
7950
8061
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7951
8062
|
if (this.snapToGrid) {
|
|
7952
8063
|
pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
|
|
@@ -7961,28 +8072,28 @@ class DiagramCanvas {
|
|
|
7961
8072
|
}
|
|
7962
8073
|
setCursorStyle();
|
|
7963
8074
|
}));
|
|
7964
|
-
enterSelection.filter('.resizable-y').append('line').attr('class', 'top-resizer').attr('stroke', 'transparent').attr('stroke-width',
|
|
7965
|
-
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) {
|
|
7966
8077
|
setCursorStyle(exports.CursorStyle.NSResize);
|
|
7967
8078
|
}
|
|
7968
8079
|
}).on(exports.Events.MouseOut, (_event, d) => {
|
|
7969
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8080
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
|
|
7970
8081
|
setCursorStyle();
|
|
7971
8082
|
}
|
|
7972
8083
|
}).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
|
|
7973
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8084
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
|
|
7974
8085
|
setCursorStyle(exports.CursorStyle.NSResize);
|
|
7975
8086
|
this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
|
|
7976
8087
|
} else {
|
|
7977
8088
|
setCursorStyle(exports.CursorStyle.NotAllowed);
|
|
7978
8089
|
}
|
|
7979
8090
|
}).on(exports.DragEvents.Drag, (event, d) => {
|
|
7980
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8091
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
|
|
7981
8092
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7982
8093
|
d.stretch(exports.Side.Top, d.coords[1] - pointerCoords[1]);
|
|
7983
8094
|
}
|
|
7984
8095
|
}).on(exports.DragEvents.End, (event, d) => {
|
|
7985
|
-
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) {
|
|
7986
8097
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7987
8098
|
if (this.snapToGrid) {
|
|
7988
8099
|
pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
|
|
@@ -7997,28 +8108,28 @@ class DiagramCanvas {
|
|
|
7997
8108
|
}
|
|
7998
8109
|
setCursorStyle();
|
|
7999
8110
|
}));
|
|
8000
|
-
enterSelection.filter('.resizable-x').append('line').attr('class', 'right-resizer').attr('stroke', 'transparent').attr('stroke-width',
|
|
8001
|
-
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) {
|
|
8002
8113
|
setCursorStyle(exports.CursorStyle.EWResize);
|
|
8003
8114
|
}
|
|
8004
8115
|
}).on(exports.Events.MouseOut, (_event, d) => {
|
|
8005
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8116
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
|
|
8006
8117
|
setCursorStyle();
|
|
8007
8118
|
}
|
|
8008
8119
|
}).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
|
|
8009
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8120
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
|
|
8010
8121
|
setCursorStyle(exports.CursorStyle.EWResize);
|
|
8011
8122
|
this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
|
|
8012
8123
|
} else {
|
|
8013
8124
|
setCursorStyle(exports.CursorStyle.NotAllowed);
|
|
8014
8125
|
}
|
|
8015
8126
|
}).on(exports.DragEvents.Drag, (event, d) => {
|
|
8016
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8127
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
|
|
8017
8128
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
8018
8129
|
d.stretch(exports.Side.Right, pointerCoords[0] - (d.coords[0] + d.width));
|
|
8019
8130
|
}
|
|
8020
8131
|
}).on(exports.DragEvents.End, (event, d) => {
|
|
8021
|
-
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) {
|
|
8022
8133
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
8023
8134
|
if (this.snapToGrid) {
|
|
8024
8135
|
pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[2], pointerCoords[1] - d.type.snapToGridOffset[3]]);
|
|
@@ -8033,28 +8144,28 @@ class DiagramCanvas {
|
|
|
8033
8144
|
}
|
|
8034
8145
|
setCursorStyle();
|
|
8035
8146
|
}));
|
|
8036
|
-
enterSelection.filter('.resizable-y').append('line').attr('class', 'bottom-resizer').attr('stroke', 'transparent').attr('stroke-width',
|
|
8037
|
-
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) {
|
|
8038
8149
|
setCursorStyle(exports.CursorStyle.NSResize);
|
|
8039
8150
|
}
|
|
8040
8151
|
}).on(exports.Events.MouseOut, (_event, d) => {
|
|
8041
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8152
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
|
|
8042
8153
|
setCursorStyle();
|
|
8043
8154
|
}
|
|
8044
8155
|
}).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
|
|
8045
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8156
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
|
|
8046
8157
|
setCursorStyle(exports.CursorStyle.NSResize);
|
|
8047
8158
|
this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
|
|
8048
8159
|
} else {
|
|
8049
8160
|
setCursorStyle(exports.CursorStyle.NotAllowed);
|
|
8050
8161
|
}
|
|
8051
8162
|
}).on(exports.DragEvents.Drag, (event, d) => {
|
|
8052
|
-
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.
|
|
8163
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
|
|
8053
8164
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
8054
8165
|
d.stretch(exports.Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height));
|
|
8055
8166
|
}
|
|
8056
8167
|
}).on(exports.DragEvents.End, (event, d) => {
|
|
8057
|
-
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) {
|
|
8058
8169
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
8059
8170
|
if (this.snapToGrid) {
|
|
8060
8171
|
if (this.snapToGrid) {
|
|
@@ -8073,17 +8184,17 @@ class DiagramCanvas {
|
|
|
8073
8184
|
}));
|
|
8074
8185
|
mergeSelection.attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).attr('opacity', d => d.removed ? 0.5 : 1);
|
|
8075
8186
|
updateLook(mergeSelection);
|
|
8076
|
-
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);
|
|
8077
|
-
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);
|
|
8078
|
-
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);
|
|
8079
|
-
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);
|
|
8080
8191
|
}
|
|
8081
8192
|
updateSectionsInView(...ids) {
|
|
8082
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);
|
|
8083
8194
|
const exitSelection = updateSelection.exit();
|
|
8084
8195
|
const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', d => {
|
|
8085
8196
|
var _a;
|
|
8086
|
-
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}`;
|
|
8087
8198
|
});
|
|
8088
8199
|
if (ids && ids.length > 0) {
|
|
8089
8200
|
updateSelection = updateSelection.filter(d => ids.includes(d.id));
|
|
@@ -8164,7 +8275,7 @@ class DiagramCanvas {
|
|
|
8164
8275
|
this.secondaryButton = false;
|
|
8165
8276
|
}));
|
|
8166
8277
|
initializeLook(enterSelection);
|
|
8167
|
-
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) => {
|
|
8168
8279
|
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
|
|
8169
8280
|
setCursorStyle(exports.CursorStyle.EWResize);
|
|
8170
8281
|
}
|
|
@@ -8198,7 +8309,7 @@ class DiagramCanvas {
|
|
|
8198
8309
|
}
|
|
8199
8310
|
setCursorStyle();
|
|
8200
8311
|
}));
|
|
8201
|
-
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) => {
|
|
8202
8313
|
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
|
|
8203
8314
|
setCursorStyle(exports.CursorStyle.NSResize);
|
|
8204
8315
|
}
|
|
@@ -8232,7 +8343,7 @@ class DiagramCanvas {
|
|
|
8232
8343
|
}
|
|
8233
8344
|
setCursorStyle();
|
|
8234
8345
|
}));
|
|
8235
|
-
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) => {
|
|
8236
8347
|
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
|
|
8237
8348
|
setCursorStyle(exports.CursorStyle.EWResize);
|
|
8238
8349
|
}
|
|
@@ -8266,7 +8377,7 @@ class DiagramCanvas {
|
|
|
8266
8377
|
}
|
|
8267
8378
|
setCursorStyle();
|
|
8268
8379
|
}));
|
|
8269
|
-
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) => {
|
|
8270
8381
|
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
|
|
8271
8382
|
setCursorStyle(exports.CursorStyle.NSResize);
|
|
8272
8383
|
}
|
|
@@ -8302,10 +8413,10 @@ class DiagramCanvas {
|
|
|
8302
8413
|
}));
|
|
8303
8414
|
mergeSelection.attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).attr('opacity', d => d.removed ? 0.5 : 1);
|
|
8304
8415
|
updateLook(mergeSelection);
|
|
8305
|
-
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);
|
|
8306
|
-
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);
|
|
8307
|
-
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);
|
|
8308
|
-
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);
|
|
8309
8420
|
}
|
|
8310
8421
|
updatePortsInView(...ids) {
|
|
8311
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);
|
|
@@ -8390,14 +8501,14 @@ class DiagramCanvas {
|
|
|
8390
8501
|
}
|
|
8391
8502
|
}
|
|
8392
8503
|
}).on(exports.DragEvents.Drag, (event, d) => {
|
|
8393
|
-
var _a, _b, _c, _d;
|
|
8504
|
+
var _a, _b, _c, _d, _e;
|
|
8394
8505
|
if (this.multipleSelectionOn || this.secondaryButton) {
|
|
8395
8506
|
this.continueMultipleSelection(event);
|
|
8396
8507
|
} else {
|
|
8397
8508
|
if (this.canUserPerformAction(exports.DiagramActions.AddConnection) && !d.removed) {
|
|
8398
8509
|
if (this.unfinishedConnection !== undefined) {
|
|
8399
8510
|
const endCoords = [event.x, event.y];
|
|
8400
|
-
(_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));
|
|
8401
8512
|
const unfinishedConnectionGhostNode = (_d = this.unfinishedConnectionTracer) === null || _d === void 0 ? void 0 : _d.node();
|
|
8402
8513
|
if (unfinishedConnectionGhostNode) {
|
|
8403
8514
|
let margin = 2;
|
|
@@ -8412,6 +8523,7 @@ class DiagramCanvas {
|
|
|
8412
8523
|
this.unfinishedConnection.endCoords = endCoords;
|
|
8413
8524
|
}
|
|
8414
8525
|
this.updateConnectionsInView(UNFINISHED_CONNECTION_ID);
|
|
8526
|
+
(_e = this.unfinishedConnectionPort) === null || _e === void 0 ? void 0 : _e.raise(false);
|
|
8415
8527
|
// highlight closest target port
|
|
8416
8528
|
if (this.model.ports.length > 0) {
|
|
8417
8529
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
@@ -8545,29 +8657,29 @@ class DiagramCanvas {
|
|
|
8545
8657
|
enterSelection.select('g.diagram-connection-end-label').append('text').style('user-select', 'none');
|
|
8546
8658
|
mergeSelection.attr('opacity', d => d.removed ? 0.5 : 1).select('path.diagram-connection-path').attr('d', d => {
|
|
8547
8659
|
var _a, _b;
|
|
8548
|
-
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);
|
|
8549
|
-
}).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');
|
|
8550
8662
|
mergeSelection.select('path.diagram-connection-path-box').attr('d', d => {
|
|
8551
8663
|
var _a, _b;
|
|
8552
|
-
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);
|
|
8553
8665
|
}).attr('stroke', 'transparent')
|
|
8554
8666
|
// allow generating pointer events even when it is transparent
|
|
8555
|
-
.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');
|
|
8556
8668
|
mergeSelection.data().forEach(connection => {
|
|
8557
8669
|
this.updateConnectionLabelsInView(connection);
|
|
8558
8670
|
this.updateConnectionMarkersInView(connection);
|
|
8559
8671
|
});
|
|
8560
8672
|
}
|
|
8561
8673
|
updateFieldsInView(...ids) {
|
|
8562
|
-
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);
|
|
8563
8675
|
const exitSelection = updateSelection.exit();
|
|
8564
|
-
const enterSelection = updateSelection.enter().append('
|
|
8676
|
+
const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', 'diagram-field');
|
|
8565
8677
|
if (ids && ids.length > 0) {
|
|
8566
8678
|
updateSelection = updateSelection.filter(d => ids.includes(d.id));
|
|
8567
8679
|
}
|
|
8568
8680
|
const mergeSelection = enterSelection.merge(updateSelection);
|
|
8569
8681
|
exitSelection.remove();
|
|
8570
|
-
enterSelection.
|
|
8682
|
+
enterSelection.on(exports.Events.MouseOver, (_event, d) => {
|
|
8571
8683
|
if (!this.dragging) {
|
|
8572
8684
|
this.userHighlight.focusOn(d);
|
|
8573
8685
|
this.diagramEvent$.next(new DiagramHighlightedEvent(d));
|
|
@@ -8604,22 +8716,7 @@ class DiagramCanvas {
|
|
|
8604
8716
|
this.diagramEvent$.next(diagramEvent);
|
|
8605
8717
|
if (!diagramEvent.defaultPrevented && this.canUserPerformAction(exports.DiagramActions.EditField) && d.editable && !d.removed) {
|
|
8606
8718
|
this.currentAction = new EditFieldAction(this, d.id, d.text, '');
|
|
8607
|
-
this.
|
|
8608
|
-
// (_text)
|
|
8609
|
-
/*
|
|
8610
|
-
Empty for now
|
|
8611
|
-
We should create a better function to stretch the root element as the text expands
|
|
8612
|
-
Bear in mind that DiagramNode.setGeometry() calls DiagramNode.raise(), which breaks the input field
|
|
8613
|
-
*/
|
|
8614
|
-
}, text => {
|
|
8615
|
-
d.text = text;
|
|
8616
|
-
if (this.currentAction instanceof EditFieldAction) {
|
|
8617
|
-
this.currentAction.to = text;
|
|
8618
|
-
this.currentAction.do();
|
|
8619
|
-
this.actionStack.add(this.currentAction);
|
|
8620
|
-
this.currentAction = undefined;
|
|
8621
|
-
}
|
|
8622
|
-
});
|
|
8719
|
+
this.openTextInput(d.id);
|
|
8623
8720
|
}
|
|
8624
8721
|
}).call(d3__namespace.drag().filter(event => {
|
|
8625
8722
|
this.secondaryButton = isSecondaryButton(event);
|
|
@@ -8673,18 +8770,25 @@ class DiagramCanvas {
|
|
|
8673
8770
|
}
|
|
8674
8771
|
}
|
|
8675
8772
|
this.secondaryButton = false;
|
|
8676
|
-
}))
|
|
8677
|
-
|
|
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');
|
|
8678
8782
|
}
|
|
8679
8783
|
updateObjectsInView(...ids) {
|
|
8680
|
-
let updateSelection = this.selectCanvasElements().selectAll('
|
|
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);
|
|
8681
8785
|
const exitSelection = updateSelection.exit();
|
|
8682
|
-
const enterSelection = updateSelection.enter().append('
|
|
8786
|
+
const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', 'diagram-object');
|
|
8683
8787
|
if (ids && ids.length > 0) {
|
|
8684
8788
|
updateSelection = updateSelection.filter(d => ids.includes(d.id));
|
|
8685
8789
|
}
|
|
8686
8790
|
const mergeSelection = enterSelection.merge(updateSelection);
|
|
8687
|
-
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);
|
|
8688
8792
|
exitSelection.remove();
|
|
8689
8793
|
enterSelection.on(exports.Events.ContextMenu, (event, d) => {
|
|
8690
8794
|
if (this.dragging) {
|
|
@@ -8720,14 +8824,14 @@ class DiagramCanvas {
|
|
|
8720
8824
|
}));
|
|
8721
8825
|
}
|
|
8722
8826
|
updateDecoratorsInView(...ids) {
|
|
8723
|
-
let updateSelection = this.selectCanvasElements().selectAll('
|
|
8827
|
+
let updateSelection = this.selectCanvasElements().selectAll('g.diagram-decorator').data(this.model.decorators.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
|
|
8724
8828
|
const exitSelection = updateSelection.exit();
|
|
8725
|
-
const enterSelection = updateSelection.enter().append('
|
|
8829
|
+
const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', 'diagram-decorator');
|
|
8726
8830
|
if (ids && ids.length > 0) {
|
|
8727
8831
|
updateSelection = updateSelection.filter(d => ids.includes(d.id));
|
|
8728
8832
|
}
|
|
8729
8833
|
const mergeSelection = enterSelection.merge(updateSelection);
|
|
8730
|
-
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);
|
|
8731
8835
|
exitSelection.remove();
|
|
8732
8836
|
enterSelection.on(exports.Events.MouseOver, (_event, d) => {
|
|
8733
8837
|
if (!this.dragging) {
|
|
@@ -8906,10 +9010,10 @@ class DiagramCanvas {
|
|
|
8906
9010
|
pathStartLabelPoint = pathNode.getPointAtLength(getLeftMargin(labelConfiguration) + boundingWidth / 2);
|
|
8907
9011
|
break;
|
|
8908
9012
|
case exports.Side.Top:
|
|
8909
|
-
pathStartLabelPoint = pathNode.getPointAtLength(getBottomMargin(labelConfiguration) +
|
|
9013
|
+
pathStartLabelPoint = pathNode.getPointAtLength(getBottomMargin(labelConfiguration) + boundingHeight / 2);
|
|
8910
9014
|
break;
|
|
8911
9015
|
case exports.Side.Bottom:
|
|
8912
|
-
pathStartLabelPoint = pathNode.getPointAtLength(getTopMargin(labelConfiguration) +
|
|
9016
|
+
pathStartLabelPoint = pathNode.getPointAtLength(getTopMargin(labelConfiguration) + boundingHeight / 2);
|
|
8913
9017
|
break;
|
|
8914
9018
|
default:
|
|
8915
9019
|
pathStartLabelPoint = pathNode.getPointAtLength(Math.max(getLeftMargin(labelConfiguration) + boundingWidth / 2, getRightMargin(labelConfiguration) + boundingWidth / 2, getTopMargin(labelConfiguration) + boundingHeight / 2, getBottomMargin(labelConfiguration) + boundingHeight / 2));
|
|
@@ -8944,10 +9048,10 @@ class DiagramCanvas {
|
|
|
8944
9048
|
pathEndLabelPoint = pathNode.getPointAtLength(pathLength - (getLeftMargin(labelConfiguration) + boundingWidth / 2));
|
|
8945
9049
|
break;
|
|
8946
9050
|
case exports.Side.Top:
|
|
8947
|
-
pathEndLabelPoint = pathNode.getPointAtLength(pathLength - (getBottomMargin(labelConfiguration) +
|
|
9051
|
+
pathEndLabelPoint = pathNode.getPointAtLength(pathLength - (getBottomMargin(labelConfiguration) + boundingHeight / 2));
|
|
8948
9052
|
break;
|
|
8949
9053
|
case exports.Side.Bottom:
|
|
8950
|
-
pathEndLabelPoint = pathNode.getPointAtLength(pathLength - (getTopMargin(labelConfiguration) +
|
|
9054
|
+
pathEndLabelPoint = pathNode.getPointAtLength(pathLength - (getTopMargin(labelConfiguration) + boundingHeight / 2));
|
|
8951
9055
|
break;
|
|
8952
9056
|
default:
|
|
8953
9057
|
pathEndLabelPoint = pathNode.getPointAtLength(pathLength - Math.max(getLeftMargin(labelConfiguration) + boundingWidth / 2, getRightMargin(labelConfiguration) + boundingWidth / 2, getTopMargin(labelConfiguration) + boundingHeight / 2, getBottomMargin(labelConfiguration) + boundingHeight / 2));
|
|
@@ -9102,6 +9206,7 @@ class DiagramCanvas {
|
|
|
9102
9206
|
if (port.allowsOutgoing || port.allowsIncoming) {
|
|
9103
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)) {
|
|
9104
9208
|
this.unfinishedConnection = new DiagramConnection(this.model, this.connectionType, port, undefined, UNFINISHED_CONNECTION_ID);
|
|
9209
|
+
this.unfinishedConnectionPort = port;
|
|
9105
9210
|
} else {
|
|
9106
9211
|
if (this.inferConnectionType) {
|
|
9107
9212
|
let differentConnectionType = this.model.connections.types.all().find(t => {
|
|
@@ -9116,6 +9221,7 @@ class DiagramCanvas {
|
|
|
9116
9221
|
}
|
|
9117
9222
|
if (differentConnectionType !== undefined) {
|
|
9118
9223
|
this.unfinishedConnection = new DiagramConnection(this.model, differentConnectionType, port, undefined, UNFINISHED_CONNECTION_ID);
|
|
9224
|
+
this.unfinishedConnectionPort = port;
|
|
9119
9225
|
}
|
|
9120
9226
|
}
|
|
9121
9227
|
}
|
|
@@ -9189,6 +9295,7 @@ class DiagramCanvas {
|
|
|
9189
9295
|
(_b = this.unfinishedConnection) === null || _b === void 0 ? void 0 : _b.setEnd(undefined);
|
|
9190
9296
|
(_d = (_c = this.unfinishedConnection) === null || _c === void 0 ? void 0 : _c.select()) === null || _d === void 0 ? void 0 : _d.remove();
|
|
9191
9297
|
this.unfinishedConnection = undefined;
|
|
9298
|
+
this.unfinishedConnectionPort = undefined;
|
|
9192
9299
|
}
|
|
9193
9300
|
cancelAllUserActions() {
|
|
9194
9301
|
this.currentAction = undefined;
|
|
@@ -9200,7 +9307,28 @@ class DiagramCanvas {
|
|
|
9200
9307
|
canUserPerformAction(action) {
|
|
9201
9308
|
return this.userActions[action] !== false;
|
|
9202
9309
|
}
|
|
9203
|
-
|
|
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) {
|
|
9204
9332
|
// if we have a text input open, close it before creating a new one
|
|
9205
9333
|
this.removeInputField();
|
|
9206
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');
|
|
@@ -9210,16 +9338,16 @@ class DiagramCanvas {
|
|
|
9210
9338
|
let inputFieldHeight;
|
|
9211
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 => {
|
|
9212
9340
|
event.stopPropagation();
|
|
9213
|
-
|
|
9214
|
-
|
|
9215
|
-
if (event.key === exports.Keys.Escape) {
|
|
9216
|
-
const value = inputField.property('value');
|
|
9341
|
+
if (event.key === exports.Keys.Escape || event.key === exports.Keys.Enter && !multiline) {
|
|
9342
|
+
const value = inputField.property('value') || '';
|
|
9217
9343
|
this.removeInputField();
|
|
9218
9344
|
if (finishCallback) {
|
|
9219
9345
|
finishCallback(value);
|
|
9220
9346
|
}
|
|
9221
9347
|
}
|
|
9222
|
-
}).on(exports.Events.
|
|
9348
|
+
}).on(exports.Events.KeyUp, event => {
|
|
9349
|
+
event.stopPropagation();
|
|
9350
|
+
}).on(exports.Events.Input, event => {
|
|
9223
9351
|
const value = inputField.property('value');
|
|
9224
9352
|
inputField.attr('cols', numberOfColumns(value) + 1);
|
|
9225
9353
|
inputField.attr('rows', numberOfRows(value) + 1);
|
|
@@ -9262,13 +9390,54 @@ class DiagramCanvas {
|
|
|
9262
9390
|
}
|
|
9263
9391
|
minimumSizeOfField(field) {
|
|
9264
9392
|
var _a, _b;
|
|
9265
|
-
const
|
|
9266
|
-
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) {
|
|
9267
9395
|
// happens when a field has been created but not updated in view yet
|
|
9268
9396
|
return [0, 0];
|
|
9269
9397
|
}
|
|
9270
|
-
const
|
|
9271
|
-
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
|
+
}
|
|
9272
9441
|
}
|
|
9273
9442
|
/**
|
|
9274
9443
|
* Method to call to start the moving of a node triggered by a user drag event.
|
|
@@ -9300,6 +9469,7 @@ class DiagramCanvas {
|
|
|
9300
9469
|
}
|
|
9301
9470
|
this.userHighlight.clear();
|
|
9302
9471
|
this.dragging = true;
|
|
9472
|
+
this.diagramEvent$.next(new DiagramDraggingNodeEvent(d));
|
|
9303
9473
|
}
|
|
9304
9474
|
}
|
|
9305
9475
|
/**
|
|
@@ -10325,6 +10495,7 @@ exports.DiagramContextMenu = DiagramContextMenu;
|
|
|
10325
10495
|
exports.DiagramDecorator = DiagramDecorator;
|
|
10326
10496
|
exports.DiagramDecoratorSet = DiagramDecoratorSet;
|
|
10327
10497
|
exports.DiagramDoubleClickEvent = DiagramDoubleClickEvent;
|
|
10498
|
+
exports.DiagramDraggingNodeEvent = DiagramDraggingNodeEvent;
|
|
10328
10499
|
exports.DiagramElement = DiagramElement;
|
|
10329
10500
|
exports.DiagramElementSet = DiagramElementSet;
|
|
10330
10501
|
exports.DiagramEntitySet = DiagramEntitySet;
|