@logicflow/extension 1.2.0-next.0 → 1.2.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/NodeResize/Control/Control.js +71 -16
- package/cjs/NodeResize/Node/DiamondResize.js +24 -10
- package/cjs/NodeResize/Node/EllipseResize.js +24 -10
- package/cjs/NodeResize/Node/HtmlResize.js +24 -10
- package/cjs/NodeResize/Node/RectResize.js +24 -10
- package/cjs/bpmn-adapter/index.js +74 -122
- package/cjs/bpmn-adapter/json2xml.js +2 -4
- package/cjs/bpmn-adapter/xml2json.js +247 -2
- package/cjs/components/control/index.js +16 -16
- package/cjs/components/dnd-panel/index.js +21 -0
- package/cjs/components/highlight/index.js +0 -1
- package/cjs/components/menu/index.js +9 -9
- package/cjs/components/mini-map/index.js +223 -138
- package/cjs/components/selection-select/index.js +6 -19
- package/cjs/index.js +0 -1
- package/cjs/materials/curved-edge/index.js +19 -5
- package/cjs/materials/curved-edge/searchMiddleIndex.js +17 -0
- package/cjs/materials/group/GroupNode.js +34 -65
- package/cjs/materials/group/index.js +80 -70
- package/cjs/style/index.css +10 -0
- package/cjs/tools/auto-layout/index.js +1 -1
- package/es/NodeResize/Control/Control.d.ts +4 -1
- package/es/NodeResize/Control/Control.js +71 -16
- package/es/NodeResize/Node/DiamondResize.d.ts +3 -1
- package/es/NodeResize/Node/DiamondResize.js +24 -10
- package/es/NodeResize/Node/EllipseResize.d.ts +3 -1
- package/es/NodeResize/Node/EllipseResize.js +24 -10
- package/es/NodeResize/Node/HtmlResize.d.ts +3 -1
- package/es/NodeResize/Node/HtmlResize.js +24 -10
- package/es/NodeResize/Node/RectResize.d.ts +3 -1
- package/es/NodeResize/Node/RectResize.js +24 -10
- package/es/bpmn-adapter/index.d.ts +33 -41
- package/es/bpmn-adapter/index.js +74 -122
- package/es/bpmn-adapter/json2xml.js +2 -4
- package/es/bpmn-adapter/xml2json.js +247 -2
- package/es/components/control/index.d.ts +3 -2
- package/es/components/control/index.js +16 -16
- package/es/components/dnd-panel/index.js +21 -0
- package/es/components/highlight/index.js +0 -1
- package/es/components/menu/index.d.ts +3 -2
- package/es/components/menu/index.js +9 -9
- package/es/components/mini-map/index.d.ts +57 -45
- package/es/components/mini-map/index.js +223 -138
- package/es/components/selection-select/index.d.ts +0 -1
- package/es/components/selection-select/index.js +6 -19
- package/es/index.d.ts +0 -1
- package/es/index.js +0 -1
- package/es/materials/curved-edge/index.js +19 -5
- package/es/materials/curved-edge/searchMiddleIndex.d.ts +1 -0
- package/es/materials/curved-edge/searchMiddleIndex.js +14 -0
- package/es/materials/group/GroupNode.d.ts +5 -7
- package/es/materials/group/GroupNode.js +34 -65
- package/es/materials/group/index.d.ts +19 -1
- package/es/materials/group/index.js +80 -70
- package/es/style/index.css +10 -0
- package/es/tools/auto-layout/index.d.ts +1 -1
- package/es/tools/auto-layout/index.js +1 -1
- 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/FlowPath.js +1 -1
- package/lib/Group.js +1 -1
- package/lib/Highlight.js +1 -1
- 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/lib/style/index.css +10 -0
- package/package.json +3 -2
- package/types/NodeResize/Control/Control.d.ts +4 -1
- package/types/NodeResize/Node/DiamondResize.d.ts +3 -1
- package/types/NodeResize/Node/EllipseResize.d.ts +3 -1
- package/types/NodeResize/Node/HtmlResize.d.ts +3 -1
- package/types/NodeResize/Node/RectResize.d.ts +3 -1
- package/types/bpmn-adapter/index.d.ts +33 -41
- package/types/components/control/index.d.ts +3 -2
- package/types/components/menu/index.d.ts +3 -2
- package/types/components/mini-map/index.d.ts +57 -45
- package/types/components/selection-select/index.d.ts +0 -1
- package/types/index.d.ts +0 -1
- package/types/materials/curved-edge/searchMiddleIndex.d.ts +1 -0
- package/types/materials/group/GroupNode.d.ts +5 -7
- package/types/materials/group/index.d.ts +19 -1
- package/types/tools/auto-layout/index.d.ts +1 -1
- package/cjs/locale/en-locale/en.js +0 -22
- package/cjs/locale/en-locale/index.js +0 -29
- package/cjs/locale/locale.js +0 -19
- package/es/locale/en-locale/en.d.ts +0 -19
- package/es/locale/en-locale/en.js +0 -19
- package/es/locale/en-locale/index.d.ts +0 -9
- package/es/locale/en-locale/index.js +0 -26
- package/es/locale/locale.d.ts +0 -6
- package/es/locale/locale.js +0 -16
- package/lib/EnLocale.js +0 -1
|
@@ -9,134 +9,180 @@ var __values = (this && this.__values) || function(o) {
|
|
|
9
9
|
};
|
|
10
10
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
11
11
|
};
|
|
12
|
+
import { throttle } from 'lodash-es';
|
|
12
13
|
var MiniMap = /** @class */ (function () {
|
|
13
14
|
function MiniMap(_a) {
|
|
14
15
|
var _this = this;
|
|
15
|
-
var lf = _a.lf, LogicFlow = _a.LogicFlow;
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
23
|
-
this.
|
|
24
|
-
this.
|
|
25
|
-
this.
|
|
26
|
-
this.
|
|
27
|
-
this.
|
|
28
|
-
this.
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
31
|
-
this.
|
|
32
|
-
this.
|
|
33
|
-
this.
|
|
34
|
-
this.
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
16
|
+
var lf = _a.lf, LogicFlow = _a.LogicFlow, options = _a.options;
|
|
17
|
+
this.lf = null;
|
|
18
|
+
this.container = null;
|
|
19
|
+
this.miniMapWrap = null;
|
|
20
|
+
this.miniMapContainer = null;
|
|
21
|
+
this.lfMap = null;
|
|
22
|
+
this.viewport = null;
|
|
23
|
+
this.width = 150;
|
|
24
|
+
this.height = 220;
|
|
25
|
+
this.leftPosition = undefined;
|
|
26
|
+
this.topPosition = undefined;
|
|
27
|
+
this.rightPosition = undefined;
|
|
28
|
+
this.bottomPosition = undefined;
|
|
29
|
+
this.miniMapWidth = 450;
|
|
30
|
+
this.miniMapHeight = 660;
|
|
31
|
+
this.viewPortTop = 0;
|
|
32
|
+
this.viewPortLeft = 0;
|
|
33
|
+
this.startPosition = null;
|
|
34
|
+
this.viewPortScale = 1;
|
|
35
|
+
this.viewPortWidth = 150;
|
|
36
|
+
this.viewPortHeight = 75;
|
|
37
|
+
this.resetDataX = 0;
|
|
38
|
+
this.resetDataY = 0;
|
|
39
|
+
this.LogicFlow = null;
|
|
40
|
+
this.isShow = false;
|
|
41
|
+
this.isShowHeader = true;
|
|
42
|
+
this.isShowCloseIcon = true;
|
|
43
|
+
this.dragging = false;
|
|
44
|
+
this.disabledPlugins = ['miniMap', 'control', 'selectionSelect'];
|
|
37
45
|
/**
|
|
38
46
|
* 显示mini map
|
|
39
|
-
|
|
47
|
+
*/
|
|
40
48
|
this.show = function (leftPosition, topPosition) {
|
|
41
|
-
_this.
|
|
42
|
-
if (!_this.
|
|
43
|
-
_this.
|
|
49
|
+
_this.setView();
|
|
50
|
+
if (!_this.isShow) {
|
|
51
|
+
_this.createMiniMap(leftPosition, topPosition);
|
|
44
52
|
}
|
|
45
|
-
_this.
|
|
53
|
+
_this.isShow = true;
|
|
46
54
|
};
|
|
47
55
|
/**
|
|
48
56
|
* 隐藏mini map
|
|
49
57
|
*/
|
|
50
58
|
this.hide = function () {
|
|
51
|
-
if (_this.
|
|
52
|
-
_this.
|
|
59
|
+
if (_this.isShow) {
|
|
60
|
+
_this.removeMiniMap();
|
|
53
61
|
}
|
|
54
|
-
_this.
|
|
62
|
+
_this.isShow = false;
|
|
63
|
+
};
|
|
64
|
+
this.reset = function () {
|
|
65
|
+
_this.lf.resetTranslate();
|
|
66
|
+
_this.lf.resetZoom();
|
|
67
|
+
_this.hide();
|
|
68
|
+
_this.show();
|
|
55
69
|
};
|
|
56
|
-
this.
|
|
57
|
-
document.addEventListener('mousemove', _this.
|
|
58
|
-
document.addEventListener('mouseup', _this.
|
|
59
|
-
_this.
|
|
70
|
+
this.startDrag = function (e) {
|
|
71
|
+
document.addEventListener('mousemove', _this.drag);
|
|
72
|
+
document.addEventListener('mouseup', _this.drop);
|
|
73
|
+
_this.startPosition = {
|
|
60
74
|
x: e.x,
|
|
61
75
|
y: e.y,
|
|
62
76
|
};
|
|
63
77
|
};
|
|
64
78
|
this.moveViewport = function (top, left) {
|
|
65
|
-
var viewStyle = _this.
|
|
66
|
-
_this.
|
|
67
|
-
_this.
|
|
68
|
-
viewStyle.top = _this.
|
|
69
|
-
viewStyle.left = _this.
|
|
79
|
+
var viewStyle = _this.viewport.style;
|
|
80
|
+
_this.viewPortTop = top;
|
|
81
|
+
_this.viewPortLeft = left;
|
|
82
|
+
viewStyle.top = _this.viewPortTop + "px";
|
|
83
|
+
viewStyle.left = _this.viewPortLeft + "px";
|
|
70
84
|
};
|
|
71
|
-
this.
|
|
72
|
-
|
|
73
|
-
var
|
|
85
|
+
this.drag = function (e) {
|
|
86
|
+
_this.dragging = true;
|
|
87
|
+
var top = _this.viewPortTop + e.y - _this.startPosition.y;
|
|
88
|
+
var left = _this.viewPortLeft + e.x - _this.startPosition.x;
|
|
74
89
|
_this.moveViewport(top, left);
|
|
75
|
-
_this.
|
|
90
|
+
_this.startPosition = {
|
|
76
91
|
x: e.x,
|
|
77
92
|
y: e.y,
|
|
78
93
|
};
|
|
79
|
-
var centerX = (_this.
|
|
80
|
-
/ _this.
|
|
81
|
-
var centerY = (_this.
|
|
82
|
-
/ _this.
|
|
83
|
-
_this.
|
|
94
|
+
var centerX = (_this.viewPortLeft + _this.viewPortWidth / 2)
|
|
95
|
+
/ _this.viewPortScale;
|
|
96
|
+
var centerY = (_this.viewPortTop + _this.viewPortHeight / 2)
|
|
97
|
+
/ _this.viewPortScale;
|
|
98
|
+
_this.lf.focusOn({
|
|
84
99
|
coordinate: {
|
|
85
|
-
x: centerX + _this.
|
|
86
|
-
y: centerY + _this.
|
|
100
|
+
x: centerX + _this.resetDataX,
|
|
101
|
+
y: centerY + _this.resetDataY,
|
|
87
102
|
},
|
|
88
103
|
});
|
|
89
104
|
};
|
|
90
|
-
this.
|
|
91
|
-
document.removeEventListener('mousemove', _this.
|
|
92
|
-
document.removeEventListener('mouseup', _this.
|
|
93
|
-
var top = _this.
|
|
94
|
-
var left = _this.
|
|
95
|
-
if (_this.
|
|
96
|
-
left = _this.
|
|
105
|
+
this.drop = function () {
|
|
106
|
+
document.removeEventListener('mousemove', _this.drag);
|
|
107
|
+
document.removeEventListener('mouseup', _this.drop);
|
|
108
|
+
var top = _this.viewPortTop;
|
|
109
|
+
var left = _this.viewPortLeft;
|
|
110
|
+
if (_this.viewPortLeft > _this.width) {
|
|
111
|
+
left = _this.width - _this.viewPortWidth;
|
|
97
112
|
}
|
|
98
|
-
if (_this.
|
|
99
|
-
top = _this.
|
|
113
|
+
if (_this.viewPortTop > _this.height) {
|
|
114
|
+
top = _this.height - _this.viewPortHeight;
|
|
100
115
|
}
|
|
101
|
-
if (_this.
|
|
116
|
+
if (_this.viewPortLeft < -_this.width) {
|
|
102
117
|
left = 0;
|
|
103
118
|
}
|
|
104
|
-
if (_this.
|
|
119
|
+
if (_this.viewPortTop < -_this.height) {
|
|
105
120
|
top = 0;
|
|
106
121
|
}
|
|
107
122
|
_this.moveViewport(top, left);
|
|
108
123
|
};
|
|
109
|
-
this.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
124
|
+
this.mapClick = function (e) {
|
|
125
|
+
if (_this.dragging) {
|
|
126
|
+
_this.dragging = false;
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
var layerX = e.layerX, layerY = e.layerY;
|
|
130
|
+
var ViewPortCenterX = layerX;
|
|
131
|
+
var ViewPortCenterY = layerY;
|
|
132
|
+
var graphData = _this.lf.getGraphRawData();
|
|
133
|
+
var _a = _this.getBounds(graphData), left = _a.left, top_1 = _a.top;
|
|
134
|
+
var resetGraphX = left + ViewPortCenterX / _this.viewPortScale;
|
|
135
|
+
var resetGraphY = top_1 + ViewPortCenterY / _this.viewPortScale;
|
|
136
|
+
_this.lf.focusOn({ coordinate: { x: resetGraphX, y: resetGraphY } });
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
this.lf = lf;
|
|
140
|
+
if (options && options.MiniMap) {
|
|
141
|
+
this.setOption(options);
|
|
142
|
+
}
|
|
143
|
+
this.miniMapWidth = lf.graphModel.width;
|
|
144
|
+
this.miniMapHeight = (lf.graphModel.width * this.height) / this.width;
|
|
145
|
+
this.LogicFlow = LogicFlow;
|
|
146
|
+
this.initMiniMap();
|
|
114
147
|
}
|
|
115
148
|
MiniMap.prototype.render = function (lf, container) {
|
|
116
149
|
var _this = this;
|
|
117
|
-
this.
|
|
118
|
-
this.
|
|
119
|
-
if (_this.
|
|
120
|
-
_this.
|
|
150
|
+
this.container = container;
|
|
151
|
+
this.lf.on('history:change', function () {
|
|
152
|
+
if (_this.isShow) {
|
|
153
|
+
_this.setView();
|
|
121
154
|
}
|
|
122
155
|
});
|
|
123
|
-
this.
|
|
124
|
-
|
|
125
|
-
|
|
156
|
+
this.lf.on('graph:transform', throttle(function () {
|
|
157
|
+
// 小地图已展示,并且没有拖拽小地图视口
|
|
158
|
+
if (_this.isShow && !_this.dragging) {
|
|
159
|
+
_this.setView();
|
|
126
160
|
}
|
|
127
|
-
});
|
|
161
|
+
}, 300));
|
|
128
162
|
};
|
|
129
163
|
MiniMap.prototype.init = function (option) {
|
|
130
|
-
this.
|
|
164
|
+
this.disabledPlugins = this.disabledPlugins.concat(option.disabledPlugins || []);
|
|
165
|
+
};
|
|
166
|
+
MiniMap.prototype.setOption = function (options) {
|
|
167
|
+
var _a = options.MiniMap, _b = _a.width, width = _b === void 0 ? 150 : _b, _c = _a.height, height = _c === void 0 ? 220 : _c, _d = _a.isShowHeader, isShowHeader = _d === void 0 ? true : _d, _e = _a.isShowCloseIcon, isShowCloseIcon = _e === void 0 ? true : _e, _f = _a.leftPosition, leftPosition = _f === void 0 ? 0 : _f, _g = _a.topPosition, topPosition = _g === void 0 ? 0 : _g, rightPosition = _a.rightPosition, bottomPosition = _a.bottomPosition;
|
|
168
|
+
this.width = width;
|
|
169
|
+
this.height = height;
|
|
170
|
+
this.isShowHeader = isShowHeader;
|
|
171
|
+
this.isShowCloseIcon = isShowCloseIcon;
|
|
172
|
+
this.viewPortWidth = width;
|
|
173
|
+
this.leftPosition = leftPosition;
|
|
174
|
+
this.topPosition = topPosition;
|
|
175
|
+
this.rightPosition = rightPosition;
|
|
176
|
+
this.bottomPosition = bottomPosition;
|
|
131
177
|
};
|
|
132
|
-
MiniMap.prototype.
|
|
178
|
+
MiniMap.prototype.initMiniMap = function () {
|
|
133
179
|
var miniMapWrap = document.createElement('div');
|
|
134
180
|
miniMapWrap.className = 'lf-mini-map-graph';
|
|
135
|
-
miniMapWrap.style.width = this.
|
|
136
|
-
miniMapWrap.style.height = this.
|
|
137
|
-
this.
|
|
138
|
-
width: this.
|
|
139
|
-
height: (this.
|
|
181
|
+
miniMapWrap.style.width = this.width + 4 + "px";
|
|
182
|
+
miniMapWrap.style.height = this.height + "px";
|
|
183
|
+
this.lfMap = new this.LogicFlow({
|
|
184
|
+
width: this.lf.graphModel.width,
|
|
185
|
+
height: (this.lf.graphModel.width * this.height) / this.width,
|
|
140
186
|
container: miniMapWrap,
|
|
141
187
|
isSilentMode: true,
|
|
142
188
|
stopZoomGraph: true,
|
|
@@ -144,48 +190,68 @@ var MiniMap = /** @class */ (function () {
|
|
|
144
190
|
stopMoveGraph: true,
|
|
145
191
|
hideAnchors: true,
|
|
146
192
|
hoverOutline: false,
|
|
147
|
-
disabledPlugins: this.
|
|
193
|
+
disabledPlugins: this.disabledPlugins,
|
|
148
194
|
});
|
|
149
195
|
// minimap中禁用adapter。
|
|
150
|
-
this.
|
|
151
|
-
this.
|
|
152
|
-
this.
|
|
153
|
-
this.
|
|
196
|
+
this.lfMap.adapterIn = function (a) { return a; };
|
|
197
|
+
this.lfMap.adapterOut = function (a) { return a; };
|
|
198
|
+
this.miniMapWrap = miniMapWrap;
|
|
199
|
+
this.createViewPort();
|
|
200
|
+
miniMapWrap.addEventListener('click', this.mapClick);
|
|
154
201
|
};
|
|
155
|
-
MiniMap.prototype.
|
|
202
|
+
MiniMap.prototype.createMiniMap = function (left, top) {
|
|
156
203
|
var miniMapContainer = document.createElement('div');
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
miniMapContainer.style.
|
|
161
|
-
|
|
204
|
+
miniMapContainer.appendChild(this.miniMapWrap);
|
|
205
|
+
if (typeof left !== 'undefined' || typeof top !== 'undefined') {
|
|
206
|
+
miniMapContainer.style.left = (left || 0) + "px";
|
|
207
|
+
miniMapContainer.style.top = (top || 0) + "px";
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
if (typeof this.rightPosition !== 'undefined') {
|
|
211
|
+
miniMapContainer.style.right = this.rightPosition + "px";
|
|
212
|
+
}
|
|
213
|
+
else if (typeof this.leftPosition !== 'undefined') {
|
|
214
|
+
miniMapContainer.style.left = this.leftPosition + "px";
|
|
215
|
+
}
|
|
216
|
+
if (typeof this.bottomPosition !== 'undefined') {
|
|
217
|
+
miniMapContainer.style.bottom = this.bottomPosition + "px";
|
|
218
|
+
}
|
|
219
|
+
else if (typeof this.topPosition !== 'undefined') {
|
|
220
|
+
miniMapContainer.style.top = this.topPosition + "px";
|
|
221
|
+
}
|
|
162
222
|
}
|
|
163
223
|
miniMapContainer.style.position = 'absolute';
|
|
164
224
|
miniMapContainer.className = 'lf-mini-map';
|
|
165
|
-
this.
|
|
166
|
-
|
|
225
|
+
if (!this.isShowCloseIcon) {
|
|
226
|
+
miniMapContainer.classList.add('lf-mini-map-no-close-icon');
|
|
227
|
+
}
|
|
228
|
+
if (!this.isShowHeader) {
|
|
229
|
+
miniMapContainer.classList.add('lf-mini-map-no-header');
|
|
230
|
+
}
|
|
231
|
+
this.container.appendChild(miniMapContainer);
|
|
232
|
+
this.miniMapWrap.appendChild(this.viewport);
|
|
167
233
|
var header = document.createElement('div');
|
|
168
234
|
header.className = 'lf-mini-map-header';
|
|
169
|
-
header.innerText =
|
|
235
|
+
header.innerText = MiniMap.headerTitle;
|
|
170
236
|
miniMapContainer.appendChild(header);
|
|
171
237
|
var close = document.createElement('span');
|
|
172
238
|
close.className = 'lf-mini-map-close';
|
|
173
239
|
close.addEventListener('click', this.hide);
|
|
174
240
|
miniMapContainer.appendChild(close);
|
|
175
|
-
this.
|
|
241
|
+
this.miniMapContainer = miniMapContainer;
|
|
176
242
|
};
|
|
177
|
-
MiniMap.prototype.
|
|
178
|
-
this.
|
|
243
|
+
MiniMap.prototype.removeMiniMap = function () {
|
|
244
|
+
this.container.removeChild(this.miniMapContainer);
|
|
179
245
|
};
|
|
180
246
|
/**
|
|
181
247
|
* 计算所有图形一起,占领的区域范围。
|
|
182
248
|
* @param data
|
|
183
249
|
*/
|
|
184
|
-
MiniMap.prototype.
|
|
250
|
+
MiniMap.prototype.getBounds = function (data) {
|
|
185
251
|
var left = 0;
|
|
186
|
-
var right = this.
|
|
252
|
+
var right = this.miniMapWidth;
|
|
187
253
|
var top = 0;
|
|
188
|
-
var bottom = this.
|
|
254
|
+
var bottom = this.miniMapHeight;
|
|
189
255
|
var nodes = data.nodes;
|
|
190
256
|
if (nodes && nodes.length > 0) {
|
|
191
257
|
// 因为获取的节点不知道真实的宽高,这里需要补充一点数值
|
|
@@ -213,7 +279,7 @@ var MiniMap = /** @class */ (function () {
|
|
|
213
279
|
* 保证渲染的时候,minimap能完全展示。
|
|
214
280
|
* 获取将画布所有元素平移到0,0开始时,所有节点数据
|
|
215
281
|
*/
|
|
216
|
-
MiniMap.prototype.
|
|
282
|
+
MiniMap.prototype.resetData = function (data) {
|
|
217
283
|
var nodes = data.nodes, edges = data.edges;
|
|
218
284
|
var left = 0;
|
|
219
285
|
var top = 0;
|
|
@@ -227,8 +293,8 @@ var MiniMap = /** @class */ (function () {
|
|
|
227
293
|
top = nodeTop < top ? nodeTop : top;
|
|
228
294
|
});
|
|
229
295
|
if (left < 0 || top < 0) {
|
|
230
|
-
this.
|
|
231
|
-
this.
|
|
296
|
+
this.resetDataX = left;
|
|
297
|
+
this.resetDataY = top;
|
|
232
298
|
nodes.forEach(function (node) {
|
|
233
299
|
node.x = node.x - left;
|
|
234
300
|
node.y = node.y - top;
|
|
@@ -266,21 +332,22 @@ var MiniMap = /** @class */ (function () {
|
|
|
266
332
|
* 显示视口范围
|
|
267
333
|
* 1. 基于画布的范围比例,设置视口范围比例。宽度默认为导航宽度。
|
|
268
334
|
*/
|
|
269
|
-
MiniMap.prototype.
|
|
335
|
+
MiniMap.prototype.setView = function () {
|
|
270
336
|
var e_1, _a;
|
|
271
337
|
// 1. 获取到图中所有的节点中的位置,将其偏移到原点开始(避免节点位置为负的时候无法展示问题)。
|
|
272
|
-
var
|
|
338
|
+
var graphData = this.lf.getGraphRawData();
|
|
339
|
+
var data = this.resetData(graphData);
|
|
273
340
|
// 由于随时都会有新节点注册进来,需要同步将注册的
|
|
274
|
-
var viewMap = this.
|
|
275
|
-
var modelMap = this.
|
|
276
|
-
var minimapViewMap = this.
|
|
341
|
+
var viewMap = this.lf.viewMap;
|
|
342
|
+
var modelMap = this.lf.graphModel.modelMap;
|
|
343
|
+
var minimapViewMap = this.lfMap.viewMap;
|
|
277
344
|
try {
|
|
278
345
|
// todo: no-restricted-syntax
|
|
279
346
|
for (var _b = __values(viewMap.keys()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
280
347
|
var key = _c.value;
|
|
281
348
|
if (!minimapViewMap.has(key)) {
|
|
282
|
-
this.
|
|
283
|
-
this.
|
|
349
|
+
this.lfMap.setView(key, viewMap.get(key));
|
|
350
|
+
this.lfMap.graphModel.modelMap.set(key, modelMap.get(key));
|
|
284
351
|
}
|
|
285
352
|
}
|
|
286
353
|
}
|
|
@@ -291,22 +358,22 @@ var MiniMap = /** @class */ (function () {
|
|
|
291
358
|
}
|
|
292
359
|
finally { if (e_1) throw e_1.error; }
|
|
293
360
|
}
|
|
294
|
-
this.
|
|
361
|
+
this.lfMap.render(data);
|
|
295
362
|
// 2. 将偏移后的数据渲染到minimap画布上
|
|
296
363
|
// 3. 计算出所有节点在一起的边界。
|
|
297
|
-
var _d = this.
|
|
364
|
+
var _d = this.getBounds(data), left = _d.left, top = _d.top, right = _d.right, bottom = _d.bottom;
|
|
298
365
|
// 4. 计算所有节点的边界与minimap看板的边界的比例.
|
|
299
|
-
var realWidthScale = this.
|
|
300
|
-
var realHeightScale = this.
|
|
366
|
+
var realWidthScale = this.width / (right - left);
|
|
367
|
+
var realHeightScale = this.height / (bottom - top);
|
|
301
368
|
// 5. 取比例最小的值,将渲染的画布缩小对应比例。
|
|
302
|
-
var innerStyle = this.
|
|
369
|
+
var innerStyle = this.miniMapWrap.firstChild.style;
|
|
303
370
|
var scale = Math.min(realWidthScale, realHeightScale);
|
|
304
371
|
innerStyle.transform = "matrix(" + scale + ", 0, 0, " + scale + ", 0, 0)";
|
|
305
372
|
innerStyle.transformOrigin = 'left top';
|
|
306
373
|
innerStyle.height = bottom - Math.min(top, 0) + "px";
|
|
307
374
|
innerStyle.width = right - Math.min(left, 0) + "px";
|
|
308
|
-
this.
|
|
309
|
-
this.
|
|
375
|
+
this.viewPortScale = scale;
|
|
376
|
+
this.setViewPort(scale, {
|
|
310
377
|
left: left,
|
|
311
378
|
top: top,
|
|
312
379
|
right: right,
|
|
@@ -314,36 +381,54 @@ var MiniMap = /** @class */ (function () {
|
|
|
314
381
|
});
|
|
315
382
|
};
|
|
316
383
|
// 设置视口
|
|
317
|
-
MiniMap.prototype.
|
|
384
|
+
MiniMap.prototype.setViewPort = function (scale, _a) {
|
|
318
385
|
var left = _a.left, right = _a.right, top = _a.top, bottom = _a.bottom;
|
|
319
|
-
var viewStyle = this.
|
|
320
|
-
viewStyle.width = this.
|
|
321
|
-
viewStyle.height = (this.
|
|
322
|
-
|
|
323
|
-
var _b = this.__lf.getTransform(), TRANSLATE_X = _b.TRANSLATE_X, TRANSLATE_Y = _b.TRANSLATE_Y;
|
|
386
|
+
var viewStyle = this.viewport.style;
|
|
387
|
+
viewStyle.width = this.viewPortWidth + "px";
|
|
388
|
+
viewStyle.height = (this.viewPortWidth) / (this.lf.graphModel.width / this.lf.graphModel.height) + "px";
|
|
389
|
+
var _b = this.lf.getTransform(), TRANSLATE_X = _b.TRANSLATE_X, TRANSLATE_Y = _b.TRANSLATE_Y, SCALE_X = _b.SCALE_X, SCALE_Y = _b.SCALE_Y;
|
|
324
390
|
var realWidth = right - left;
|
|
325
|
-
//
|
|
326
|
-
var
|
|
391
|
+
// 视口宽 = 小地图宽 / (所有元素一起占据的真实宽 / 绘布宽)
|
|
392
|
+
var viewPortWidth = (this.width) / (realWidth / this.lf.graphModel.width);
|
|
393
|
+
// 实际视口宽 = 小地图宽 * 占宽度比例
|
|
394
|
+
var realViewPortWidth = this.width * (viewPortWidth / this.width);
|
|
395
|
+
var graphRatio = (this.lf.graphModel.width / this.lf.graphModel.height);
|
|
327
396
|
// 视口实际高 = 视口实际宽 / (绘布宽 / 绘布高)
|
|
328
|
-
var graphRatio = (this.__lf.graphModel.width / this.__lf.graphModel.height);
|
|
329
397
|
var realViewPortHeight = realViewPortWidth / graphRatio;
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
398
|
+
var graphData = this.lf.getGraphRawData();
|
|
399
|
+
var _c = this.getBounds(graphData), graphLeft = _c.left, graphTop = _c.top;
|
|
400
|
+
var viewportLeft = graphLeft;
|
|
401
|
+
var viewportTop = graphTop;
|
|
402
|
+
viewportLeft += TRANSLATE_X / SCALE_X;
|
|
403
|
+
viewportTop += TRANSLATE_Y / SCALE_Y;
|
|
404
|
+
this.viewPortTop = viewportTop > 0 ? 0 : (-viewportTop * scale);
|
|
405
|
+
this.viewPortLeft = viewportLeft > 0 ? 0 : (-viewportLeft * scale);
|
|
406
|
+
this.viewPortWidth = realViewPortWidth;
|
|
407
|
+
this.viewPortHeight = realViewPortHeight;
|
|
408
|
+
viewStyle.top = this.viewPortTop + "px";
|
|
409
|
+
viewStyle.left = this.viewPortLeft + "px";
|
|
410
|
+
viewStyle.width = realViewPortWidth / SCALE_X + "px";
|
|
411
|
+
viewStyle.height = realViewPortHeight / SCALE_Y + "px";
|
|
338
412
|
};
|
|
339
413
|
// 预览视窗
|
|
340
|
-
MiniMap.prototype.
|
|
414
|
+
MiniMap.prototype.createViewPort = function () {
|
|
341
415
|
var div = document.createElement('div');
|
|
342
416
|
div.className = 'lf-minimap-viewport';
|
|
343
|
-
div.addEventListener('mousedown', this.
|
|
344
|
-
this.
|
|
417
|
+
div.addEventListener('mousedown', this.startDrag);
|
|
418
|
+
this.viewport = div;
|
|
345
419
|
};
|
|
346
420
|
MiniMap.pluginName = 'miniMap';
|
|
421
|
+
MiniMap.width = 150;
|
|
422
|
+
MiniMap.height = 220;
|
|
423
|
+
MiniMap.viewPortWidth = 150;
|
|
424
|
+
MiniMap.viewPortHeight = 75;
|
|
425
|
+
MiniMap.isShowHeader = true;
|
|
426
|
+
MiniMap.isShowCloseIcon = true;
|
|
427
|
+
MiniMap.leftPosition = 0;
|
|
428
|
+
MiniMap.topPosition = 0;
|
|
429
|
+
MiniMap.rightPosition = null;
|
|
430
|
+
MiniMap.bottomPosition = null;
|
|
431
|
+
MiniMap.headerTitle = '导航';
|
|
347
432
|
return MiniMap;
|
|
348
433
|
}());
|
|
349
434
|
export default MiniMap;
|
|
@@ -45,7 +45,7 @@ var SelectionSelect = /** @class */ (function () {
|
|
|
45
45
|
var group = _this.lf.graphModel.group;
|
|
46
46
|
elements.forEach(function (element) {
|
|
47
47
|
// 如果节点属于分组,则不不选中节点
|
|
48
|
-
if (
|
|
48
|
+
if (!group || !group.getNodeGroup(element.id)) {
|
|
49
49
|
_this.lf.selectElementById(element.id, true);
|
|
50
50
|
}
|
|
51
51
|
});
|
|
@@ -72,6 +72,11 @@ var SelectionSelect = /** @class */ (function () {
|
|
|
72
72
|
if (!config.stopMoveGraph || _this.__disabled) {
|
|
73
73
|
return;
|
|
74
74
|
}
|
|
75
|
+
// 禁用右键框选,修复可能导致画布出现多个框选框不消失的问题,见https://github.com/didi/LogicFlow/issues/985
|
|
76
|
+
var isRightClick = e.button === 2;
|
|
77
|
+
if (isRightClick) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
75
80
|
var _b = lf.getPointByClient(e.clientX, e.clientY).domOverlayPosition, x = _b.x, y = _b.y;
|
|
76
81
|
_this.startPoint = { x: x, y: y };
|
|
77
82
|
_this.endPoint = { x: x, y: y };
|
|
@@ -123,24 +128,6 @@ var SelectionSelect = /** @class */ (function () {
|
|
|
123
128
|
}
|
|
124
129
|
this.close();
|
|
125
130
|
};
|
|
126
|
-
SelectionSelect.prototype.isSelectElement = function (elementModel) {
|
|
127
|
-
// 如果不可见,则不被选中
|
|
128
|
-
if (!elementModel.visible)
|
|
129
|
-
return false;
|
|
130
|
-
var group = this.lf.extension.group;
|
|
131
|
-
// 节点在group中,则不被选中
|
|
132
|
-
if (group) {
|
|
133
|
-
if (elementModel.BaseType === 'node' && group.getNodeGroup(elementModel.id))
|
|
134
|
-
return false;
|
|
135
|
-
if (elementModel.BaseType === 'edge') {
|
|
136
|
-
if (group.getNodeGroup(elementModel.sourceNodeId)
|
|
137
|
-
|| group.getNodeGroup(elementModel.targetNodeId)) {
|
|
138
|
-
return false;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return true;
|
|
143
|
-
};
|
|
144
131
|
SelectionSelect.prototype.open = function () {
|
|
145
132
|
this.__disabled = false;
|
|
146
133
|
};
|
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
|
@@ -39,6 +39,7 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
39
39
|
return ar;
|
|
40
40
|
};
|
|
41
41
|
import { PolylineEdge, PolylineEdgeModel, h } from '@logicflow/core';
|
|
42
|
+
import searchMiddleIndex from './searchMiddleIndex';
|
|
42
43
|
var CurvedEdge = /** @class */ (function (_super) {
|
|
43
44
|
__extends(CurvedEdge, _super);
|
|
44
45
|
function CurvedEdge() {
|
|
@@ -67,7 +68,20 @@ var CurvedEdge = /** @class */ (function (_super) {
|
|
|
67
68
|
var style = model.getEdgeStyle();
|
|
68
69
|
var animationStyle = model.getEdgeAnimationStyle();
|
|
69
70
|
var points2 = this.pointFilter(points.split(' ').map(function (p) { return p.split(',').map(function (a) { return Number(a); }); }));
|
|
70
|
-
var
|
|
71
|
+
var res = searchMiddleIndex(points2);
|
|
72
|
+
if (res) {
|
|
73
|
+
var _b = __read(res, 2), first = _b[0], last = _b[1];
|
|
74
|
+
var firstPoint = points2[first];
|
|
75
|
+
var lastPoint_1 = points2[last];
|
|
76
|
+
var flag = firstPoint.some(function (num, index) { return num === lastPoint_1[index]; });
|
|
77
|
+
if (!flag) {
|
|
78
|
+
var diff = (lastPoint_1[1] - firstPoint[1]) / 2;
|
|
79
|
+
var firstNextPoint = [lastPoint_1[0], lastPoint_1[1] - diff];
|
|
80
|
+
var lastPrePoint = [firstPoint[0], firstPoint[1] + diff];
|
|
81
|
+
points2.splice(first + 1, 0, lastPrePoint, firstNextPoint);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
var _c = __read(points2[0], 2), startX = _c[0], startY = _c[1];
|
|
71
85
|
var d = "M" + startX + " " + startY;
|
|
72
86
|
// 1) 如果一个点不为开始和结束,则在这个点的前后增加弧度开始和结束点。
|
|
73
87
|
// 2) 判断这个点与前一个点的坐标
|
|
@@ -75,9 +89,9 @@ var CurvedEdge = /** @class */ (function (_super) {
|
|
|
75
89
|
// y为(这个点的y 大于前一个点的y, 则 为 这个点的y - 5;小于前一个点的y, 则为这个点的y+5)
|
|
76
90
|
// 同理,判断这个点与后一个点的x,y是否相同,如果x相同,则y进行加减,如果y相同,则x进行加减
|
|
77
91
|
for (var i = 1; i < points2.length - 1; i++) {
|
|
78
|
-
var
|
|
79
|
-
var
|
|
80
|
-
var
|
|
92
|
+
var _d = __read(points2[i - 1], 2), preX = _d[0], preY = _d[1];
|
|
93
|
+
var _e = __read(points2[i], 2), currentX = _e[0], currentY = _e[1];
|
|
94
|
+
var _f = __read(points2[i + 1], 2), nextX = _f[0], nextY = _f[1];
|
|
81
95
|
if (currentX === preX && currentY !== preY) {
|
|
82
96
|
var y = currentY > preY ? currentY - radius : currentY + radius;
|
|
83
97
|
d = d + " L " + currentX + " " + y;
|
|
@@ -96,7 +110,7 @@ var CurvedEdge = /** @class */ (function (_super) {
|
|
|
96
110
|
d = d + " " + x + " " + currentY;
|
|
97
111
|
}
|
|
98
112
|
}
|
|
99
|
-
var
|
|
113
|
+
var _g = __read(points2[points2.length - 1], 2), endX = _g[0], endY = _g[1];
|
|
100
114
|
d = d + " L " + endX + " " + endY;
|
|
101
115
|
var attrs = __assign(__assign(__assign({ d: d, style: isAnimation ? animationStyle : {} }, style), arrowConfig), { fill: 'none' });
|
|
102
116
|
return h('path', __assign({ d: d }, attrs));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function searchMiddleIndex<T>(arr: Array<T>): [number, number] | false;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export default function searchMiddleIndex(arr) {
|
|
2
|
+
if (arr.length <= 1)
|
|
3
|
+
return false;
|
|
4
|
+
var first = 0;
|
|
5
|
+
var last = arr.length - 1;
|
|
6
|
+
while (first !== last && first + 1 !== last && last - 1 !== first) {
|
|
7
|
+
first++;
|
|
8
|
+
last--;
|
|
9
|
+
}
|
|
10
|
+
if (first === last) {
|
|
11
|
+
return [--first, last];
|
|
12
|
+
}
|
|
13
|
+
return [first, last];
|
|
14
|
+
}
|