@metadev/daga 4.2.0 → 4.2.2
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 +15 -1
- package/index.cjs.js +302 -166
- package/index.esm.js +302 -166
- package/package.json +1 -1
- package/src/lib/diagram/canvas/diagram-canvas.d.ts +1 -1
- package/src/lib/diagram/canvas/diagram-user-selection.d.ts +3 -1
- package/src/lib/diagram/config/diagram-config.d.ts +54 -1
- package/src/lib/diagram/model/diagram-decorator.d.ts +13 -3
- package/src/lib/diagram/model/diagram-field.d.ts +9 -3
- package/src/lib/diagram/model/diagram-port.d.ts +13 -3
- package/src/lib/diagram/model/diagram-section.d.ts +16 -0
- package/src/lib/interfaces/canvas.d.ts +2 -1
- package/src/lib/util/canvas-util.d.ts +18 -0
- package/src/lib/util/trig.d.ts +20 -0
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
|
|
171
|
-
|
|
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
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
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
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
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
|
-
|
|
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(
|
|
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(
|
|
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
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
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
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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(
|
|
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(
|
|
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
|
|
4030
|
-
|
|
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
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,35 @@ 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().filter(event => {
|
|
7194
|
+
// Disable double-click zoom by filtering out dblclick events
|
|
7195
|
+
return event.type !== exports.Events.DoubleClick;
|
|
7196
|
+
}).on(exports.ZoomEvents.Zoom, event => {
|
|
7197
|
+
if (event.sourceEvent) {
|
|
7198
|
+
// zoom event was triggered by user
|
|
7199
|
+
if (!this.canUserPerformAction(exports.DiagramActions.Zoom)) {
|
|
7200
|
+
setCursorStyle(exports.CursorStyle.NotAllowed);
|
|
7201
|
+
return;
|
|
7202
|
+
}
|
|
7203
|
+
if (event.sourceEvent.type === exports.Events.Wheel && event.sourceEvent.wheelDelta !== undefined) {
|
|
7204
|
+
if (event.sourceEvent.wheelDelta > 0) {
|
|
7205
|
+
setCursorStyle(exports.CursorStyle.ZoomIn);
|
|
7206
|
+
}
|
|
7207
|
+
if (event.sourceEvent.wheelDelta < 0) {
|
|
7208
|
+
setCursorStyle(exports.CursorStyle.ZoomOut);
|
|
7209
|
+
}
|
|
7210
|
+
} else if (event.sourceEvent.type === exports.Events.MouseMove) {
|
|
7211
|
+
setCursorStyle(exports.CursorStyle.AllScroll);
|
|
7212
|
+
}
|
|
7213
|
+
}
|
|
7214
|
+
this.zoomTransform = event.transform;
|
|
7215
|
+
const transformAttribute = event.transform.toString();
|
|
7216
|
+
this.selectCanvasElements().attr('transform', transformAttribute);
|
|
7217
|
+
d3__namespace.select(`#${this.backgroundPatternId}`).attr('patternTransform', transformAttribute);
|
|
7218
|
+
this.contextMenu.close();
|
|
7219
|
+
}).on(exports.ZoomEvents.End, () => {
|
|
7220
|
+
setCursorStyle();
|
|
7221
|
+
}));
|
|
7028
7222
|
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
7223
|
if (this.unfinishedConnection !== undefined) {
|
|
7030
7224
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
@@ -7055,53 +7249,28 @@ class DiagramCanvas {
|
|
|
7055
7249
|
this.continueMultipleSelection(event);
|
|
7056
7250
|
}).on(exports.DragEvents.End, event => {
|
|
7057
7251
|
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
7252
|
}));
|
|
7084
7253
|
initializeGrid(this, canvasView, this.backgroundPatternId);
|
|
7085
7254
|
canvasView.append('g').attr('class', 'daga-canvas-elements');
|
|
7086
7255
|
}
|
|
7087
7256
|
zoomBy(factor) {
|
|
7088
7257
|
if (!isNaN(factor)) {
|
|
7089
|
-
this.zoomBehavior.scaleBy(this.selectCanvasView()
|
|
7258
|
+
this.zoomBehavior.scaleBy(this.selectCanvasView(), factor);
|
|
7090
7259
|
}
|
|
7091
7260
|
}
|
|
7092
7261
|
zoomTo(level) {
|
|
7093
7262
|
if (!isNaN(level)) {
|
|
7094
|
-
this.zoomBehavior.scaleTo(this.selectCanvasView()
|
|
7263
|
+
this.zoomBehavior.scaleTo(this.selectCanvasView(), level);
|
|
7095
7264
|
}
|
|
7096
7265
|
}
|
|
7097
7266
|
translateBy(x, y) {
|
|
7098
7267
|
if (!isNaN(x) && !isNaN(y)) {
|
|
7099
|
-
this.zoomBehavior.translateBy(this.selectCanvasView()
|
|
7268
|
+
this.zoomBehavior.translateBy(this.selectCanvasView(), x, y);
|
|
7100
7269
|
}
|
|
7101
7270
|
}
|
|
7102
7271
|
translateTo(x, y) {
|
|
7103
7272
|
if (!isNaN(x) && !isNaN(y)) {
|
|
7104
|
-
this.zoomBehavior.translateTo(this.selectCanvasView()
|
|
7273
|
+
this.zoomBehavior.translateTo(this.selectCanvasView(), x, y);
|
|
7105
7274
|
}
|
|
7106
7275
|
}
|
|
7107
7276
|
center() {
|
|
@@ -7395,8 +7564,8 @@ class DiagramCanvas {
|
|
|
7395
7564
|
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
7565
|
const exitSelection = updateSelection.exit();
|
|
7397
7566
|
const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', d => {
|
|
7398
|
-
var _a
|
|
7399
|
-
return `diagram-section${
|
|
7567
|
+
var _a;
|
|
7568
|
+
return `diagram-section${d.getResizableX() ? ' resizable-x' : ''}${d.getResizableY() ? ' resizable-y' : ''} ${(_a = d.look) === null || _a === void 0 ? void 0 : _a.lookType}`;
|
|
7400
7569
|
});
|
|
7401
7570
|
if (ids && ids.length > 0) {
|
|
7402
7571
|
updateSelection = updateSelection.filter(d => ids.includes(d.id));
|
|
@@ -7478,32 +7647,27 @@ class DiagramCanvas {
|
|
|
7478
7647
|
}));
|
|
7479
7648
|
initializeLook(enterSelection);
|
|
7480
7649
|
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
|
-
|
|
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) {
|
|
7650
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
|
|
7483
7651
|
setCursorStyle(exports.CursorStyle.EWResize);
|
|
7484
7652
|
}
|
|
7485
7653
|
}).on(exports.Events.MouseOut, (_event, d) => {
|
|
7486
|
-
|
|
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) {
|
|
7654
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
|
|
7488
7655
|
setCursorStyle();
|
|
7489
7656
|
}
|
|
7490
7657
|
}).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
|
|
7491
|
-
|
|
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) {
|
|
7658
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed && d.node) {
|
|
7493
7659
|
setCursorStyle(exports.CursorStyle.EWResize);
|
|
7494
7660
|
this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
|
|
7495
7661
|
} else {
|
|
7496
7662
|
setCursorStyle(exports.CursorStyle.NotAllowed);
|
|
7497
7663
|
}
|
|
7498
7664
|
}).on(exports.DragEvents.Drag, (event, d) => {
|
|
7499
|
-
|
|
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) {
|
|
7665
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed && d.node) {
|
|
7501
7666
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7502
7667
|
d.node.stretchSections(exports.Side.Left, d.coords[0] - pointerCoords[0], d.indexXInNode, d.indexYInNode);
|
|
7503
7668
|
}
|
|
7504
7669
|
}).on(exports.DragEvents.End, (event, d) => {
|
|
7505
|
-
|
|
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) {
|
|
7670
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection && d.node) {
|
|
7507
7671
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7508
7672
|
if (this.snapToGrid) {
|
|
7509
7673
|
pointerCoords = this.getClosestGridPoint(pointerCoords);
|
|
@@ -7517,32 +7681,27 @@ class DiagramCanvas {
|
|
|
7517
7681
|
setCursorStyle();
|
|
7518
7682
|
}));
|
|
7519
7683
|
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
|
-
|
|
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) {
|
|
7684
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
|
|
7522
7685
|
setCursorStyle(exports.CursorStyle.NSResize);
|
|
7523
7686
|
}
|
|
7524
7687
|
}).on(exports.Events.MouseOut, (_event, d) => {
|
|
7525
|
-
|
|
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) {
|
|
7688
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
|
|
7527
7689
|
setCursorStyle();
|
|
7528
7690
|
}
|
|
7529
7691
|
}).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
|
|
7530
|
-
|
|
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) {
|
|
7692
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed && d.node) {
|
|
7532
7693
|
setCursorStyle(exports.CursorStyle.NSResize);
|
|
7533
7694
|
this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
|
|
7534
7695
|
} else {
|
|
7535
7696
|
setCursorStyle(exports.CursorStyle.NotAllowed);
|
|
7536
7697
|
}
|
|
7537
7698
|
}).on(exports.DragEvents.Drag, (event, d) => {
|
|
7538
|
-
|
|
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) {
|
|
7699
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed && d.node) {
|
|
7540
7700
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7541
7701
|
d.node.stretchSections(exports.Side.Top, d.coords[1] - pointerCoords[1], d.indexXInNode, d.indexYInNode);
|
|
7542
7702
|
}
|
|
7543
7703
|
}).on(exports.DragEvents.End, (event, d) => {
|
|
7544
|
-
|
|
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) {
|
|
7704
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection && d.node) {
|
|
7546
7705
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7547
7706
|
if (this.snapToGrid) {
|
|
7548
7707
|
pointerCoords = this.getClosestGridPoint(pointerCoords);
|
|
@@ -7556,32 +7715,27 @@ class DiagramCanvas {
|
|
|
7556
7715
|
setCursorStyle();
|
|
7557
7716
|
}));
|
|
7558
7717
|
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
|
-
|
|
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) {
|
|
7718
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
|
|
7561
7719
|
setCursorStyle(exports.CursorStyle.EWResize);
|
|
7562
7720
|
}
|
|
7563
7721
|
}).on(exports.Events.MouseOut, (_event, d) => {
|
|
7564
|
-
|
|
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) {
|
|
7722
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
|
|
7566
7723
|
setCursorStyle();
|
|
7567
7724
|
}
|
|
7568
7725
|
}).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
|
|
7569
|
-
|
|
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) {
|
|
7726
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed && d.node) {
|
|
7571
7727
|
setCursorStyle(exports.CursorStyle.EWResize);
|
|
7572
7728
|
this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
|
|
7573
7729
|
} else {
|
|
7574
7730
|
setCursorStyle(exports.CursorStyle.NotAllowed);
|
|
7575
7731
|
}
|
|
7576
7732
|
}).on(exports.DragEvents.Drag, (event, d) => {
|
|
7577
|
-
|
|
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) {
|
|
7733
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed && d.node) {
|
|
7579
7734
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7580
7735
|
d.node.stretchSections(exports.Side.Right, pointerCoords[0] - (d.coords[0] + d.width), d.indexXInNode, d.indexYInNode);
|
|
7581
7736
|
}
|
|
7582
7737
|
}).on(exports.DragEvents.End, (event, d) => {
|
|
7583
|
-
|
|
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) {
|
|
7738
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection && d.node) {
|
|
7585
7739
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7586
7740
|
if (this.snapToGrid) {
|
|
7587
7741
|
pointerCoords = this.getClosestGridPoint(pointerCoords);
|
|
@@ -7595,32 +7749,27 @@ class DiagramCanvas {
|
|
|
7595
7749
|
setCursorStyle();
|
|
7596
7750
|
}));
|
|
7597
7751
|
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
|
-
|
|
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) {
|
|
7752
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
|
|
7600
7753
|
setCursorStyle(exports.CursorStyle.NSResize);
|
|
7601
7754
|
}
|
|
7602
7755
|
}).on(exports.Events.MouseOut, (_event, d) => {
|
|
7603
|
-
|
|
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) {
|
|
7756
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
|
|
7605
7757
|
setCursorStyle();
|
|
7606
7758
|
}
|
|
7607
7759
|
}).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
|
|
7608
|
-
|
|
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) {
|
|
7760
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed && d.node) {
|
|
7610
7761
|
setCursorStyle(exports.CursorStyle.NSResize);
|
|
7611
7762
|
this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
|
|
7612
7763
|
} else {
|
|
7613
7764
|
setCursorStyle(exports.CursorStyle.NotAllowed);
|
|
7614
7765
|
}
|
|
7615
7766
|
}).on(exports.DragEvents.Drag, (event, d) => {
|
|
7616
|
-
|
|
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) {
|
|
7767
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed && d.node) {
|
|
7618
7768
|
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7619
7769
|
d.node.stretchSections(exports.Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height), d.indexXInNode, d.indexYInNode);
|
|
7620
7770
|
}
|
|
7621
7771
|
}).on(exports.DragEvents.End, (event, d) => {
|
|
7622
|
-
|
|
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) {
|
|
7772
|
+
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection && d.node) {
|
|
7624
7773
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7625
7774
|
if (this.snapToGrid) {
|
|
7626
7775
|
pointerCoords = this.getClosestGridPoint(pointerCoords);
|
|
@@ -7937,7 +8086,7 @@ class DiagramCanvas {
|
|
|
7937
8086
|
this.diagramEvent$.next(diagramEvent);
|
|
7938
8087
|
if (!diagramEvent.defaultPrevented && this.canUserPerformAction(exports.DiagramActions.EditField) && d.editable && !d.removed) {
|
|
7939
8088
|
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,
|
|
8089
|
+
this.createInputField(d.text, d.coords, d.width, d.height, d.fontSize, d.fontFamily || DIAGRAM_FIELD_DEFAULTS.fontFamily, d.orientation, _text => {
|
|
7941
8090
|
/*
|
|
7942
8091
|
Empty for now
|
|
7943
8092
|
We should create a better function to stretch the root element as the text expands
|
|
@@ -8006,24 +8155,7 @@ class DiagramCanvas {
|
|
|
8006
8155
|
}
|
|
8007
8156
|
this.secondaryButton = false;
|
|
8008
8157
|
})).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' :
|
|
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, '<').replace(/>/g, '>').replace(/\n/g, '<br/>'));
|
|
8158
|
+
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, '<').replace(/>/g, '>').replace(/\n/g, '<br/>'));
|
|
8027
8159
|
}
|
|
8028
8160
|
updateObjectsInView(...ids) {
|
|
8029
8161
|
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 +8375,7 @@ class DiagramCanvas {
|
|
|
8243
8375
|
}
|
|
8244
8376
|
return true;
|
|
8245
8377
|
}
|
|
8246
|
-
fitFieldRootInView(id, shrink) {
|
|
8378
|
+
fitFieldRootInView(id, shrink = true) {
|
|
8247
8379
|
var _a, _b, _c;
|
|
8248
8380
|
const field = this.model.fields.get(id);
|
|
8249
8381
|
if (!field) {
|
|
@@ -8304,15 +8436,15 @@ class DiagramCanvas {
|
|
|
8304
8436
|
if (field.rootElement.height + stretchY < (field.rootElement.getMinHeight() || 0)) {
|
|
8305
8437
|
stretchY = (field.rootElement.getMinHeight() || 0) - field.rootElement.height;
|
|
8306
8438
|
}
|
|
8307
|
-
if (shrink
|
|
8439
|
+
if (shrink || stretchX > 0) {
|
|
8308
8440
|
(_b = field.rootElement.node) === null || _b === void 0 ? void 0 : _b.stretchSections(exports.Side.Right, stretchX, field.rootElement.indexXInNode, field.rootElement.indexYInNode);
|
|
8309
8441
|
}
|
|
8310
|
-
if (shrink
|
|
8442
|
+
if (shrink || stretchY > 0) {
|
|
8311
8443
|
(_c = field.rootElement.node) === null || _c === void 0 ? void 0 : _c.stretchSections(exports.Side.Bottom, stretchY, field.rootElement.indexXInNode, field.rootElement.indexYInNode);
|
|
8312
8444
|
}
|
|
8313
8445
|
}
|
|
8314
8446
|
}
|
|
8315
|
-
fitNodeInView(id) {
|
|
8447
|
+
fitNodeInView(id, shrink = true) {
|
|
8316
8448
|
var _a, _b;
|
|
8317
8449
|
const node = this.model.nodes.get(id);
|
|
8318
8450
|
if (!node) {
|
|
@@ -8333,8 +8465,12 @@ class DiagramCanvas {
|
|
|
8333
8465
|
// add the margin that goes between the rightmost and bottommost points of the sections and the edge of the node
|
|
8334
8466
|
newNodeWidth += ((_a = node.type.sectionGrid) === null || _a === void 0 ? void 0 : _a.margin) || 0;
|
|
8335
8467
|
newNodeHeight += ((_b = node.type.sectionGrid) === null || _b === void 0 ? void 0 : _b.margin) || 0;
|
|
8336
|
-
|
|
8337
|
-
|
|
8468
|
+
if (shrink || newNodeWidth > node.width) {
|
|
8469
|
+
node.stretch(exports.Side.Right, newNodeWidth - node.width);
|
|
8470
|
+
}
|
|
8471
|
+
if (shrink || newNodeHeight > node.height) {
|
|
8472
|
+
node.stretch(exports.Side.Bottom, newNodeHeight - node.height);
|
|
8473
|
+
}
|
|
8338
8474
|
}
|
|
8339
8475
|
}
|
|
8340
8476
|
selectRoot() {
|
|
@@ -9177,7 +9313,7 @@ class ForceLayout {
|
|
|
9177
9313
|
return model;
|
|
9178
9314
|
}
|
|
9179
9315
|
// as a starting point, we apply a simple layout
|
|
9180
|
-
new BreadthLayout().apply(model);
|
|
9316
|
+
new BreadthLayout(this.gapSize).apply(model);
|
|
9181
9317
|
const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
|
|
9182
9318
|
const coolingFactor = 0.99;
|
|
9183
9319
|
const minimumTemperature = 1;
|
|
@@ -9304,7 +9440,7 @@ class PriorityLayout {
|
|
|
9304
9440
|
const minimumPriority = Math.min(...model.nodes.map(n => n.getPriority()));
|
|
9305
9441
|
if (maximumPriority === minimumPriority) {
|
|
9306
9442
|
// if there's no disparity in priorities, just use breadth layout
|
|
9307
|
-
new BreadthLayout().apply(model);
|
|
9443
|
+
new BreadthLayout(this.gapSize).apply(model);
|
|
9308
9444
|
return model;
|
|
9309
9445
|
}
|
|
9310
9446
|
const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
|
|
@@ -9414,7 +9550,7 @@ class TreeLayout {
|
|
|
9414
9550
|
const minimumPriority = Math.min(...model.nodes.map(n => n.getPriority()));
|
|
9415
9551
|
if (maximumPriority === minimumPriority) {
|
|
9416
9552
|
// if there's no disparity in priorities, just use breadth layout
|
|
9417
|
-
new BreadthLayout().apply(model);
|
|
9553
|
+
new BreadthLayout(this.gapSize).apply(model);
|
|
9418
9554
|
return model;
|
|
9419
9555
|
}
|
|
9420
9556
|
const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
|