@logicflow/extension 1.2.0-alpha.8 → 1.2.0-next.0
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 +42 -14
- package/cjs/NodeResize/Node/DiamondResize.js +5 -2
- package/cjs/NodeResize/Node/EllipseResize.js +5 -2
- package/cjs/NodeResize/Node/HtmlResize.js +5 -2
- package/cjs/NodeResize/Node/RectResize.js +5 -2
- package/cjs/bpmn-adapter/json2xml.js +0 -1
- package/cjs/components/mini-map/index.js +24 -4
- package/cjs/components/selection-select/index.js +7 -1
- package/cjs/materials/curved-edge/index.js +47 -40
- package/cjs/materials/group/GroupNode.js +47 -13
- package/cjs/materials/group/index.js +73 -21
- package/cjs/tools/snapshot/index.js +1 -1
- package/cjs/turbo-adapter/index.js +4 -6
- package/es/NodeResize/Control/Control.d.ts +4 -0
- package/es/NodeResize/Control/Control.js +42 -14
- package/es/NodeResize/Node/DiamondResize.js +5 -2
- package/es/NodeResize/Node/EllipseResize.js +5 -2
- package/es/NodeResize/Node/HtmlResize.js +5 -2
- package/es/NodeResize/Node/RectResize.js +5 -2
- package/es/bpmn-adapter/json2xml.js +0 -1
- package/es/components/mini-map/index.d.ts +1 -0
- package/es/components/mini-map/index.js +24 -4
- package/es/components/selection-select/index.js +7 -1
- package/es/materials/curved-edge/index.d.ts +7 -6
- package/es/materials/curved-edge/index.js +47 -39
- package/es/materials/group/GroupNode.d.ts +10 -0
- package/es/materials/group/GroupNode.js +47 -13
- package/es/materials/group/index.d.ts +5 -7
- package/es/materials/group/index.js +73 -21
- package/es/tools/snapshot/index.js +1 -1
- package/es/turbo-adapter/index.js +4 -6
- 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 -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/package.json +4 -4
- package/types/NodeResize/Control/Control.d.ts +4 -0
- package/types/components/mini-map/index.d.ts +1 -0
- package/types/materials/curved-edge/index.d.ts +7 -6
- package/types/materials/group/GroupNode.d.ts +10 -0
- package/types/materials/group/index.d.ts +5 -7
|
@@ -51,10 +51,17 @@ var Group = /** @class */ (function () {
|
|
|
51
51
|
preGroup.setAllowAppendChild(false);
|
|
52
52
|
}
|
|
53
53
|
// 然后再判断这个节点是否在某个group中,如果在,则将其添加到对应的group中
|
|
54
|
-
var
|
|
55
|
-
var group = _this.getGroup(bounds);
|
|
54
|
+
var group = _this.getGroup(_this.lf.getNodeModelById(data.id));
|
|
56
55
|
if (!group)
|
|
57
56
|
return;
|
|
57
|
+
var isAllowAppendIn = group.isAllowAppendIn(data);
|
|
58
|
+
if (!isAllowAppendIn) {
|
|
59
|
+
_this.lf.emit('group:not-allowed', {
|
|
60
|
+
group: group.getData(),
|
|
61
|
+
node: data,
|
|
62
|
+
});
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
58
65
|
if (data.id !== group.id) {
|
|
59
66
|
group.addChild(data.id);
|
|
60
67
|
_this.nodeGroupMap.set(data.id, group.id);
|
|
@@ -79,39 +86,49 @@ var Group = /** @class */ (function () {
|
|
|
79
86
|
this.setActiveGroup = function (_a) {
|
|
80
87
|
var data = _a.data;
|
|
81
88
|
var nodeModel = _this.lf.getNodeModelById(data.id);
|
|
82
|
-
|
|
89
|
+
var newGroup = _this.getGroup(nodeModel);
|
|
90
|
+
if (_this.activeGroup) {
|
|
91
|
+
_this.activeGroup.setAllowAppendChild(false);
|
|
92
|
+
}
|
|
93
|
+
if (!newGroup || (nodeModel.isGroup && newGroup.id === data.id))
|
|
94
|
+
return;
|
|
95
|
+
var isAllowAppendIn = newGroup.isAllowAppendIn(data);
|
|
96
|
+
if (!isAllowAppendIn) {
|
|
83
97
|
return;
|
|
84
|
-
var bounds = nodeModel.getBounds();
|
|
85
|
-
var newGroup = _this.getGroup(bounds);
|
|
86
|
-
if (newGroup || newGroup !== _this.activeGroup) {
|
|
87
|
-
if (_this.activeGroup) {
|
|
88
|
-
_this.activeGroup.setAllowAppendChild(false);
|
|
89
|
-
}
|
|
90
|
-
if (newGroup) {
|
|
91
|
-
_this.activeGroup = newGroup;
|
|
92
|
-
_this.activeGroup.setAllowAppendChild(true);
|
|
93
|
-
}
|
|
94
98
|
}
|
|
99
|
+
_this.activeGroup = newGroup;
|
|
100
|
+
_this.activeGroup.setAllowAppendChild(true);
|
|
95
101
|
};
|
|
96
102
|
lf.register(GroupNode_1.default);
|
|
97
103
|
this.lf = lf;
|
|
98
104
|
lf.graphModel.addNodeMoveRules(function (model, deltaX, deltaY) {
|
|
99
105
|
if (model.isGroup) { // 如果移动的是分组,那么分组的子节点也跟着移动。
|
|
100
|
-
|
|
106
|
+
var nodeIds = _this.getNodeAllChild(model);
|
|
107
|
+
lf.graphModel.moveNodes(nodeIds, deltaX, deltaY, true);
|
|
101
108
|
return true;
|
|
102
109
|
}
|
|
103
110
|
var groupModel = lf.getNodeModelById(_this.nodeGroupMap.get(model.id));
|
|
104
|
-
|
|
111
|
+
var allowMove = true;
|
|
112
|
+
if (groupModel && groupModel.isRestrict) {
|
|
113
|
+
// 如果移动的节点存在分组中,且这个分组禁止子节点移出去。
|
|
105
114
|
var _a = model.getBounds(), x1 = _a.x1, y1 = _a.y1, x2 = _a.x2, y2 = _a.y2;
|
|
106
|
-
|
|
115
|
+
allowMove = groupModel.isAllowMoveTo({
|
|
107
116
|
x1: x1 + deltaX,
|
|
108
117
|
y1: y1 + deltaY,
|
|
109
118
|
x2: x2 + deltaX,
|
|
110
119
|
y2: y2 + deltaY,
|
|
111
120
|
});
|
|
112
|
-
return r;
|
|
113
121
|
}
|
|
114
|
-
|
|
122
|
+
if (model.isGroup) {
|
|
123
|
+
// 如果移动的是分组,那么分组的子节点也跟着移动。
|
|
124
|
+
if (allowMove === true) {
|
|
125
|
+
lf.graphModel.moveNodes(__spread(model.getChildren()), deltaX, deltaY, true);
|
|
126
|
+
}
|
|
127
|
+
else if (typeof allowMove !== 'boolean') {
|
|
128
|
+
lf.graphModel.moveNodes(__spread(model.getChildren()), allowMove.x ? deltaX : 0, allowMove.y ? deltaY : 0, true);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return allowMove;
|
|
115
132
|
});
|
|
116
133
|
lf.graphModel.group = this;
|
|
117
134
|
lf.on('node:add', this.appendNodeToGroup);
|
|
@@ -121,17 +138,52 @@ var Group = /** @class */ (function () {
|
|
|
121
138
|
lf.on('node:drag', this.setActiveGroup);
|
|
122
139
|
lf.on('graph:rendered', this.graphRendered);
|
|
123
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* 获取一个节点内部所有的子节点,包裹分组的子节点
|
|
143
|
+
*/
|
|
144
|
+
Group.prototype.getNodeAllChild = function (model) {
|
|
145
|
+
var _this = this;
|
|
146
|
+
var nodeIds = [];
|
|
147
|
+
if (model.children) {
|
|
148
|
+
model.children.forEach(function (nodeId) {
|
|
149
|
+
nodeIds.push(nodeId);
|
|
150
|
+
var nodeModel = _this.lf.getNodeModelById(nodeId);
|
|
151
|
+
if (nodeModel.isGroup) {
|
|
152
|
+
nodeIds = nodeIds.concat(_this.getNodeAllChild(nodeModel));
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
return nodeIds;
|
|
157
|
+
};
|
|
124
158
|
/**
|
|
125
159
|
* 获取自定位置其所属分组
|
|
126
160
|
*/
|
|
127
|
-
Group.prototype.getGroup = function (
|
|
161
|
+
Group.prototype.getGroup = function (nodeModel) {
|
|
162
|
+
if (nodeModel.nestable === false) {
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
var bounds = nodeModel.getBounds();
|
|
128
166
|
var nodes = this.lf.graphModel.nodes;
|
|
167
|
+
var selectedModel = null;
|
|
129
168
|
for (var i = 0; i < nodes.length; i++) {
|
|
130
169
|
var model = nodes[i];
|
|
131
|
-
if (model.isGroup && model.isInRange(bounds)) {
|
|
132
|
-
|
|
170
|
+
if (model !== nodeModel && model.isGroup && model.isInRange(bounds)) {
|
|
171
|
+
if (selectedModel) {
|
|
172
|
+
if (selectedModel.zIndex > model.zIndex) {
|
|
173
|
+
selectedModel = model;
|
|
174
|
+
}
|
|
175
|
+
else if (selectedModel.zIndex === model.zIndex) {
|
|
176
|
+
if (!model.isInRange(selectedModel.getBounds())) {
|
|
177
|
+
selectedModel = model;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
selectedModel = model;
|
|
183
|
+
}
|
|
133
184
|
}
|
|
134
185
|
}
|
|
186
|
+
return selectedModel;
|
|
135
187
|
};
|
|
136
188
|
/**
|
|
137
189
|
* 获取某个节点所属的groupModel
|
|
@@ -164,7 +164,7 @@ var Snapshot = /** @class */ (function () {
|
|
|
164
164
|
真实dom存在缩放影响其宽高数值
|
|
165
165
|
在得到真实宽高后除以缩放比例即可得到正常宽高
|
|
166
166
|
*/
|
|
167
|
-
var base =
|
|
167
|
+
var base = this.lf.graphModel.rootEl.querySelector('.lf-base');
|
|
168
168
|
var bbox = base.getBoundingClientRect();
|
|
169
169
|
var graphModel = this.lf.graphModel;
|
|
170
170
|
var transformModel = graphModel.transformModel;
|
|
@@ -84,7 +84,7 @@ function convertEdgeToTurboElement(edge) {
|
|
|
84
84
|
outgoing: [targetNodeId],
|
|
85
85
|
type: getTurboType(type),
|
|
86
86
|
dockers: [],
|
|
87
|
-
properties: __assign(__assign({}, properties), { name: (text && text.value) || '', text: text, startPoint: JSON.stringify(startPoint), endPoint: JSON.stringify(endPoint), pointsList: JSON.stringify(
|
|
87
|
+
properties: __assign(__assign({}, properties), { name: (text && text.value) || '', text: text, startPoint: JSON.stringify(startPoint), endPoint: JSON.stringify(endPoint), pointsList: JSON.stringify(pointsList) }),
|
|
88
88
|
key: id,
|
|
89
89
|
};
|
|
90
90
|
}
|
|
@@ -123,16 +123,13 @@ function convertFlowElementToEdge(element) {
|
|
|
123
123
|
properties: {},
|
|
124
124
|
};
|
|
125
125
|
if (startPoint) {
|
|
126
|
-
// @ts-ignore
|
|
127
126
|
edge.startPoint = JSON.parse(startPoint);
|
|
128
127
|
}
|
|
129
128
|
if (endPoint) {
|
|
130
|
-
// @ts-ignore
|
|
131
129
|
edge.endPoint = JSON.parse(endPoint);
|
|
132
130
|
}
|
|
133
131
|
if (pointsList) {
|
|
134
|
-
|
|
135
|
-
edge.endPoint = JSON.parse(pointsList);
|
|
132
|
+
edge.pointsList = JSON.parse(pointsList);
|
|
136
133
|
}
|
|
137
134
|
// 这种转换方式,在自定义属性中不能与excludeProperties中的属性重名,否则将在转换过程中丢失
|
|
138
135
|
var excludeProperties = ['startPoint', 'endPoint', 'pointsList', 'text'];
|
|
@@ -147,6 +144,7 @@ function convertFlowElementToEdge(element) {
|
|
|
147
144
|
function convertFlowElementToNode(element) {
|
|
148
145
|
var properties = element.properties, key = element.key, type = element.type, bounds = element.bounds;
|
|
149
146
|
var x = properties.x, y = properties.y;
|
|
147
|
+
var text = properties.text;
|
|
150
148
|
if (x === undefined) {
|
|
151
149
|
var _a = __read(bounds, 2), _b = _a[0], x1 = _b.x, y1 = _b.y, _c = _a[1], x2 = _c.x, y2 = _c.y;
|
|
152
150
|
x = (x1 + x2) / 2;
|
|
@@ -157,7 +155,7 @@ function convertFlowElementToNode(element) {
|
|
|
157
155
|
type: TurboTypeMap[type],
|
|
158
156
|
x: x,
|
|
159
157
|
y: y,
|
|
160
|
-
text:
|
|
158
|
+
text: text,
|
|
161
159
|
properties: {},
|
|
162
160
|
};
|
|
163
161
|
// 这种转换方式,在自定义属性中不能与excludeProperties中的属性重名,否则将在转换过程中丢失
|
|
@@ -22,6 +22,22 @@ var __assign = (this && this.__assign) || function () {
|
|
|
22
22
|
};
|
|
23
23
|
return __assign.apply(this, arguments);
|
|
24
24
|
};
|
|
25
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
26
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
27
|
+
if (!m) return o;
|
|
28
|
+
var i = m.call(o), r, ar = [], e;
|
|
29
|
+
try {
|
|
30
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
31
|
+
}
|
|
32
|
+
catch (error) { e = { error: error }; }
|
|
33
|
+
finally {
|
|
34
|
+
try {
|
|
35
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
36
|
+
}
|
|
37
|
+
finally { if (e) throw e.error; }
|
|
38
|
+
}
|
|
39
|
+
return ar;
|
|
40
|
+
};
|
|
25
41
|
import { h, Component } from 'preact';
|
|
26
42
|
import { LogicFlowUtil } from '@logicflow/core';
|
|
27
43
|
import Rect from '../BasicShape/Rect';
|
|
@@ -55,7 +71,7 @@ var Control = /** @class */ (function (_super) {
|
|
|
55
71
|
resize.height = height - deltaY * pct;
|
|
56
72
|
break;
|
|
57
73
|
case 2:
|
|
58
|
-
resize.width = width + deltaX;
|
|
74
|
+
resize.width = width + deltaX * pct;
|
|
59
75
|
resize.height = height + deltaY * pct;
|
|
60
76
|
break;
|
|
61
77
|
case 3:
|
|
@@ -165,9 +181,9 @@ var Control = /** @class */ (function (_super) {
|
|
|
165
181
|
_this.updatePosition({ deltaX: deltaX, deltaY: deltaY });
|
|
166
182
|
// 更新rx ry,宽高为计算属性自动更新
|
|
167
183
|
// @ts-ignore
|
|
168
|
-
_this.nodeModel.rx =
|
|
184
|
+
_this.nodeModel.rx = size.width;
|
|
169
185
|
// @ts-ignore
|
|
170
|
-
_this.nodeModel.ry =
|
|
186
|
+
_this.nodeModel.ry = size.height;
|
|
171
187
|
_this.nodeModel.setProperties({
|
|
172
188
|
nodeSize: {
|
|
173
189
|
rx: size.width,
|
|
@@ -229,9 +245,9 @@ var Control = /** @class */ (function (_super) {
|
|
|
229
245
|
_this.updatePosition({ deltaX: deltaX, deltaY: deltaY });
|
|
230
246
|
// 更新rx ry,宽高为计算属性自动更新
|
|
231
247
|
// @ts-ignore
|
|
232
|
-
_this.nodeModel.rx =
|
|
248
|
+
_this.nodeModel.rx = size.width;
|
|
233
249
|
// @ts-ignore
|
|
234
|
-
_this.nodeModel.ry =
|
|
250
|
+
_this.nodeModel.ry = size.height;
|
|
235
251
|
_this.nodeModel.setProperties({
|
|
236
252
|
nodeSize: {
|
|
237
253
|
rx: size.width,
|
|
@@ -273,8 +289,11 @@ var Control = /** @class */ (function (_super) {
|
|
|
273
289
|
_this.graphModel.eventCenter.emit('node:resize', { oldNodeSize: oldNodeSize, newNodeSize: newNodeSize });
|
|
274
290
|
};
|
|
275
291
|
_this.onDragging = function (_a) {
|
|
292
|
+
var _b;
|
|
276
293
|
var deltaX = _a.deltaX, deltaY = _a.deltaY;
|
|
294
|
+
var transformModel = _this.graphModel.transformModel;
|
|
277
295
|
var modelType = _this.nodeModel.modelType;
|
|
296
|
+
_b = __read(transformModel.fixDeltaXY(deltaX, deltaY), 2), deltaX = _b[0], deltaY = _b[1];
|
|
278
297
|
// html和矩形的计算方式是一样的,共用一个方法
|
|
279
298
|
if (modelType === ModelType.RECT_NODE || modelType === ModelType.HTML_NODE) {
|
|
280
299
|
_this.updateRect({ deltaX: deltaX, deltaY: deltaY });
|
|
@@ -287,23 +306,32 @@ var Control = /** @class */ (function (_super) {
|
|
|
287
306
|
_this.updateDiamond({ deltaX: deltaX, deltaY: deltaY });
|
|
288
307
|
}
|
|
289
308
|
};
|
|
309
|
+
/**
|
|
310
|
+
* 由于将拖拽放大缩小改成丝滑模式,这个时候需要在拖拽结束的时候,将节点的位置更新到grid上.
|
|
311
|
+
*/
|
|
312
|
+
_this.onDragEnd = function () {
|
|
313
|
+
var _a = _this.graphModel.gridSize, gridSize = _a === void 0 ? 1 : _a;
|
|
314
|
+
var x = gridSize * Math.round(_this.nodeModel.x / gridSize);
|
|
315
|
+
var y = gridSize * Math.round(_this.nodeModel.y / gridSize);
|
|
316
|
+
_this.nodeModel.moveTo(x, y);
|
|
317
|
+
};
|
|
290
318
|
_this.index = props.index;
|
|
291
319
|
_this.nodeModel = props.model;
|
|
292
320
|
_this.graphModel = props.graphModel;
|
|
293
|
-
var gridSize = _this.graphModel.gridSize;
|
|
294
321
|
// 为保证对齐线功能正常使用,step默认是网格grid的两倍,
|
|
295
322
|
// 没有网格设置,默认为2,保证坐标是整数
|
|
296
|
-
|
|
297
|
-
if (gridSize > 1) {
|
|
298
|
-
|
|
299
|
-
}
|
|
300
|
-
if (
|
|
301
|
-
|
|
302
|
-
}
|
|
323
|
+
// let step = 2;
|
|
324
|
+
// if (gridSize > 1) {
|
|
325
|
+
// step = 2 * gridSize;
|
|
326
|
+
// }
|
|
327
|
+
// if (this.nodeModel.gridSize) {
|
|
328
|
+
// step = 2 * this.nodeModel.gridSize;
|
|
329
|
+
// }
|
|
303
330
|
_this.state = {};
|
|
304
331
|
_this.dragHandler = new StepDrag({
|
|
305
332
|
onDragging: _this.onDragging,
|
|
306
|
-
|
|
333
|
+
onDragEnd: _this.onDragEnd,
|
|
334
|
+
step: 1,
|
|
307
335
|
});
|
|
308
336
|
return _this;
|
|
309
337
|
}
|
|
@@ -48,6 +48,9 @@ var DiamondResizeModel = /** @class */ (function (_super) {
|
|
|
48
48
|
};
|
|
49
49
|
DiamondResizeModel.prototype.getOutlineStyle = function () {
|
|
50
50
|
var style = _super.prototype.getOutlineStyle.call(this);
|
|
51
|
+
var isSilentMode = this.graphModel.editConfigModel.isSilentMode;
|
|
52
|
+
if (isSilentMode)
|
|
53
|
+
return style;
|
|
51
54
|
style.stroke = 'none';
|
|
52
55
|
if (style.hover) {
|
|
53
56
|
style.hover.stroke = 'none';
|
|
@@ -89,10 +92,10 @@ var DiamondResizeView = /** @class */ (function (_super) {
|
|
|
89
92
|
h(Polygon, __assign({}, style, { points: points }))));
|
|
90
93
|
};
|
|
91
94
|
DiamondResizeView.prototype.getShape = function () {
|
|
92
|
-
var
|
|
95
|
+
var _a = this.props, isSelected = _a.model.isSelected, isSilentMode = _a.graphModel.editConfigModel.isSilentMode;
|
|
93
96
|
return (h("g", null,
|
|
94
97
|
this.getResizeShape(),
|
|
95
|
-
isSelected ? this.getControlGroup() : ''));
|
|
98
|
+
isSelected && !isSilentMode ? this.getControlGroup() : ''));
|
|
96
99
|
};
|
|
97
100
|
return DiamondResizeView;
|
|
98
101
|
}(DiamondNode));
|
|
@@ -35,6 +35,9 @@ var EllipseResizeModel = /** @class */ (function (_super) {
|
|
|
35
35
|
};
|
|
36
36
|
EllipseResizeModel.prototype.getOutlineStyle = function () {
|
|
37
37
|
var style = _super.prototype.getOutlineStyle.call(this);
|
|
38
|
+
var isSilentMode = this.graphModel.editConfigModel.isSilentMode;
|
|
39
|
+
if (isSilentMode)
|
|
40
|
+
return style;
|
|
38
41
|
style.stroke = 'none';
|
|
39
42
|
if (style.hover) {
|
|
40
43
|
style.hover.stroke = 'none';
|
|
@@ -72,10 +75,10 @@ var EllipseResizeView = /** @class */ (function (_super) {
|
|
|
72
75
|
return _super.prototype.getShape.call(this);
|
|
73
76
|
};
|
|
74
77
|
EllipseResizeView.prototype.getShape = function () {
|
|
75
|
-
var
|
|
78
|
+
var _a = this.props, model = _a.model, isSilentMode = _a.graphModel.editConfigModel.isSilentMode;
|
|
76
79
|
return (h("g", null,
|
|
77
80
|
this.getResizeShape(),
|
|
78
|
-
model.isSelected ? this.getControlGroup() : ''));
|
|
81
|
+
model.isSelected && !isSilentMode ? this.getControlGroup() : ''));
|
|
79
82
|
};
|
|
80
83
|
return EllipseResizeView;
|
|
81
84
|
}(EllipseNode));
|
|
@@ -35,6 +35,9 @@ var HtmlResizeModel = /** @class */ (function (_super) {
|
|
|
35
35
|
};
|
|
36
36
|
HtmlResizeModel.prototype.getOutlineStyle = function () {
|
|
37
37
|
var style = _super.prototype.getOutlineStyle.call(this);
|
|
38
|
+
var isSilentMode = this.graphModel.editConfigModel.isSilentMode;
|
|
39
|
+
if (isSilentMode)
|
|
40
|
+
return style;
|
|
38
41
|
style.stroke = 'none';
|
|
39
42
|
if (style.hover) {
|
|
40
43
|
style.hover.stroke = 'none';
|
|
@@ -72,10 +75,10 @@ var HtmlResizeView = /** @class */ (function (_super) {
|
|
|
72
75
|
return _super.prototype.getShape.call(this);
|
|
73
76
|
};
|
|
74
77
|
HtmlResizeView.prototype.getShape = function () {
|
|
75
|
-
var
|
|
78
|
+
var _a = this.props, isSelected = _a.model.isSelected, isSilentMode = _a.graphModel.editConfigModel.isSilentMode;
|
|
76
79
|
return (h("g", null,
|
|
77
80
|
this.getResizeShape(),
|
|
78
|
-
isSelected ? this.getControlGroup() : ''));
|
|
81
|
+
isSelected && !isSilentMode ? this.getControlGroup() : ''));
|
|
79
82
|
};
|
|
80
83
|
return HtmlResizeView;
|
|
81
84
|
}(HtmlNode));
|
|
@@ -35,6 +35,9 @@ var RectResizeModel = /** @class */ (function (_super) {
|
|
|
35
35
|
};
|
|
36
36
|
RectResizeModel.prototype.getOutlineStyle = function () {
|
|
37
37
|
var style = _super.prototype.getOutlineStyle.call(this);
|
|
38
|
+
var isSilentMode = this.graphModel.editConfigModel.isSilentMode;
|
|
39
|
+
if (isSilentMode)
|
|
40
|
+
return style;
|
|
38
41
|
style.stroke = 'none';
|
|
39
42
|
if (style.hover) {
|
|
40
43
|
style.hover.stroke = 'none';
|
|
@@ -76,10 +79,10 @@ var RectResizeView = /** @class */ (function (_super) {
|
|
|
76
79
|
return _super.prototype.getShape.call(this);
|
|
77
80
|
};
|
|
78
81
|
RectResizeView.prototype.getShape = function () {
|
|
79
|
-
var
|
|
82
|
+
var _a = this.props, isSelected = _a.model.isSelected, isSilentMode = _a.graphModel.editConfigModel.isSilentMode;
|
|
80
83
|
return (h("g", null,
|
|
81
84
|
this.getResizeShape(),
|
|
82
|
-
isSelected ? this.getControlGroup() : ''));
|
|
85
|
+
isSelected && !isSilentMode ? this.getControlGroup() : ''));
|
|
83
86
|
};
|
|
84
87
|
return RectResizeView;
|
|
85
88
|
}(RectNode));
|
|
@@ -61,12 +61,17 @@ var MiniMap = /** @class */ (function () {
|
|
|
61
61
|
y: e.y,
|
|
62
62
|
};
|
|
63
63
|
};
|
|
64
|
-
this.
|
|
64
|
+
this.moveViewport = function (top, left) {
|
|
65
65
|
var viewStyle = _this.__viewport.style;
|
|
66
|
-
_this.__viewPortTop
|
|
67
|
-
_this.__viewPortLeft
|
|
66
|
+
_this.__viewPortTop = top;
|
|
67
|
+
_this.__viewPortLeft = left;
|
|
68
68
|
viewStyle.top = _this.__viewPortTop + "px";
|
|
69
69
|
viewStyle.left = _this.__viewPortLeft + "px";
|
|
70
|
+
};
|
|
71
|
+
this.__drag = function (e) {
|
|
72
|
+
var top = _this.__viewPortTop + e.y - _this.__startPosition.y;
|
|
73
|
+
var left = _this.__viewPortLeft + e.x - _this.__startPosition.x;
|
|
74
|
+
_this.moveViewport(top, left);
|
|
70
75
|
_this.__startPosition = {
|
|
71
76
|
x: e.x,
|
|
72
77
|
y: e.y,
|
|
@@ -85,6 +90,21 @@ var MiniMap = /** @class */ (function () {
|
|
|
85
90
|
this.__drop = function () {
|
|
86
91
|
document.removeEventListener('mousemove', _this.__drag);
|
|
87
92
|
document.removeEventListener('mouseup', _this.__drop);
|
|
93
|
+
var top = _this.__viewPortTop;
|
|
94
|
+
var left = _this.__viewPortLeft;
|
|
95
|
+
if (_this.__viewPortLeft > _this.__width) {
|
|
96
|
+
left = _this.__width - _this.__viewPortWidth;
|
|
97
|
+
}
|
|
98
|
+
if (_this.__viewPortTop > _this.__height) {
|
|
99
|
+
top = _this.__height - _this.__viewPortHeight;
|
|
100
|
+
}
|
|
101
|
+
if (_this.__viewPortLeft < -_this.__width) {
|
|
102
|
+
left = 0;
|
|
103
|
+
}
|
|
104
|
+
if (_this.__viewPortTop < -_this.__height) {
|
|
105
|
+
top = 0;
|
|
106
|
+
}
|
|
107
|
+
_this.moveViewport(top, left);
|
|
88
108
|
};
|
|
89
109
|
this.__lf = lf;
|
|
90
110
|
this.__miniMapWidth = lf.graphModel.width;
|
|
@@ -308,7 +328,7 @@ var MiniMap = /** @class */ (function () {
|
|
|
308
328
|
var graphRatio = (this.__lf.graphModel.width / this.__lf.graphModel.height);
|
|
309
329
|
var realViewPortHeight = realViewPortWidth / graphRatio;
|
|
310
330
|
this.__viewPortTop = TRANSLATE_Y > 0 ? 0 : -TRANSLATE_Y * scale;
|
|
311
|
-
this.__viewPortLeft = -TRANSLATE_X * scale;
|
|
331
|
+
this.__viewPortLeft = TRANSLATE_X > 0 ? 0 : -TRANSLATE_X * scale;
|
|
312
332
|
this.__viewPortWidth = realViewPortWidth;
|
|
313
333
|
this.__viewPortHeight = realViewPortHeight;
|
|
314
334
|
viewStyle.top = this.__viewPortTop + "px";
|
|
@@ -31,6 +31,7 @@ var SelectionSelect = /** @class */ (function () {
|
|
|
31
31
|
this.__drawOff = function () {
|
|
32
32
|
document.removeEventListener('mousemove', _this.__draw);
|
|
33
33
|
document.removeEventListener('mouseup', _this.__drawOff);
|
|
34
|
+
_this.wrapper.oncontextmenu = null;
|
|
34
35
|
_this.__domContainer.removeChild(_this.wrapper);
|
|
35
36
|
var _a = _this.startPoint, x = _a.x, y = _a.y;
|
|
36
37
|
var _b = _this.endPoint, x1 = _b.x, y1 = _b.y;
|
|
@@ -40,8 +41,10 @@ var SelectionSelect = /** @class */ (function () {
|
|
|
40
41
|
}
|
|
41
42
|
var lt = [Math.min(x, x1), Math.min(y, y1)];
|
|
42
43
|
var rt = [Math.max(x, x1), Math.max(y, y1)];
|
|
43
|
-
var elements = _this.lf.graphModel.getAreaElement(lt, rt, _this.isWholeEdge, _this.isWholeNode);
|
|
44
|
+
var elements = _this.lf.graphModel.getAreaElement(lt, rt, _this.isWholeEdge, _this.isWholeNode, true);
|
|
45
|
+
var group = _this.lf.graphModel.group;
|
|
44
46
|
elements.forEach(function (element) {
|
|
47
|
+
// 如果节点属于分组,则不不选中节点
|
|
45
48
|
if (_this.isSelectElement(element)) {
|
|
46
49
|
_this.lf.selectElementById(element.id, true);
|
|
47
50
|
}
|
|
@@ -74,6 +77,9 @@ var SelectionSelect = /** @class */ (function () {
|
|
|
74
77
|
_this.endPoint = { x: x, y: y };
|
|
75
78
|
var wrapper = document.createElement('div');
|
|
76
79
|
wrapper.className = 'lf-selection-select';
|
|
80
|
+
wrapper.oncontextmenu = function prevent(ev) {
|
|
81
|
+
ev.preventDefault();
|
|
82
|
+
};
|
|
77
83
|
wrapper.style.top = _this.startPoint.y + "px";
|
|
78
84
|
wrapper.style.left = _this.startPoint.x + "px";
|
|
79
85
|
domContainer.appendChild(wrapper);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { PolylineEdge, PolylineEdgeModel } from '@logicflow/core';
|
|
2
|
+
declare class CurvedEdge extends PolylineEdge {
|
|
3
|
+
pointFilter(points: any): any;
|
|
4
|
+
getEdge(): import("preact").VNode<any>;
|
|
4
5
|
}
|
|
5
|
-
declare
|
|
6
|
-
|
|
7
|
-
export { CurvedEdge, };
|
|
6
|
+
declare class CurvedEdgeModel extends PolylineEdgeModel {
|
|
7
|
+
}
|
|
8
|
+
export { CurvedEdge, CurvedEdgeModel, };
|
|
@@ -11,6 +11,17 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
11
11
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
12
12
|
};
|
|
13
13
|
})();
|
|
14
|
+
var __assign = (this && this.__assign) || function () {
|
|
15
|
+
__assign = Object.assign || function(t) {
|
|
16
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
17
|
+
s = arguments[i];
|
|
18
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
19
|
+
t[p] = s[p];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
return __assign.apply(this, arguments);
|
|
24
|
+
};
|
|
14
25
|
var __read = (this && this.__read) || function (o, n) {
|
|
15
26
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
16
27
|
if (!m) return o;
|
|
@@ -28,15 +39,34 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
28
39
|
return ar;
|
|
29
40
|
};
|
|
30
41
|
import { PolylineEdge, PolylineEdgeModel, h } from '@logicflow/core';
|
|
31
|
-
var
|
|
32
|
-
__extends(
|
|
33
|
-
function
|
|
42
|
+
var CurvedEdge = /** @class */ (function (_super) {
|
|
43
|
+
__extends(CurvedEdge, _super);
|
|
44
|
+
function CurvedEdge() {
|
|
34
45
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
35
46
|
}
|
|
36
|
-
|
|
37
|
-
var
|
|
38
|
-
var
|
|
39
|
-
|
|
47
|
+
CurvedEdge.prototype.pointFilter = function (points) {
|
|
48
|
+
var allPoints = points;
|
|
49
|
+
var i = 1;
|
|
50
|
+
while (i < allPoints.length - 1) {
|
|
51
|
+
var _a = __read(allPoints[i - 1], 2), x = _a[0], y = _a[1];
|
|
52
|
+
var _b = __read(allPoints[i], 2), x1 = _b[0], y1 = _b[1];
|
|
53
|
+
var _c = __read(allPoints[i + 1], 2), x2 = _c[0], y2 = _c[1];
|
|
54
|
+
if ((x === x1 && x1 === x2)
|
|
55
|
+
|| (y === y1 && y1 === y2)) {
|
|
56
|
+
allPoints.splice(i, 1);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
i++;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return allPoints;
|
|
63
|
+
};
|
|
64
|
+
CurvedEdge.prototype.getEdge = function () {
|
|
65
|
+
var model = this.props.model;
|
|
66
|
+
var points = model.points, isAnimation = model.isAnimation, arrowConfig = model.arrowConfig, _a = model.radius, radius = _a === void 0 ? 5 : _a;
|
|
67
|
+
var style = model.getEdgeStyle();
|
|
68
|
+
var animationStyle = model.getEdgeAnimationStyle();
|
|
69
|
+
var points2 = this.pointFilter(points.split(' ').map(function (p) { return p.split(',').map(function (a) { return Number(a); }); }));
|
|
40
70
|
var _b = __read(points2[0], 2), startX = _b[0], startY = _b[1];
|
|
41
71
|
var d = "M" + startX + " " + startY;
|
|
42
72
|
// 1) 如果一个点不为开始和结束,则在这个点的前后增加弧度开始和结束点。
|
|
@@ -44,42 +74,34 @@ var CurvedEdgeView = /** @class */ (function (_super) {
|
|
|
44
74
|
// 如果x相同则前一个点的x也不变,
|
|
45
75
|
// y为(这个点的y 大于前一个点的y, 则 为 这个点的y - 5;小于前一个点的y, 则为这个点的y+5)
|
|
46
76
|
// 同理,判断这个点与后一个点的x,y是否相同,如果x相同,则y进行加减,如果y相同,则x进行加减
|
|
47
|
-
// todo: 好丑,看看怎么优化下
|
|
48
|
-
var space = 5;
|
|
49
77
|
for (var i = 1; i < points2.length - 1; i++) {
|
|
50
78
|
var _c = __read(points2[i - 1], 2), preX = _c[0], preY = _c[1];
|
|
51
79
|
var _d = __read(points2[i], 2), currentX = _d[0], currentY = _d[1];
|
|
52
80
|
var _e = __read(points2[i + 1], 2), nextX = _e[0], nextY = _e[1];
|
|
53
81
|
if (currentX === preX && currentY !== preY) {
|
|
54
|
-
var y = currentY > preY ? currentY -
|
|
82
|
+
var y = currentY > preY ? currentY - radius : currentY + radius;
|
|
55
83
|
d = d + " L " + currentX + " " + y;
|
|
56
84
|
}
|
|
57
85
|
if (currentY === preY && currentX !== preX) {
|
|
58
|
-
var x = currentX > preX ? currentX -
|
|
86
|
+
var x = currentX > preX ? currentX - radius : currentX + radius;
|
|
59
87
|
d = d + " L " + x + " " + currentY;
|
|
60
88
|
}
|
|
61
89
|
d = d + " Q " + currentX + " " + currentY;
|
|
62
90
|
if (currentX === nextX && currentY !== nextY) {
|
|
63
|
-
var y = currentY > nextY ? currentY -
|
|
91
|
+
var y = currentY > nextY ? currentY - radius : currentY + radius;
|
|
64
92
|
d = d + " " + currentX + " " + y;
|
|
65
93
|
}
|
|
66
94
|
if (currentY === nextY && currentX !== nextX) {
|
|
67
|
-
var x = currentX > nextX ? currentX -
|
|
95
|
+
var x = currentX > nextX ? currentX - radius : currentX + radius;
|
|
68
96
|
d = d + " " + x + " " + currentY;
|
|
69
97
|
}
|
|
70
98
|
}
|
|
71
99
|
var _f = __read(points2[points2.length - 1], 2), endX = _f[0], endY = _f[1];
|
|
72
100
|
d = d + " L " + endX + " " + endY;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
strokeWidth: strokeWidth,
|
|
76
|
-
stroke: stroke,
|
|
77
|
-
fill: 'none',
|
|
78
|
-
strokeDashArray: strokeDashArray,
|
|
79
|
-
});
|
|
101
|
+
var attrs = __assign(__assign(__assign({ d: d, style: isAnimation ? animationStyle : {} }, style), arrowConfig), { fill: 'none' });
|
|
102
|
+
return h('path', __assign({ d: d }, attrs));
|
|
80
103
|
};
|
|
81
|
-
|
|
82
|
-
return CurvedEdgeView;
|
|
104
|
+
return CurvedEdge;
|
|
83
105
|
}(PolylineEdge));
|
|
84
106
|
var CurvedEdgeModel = /** @class */ (function (_super) {
|
|
85
107
|
__extends(CurvedEdgeModel, _super);
|
|
@@ -88,20 +110,6 @@ var CurvedEdgeModel = /** @class */ (function (_super) {
|
|
|
88
110
|
}
|
|
89
111
|
return CurvedEdgeModel;
|
|
90
112
|
}(PolylineEdgeModel));
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
init: function (_a) {
|
|
95
|
-
var curvedSpace = _a.curvedSpace;
|
|
96
|
-
CurvedEdge.curvedSpace = curvedSpace;
|
|
97
|
-
},
|
|
98
|
-
install: function (lf) {
|
|
99
|
-
lf.register({
|
|
100
|
-
type: 'curved-edge',
|
|
101
|
-
view: CurvedEdgeView,
|
|
102
|
-
model: CurvedEdgeModel,
|
|
103
|
-
});
|
|
104
|
-
},
|
|
105
|
-
};
|
|
106
|
-
export default CurvedEdge;
|
|
107
|
-
export { CurvedEdge, };
|
|
113
|
+
export { CurvedEdge,
|
|
114
|
+
// CurvedEdgeView,
|
|
115
|
+
CurvedEdgeModel, };
|