@metadev/daga 3.1.5 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Changelog.md +16 -0
- package/index.cjs.js +759 -365
- package/index.esm.js +759 -365
- package/package.json +1 -1
- package/src/index.d.ts +5 -2
- package/src/lib/diagram/canvas/diagram-canvas-util.d.ts +26 -0
- package/src/lib/diagram/canvas/diagram-canvas.d.ts +1 -3
- package/src/lib/diagram/canvas/diagram-context-menu.d.ts +6 -1
- package/src/lib/diagram/config/diagram-canvas-config.d.ts +97 -0
- package/src/lib/diagram/{diagram-config.d.ts → config/diagram-config.d.ts} +23 -294
- package/src/lib/diagram/config/diagram-look-config.d.ts +220 -0
- package/src/lib/diagram/model/diagram-connection.d.ts +86 -26
- package/src/lib/diagram/model/diagram-decorator.d.ts +8 -2
- package/src/lib/diagram/model/diagram-element.d.ts +4 -0
- package/src/lib/diagram/model/diagram-field.d.ts +1 -2
- package/src/lib/diagram/model/diagram-node.d.ts +38 -8
- package/src/lib/diagram/model/diagram-object.d.ts +8 -2
- package/src/lib/diagram/model/diagram-port.d.ts +47 -12
- package/src/lib/diagram/model/diagram-property.d.ts +18 -3
- package/src/lib/diagram/model/diagram-section.d.ts +44 -20
- package/src/lib/interfaces/canvas.d.ts +1 -1
- package/src/lib/util/html-util.d.ts +1 -0
- package/src/lib/util/test-util.d.ts +1 -1
package/index.cjs.js
CHANGED
|
@@ -828,6 +828,64 @@ const numberOfRows = s => {
|
|
|
828
828
|
return ((_a = s.match(/\n/g)) === null || _a === undefined ? undefined : _a.length) || 0;
|
|
829
829
|
};
|
|
830
830
|
|
|
831
|
+
/******************************************************************************
|
|
832
|
+
Copyright (c) Microsoft Corporation.
|
|
833
|
+
|
|
834
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
835
|
+
purpose with or without fee is hereby granted.
|
|
836
|
+
|
|
837
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
838
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
839
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
840
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
841
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
842
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
843
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
844
|
+
***************************************************************************** */
|
|
845
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
846
|
+
|
|
847
|
+
|
|
848
|
+
function __rest(s, e) {
|
|
849
|
+
var t = {};
|
|
850
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
851
|
+
t[p] = s[p];
|
|
852
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
853
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
854
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
855
|
+
t[p[i]] = s[p[i]];
|
|
856
|
+
}
|
|
857
|
+
return t;
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
861
|
+
var e = new Error(message);
|
|
862
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
863
|
+
};
|
|
864
|
+
|
|
865
|
+
/**
|
|
866
|
+
* Converts a configuration for a look into an easier to consult object of fully qualified looks for each case.
|
|
867
|
+
*
|
|
868
|
+
* @param lookConfig A look configuration object
|
|
869
|
+
* @returns An object with four keys for a look with each possible state of being selected or not and being highlighted or not.
|
|
870
|
+
*/
|
|
871
|
+
const extractLooksFromConfig = lookConfig => {
|
|
872
|
+
const {
|
|
873
|
+
selected,
|
|
874
|
+
highlighted
|
|
875
|
+
} = lookConfig,
|
|
876
|
+
rest = __rest(lookConfig, ["selected", "highlighted"]);
|
|
877
|
+
const defaultLook = rest;
|
|
878
|
+
const selectedLook = Object.assign(Object.assign({}, defaultLook), selected);
|
|
879
|
+
const highlightedLook = Object.assign(Object.assign({}, defaultLook), highlighted);
|
|
880
|
+
const selectedAndHighlightedLook = Object.assign(Object.assign(Object.assign({}, defaultLook), highlighted), selected);
|
|
881
|
+
return {
|
|
882
|
+
defaultLook,
|
|
883
|
+
selectedLook,
|
|
884
|
+
highlightedLook,
|
|
885
|
+
selectedAndHighlightedLook
|
|
886
|
+
};
|
|
887
|
+
};
|
|
888
|
+
|
|
831
889
|
/**
|
|
832
890
|
* Represents a collection of diagram entities of a type that exists as part of a diagram model.
|
|
833
891
|
* @public
|
|
@@ -964,6 +1022,10 @@ class DiagramEntitySet {
|
|
|
964
1022
|
}
|
|
965
1023
|
}
|
|
966
1024
|
|
|
1025
|
+
const escapeSelector = selector => {
|
|
1026
|
+
return selector.replace(/([!"#$%&'()*+,\-./:;<=>?@[\\\]^`{|}])/g, '\\$1');
|
|
1027
|
+
};
|
|
1028
|
+
|
|
967
1029
|
/**
|
|
968
1030
|
* Default priority value for diagram elements.
|
|
969
1031
|
* @private
|
|
@@ -976,6 +1038,10 @@ const DEFAULT_PRIORITY = 0;
|
|
|
976
1038
|
* @see DiagramCanvas
|
|
977
1039
|
*/
|
|
978
1040
|
class DiagramElement {
|
|
1041
|
+
/**
|
|
1042
|
+
* Identifier that uniquely identifies this element within its diagram model. Cannot be an empty string.
|
|
1043
|
+
* @public
|
|
1044
|
+
*/
|
|
979
1045
|
get id() {
|
|
980
1046
|
return this._id;
|
|
981
1047
|
}
|
|
@@ -1021,7 +1087,7 @@ class DiagramElement {
|
|
|
1021
1087
|
*/
|
|
1022
1088
|
select() {
|
|
1023
1089
|
var _a, _b;
|
|
1024
|
-
return (_b = (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.selectCanvasView()) === null || _b === undefined ? undefined : _b.select(`
|
|
1090
|
+
return (_b = (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.selectCanvasView()) === null || _b === undefined ? undefined : _b.select(`[id='${escapeSelector(this.id)}']`);
|
|
1025
1091
|
}
|
|
1026
1092
|
}
|
|
1027
1093
|
class DiagramElementSet extends DiagramEntitySet {
|
|
@@ -1244,7 +1310,6 @@ class ValueSet {
|
|
|
1244
1310
|
constructor(propertySet, rootElement) {
|
|
1245
1311
|
this.displayedProperties = [];
|
|
1246
1312
|
this.hiddenProperties = [];
|
|
1247
|
-
// TODO JC: make this private after reviewing how it's used from React
|
|
1248
1313
|
this.values = {};
|
|
1249
1314
|
this.valueSets = {};
|
|
1250
1315
|
/**
|
|
@@ -1529,7 +1594,7 @@ class ValueSet {
|
|
|
1529
1594
|
this.values[key] = structuredClone(property.defaultValue);
|
|
1530
1595
|
}
|
|
1531
1596
|
if (rootAttribute !== undefined && rootAttribute !== null) {
|
|
1532
|
-
if (property.defaultValue !== undefined) {
|
|
1597
|
+
if (property.defaultValue !== undefined && !equals(this.values[key], property.defaultValue)) {
|
|
1533
1598
|
this.setRootElementValue(rootAttribute, this.values[key]);
|
|
1534
1599
|
} else {
|
|
1535
1600
|
this.values[key] = this.getRootElementValue(rootAttribute);
|
|
@@ -1647,6 +1712,34 @@ const diff = (a, b) => {
|
|
|
1647
1712
|
}
|
|
1648
1713
|
return [aDiff, bDiff];
|
|
1649
1714
|
};
|
|
1715
|
+
/**
|
|
1716
|
+
* Calculates the differences between the two given values of a valueset and returns two objects containing the differences in each relative to the other.
|
|
1717
|
+
*
|
|
1718
|
+
* @param a An object.
|
|
1719
|
+
* @param b An object.
|
|
1720
|
+
* @param valueSet A ValueSet to use as reference for the keys and types of each property.
|
|
1721
|
+
* @returns A tuple of two objects with each containing the keys that have a different value in the corresponding argument compared to the other argument.
|
|
1722
|
+
*/
|
|
1723
|
+
const diffProperties = (a, b, valueSet) => {
|
|
1724
|
+
const aDiff = {};
|
|
1725
|
+
const bDiff = {};
|
|
1726
|
+
for (const key in valueSet.propertySet.propertyMap) {
|
|
1727
|
+
if (valueSet.propertySet.propertyMap[key].type === exports.Type.Object) {
|
|
1728
|
+
const diffAB = diffProperties(a[key], b[key], valueSet.getSubValueSet(key));
|
|
1729
|
+
// only add the key if differences are detected
|
|
1730
|
+
if (Object.keys(diffAB[0]).length > 0 && Object.keys(diffAB[1]).length > 0) {
|
|
1731
|
+
aDiff[key] = diffAB[0];
|
|
1732
|
+
bDiff[key] = diffAB[1];
|
|
1733
|
+
}
|
|
1734
|
+
} else {
|
|
1735
|
+
if (!equals(a[key], b[key])) {
|
|
1736
|
+
aDiff[key] = a[key];
|
|
1737
|
+
bDiff[key] = b[key];
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
return [aDiff, bDiff];
|
|
1742
|
+
};
|
|
1650
1743
|
/**
|
|
1651
1744
|
* Checks if the given value is an object.
|
|
1652
1745
|
* @public
|
|
@@ -1662,16 +1755,24 @@ const isObject = x => x !== undefined && x !== null && x.constructor === Object;
|
|
|
1662
1755
|
*/
|
|
1663
1756
|
const DIAGRAM_CONNECTION_TYPE_DEFAULTS = {
|
|
1664
1757
|
name: '',
|
|
1665
|
-
width: 1,
|
|
1666
|
-
shape: exports.LineShape.Straight,
|
|
1667
|
-
style: exports.LineStyle.Solid,
|
|
1668
1758
|
label: null,
|
|
1669
|
-
|
|
1670
|
-
|
|
1759
|
+
look: {
|
|
1760
|
+
lookType: 'connection-look',
|
|
1761
|
+
color: '#000000',
|
|
1762
|
+
thickness: 1,
|
|
1763
|
+
shape: exports.LineShape.Straight,
|
|
1764
|
+
style: exports.LineStyle.Solid,
|
|
1765
|
+
selected: {
|
|
1766
|
+
color: '#AA00AA'
|
|
1767
|
+
},
|
|
1768
|
+
highlighted: {
|
|
1769
|
+
thickness: 2
|
|
1770
|
+
}
|
|
1771
|
+
},
|
|
1772
|
+
startMarkerLook: undefined,
|
|
1773
|
+
endMarkerLook: undefined,
|
|
1671
1774
|
startTypes: [],
|
|
1672
1775
|
endTypes: [],
|
|
1673
|
-
color: '#000000',
|
|
1674
|
-
selectedColor: '#000000',
|
|
1675
1776
|
properties: []
|
|
1676
1777
|
};
|
|
1677
1778
|
/**
|
|
@@ -1684,16 +1785,38 @@ class DiagramConnectionType {
|
|
|
1684
1785
|
const values = Object.assign(Object.assign({}, DIAGRAM_CONNECTION_TYPE_DEFAULTS), options);
|
|
1685
1786
|
this.id = values.id;
|
|
1686
1787
|
this.name = values.name;
|
|
1687
|
-
this.width = values.width;
|
|
1688
|
-
this.shape = values.shape;
|
|
1689
|
-
this.style = values.style;
|
|
1690
1788
|
this.label = values.label;
|
|
1691
|
-
|
|
1692
|
-
this.
|
|
1789
|
+
const looks = extractLooksFromConfig(values.look);
|
|
1790
|
+
this.defaultLook = looks.defaultLook;
|
|
1791
|
+
this.selectedLook = looks.selectedLook;
|
|
1792
|
+
this.highlightedLook = looks.highlightedLook;
|
|
1793
|
+
this.selectedAndHighlightedLook = looks.selectedAndHighlightedLook;
|
|
1794
|
+
if (values.startMarkerLook !== undefined) {
|
|
1795
|
+
const startMarkerLooks = extractLooksFromConfig(values.startMarkerLook);
|
|
1796
|
+
this.defaultStartMarkerLook = startMarkerLooks.defaultLook;
|
|
1797
|
+
this.selectedStartMarkerLook = startMarkerLooks.selectedLook;
|
|
1798
|
+
this.highlightedStartMarkerLook = startMarkerLooks.highlightedLook;
|
|
1799
|
+
this.selectedAndHighlightedStartMarkerLook = startMarkerLooks.selectedAndHighlightedLook;
|
|
1800
|
+
} else {
|
|
1801
|
+
this.defaultStartMarkerLook = null;
|
|
1802
|
+
this.selectedStartMarkerLook = null;
|
|
1803
|
+
this.highlightedStartMarkerLook = null;
|
|
1804
|
+
this.selectedAndHighlightedStartMarkerLook = null;
|
|
1805
|
+
}
|
|
1806
|
+
if (values.endMarkerLook !== undefined) {
|
|
1807
|
+
const endMarkerLooks = extractLooksFromConfig(values.endMarkerLook);
|
|
1808
|
+
this.defaultEndMarkerLook = endMarkerLooks.defaultLook;
|
|
1809
|
+
this.selectedEndMarkerLook = endMarkerLooks.selectedLook;
|
|
1810
|
+
this.highlightedEndMarkerLook = endMarkerLooks.highlightedLook;
|
|
1811
|
+
this.selectedAndHighlightedEndMarkerLook = endMarkerLooks.selectedAndHighlightedLook;
|
|
1812
|
+
} else {
|
|
1813
|
+
this.defaultEndMarkerLook = null;
|
|
1814
|
+
this.selectedEndMarkerLook = null;
|
|
1815
|
+
this.highlightedEndMarkerLook = null;
|
|
1816
|
+
this.selectedAndHighlightedEndMarkerLook = null;
|
|
1817
|
+
}
|
|
1693
1818
|
this.startTypes = values.startTypes;
|
|
1694
1819
|
this.endTypes = values.endTypes;
|
|
1695
|
-
this.color = values.color;
|
|
1696
|
-
this.selectedColor = values.selectedColor;
|
|
1697
1820
|
this.propertySet = new PropertySet(values.properties);
|
|
1698
1821
|
}
|
|
1699
1822
|
canStartFromType(type) {
|
|
@@ -1709,6 +1832,27 @@ class DiagramConnectionType {
|
|
|
1709
1832
|
* @see DiagramPort
|
|
1710
1833
|
*/
|
|
1711
1834
|
class DiagramConnection extends DiagramElement {
|
|
1835
|
+
get type() {
|
|
1836
|
+
return this._type;
|
|
1837
|
+
}
|
|
1838
|
+
set type(type) {
|
|
1839
|
+
var _a, _b;
|
|
1840
|
+
(_b = (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.userSelection) === null || _b === undefined ? undefined : _b.openInPropertyEditor(undefined);
|
|
1841
|
+
this._type = type;
|
|
1842
|
+
if (this.valueSet) {
|
|
1843
|
+
this.valueSet = new ValueSet(type.propertySet, this);
|
|
1844
|
+
}
|
|
1845
|
+
this.updateInView();
|
|
1846
|
+
}
|
|
1847
|
+
get typeString() {
|
|
1848
|
+
return this.type.id;
|
|
1849
|
+
}
|
|
1850
|
+
set typeString(typeString) {
|
|
1851
|
+
const type = this.model.connections.types.get(typeString);
|
|
1852
|
+
if (type) {
|
|
1853
|
+
this.type = type;
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1712
1856
|
/**
|
|
1713
1857
|
* Name of this connection. Alias for this connection's middle label.
|
|
1714
1858
|
* @public
|
|
@@ -1719,10 +1863,127 @@ class DiagramConnection extends DiagramElement {
|
|
|
1719
1863
|
set name(name) {
|
|
1720
1864
|
this.middleLabel = name;
|
|
1721
1865
|
}
|
|
1866
|
+
/**
|
|
1867
|
+
* Current look of the connection.
|
|
1868
|
+
* @private
|
|
1869
|
+
*/
|
|
1870
|
+
get look() {
|
|
1871
|
+
if (this.selected) {
|
|
1872
|
+
if (this.highlighted) {
|
|
1873
|
+
return this._selectedAndHighlightedLook !== undefined ? this._selectedAndHighlightedLook : this.type.selectedAndHighlightedLook;
|
|
1874
|
+
} else {
|
|
1875
|
+
return this._selectedLook !== undefined ? this._selectedLook : this.type.selectedLook;
|
|
1876
|
+
}
|
|
1877
|
+
} else {
|
|
1878
|
+
if (this.highlighted) {
|
|
1879
|
+
return this._highlightedLook !== undefined ? this._highlightedLook : this.type.highlightedLook;
|
|
1880
|
+
} else {
|
|
1881
|
+
return this._defaultLook !== undefined ? this._defaultLook : this.type.defaultLook;
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
}
|
|
1885
|
+
/**
|
|
1886
|
+
* Sets the look configuration of the connection to override the one determined by the type.
|
|
1887
|
+
* `undefined` resets it to the one determined by the type.
|
|
1888
|
+
* @private
|
|
1889
|
+
*/
|
|
1890
|
+
set look(look) {
|
|
1891
|
+
if (look) {
|
|
1892
|
+
const looks = extractLooksFromConfig(look);
|
|
1893
|
+
this._defaultLook = Object.assign(Object.assign({}, this._defaultLook), looks.defaultLook);
|
|
1894
|
+
this._selectedLook = Object.assign(Object.assign({}, this._selectedLook), looks.selectedLook);
|
|
1895
|
+
this._highlightedLook = Object.assign(Object.assign({}, this._highlightedLook), looks.highlightedLook);
|
|
1896
|
+
this._selectedAndHighlightedLook = Object.assign(Object.assign({}, this._selectedAndHighlightedLook), looks.selectedAndHighlightedLook);
|
|
1897
|
+
} else {
|
|
1898
|
+
this._defaultLook = look;
|
|
1899
|
+
this._selectedLook = look;
|
|
1900
|
+
this._highlightedLook = look;
|
|
1901
|
+
this._selectedAndHighlightedLook = look;
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
/**
|
|
1905
|
+
* Current look of the start marker.
|
|
1906
|
+
* @private
|
|
1907
|
+
*/
|
|
1908
|
+
get startMarkerLook() {
|
|
1909
|
+
if (this.selected) {
|
|
1910
|
+
if (this.highlighted) {
|
|
1911
|
+
return this._selectedAndHighlightedStartMarkerLook !== undefined ? this._selectedAndHighlightedStartMarkerLook : this.type.selectedAndHighlightedStartMarkerLook;
|
|
1912
|
+
} else {
|
|
1913
|
+
return this._selectedStartMarkerLook !== undefined ? this._selectedStartMarkerLook : this.type.selectedStartMarkerLook;
|
|
1914
|
+
}
|
|
1915
|
+
} else {
|
|
1916
|
+
if (this.highlighted) {
|
|
1917
|
+
return this._highlightedStartMarkerLook !== undefined ? this._highlightedStartMarkerLook : this.type.highlightedStartMarkerLook;
|
|
1918
|
+
} else {
|
|
1919
|
+
return this._defaultStartMarkerLook !== undefined ? this._defaultStartMarkerLook : this.type.defaultStartMarkerLook;
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
/**
|
|
1924
|
+
* Sets the look configuration of the start marker to override the one determined by the type.
|
|
1925
|
+
* `null` stands for no marker and `undefined` resets it to the one determined by the type.
|
|
1926
|
+
* @private
|
|
1927
|
+
*/
|
|
1928
|
+
set startMarkerLook(startMarkerLook) {
|
|
1929
|
+
if (startMarkerLook) {
|
|
1930
|
+
const looks = extractLooksFromConfig(startMarkerLook);
|
|
1931
|
+
this._defaultStartMarkerLook = Object.assign(Object.assign({}, this._defaultStartMarkerLook), looks.defaultLook);
|
|
1932
|
+
this._selectedStartMarkerLook = Object.assign(Object.assign({}, this._selectedStartMarkerLook), looks.selectedLook);
|
|
1933
|
+
this._highlightedStartMarkerLook = Object.assign(Object.assign({}, this._highlightedStartMarkerLook), looks.highlightedLook);
|
|
1934
|
+
this._selectedAndHighlightedStartMarkerLook = Object.assign(Object.assign({}, this._selectedAndHighlightedStartMarkerLook), looks.selectedAndHighlightedLook);
|
|
1935
|
+
} else {
|
|
1936
|
+
this._defaultStartMarkerLook = startMarkerLook;
|
|
1937
|
+
this._selectedStartMarkerLook = startMarkerLook;
|
|
1938
|
+
this._highlightedStartMarkerLook = startMarkerLook;
|
|
1939
|
+
this._selectedAndHighlightedStartMarkerLook = startMarkerLook;
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
/**
|
|
1943
|
+
* Current look of the end marker.
|
|
1944
|
+
* @private
|
|
1945
|
+
*/
|
|
1946
|
+
get endMarkerLook() {
|
|
1947
|
+
if (this.selected) {
|
|
1948
|
+
if (this.highlighted) {
|
|
1949
|
+
return this._selectedAndHighlightedEndMarkerLook !== undefined ? this._selectedAndHighlightedEndMarkerLook : this.type.selectedAndHighlightedEndMarkerLook;
|
|
1950
|
+
} else {
|
|
1951
|
+
return this._selectedEndMarkerLook !== undefined ? this._selectedEndMarkerLook : this.type.selectedEndMarkerLook;
|
|
1952
|
+
}
|
|
1953
|
+
} else {
|
|
1954
|
+
if (this.highlighted) {
|
|
1955
|
+
return this._highlightedEndMarkerLook !== undefined ? this._highlightedEndMarkerLook : this.type.highlightedEndMarkerLook;
|
|
1956
|
+
} else {
|
|
1957
|
+
return this._defaultEndMarkerLook !== undefined ? this._defaultEndMarkerLook : this.type.defaultEndMarkerLook;
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
/**
|
|
1962
|
+
* Sets the look configuration of the end marker to override the one determined by the type.
|
|
1963
|
+
* `null` stands for no marker and `undefined` resets it to the one determined by the type.
|
|
1964
|
+
* @private
|
|
1965
|
+
*/
|
|
1966
|
+
set endMarkerLook(endMarkerLook) {
|
|
1967
|
+
if (endMarkerLook) {
|
|
1968
|
+
const looks = extractLooksFromConfig(endMarkerLook);
|
|
1969
|
+
this._defaultEndMarkerLook = Object.assign(Object.assign({}, this._defaultEndMarkerLook), looks.defaultLook);
|
|
1970
|
+
this._selectedEndMarkerLook = Object.assign(Object.assign({}, this._selectedEndMarkerLook), looks.selectedLook);
|
|
1971
|
+
this._highlightedEndMarkerLook = Object.assign(Object.assign({}, this._highlightedEndMarkerLook), looks.highlightedLook);
|
|
1972
|
+
this._selectedAndHighlightedEndMarkerLook = Object.assign(Object.assign({}, this._selectedAndHighlightedEndMarkerLook), looks.selectedAndHighlightedLook);
|
|
1973
|
+
} else {
|
|
1974
|
+
this._defaultEndMarkerLook = endMarkerLook;
|
|
1975
|
+
this._selectedEndMarkerLook = endMarkerLook;
|
|
1976
|
+
this._highlightedEndMarkerLook = endMarkerLook;
|
|
1977
|
+
this._selectedAndHighlightedEndMarkerLook = endMarkerLook;
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1722
1980
|
constructor(model, type, start, end, id) {
|
|
1723
1981
|
if (model.connections.get(id) !== undefined) {
|
|
1724
1982
|
throw new Error(`DiagramConnection with id "${id}" already exists`);
|
|
1725
1983
|
}
|
|
1984
|
+
if (!id) {
|
|
1985
|
+
throw new Error(`DiagramConnection cannot have an empty or null id`);
|
|
1986
|
+
}
|
|
1726
1987
|
super(model, id);
|
|
1727
1988
|
/**
|
|
1728
1989
|
* Coordinates of the start point of this connection.
|
|
@@ -1754,11 +2015,9 @@ class DiagramConnection extends DiagramElement {
|
|
|
1754
2015
|
* @public
|
|
1755
2016
|
*/
|
|
1756
2017
|
this.points = [];
|
|
1757
|
-
this.
|
|
2018
|
+
this._type = type;
|
|
1758
2019
|
this.valueSet = new ValueSet(type.propertySet, this);
|
|
1759
2020
|
this.originalData = {};
|
|
1760
|
-
this.startMarkerLook = type.defaultStartMarkerLook;
|
|
1761
|
-
this.endMarkerLook = type.defaultEndMarkerLook;
|
|
1762
2021
|
this.setStart(start);
|
|
1763
2022
|
this.setEnd(end);
|
|
1764
2023
|
}
|
|
@@ -1931,7 +2190,7 @@ class DiagramConnectionSet extends DiagramElementSet {
|
|
|
1931
2190
|
* @param type The type of the connection given as either the type itself or the id of the type.
|
|
1932
2191
|
* @param start The start port of the connection.
|
|
1933
2192
|
* @param end The end port of the connection.
|
|
1934
|
-
* @param id The id of the connection.
|
|
2193
|
+
* @param id The id of the connection. Cannot be an empty string.
|
|
1935
2194
|
* @returns The instanced connection.
|
|
1936
2195
|
*/
|
|
1937
2196
|
new(type, start, end, id) {
|
|
@@ -2035,10 +2294,6 @@ class DiagramField extends DiagramElement {
|
|
|
2035
2294
|
this.editable = editable;
|
|
2036
2295
|
this.fit = fit;
|
|
2037
2296
|
}
|
|
2038
|
-
select() {
|
|
2039
|
-
var _a, _b;
|
|
2040
|
-
return (_b = (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.selectCanvasView()) === null || _b === undefined ? undefined : _b.select(`foreignObject#${this.id}`);
|
|
2041
|
-
}
|
|
2042
2297
|
get removed() {
|
|
2043
2298
|
return this.selfRemoved || this.rootElement !== undefined && this.rootElement.removed;
|
|
2044
2299
|
}
|
|
@@ -2257,30 +2512,6 @@ const getTopPadding$1 = config => {
|
|
|
2257
2512
|
}
|
|
2258
2513
|
};
|
|
2259
2514
|
|
|
2260
|
-
/**
|
|
2261
|
-
* Default values of the look of a diagram section.
|
|
2262
|
-
* @private
|
|
2263
|
-
* @see DIAGRAM_SECTION_DEFAULTS
|
|
2264
|
-
*/
|
|
2265
|
-
const DIAGRAM_SECTION_LOOK_DEFAULTS = {
|
|
2266
|
-
lookType: 'shaped-look',
|
|
2267
|
-
shape: exports.ClosedShape.Rectangle,
|
|
2268
|
-
fillColor: '#FFFFFF',
|
|
2269
|
-
borderColor: '#000000',
|
|
2270
|
-
selectedFillColor: '#FFFFFF',
|
|
2271
|
-
selectedBorderColor: '#000000'
|
|
2272
|
-
};
|
|
2273
|
-
/**
|
|
2274
|
-
* Default values of the parameters of a diagram section.
|
|
2275
|
-
* @private
|
|
2276
|
-
* @see DiagramSection
|
|
2277
|
-
*/
|
|
2278
|
-
const DIAGRAM_SECTION_DEFAULTS = {
|
|
2279
|
-
label: null,
|
|
2280
|
-
ports: [],
|
|
2281
|
-
look: DIAGRAM_SECTION_LOOK_DEFAULTS,
|
|
2282
|
-
priority: DEFAULT_PRIORITY
|
|
2283
|
-
};
|
|
2284
2515
|
/**
|
|
2285
2516
|
* Default value of the default width of a diagram section.
|
|
2286
2517
|
* @private
|
|
@@ -2305,6 +2536,41 @@ const DIAGRAM_SECTION_MIN_WIDTH = 1;
|
|
|
2305
2536
|
* @see DiagramSection
|
|
2306
2537
|
*/
|
|
2307
2538
|
const DIAGRAM_SECTION_MIN_HEIGHT = 1;
|
|
2539
|
+
/**
|
|
2540
|
+
* A grid of sections which a node has.
|
|
2541
|
+
* @public
|
|
2542
|
+
* @see DiagramNode
|
|
2543
|
+
* @see SectionGridConfig
|
|
2544
|
+
*/
|
|
2545
|
+
class DiagramSectionGrid {
|
|
2546
|
+
constructor(options) {
|
|
2547
|
+
this.margin = options.margin || 0;
|
|
2548
|
+
this.defaultWidths = options.defaultWidths || null;
|
|
2549
|
+
this.defaultHeights = options.defaultHeights || null;
|
|
2550
|
+
this.minWidths = options.minWidths || null;
|
|
2551
|
+
this.minHeights = options.minHeights || null;
|
|
2552
|
+
this.sections = [];
|
|
2553
|
+
for (const sectionRow of options.sections) {
|
|
2554
|
+
const sectionList = [];
|
|
2555
|
+
this.sections.push(sectionList);
|
|
2556
|
+
for (const section of sectionRow) {
|
|
2557
|
+
sectionList.push(new DiagramSectionType(section));
|
|
2558
|
+
}
|
|
2559
|
+
}
|
|
2560
|
+
}
|
|
2561
|
+
}
|
|
2562
|
+
class DiagramSectionType {
|
|
2563
|
+
constructor(options) {
|
|
2564
|
+
this.label = options.label || null;
|
|
2565
|
+
this.ports = options.ports || [];
|
|
2566
|
+
this.priority = options.priority || DEFAULT_PRIORITY;
|
|
2567
|
+
const looks = extractLooksFromConfig(options.look || DIAGRAM_NODE_LOOK_DEFAULTS);
|
|
2568
|
+
this.defaultLook = looks.defaultLook;
|
|
2569
|
+
this.selectedLook = looks.selectedLook;
|
|
2570
|
+
this.highlightedLook = looks.highlightedLook;
|
|
2571
|
+
this.selectedAndHighlightedLook = looks.selectedAndHighlightedLook;
|
|
2572
|
+
}
|
|
2573
|
+
}
|
|
2308
2574
|
/**
|
|
2309
2575
|
* A section of a node which can have connections and display a property of the node.
|
|
2310
2576
|
* @public
|
|
@@ -2326,10 +2592,52 @@ class DiagramSection extends DiagramElement {
|
|
|
2326
2592
|
this.label.text = name;
|
|
2327
2593
|
}
|
|
2328
2594
|
}
|
|
2595
|
+
/**
|
|
2596
|
+
* Current look of this port.
|
|
2597
|
+
* @private
|
|
2598
|
+
*/
|
|
2599
|
+
get look() {
|
|
2600
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2601
|
+
if (this.selected) {
|
|
2602
|
+
if (this.highlighted) {
|
|
2603
|
+
return this._selectedAndHighlightedLook !== undefined ? this._selectedAndHighlightedLook : ((_a = this.type) === null || _a === undefined ? undefined : _a.selectedAndHighlightedLook) || ((_b = this.node) === null || _b === undefined ? undefined : _b.look);
|
|
2604
|
+
} else {
|
|
2605
|
+
return this._selectedLook !== undefined ? this._selectedLook : ((_c = this.type) === null || _c === undefined ? undefined : _c.selectedLook) || ((_d = this.node) === null || _d === undefined ? undefined : _d.look);
|
|
2606
|
+
}
|
|
2607
|
+
} else {
|
|
2608
|
+
if (this.highlighted) {
|
|
2609
|
+
return this._highlightedLook !== undefined ? this._highlightedLook : ((_e = this.type) === null || _e === undefined ? undefined : _e.highlightedLook) || ((_f = this.node) === null || _f === undefined ? undefined : _f.look);
|
|
2610
|
+
} else {
|
|
2611
|
+
return this._defaultLook !== undefined ? this._defaultLook : ((_g = this.type) === null || _g === undefined ? undefined : _g.defaultLook) || ((_h = this.node) === null || _h === undefined ? undefined : _h.look);
|
|
2612
|
+
}
|
|
2613
|
+
}
|
|
2614
|
+
}
|
|
2615
|
+
/**
|
|
2616
|
+
* Sets the look configuration of the look to override the one determined by the type.
|
|
2617
|
+
* `undefined` resets it to the one determined by the type.
|
|
2618
|
+
* @private
|
|
2619
|
+
*/
|
|
2620
|
+
set look(look) {
|
|
2621
|
+
if (look) {
|
|
2622
|
+
const looks = extractLooksFromConfig(look);
|
|
2623
|
+
this._defaultLook = Object.assign(Object.assign({}, this._defaultLook), looks.defaultLook);
|
|
2624
|
+
this._selectedLook = Object.assign(Object.assign({}, this._selectedLook), looks.selectedLook);
|
|
2625
|
+
this._highlightedLook = Object.assign(Object.assign({}, this._highlightedLook), looks.highlightedLook);
|
|
2626
|
+
this._selectedAndHighlightedLook = Object.assign(Object.assign({}, this._selectedAndHighlightedLook), looks.selectedAndHighlightedLook);
|
|
2627
|
+
} else {
|
|
2628
|
+
this._defaultLook = look;
|
|
2629
|
+
this._selectedLook = look;
|
|
2630
|
+
this._highlightedLook = look;
|
|
2631
|
+
this._selectedAndHighlightedLook = look;
|
|
2632
|
+
}
|
|
2633
|
+
}
|
|
2329
2634
|
constructor(model, node, indexXInNode, indexYInNode, coords, width, height, id) {
|
|
2330
2635
|
if (model.sections.get(id) !== undefined) {
|
|
2331
2636
|
throw new Error(`DiagramSection with id "${id}" already exists`);
|
|
2332
2637
|
}
|
|
2638
|
+
if (!id) {
|
|
2639
|
+
throw new Error(`DiagramSection cannot have an empty or null id`);
|
|
2640
|
+
}
|
|
2333
2641
|
super(model, id);
|
|
2334
2642
|
/**
|
|
2335
2643
|
* Ports of this section.
|
|
@@ -2368,7 +2676,7 @@ class DiagramSection extends DiagramElement {
|
|
|
2368
2676
|
decorator.raise();
|
|
2369
2677
|
}
|
|
2370
2678
|
}
|
|
2371
|
-
|
|
2679
|
+
get type() {
|
|
2372
2680
|
var _a, _b, _c, _d, _e;
|
|
2373
2681
|
return (_e = (_d = (_c = (_b = (_a = this.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.sectionGrid) === null || _c === undefined ? undefined : _c.sections) === null || _d === undefined ? undefined : _d[this.indexYInNode]) === null || _e === undefined ? undefined : _e[this.indexXInNode];
|
|
2374
2682
|
}
|
|
@@ -2382,7 +2690,7 @@ class DiagramSection extends DiagramElement {
|
|
|
2382
2690
|
}
|
|
2383
2691
|
getPriority() {
|
|
2384
2692
|
var _a, _b, _c, _d, _e, _f;
|
|
2385
|
-
return ((_f = (_e = (_d = (_c = (_b = (_a = this.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.sectionGrid) === null || _c === undefined ? undefined : _c.sections) === null || _d === undefined ? undefined : _d[this.indexYInNode]) === null || _e === undefined ? undefined : _e[this.indexXInNode]) === null || _f === undefined ? undefined : _f.priority) ||
|
|
2693
|
+
return ((_f = (_e = (_d = (_c = (_b = (_a = this.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.sectionGrid) === null || _c === undefined ? undefined : _c.sections) === null || _d === undefined ? undefined : _d[this.indexYInNode]) === null || _e === undefined ? undefined : _e[this.indexXInNode]) === null || _f === undefined ? undefined : _f.priority) || DEFAULT_PRIORITY;
|
|
2386
2694
|
}
|
|
2387
2695
|
/**
|
|
2388
2696
|
* Get the port of this section which is closest to the given coordinates.
|
|
@@ -2533,7 +2841,6 @@ class DiagramSection extends DiagramElement {
|
|
|
2533
2841
|
* @public
|
|
2534
2842
|
*/
|
|
2535
2843
|
setGeometry(geometry) {
|
|
2536
|
-
var _a, _b, _c, _d, _e, _f;
|
|
2537
2844
|
const oldCoordsX = [this.coords[0], this.coords[0] + this.width];
|
|
2538
2845
|
const oldCoordsY = [this.coords[1], this.coords[1] + this.height];
|
|
2539
2846
|
this.coords = [...geometry.coords];
|
|
@@ -2546,10 +2853,11 @@ class DiagramSection extends DiagramElement {
|
|
|
2546
2853
|
port.move(translatePoint(port.coords, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY));
|
|
2547
2854
|
}
|
|
2548
2855
|
// Set label's dimensions as a function of ours.
|
|
2856
|
+
const type = this.type;
|
|
2549
2857
|
if (this.label) {
|
|
2550
|
-
this.label.coords = [this.coords[0] + getLeftMargin(
|
|
2551
|
-
this.label.width = this.width - getLeftMargin(
|
|
2552
|
-
this.label.height = this.height - getTopMargin(
|
|
2858
|
+
this.label.coords = [this.coords[0] + getLeftMargin(type === null || type === undefined ? undefined : type.label), this.coords[1] + getTopMargin(type === null || type === undefined ? undefined : type.label)];
|
|
2859
|
+
this.label.width = this.width - getLeftMargin(type === null || type === undefined ? undefined : type.label) - getRightMargin(type === null || type === undefined ? undefined : type.label);
|
|
2860
|
+
this.label.height = this.height - getTopMargin(type === null || type === undefined ? undefined : type.label) - getBottomMargin(type === null || type === undefined ? undefined : type.label);
|
|
2553
2861
|
this.label.updateInView();
|
|
2554
2862
|
}
|
|
2555
2863
|
// Move decorators to match the new coords.
|
|
@@ -2650,8 +2958,14 @@ const DIAGRAM_NODE_LOOK_DEFAULTS = {
|
|
|
2650
2958
|
shape: exports.ClosedShape.Rectangle,
|
|
2651
2959
|
fillColor: '#FFFFFF',
|
|
2652
2960
|
borderColor: '#000000',
|
|
2653
|
-
|
|
2654
|
-
|
|
2961
|
+
borderThickness: 1,
|
|
2962
|
+
selected: {
|
|
2963
|
+
fillColor: '#FFAAFF',
|
|
2964
|
+
borderColor: '#AA00AA'
|
|
2965
|
+
},
|
|
2966
|
+
highlighted: {
|
|
2967
|
+
borderThickness: 3
|
|
2968
|
+
}
|
|
2655
2969
|
};
|
|
2656
2970
|
/**
|
|
2657
2971
|
* Default values of the parameters of a diagram node.
|
|
@@ -2699,8 +3013,12 @@ class DiagramNodeType {
|
|
|
2699
3013
|
this.topPadding = getTopPadding(values);
|
|
2700
3014
|
this.label = values.label;
|
|
2701
3015
|
this.ports = values.ports;
|
|
2702
|
-
this.sectionGrid = values.sectionGrid;
|
|
2703
|
-
|
|
3016
|
+
this.sectionGrid = values.sectionGrid ? new DiagramSectionGrid(values.sectionGrid) : null;
|
|
3017
|
+
const looks = extractLooksFromConfig(values.look);
|
|
3018
|
+
this.defaultLook = looks.defaultLook;
|
|
3019
|
+
this.selectedLook = looks.selectedLook;
|
|
3020
|
+
this.highlightedLook = looks.highlightedLook;
|
|
3021
|
+
this.selectedAndHighlightedLook = looks.selectedAndHighlightedLook;
|
|
2704
3022
|
this.isUnique = values.isUnique;
|
|
2705
3023
|
this.canBeParentless = values.canBeParentless;
|
|
2706
3024
|
this.childrenTypes = values.childrenTypes;
|
|
@@ -2716,6 +3034,27 @@ class DiagramNodeType {
|
|
|
2716
3034
|
* @see DiagramSection
|
|
2717
3035
|
*/
|
|
2718
3036
|
class DiagramNode extends DiagramElement {
|
|
3037
|
+
get type() {
|
|
3038
|
+
return this._type;
|
|
3039
|
+
}
|
|
3040
|
+
set type(type) {
|
|
3041
|
+
var _a, _b;
|
|
3042
|
+
(_b = (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.userSelection) === null || _b === undefined ? undefined : _b.openInPropertyEditor(undefined);
|
|
3043
|
+
this._type = type;
|
|
3044
|
+
if (this.valueSet) {
|
|
3045
|
+
this.valueSet = new ValueSet(type.propertySet, this);
|
|
3046
|
+
}
|
|
3047
|
+
this.updateInView();
|
|
3048
|
+
}
|
|
3049
|
+
get typeString() {
|
|
3050
|
+
return this.type.id;
|
|
3051
|
+
}
|
|
3052
|
+
set typeString(typeString) {
|
|
3053
|
+
const type = this.model.nodes.types.get(typeString);
|
|
3054
|
+
if (type) {
|
|
3055
|
+
this.type = type;
|
|
3056
|
+
}
|
|
3057
|
+
}
|
|
2719
3058
|
/**
|
|
2720
3059
|
* Name of this node. Alias for this node's label's text.
|
|
2721
3060
|
* @public
|
|
@@ -2729,10 +3068,51 @@ class DiagramNode extends DiagramElement {
|
|
|
2729
3068
|
this.label.text = name;
|
|
2730
3069
|
}
|
|
2731
3070
|
}
|
|
3071
|
+
/**
|
|
3072
|
+
* Current look of this port.
|
|
3073
|
+
* @private
|
|
3074
|
+
*/
|
|
3075
|
+
get look() {
|
|
3076
|
+
if (this.selected) {
|
|
3077
|
+
if (this.highlighted) {
|
|
3078
|
+
return this._selectedAndHighlightedLook !== undefined ? this._selectedAndHighlightedLook : this.type.selectedAndHighlightedLook;
|
|
3079
|
+
} else {
|
|
3080
|
+
return this._selectedLook !== undefined ? this._selectedLook : this.type.selectedLook;
|
|
3081
|
+
}
|
|
3082
|
+
} else {
|
|
3083
|
+
if (this.highlighted) {
|
|
3084
|
+
return this._highlightedLook !== undefined ? this._highlightedLook : this.type.highlightedLook;
|
|
3085
|
+
} else {
|
|
3086
|
+
return this._defaultLook !== undefined ? this._defaultLook : this.type.defaultLook;
|
|
3087
|
+
}
|
|
3088
|
+
}
|
|
3089
|
+
}
|
|
3090
|
+
/**
|
|
3091
|
+
* Sets the look configuration of the look to override the one determined by the type.
|
|
3092
|
+
* `undefined` resets it to the one determined by the type.
|
|
3093
|
+
* @private
|
|
3094
|
+
*/
|
|
3095
|
+
set look(look) {
|
|
3096
|
+
if (look) {
|
|
3097
|
+
const looks = extractLooksFromConfig(look);
|
|
3098
|
+
this._defaultLook = Object.assign(Object.assign({}, this._defaultLook), looks.defaultLook);
|
|
3099
|
+
this._selectedLook = Object.assign(Object.assign({}, this._selectedLook), looks.selectedLook);
|
|
3100
|
+
this._highlightedLook = Object.assign(Object.assign({}, this._highlightedLook), looks.highlightedLook);
|
|
3101
|
+
this._selectedAndHighlightedLook = Object.assign(Object.assign({}, this._selectedAndHighlightedLook), looks.selectedAndHighlightedLook);
|
|
3102
|
+
} else {
|
|
3103
|
+
this._defaultLook = look;
|
|
3104
|
+
this._selectedLook = look;
|
|
3105
|
+
this._highlightedLook = look;
|
|
3106
|
+
this._selectedAndHighlightedLook = look;
|
|
3107
|
+
}
|
|
3108
|
+
}
|
|
2732
3109
|
constructor(model, type, coords = [0, 0], id) {
|
|
2733
3110
|
if (model.nodes.get(id) !== undefined) {
|
|
2734
3111
|
throw new Error(`DiagramNode with id "${id}" already exists`);
|
|
2735
3112
|
}
|
|
3113
|
+
if (!id) {
|
|
3114
|
+
throw new Error(`DiagramNode cannot have an empty or null id`);
|
|
3115
|
+
}
|
|
2736
3116
|
super(model, id);
|
|
2737
3117
|
/**
|
|
2738
3118
|
* Nodes contained within this node.
|
|
@@ -2759,7 +3139,7 @@ class DiagramNode extends DiagramElement {
|
|
|
2759
3139
|
* @public
|
|
2760
3140
|
*/
|
|
2761
3141
|
this.geometryTimestamp = null;
|
|
2762
|
-
this.
|
|
3142
|
+
this._type = type;
|
|
2763
3143
|
this.valueSet = new ValueSet(type.propertySet, this);
|
|
2764
3144
|
this.originalData = {};
|
|
2765
3145
|
this.coords = coords;
|
|
@@ -3238,7 +3618,7 @@ class DiagramNodeSet extends DiagramElementSet {
|
|
|
3238
3618
|
* @public
|
|
3239
3619
|
* @param type The type of the node given as either the type itself or the id of the type.
|
|
3240
3620
|
* @param coords The coordinates of the top left corner of the node in the diagram.
|
|
3241
|
-
* @param id The id of the node.
|
|
3621
|
+
* @param id The id of the node. Cannot be an empty string.
|
|
3242
3622
|
* @returns The instanced node.
|
|
3243
3623
|
*/
|
|
3244
3624
|
new(type, coords, id) {
|
|
@@ -3273,7 +3653,8 @@ class DiagramNodeSet extends DiagramElementSet {
|
|
|
3273
3653
|
if (nodeType.ports.length > 0) {
|
|
3274
3654
|
for (let i = 0; i < nodeType.ports.length; ++i) {
|
|
3275
3655
|
const portConfig = nodeType.ports[i];
|
|
3276
|
-
const
|
|
3656
|
+
const portType = portConfig.type !== undefined ? this.model.ports.types.get(portConfig.type) : undefined;
|
|
3657
|
+
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}_${i}`);
|
|
3277
3658
|
if ((_e = port.type) === null || _e === undefined ? undefined : _e.label) {
|
|
3278
3659
|
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_f = port.type) === null || _f === undefined ? undefined : _f.label);
|
|
3279
3660
|
const labelWidth = 6 * labelConfiguration.fontSize + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
|
|
@@ -3470,14 +3851,24 @@ const getTopPadding = config => {
|
|
|
3470
3851
|
};
|
|
3471
3852
|
|
|
3472
3853
|
/**
|
|
3473
|
-
* Default values of the
|
|
3854
|
+
* Default values of the look of a diagram port.
|
|
3474
3855
|
* @private
|
|
3475
|
-
* @see
|
|
3856
|
+
* @see DIAGRAM_NODE_TYPE_DEFAULTS
|
|
3476
3857
|
*/
|
|
3477
|
-
const
|
|
3478
|
-
|
|
3479
|
-
|
|
3858
|
+
const DIAGRAM_PORT_LOOK_DEFAULTS = {
|
|
3859
|
+
lookType: 'shaped-look',
|
|
3860
|
+
shape: exports.ClosedShape.Ellipse,
|
|
3861
|
+
fillColor: 'transparent',
|
|
3862
|
+
borderColor: 'transparent',
|
|
3863
|
+
borderThickness: 0,
|
|
3864
|
+
selected: {
|
|
3865
|
+
fillColor: 'rgba(255, 0, 255, 0.5)'
|
|
3866
|
+
},
|
|
3867
|
+
highlighted: {
|
|
3868
|
+
fillColor: 'rgba(0, 255, 255, 0.5)'
|
|
3869
|
+
}
|
|
3480
3870
|
};
|
|
3871
|
+
const DIAGRAM_PORT_LOOKS = extractLooksFromConfig(DIAGRAM_PORT_LOOK_DEFAULTS);
|
|
3481
3872
|
/**
|
|
3482
3873
|
* Default values of the parameters of a diagram port.
|
|
3483
3874
|
* @private
|
|
@@ -3488,7 +3879,8 @@ const DIAGRAM_PORT_TYPE_DEFAULTS = {
|
|
|
3488
3879
|
label: null,
|
|
3489
3880
|
allowsOutgoing: true,
|
|
3490
3881
|
allowsIncoming: true,
|
|
3491
|
-
width: 24
|
|
3882
|
+
width: 24,
|
|
3883
|
+
look: DIAGRAM_PORT_LOOK_DEFAULTS
|
|
3492
3884
|
};
|
|
3493
3885
|
/**
|
|
3494
3886
|
* A port type, which holds properties that ports of this type share in common.
|
|
@@ -3504,7 +3896,11 @@ class DiagramPortType {
|
|
|
3504
3896
|
this.allowsOutgoing = values.allowsOutgoing;
|
|
3505
3897
|
this.allowsIncoming = values.allowsIncoming;
|
|
3506
3898
|
this.width = values.width;
|
|
3507
|
-
|
|
3899
|
+
const looks = extractLooksFromConfig(values.look);
|
|
3900
|
+
this.defaultLook = looks.defaultLook;
|
|
3901
|
+
this.selectedLook = looks.selectedLook;
|
|
3902
|
+
this.highlightedLook = looks.highlightedLook;
|
|
3903
|
+
this.selectedAndHighlightedLook = looks.selectedAndHighlightedLook;
|
|
3508
3904
|
}
|
|
3509
3905
|
}
|
|
3510
3906
|
/**
|
|
@@ -3515,6 +3911,27 @@ class DiagramPortType {
|
|
|
3515
3911
|
* @see DiagramSection
|
|
3516
3912
|
*/
|
|
3517
3913
|
class DiagramPort extends DiagramElement {
|
|
3914
|
+
get type() {
|
|
3915
|
+
return this._type;
|
|
3916
|
+
}
|
|
3917
|
+
set type(type) {
|
|
3918
|
+
this._type = type;
|
|
3919
|
+
this.updateInView();
|
|
3920
|
+
}
|
|
3921
|
+
get typeString() {
|
|
3922
|
+
var _a;
|
|
3923
|
+
return (_a = this.type) === null || _a === undefined ? undefined : _a.id;
|
|
3924
|
+
}
|
|
3925
|
+
set typeString(typeString) {
|
|
3926
|
+
if (typeString === undefined) {
|
|
3927
|
+
this.type = undefined;
|
|
3928
|
+
} else {
|
|
3929
|
+
const type = this.model.ports.types.get(typeString);
|
|
3930
|
+
if (type) {
|
|
3931
|
+
this.type = type;
|
|
3932
|
+
}
|
|
3933
|
+
}
|
|
3934
|
+
}
|
|
3518
3935
|
/**
|
|
3519
3936
|
* Whether this port can be used as a connection start point.
|
|
3520
3937
|
*/
|
|
@@ -3542,10 +3959,67 @@ class DiagramPort extends DiagramElement {
|
|
|
3542
3959
|
this.label.text = name;
|
|
3543
3960
|
}
|
|
3544
3961
|
}
|
|
3962
|
+
/**
|
|
3963
|
+
* Current look of this port.
|
|
3964
|
+
* @private
|
|
3965
|
+
*/
|
|
3966
|
+
get look() {
|
|
3967
|
+
var _a, _b, _c, _d;
|
|
3968
|
+
if (this.selected) {
|
|
3969
|
+
if (this.highlighted) {
|
|
3970
|
+
return this._selectedAndHighlightedLook !== undefined ? this._selectedAndHighlightedLook : (_a = this.type || DIAGRAM_PORT_LOOKS) === null || _a === undefined ? undefined : _a.selectedAndHighlightedLook;
|
|
3971
|
+
} else {
|
|
3972
|
+
return this._selectedLook !== undefined ? this._selectedLook : (_b = this.type || DIAGRAM_PORT_LOOKS) === null || _b === undefined ? undefined : _b.selectedLook;
|
|
3973
|
+
}
|
|
3974
|
+
} else {
|
|
3975
|
+
if (this.highlighted) {
|
|
3976
|
+
return this._highlightedLook !== undefined ? this._highlightedLook : (_c = this.type || DIAGRAM_PORT_LOOKS) === null || _c === undefined ? undefined : _c.highlightedLook;
|
|
3977
|
+
} else {
|
|
3978
|
+
return this._defaultLook !== undefined ? this._defaultLook : (_d = this.type || DIAGRAM_PORT_LOOKS) === null || _d === undefined ? undefined : _d.defaultLook;
|
|
3979
|
+
}
|
|
3980
|
+
}
|
|
3981
|
+
}
|
|
3982
|
+
/**
|
|
3983
|
+
* Sets the look configuration of the look to override the one determined by the type.
|
|
3984
|
+
* `undefined` resets it to the one determined by the type.
|
|
3985
|
+
* @private
|
|
3986
|
+
*/
|
|
3987
|
+
set look(look) {
|
|
3988
|
+
if (look) {
|
|
3989
|
+
const looks = extractLooksFromConfig(look);
|
|
3990
|
+
this._defaultLook = Object.assign(Object.assign({}, this._defaultLook), looks.defaultLook);
|
|
3991
|
+
this._selectedLook = Object.assign(Object.assign({}, this._selectedLook), looks.selectedLook);
|
|
3992
|
+
this._highlightedLook = Object.assign(Object.assign({}, this._highlightedLook), looks.highlightedLook);
|
|
3993
|
+
this._selectedAndHighlightedLook = Object.assign(Object.assign({}, this._selectedAndHighlightedLook), looks.selectedAndHighlightedLook);
|
|
3994
|
+
} else {
|
|
3995
|
+
this._defaultLook = look;
|
|
3996
|
+
this._selectedLook = look;
|
|
3997
|
+
this._highlightedLook = look;
|
|
3998
|
+
this._selectedAndHighlightedLook = look;
|
|
3999
|
+
}
|
|
4000
|
+
}
|
|
4001
|
+
/**
|
|
4002
|
+
* Current width of this port.
|
|
4003
|
+
* @private
|
|
4004
|
+
*/
|
|
4005
|
+
get width() {
|
|
4006
|
+
var _a;
|
|
4007
|
+
return ((_a = this.type) === null || _a === undefined ? undefined : _a.width) || DIAGRAM_PORT_TYPE_DEFAULTS.width;
|
|
4008
|
+
}
|
|
4009
|
+
/**
|
|
4010
|
+
* Current height of this port. Same as the width.
|
|
4011
|
+
* @private
|
|
4012
|
+
*/
|
|
4013
|
+
get height() {
|
|
4014
|
+
return this.width;
|
|
4015
|
+
}
|
|
3545
4016
|
constructor(model, type, rootElement, coords, connectionPoint, direction, id) {
|
|
3546
4017
|
if (model.ports.get(id) !== undefined) {
|
|
3547
4018
|
throw new Error(`DiagramPort with id "${id}" already exists`);
|
|
3548
4019
|
}
|
|
4020
|
+
if (!id) {
|
|
4021
|
+
throw new Error(`DiagramPort cannot have an empty or null id`);
|
|
4022
|
+
}
|
|
3549
4023
|
super(model, id);
|
|
3550
4024
|
/**
|
|
3551
4025
|
* Connections that start at this port.
|
|
@@ -3557,7 +4031,7 @@ class DiagramPort extends DiagramElement {
|
|
|
3557
4031
|
* @public
|
|
3558
4032
|
*/
|
|
3559
4033
|
this.incomingConnections = [];
|
|
3560
|
-
this.
|
|
4034
|
+
this._type = type;
|
|
3561
4035
|
this.rootElement = rootElement;
|
|
3562
4036
|
this.coords = coords;
|
|
3563
4037
|
this.connectionPoint = connectionPoint || coords;
|
|
@@ -5148,7 +5622,10 @@ class DiagramHighlightedEvent extends DiagramEvent {
|
|
|
5148
5622
|
class DiagramDecorator extends DiagramElement {
|
|
5149
5623
|
constructor(model, rootElement, coords, width, height, priority, html, id) {
|
|
5150
5624
|
if (model.objects.get(id) !== undefined) {
|
|
5151
|
-
throw new Error(`
|
|
5625
|
+
throw new Error(`DiagramDecorator with id "${id}" already exists`);
|
|
5626
|
+
}
|
|
5627
|
+
if (!id) {
|
|
5628
|
+
throw new Error(`DiagramDecorator cannot have an empty or null id`);
|
|
5152
5629
|
}
|
|
5153
5630
|
super(model, id);
|
|
5154
5631
|
this.rootElement = rootElement;
|
|
@@ -5158,10 +5635,6 @@ class DiagramDecorator extends DiagramElement {
|
|
|
5158
5635
|
this.priority = priority;
|
|
5159
5636
|
this.html = html;
|
|
5160
5637
|
}
|
|
5161
|
-
select() {
|
|
5162
|
-
var _a, _b;
|
|
5163
|
-
return (_b = (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.selectCanvasView()) === null || _b === undefined ? undefined : _b.select(`foreignObject#${this.id}`);
|
|
5164
|
-
}
|
|
5165
5638
|
get removed() {
|
|
5166
5639
|
return this.selfRemoved || this.rootElement !== undefined && this.rootElement.removed;
|
|
5167
5640
|
}
|
|
@@ -5197,7 +5670,14 @@ class DiagramDecoratorSet extends DiagramElementSet {
|
|
|
5197
5670
|
}
|
|
5198
5671
|
/**
|
|
5199
5672
|
* Instance a new decorator and add it to this set.
|
|
5200
|
-
* @
|
|
5673
|
+
* @public
|
|
5674
|
+
* @param coords The coordinates of the top left corner of the decorator in the diagram.
|
|
5675
|
+
* @param width The dimension of the decorator along the x axis.
|
|
5676
|
+
* @param height The dimension of the decorator along the y axis.
|
|
5677
|
+
* @param priority The priority of the decorator. Used when filtering by priority.
|
|
5678
|
+
* @param html The html contents of the decorator.
|
|
5679
|
+
* @param id The id of the decorator. Cannot be an empty string.
|
|
5680
|
+
* @returns The instanced decorator.
|
|
5201
5681
|
*/
|
|
5202
5682
|
new(rootElement, coords, width, height, priority, html, id) {
|
|
5203
5683
|
const decorator = new DiagramDecorator(this.model, rootElement, coords, width, height, priority, html, id);
|
|
@@ -5234,6 +5714,9 @@ class DiagramObject extends DiagramElement {
|
|
|
5234
5714
|
if (model.objects.get(id) !== undefined) {
|
|
5235
5715
|
throw new Error(`DiagramObject with id "${id}" already exists`);
|
|
5236
5716
|
}
|
|
5717
|
+
if (!id) {
|
|
5718
|
+
throw new Error(`DiagramObject cannot have an empty or null id`);
|
|
5719
|
+
}
|
|
5237
5720
|
super(model, id);
|
|
5238
5721
|
this.coords = coords;
|
|
5239
5722
|
this.width = width;
|
|
@@ -5241,10 +5724,6 @@ class DiagramObject extends DiagramElement {
|
|
|
5241
5724
|
this.priority = priority;
|
|
5242
5725
|
this.html = html;
|
|
5243
5726
|
}
|
|
5244
|
-
select() {
|
|
5245
|
-
var _a, _b;
|
|
5246
|
-
return (_b = (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.selectCanvasView()) === null || _b === undefined ? undefined : _b.select(`foreignObject#${this.id}`);
|
|
5247
|
-
}
|
|
5248
5727
|
get removed() {
|
|
5249
5728
|
return this.selfRemoved;
|
|
5250
5729
|
}
|
|
@@ -5280,7 +5759,14 @@ class DiagramObjectSet extends DiagramElementSet {
|
|
|
5280
5759
|
}
|
|
5281
5760
|
/**
|
|
5282
5761
|
* Instance a new object and add it to this set.
|
|
5283
|
-
* @
|
|
5762
|
+
* @public
|
|
5763
|
+
* @param coords The coordinates of the top left corner of the object in the diagram.
|
|
5764
|
+
* @param width The dimension of the object along the x axis.
|
|
5765
|
+
* @param height The dimension of the object along the y axis.
|
|
5766
|
+
* @param priority The priority of the object. Used when filtering by priority.
|
|
5767
|
+
* @param html The html contents of the object.
|
|
5768
|
+
* @param id The id of the object. Cannot be an empty string.
|
|
5769
|
+
* @returns The instanced object.
|
|
5284
5770
|
*/
|
|
5285
5771
|
new(coords, width, height, priority, html, id) {
|
|
5286
5772
|
const object = new DiagramObject(this.model, coords, width, height, priority, html, id);
|
|
@@ -5383,11 +5869,76 @@ class DiagramModel {
|
|
|
5383
5869
|
}
|
|
5384
5870
|
}
|
|
5385
5871
|
|
|
5872
|
+
/**
|
|
5873
|
+
* Checks if the given mouse event was produced with a secondary button press.
|
|
5874
|
+
* @private
|
|
5875
|
+
* @param event A mouse event.
|
|
5876
|
+
* @returns `true` if the given mouse event was produced with a secondary button press, `false` otherwise.
|
|
5877
|
+
*/
|
|
5878
|
+
const isSecondaryButton = event => {
|
|
5879
|
+
return !!event.button;
|
|
5880
|
+
};
|
|
5881
|
+
/**
|
|
5882
|
+
* Get the SVG path of a diagram connection.
|
|
5883
|
+
* @private
|
|
5884
|
+
* @see linePath
|
|
5885
|
+
*/
|
|
5886
|
+
const getConnectionPath = (shape, startCoords, endCoords, startDirection, endDirection, width, startMarkerWidth, endMarkerWidth) => {
|
|
5887
|
+
return linePath(shape, [startCoords, endCoords], startDirection, endDirection, Math.max(
|
|
5888
|
+
// reasonable value for the minimumDistanceBeforeTurn relative to the line width
|
|
5889
|
+
10, startMarkerWidth || 0, endMarkerWidth || 0) * width);
|
|
5890
|
+
};
|
|
5891
|
+
const setCursorStyle = style => {
|
|
5892
|
+
if (!style) {
|
|
5893
|
+
d3__namespace.select('body').style('cursor', exports.CursorStyle.Auto);
|
|
5894
|
+
} else {
|
|
5895
|
+
d3__namespace.select('body').style('cursor', style);
|
|
5896
|
+
}
|
|
5897
|
+
};
|
|
5898
|
+
const getRelatedNodeOrItself = element => {
|
|
5899
|
+
if (element instanceof DiagramNode) {
|
|
5900
|
+
return element;
|
|
5901
|
+
}
|
|
5902
|
+
if (element instanceof DiagramSection) {
|
|
5903
|
+
return element.node || element;
|
|
5904
|
+
}
|
|
5905
|
+
return element.rootElement instanceof DiagramNode || element.rootElement instanceof DiagramSection || element.rootElement instanceof DiagramPort ? getRelatedNodeOrItself(element.rootElement) : element;
|
|
5906
|
+
};
|
|
5907
|
+
const initializeLook = selection => {
|
|
5908
|
+
selection.filter('.shaped-look').append('path');
|
|
5909
|
+
selection.filter('.image-look').append('image').attr('preserveAspectRatio', 'none');
|
|
5910
|
+
selection.filter('.stretchable-image-look').append('image').attr('class', 'top-left-image').attr('preserveAspectRatio', 'none');
|
|
5911
|
+
selection.filter('.stretchable-image-look').append('image').attr('class', 'top-image').attr('preserveAspectRatio', 'none');
|
|
5912
|
+
selection.filter('.stretchable-image-look').append('image').attr('class', 'top-right-image').attr('preserveAspectRatio', 'none');
|
|
5913
|
+
selection.filter('.stretchable-image-look').append('image').attr('class', 'left-image').attr('preserveAspectRatio', 'none');
|
|
5914
|
+
selection.filter('.stretchable-image-look').append('image').attr('class', 'center-image').attr('preserveAspectRatio', 'none');
|
|
5915
|
+
selection.filter('.stretchable-image-look').append('image').attr('class', 'right-image').attr('preserveAspectRatio', 'none');
|
|
5916
|
+
selection.filter('.stretchable-image-look').append('image').attr('class', 'bottom-left-image').attr('preserveAspectRatio', 'none');
|
|
5917
|
+
selection.filter('.stretchable-image-look').append('image').attr('class', 'bottom-image').attr('preserveAspectRatio', 'none');
|
|
5918
|
+
selection.filter('.stretchable-image-look').append('image').attr('class', 'bottom-right-image').attr('preserveAspectRatio', 'none');
|
|
5919
|
+
};
|
|
5920
|
+
const updateLook = selection => {
|
|
5921
|
+
selection.filter('.shaped-look').select('path').attr('d', d => generalClosedPath(d.look.shape, 0, 0, d.width, d.height)).attr('fill', d => d.look.fillColor).attr('stroke', d => d.look.borderColor).attr('stroke-width', d => `${d.look.borderThickness}px`);
|
|
5922
|
+
selection.filter('.image-look').select('image').attr('x', 0).attr('y', 0).attr('width', d => d.width).attr('height', d => d.height).attr('href', d => d.look.backgroundImage);
|
|
5923
|
+
selection.filter('.stretchable-image-look').select('image.top-left-image').attr('x', 0).attr('y', 0).attr('width', d => d.look.leftMargin).attr('height', d => d.look.topMargin).attr('href', d => d.look.backgroundImageTopLeft);
|
|
5924
|
+
selection.filter('.stretchable-image-look').select('image.top-image').attr('x', d => d.look.leftMargin).attr('y', 0).attr('width', d => d.width - d.look.rightMargin - d.look.leftMargin).attr('height', d => d.look.topMargin).attr('href', d => d.look.backgroundImageTop);
|
|
5925
|
+
selection.filter('.stretchable-image-look').select('image.top-right-image').attr('x', d => d.width - d.look.rightMargin).attr('y', 0).attr('width', d => d.look.rightMargin).attr('height', d => d.look.topMargin).attr('href', d => d.look.backgroundImageTopRight);
|
|
5926
|
+
selection.filter('.stretchable-image-look').select('image.left-image').attr('x', 0).attr('y', d => d.look.topMargin).attr('width', d => d.look.leftMargin).attr('height', d => d.height - d.look.bottomMargin - d.look.topMargin).attr('href', d => d.look.backgroundImageLeft);
|
|
5927
|
+
selection.filter('.stretchable-image-look').select('image.center-image').attr('x', d => d.look.leftMargin).attr('y', d => d.look.topMargin).attr('width', d => d.width - d.look.rightMargin - d.look.leftMargin).attr('height', d => d.height - d.look.bottomMargin - d.look.topMargin).attr('href', d => d.look.backgroundImageCenter);
|
|
5928
|
+
selection.filter('.stretchable-image-look').select('image.right-image').attr('x', d => d.width - d.look.rightMargin).attr('y', d => d.look.topMargin).attr('width', d => d.look.rightMargin).attr('height', d => d.height - d.look.bottomMargin - d.look.topMargin).attr('href', d => d.look.backgroundImageRight);
|
|
5929
|
+
selection.filter('.stretchable-image-look').select('image.bottom-left-image').attr('x', 0).attr('y', d => d.height - d.look.bottomMargin).attr('width', d => d.look.leftMargin).attr('height', d => d.look.bottomMargin).attr('href', d => d.look.backgroundImageBottomLeft);
|
|
5930
|
+
selection.filter('.stretchable-image-look').select('image.bottom-image').attr('x', d => d.look.leftMargin).attr('y', d => d.height - d.look.bottomMargin).attr('width', d => d.width - d.look.rightMargin - d.look.leftMargin).attr('height', d => d.look.bottomMargin).attr('href', d => d.look.backgroundImageBottom);
|
|
5931
|
+
selection.filter('.stretchable-image-look').select('image.bottom-right-image').attr('x', d => d.width - d.look.rightMargin).attr('y', d => d.height - d.look.bottomMargin).attr('width', d => d.look.rightMargin).attr('height', d => d.look.bottomMargin).attr('href', d => d.look.backgroundImageBottomRight);
|
|
5932
|
+
};
|
|
5933
|
+
|
|
5386
5934
|
const CONTEXT_MENU_MENU_RADIUS = 96;
|
|
5387
5935
|
const CONTEXT_MENU_BUTTON_RADIUS = 32;
|
|
5388
5936
|
const CONTEXT_MENU_TOTAL_RADIUS = CONTEXT_MENU_MENU_RADIUS + CONTEXT_MENU_BUTTON_RADIUS;
|
|
5389
5937
|
const CONTEXT_MENU_BUTTON_PADDING_RADIANS = Math.PI / 4;
|
|
5390
5938
|
const CONTEXT_MENU_ANIMATION_DURATION_MS = 100;
|
|
5939
|
+
const CONTEXT_MENU_DEFAULTS = {
|
|
5940
|
+
customButtons: []
|
|
5941
|
+
};
|
|
5391
5942
|
/**
|
|
5392
5943
|
* Stores the functionality regarding the context menu of a diagram canvas.
|
|
5393
5944
|
* @public
|
|
@@ -5399,8 +5950,9 @@ class DiagramContextMenu {
|
|
|
5399
5950
|
* @public
|
|
5400
5951
|
* @param canvas A canvas.
|
|
5401
5952
|
*/
|
|
5402
|
-
constructor(canvas) {
|
|
5953
|
+
constructor(canvas, config) {
|
|
5403
5954
|
this.canvas = canvas;
|
|
5955
|
+
this.config = config || CONTEXT_MENU_DEFAULTS;
|
|
5404
5956
|
}
|
|
5405
5957
|
/**
|
|
5406
5958
|
* Opens the context menu at the location determined by the given mouse event.
|
|
@@ -5427,10 +5979,9 @@ class DiagramContextMenu {
|
|
|
5427
5979
|
buttons.push({
|
|
5428
5980
|
name: 'CUT',
|
|
5429
5981
|
imageClass: 'daga-cut',
|
|
5430
|
-
onPress:
|
|
5431
|
-
|
|
5432
|
-
|
|
5433
|
-
this.canvas.cancelAllUserActions();
|
|
5982
|
+
onPress: canvas => {
|
|
5983
|
+
canvas.userSelection.cutToClipboard();
|
|
5984
|
+
canvas.cancelAllUserActions();
|
|
5434
5985
|
}
|
|
5435
5986
|
});
|
|
5436
5987
|
}
|
|
@@ -5438,10 +5989,9 @@ class DiagramContextMenu {
|
|
|
5438
5989
|
buttons.push({
|
|
5439
5990
|
name: 'COPY',
|
|
5440
5991
|
imageClass: 'daga-copy',
|
|
5441
|
-
onPress:
|
|
5442
|
-
|
|
5443
|
-
|
|
5444
|
-
this.canvas.cancelAllUserActions();
|
|
5992
|
+
onPress: canvas => {
|
|
5993
|
+
canvas.userSelection.copyToClipboard();
|
|
5994
|
+
canvas.cancelAllUserActions();
|
|
5445
5995
|
}
|
|
5446
5996
|
});
|
|
5447
5997
|
}
|
|
@@ -5449,10 +5999,9 @@ class DiagramContextMenu {
|
|
|
5449
5999
|
buttons.push({
|
|
5450
6000
|
name: 'PASTE',
|
|
5451
6001
|
imageClass: 'daga-paste',
|
|
5452
|
-
onPress:
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
this.canvas.cancelAllUserActions();
|
|
6002
|
+
onPress: canvas => {
|
|
6003
|
+
canvas.userSelection.pasteFromClipboard(canvas.getClosestGridPoint(coordsRelativeToCanvas));
|
|
6004
|
+
canvas.cancelAllUserActions();
|
|
5456
6005
|
}
|
|
5457
6006
|
});
|
|
5458
6007
|
}
|
|
@@ -5460,13 +6009,17 @@ class DiagramContextMenu {
|
|
|
5460
6009
|
buttons.push({
|
|
5461
6010
|
name: 'DELETE',
|
|
5462
6011
|
imageClass: 'daga-delete',
|
|
5463
|
-
onPress:
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
this.canvas.cancelAllUserActions();
|
|
6012
|
+
onPress: canvas => {
|
|
6013
|
+
canvas.userSelection.removeFromModel();
|
|
6014
|
+
canvas.cancelAllUserActions();
|
|
5467
6015
|
}
|
|
5468
6016
|
});
|
|
5469
6017
|
}
|
|
6018
|
+
for (const customButton of this.config.customButtons || CONTEXT_MENU_DEFAULTS.customButtons) {
|
|
6019
|
+
if (customButton.condition !== undefined ? customButton.condition(this.canvas) : true) {
|
|
6020
|
+
buttons.push(customButton);
|
|
6021
|
+
}
|
|
6022
|
+
}
|
|
5470
6023
|
// show something if there are no options available
|
|
5471
6024
|
if (buttons.length === 0) {
|
|
5472
6025
|
buttons.push({
|
|
@@ -5479,20 +6032,22 @@ class DiagramContextMenu {
|
|
|
5479
6032
|
const button = buttons[i];
|
|
5480
6033
|
const buttonOnPress = button.onPress;
|
|
5481
6034
|
const angle = (i + 0.5 - buttons.length / 2) * CONTEXT_MENU_BUTTON_PADDING_RADIANS;
|
|
5482
|
-
const buttonContainer = contextMenuContainer.append('xhtml:div').attr('class', `daga-context-menu-button ${button.
|
|
5483
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
5484
|
-
.on(exports.Events.Click, event => {
|
|
6035
|
+
const buttonContainer = contextMenuContainer.append('xhtml:div').attr('class', `daga-context-menu-button ${button.onPress !== undefined ? ' daga-clickable' : ''}`).attr('tabindex', 0).style('position', 'absolute').style('box-sizing', 'border-box').style('width', `${2 * CONTEXT_MENU_BUTTON_RADIUS}px`).style('height', `${2 * CONTEXT_MENU_BUTTON_RADIUS}px`).style('border-radius', `${CONTEXT_MENU_BUTTON_RADIUS}px`).style('pointer-events', 'auto').on(exports.Events.Click, event => {
|
|
5485
6036
|
if (buttonOnPress) {
|
|
5486
|
-
|
|
6037
|
+
event.preventDefault();
|
|
6038
|
+
buttonOnPress(this.canvas);
|
|
5487
6039
|
}
|
|
5488
|
-
})
|
|
5489
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
5490
|
-
.on(exports.Events.KeyDown, event => {
|
|
6040
|
+
}).on(exports.Events.KeyDown, event => {
|
|
5491
6041
|
if (buttonOnPress && event.key === exports.Keys.Enter) {
|
|
5492
|
-
|
|
6042
|
+
event.preventDefault();
|
|
6043
|
+
buttonOnPress(this.canvas);
|
|
5493
6044
|
}
|
|
5494
6045
|
});
|
|
5495
|
-
|
|
6046
|
+
if (button.imageClass !== undefined) {
|
|
6047
|
+
buttonContainer.append('xhtml:div').style('position', 'absolute').style('left', `${0.75 * CONTEXT_MENU_BUTTON_RADIUS}px`).style('top', `${0.5 * CONTEXT_MENU_BUTTON_RADIUS}px`).style('width', `${0.5 * CONTEXT_MENU_BUTTON_RADIUS}px`).style('height', `${0.5 * CONTEXT_MENU_BUTTON_RADIUS}px`).style('background-size', 'contain').style('background-repeat', 'no-repeat').attr('class', button.imageClass);
|
|
6048
|
+
} else if (button.image !== undefined) {
|
|
6049
|
+
buttonContainer.append('xhtml:img').style('position', 'absolute').style('left', `${0.75 * CONTEXT_MENU_BUTTON_RADIUS}px`).style('top', `${0.5 * CONTEXT_MENU_BUTTON_RADIUS}px`).style('width', `${0.5 * CONTEXT_MENU_BUTTON_RADIUS}px`).style('height', `${0.5 * CONTEXT_MENU_BUTTON_RADIUS}px`).attr('src', button.image);
|
|
6050
|
+
}
|
|
5496
6051
|
buttonContainer.append('xhtml:span').style('position', 'absolute').style('left', `${0.2 * CONTEXT_MENU_BUTTON_RADIUS}px`).style('top', `${1.1 * CONTEXT_MENU_BUTTON_RADIUS}px`).style('text-align', 'center').style('width', `${1.6 * CONTEXT_MENU_BUTTON_RADIUS}px`).style('height', `${0.35 * CONTEXT_MENU_BUTTON_RADIUS}px`).style('margin', '0').style('font-size', `${0.35 * CONTEXT_MENU_BUTTON_RADIUS}px`).style('font-weight', '700').style('user-select', 'none').text(button.name);
|
|
5497
6052
|
buttonContainer.transition().ease(d3__namespace.easeLinear).duration(CONTEXT_MENU_ANIMATION_DURATION_MS).tween('progress', () => {
|
|
5498
6053
|
return value => {
|
|
@@ -5977,7 +6532,7 @@ class DiagramUserSelection extends DiagramElementSet {
|
|
|
5977
6532
|
}
|
|
5978
6533
|
}
|
|
5979
6534
|
makeUpdateValuesAction() {
|
|
5980
|
-
var _a, _b;
|
|
6535
|
+
var _a, _b, _c;
|
|
5981
6536
|
if (this.propertyEditorSelection === undefined || this.propertyEditorValues === undefined) {
|
|
5982
6537
|
return;
|
|
5983
6538
|
}
|
|
@@ -5989,7 +6544,7 @@ class DiagramUserSelection extends DiagramElementSet {
|
|
|
5989
6544
|
}
|
|
5990
6545
|
const from = this.propertyEditorValues;
|
|
5991
6546
|
const to = structuredClone((_b = this.propertyEditorSelection) === null || _b === undefined ? undefined : _b.valueSet.getValues());
|
|
5992
|
-
const [fromDiff, toDiff] =
|
|
6547
|
+
const [fromDiff, toDiff] = diffProperties(from, to, (_c = this.propertyEditorSelection) === null || _c === undefined ? undefined : _c.valueSet);
|
|
5993
6548
|
const currentAction = new UpdateValuesAction(this.canvas, previousSelectionId, fromDiff, toDiff);
|
|
5994
6549
|
currentAction.do();
|
|
5995
6550
|
this.canvas.actionStack.add(currentAction);
|
|
@@ -6032,7 +6587,7 @@ class DiagramCanvas {
|
|
|
6032
6587
|
* @param config The configuration object used to set the parameters of this canvas.
|
|
6033
6588
|
*/
|
|
6034
6589
|
constructor(parentComponent, config) {
|
|
6035
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
6590
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
6036
6591
|
this.backgroundPatternId = `daga-background-pattern-id-${DiagramCanvas.canvasCount++}`;
|
|
6037
6592
|
this.zoomTransform = d3__namespace.zoomIdentity;
|
|
6038
6593
|
// used to distinguish drags from clicks when dragging elements and during multiple selection
|
|
@@ -6049,17 +6604,17 @@ class DiagramCanvas {
|
|
|
6049
6604
|
this.model = new DiagramModel(this, undefined, config.name || 'unnamed', '', config.type || '', config.properties || []);
|
|
6050
6605
|
this.userSelection = new DiagramUserSelection(this);
|
|
6051
6606
|
this.userHighlight = new DiagramUserHighlight(this);
|
|
6052
|
-
this.contextMenu = new DiagramContextMenu(this);
|
|
6053
|
-
this.backgroundColor = ((
|
|
6054
|
-
this.gridSize = ((
|
|
6055
|
-
this.gridThickness = Math.abs(((
|
|
6056
|
-
this.gridColor = ((
|
|
6057
|
-
this.snapToGrid = ((
|
|
6058
|
-
this.zoomFactor = ((
|
|
6059
|
-
this.panRate = ((
|
|
6607
|
+
this.contextMenu = new DiagramContextMenu(this, (_a = config.canvas) === null || _a === undefined ? undefined : _a.contextMenu);
|
|
6608
|
+
this.backgroundColor = ((_b = config.canvas) === null || _b === undefined ? undefined : _b.backgroundColor) || '#FFFFFF';
|
|
6609
|
+
this.gridSize = ((_d = (_c = config.canvas) === null || _c === undefined ? undefined : _c.grid) === null || _d === undefined ? undefined : _d.enabled) === false || ((_e = config.canvas) === null || _e === undefined ? undefined : _e.grid) === undefined ? 0 : Math.abs(((_g = (_f = config.canvas) === null || _f === undefined ? undefined : _f.grid) === null || _g === undefined ? undefined : _g.spacing) || 10);
|
|
6610
|
+
this.gridThickness = Math.abs(((_j = (_h = config.canvas) === null || _h === undefined ? undefined : _h.grid) === null || _j === undefined ? undefined : _j.thickness) || 0.05);
|
|
6611
|
+
this.gridColor = ((_l = (_k = config.canvas) === null || _k === undefined ? undefined : _k.grid) === null || _l === undefined ? undefined : _l.color) || 'rgba(0, 0, 0, 0.1)';
|
|
6612
|
+
this.snapToGrid = ((_o = (_m = config.canvas) === null || _m === undefined ? undefined : _m.grid) === null || _o === undefined ? undefined : _o.enabled) === false || ((_p = config.canvas) === null || _p === undefined ? undefined : _p.grid) === undefined ? false : ((_r = (_q = config.canvas) === null || _q === undefined ? undefined : _q.grid) === null || _r === undefined ? undefined : _r.snap) || false;
|
|
6613
|
+
this.zoomFactor = ((_s = config.canvas) === null || _s === undefined ? undefined : _s.zoomFactor) || 2;
|
|
6614
|
+
this.panRate = ((_t = config.canvas) === null || _t === undefined ? undefined : _t.panRate) || 100;
|
|
6060
6615
|
this.inferConnectionType = config.inferConnectionType || false;
|
|
6061
6616
|
this.multipleSelectionOn = false;
|
|
6062
|
-
this.priorityThresholds = ((
|
|
6617
|
+
this.priorityThresholds = ((_u = config.canvas) === null || _u === undefined ? undefined : _u.priorityThresholds) || [];
|
|
6063
6618
|
this.priorityThreshold = this.priorityThresholds ? this.priorityThresholds[0] : undefined;
|
|
6064
6619
|
this.layoutFormat = config.layoutFormat;
|
|
6065
6620
|
this.userActions = config.userActions || {};
|
|
@@ -6412,7 +6967,7 @@ class DiagramCanvas {
|
|
|
6412
6967
|
updateNodesInView(...ids) {
|
|
6413
6968
|
let updateSelection = this.selectCanvasElements().selectAll('g.diagram-node').data(this.model.nodes.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
|
|
6414
6969
|
const exitSelection = updateSelection.exit();
|
|
6415
|
-
const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', d => `diagram-node${d.type.resizableX ? ' resizable-x' : ''}${d.type.resizableY ? ' resizable-y' : ''} ${d.type.
|
|
6970
|
+
const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', d => `diagram-node${d.type.resizableX ? ' resizable-x' : ''}${d.type.resizableY ? ' resizable-y' : ''} ${d.type.defaultLook.lookType}`);
|
|
6416
6971
|
if (ids && ids.length > 0) {
|
|
6417
6972
|
updateSelection = updateSelection.filter(d => ids.includes(d.id));
|
|
6418
6973
|
}
|
|
@@ -6474,17 +7029,7 @@ class DiagramCanvas {
|
|
|
6474
7029
|
}
|
|
6475
7030
|
this.secondaryButton = false;
|
|
6476
7031
|
}));
|
|
6477
|
-
enterSelection
|
|
6478
|
-
enterSelection.filter('.image-look').append('image').attr('preserveAspectRatio', 'none');
|
|
6479
|
-
enterSelection.filter('.stretchable-image-look').append('image').attr('class', 'top-left-image').attr('preserveAspectRatio', 'none');
|
|
6480
|
-
enterSelection.filter('.stretchable-image-look').append('image').attr('class', 'top-image').attr('preserveAspectRatio', 'none');
|
|
6481
|
-
enterSelection.filter('.stretchable-image-look').append('image').attr('class', 'top-right-image').attr('preserveAspectRatio', 'none');
|
|
6482
|
-
enterSelection.filter('.stretchable-image-look').append('image').attr('class', 'left-image').attr('preserveAspectRatio', 'none');
|
|
6483
|
-
enterSelection.filter('.stretchable-image-look').append('image').attr('class', 'center-image').attr('preserveAspectRatio', 'none');
|
|
6484
|
-
enterSelection.filter('.stretchable-image-look').append('image').attr('class', 'right-image').attr('preserveAspectRatio', 'none');
|
|
6485
|
-
enterSelection.filter('.stretchable-image-look').append('image').attr('class', 'bottom-left-image').attr('preserveAspectRatio', 'none');
|
|
6486
|
-
enterSelection.filter('.stretchable-image-look').append('image').attr('class', 'bottom-image').attr('preserveAspectRatio', 'none');
|
|
6487
|
-
enterSelection.filter('.stretchable-image-look').append('image').attr('class', 'bottom-right-image').attr('preserveAspectRatio', 'none');
|
|
7032
|
+
initializeLook(enterSelection);
|
|
6488
7033
|
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) => {
|
|
6489
7034
|
if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.type.resizableX && !d.removed) {
|
|
6490
7035
|
setCursorStyle(exports.CursorStyle.EWResize);
|
|
@@ -6622,17 +7167,7 @@ class DiagramCanvas {
|
|
|
6622
7167
|
setCursorStyle();
|
|
6623
7168
|
}));
|
|
6624
7169
|
mergeSelection.attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).attr('opacity', d => d.removed ? 0.5 : 1);
|
|
6625
|
-
mergeSelection
|
|
6626
|
-
mergeSelection.filter('.image-look').select('image').attr('x', 0).attr('y', 0).attr('width', d => d.width).attr('height', d => d.height).attr('href', d => d.selected ? d.type.look.selectedBackgroundImage : d.type.look.backgroundImage);
|
|
6627
|
-
mergeSelection.filter('.stretchable-image-look').select('image.top-left-image').attr('x', 0).attr('y', 0).attr('width', d => d.type.look.leftMargin).attr('height', d => d.type.look.topMargin).attr('href', d => d.selected ? d.type.look.selectedBackgroundImageTopLeft : d.type.look.backgroundImageTopLeft);
|
|
6628
|
-
mergeSelection.filter('.stretchable-image-look').select('image.top-image').attr('x', d => d.type.look.leftMargin).attr('y', 0).attr('width', d => d.width - d.type.look.rightMargin - d.type.look.leftMargin).attr('height', d => d.type.look.topMargin).attr('href', d => d.selected ? d.type.look.selectedBackgroundImageTop : d.type.look.backgroundImageTop);
|
|
6629
|
-
mergeSelection.filter('.stretchable-image-look').select('image.top-right-image').attr('x', d => d.width - d.type.look.rightMargin).attr('y', 0).attr('width', d => d.type.look.rightMargin).attr('height', d => d.type.look.topMargin).attr('href', d => d.selected ? d.type.look.selectedBackgroundImageTopRight : d.type.look.backgroundImageTopRight);
|
|
6630
|
-
mergeSelection.filter('.stretchable-image-look').select('image.left-image').attr('x', 0).attr('y', d => d.type.look.topMargin).attr('width', d => d.type.look.leftMargin).attr('height', d => d.height - d.type.look.bottomMargin - d.type.look.topMargin).attr('href', d => d.selected ? d.type.look.selectedBackgroundImageLeft : d.type.look.backgroundImageLeft);
|
|
6631
|
-
mergeSelection.filter('.stretchable-image-look').select('image.center-image').attr('x', d => d.type.look.leftMargin).attr('y', d => d.type.look.topMargin).attr('width', d => d.width - d.type.look.rightMargin - d.type.look.leftMargin).attr('height', d => d.height - d.type.look.bottomMargin - d.type.look.topMargin).attr('href', d => d.selected ? d.type.look.selectedBackgroundImageCenter : d.type.look.backgroundImageCenter);
|
|
6632
|
-
mergeSelection.filter('.stretchable-image-look').select('image.right-image').attr('x', d => d.width - d.type.look.rightMargin).attr('y', d => d.type.look.topMargin).attr('width', d => d.type.look.rightMargin).attr('height', d => d.height - d.type.look.bottomMargin - d.type.look.topMargin).attr('href', d => d.selected ? d.type.look.selectedBackgroundImageRight : d.type.look.backgroundImageRight);
|
|
6633
|
-
mergeSelection.filter('.stretchable-image-look').select('image.bottom-left-image').attr('x', 0).attr('y', d => d.height - d.type.look.bottomMargin).attr('width', d => d.type.look.leftMargin).attr('height', d => d.type.look.bottomMargin).attr('href', d => d.selected ? d.type.look.selectedBackgroundImageBottomLeft : d.type.look.backgroundImageBottomLeft);
|
|
6634
|
-
mergeSelection.filter('.stretchable-image-look').select('image.bottom-image').attr('x', d => d.type.look.leftMargin).attr('y', d => d.height - d.type.look.bottomMargin).attr('width', d => d.width - d.type.look.rightMargin - d.type.look.leftMargin).attr('height', d => d.type.look.bottomMargin).attr('href', d => d.selected ? d.type.look.selectedBackgroundImageBottom : d.type.look.backgroundImageBottom);
|
|
6635
|
-
mergeSelection.filter('.stretchable-image-look').select('image.bottom-right-image').attr('x', d => d.width - d.type.look.rightMargin).attr('y', d => d.height - d.type.look.bottomMargin).attr('width', d => d.type.look.rightMargin).attr('height', d => d.type.look.bottomMargin).attr('href', d => d.selected ? d.type.look.selectedBackgroundImageBottomRight : d.type.look.backgroundImageBottomRight);
|
|
7170
|
+
updateLook(mergeSelection);
|
|
6636
7171
|
mergeSelection.filter('.resizable-x').select('line.left-resizer').attr('x1', RESIZER_THICKNESS / 2).attr('x2', RESIZER_THICKNESS / 2).attr('y1', 0).attr('y2', d => d.height);
|
|
6637
7172
|
mergeSelection.filter('.resizable-y').select('line.top-resizer').attr('x1', 0).attr('x2', d => d.width).attr('y1', RESIZER_THICKNESS / 2).attr('y2', RESIZER_THICKNESS / 2);
|
|
6638
7173
|
mergeSelection.filter('.resizable-x').select('line.right-resizer').attr('x1', d => d.width - RESIZER_THICKNESS / 2).attr('x2', d => d.width - RESIZER_THICKNESS / 2).attr('y1', 0).attr('y2', d => d.height);
|
|
@@ -6642,8 +7177,8 @@ class DiagramCanvas {
|
|
|
6642
7177
|
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);
|
|
6643
7178
|
const exitSelection = updateSelection.exit();
|
|
6644
7179
|
const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', d => {
|
|
6645
|
-
var _a, _b, _c, _d, _e
|
|
6646
|
-
return `diagram-section${((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) ? ' resizable-x' : ''}${((_d = (_c = d.node) === null || _c === undefined ? undefined : _c.type) === null || _d === undefined ? undefined : _d.resizableY) ? ' resizable-y' : ''} ${(
|
|
7180
|
+
var _a, _b, _c, _d, _e;
|
|
7181
|
+
return `diagram-section${((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) ? ' resizable-x' : ''}${((_d = (_c = d.node) === null || _c === undefined ? undefined : _c.type) === null || _d === undefined ? undefined : _d.resizableY) ? ' resizable-y' : ''} ${(_e = d.look) === null || _e === undefined ? undefined : _e.lookType}`;
|
|
6647
7182
|
});
|
|
6648
7183
|
if (ids && ids.length > 0) {
|
|
6649
7184
|
updateSelection = updateSelection.filter(d => ids.includes(d.id));
|
|
@@ -6723,17 +7258,7 @@ class DiagramCanvas {
|
|
|
6723
7258
|
}
|
|
6724
7259
|
this.secondaryButton = false;
|
|
6725
7260
|
}));
|
|
6726
|
-
enterSelection
|
|
6727
|
-
enterSelection.filter('.image-look').append('image').attr('preserveAspectRatio', 'none');
|
|
6728
|
-
enterSelection.filter('.stretchable-image-look').append('image').attr('class', 'top-left-image').attr('preserveAspectRatio', 'none');
|
|
6729
|
-
enterSelection.filter('.stretchable-image-look').append('image').attr('class', 'top-image').attr('preserveAspectRatio', 'none');
|
|
6730
|
-
enterSelection.filter('.stretchable-image-look').append('image').attr('class', 'top-right-image').attr('preserveAspectRatio', 'none');
|
|
6731
|
-
enterSelection.filter('.stretchable-image-look').append('image').attr('class', 'left-image').attr('preserveAspectRatio', 'none');
|
|
6732
|
-
enterSelection.filter('.stretchable-image-look').append('image').attr('class', 'center-image').attr('preserveAspectRatio', 'none');
|
|
6733
|
-
enterSelection.filter('.stretchable-image-look').append('image').attr('class', 'right-image').attr('preserveAspectRatio', 'none');
|
|
6734
|
-
enterSelection.filter('.stretchable-image-look').append('image').attr('class', 'bottom-left-image').attr('preserveAspectRatio', 'none');
|
|
6735
|
-
enterSelection.filter('.stretchable-image-look').append('image').attr('class', 'bottom-image').attr('preserveAspectRatio', 'none');
|
|
6736
|
-
enterSelection.filter('.stretchable-image-look').append('image').attr('class', 'bottom-right-image').attr('preserveAspectRatio', 'none');
|
|
7261
|
+
initializeLook(enterSelection);
|
|
6737
7262
|
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) => {
|
|
6738
7263
|
var _a, _b;
|
|
6739
7264
|
if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
|
|
@@ -6891,146 +7416,7 @@ class DiagramCanvas {
|
|
|
6891
7416
|
setCursorStyle();
|
|
6892
7417
|
}));
|
|
6893
7418
|
mergeSelection.attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).attr('opacity', d => d.removed ? 0.5 : 1);
|
|
6894
|
-
mergeSelection
|
|
6895
|
-
var _a;
|
|
6896
|
-
return generalClosedPath(((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).shape, 0, 0, d.width, d.height);
|
|
6897
|
-
}).attr('fill', d => {
|
|
6898
|
-
var _a, _b;
|
|
6899
|
-
return d.selected ? ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).selectedFillColor : ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).fillColor;
|
|
6900
|
-
}).attr('stroke', d => {
|
|
6901
|
-
var _a, _b;
|
|
6902
|
-
return d.selected ? ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).selectedBorderColor : ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).borderColor;
|
|
6903
|
-
}).attr('stroke-width', d => `${d.highlighted ? 3 : 1}px`);
|
|
6904
|
-
mergeSelection.filter('.image-look').select('image').attr('x', 0).attr('y', 0).attr('width', d => d.width).attr('height', d => d.height).attr('href', d => {
|
|
6905
|
-
var _a, _b;
|
|
6906
|
-
return d.selected ? ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).selectedBackgroundImage : ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).backgroundImage;
|
|
6907
|
-
});
|
|
6908
|
-
mergeSelection.filter('.stretchable-image-look').select('image.top-left-image').attr('x', 0).attr('y', 0).attr('width', d => {
|
|
6909
|
-
var _a;
|
|
6910
|
-
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).leftMargin;
|
|
6911
|
-
}).attr('height', d => {
|
|
6912
|
-
var _a;
|
|
6913
|
-
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).topMargin;
|
|
6914
|
-
}).attr('href', d => {
|
|
6915
|
-
var _a, _b;
|
|
6916
|
-
return d.selected ? ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).selectedBackgroundImageTopLeft : ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).backgroundImageTopLeft;
|
|
6917
|
-
});
|
|
6918
|
-
mergeSelection.filter('.stretchable-image-look').select('image.top-image').attr('x', d => {
|
|
6919
|
-
var _a;
|
|
6920
|
-
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).leftMargin;
|
|
6921
|
-
}).attr('y', 0).attr('width', d => {
|
|
6922
|
-
var _a, _b;
|
|
6923
|
-
return d.width - ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).rightMargin - ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).leftMargin;
|
|
6924
|
-
}).attr('height', d => {
|
|
6925
|
-
var _a;
|
|
6926
|
-
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).topMargin;
|
|
6927
|
-
}).attr('href', d => {
|
|
6928
|
-
var _a, _b;
|
|
6929
|
-
return d.selected ? ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).selectedBackgroundImageTop : ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).backgroundImageTop;
|
|
6930
|
-
});
|
|
6931
|
-
mergeSelection.filter('.stretchable-image-look').select('image.top-right-image').attr('x', d => {
|
|
6932
|
-
var _a;
|
|
6933
|
-
return d.width - ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).rightMargin;
|
|
6934
|
-
}).attr('y', 0).attr('width', d => {
|
|
6935
|
-
var _a;
|
|
6936
|
-
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).rightMargin;
|
|
6937
|
-
}).attr('height', d => {
|
|
6938
|
-
var _a;
|
|
6939
|
-
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).topMargin;
|
|
6940
|
-
}).attr('href', d => {
|
|
6941
|
-
var _a, _b;
|
|
6942
|
-
return d.selected ? ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).selectedBackgroundImageTopRight : ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).backgroundImageTopRight;
|
|
6943
|
-
});
|
|
6944
|
-
mergeSelection.filter('.stretchable-image-look').select('image.left-image').attr('x', 0).attr('y', d => {
|
|
6945
|
-
var _a;
|
|
6946
|
-
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).topMargin;
|
|
6947
|
-
}).attr('width', d => {
|
|
6948
|
-
var _a;
|
|
6949
|
-
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).leftMargin;
|
|
6950
|
-
}).attr('height', d => {
|
|
6951
|
-
var _a, _b;
|
|
6952
|
-
return d.height - ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).bottomMargin - ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).topMargin;
|
|
6953
|
-
}).attr('href', d => {
|
|
6954
|
-
var _a, _b;
|
|
6955
|
-
return d.selected ? ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).selectedBackgroundImageLeft : ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).backgroundImageLeft;
|
|
6956
|
-
});
|
|
6957
|
-
mergeSelection.filter('.stretchable-image-look').select('image.center-image').attr('x', d => {
|
|
6958
|
-
var _a;
|
|
6959
|
-
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).leftMargin;
|
|
6960
|
-
}).attr('y', d => {
|
|
6961
|
-
var _a;
|
|
6962
|
-
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).topMargin;
|
|
6963
|
-
}).attr('width', d => {
|
|
6964
|
-
var _a, _b;
|
|
6965
|
-
return d.width - ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).rightMargin - ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).leftMargin;
|
|
6966
|
-
}).attr('height', d => {
|
|
6967
|
-
var _a, _b;
|
|
6968
|
-
return d.height - ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).bottomMargin - ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).topMargin;
|
|
6969
|
-
}).attr('href', d => {
|
|
6970
|
-
var _a, _b;
|
|
6971
|
-
return d.selected ? ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).selectedBackgroundImageCenter : ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).backgroundImageCenter;
|
|
6972
|
-
});
|
|
6973
|
-
mergeSelection.filter('.stretchable-image-look').select('image.right-image').attr('x', d => {
|
|
6974
|
-
var _a;
|
|
6975
|
-
return d.width - ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).rightMargin;
|
|
6976
|
-
}).attr('y', d => {
|
|
6977
|
-
var _a;
|
|
6978
|
-
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).topMargin;
|
|
6979
|
-
}).attr('width', d => {
|
|
6980
|
-
var _a;
|
|
6981
|
-
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).rightMargin;
|
|
6982
|
-
}).attr('height', d => {
|
|
6983
|
-
var _a, _b;
|
|
6984
|
-
return d.height - ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).bottomMargin - ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).topMargin;
|
|
6985
|
-
}).attr('href', d => {
|
|
6986
|
-
var _a, _b;
|
|
6987
|
-
return d.selected ? ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).selectedBackgroundImageRight : ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).backgroundImageRight;
|
|
6988
|
-
});
|
|
6989
|
-
mergeSelection.filter('.stretchable-image-look').select('image.bottom-left-image').attr('x', 0).attr('y', d => {
|
|
6990
|
-
var _a;
|
|
6991
|
-
return d.height - ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).bottomMargin;
|
|
6992
|
-
}).attr('width', d => {
|
|
6993
|
-
var _a;
|
|
6994
|
-
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).leftMargin;
|
|
6995
|
-
}).attr('height', d => {
|
|
6996
|
-
var _a;
|
|
6997
|
-
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).bottomMargin;
|
|
6998
|
-
}).attr('href', d => {
|
|
6999
|
-
var _a, _b;
|
|
7000
|
-
return d.selected ? ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).selectedBackgroundImageBottomLeft : ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).backgroundImageBottomLeft;
|
|
7001
|
-
});
|
|
7002
|
-
mergeSelection.filter('.stretchable-image-look').select('image.bottom-image').attr('x', d => {
|
|
7003
|
-
var _a;
|
|
7004
|
-
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).leftMargin;
|
|
7005
|
-
}).attr('y', d => {
|
|
7006
|
-
var _a;
|
|
7007
|
-
return d.height - ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).bottomMargin;
|
|
7008
|
-
}).attr('width', d => {
|
|
7009
|
-
var _a, _b;
|
|
7010
|
-
return d.width - ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).rightMargin - ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).leftMargin;
|
|
7011
|
-
}).attr('height', d => {
|
|
7012
|
-
var _a;
|
|
7013
|
-
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).bottomMargin;
|
|
7014
|
-
}).attr('href', d => {
|
|
7015
|
-
var _a, _b;
|
|
7016
|
-
return d.selected ? ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).selectedBackgroundImageBottom : ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).backgroundImageBottom;
|
|
7017
|
-
});
|
|
7018
|
-
mergeSelection.filter('.stretchable-image-look').select('image.bottom-right-image').attr('x', d => {
|
|
7019
|
-
var _a;
|
|
7020
|
-
return d.width - ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).rightMargin;
|
|
7021
|
-
}).attr('y', d => {
|
|
7022
|
-
var _a;
|
|
7023
|
-
return d.height - ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).bottomMargin;
|
|
7024
|
-
}).attr('width', d => {
|
|
7025
|
-
var _a;
|
|
7026
|
-
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).rightMargin;
|
|
7027
|
-
}).attr('height', d => {
|
|
7028
|
-
var _a;
|
|
7029
|
-
return ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).bottomMargin;
|
|
7030
|
-
}).attr('href', d => {
|
|
7031
|
-
var _a, _b;
|
|
7032
|
-
return d.selected ? ((_a = d.getConfig()) === null || _a === undefined ? undefined : _a.look).selectedBackgroundImageBottomRight : ((_b = d.getConfig()) === null || _b === undefined ? undefined : _b.look).backgroundImageBottomRight;
|
|
7033
|
-
});
|
|
7419
|
+
updateLook(mergeSelection);
|
|
7034
7420
|
mergeSelection.filter('.resizable-x').select('line.left-resizer').attr('x1', RESIZER_THICKNESS / 2).attr('x2', RESIZER_THICKNESS / 2).attr('y1', 0).attr('y2', d => d.height);
|
|
7035
7421
|
mergeSelection.filter('.resizable-y').select('line.top-resizer').attr('x1', 0).attr('x2', d => d.width).attr('y1', RESIZER_THICKNESS / 2).attr('y2', RESIZER_THICKNESS / 2);
|
|
7036
7422
|
mergeSelection.filter('.resizable-x').select('line.right-resizer').attr('x1', d => d.width - RESIZER_THICKNESS / 2).attr('x2', d => d.width - RESIZER_THICKNESS / 2).attr('y1', 0).attr('y2', d => d.height);
|
|
@@ -7039,10 +7425,7 @@ class DiagramCanvas {
|
|
|
7039
7425
|
updatePortsInView(...ids) {
|
|
7040
7426
|
let updateSelection = this.selectCanvasElements().selectAll('g.diagram-port').data(this.model.ports.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
|
|
7041
7427
|
const exitSelection = updateSelection.exit();
|
|
7042
|
-
const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', d => {
|
|
7043
|
-
var _a, _b;
|
|
7044
|
-
return `diagram-port ${((_b = (_a = d.type) === null || _a === undefined ? undefined : _a.look) === null || _b === undefined ? undefined : _b.lookType) || 'default'}`;
|
|
7045
|
-
});
|
|
7428
|
+
const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', d => `diagram-port ${d.look.lookType}`);
|
|
7046
7429
|
if (ids && ids.length > 0) {
|
|
7047
7430
|
updateSelection = updateSelection.filter(d => ids.includes(d.id));
|
|
7048
7431
|
}
|
|
@@ -7129,7 +7512,7 @@ class DiagramCanvas {
|
|
|
7129
7512
|
if (this.canUserPerformAction(exports.DiagramActions.AddConnection) && !d.removed) {
|
|
7130
7513
|
if (this.unfinishedConnection !== undefined) {
|
|
7131
7514
|
const endCoords = [event.x, event.y];
|
|
7132
|
-
(_a = this.unfinishedConnectionTracer) === null || _a === undefined ? undefined : _a.attr('d', getConnectionPath(this.unfinishedConnection.
|
|
7515
|
+
(_a = this.unfinishedConnectionTracer) === null || _a === undefined ? undefined : _a.attr('d', getConnectionPath(this.unfinishedConnection.look.shape, this.unfinishedConnection.startCoords, endCoords, this.unfinishedConnection.startDirection, this.unfinishedConnection.endDirection, this.unfinishedConnection.look.thickness, (_b = this.unfinishedConnection.startMarkerLook) === null || _b === undefined ? undefined : _b.width, (_c = this.unfinishedConnection.endMarkerLook) === null || _c === undefined ? undefined : _c.width));
|
|
7133
7516
|
const unfinishedConnectionGhostNode = (_d = this.unfinishedConnectionTracer) === null || _d === undefined ? undefined : _d.node();
|
|
7134
7517
|
if (unfinishedConnectionGhostNode) {
|
|
7135
7518
|
let margin = 2;
|
|
@@ -7201,14 +7584,10 @@ class DiagramCanvas {
|
|
|
7201
7584
|
}
|
|
7202
7585
|
this.secondaryButton = false;
|
|
7203
7586
|
}));
|
|
7204
|
-
enterSelection.filter('.default').append('circle');
|
|
7205
7587
|
enterSelection.filter('.image-look').append('image');
|
|
7206
|
-
|
|
7207
|
-
mergeSelection.
|
|
7208
|
-
mergeSelection
|
|
7209
|
-
var _a, _b;
|
|
7210
|
-
return d.selected ? ((_a = d.type) === null || _a === undefined ? undefined : _a.look).selectedBackgroundImage : ((_b = d.type) === null || _b === undefined ? undefined : _b.look).backgroundImage;
|
|
7211
|
-
});
|
|
7588
|
+
initializeLook(enterSelection);
|
|
7589
|
+
mergeSelection.attr('transform', d => `translate(${d.coords[0] - d.width / 2},${d.coords[1] - d.width / 2})`).attr('opacity', d => d.removed ? 0.5 : 1);
|
|
7590
|
+
updateLook(mergeSelection);
|
|
7212
7591
|
}
|
|
7213
7592
|
updateConnectionsInView(...ids) {
|
|
7214
7593
|
const connectionList = this.model.connections.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true);
|
|
@@ -7281,14 +7660,14 @@ class DiagramCanvas {
|
|
|
7281
7660
|
enterSelection.select('g.diagram-connection-end-label').append('text').style('user-select', 'none');
|
|
7282
7661
|
mergeSelection.attr('opacity', d => d.removed ? 0.5 : 1).select('path.diagram-connection-path').attr('d', d => {
|
|
7283
7662
|
var _a, _b;
|
|
7284
|
-
return getConnectionPath(d.
|
|
7285
|
-
}).attr('marker-start', d => `url(#${d.id}-start-marker)`).attr('marker-end', d => `url(#${d.id}-end-marker)`).attr('stroke', d => d.
|
|
7663
|
+
return getConnectionPath(d.look.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.look.thickness, (_a = d.startMarkerLook) === null || _a === undefined ? undefined : _a.width, (_b = d.endMarkerLook) === null || _b === undefined ? undefined : _b.width);
|
|
7664
|
+
}).attr('marker-start', d => `url(#${d.id}-start-marker)`).attr('marker-end', d => `url(#${d.id}-end-marker)`).attr('stroke', d => d.look.color).attr('stroke-width', d => `${d.look.thickness}px`).attr('stroke-dasharray', d => lineStyleDasharray(d.look.style, d.look.thickness)).attr('fill', 'none');
|
|
7286
7665
|
mergeSelection.select('path.diagram-connection-path-box').attr('d', d => {
|
|
7287
7666
|
var _a, _b;
|
|
7288
|
-
return getConnectionPath(d.
|
|
7667
|
+
return getConnectionPath(d.look.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.look.thickness, (_a = d.startMarkerLook) === null || _a === undefined ? undefined : _a.width, (_b = d.endMarkerLook) === null || _b === undefined ? undefined : _b.width);
|
|
7289
7668
|
}).attr('stroke', 'transparent')
|
|
7290
7669
|
// allow generating pointer events even when it is transparent
|
|
7291
|
-
.attr('pointer-events', 'stroke').attr('stroke-width', d => `${d.
|
|
7670
|
+
.attr('pointer-events', 'stroke').attr('stroke-width', d => `${d.look.thickness + CONNECTION_PATH_BOX_THICKNESS}px`).attr('stroke-dasharray', d => lineStyleDasharray(d.look.style, d.look.thickness)).attr('fill', 'none');
|
|
7292
7671
|
mergeSelection.data().forEach(connection => {
|
|
7293
7672
|
this.updateConnectionLabelsInView(connection);
|
|
7294
7673
|
this.updateConnectionMarkersInView(connection);
|
|
@@ -7437,11 +7816,17 @@ class DiagramCanvas {
|
|
|
7437
7816
|
this.secondaryButton = isSecondaryButton(event);
|
|
7438
7817
|
return true;
|
|
7439
7818
|
}).on(exports.DragEvents.Start, event => {
|
|
7440
|
-
this.
|
|
7819
|
+
if (this.multipleSelectionOn || this.secondaryButton) {
|
|
7820
|
+
this.startMultipleSelection(event);
|
|
7821
|
+
}
|
|
7441
7822
|
}).on(exports.DragEvents.Drag, event => {
|
|
7442
|
-
this.
|
|
7823
|
+
if (this.multipleSelectionOn || this.secondaryButton) {
|
|
7824
|
+
this.continueMultipleSelection(event);
|
|
7825
|
+
}
|
|
7443
7826
|
}).on(exports.DragEvents.End, event => {
|
|
7444
|
-
this.
|
|
7827
|
+
if (this.multipleSelectionOn || this.secondaryButton) {
|
|
7828
|
+
this.finishMultipleSelection(event);
|
|
7829
|
+
}
|
|
7445
7830
|
}));
|
|
7446
7831
|
}
|
|
7447
7832
|
updateDecoratorsInView(...ids) {
|
|
@@ -7473,12 +7858,55 @@ class DiagramCanvas {
|
|
|
7473
7858
|
}).call(d3__namespace.drag().filter(event => {
|
|
7474
7859
|
this.secondaryButton = isSecondaryButton(event);
|
|
7475
7860
|
return true;
|
|
7476
|
-
}).on(exports.DragEvents.Start, event => {
|
|
7477
|
-
this.
|
|
7478
|
-
|
|
7479
|
-
|
|
7480
|
-
|
|
7481
|
-
|
|
7861
|
+
}).on(exports.DragEvents.Start, (event, d) => {
|
|
7862
|
+
if (this.multipleSelectionOn || this.secondaryButton) {
|
|
7863
|
+
this.startMultipleSelection(event);
|
|
7864
|
+
} else {
|
|
7865
|
+
let node;
|
|
7866
|
+
if (d.rootElement instanceof DiagramNode) {
|
|
7867
|
+
node = d.rootElement;
|
|
7868
|
+
} else if (d.rootElement instanceof DiagramSection) {
|
|
7869
|
+
node = d.rootElement.node;
|
|
7870
|
+
}
|
|
7871
|
+
if (node) {
|
|
7872
|
+
this.startMovingNode(event, node);
|
|
7873
|
+
} else {
|
|
7874
|
+
setCursorStyle(exports.CursorStyle.NotAllowed);
|
|
7875
|
+
}
|
|
7876
|
+
}
|
|
7877
|
+
}).on(exports.DragEvents.Drag, (event, d) => {
|
|
7878
|
+
if (this.multipleSelectionOn || this.secondaryButton) {
|
|
7879
|
+
this.continueMultipleSelection(event);
|
|
7880
|
+
} else {
|
|
7881
|
+
let node;
|
|
7882
|
+
if (d.rootElement instanceof DiagramNode) {
|
|
7883
|
+
node = d.rootElement;
|
|
7884
|
+
} else if (d.rootElement instanceof DiagramSection) {
|
|
7885
|
+
node = d.rootElement.node;
|
|
7886
|
+
}
|
|
7887
|
+
if (node) {
|
|
7888
|
+
this.continueMovingNode(event, node);
|
|
7889
|
+
} else {
|
|
7890
|
+
setCursorStyle(exports.CursorStyle.NotAllowed);
|
|
7891
|
+
}
|
|
7892
|
+
}
|
|
7893
|
+
}).on(exports.DragEvents.End, (event, d) => {
|
|
7894
|
+
if (this.multipleSelectionOn || this.secondaryButton) {
|
|
7895
|
+
this.finishMultipleSelection(event);
|
|
7896
|
+
} else {
|
|
7897
|
+
let node;
|
|
7898
|
+
if (d.rootElement instanceof DiagramNode) {
|
|
7899
|
+
node = d.rootElement;
|
|
7900
|
+
} else if (d.rootElement instanceof DiagramSection) {
|
|
7901
|
+
node = d.rootElement.node;
|
|
7902
|
+
}
|
|
7903
|
+
if (node) {
|
|
7904
|
+
this.finishMovingNode(event, node);
|
|
7905
|
+
} else {
|
|
7906
|
+
setCursorStyle();
|
|
7907
|
+
}
|
|
7908
|
+
}
|
|
7909
|
+
this.secondaryButton = false;
|
|
7482
7910
|
}));
|
|
7483
7911
|
}
|
|
7484
7912
|
updateConnectionLabelsInView(connection) {
|
|
@@ -7497,7 +7925,7 @@ class DiagramCanvas {
|
|
|
7497
7925
|
const boundingWidth = !connection.startLabel ? 0 : startLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
|
|
7498
7926
|
const boundingHeight = !connection.startLabel ? 0 : startLabelBoundingRect.height / this.zoomTransform.k + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
|
|
7499
7927
|
const pathStartLabelPoint = pathNode.getPointAtLength(Math.max(getLeftMargin(labelConfiguration) + boundingWidth / 2, getRightMargin(labelConfiguration) + boundingWidth / 2, getTopMargin(labelConfiguration) + boundingHeight / 2, getBottomMargin(labelConfiguration) + boundingHeight / 2));
|
|
7500
|
-
connectionSelection.select('g.diagram-connection-start-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', connection.
|
|
7928
|
+
connectionSelection.select('g.diagram-connection-start-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', connection.look.color).attr('stroke', 'none');
|
|
7501
7929
|
connectionSelection.select('g.diagram-connection-start-label').attr('transform', `translate(${pathStartLabelPoint.x},${pathStartLabelPoint.y})`);
|
|
7502
7930
|
}
|
|
7503
7931
|
// bind middle labels
|
|
@@ -7508,7 +7936,7 @@ class DiagramCanvas {
|
|
|
7508
7936
|
const boundingWidth = !connection.middleLabel ? 0 : middleLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
|
|
7509
7937
|
const boundingHeight = !connection.middleLabel ? 0 : middleLabelBoundingRect.height / this.zoomTransform.k + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
|
|
7510
7938
|
const pathMiddleLabelPoint = pathNode.getPointAtLength(pathLength / 2);
|
|
7511
|
-
connectionSelection.select('g.diagram-connection-middle-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', connection.
|
|
7939
|
+
connectionSelection.select('g.diagram-connection-middle-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', connection.look.color).attr('stroke', 'none');
|
|
7512
7940
|
connectionSelection.select('g.diagram-connection-middle-label').attr('transform', `translate(${pathMiddleLabelPoint.x},${pathMiddleLabelPoint.y})`);
|
|
7513
7941
|
}
|
|
7514
7942
|
// bind end labels
|
|
@@ -7519,7 +7947,7 @@ class DiagramCanvas {
|
|
|
7519
7947
|
const boundingWidth = !connection.endLabel ? 0 : endLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
|
|
7520
7948
|
const boundingHeight = !connection.endLabel ? 0 : endLabelBoundingRect.height / this.zoomTransform.k + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
|
|
7521
7949
|
const pathEndLabelPoint = pathNode.getPointAtLength(pathLength - Math.max(getLeftMargin(labelConfiguration) + boundingWidth / 2, getRightMargin(labelConfiguration) + boundingWidth / 2, getTopMargin(labelConfiguration) + boundingHeight / 2, getBottomMargin(labelConfiguration) + boundingHeight / 2));
|
|
7522
|
-
connectionSelection.select('g.diagram-connection-end-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', connection.
|
|
7950
|
+
connectionSelection.select('g.diagram-connection-end-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', connection.look.color).attr('stroke', 'none');
|
|
7523
7951
|
connectionSelection.select('g.diagram-connection-end-label').attr('transform', `translate(${pathEndLabelPoint.x},${pathEndLabelPoint.y})`);
|
|
7524
7952
|
}
|
|
7525
7953
|
}
|
|
@@ -7529,18 +7957,18 @@ class DiagramCanvas {
|
|
|
7529
7957
|
const startMarkerSelection = connectionSelection.select('marker.diagram-connection-start-marker');
|
|
7530
7958
|
const endMarkerSelection = connectionSelection.select('marker.diagram-connection-end-marker');
|
|
7531
7959
|
if (connection.startMarkerLook !== null) {
|
|
7532
|
-
startMarkerSelection.attr('orient', 'auto-start-reverse').attr('markerWidth', connection.startMarkerLook.
|
|
7960
|
+
startMarkerSelection.attr('orient', 'auto-start-reverse').attr('markerWidth', connection.startMarkerLook.width).attr('markerHeight', connection.startMarkerLook.height).attr('refX', connection.startMarkerLook.refX).attr('refY', connection.startMarkerLook.refY).select('image').attr('href', connection.startMarkerLook.image).attr('width', connection.startMarkerLook.width).attr('height', connection.startMarkerLook.height);
|
|
7533
7961
|
} else {
|
|
7534
7962
|
startMarkerSelection.attr('orient', 'auto-start-reverse').attr('markerWidth', 0).attr('markerHeight', 0);
|
|
7535
7963
|
}
|
|
7536
7964
|
if (connection.endMarkerLook !== null) {
|
|
7537
|
-
endMarkerSelection.attr('orient', 'auto-start-reverse').attr('markerWidth', connection.endMarkerLook.
|
|
7965
|
+
endMarkerSelection.attr('orient', 'auto-start-reverse').attr('markerWidth', connection.endMarkerLook.width).attr('markerHeight', connection.endMarkerLook.height).attr('refX', connection.endMarkerLook.refX).attr('refY', connection.endMarkerLook.refY).select('image').attr('href', connection.endMarkerLook.image).attr('width', connection.endMarkerLook.width).attr('height', connection.endMarkerLook.height);
|
|
7538
7966
|
} else {
|
|
7539
7967
|
endMarkerSelection.attr('orient', 'auto-start-reverse').attr('markerWidth', 0).attr('markerHeight', 0);
|
|
7540
7968
|
}
|
|
7541
7969
|
}
|
|
7542
7970
|
fitFieldRootInView(id) {
|
|
7543
|
-
var _a, _b, _c
|
|
7971
|
+
var _a, _b, _c;
|
|
7544
7972
|
const field = this.model.fields.get(id);
|
|
7545
7973
|
if (!field) {
|
|
7546
7974
|
return;
|
|
@@ -7582,8 +8010,9 @@ class DiagramCanvas {
|
|
|
7582
8010
|
if (fieldDimensions[1] < minimumFieldHeight) {
|
|
7583
8011
|
fieldDimensions[1] = minimumFieldHeight;
|
|
7584
8012
|
}
|
|
7585
|
-
|
|
7586
|
-
let
|
|
8013
|
+
const type = field.rootElement.type;
|
|
8014
|
+
let stretchX = fieldDimensions[0] + getLeftMargin(type === null || type === undefined ? undefined : type.label) + getRightMargin(type === null || type === undefined ? undefined : type.label) - field.rootElement.width;
|
|
8015
|
+
let stretchY = fieldDimensions[1] + getTopMargin(type === null || type === undefined ? undefined : type.label) + getBottomMargin(type === null || type === undefined ? undefined : type.label) - field.rootElement.height;
|
|
7587
8016
|
if (this.snapToGrid) {
|
|
7588
8017
|
stretchX = Math.ceil(stretchX / this.gridSize) * this.gridSize;
|
|
7589
8018
|
stretchY = Math.ceil(stretchY / this.gridSize) * this.gridSize;
|
|
@@ -7595,8 +8024,8 @@ class DiagramCanvas {
|
|
|
7595
8024
|
if (field.rootElement.height + stretchY < (field.rootElement.getMinHeight() || 0)) {
|
|
7596
8025
|
stretchY = (field.rootElement.getMinHeight() || 0) - field.rootElement.height;
|
|
7597
8026
|
}
|
|
7598
|
-
(
|
|
7599
|
-
(
|
|
8027
|
+
(_b = field.rootElement.node) === null || _b === undefined ? undefined : _b.stretchSections(exports.Side.Right, stretchX, field.rootElement.indexXInNode, field.rootElement.indexYInNode);
|
|
8028
|
+
(_c = field.rootElement.node) === null || _c === undefined ? undefined : _c.stretchSections(exports.Side.Bottom, stretchY, field.rootElement.indexXInNode, field.rootElement.indexYInNode);
|
|
7600
8029
|
}
|
|
7601
8030
|
}
|
|
7602
8031
|
fitNodeInView(id) {
|
|
@@ -7927,41 +8356,6 @@ class DiagramCanvas {
|
|
|
7927
8356
|
}
|
|
7928
8357
|
}
|
|
7929
8358
|
DiagramCanvas.canvasCount = 0;
|
|
7930
|
-
/**
|
|
7931
|
-
* Checks if the given mouse event was produced with a secondary button press.
|
|
7932
|
-
* @private
|
|
7933
|
-
* @param event A mouse event.
|
|
7934
|
-
* @returns `true` if the given mouse event was produced with a secondary button press, `false` otherwise.
|
|
7935
|
-
*/
|
|
7936
|
-
const isSecondaryButton = event => {
|
|
7937
|
-
return !!event.button;
|
|
7938
|
-
};
|
|
7939
|
-
/**
|
|
7940
|
-
* Get the SVG path of a diagram connection.
|
|
7941
|
-
* @private
|
|
7942
|
-
* @see linePath
|
|
7943
|
-
*/
|
|
7944
|
-
const getConnectionPath = (shape, startCoords, endCoords, startDirection, endDirection, width, startMarkerWidth, endMarkerWidth) => {
|
|
7945
|
-
return linePath(shape, [startCoords, endCoords], startDirection, endDirection, Math.max(
|
|
7946
|
-
// reasonable value for the minimumDistanceBeforeTurn relative to the line width
|
|
7947
|
-
10, startMarkerWidth || 0, endMarkerWidth || 0) * width);
|
|
7948
|
-
};
|
|
7949
|
-
const setCursorStyle = style => {
|
|
7950
|
-
if (!style) {
|
|
7951
|
-
d3__namespace.select('body').style('cursor', exports.CursorStyle.Auto);
|
|
7952
|
-
} else {
|
|
7953
|
-
d3__namespace.select('body').style('cursor', style);
|
|
7954
|
-
}
|
|
7955
|
-
};
|
|
7956
|
-
const getRelatedNodeOrItself = element => {
|
|
7957
|
-
if (element instanceof DiagramNode) {
|
|
7958
|
-
return element;
|
|
7959
|
-
}
|
|
7960
|
-
if (element instanceof DiagramSection) {
|
|
7961
|
-
return element.node || element;
|
|
7962
|
-
}
|
|
7963
|
-
return element.rootElement instanceof DiagramNode || element.rootElement instanceof DiagramSection || element.rootElement instanceof DiagramPort ? getRelatedNodeOrItself(element.rootElement) : element;
|
|
7964
|
-
};
|
|
7965
8359
|
|
|
7966
8360
|
const VERSION = '0.0.1';
|
|
7967
8361
|
/**
|