@logicflow/extension 1.2.0-alpha.1 → 1.2.0-alpha.10
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/cjs/NodeResize/Control/Control.js +13 -9
- package/cjs/NodeResize/Node/DiamondResize.js +10 -8
- package/cjs/NodeResize/Node/EllipseResize.js +10 -8
- package/cjs/NodeResize/Node/HtmlResize.js +10 -8
- package/cjs/NodeResize/Node/RectResize.js +10 -8
- package/cjs/bpmn-adapter/index.js +1 -1
- package/cjs/components/control/index.js +16 -16
- package/cjs/components/highlight/index.js +187 -0
- package/cjs/components/menu/index.js +9 -9
- package/cjs/components/mini-map/index.js +5 -0
- package/cjs/components/selection-select/index.js +22 -2
- package/cjs/index.js +2 -0
- package/cjs/locale/en-locale/en.js +22 -0
- package/cjs/locale/en-locale/index.js +29 -0
- package/cjs/locale/locale.js +19 -0
- package/cjs/materials/group/GroupNode.js +22 -12
- package/cjs/turbo-adapter/index.js +71 -41
- package/es/NodeResize/Control/Control.js +13 -9
- package/es/NodeResize/Node/DiamondResize.d.ts +1 -1
- package/es/NodeResize/Node/DiamondResize.js +10 -8
- package/es/NodeResize/Node/EllipseResize.d.ts +1 -1
- package/es/NodeResize/Node/EllipseResize.js +10 -8
- package/es/NodeResize/Node/HtmlResize.d.ts +1 -1
- package/es/NodeResize/Node/HtmlResize.js +10 -8
- package/es/NodeResize/Node/RectResize.d.ts +1 -1
- package/es/NodeResize/Node/RectResize.js +10 -8
- package/es/bpmn-adapter/index.js +1 -1
- package/es/components/control/index.d.ts +2 -3
- package/es/components/control/index.js +16 -16
- package/es/components/highlight/index.d.ts +21 -0
- package/es/components/highlight/index.js +184 -0
- package/es/components/menu/index.d.ts +2 -3
- package/es/components/menu/index.js +9 -9
- package/es/components/mini-map/index.js +5 -0
- package/es/components/selection-select/index.d.ts +1 -0
- package/es/components/selection-select/index.js +22 -2
- package/es/index.d.ts +2 -0
- package/es/index.js +2 -0
- package/es/locale/en-locale/en.d.ts +19 -0
- package/es/locale/en-locale/en.js +19 -0
- package/es/locale/en-locale/index.d.ts +9 -0
- package/es/locale/en-locale/index.js +26 -0
- package/es/locale/locale.d.ts +6 -0
- package/es/locale/locale.js +16 -0
- package/es/materials/group/GroupNode.js +22 -12
- package/es/turbo-adapter/index.d.ts +6 -7
- package/es/turbo-adapter/index.js +70 -40
- package/lib/AutoLayout.js +1 -1
- package/lib/BpmnAdapter.js +1 -1
- package/lib/BpmnElement.js +1 -1
- package/lib/ContextMenu.js +1 -1
- package/lib/Control.js +1 -1
- package/lib/CurvedEdge.js +1 -1
- package/lib/DndPanel.js +1 -1
- package/lib/EnLocale.js +1 -0
- package/lib/FlowPath.js +1 -1
- package/lib/Group.js +1 -1
- package/lib/Highlight.js +1 -0
- package/lib/InsertNodeInPolyline.js +1 -1
- package/lib/Menu.js +1 -1
- package/lib/MiniMap.js +1 -1
- package/lib/NodeResize.js +1 -1
- package/lib/RectLabelNode.js +1 -1
- package/lib/SelectionSelect.js +1 -1
- package/lib/Snapshot.js +1 -1
- package/lib/TurboAdapter.js +1 -1
- package/lib/lfJson2Xml.js +1 -1
- package/lib/lfXml2Json.js +1 -1
- package/package.json +2 -2
- package/types/NodeResize/Node/DiamondResize.d.ts +1 -1
- package/types/NodeResize/Node/EllipseResize.d.ts +1 -1
- package/types/NodeResize/Node/HtmlResize.d.ts +1 -1
- package/types/NodeResize/Node/RectResize.d.ts +1 -1
- package/types/components/control/index.d.ts +2 -3
- package/types/components/highlight/index.d.ts +21 -0
- package/types/components/menu/index.d.ts +2 -3
- package/types/components/selection-select/index.d.ts +1 -0
- package/types/index.d.ts +2 -0
- package/types/locale/en-locale/en.d.ts +19 -0
- package/types/locale/en-locale/index.d.ts +9 -0
- package/types/locale/locale.d.ts +6 -0
- package/types/turbo-adapter/index.d.ts +6 -7
- package/types/NodeResize/BasicShape/Ellipse.d.ts +0 -2
- package/types/curved.d.ts +0 -0
- package/types/group-shrink/index.d.ts +0 -28
|
@@ -37,9 +37,11 @@ var Control = /** @class */ (function (_super) {
|
|
|
37
37
|
_this.updatePosition = function (_a) {
|
|
38
38
|
var deltaX = _a.deltaX, deltaY = _a.deltaY;
|
|
39
39
|
var _b = _this.nodeModel, x = _b.x, y = _b.y;
|
|
40
|
-
_this.nodeModel.x = x + deltaX / 2;
|
|
41
|
-
_this.nodeModel.y = y + deltaY / 2;
|
|
42
40
|
_this.nodeModel.moveText(deltaX / 2, deltaY / 2);
|
|
41
|
+
_this.nodeModel.updateAttributes({
|
|
42
|
+
x: x + deltaX / 2,
|
|
43
|
+
y: y + deltaY / 2,
|
|
44
|
+
});
|
|
43
45
|
};
|
|
44
46
|
// 计算control拖动后,节点的宽高
|
|
45
47
|
_this.getResize = function (_a) {
|
|
@@ -55,7 +57,7 @@ var Control = /** @class */ (function (_super) {
|
|
|
55
57
|
resize.height = height - deltaY * pct;
|
|
56
58
|
break;
|
|
57
59
|
case 2:
|
|
58
|
-
resize.width = width + deltaX;
|
|
60
|
+
resize.width = width + deltaX * pct;
|
|
59
61
|
resize.height = height + deltaY * pct;
|
|
60
62
|
break;
|
|
61
63
|
case 3:
|
|
@@ -93,14 +95,16 @@ var Control = /** @class */ (function (_super) {
|
|
|
93
95
|
}
|
|
94
96
|
_this.updatePosition({ deltaX: deltaX, deltaY: deltaY });
|
|
95
97
|
// 更新宽高
|
|
96
|
-
_this.nodeModel.width = size.width;
|
|
97
|
-
_this.nodeModel.height = size.height;
|
|
98
98
|
_this.nodeModel.setProperties({
|
|
99
99
|
nodeSize: {
|
|
100
100
|
width: size.width,
|
|
101
101
|
height: size.height,
|
|
102
102
|
},
|
|
103
103
|
});
|
|
104
|
+
_this.nodeModel.updateAttributes({
|
|
105
|
+
width: size.width,
|
|
106
|
+
height: size.height,
|
|
107
|
+
});
|
|
104
108
|
var edges = _this.getNodeEdges(id);
|
|
105
109
|
var beforeNode = {
|
|
106
110
|
x: x,
|
|
@@ -163,9 +167,9 @@ var Control = /** @class */ (function (_super) {
|
|
|
163
167
|
_this.updatePosition({ deltaX: deltaX, deltaY: deltaY });
|
|
164
168
|
// 更新rx ry,宽高为计算属性自动更新
|
|
165
169
|
// @ts-ignore
|
|
166
|
-
_this.nodeModel.rx =
|
|
170
|
+
_this.nodeModel.rx = size.width;
|
|
167
171
|
// @ts-ignore
|
|
168
|
-
_this.nodeModel.ry =
|
|
172
|
+
_this.nodeModel.ry = size.height;
|
|
169
173
|
_this.nodeModel.setProperties({
|
|
170
174
|
nodeSize: {
|
|
171
175
|
rx: size.width,
|
|
@@ -227,9 +231,9 @@ var Control = /** @class */ (function (_super) {
|
|
|
227
231
|
_this.updatePosition({ deltaX: deltaX, deltaY: deltaY });
|
|
228
232
|
// 更新rx ry,宽高为计算属性自动更新
|
|
229
233
|
// @ts-ignore
|
|
230
|
-
_this.nodeModel.rx =
|
|
234
|
+
_this.nodeModel.rx = size.width;
|
|
231
235
|
// @ts-ignore
|
|
232
|
-
_this.nodeModel.ry =
|
|
236
|
+
_this.nodeModel.ry = size.height;
|
|
233
237
|
_this.nodeModel.setProperties({
|
|
234
238
|
nodeSize: {
|
|
235
239
|
rx: size.width,
|
|
@@ -29,14 +29,8 @@ var ControlGroup_1 = require("../Control/ControlGroup");
|
|
|
29
29
|
var Polygon_1 = require("../BasicShape/Polygon");
|
|
30
30
|
var DiamondResizeModel = /** @class */ (function (_super) {
|
|
31
31
|
__extends(DiamondResizeModel, _super);
|
|
32
|
-
function DiamondResizeModel(
|
|
33
|
-
|
|
34
|
-
var nodeSize = _this.properties.nodeSize;
|
|
35
|
-
if (nodeSize) {
|
|
36
|
-
_this.rx = nodeSize.rx;
|
|
37
|
-
_this.ry = nodeSize.ry;
|
|
38
|
-
}
|
|
39
|
-
return _this;
|
|
32
|
+
function DiamondResizeModel() {
|
|
33
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
40
34
|
}
|
|
41
35
|
DiamondResizeModel.prototype.initNodeData = function (data) {
|
|
42
36
|
_super.prototype.initNodeData.call(this, data);
|
|
@@ -46,6 +40,14 @@ var DiamondResizeModel = /** @class */ (function (_super) {
|
|
|
46
40
|
this.maxHeight = 2000;
|
|
47
41
|
this.gridSize = 1;
|
|
48
42
|
};
|
|
43
|
+
DiamondResizeModel.prototype.init = function () {
|
|
44
|
+
_super.prototype.init.call(this);
|
|
45
|
+
var nodeSize = this.properties.nodeSize;
|
|
46
|
+
if (nodeSize) {
|
|
47
|
+
this.rx = nodeSize.rx;
|
|
48
|
+
this.ry = nodeSize.ry;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
49
51
|
DiamondResizeModel.prototype.getOutlineStyle = function () {
|
|
50
52
|
var style = _super.prototype.getOutlineStyle.call(this);
|
|
51
53
|
style.stroke = 'none';
|
|
@@ -17,14 +17,8 @@ var core_1 = require("@logicflow/core");
|
|
|
17
17
|
var ControlGroup_1 = require("../Control/ControlGroup");
|
|
18
18
|
var EllipseResizeModel = /** @class */ (function (_super) {
|
|
19
19
|
__extends(EllipseResizeModel, _super);
|
|
20
|
-
function EllipseResizeModel(
|
|
21
|
-
|
|
22
|
-
var nodeSize = _this.properties.nodeSize;
|
|
23
|
-
if (nodeSize) {
|
|
24
|
-
_this.rx = nodeSize.rx;
|
|
25
|
-
_this.ry = nodeSize.ry;
|
|
26
|
-
}
|
|
27
|
-
return _this;
|
|
20
|
+
function EllipseResizeModel() {
|
|
21
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
28
22
|
}
|
|
29
23
|
EllipseResizeModel.prototype.initNodeData = function (data) {
|
|
30
24
|
_super.prototype.initNodeData.call(this, data);
|
|
@@ -33,6 +27,14 @@ var EllipseResizeModel = /** @class */ (function (_super) {
|
|
|
33
27
|
this.maxWidth = 2000;
|
|
34
28
|
this.maxHeight = 2000;
|
|
35
29
|
};
|
|
30
|
+
EllipseResizeModel.prototype.init = function () {
|
|
31
|
+
_super.prototype.init.call(this);
|
|
32
|
+
var nodeSize = this.properties.nodeSize;
|
|
33
|
+
if (nodeSize) {
|
|
34
|
+
this.rx = nodeSize.rx;
|
|
35
|
+
this.ry = nodeSize.ry;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
36
38
|
EllipseResizeModel.prototype.getOutlineStyle = function () {
|
|
37
39
|
var style = _super.prototype.getOutlineStyle.call(this);
|
|
38
40
|
style.stroke = 'none';
|
|
@@ -17,14 +17,8 @@ var core_1 = require("@logicflow/core");
|
|
|
17
17
|
var ControlGroup_1 = require("../Control/ControlGroup");
|
|
18
18
|
var HtmlResizeModel = /** @class */ (function (_super) {
|
|
19
19
|
__extends(HtmlResizeModel, _super);
|
|
20
|
-
function HtmlResizeModel(
|
|
21
|
-
|
|
22
|
-
var nodeSize = _this.properties.nodeSize;
|
|
23
|
-
if (nodeSize) {
|
|
24
|
-
_this.width = nodeSize.width;
|
|
25
|
-
_this.height = nodeSize.height;
|
|
26
|
-
}
|
|
27
|
-
return _this;
|
|
20
|
+
function HtmlResizeModel() {
|
|
21
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
28
22
|
}
|
|
29
23
|
HtmlResizeModel.prototype.initNodeData = function (data) {
|
|
30
24
|
_super.prototype.initNodeData.call(this, data);
|
|
@@ -33,6 +27,14 @@ var HtmlResizeModel = /** @class */ (function (_super) {
|
|
|
33
27
|
this.maxWidth = 2000;
|
|
34
28
|
this.maxHeight = 2000;
|
|
35
29
|
};
|
|
30
|
+
HtmlResizeModel.prototype.init = function () {
|
|
31
|
+
_super.prototype.init.call(this);
|
|
32
|
+
var nodeSize = this.properties.nodeSize;
|
|
33
|
+
if (nodeSize) {
|
|
34
|
+
this.width = nodeSize.width;
|
|
35
|
+
this.height = nodeSize.height;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
36
38
|
HtmlResizeModel.prototype.getOutlineStyle = function () {
|
|
37
39
|
var style = _super.prototype.getOutlineStyle.call(this);
|
|
38
40
|
style.stroke = 'none';
|
|
@@ -17,14 +17,8 @@ var core_1 = require("@logicflow/core");
|
|
|
17
17
|
var ControlGroup_1 = require("../Control/ControlGroup");
|
|
18
18
|
var RectResizeModel = /** @class */ (function (_super) {
|
|
19
19
|
__extends(RectResizeModel, _super);
|
|
20
|
-
function RectResizeModel(
|
|
21
|
-
|
|
22
|
-
var nodeSize = _this.properties.nodeSize;
|
|
23
|
-
if (nodeSize) {
|
|
24
|
-
_this.width = nodeSize.width;
|
|
25
|
-
_this.height = nodeSize.height;
|
|
26
|
-
}
|
|
27
|
-
return _this;
|
|
20
|
+
function RectResizeModel() {
|
|
21
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
28
22
|
}
|
|
29
23
|
RectResizeModel.prototype.initNodeData = function (data) {
|
|
30
24
|
_super.prototype.initNodeData.call(this, data);
|
|
@@ -33,6 +27,14 @@ var RectResizeModel = /** @class */ (function (_super) {
|
|
|
33
27
|
this.maxWidth = 2000;
|
|
34
28
|
this.maxHeight = 2000;
|
|
35
29
|
};
|
|
30
|
+
RectResizeModel.prototype.init = function () {
|
|
31
|
+
_super.prototype.init.call(this);
|
|
32
|
+
var nodeSize = this.properties.nodeSize;
|
|
33
|
+
if (nodeSize) {
|
|
34
|
+
this.width = nodeSize.width;
|
|
35
|
+
this.height = nodeSize.height;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
36
38
|
RectResizeModel.prototype.getOutlineStyle = function () {
|
|
37
39
|
var style = _super.prototype.getOutlineStyle.call(this);
|
|
38
40
|
style.stroke = 'none';
|
|
@@ -179,7 +179,7 @@ function convertLf2ProcessData(bpmnProcessData, data) {
|
|
|
179
179
|
return edgeConfig;
|
|
180
180
|
});
|
|
181
181
|
// @see https://github.com/didi/LogicFlow/issues/325
|
|
182
|
-
// 需要保证
|
|
182
|
+
// 需要保证incoming在outgoing之前
|
|
183
183
|
data.edges.forEach(function (edge) {
|
|
184
184
|
var sourceNode = nodeMap.get(edge.sourceNodeId);
|
|
185
185
|
if (!sourceNode['bpmn:outgoing']) {
|
|
@@ -22,15 +22,16 @@ var __spread = (this && this.__spread) || function () {
|
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
exports.Control = void 0;
|
|
24
24
|
var Control = /** @class */ (function () {
|
|
25
|
-
function Control(
|
|
25
|
+
function Control(args) {
|
|
26
26
|
var _this = this;
|
|
27
|
-
|
|
27
|
+
this.lf = args.lf;
|
|
28
|
+
this.LogicFlow = args.LogicFlow;
|
|
28
29
|
this.controlItems = [
|
|
29
30
|
{
|
|
30
31
|
key: 'zoom-out',
|
|
31
32
|
iconClass: 'lf-control-zoomOut',
|
|
32
|
-
title: '缩小流程图',
|
|
33
|
-
text: '缩小',
|
|
33
|
+
title: this.LogicFlow.t('缩小流程图'),
|
|
34
|
+
text: this.LogicFlow.t('缩小'),
|
|
34
35
|
onClick: function () {
|
|
35
36
|
_this.lf.zoom(false);
|
|
36
37
|
},
|
|
@@ -38,8 +39,8 @@ var Control = /** @class */ (function () {
|
|
|
38
39
|
{
|
|
39
40
|
key: 'zoom-in',
|
|
40
41
|
iconClass: 'lf-control-zoomIn',
|
|
41
|
-
title: '放大流程图',
|
|
42
|
-
text: '放大',
|
|
42
|
+
title: this.LogicFlow.t('放大流程图'),
|
|
43
|
+
text: this.LogicFlow.t('放大'),
|
|
43
44
|
onClick: function () {
|
|
44
45
|
_this.lf.zoom(true);
|
|
45
46
|
},
|
|
@@ -47,8 +48,8 @@ var Control = /** @class */ (function () {
|
|
|
47
48
|
{
|
|
48
49
|
key: 'reset',
|
|
49
50
|
iconClass: 'lf-control-fit',
|
|
50
|
-
title: '恢复流程原有尺寸',
|
|
51
|
-
text: '适应',
|
|
51
|
+
title: this.LogicFlow.t('恢复流程原有尺寸'),
|
|
52
|
+
text: this.LogicFlow.t('适应'),
|
|
52
53
|
onClick: function () {
|
|
53
54
|
_this.lf.resetZoom();
|
|
54
55
|
},
|
|
@@ -56,8 +57,8 @@ var Control = /** @class */ (function () {
|
|
|
56
57
|
{
|
|
57
58
|
key: 'undo',
|
|
58
59
|
iconClass: 'lf-control-undo',
|
|
59
|
-
title: '回到上一步',
|
|
60
|
-
text: '上一步',
|
|
60
|
+
title: this.LogicFlow.t('回到上一步'),
|
|
61
|
+
text: this.LogicFlow.t('上一步'),
|
|
61
62
|
onClick: function () {
|
|
62
63
|
_this.lf.undo();
|
|
63
64
|
},
|
|
@@ -65,14 +66,13 @@ var Control = /** @class */ (function () {
|
|
|
65
66
|
{
|
|
66
67
|
key: 'redo',
|
|
67
68
|
iconClass: 'lf-control-redo',
|
|
68
|
-
title: '移到下一步',
|
|
69
|
-
text: '下一步',
|
|
69
|
+
title: this.LogicFlow.t('移到下一步'),
|
|
70
|
+
text: this.LogicFlow.t('下一步'),
|
|
70
71
|
onClick: function () {
|
|
71
72
|
_this.lf.redo();
|
|
72
73
|
},
|
|
73
74
|
},
|
|
74
75
|
];
|
|
75
|
-
this.lf = lf;
|
|
76
76
|
}
|
|
77
77
|
Control.prototype.render = function (lf, domContainer) {
|
|
78
78
|
this.destroy();
|
|
@@ -113,14 +113,14 @@ var Control = /** @class */ (function () {
|
|
|
113
113
|
text.title = item.title;
|
|
114
114
|
text.innerText = item.text;
|
|
115
115
|
itemContainer.append(icon, text);
|
|
116
|
-
switch (item.
|
|
117
|
-
case '
|
|
116
|
+
switch (item.key) {
|
|
117
|
+
case 'undo':
|
|
118
118
|
_this.lf.on('history:change', function (_a) {
|
|
119
119
|
var undoAble = _a.data.undoAble;
|
|
120
120
|
itemContainer.className = undoAble ? NORMAL : DISABLED;
|
|
121
121
|
});
|
|
122
122
|
break;
|
|
123
|
-
case '
|
|
123
|
+
case 'redo':
|
|
124
124
|
_this.lf.on('history:change', function (_a) {
|
|
125
125
|
var redoAble = _a.data.redoAble;
|
|
126
126
|
itemContainer.className = redoAble ? NORMAL : DISABLED;
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
14
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
15
|
+
if (!m) return o;
|
|
16
|
+
var i = m.call(o), r, ar = [], e;
|
|
17
|
+
try {
|
|
18
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
19
|
+
}
|
|
20
|
+
catch (error) { e = { error: error }; }
|
|
21
|
+
finally {
|
|
22
|
+
try {
|
|
23
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
24
|
+
}
|
|
25
|
+
finally { if (e) throw e.error; }
|
|
26
|
+
}
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
var __spread = (this && this.__spread) || function () {
|
|
30
|
+
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
|
31
|
+
return ar;
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
exports.Highlight = void 0;
|
|
35
|
+
// 后续并入FlowPath
|
|
36
|
+
var getPath = function (id, lf) {
|
|
37
|
+
var el = lf.getModelById(id);
|
|
38
|
+
return getNodePath(el.BaseType === 'node' ? el : el.targetNode, lf);
|
|
39
|
+
};
|
|
40
|
+
// dfs + 动态规划
|
|
41
|
+
// todo 算法优化
|
|
42
|
+
var getNodePath = function (node, lf) {
|
|
43
|
+
var incomingPaths = [];
|
|
44
|
+
var outgoingPaths = [];
|
|
45
|
+
var getIncomingPaths = function (curNode, path, prevNode) {
|
|
46
|
+
if (prevNode === void 0) { prevNode = null; }
|
|
47
|
+
if (prevNode) {
|
|
48
|
+
// * 上个节点和当前节点中间边
|
|
49
|
+
path.unshift.apply(path, __spread(lf
|
|
50
|
+
.getEdgeModels({
|
|
51
|
+
sourceNodeId: curNode.id,
|
|
52
|
+
targetNodeId: prevNode.id,
|
|
53
|
+
})
|
|
54
|
+
.map(function (item) { return item.id; })));
|
|
55
|
+
}
|
|
56
|
+
// * 路径中存在节点,则不再继续查找,说明出现环情况
|
|
57
|
+
if (path.includes(curNode.id)) {
|
|
58
|
+
incomingPaths.push(path);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
// * 路径中当前加入节点
|
|
62
|
+
path.unshift(curNode.id);
|
|
63
|
+
if (!curNode.incoming.nodes.length) {
|
|
64
|
+
incomingPaths.push(path);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
// * 往下找
|
|
68
|
+
curNode.incoming.nodes.forEach(function (nextNode) {
|
|
69
|
+
getIncomingPaths(nextNode, path.slice(), curNode);
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
// * 同上逻辑
|
|
73
|
+
var getOutgoingPaths = function (curNode, path, prevNode) {
|
|
74
|
+
if (prevNode === void 0) { prevNode = null; }
|
|
75
|
+
if (prevNode) {
|
|
76
|
+
path.push.apply(path, __spread(lf
|
|
77
|
+
.getEdgeModels({
|
|
78
|
+
sourceNodeId: prevNode.id,
|
|
79
|
+
targetNodeId: curNode.id,
|
|
80
|
+
})
|
|
81
|
+
.map(function (item) { return item.id; })));
|
|
82
|
+
}
|
|
83
|
+
if (path.includes(curNode.id)) {
|
|
84
|
+
outgoingPaths.push(path);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
path.push(curNode.id);
|
|
88
|
+
if (!curNode.outgoing.nodes.length) {
|
|
89
|
+
outgoingPaths.push(path);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
curNode.outgoing.nodes.forEach(function (nextNode) {
|
|
93
|
+
getOutgoingPaths(nextNode, path.slice(), curNode);
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
getIncomingPaths(node, []);
|
|
97
|
+
getOutgoingPaths(node, []);
|
|
98
|
+
return __spread(new Set(__spread(incomingPaths.flat(), outgoingPaths.flat())));
|
|
99
|
+
};
|
|
100
|
+
var Highlight = /** @class */ (function () {
|
|
101
|
+
function Highlight(_a) {
|
|
102
|
+
var lf = _a.lf;
|
|
103
|
+
this.mode = 'path';
|
|
104
|
+
this.manual = false;
|
|
105
|
+
this.tempStyles = {};
|
|
106
|
+
this.lf = lf;
|
|
107
|
+
}
|
|
108
|
+
Highlight.prototype.setMode = function (mode) {
|
|
109
|
+
this.mode = mode;
|
|
110
|
+
};
|
|
111
|
+
Highlight.prototype.setManual = function (manual) {
|
|
112
|
+
this.manual = manual;
|
|
113
|
+
};
|
|
114
|
+
Highlight.prototype.highlightSingle = function (id) {
|
|
115
|
+
var model = this.lf.getModelById(id);
|
|
116
|
+
if (model.BaseType === 'node') {
|
|
117
|
+
// 高亮节点
|
|
118
|
+
model.updateStyles(this.tempStyles[id]);
|
|
119
|
+
}
|
|
120
|
+
else if (model.BaseType === 'edge') {
|
|
121
|
+
// 高亮边及对应的节点
|
|
122
|
+
model.updateStyles(this.tempStyles[id]);
|
|
123
|
+
model.sourceNode.updateStyles(this.tempStyles[model.sourceNode.id]);
|
|
124
|
+
model.targetNode.updateStyles(this.tempStyles[model.targetNode.id]);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
Highlight.prototype.highlightPath = function (id) {
|
|
128
|
+
var _this = this;
|
|
129
|
+
var path = getPath(id, this.lf);
|
|
130
|
+
path.forEach(function (_id) {
|
|
131
|
+
// 高亮路径上所有的边和节点
|
|
132
|
+
_this.lf.getModelById(_id).updateStyles(_this.tempStyles[_id]);
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
Highlight.prototype.highlight = function (id, mode) {
|
|
136
|
+
var _this = this;
|
|
137
|
+
if (mode === void 0) { mode = this.mode; }
|
|
138
|
+
if (this.manual)
|
|
139
|
+
return;
|
|
140
|
+
if (Object.keys(this.tempStyles).length) {
|
|
141
|
+
this.restoreHighlight();
|
|
142
|
+
}
|
|
143
|
+
Object.values(this.lf.graphModel.modelsMap).forEach(function (item) {
|
|
144
|
+
// 所有节点样式都进行备份
|
|
145
|
+
// eslint-disable-next-line operator-linebreak
|
|
146
|
+
var oStyle = item.BaseType === 'node' ? item.getNodeStyle() : item.getEdgeStyle();
|
|
147
|
+
_this.tempStyles[item.id] = __assign({}, oStyle);
|
|
148
|
+
// 所有节点都设置透明度为0.1
|
|
149
|
+
item.setStyles({ opacity: 0.1 });
|
|
150
|
+
});
|
|
151
|
+
var modeTrigger = {
|
|
152
|
+
single: this.highlightSingle.bind(this),
|
|
153
|
+
path: this.highlightPath.bind(this),
|
|
154
|
+
};
|
|
155
|
+
modeTrigger[mode](id);
|
|
156
|
+
};
|
|
157
|
+
Highlight.prototype.restoreHighlight = function () {
|
|
158
|
+
var _this = this;
|
|
159
|
+
// 恢复所有节点的样式
|
|
160
|
+
if (!Object.keys(this.tempStyles).length)
|
|
161
|
+
return;
|
|
162
|
+
Object.values(this.lf.graphModel.modelsMap).forEach(function (item) {
|
|
163
|
+
var _a;
|
|
164
|
+
var oStyle = (_a = _this.tempStyles[item.id]) !== null && _a !== void 0 ? _a : {};
|
|
165
|
+
item.updateStyles(__assign({}, oStyle));
|
|
166
|
+
});
|
|
167
|
+
this.tempStyles = {};
|
|
168
|
+
};
|
|
169
|
+
Highlight.prototype.render = function (lf, domContainer) {
|
|
170
|
+
var _this = this;
|
|
171
|
+
this.lf.on('node:mouseenter', function (_a) {
|
|
172
|
+
var data = _a.data;
|
|
173
|
+
return _this.highlight(data.id);
|
|
174
|
+
});
|
|
175
|
+
this.lf.on('edge:mouseenter', function (_a) {
|
|
176
|
+
var data = _a.data;
|
|
177
|
+
return _this.highlight(data.id);
|
|
178
|
+
});
|
|
179
|
+
this.lf.on('node:mouseleave', this.restoreHighlight.bind(this));
|
|
180
|
+
this.lf.on('edge:mouseleave', this.restoreHighlight.bind(this));
|
|
181
|
+
this.lf.on('history:change', this.restoreHighlight.bind(this));
|
|
182
|
+
};
|
|
183
|
+
Highlight.prototype.destroy = function () { };
|
|
184
|
+
Highlight.pluginName = 'highlight';
|
|
185
|
+
return Highlight;
|
|
186
|
+
}());
|
|
187
|
+
exports.Highlight = Highlight;
|
|
@@ -26,11 +26,11 @@ var DefaultEdgeMenuKey = 'lf:defaultEdgeMenu';
|
|
|
26
26
|
var DefaultGraphMenuKey = 'lf:defaultGraphMenu';
|
|
27
27
|
var DefaultSelectionMenuKey = 'lf:defaultSelectionMenu';
|
|
28
28
|
var Menu = /** @class */ (function () {
|
|
29
|
-
function Menu(
|
|
29
|
+
function Menu(args) {
|
|
30
30
|
var _this = this;
|
|
31
|
-
var lf = _a.lf;
|
|
32
31
|
this.__menuDOM = document.createElement('ul');
|
|
33
|
-
this.lf = lf;
|
|
32
|
+
this.lf = args.lf;
|
|
33
|
+
this.LogicFlow = args.LogicFlow;
|
|
34
34
|
this.menuTypeMap = new Map();
|
|
35
35
|
this.init();
|
|
36
36
|
this.lf.setMenuConfig = function (config) {
|
|
@@ -50,19 +50,19 @@ var Menu = /** @class */ (function () {
|
|
|
50
50
|
var _this = this;
|
|
51
51
|
var defaultNodeMenu = [
|
|
52
52
|
{
|
|
53
|
-
text: '删除',
|
|
53
|
+
text: this.LogicFlow.t('删除'),
|
|
54
54
|
callback: function (node) {
|
|
55
55
|
_this.lf.deleteNode(node.id);
|
|
56
56
|
},
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
|
-
text: '编辑文本',
|
|
59
|
+
text: this.LogicFlow.t('编辑文本'),
|
|
60
60
|
callback: function (node) {
|
|
61
61
|
_this.lf.graphModel.editText(node.id);
|
|
62
62
|
},
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
|
-
text: '复制',
|
|
65
|
+
text: this.LogicFlow.t('复制'),
|
|
66
66
|
callback: function (node) {
|
|
67
67
|
_this.lf.cloneNode(node.id);
|
|
68
68
|
},
|
|
@@ -71,13 +71,13 @@ var Menu = /** @class */ (function () {
|
|
|
71
71
|
this.menuTypeMap.set(DefaultNodeMenuKey, defaultNodeMenu);
|
|
72
72
|
var defaultEdgeMenu = [
|
|
73
73
|
{
|
|
74
|
-
text: '删除',
|
|
74
|
+
text: this.LogicFlow.t('删除'),
|
|
75
75
|
callback: function (edge) {
|
|
76
76
|
_this.lf.deleteEdge(edge.id);
|
|
77
77
|
},
|
|
78
78
|
},
|
|
79
79
|
{
|
|
80
|
-
text: '编辑文本',
|
|
80
|
+
text: this.LogicFlow.t('编辑文本'),
|
|
81
81
|
callback: function (edge) {
|
|
82
82
|
_this.lf.graphModel.editText(edge.id);
|
|
83
83
|
},
|
|
@@ -87,7 +87,7 @@ var Menu = /** @class */ (function () {
|
|
|
87
87
|
this.menuTypeMap.set(DefaultGraphMenuKey, []);
|
|
88
88
|
var DefaultSelectionMenu = [
|
|
89
89
|
{
|
|
90
|
-
text: '删除',
|
|
90
|
+
text: this.LogicFlow.t('删除'),
|
|
91
91
|
callback: function (elements) {
|
|
92
92
|
_this.lf.clearSelectElements();
|
|
93
93
|
elements.edges.forEach(function (edge) { return _this.lf.deleteEdge(edge.id); });
|
|
@@ -103,6 +103,11 @@ var MiniMap = /** @class */ (function () {
|
|
|
103
103
|
_this.__setView();
|
|
104
104
|
}
|
|
105
105
|
});
|
|
106
|
+
this.__lf.on('blank:drop', function () {
|
|
107
|
+
if (_this.__isShow) {
|
|
108
|
+
_this.__setView();
|
|
109
|
+
}
|
|
110
|
+
});
|
|
106
111
|
};
|
|
107
112
|
MiniMap.prototype.init = function (option) {
|
|
108
113
|
this.__disabledPlugins = this.__disabledPlugins.concat(option.disabledPlugins || []);
|
|
@@ -43,9 +43,11 @@ var SelectionSelect = /** @class */ (function () {
|
|
|
43
43
|
}
|
|
44
44
|
var lt = [Math.min(x, x1), Math.min(y, y1)];
|
|
45
45
|
var rt = [Math.max(x, x1), Math.max(y, y1)];
|
|
46
|
-
var elements = _this.lf.getAreaElement(lt, rt, _this.isWholeEdge, _this.isWholeNode);
|
|
46
|
+
var elements = _this.lf.graphModel.getAreaElement(lt, rt, _this.isWholeEdge, _this.isWholeNode);
|
|
47
47
|
elements.forEach(function (element) {
|
|
48
|
-
_this.
|
|
48
|
+
if (_this.isSelectElement(element)) {
|
|
49
|
+
_this.lf.selectElementById(element.id, true);
|
|
50
|
+
}
|
|
49
51
|
});
|
|
50
52
|
_this.lf.emit('selection:selected', elements);
|
|
51
53
|
};
|
|
@@ -118,6 +120,24 @@ var SelectionSelect = /** @class */ (function () {
|
|
|
118
120
|
}
|
|
119
121
|
this.close();
|
|
120
122
|
};
|
|
123
|
+
SelectionSelect.prototype.isSelectElement = function (elementModel) {
|
|
124
|
+
// 如果不可见,则不被选中
|
|
125
|
+
if (!elementModel.visible)
|
|
126
|
+
return false;
|
|
127
|
+
var group = this.lf.extension.group;
|
|
128
|
+
// 节点在group中,则不被选中
|
|
129
|
+
if (group) {
|
|
130
|
+
if (elementModel.BaseType === 'node' && group.getNodeGroup(elementModel.id))
|
|
131
|
+
return false;
|
|
132
|
+
if (elementModel.BaseType === 'edge') {
|
|
133
|
+
if (group.getNodeGroup(elementModel.sourceNodeId)
|
|
134
|
+
|| group.getNodeGroup(elementModel.targetNodeId)) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return true;
|
|
140
|
+
};
|
|
121
141
|
SelectionSelect.prototype.open = function () {
|
|
122
142
|
this.__disabled = false;
|
|
123
143
|
};
|
package/cjs/index.js
CHANGED
|
@@ -29,3 +29,5 @@ __exportStar(require("./tools/flow-path"), exports);
|
|
|
29
29
|
__exportStar(require("./tools/auto-layout"), exports);
|
|
30
30
|
__exportStar(require("./bpmn-adapter/xml2json"), exports);
|
|
31
31
|
__exportStar(require("./bpmn-adapter/json2xml"), exports);
|
|
32
|
+
__exportStar(require("./locale/en-locale"), exports);
|
|
33
|
+
__exportStar(require("./components/highlight"), exports);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.en = void 0;
|
|
4
|
+
var en = {
|
|
5
|
+
文本: 'text',
|
|
6
|
+
开始: 'start',
|
|
7
|
+
缩小流程图: 'zoom in',
|
|
8
|
+
缩小: 'zoom in',
|
|
9
|
+
放大流程图: 'zoom out',
|
|
10
|
+
放大: 'zoom out',
|
|
11
|
+
恢复流程原有尺寸: 'adapt to original size',
|
|
12
|
+
适应: 'adapt',
|
|
13
|
+
回到上一步: 'undo',
|
|
14
|
+
上一步: 'undo',
|
|
15
|
+
移到下一步: 'redo',
|
|
16
|
+
下一步: 'redo',
|
|
17
|
+
删除: 'delete',
|
|
18
|
+
编辑文本: 'edit text',
|
|
19
|
+
复制: 'copy',
|
|
20
|
+
};
|
|
21
|
+
exports.en = en;
|
|
22
|
+
exports.default = en;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.EnLocale = void 0;
|
|
17
|
+
var locale_1 = require("../locale");
|
|
18
|
+
var en_1 = require("./en");
|
|
19
|
+
var EnLocale = /** @class */ (function (_super) {
|
|
20
|
+
__extends(EnLocale, _super);
|
|
21
|
+
function EnLocale(_a) {
|
|
22
|
+
var LogicFlow = _a.LogicFlow;
|
|
23
|
+
return _super.call(this, LogicFlow, en_1.default) || this;
|
|
24
|
+
}
|
|
25
|
+
EnLocale.pluginName = 'enLocale';
|
|
26
|
+
return EnLocale;
|
|
27
|
+
}(locale_1.Locale));
|
|
28
|
+
exports.EnLocale = EnLocale;
|
|
29
|
+
exports.default = EnLocale;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Locale = void 0;
|
|
4
|
+
var Locale = /** @class */ (function () {
|
|
5
|
+
function Locale(LogicFlow, map) {
|
|
6
|
+
if (LogicFlow && map) {
|
|
7
|
+
this.replaceTranslator(LogicFlow, map);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
Locale.prototype.replaceTranslator = function (LogicFlow, map) {
|
|
11
|
+
LogicFlow.t = function (text) { return (map[text] ? map[text] : text); };
|
|
12
|
+
};
|
|
13
|
+
Locale.prototype.setDefault = function (LogicFlow) {
|
|
14
|
+
LogicFlow.t = Locale.defaultTranslator;
|
|
15
|
+
};
|
|
16
|
+
Locale.defaultTranslator = function (text) { return text; };
|
|
17
|
+
return Locale;
|
|
18
|
+
}());
|
|
19
|
+
exports.Locale = Locale;
|