@metadev/daga 4.2.0 → 4.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js CHANGED
@@ -158,17 +158,67 @@ const translateCoordinate = (oldCoordinate, oldCoordinates, newCoordinates) => {
158
158
  return (oldCoordinate - oldCoordinates[0]) / (oldCoordinates[1] - oldCoordinates[0]) * (newCoordinates[1] - newCoordinates[0]) + newCoordinates[0];
159
159
  };
160
160
  /**
161
- * Moves the coordinates of the given point according to the given changes in coordinates.
161
+ * Moves the coordinates of the given point according to the given changes in coordinates and anchor points.
162
162
  * @public
163
163
  * @param oldPoint A point.
164
164
  * @param oldCoordsX A range of coordinates along the x axis.
165
165
  * @param oldCoordsY A range of coordinates along the y axis.
166
166
  * @param newCoordsX A range of coordinates along the x axis.
167
167
  * @param newCoordsY A range of coordinates along the y axis.
168
+ * @param anchorPointX The horizontal anchor point behavior.
169
+ * @param anchorPointY The vertical anchor point behavior.
168
170
  * @returns A new point.
169
171
  */
170
- const translatePoint = (oldPoint, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY) => {
171
- return [translateCoordinate(oldPoint[0], oldCoordsX, newCoordsX), translateCoordinate(oldPoint[1], oldCoordsY, newCoordsY)];
172
+ const translatePointWithAnchors = (oldPoint, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY, anchorPointX, anchorPointY) => {
173
+ const newX = (() => {
174
+ switch (anchorPointX) {
175
+ case 'start':
176
+ // Always maintain the same distance from the left edge
177
+ return newCoordsX[0] + (oldPoint[0] - oldCoordsX[0]);
178
+ case 'end':
179
+ // Always maintain the same distance from the right edge
180
+ return newCoordsX[1] - (oldCoordsX[1] - oldPoint[0]);
181
+ case 'middle':
182
+ {
183
+ // Always maintain the same relative position from the center
184
+ const oldCenterX = (oldCoordsX[0] + oldCoordsX[1]) / 2;
185
+ const newCenterX = (newCoordsX[0] + newCoordsX[1]) / 2;
186
+ const oldWidth = oldCoordsX[1] - oldCoordsX[0];
187
+ const newWidth = newCoordsX[1] - newCoordsX[0];
188
+ const relativePosition = (oldPoint[0] - oldCenterX) / oldWidth;
189
+ return newCenterX + relativePosition * newWidth;
190
+ }
191
+ case 'floating':
192
+ default:
193
+ // Scale proportionally (original behavior)
194
+ return translateCoordinate(oldPoint[0], oldCoordsX, newCoordsX);
195
+ }
196
+ })();
197
+ const newY = (() => {
198
+ switch (anchorPointY) {
199
+ case 'start':
200
+ // Always maintain the same distance from the top edge
201
+ return newCoordsY[0] + (oldPoint[1] - oldCoordsY[0]);
202
+ case 'end':
203
+ // Always maintain the same distance from the bottom edge
204
+ return newCoordsY[1] - (oldCoordsY[1] - oldPoint[1]);
205
+ case 'middle':
206
+ {
207
+ // Always maintain the same relative position from the center
208
+ const oldCenterY = (oldCoordsY[0] + oldCoordsY[1]) / 2;
209
+ const newCenterY = (newCoordsY[0] + newCoordsY[1]) / 2;
210
+ const oldHeight = oldCoordsY[1] - oldCoordsY[0];
211
+ const newHeight = newCoordsY[1] - newCoordsY[0];
212
+ const relativePosition = (oldPoint[1] - oldCenterY) / oldHeight;
213
+ return newCenterY + relativePosition * newHeight;
214
+ }
215
+ case 'floating':
216
+ default:
217
+ // Scale proportionally (original behavior)
218
+ return translateCoordinate(oldPoint[1], oldCoordsY, newCoordsY);
219
+ }
220
+ })();
221
+ return [newX, newY];
172
222
  };
173
223
  /**
174
224
  * Calculates the euclidean distance between two points.
@@ -265,6 +315,10 @@ exports.ZoomEvents = void 0;
265
315
  ZoomEvents["End"] = "end";
266
316
  })(exports.ZoomEvents || (exports.ZoomEvents = {}));
267
317
 
318
+ const escapeSelector = selector => {
319
+ return selector.replace(/([!"#$%&'()*+,\-./:;<=>?@[\\\]^`{|}])/g, '\\$1');
320
+ };
321
+
268
322
  /**
269
323
  * An enumeration of the possible shapes of a line.
270
324
  * @public
@@ -1022,10 +1076,6 @@ class DiagramEntitySet {
1022
1076
  }
1023
1077
  }
1024
1078
 
1025
- const escapeSelector = selector => {
1026
- return selector.replace(/([!"#$%&'()*+,\-./:;<=>?@[\\\]^`{|}])/g, '\\$1');
1027
- };
1028
-
1029
1079
  /**
1030
1080
  * Default priority value for diagram elements.
1031
1081
  * @private
@@ -1837,20 +1887,24 @@ class DiagramConnection extends DiagramElement {
1837
1887
  }
1838
1888
  set type(type) {
1839
1889
  var _a, _b;
1840
- (_b = (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.userSelection) === null || _b === void 0 ? void 0 : _b.openInPropertyEditor(undefined);
1841
- this._type = type;
1842
- if (this.valueSet) {
1843
- this.valueSet = new ValueSet(type.propertySet, this);
1890
+ if (type !== this._type) {
1891
+ this._type = type;
1892
+ if (this.valueSet) {
1893
+ this.valueSet = new ValueSet(type.propertySet, this);
1894
+ }
1895
+ (_b = (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.userSelection) === null || _b === void 0 ? void 0 : _b.openInPropertyEditor(this, false);
1896
+ this.updateInView();
1844
1897
  }
1845
- this.updateInView();
1846
1898
  }
1847
1899
  get typeString() {
1848
1900
  return this.type.id;
1849
1901
  }
1850
1902
  set typeString(typeString) {
1851
- const type = this.model.connections.types.get(typeString);
1852
- if (type) {
1853
- this.type = type;
1903
+ if (typeString !== this.type.id) {
1904
+ const type = this.model.connections.types.get(typeString);
1905
+ if (type) {
1906
+ this.type = type;
1907
+ }
1854
1908
  }
1855
1909
  }
1856
1910
  /**
@@ -2241,7 +2295,8 @@ const DIAGRAM_FIELD_DEFAULTS = {
2241
2295
  horizontalAlign: exports.HorizontalAlign.Center,
2242
2296
  verticalAlign: exports.VerticalAlign.Center,
2243
2297
  orientation: exports.Side.Top,
2244
- fit: false
2298
+ fit: false,
2299
+ shrink: true
2245
2300
  };
2246
2301
  /**
2247
2302
  * A field which displays text and is part of a diagram element.
@@ -2266,10 +2321,10 @@ class DiagramField extends DiagramElement {
2266
2321
  this._text = value;
2267
2322
  this.updateInView();
2268
2323
  if (this.fit) {
2269
- (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.fitFieldRootInView(this.id);
2324
+ (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.fitFieldRootInView(this.id, this.shrink);
2270
2325
  }
2271
2326
  }
2272
- constructor(model, rootElement, coords, width, height, fontSize, fontFamily, color, selectedColor, horizontalAlign, verticalAlign, orientation, text, editable, fit) {
2327
+ constructor(model, rootElement, coords, width, height, fontSize, fontFamily, color, selectedColor, horizontalAlign, verticalAlign, orientation, text, editable, fit, shrink) {
2273
2328
  const id = `${rootElement === null || rootElement === void 0 ? void 0 : rootElement.id}_field`;
2274
2329
  if (model.fields.get(id) !== undefined) {
2275
2330
  throw new Error('DiagramField for rootElement already exists');
@@ -2290,11 +2345,31 @@ class DiagramField extends DiagramElement {
2290
2345
  this.selectedColor = selectedColor;
2291
2346
  this.horizontalAlign = horizontalAlign;
2292
2347
  this.verticalAlign = verticalAlign;
2293
- this.orientation = orientation;
2348
+ if (!isNaN(Number(orientation))) {
2349
+ this.orientation = Number(orientation);
2350
+ } else {
2351
+ switch (orientation) {
2352
+ case exports.Side.Top:
2353
+ this.orientation = 0;
2354
+ break;
2355
+ case exports.Side.Right:
2356
+ this.orientation = 90;
2357
+ break;
2358
+ case exports.Side.Bottom:
2359
+ this.orientation = 180;
2360
+ break;
2361
+ case exports.Side.Left:
2362
+ this.orientation = 270;
2363
+ break;
2364
+ default:
2365
+ this.orientation = 0;
2366
+ }
2367
+ }
2294
2368
  this.defaultText = text;
2295
2369
  this._text = text;
2296
2370
  this.editable = editable;
2297
2371
  this.fit = fit;
2372
+ this.shrink = shrink;
2298
2373
  }
2299
2374
  get removed() {
2300
2375
  return this.selfRemoved || this.rootElement !== undefined && this.rootElement.removed;
@@ -2334,8 +2409,8 @@ class DiagramFieldSet extends DiagramElementSet {
2334
2409
  * 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.
2335
2410
  * @private
2336
2411
  */
2337
- new(rootElement, coords, fontSize, fontFamily, color, selectedColor, width, height, horizontalAlign, verticalAlign, orientation, text, editable, fit) {
2338
- const field = new DiagramField(this.model, rootElement, coords, width, height, fontSize, fontFamily, color, selectedColor, horizontalAlign, verticalAlign, orientation, text, editable, fit);
2412
+ new(rootElement, coords, fontSize, fontFamily, color, selectedColor, width, height, horizontalAlign, verticalAlign, orientation, text, editable, fit, shrink) {
2413
+ const field = new DiagramField(this.model, rootElement, coords, width, height, fontSize, fontFamily, color, selectedColor, horizontalAlign, verticalAlign, orientation, text, editable, fit, shrink);
2339
2414
  super.add(field);
2340
2415
  field.updateInView();
2341
2416
  // add this field to its root element
@@ -2566,6 +2641,8 @@ class DiagramSectionType {
2566
2641
  this.label = options.label || null;
2567
2642
  this.ports = options.ports || [];
2568
2643
  this.priority = options.priority || DEFAULT_PRIORITY;
2644
+ this.resizableX = options.resizableX;
2645
+ this.resizableY = options.resizableY;
2569
2646
  const looks = extractLooksFromConfig(options.look || DIAGRAM_NODE_LOOK_DEFAULTS);
2570
2647
  this.defaultLook = looks.defaultLook;
2571
2648
  this.selectedLook = looks.selectedLook;
@@ -2694,6 +2771,34 @@ class DiagramSection extends DiagramElement {
2694
2771
  var _a, _b, _c, _d, _e, _f;
2695
2772
  return ((_f = (_e = (_d = (_c = (_b = (_a = this.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.sectionGrid) === null || _c === void 0 ? void 0 : _c.sections) === null || _d === void 0 ? void 0 : _d[this.indexYInNode]) === null || _e === void 0 ? void 0 : _e[this.indexXInNode]) === null || _f === void 0 ? void 0 : _f.priority) || DEFAULT_PRIORITY;
2696
2773
  }
2774
+ /**
2775
+ * Returns whether this section can be resized horizontally.
2776
+ * If the section has a specific resizableX setting, it uses that.
2777
+ * Otherwise, it inherits from the parent node's resizableX setting.
2778
+ * @public
2779
+ */
2780
+ getResizableX() {
2781
+ var _a, _b;
2782
+ const sectionType = this.type;
2783
+ if ((sectionType === null || sectionType === void 0 ? void 0 : sectionType.resizableX) !== undefined) {
2784
+ return sectionType.resizableX;
2785
+ }
2786
+ return ((_b = (_a = this.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) || false;
2787
+ }
2788
+ /**
2789
+ * Returns whether this section can be resized vertically.
2790
+ * If the section has a specific resizableY setting, it uses that.
2791
+ * Otherwise, it inherits from the parent node's resizableY setting.
2792
+ * @public
2793
+ */
2794
+ getResizableY() {
2795
+ var _a, _b;
2796
+ const sectionType = this.type;
2797
+ if ((sectionType === null || sectionType === void 0 ? void 0 : sectionType.resizableY) !== undefined) {
2798
+ return sectionType.resizableY;
2799
+ }
2800
+ return ((_b = (_a = this.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) || false;
2801
+ }
2697
2802
  /**
2698
2803
  * Get the port of this section which is closest to the given coordinates.
2699
2804
  * @param coords A point in the diagram.
@@ -2852,7 +2957,7 @@ class DiagramSection extends DiagramElement {
2852
2957
  const newCoordsY = [this.coords[1], this.coords[1] + this.height];
2853
2958
  // Move ports to match the new coords.
2854
2959
  for (const port of this.ports) {
2855
- port.move(translatePoint(port.coords, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY));
2960
+ port.move(translatePointWithAnchors(port.coords, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY, port.anchorPointX, port.anchorPointY));
2856
2961
  }
2857
2962
  // Set label's dimensions as a function of ours.
2858
2963
  const type = this.type;
@@ -2864,7 +2969,7 @@ class DiagramSection extends DiagramElement {
2864
2969
  }
2865
2970
  // Move decorators to match the new coords.
2866
2971
  for (const decorator of this.decorators) {
2867
- decorator.move(translatePoint(decorator.coords, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY));
2972
+ decorator.move(translatePointWithAnchors(decorator.coords, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY, decorator.anchorPointX, decorator.anchorPointY));
2868
2973
  }
2869
2974
  // Update canvas.
2870
2975
  this.getConnections().forEach(c => c.tighten());
@@ -2897,7 +3002,7 @@ class DiagramSectionSet extends DiagramElementSet {
2897
3002
  if (sectionPorts && sectionPorts.length > 0) {
2898
3003
  for (let i = 0; i < sectionPorts.length; ++i) {
2899
3004
  const portConfig = sectionPorts[i];
2900
- const port = this.model.ports.new(portConfig.type !== undefined ? this.model.ports.types.get(portConfig.type) : undefined, section, [section.coords[0] + (portConfig.coords[0] || 0), section.coords[1] + (portConfig.coords[1] || 0)], portConfig.connectionPoint !== undefined ? [section.coords[0] + (portConfig.connectionPoint[0] || 0), section.coords[1] + (portConfig.connectionPoint[1] || 0)] : undefined, portConfig === null || portConfig === void 0 ? void 0 : portConfig.direction, `${section.id}_${i}`);
3005
+ const port = this.model.ports.new(portConfig.type !== undefined ? this.model.ports.types.get(portConfig.type) : undefined, section, [section.coords[0] + (portConfig.coords[0] || 0), section.coords[1] + (portConfig.coords[1] || 0)], portConfig.connectionPoint !== undefined ? [section.coords[0] + (portConfig.connectionPoint[0] || 0), section.coords[1] + (portConfig.connectionPoint[1] || 0)] : undefined, portConfig === null || portConfig === void 0 ? void 0 : portConfig.direction, `${section.id}_${i}`, portConfig.anchorPointX || 'floating', portConfig.anchorPointY || 'floating');
2901
3006
  if ((_e = port.type) === null || _e === void 0 ? void 0 : _e.label) {
2902
3007
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_f = port.type) === null || _f === void 0 ? void 0 : _f.label);
2903
3008
  const labelWidth = 6 * labelConfiguration.fontSize + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
@@ -2915,7 +3020,7 @@ class DiagramSectionSet extends DiagramElementSet {
2915
3020
  default:
2916
3021
  labelCoords = port.coords;
2917
3022
  }
2918
- 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);
3023
+ 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);
2919
3024
  }
2920
3025
  }
2921
3026
  }
@@ -2923,7 +3028,7 @@ class DiagramSectionSet extends DiagramElementSet {
2923
3028
  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;
2924
3029
  if (sectionLabel) {
2925
3030
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), sectionLabel);
2926
- 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);
3031
+ 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);
2927
3032
  }
2928
3033
  return section;
2929
3034
  }
@@ -3043,20 +3148,24 @@ class DiagramNode extends DiagramElement {
3043
3148
  }
3044
3149
  set type(type) {
3045
3150
  var _a, _b;
3046
- (_b = (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.userSelection) === null || _b === void 0 ? void 0 : _b.openInPropertyEditor(undefined);
3047
- this._type = type;
3048
- if (this.valueSet) {
3049
- this.valueSet = new ValueSet(type.propertySet, this);
3151
+ if (type !== this._type) {
3152
+ this._type = type;
3153
+ if (this.valueSet) {
3154
+ this.valueSet = new ValueSet(type.propertySet, this);
3155
+ }
3156
+ (_b = (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.userSelection) === null || _b === void 0 ? void 0 : _b.openInPropertyEditor(this, false);
3157
+ this.updateInView();
3050
3158
  }
3051
- this.updateInView();
3052
3159
  }
3053
3160
  get typeString() {
3054
3161
  return this.type.id;
3055
3162
  }
3056
3163
  set typeString(typeString) {
3057
- const type = this.model.nodes.types.get(typeString);
3058
- if (type) {
3059
- this.type = type;
3164
+ if (typeString !== this.type.id) {
3165
+ const type = this.model.nodes.types.get(typeString);
3166
+ if (type) {
3167
+ this.type = type;
3168
+ }
3060
3169
  }
3061
3170
  }
3062
3171
  /**
@@ -3356,21 +3465,42 @@ class DiagramNode extends DiagramElement {
3356
3465
  child.parent = undefined;
3357
3466
  }
3358
3467
  fitToChild(child) {
3468
+ // if the node includes sections, we stretch the sections as well when fitting to a child node
3469
+ // we assume it is most natural to stretch the last row and column of section
3470
+ // TODO: consider being able to configure which row or column gets stretched first
3471
+ const maxSectionIndexX = Math.max(...this.sections.map(s => s.indexXInNode));
3472
+ const maxSectionIndexY = Math.max(...this.sections.map(s => s.indexYInNode));
3359
3473
  const excessLeft = this.coords[0] - child.coords[0] + this.type.leftPadding;
3360
3474
  if (excessLeft >= 0) {
3361
- this.stretch(exports.Side.Left, excessLeft);
3475
+ if (this.sections.length > 0) {
3476
+ this.stretchSections(exports.Side.Left, excessLeft, maxSectionIndexX, maxSectionIndexY);
3477
+ } else {
3478
+ this.stretch(exports.Side.Left, excessLeft);
3479
+ }
3362
3480
  }
3363
3481
  const excessTop = this.coords[1] - child.coords[1] + this.type.topPadding;
3364
3482
  if (excessTop >= 0) {
3365
- this.stretch(exports.Side.Top, excessTop);
3483
+ if (this.sections.length > 0) {
3484
+ this.stretchSections(exports.Side.Top, excessTop, maxSectionIndexX, maxSectionIndexY);
3485
+ } else {
3486
+ this.stretch(exports.Side.Top, excessTop);
3487
+ }
3366
3488
  }
3367
3489
  const excessRight = child.coords[0] + child.width - (this.coords[0] + this.width) + this.type.rightPadding;
3368
3490
  if (excessRight >= 0) {
3369
- this.stretch(exports.Side.Right, excessRight);
3491
+ if (this.sections.length > 0) {
3492
+ this.stretchSections(exports.Side.Right, excessRight, maxSectionIndexX, maxSectionIndexY);
3493
+ } else {
3494
+ this.stretch(exports.Side.Right, excessRight);
3495
+ }
3370
3496
  }
3371
3497
  const excessBottom = child.coords[1] + child.height - (this.coords[1] + this.height) + this.type.bottomPadding;
3372
3498
  if (excessBottom >= 0) {
3373
- this.stretch(exports.Side.Bottom, excessBottom);
3499
+ if (this.sections.length > 0) {
3500
+ this.stretchSections(exports.Side.Bottom, excessBottom, maxSectionIndexX, maxSectionIndexY);
3501
+ } else {
3502
+ this.stretch(exports.Side.Bottom, excessBottom);
3503
+ }
3374
3504
  }
3375
3505
  if (this.parent) {
3376
3506
  // ensure this node also fits inside its parent after stretching
@@ -3585,7 +3715,7 @@ class DiagramNode extends DiagramElement {
3585
3715
  }
3586
3716
  // Move ports to match the new coords.
3587
3717
  for (const port of this.ports) {
3588
- port.move(translatePoint(port.coords, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY));
3718
+ port.move(translatePointWithAnchors(port.coords, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY, port.anchorPointX, port.anchorPointY));
3589
3719
  }
3590
3720
  // Set label's dimensions as a function of ours.
3591
3721
  if (this.label) {
@@ -3596,7 +3726,7 @@ class DiagramNode extends DiagramElement {
3596
3726
  }
3597
3727
  // Move decorators to match the new coords.
3598
3728
  for (const decorator of this.decorators) {
3599
- decorator.move(translatePoint(decorator.coords, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY));
3729
+ decorator.move(translatePointWithAnchors(decorator.coords, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY, decorator.anchorPointX, decorator.anchorPointY));
3600
3730
  }
3601
3731
  // Update canvas.
3602
3732
  this.getConnections().forEach(c => c.tighten());
@@ -3758,7 +3888,7 @@ class DiagramNodeSet extends DiagramElementSet {
3758
3888
  for (let i = 0; i < nodeType.ports.length; ++i) {
3759
3889
  const portConfig = nodeType.ports[i];
3760
3890
  const portType = portConfig.type !== undefined ? this.model.ports.types.get(portConfig.type) : undefined;
3761
- const port = this.model.ports.new(portType, node, [node.coords[0] + portConfig.coords[0], node.coords[1] + portConfig.coords[1]], portConfig.connectionPoint !== undefined ? [node.coords[0] + (portConfig.connectionPoint[0] || 0), node.coords[1] + (portConfig.connectionPoint[1] || 0)] : undefined, portConfig.direction, `${node.id}_port_${i}`);
3891
+ const port = this.model.ports.new(portType, node, [node.coords[0] + portConfig.coords[0], node.coords[1] + portConfig.coords[1]], portConfig.connectionPoint !== undefined ? [node.coords[0] + (portConfig.connectionPoint[0] || 0), node.coords[1] + (portConfig.connectionPoint[1] || 0)] : undefined, portConfig.direction, `${node.id}_port_${i}`, portConfig.anchorPointX || 'floating', portConfig.anchorPointY || 'floating');
3762
3892
  if ((_e = port.type) === null || _e === void 0 ? void 0 : _e.label) {
3763
3893
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_f = port.type) === null || _f === void 0 ? void 0 : _f.label);
3764
3894
  const labelWidth = 6 * labelConfiguration.fontSize + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
@@ -3776,20 +3906,20 @@ class DiagramNodeSet extends DiagramElementSet {
3776
3906
  default:
3777
3907
  labelCoords = port.coords;
3778
3908
  }
3779
- 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);
3909
+ 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);
3780
3910
  }
3781
3911
  }
3782
3912
  }
3783
3913
  // add node label
3784
3914
  if (nodeType.label) {
3785
3915
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), nodeType.label);
3786
- 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);
3916
+ 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);
3787
3917
  }
3788
3918
  // add node decorators
3789
3919
  if (nodeType.decorators.length > 0) {
3790
3920
  for (let i = 0; i < nodeType.decorators.length; ++i) {
3791
3921
  const decoratorConfig = nodeType.decorators[i];
3792
- this.model.decorators.new(node, [node.coords[0] + decoratorConfig.coords[0], node.coords[1] + decoratorConfig.coords[1]], decoratorConfig.width, decoratorConfig.height, node.getPriority(), decoratorConfig.html, `${node.id}_decorator_${i}`);
3922
+ this.model.decorators.new(node, [node.coords[0] + decoratorConfig.coords[0], node.coords[1] + decoratorConfig.coords[1]], decoratorConfig.width, decoratorConfig.height, node.getPriority(), decoratorConfig.html, `${node.id}_decorator_${i}`, decoratorConfig.anchorPointX || 'floating', decoratorConfig.anchorPointY || 'floating');
3793
3923
  }
3794
3924
  }
3795
3925
  node.valueSet.resetValues();
@@ -4026,20 +4156,25 @@ class DiagramPort extends DiagramElement {
4026
4156
  return this._type;
4027
4157
  }
4028
4158
  set type(type) {
4029
- this._type = type;
4030
- this.updateInView();
4159
+ if (type !== this._type) {
4160
+ this._type = type;
4161
+ this.updateInView();
4162
+ }
4031
4163
  }
4032
4164
  get typeString() {
4033
4165
  var _a;
4034
4166
  return (_a = this.type) === null || _a === void 0 ? void 0 : _a.id;
4035
4167
  }
4036
4168
  set typeString(typeString) {
4037
- if (typeString === undefined) {
4038
- this.type = undefined;
4039
- } else {
4040
- const type = this.model.ports.types.get(typeString);
4041
- if (type) {
4042
- this.type = type;
4169
+ var _a;
4170
+ if (typeString !== ((_a = this.type) === null || _a === void 0 ? void 0 : _a.id)) {
4171
+ if (typeString === undefined) {
4172
+ this.type = undefined;
4173
+ } else {
4174
+ const type = this.model.ports.types.get(typeString);
4175
+ if (type) {
4176
+ this.type = type;
4177
+ }
4043
4178
  }
4044
4179
  }
4045
4180
  }
@@ -4124,7 +4259,7 @@ class DiagramPort extends DiagramElement {
4124
4259
  get height() {
4125
4260
  return this.width;
4126
4261
  }
4127
- constructor(model, type, rootElement, coords, connectionPoint, direction, id) {
4262
+ constructor(model, type, rootElement, coords, connectionPoint, direction, id, anchorPointX = 'floating', anchorPointY = 'floating') {
4128
4263
  if (model.ports.get(id) !== undefined) {
4129
4264
  throw new Error(`DiagramPort with id "${id}" already exists`);
4130
4265
  }
@@ -4147,6 +4282,8 @@ class DiagramPort extends DiagramElement {
4147
4282
  this.coords = coords;
4148
4283
  this.connectionPoint = connectionPoint || coords;
4149
4284
  this.direction = direction;
4285
+ this.anchorPointX = anchorPointX;
4286
+ this.anchorPointY = anchorPointY;
4150
4287
  }
4151
4288
  get removed() {
4152
4289
  return this.selfRemoved || this.rootElement !== undefined && this.rootElement.removed;
@@ -4244,8 +4381,8 @@ class DiagramPortSet extends DiagramElementSet {
4244
4381
  * Instance a new port and add it to this set. This method is normally called when instancing an element with a port and it is rarely called by itself.
4245
4382
  * @private
4246
4383
  */
4247
- new(type, rootElement, coords, connectionPoint, direction, id) {
4248
- const port = new DiagramPort(this.model, type, rootElement, coords, connectionPoint, direction, id);
4384
+ new(type, rootElement, coords, connectionPoint, direction, id, anchorPointX = 'floating', anchorPointY = 'floating') {
4385
+ const port = new DiagramPort(this.model, type, rootElement, coords, connectionPoint, direction, id, anchorPointX, anchorPointY);
4249
4386
  super.add(port);
4250
4387
  port.updateInView();
4251
4388
  // add this port to its root element
@@ -4330,7 +4467,7 @@ class DagaImporter {
4330
4467
  // add node label
4331
4468
  if (newNodeType.label) {
4332
4469
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newNodeType.label);
4333
- 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.editable, labelConfiguration.fit);
4470
+ 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.editable, labelConfiguration.fit, labelConfiguration.shrink);
4334
4471
  newField.text = node.label;
4335
4472
  newNode.label = newField;
4336
4473
  model.fields.add(newField);
@@ -4352,7 +4489,7 @@ class DagaImporter {
4352
4489
  // add section label
4353
4490
  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) {
4354
4491
  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);
4355
- 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.editable, labelConfiguration.fit);
4492
+ 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.editable, labelConfiguration.fit, labelConfiguration.shrink);
4356
4493
  newField.text = section.label;
4357
4494
  newSection.label = newField;
4358
4495
  model.fields.add(newField);
@@ -4384,7 +4521,7 @@ class DagaImporter {
4384
4521
  default:
4385
4522
  labelCoords = newPort.coords;
4386
4523
  }
4387
- 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);
4524
+ 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);
4388
4525
  newField.text = port.label;
4389
4526
  newPort.label = newField;
4390
4527
  model.fields.add(newField);
@@ -4431,7 +4568,7 @@ class DagaImporter {
4431
4568
  default:
4432
4569
  labelCoords = newPort.coords;
4433
4570
  }
4434
- 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);
4571
+ 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);
4435
4572
  newField.text = port.label;
4436
4573
  newPort.label = newField;
4437
4574
  model.fields.add(newField);
@@ -4675,11 +4812,11 @@ class SetGeometryCollabAction {
4675
4812
  node.setGeometry(this.to);
4676
4813
  // Re-fit the labels, in case their text has changed since `this.to` was measured.
4677
4814
  if ((_a = node.label) === null || _a === void 0 ? void 0 : _a.fit) {
4678
- this.canvas.fitFieldRootInView(node.label.id);
4815
+ this.canvas.fitFieldRootInView(node.label.id, node.label.shrink);
4679
4816
  }
4680
4817
  for (const section of node.sections) {
4681
4818
  if ((_b = section.label) === null || _b === void 0 ? void 0 : _b.fit) {
4682
- this.canvas.fitFieldRootInView(section.label.id);
4819
+ this.canvas.fitFieldRootInView(section.label.id, section.label.shrink);
4683
4820
  }
4684
4821
  }
4685
4822
  (_c = node.parent) === null || _c === void 0 ? void 0 : _c.fitToChild(node);
@@ -5800,7 +5937,7 @@ class DiagramHighlightedEvent extends DiagramEvent {
5800
5937
  * @see DiagramSection
5801
5938
  */
5802
5939
  class DiagramDecorator extends DiagramElement {
5803
- constructor(model, rootElement, coords, width, height, priority, html, id) {
5940
+ constructor(model, rootElement, coords, width, height, priority, html, id, anchorPointX = 'floating', anchorPointY = 'floating') {
5804
5941
  if (model.objects.get(id) !== undefined) {
5805
5942
  throw new Error(`DiagramDecorator with id "${id}" already exists`);
5806
5943
  }
@@ -5814,6 +5951,8 @@ class DiagramDecorator extends DiagramElement {
5814
5951
  this.height = height;
5815
5952
  this.priority = priority;
5816
5953
  this.html = html;
5954
+ this.anchorPointX = anchorPointX;
5955
+ this.anchorPointY = anchorPointY;
5817
5956
  }
5818
5957
  get removed() {
5819
5958
  return this.selfRemoved || this.rootElement !== undefined && this.rootElement.removed;
@@ -5859,8 +5998,8 @@ class DiagramDecoratorSet extends DiagramElementSet {
5859
5998
  * @param id The id of the decorator. Cannot be an empty string.
5860
5999
  * @returns The instanced decorator.
5861
6000
  */
5862
- new(rootElement, coords, width, height, priority, html, id) {
5863
- const decorator = new DiagramDecorator(this.model, rootElement, coords, width, height, priority, html, id);
6001
+ new(rootElement, coords, width, height, priority, html, id, anchorPointX = 'floating', anchorPointY = 'floating') {
6002
+ const decorator = new DiagramDecorator(this.model, rootElement, coords, width, height, priority, html, id, anchorPointX, anchorPointY);
5864
6003
  super.add(decorator);
5865
6004
  decorator.updateInView();
5866
6005
  // add this port to its root element
@@ -6693,11 +6832,15 @@ class DiagramUserSelection extends DiagramElementSet {
6693
6832
  * Opens the value set of a diagram model or a diagram element in the property editor.
6694
6833
  * @public
6695
6834
  * @param selection A diagram model or a diagram element with a value set.
6835
+ * @param makeUpdateValuesAction Whether the method should create an UpdateValuesAction.
6696
6836
  * @see PropertyEditor
6837
+ * @see UpdateValuesAction
6697
6838
  */
6698
- openInPropertyEditor(selection) {
6839
+ openInPropertyEditor(selection, makeUpdateValuesAction = true) {
6699
6840
  var _a;
6700
- this.makeUpdateValuesAction();
6841
+ if (makeUpdateValuesAction) {
6842
+ this.makeUpdateValuesAction();
6843
+ }
6701
6844
  const propertyEditor = (_a = this.canvas.parentComponent) === null || _a === void 0 ? void 0 : _a.propertyEditor;
6702
6845
  if (propertyEditor === undefined) {
6703
6846
  return;
@@ -6705,7 +6848,9 @@ class DiagramUserSelection extends DiagramElementSet {
6705
6848
  const selectedValueSet = selection === null || selection === void 0 ? void 0 : selection.valueSet;
6706
6849
  if (selectedValueSet) {
6707
6850
  this.propertyEditorSelection = selection;
6708
- this.propertyEditorValues = structuredClone(selectedValueSet.getValues());
6851
+ if (makeUpdateValuesAction) {
6852
+ this.propertyEditorValues = structuredClone(selectedValueSet.getValues());
6853
+ }
6709
6854
  if (propertyEditor) {
6710
6855
  if (selection instanceof DiagramNode || selection instanceof DiagramConnection) {
6711
6856
  if (selection instanceof DiagramNode) {
@@ -6757,6 +6902,26 @@ class DiagramUserSelection extends DiagramElementSet {
6757
6902
  }
6758
6903
  }
6759
6904
 
6905
+ const degreesToRadians = theta => theta * Math.PI / 180;
6906
+ /**
6907
+ * 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.
6908
+ *
6909
+ * @param width The width of a bounding box.
6910
+ * @param height The height of a bounding box.
6911
+ * @param orientation A rotation in degrees.
6912
+ * @returns The size of the original rectangle.
6913
+ */
6914
+ const unrotate = (width, height, orientation) => {
6915
+ // TODO: this method fails under certain edge cases
6916
+ // like for example, when angle is 45 degrees so sin(theta) == cos(theta)
6917
+ const theta = degreesToRadians(orientation);
6918
+ const orientationSine = Math.sin(theta);
6919
+ const orientationCosine = Math.cos(theta);
6920
+ const oldWidth = (Math.abs(width * orientationCosine) - Math.abs(height * orientationSine)) / (orientationCosine * orientationCosine - orientationSine * orientationSine);
6921
+ const oldHeight = (Math.abs(width * orientationSine) - Math.abs(height * orientationCosine)) / (orientationSine * orientationSine - orientationCosine * orientationCosine);
6922
+ return [oldWidth, oldHeight];
6923
+ };
6924
+
6760
6925
  /**
6761
6926
  * Thickness of the invisible path around a connection used to make it easier to click on, in diagram units.
6762
6927
  * @private
@@ -7025,6 +7190,32 @@ class DiagramCanvas {
7025
7190
  }
7026
7191
  });
7027
7192
  const canvasView = this.selectSVGElement().append('g').attr('class', 'daga-canvas-view').attr('width', `100%`).attr('height', `100%`);
7193
+ canvasView.call(this.zoomBehavior = d3__namespace.zoom().on(exports.ZoomEvents.Zoom, event => {
7194
+ if (event.sourceEvent) {
7195
+ // zoom event was triggered by user
7196
+ if (!this.canUserPerformAction(exports.DiagramActions.Zoom)) {
7197
+ setCursorStyle(exports.CursorStyle.NotAllowed);
7198
+ return;
7199
+ }
7200
+ if (event.sourceEvent.type === exports.Events.Wheel && event.sourceEvent.wheelDelta !== undefined) {
7201
+ if (event.sourceEvent.wheelDelta > 0) {
7202
+ setCursorStyle(exports.CursorStyle.ZoomIn);
7203
+ }
7204
+ if (event.sourceEvent.wheelDelta < 0) {
7205
+ setCursorStyle(exports.CursorStyle.ZoomOut);
7206
+ }
7207
+ } else if (event.sourceEvent.type === exports.Events.MouseMove) {
7208
+ setCursorStyle(exports.CursorStyle.AllScroll);
7209
+ }
7210
+ }
7211
+ this.zoomTransform = event.transform;
7212
+ const transformAttribute = event.transform.toString();
7213
+ this.selectCanvasElements().attr('transform', transformAttribute);
7214
+ d3__namespace.select(`#${this.backgroundPatternId}`).attr('patternTransform', transformAttribute);
7215
+ this.contextMenu.close();
7216
+ }).on(exports.ZoomEvents.End, () => {
7217
+ setCursorStyle();
7218
+ }));
7028
7219
  canvasView.append('rect').attr('x', 0).attr('y', 0).attr('width', `100%`).attr('height', `100%`).attr('fill', this.backgroundColor).attr('stroke-width', '0').on(exports.Events.MouseMove, event => {
7029
7220
  if (this.unfinishedConnection !== undefined) {
7030
7221
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
@@ -7055,53 +7246,28 @@ class DiagramCanvas {
7055
7246
  this.continueMultipleSelection(event);
7056
7247
  }).on(exports.DragEvents.End, event => {
7057
7248
  this.finishMultipleSelection(event);
7058
- })).call(this.zoomBehavior = d3__namespace.zoom().on(exports.ZoomEvents.Zoom, event => {
7059
- if (event.sourceEvent) {
7060
- // zoom event was triggered by user
7061
- if (!this.canUserPerformAction(exports.DiagramActions.Zoom)) {
7062
- setCursorStyle(exports.CursorStyle.NotAllowed);
7063
- return;
7064
- }
7065
- if (event.sourceEvent.type === exports.Events.Wheel && event.sourceEvent.wheelDelta !== undefined) {
7066
- if (event.sourceEvent.wheelDelta > 0) {
7067
- setCursorStyle(exports.CursorStyle.ZoomIn);
7068
- }
7069
- if (event.sourceEvent.wheelDelta < 0) {
7070
- setCursorStyle(exports.CursorStyle.ZoomOut);
7071
- }
7072
- } else if (event.sourceEvent.type === exports.Events.MouseMove) {
7073
- setCursorStyle(exports.CursorStyle.AllScroll);
7074
- }
7075
- }
7076
- this.zoomTransform = event.transform;
7077
- const transformAttribute = event.transform.toString();
7078
- this.selectCanvasElements().attr('transform', transformAttribute);
7079
- d3__namespace.select(`#${this.backgroundPatternId}`).attr('patternTransform', transformAttribute);
7080
- this.contextMenu.close();
7081
- }).on(exports.ZoomEvents.End, () => {
7082
- setCursorStyle();
7083
7249
  }));
7084
7250
  initializeGrid(this, canvasView, this.backgroundPatternId);
7085
7251
  canvasView.append('g').attr('class', 'daga-canvas-elements');
7086
7252
  }
7087
7253
  zoomBy(factor) {
7088
7254
  if (!isNaN(factor)) {
7089
- this.zoomBehavior.scaleBy(this.selectCanvasView().select('rect'), factor);
7255
+ this.zoomBehavior.scaleBy(this.selectCanvasView(), factor);
7090
7256
  }
7091
7257
  }
7092
7258
  zoomTo(level) {
7093
7259
  if (!isNaN(level)) {
7094
- this.zoomBehavior.scaleTo(this.selectCanvasView().select('rect'), level);
7260
+ this.zoomBehavior.scaleTo(this.selectCanvasView(), level);
7095
7261
  }
7096
7262
  }
7097
7263
  translateBy(x, y) {
7098
7264
  if (!isNaN(x) && !isNaN(y)) {
7099
- this.zoomBehavior.translateBy(this.selectCanvasView().select('rect'), x, y);
7265
+ this.zoomBehavior.translateBy(this.selectCanvasView(), x, y);
7100
7266
  }
7101
7267
  }
7102
7268
  translateTo(x, y) {
7103
7269
  if (!isNaN(x) && !isNaN(y)) {
7104
- this.zoomBehavior.translateTo(this.selectCanvasView().select('rect'), x, y);
7270
+ this.zoomBehavior.translateTo(this.selectCanvasView(), x, y);
7105
7271
  }
7106
7272
  }
7107
7273
  center() {
@@ -7395,8 +7561,8 @@ class DiagramCanvas {
7395
7561
  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);
7396
7562
  const exitSelection = updateSelection.exit();
7397
7563
  const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', d => {
7398
- var _a, _b, _c, _d, _e;
7399
- return `diagram-section${((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) ? ' resizable-x' : ''}${((_d = (_c = d.node) === null || _c === void 0 ? void 0 : _c.type) === null || _d === void 0 ? void 0 : _d.resizableY) ? ' resizable-y' : ''} ${(_e = d.look) === null || _e === void 0 ? void 0 : _e.lookType}`;
7564
+ var _a;
7565
+ return `diagram-section${d.getResizableX() ? ' resizable-x' : ''}${d.getResizableY() ? ' resizable-y' : ''} ${(_a = d.look) === null || _a === void 0 ? void 0 : _a.lookType}`;
7400
7566
  });
7401
7567
  if (ids && ids.length > 0) {
7402
7568
  updateSelection = updateSelection.filter(d => ids.includes(d.id));
@@ -7478,32 +7644,27 @@ class DiagramCanvas {
7478
7644
  }));
7479
7645
  initializeLook(enterSelection);
7480
7646
  enterSelection.filter('.resizable-x').append('line').attr('class', 'left-resizer').attr('stroke', 'transparent').attr('stroke-width', `${RESIZER_THICKNESS}px`).on(exports.Events.MouseOver, (_event, d) => {
7481
- var _a, _b;
7482
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed) {
7647
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
7483
7648
  setCursorStyle(exports.CursorStyle.EWResize);
7484
7649
  }
7485
7650
  }).on(exports.Events.MouseOut, (_event, d) => {
7486
- var _a, _b;
7487
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed) {
7651
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
7488
7652
  setCursorStyle();
7489
7653
  }
7490
7654
  }).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
7491
- var _a, _b;
7492
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed) {
7655
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed && d.node) {
7493
7656
  setCursorStyle(exports.CursorStyle.EWResize);
7494
7657
  this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
7495
7658
  } else {
7496
7659
  setCursorStyle(exports.CursorStyle.NotAllowed);
7497
7660
  }
7498
7661
  }).on(exports.DragEvents.Drag, (event, d) => {
7499
- var _a, _b;
7500
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed) {
7662
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed && d.node) {
7501
7663
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7502
7664
  d.node.stretchSections(exports.Side.Left, d.coords[0] - pointerCoords[0], d.indexXInNode, d.indexYInNode);
7503
7665
  }
7504
7666
  }).on(exports.DragEvents.End, (event, d) => {
7505
- var _a, _b;
7506
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection) {
7667
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection && d.node) {
7507
7668
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7508
7669
  if (this.snapToGrid) {
7509
7670
  pointerCoords = this.getClosestGridPoint(pointerCoords);
@@ -7517,32 +7678,27 @@ class DiagramCanvas {
7517
7678
  setCursorStyle();
7518
7679
  }));
7519
7680
  enterSelection.filter('.resizable-y').append('line').attr('class', 'top-resizer').attr('stroke', 'transparent').attr('stroke-width', `${RESIZER_THICKNESS}px`).on(exports.Events.MouseOver, (_event, d) => {
7520
- var _a, _b;
7521
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed) {
7681
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
7522
7682
  setCursorStyle(exports.CursorStyle.NSResize);
7523
7683
  }
7524
7684
  }).on(exports.Events.MouseOut, (_event, d) => {
7525
- var _a, _b;
7526
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed) {
7685
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
7527
7686
  setCursorStyle();
7528
7687
  }
7529
7688
  }).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
7530
- var _a, _b;
7531
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed) {
7689
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed && d.node) {
7532
7690
  setCursorStyle(exports.CursorStyle.NSResize);
7533
7691
  this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
7534
7692
  } else {
7535
7693
  setCursorStyle(exports.CursorStyle.NotAllowed);
7536
7694
  }
7537
7695
  }).on(exports.DragEvents.Drag, (event, d) => {
7538
- var _a, _b;
7539
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed) {
7696
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed && d.node) {
7540
7697
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7541
7698
  d.node.stretchSections(exports.Side.Top, d.coords[1] - pointerCoords[1], d.indexXInNode, d.indexYInNode);
7542
7699
  }
7543
7700
  }).on(exports.DragEvents.End, (event, d) => {
7544
- var _a, _b;
7545
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection) {
7701
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection && d.node) {
7546
7702
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7547
7703
  if (this.snapToGrid) {
7548
7704
  pointerCoords = this.getClosestGridPoint(pointerCoords);
@@ -7556,32 +7712,27 @@ class DiagramCanvas {
7556
7712
  setCursorStyle();
7557
7713
  }));
7558
7714
  enterSelection.filter('.resizable-x').append('line').attr('class', 'right-resizer').attr('stroke', 'transparent').attr('stroke-width', `${RESIZER_THICKNESS}px`).on(exports.Events.MouseOver, (_event, d) => {
7559
- var _a, _b;
7560
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed) {
7715
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
7561
7716
  setCursorStyle(exports.CursorStyle.EWResize);
7562
7717
  }
7563
7718
  }).on(exports.Events.MouseOut, (_event, d) => {
7564
- var _a, _b;
7565
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed) {
7719
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
7566
7720
  setCursorStyle();
7567
7721
  }
7568
7722
  }).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
7569
- var _a, _b;
7570
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed) {
7723
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed && d.node) {
7571
7724
  setCursorStyle(exports.CursorStyle.EWResize);
7572
7725
  this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
7573
7726
  } else {
7574
7727
  setCursorStyle(exports.CursorStyle.NotAllowed);
7575
7728
  }
7576
7729
  }).on(exports.DragEvents.Drag, (event, d) => {
7577
- var _a, _b;
7578
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed) {
7730
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed && d.node) {
7579
7731
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7580
7732
  d.node.stretchSections(exports.Side.Right, pointerCoords[0] - (d.coords[0] + d.width), d.indexXInNode, d.indexYInNode);
7581
7733
  }
7582
7734
  }).on(exports.DragEvents.End, (event, d) => {
7583
- var _a, _b;
7584
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection) {
7735
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection && d.node) {
7585
7736
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7586
7737
  if (this.snapToGrid) {
7587
7738
  pointerCoords = this.getClosestGridPoint(pointerCoords);
@@ -7595,32 +7746,27 @@ class DiagramCanvas {
7595
7746
  setCursorStyle();
7596
7747
  }));
7597
7748
  enterSelection.filter('.resizable-y').append('line').attr('class', 'bottom-resizer').attr('stroke', 'transparent').attr('stroke-width', `${RESIZER_THICKNESS}px`).on(exports.Events.MouseOver, (_event, d) => {
7598
- var _a, _b;
7599
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed) {
7749
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
7600
7750
  setCursorStyle(exports.CursorStyle.NSResize);
7601
7751
  }
7602
7752
  }).on(exports.Events.MouseOut, (_event, d) => {
7603
- var _a, _b;
7604
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed) {
7753
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
7605
7754
  setCursorStyle();
7606
7755
  }
7607
7756
  }).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
7608
- var _a, _b;
7609
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed) {
7757
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed && d.node) {
7610
7758
  setCursorStyle(exports.CursorStyle.NSResize);
7611
7759
  this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
7612
7760
  } else {
7613
7761
  setCursorStyle(exports.CursorStyle.NotAllowed);
7614
7762
  }
7615
7763
  }).on(exports.DragEvents.Drag, (event, d) => {
7616
- var _a, _b;
7617
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed) {
7764
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed && d.node) {
7618
7765
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7619
7766
  d.node.stretchSections(exports.Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height), d.indexXInNode, d.indexYInNode);
7620
7767
  }
7621
7768
  }).on(exports.DragEvents.End, (event, d) => {
7622
- var _a, _b;
7623
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection) {
7769
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection && d.node) {
7624
7770
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7625
7771
  if (this.snapToGrid) {
7626
7772
  pointerCoords = this.getClosestGridPoint(pointerCoords);
@@ -7937,7 +8083,7 @@ class DiagramCanvas {
7937
8083
  this.diagramEvent$.next(diagramEvent);
7938
8084
  if (!diagramEvent.defaultPrevented && this.canUserPerformAction(exports.DiagramActions.EditField) && d.editable && !d.removed) {
7939
8085
  this.currentAction = new EditFieldAction(this, d.id, d.text, '');
7940
- this.createInputField(d.text, d.coords, d.width, d.height, d.fontSize, d.fontFamily || DIAGRAM_FIELD_DEFAULTS.fontFamily, d.orientation, text => {
8086
+ this.createInputField(d.text, d.coords, d.width, d.height, d.fontSize, d.fontFamily || DIAGRAM_FIELD_DEFAULTS.fontFamily, d.orientation, _text => {
7941
8087
  /*
7942
8088
  Empty for now
7943
8089
  We should create a better function to stretch the root element as the text expands
@@ -8006,24 +8152,7 @@ class DiagramCanvas {
8006
8152
  }
8007
8153
  this.secondaryButton = false;
8008
8154
  })).append('xhtml:div').style('width', '100%').style('height', '100%').style('display', 'flex').append('xhtml:p').style('box-sizing', 'border-box').style('outline', 0).style('margin', 0).style('border', 0).style('padding', 0).style('user-select', 'none').style('font-kerning', 'none').style('white-space', 'nowrap');
8009
- mergeSelection.attr('x', 0).attr('y', 0).attr('width', d => `${d.width}px`).attr('height', d => `${d.height}px`).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).attr('opacity', d => d.removed ? 0.5 : 1).select('div').style('justify-content', d => d.horizontalAlign === exports.HorizontalAlign.Center ? 'center' : d.horizontalAlign === exports.HorizontalAlign.Right ? 'flex-end' : 'flex-start').style('align-items', d => d.verticalAlign === exports.VerticalAlign.Center ? 'center' : d.verticalAlign === exports.VerticalAlign.Bottom ? 'end' : 'start').select('p').style('max-width', d => d.fit ? 'default' : '100%').style('max-height', d => d.fit ? 'default' : '100%').style('overflow', d => d.fit ? 'default' : 'hidden').style('text-overflow', d => d.fit ? 'default' : 'ellipsis').style('text-align', d => d.horizontalAlign === exports.HorizontalAlign.Center ? 'center' : d.horizontalAlign === exports.HorizontalAlign.Right ? 'end' : 'start').style('transform', d => {
8010
- if (!isNaN(Number(d.orientation))) {
8011
- return `rotate(${d.orientation}deg)`;
8012
- } else {
8013
- switch (d.orientation) {
8014
- case exports.Side.Top:
8015
- return 'rotate(0deg)';
8016
- case exports.Side.Right:
8017
- return 'rotate(90deg)';
8018
- case exports.Side.Bottom:
8019
- return 'rotate(180deg)';
8020
- case exports.Side.Left:
8021
- return 'rotate(270deg)';
8022
- default:
8023
- return 'rotate(0deg)';
8024
- }
8025
- }
8026
- }).style('font-size', d => `${d.fontSize}px`).style('font-family', d => d.fontFamily || "'Wonder Unit Sans', sans-serif").style('font-weight', d => d.highlighted ? 600 : 400).style('color', d => d.selected ? d.selectedColor || '#000000' : d.color || '#000000').html(d => d.text.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g, '<br/>'));
8155
+ mergeSelection.attr('x', 0).attr('y', 0).attr('width', d => `${d.width}px`).attr('height', d => `${d.height}px`).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).attr('opacity', d => d.removed ? 0.5 : 1).select('div').style('justify-content', d => d.horizontalAlign === exports.HorizontalAlign.Center ? 'center' : d.horizontalAlign === exports.HorizontalAlign.Right ? 'flex-end' : 'flex-start').style('align-items', d => d.verticalAlign === exports.VerticalAlign.Center ? 'center' : d.verticalAlign === exports.VerticalAlign.Bottom ? 'end' : 'start').select('p').style('max-width', d => d.fit ? 'default' : `${unrotate(d.width, d.height, d.orientation)[0]}px`).style('max-height', d => d.fit ? 'default' : `${unrotate(d.width, d.height, d.orientation)[1]}px`).style('overflow', d => d.fit ? 'default' : 'clip').style('text-overflow', d => d.fit ? 'default' : 'ellipsis').style('text-align', d => d.horizontalAlign === exports.HorizontalAlign.Center ? 'center' : d.horizontalAlign === exports.HorizontalAlign.Right ? 'end' : 'start').style('transform', d => `rotate(${d.orientation}deg)`).style('font-size', d => `${d.fontSize}px`).style('font-family', d => d.fontFamily || "'Wonder Unit Sans', sans-serif").style('font-weight', d => d.highlighted ? 600 : 400).style('color', d => d.selected ? d.selectedColor || '#000000' : d.color || '#000000').html(d => d.text.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g, '<br/>'));
8027
8156
  }
8028
8157
  updateObjectsInView(...ids) {
8029
8158
  let updateSelection = this.selectCanvasElements().selectAll('foreignObject.diagram-object').data(this.model.objects.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
@@ -8243,7 +8372,7 @@ class DiagramCanvas {
8243
8372
  }
8244
8373
  return true;
8245
8374
  }
8246
- fitFieldRootInView(id, shrink) {
8375
+ fitFieldRootInView(id, shrink = true) {
8247
8376
  var _a, _b, _c;
8248
8377
  const field = this.model.fields.get(id);
8249
8378
  if (!field) {
@@ -8304,15 +8433,15 @@ class DiagramCanvas {
8304
8433
  if (field.rootElement.height + stretchY < (field.rootElement.getMinHeight() || 0)) {
8305
8434
  stretchY = (field.rootElement.getMinHeight() || 0) - field.rootElement.height;
8306
8435
  }
8307
- if (shrink !== false || stretchX > 0) {
8436
+ if (shrink || stretchX > 0) {
8308
8437
  (_b = field.rootElement.node) === null || _b === void 0 ? void 0 : _b.stretchSections(exports.Side.Right, stretchX, field.rootElement.indexXInNode, field.rootElement.indexYInNode);
8309
8438
  }
8310
- if (shrink !== false || stretchY > 0) {
8439
+ if (shrink || stretchY > 0) {
8311
8440
  (_c = field.rootElement.node) === null || _c === void 0 ? void 0 : _c.stretchSections(exports.Side.Bottom, stretchY, field.rootElement.indexXInNode, field.rootElement.indexYInNode);
8312
8441
  }
8313
8442
  }
8314
8443
  }
8315
- fitNodeInView(id) {
8444
+ fitNodeInView(id, shrink = true) {
8316
8445
  var _a, _b;
8317
8446
  const node = this.model.nodes.get(id);
8318
8447
  if (!node) {
@@ -8333,8 +8462,12 @@ class DiagramCanvas {
8333
8462
  // add the margin that goes between the rightmost and bottommost points of the sections and the edge of the node
8334
8463
  newNodeWidth += ((_a = node.type.sectionGrid) === null || _a === void 0 ? void 0 : _a.margin) || 0;
8335
8464
  newNodeHeight += ((_b = node.type.sectionGrid) === null || _b === void 0 ? void 0 : _b.margin) || 0;
8336
- node.stretch(exports.Side.Right, newNodeWidth - node.width);
8337
- node.stretch(exports.Side.Bottom, newNodeHeight - node.height);
8465
+ if (shrink || newNodeWidth > node.width) {
8466
+ node.stretch(exports.Side.Right, newNodeWidth - node.width);
8467
+ }
8468
+ if (shrink || newNodeHeight > node.height) {
8469
+ node.stretch(exports.Side.Bottom, newNodeHeight - node.height);
8470
+ }
8338
8471
  }
8339
8472
  }
8340
8473
  selectRoot() {
@@ -9177,7 +9310,7 @@ class ForceLayout {
9177
9310
  return model;
9178
9311
  }
9179
9312
  // as a starting point, we apply a simple layout
9180
- new BreadthLayout().apply(model);
9313
+ new BreadthLayout(this.gapSize).apply(model);
9181
9314
  const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
9182
9315
  const coolingFactor = 0.99;
9183
9316
  const minimumTemperature = 1;
@@ -9304,7 +9437,7 @@ class PriorityLayout {
9304
9437
  const minimumPriority = Math.min(...model.nodes.map(n => n.getPriority()));
9305
9438
  if (maximumPriority === minimumPriority) {
9306
9439
  // if there's no disparity in priorities, just use breadth layout
9307
- new BreadthLayout().apply(model);
9440
+ new BreadthLayout(this.gapSize).apply(model);
9308
9441
  return model;
9309
9442
  }
9310
9443
  const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
@@ -9414,7 +9547,7 @@ class TreeLayout {
9414
9547
  const minimumPriority = Math.min(...model.nodes.map(n => n.getPriority()));
9415
9548
  if (maximumPriority === minimumPriority) {
9416
9549
  // if there's no disparity in priorities, just use breadth layout
9417
- new BreadthLayout().apply(model);
9550
+ new BreadthLayout(this.gapSize).apply(model);
9418
9551
  return model;
9419
9552
  }
9420
9553
  const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;