@logicflow/core 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -8
- package/dist/logic-flow.js +128 -87
- package/dist/logic-flow.min.js +1 -1
- package/package.json +2 -2
- package/types/constant/DefaultTheme.d.ts +4 -22
- package/types/model/edge/BaseEdgeModel.d.ts +0 -1
- package/types/model/edge/BezierEdgeModel.d.ts +1 -1
- package/types/model/node/CircleNodeModel.d.ts +0 -1
- package/types/model/node/RectNodeModel.d.ts +0 -3
- package/types/model/node/TextNodeModel.d.ts +1 -1
- package/types/view/edge/AdjustPoint.d.ts +7 -2
- package/types/view/edge/BaseEdge.d.ts +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<a href="
|
|
2
|
+
<a href="https://docs.logic-flow.cn" target="_blank">
|
|
3
3
|
<img
|
|
4
|
-
src="
|
|
4
|
+
src="https://docs.logic-flow.cn/docs/_images/logo.png"
|
|
5
5
|
alt="LogicFlow logo"
|
|
6
6
|
width="250"
|
|
7
7
|
/>
|
|
@@ -104,13 +104,10 @@ lf.render(data);
|
|
|
104
104
|
|
|
105
105
|
## 文档
|
|
106
106
|
|
|
107
|
-
[官方文档](
|
|
107
|
+
[官方文档](https://docs.logic-flow.cn)
|
|
108
108
|
|
|
109
|
-
- [快速上手](
|
|
110
|
-
- [
|
|
111
|
-
- [进阶指南](http://logic-flow.org/guide/advance/theme.html)
|
|
112
|
-
- [拓展](http://logic-flow.org/guide/extension/extension-components.html)
|
|
113
|
-
- [示例](http://logic-flow.org/usage/bpmn.html)
|
|
109
|
+
- [快速上手](https://docs.logic-flow.cn/docs/#/zh/guide/start)
|
|
110
|
+
- [示例](https://docs.logic-flow.cn/examples/#/gallery)
|
|
114
111
|
|
|
115
112
|
## 核心能力
|
|
116
113
|
|
package/dist/logic-flow.js
CHANGED
|
@@ -28396,17 +28396,18 @@ var ToolOverlay_ToolOverlay = src_observer(ToolOverlay_class = /*#__PURE__*/func
|
|
|
28396
28396
|
}
|
|
28397
28397
|
|
|
28398
28398
|
ToolOverlay_createClass(ToolOverlay, [{
|
|
28399
|
+
key: "componentDidMount",
|
|
28400
|
+
value: // 在react严格模式下,useEffect会执行两次,但是在LogicFlow内部,则只会触发一次componentDidMount和componentDidUpdate。
|
|
28401
|
+
// 其中第一次componentDidMount对应的graphModel为被丢弃的graphModel, 所以不应该生效。
|
|
28402
|
+
// 在非react环境下,只会触发一次componentDidMount,不会触发componentDidUpdate。
|
|
28403
|
+
// 所以这里采用componentDidUpdate和componentDidMount都去触发插件的render方法。
|
|
28404
|
+
function componentDidMount() {
|
|
28405
|
+
this.triggerToolRender();
|
|
28406
|
+
}
|
|
28407
|
+
}, {
|
|
28399
28408
|
key: "componentDidUpdate",
|
|
28400
28409
|
value: function componentDidUpdate() {
|
|
28401
|
-
|
|
28402
|
-
tool = _this$props.tool,
|
|
28403
|
-
graphModel = _this$props.graphModel;
|
|
28404
|
-
var ToolOverlayElement = document.querySelector("#ToolOverlay_".concat(graphModel.flowId));
|
|
28405
|
-
var lf = tool.getInstance();
|
|
28406
|
-
lf.components.forEach(function (render) {
|
|
28407
|
-
return render(lf, ToolOverlayElement);
|
|
28408
|
-
});
|
|
28409
|
-
lf.components = []; // 保证extension组件的render只执行一次
|
|
28410
|
+
this.triggerToolRender();
|
|
28410
28411
|
}
|
|
28411
28412
|
/**
|
|
28412
28413
|
* 外部传入的一般是HTMLElement
|
|
@@ -28415,9 +28416,9 @@ var ToolOverlay_ToolOverlay = src_observer(ToolOverlay_class = /*#__PURE__*/func
|
|
|
28415
28416
|
}, {
|
|
28416
28417
|
key: "getTools",
|
|
28417
28418
|
value: function getTools() {
|
|
28418
|
-
var _this$
|
|
28419
|
-
tool = _this$
|
|
28420
|
-
graphModel = _this$
|
|
28419
|
+
var _this$props = this.props,
|
|
28420
|
+
tool = _this$props.tool,
|
|
28421
|
+
graphModel = _this$props.graphModel;
|
|
28421
28422
|
var tools = tool.getTools();
|
|
28422
28423
|
var components = tools.map(function (item) {
|
|
28423
28424
|
return Object(preact_module["g" /* h */])(item, {
|
|
@@ -28428,6 +28429,19 @@ var ToolOverlay_ToolOverlay = src_observer(ToolOverlay_class = /*#__PURE__*/func
|
|
|
28428
28429
|
tool.components = components;
|
|
28429
28430
|
return components;
|
|
28430
28431
|
}
|
|
28432
|
+
}, {
|
|
28433
|
+
key: "triggerToolRender",
|
|
28434
|
+
value: function triggerToolRender() {
|
|
28435
|
+
var _this$props2 = this.props,
|
|
28436
|
+
tool = _this$props2.tool,
|
|
28437
|
+
graphModel = _this$props2.graphModel;
|
|
28438
|
+
var ToolOverlayElement = document.querySelector("#ToolOverlay_".concat(graphModel.flowId));
|
|
28439
|
+
var lf = tool.getInstance();
|
|
28440
|
+
lf.components.forEach(function (render) {
|
|
28441
|
+
return render(lf, ToolOverlayElement);
|
|
28442
|
+
});
|
|
28443
|
+
lf.components = []; // 保证extension组件的render只执行一次
|
|
28444
|
+
}
|
|
28431
28445
|
}, {
|
|
28432
28446
|
key: "render",
|
|
28433
28447
|
value: function render() {
|
|
@@ -35022,7 +35036,7 @@ var AdjustPoint_AdjustPoint = /*#__PURE__*/function (_Component) {
|
|
|
35022
35036
|
y: endY
|
|
35023
35037
|
}, graphModel); // 如果一定的坐标能够找到目标节点,预结算当前节点与目标节点的路径进行展示
|
|
35024
35038
|
|
|
35025
|
-
if (info && info.node && _this.isAllowAdjust(info)) {
|
|
35039
|
+
if (info && info.node && _this.isAllowAdjust(info).pass) {
|
|
35026
35040
|
var params;
|
|
35027
35041
|
var startPoint = edgeModel.startPoint,
|
|
35028
35042
|
endPoint = edgeModel.endPoint,
|
|
@@ -35107,51 +35121,67 @@ var AdjustPoint_AdjustPoint = /*#__PURE__*/function (_Component) {
|
|
|
35107
35121
|
var needRecoveryEdge = false;
|
|
35108
35122
|
var createEdgeInfo;
|
|
35109
35123
|
|
|
35110
|
-
if (info && info.node
|
|
35111
|
-
var
|
|
35112
|
-
|
|
35113
|
-
|
|
35114
|
-
|
|
35115
|
-
|
|
35116
|
-
|
|
35117
|
-
|
|
35118
|
-
|
|
35119
|
-
|
|
35120
|
-
|
|
35121
|
-
|
|
35122
|
-
|
|
35123
|
-
|
|
35124
|
-
|
|
35125
|
-
|
|
35126
|
-
|
|
35127
|
-
|
|
35128
|
-
},
|
|
35129
|
-
|
|
35130
|
-
|
|
35131
|
-
|
|
35132
|
-
|
|
35133
|
-
|
|
35134
|
-
|
|
35135
|
-
|
|
35136
|
-
|
|
35137
|
-
|
|
35138
|
-
|
|
35139
|
-
|
|
35140
|
-
|
|
35141
|
-
startPoint: AdjustPoint_objectSpread({}, edgeModel.startPoint),
|
|
35142
|
-
targetNodeId: info.node.id,
|
|
35143
|
-
targetAnchorId: info.anchor.id,
|
|
35144
|
-
endPoint: {
|
|
35145
|
-
x: info.anchor.x,
|
|
35146
|
-
y: info.anchor.y
|
|
35124
|
+
if (info && info.node) {
|
|
35125
|
+
var _this$isAllowAdjust = _this.isAllowAdjust(info),
|
|
35126
|
+
pass = _this$isAllowAdjust.pass,
|
|
35127
|
+
msg = _this$isAllowAdjust.msg,
|
|
35128
|
+
newTargetNode = _this$isAllowAdjust.newTargetNode;
|
|
35129
|
+
|
|
35130
|
+
if (pass) {
|
|
35131
|
+
var _edgeData$text;
|
|
35132
|
+
|
|
35133
|
+
var edgeData = edgeModel.getData();
|
|
35134
|
+
createEdgeInfo = AdjustPoint_objectSpread(AdjustPoint_objectSpread({}, edgeData), {}, {
|
|
35135
|
+
sourceAnchorId: '',
|
|
35136
|
+
targetAnchorId: '',
|
|
35137
|
+
text: (edgeData === null || edgeData === void 0 ? void 0 : (_edgeData$text = edgeData.text) === null || _edgeData$text === void 0 ? void 0 : _edgeData$text.value) || ''
|
|
35138
|
+
}); // 根据调整点是边的起点或重点,计算创建边需要的参数
|
|
35139
|
+
|
|
35140
|
+
if (type === AdjustType.SOURCE) {
|
|
35141
|
+
var edgeInfo = graphModel.edgeGenerator(graphModel.getNodeModelById(info.node.id).getData(), graphModel.getNodeModelById(edgeModel.targetNodeId).getData(), createEdgeInfo);
|
|
35142
|
+
createEdgeInfo = AdjustPoint_objectSpread(AdjustPoint_objectSpread({}, edgeInfo), {}, {
|
|
35143
|
+
sourceNodeId: info.node.id,
|
|
35144
|
+
sourceAnchorId: info.anchor.id,
|
|
35145
|
+
startPoint: {
|
|
35146
|
+
x: info.anchor.x,
|
|
35147
|
+
y: info.anchor.y
|
|
35148
|
+
},
|
|
35149
|
+
targetNodeId: edgeModel.targetNodeId,
|
|
35150
|
+
endPoint: AdjustPoint_objectSpread({}, edgeModel.endPoint)
|
|
35151
|
+
}); // 找到的是原有的源节点上的原锚点时,还原边
|
|
35152
|
+
|
|
35153
|
+
if (edgeModel.sourceNodeId === info.node.id && edgeModel.sourceAnchorId === info.anchor.id) {
|
|
35154
|
+
needRecoveryEdge = true;
|
|
35147
35155
|
}
|
|
35148
|
-
})
|
|
35156
|
+
} else if (type === AdjustType.TARGET) {
|
|
35157
|
+
var _edgeInfo = graphModel.edgeGenerator(graphModel.getNodeModelById(edgeModel.sourceNodeId).getData(), graphModel.getNodeModelById(info.node.id).getData(), createEdgeInfo);
|
|
35158
|
+
|
|
35159
|
+
createEdgeInfo = AdjustPoint_objectSpread(AdjustPoint_objectSpread({}, _edgeInfo), {}, {
|
|
35160
|
+
sourceNodeId: edgeModel.sourceNodeId,
|
|
35161
|
+
startPoint: AdjustPoint_objectSpread({}, edgeModel.startPoint),
|
|
35162
|
+
targetNodeId: info.node.id,
|
|
35163
|
+
targetAnchorId: info.anchor.id,
|
|
35164
|
+
endPoint: {
|
|
35165
|
+
x: info.anchor.x,
|
|
35166
|
+
y: info.anchor.y
|
|
35167
|
+
}
|
|
35168
|
+
}); // 找到的是原有的目标节点上的原锚点时,还原边
|
|
35149
35169
|
|
|
35150
|
-
|
|
35151
|
-
|
|
35170
|
+
if (edgeModel.targetNodeId === info.node.id && edgeModel.targetAnchorId === info.anchor.id) {
|
|
35171
|
+
needRecoveryEdge = true;
|
|
35172
|
+
}
|
|
35152
35173
|
}
|
|
35174
|
+
} else {
|
|
35175
|
+
// 如果没有通过校验,还原边并抛出CONNECTION_NOT_ALLOWED事件
|
|
35176
|
+
needRecoveryEdge = true;
|
|
35177
|
+
var nodeData = newTargetNode.getData();
|
|
35178
|
+
graphModel.eventCenter.emit(EventType.CONNECTION_NOT_ALLOWED, {
|
|
35179
|
+
data: nodeData,
|
|
35180
|
+
msg: msg
|
|
35181
|
+
});
|
|
35153
35182
|
}
|
|
35154
35183
|
} else {
|
|
35184
|
+
// 如果没有找到目标节点,还原边
|
|
35155
35185
|
needRecoveryEdge = true;
|
|
35156
35186
|
}
|
|
35157
35187
|
|
|
@@ -35169,7 +35199,7 @@ var AdjustPoint_AdjustPoint = /*#__PURE__*/function (_Component) {
|
|
|
35169
35199
|
}
|
|
35170
35200
|
});
|
|
35171
35201
|
} else {
|
|
35172
|
-
//
|
|
35202
|
+
// 如果没有找到目标节点或者没有通过校验,还原边
|
|
35173
35203
|
_this.recoveryEdge();
|
|
35174
35204
|
}
|
|
35175
35205
|
|
|
@@ -35271,7 +35301,11 @@ var AdjustPoint_AdjustPoint = /*#__PURE__*/function (_Component) {
|
|
|
35271
35301
|
this.preTargetNode = info.node; // #500 不允许锚点自己连自己, 在锚点一开始连接的时候, 不触发自己连接自己的校验。
|
|
35272
35302
|
|
|
35273
35303
|
if (newTargetAnchor.id === newSourceAnchor.id) {
|
|
35274
|
-
return
|
|
35304
|
+
return {
|
|
35305
|
+
pass: false,
|
|
35306
|
+
msg: '',
|
|
35307
|
+
newTargetNode: newTargetNode
|
|
35308
|
+
};
|
|
35275
35309
|
}
|
|
35276
35310
|
|
|
35277
35311
|
var targetInfoId = "".concat(newSourceNode.id, "_").concat(newTargetNode.id, "_").concat(newSourceAnchor.id, "_").concat(newTargetAnchor.id); // 查看鼠标是否进入过target,若有检验结果,表示进入过, 就不重复计算了。
|
|
@@ -35284,10 +35318,12 @@ var AdjustPoint_AdjustPoint = /*#__PURE__*/function (_Component) {
|
|
|
35284
35318
|
}
|
|
35285
35319
|
|
|
35286
35320
|
var _this$sourceRuleResul = this.sourceRuleResults.get(targetInfoId),
|
|
35287
|
-
isSourcePass = _this$sourceRuleResul.isAllPass
|
|
35321
|
+
isSourcePass = _this$sourceRuleResul.isAllPass,
|
|
35322
|
+
sourceMsg = _this$sourceRuleResul.msg;
|
|
35288
35323
|
|
|
35289
35324
|
var _this$targetRuleResul = this.targetRuleResults.get(targetInfoId),
|
|
35290
|
-
isTargetPass = _this$targetRuleResul.isAllPass
|
|
35325
|
+
isTargetPass = _this$targetRuleResul.isAllPass,
|
|
35326
|
+
targetMsg = _this$targetRuleResul.msg; // 实时提示出即将连接的节点是否允许连接
|
|
35291
35327
|
|
|
35292
35328
|
|
|
35293
35329
|
var state = isSourcePass && isTargetPass ? ElementState.ALLOW_CONNECT : ElementState.NOT_ALLOW_CONNECT;
|
|
@@ -35298,7 +35334,11 @@ var AdjustPoint_AdjustPoint = /*#__PURE__*/function (_Component) {
|
|
|
35298
35334
|
newTargetNode.setElementState(state);
|
|
35299
35335
|
}
|
|
35300
35336
|
|
|
35301
|
-
return
|
|
35337
|
+
return {
|
|
35338
|
+
pass: isSourcePass && isTargetPass,
|
|
35339
|
+
msg: targetMsg || sourceMsg,
|
|
35340
|
+
newTargetNode: newTargetNode
|
|
35341
|
+
};
|
|
35302
35342
|
}
|
|
35303
35343
|
}, {
|
|
35304
35344
|
key: "render",
|
|
@@ -35306,12 +35346,13 @@ var AdjustPoint_AdjustPoint = /*#__PURE__*/function (_Component) {
|
|
|
35306
35346
|
var _this$props6 = this.props,
|
|
35307
35347
|
x = _this$props6.x,
|
|
35308
35348
|
y = _this$props6.y,
|
|
35309
|
-
getAdjustPointShape = _this$props6.getAdjustPointShape
|
|
35349
|
+
getAdjustPointShape = _this$props6.getAdjustPointShape,
|
|
35350
|
+
edgeModel = _this$props6.edgeModel;
|
|
35310
35351
|
var dragging = this.state.dragging;
|
|
35311
35352
|
return Object(preact_module["g" /* h */])("g", {
|
|
35312
35353
|
pointerEvents: dragging ? 'none' : '',
|
|
35313
35354
|
onMouseDown: this.handleMouseDown
|
|
35314
|
-
}, getAdjustPointShape(x, y,
|
|
35355
|
+
}, !dragging ? getAdjustPointShape(x, y, edgeModel) : '');
|
|
35315
35356
|
}
|
|
35316
35357
|
}]);
|
|
35317
35358
|
|
|
@@ -35393,17 +35434,6 @@ var BaseEdge_BaseEdge = /*#__PURE__*/function (_Component) {
|
|
|
35393
35434
|
|
|
35394
35435
|
BaseEdge_defineProperty(BaseEdge_assertThisInitialized(_this), "textRef", Object(preact_module["f" /* createRef */])());
|
|
35395
35436
|
|
|
35396
|
-
BaseEdge_defineProperty(BaseEdge_assertThisInitialized(_this), "getAdjustPointShape", function (x, y) {
|
|
35397
|
-
var model = _this.props.model;
|
|
35398
|
-
var style = model.getAdjustPointStyle();
|
|
35399
|
-
return Object(preact_module["g" /* h */])(Circle, BaseEdge_extends({
|
|
35400
|
-
className: "lf-edge-adjust-point"
|
|
35401
|
-
}, style, {
|
|
35402
|
-
x: x,
|
|
35403
|
-
y: y
|
|
35404
|
-
}));
|
|
35405
|
-
});
|
|
35406
|
-
|
|
35407
35437
|
BaseEdge_defineProperty(BaseEdge_assertThisInitialized(_this), "handleHover", function (hovered, ev) {
|
|
35408
35438
|
var _this$props = _this.props,
|
|
35409
35439
|
model = _this$props.model,
|
|
@@ -35745,12 +35775,23 @@ var BaseEdge_BaseEdge = /*#__PURE__*/function (_Component) {
|
|
|
35745
35775
|
*/
|
|
35746
35776
|
|
|
35747
35777
|
}, {
|
|
35748
|
-
key: "
|
|
35749
|
-
value:
|
|
35778
|
+
key: "getAdjustPointShape",
|
|
35779
|
+
value: function getAdjustPointShape(x, y, model) {
|
|
35780
|
+
var style = model.getAdjustPointStyle();
|
|
35781
|
+
return Object(preact_module["g" /* h */])(Circle, BaseEdge_extends({
|
|
35782
|
+
className: "lf-edge-adjust-point"
|
|
35783
|
+
}, style, {
|
|
35784
|
+
x: x,
|
|
35785
|
+
y: y
|
|
35786
|
+
}));
|
|
35787
|
+
}
|
|
35750
35788
|
/**
|
|
35751
35789
|
* 不支持重写。请使用getAdjustPointShape
|
|
35752
35790
|
*/
|
|
35753
|
-
|
|
35791
|
+
|
|
35792
|
+
}, {
|
|
35793
|
+
key: "getAdjustPoints",
|
|
35794
|
+
value: function getAdjustPoints() {
|
|
35754
35795
|
var _this$props5 = this.props,
|
|
35755
35796
|
model = _this$props5.model,
|
|
35756
35797
|
graphModel = _this$props5.graphModel;
|
|
@@ -38081,15 +38122,15 @@ function initDefaultShortcut(lf, graph) {
|
|
|
38081
38122
|
var keyboardOptions = keyboard.options.keyboard; // 复制
|
|
38082
38123
|
|
|
38083
38124
|
keyboard.on(['cmd + c', 'ctrl + c'], function () {
|
|
38084
|
-
if (!keyboardOptions.enabled) return;
|
|
38085
|
-
if (graph.textEditElement) return;
|
|
38125
|
+
if (!keyboardOptions.enabled) return true;
|
|
38126
|
+
if (graph.textEditElement) return true;
|
|
38086
38127
|
var guards = lf.options.guards;
|
|
38087
38128
|
var elements = graph.getSelectElements(false);
|
|
38088
38129
|
var enabledClone = guards && guards.beforeClone ? guards.beforeClone(elements) : true;
|
|
38089
38130
|
|
|
38090
|
-
if (!enabledClone) {
|
|
38131
|
+
if (!enabledClone || elements.nodes.length === 0 && elements.edges.length === 0) {
|
|
38091
38132
|
selected = null;
|
|
38092
|
-
return
|
|
38133
|
+
return true;
|
|
38093
38134
|
}
|
|
38094
38135
|
|
|
38095
38136
|
selected = elements;
|
|
@@ -38103,13 +38144,13 @@ function initDefaultShortcut(lf, graph) {
|
|
|
38103
38144
|
}); // 粘贴
|
|
38104
38145
|
|
|
38105
38146
|
keyboard.on(['cmd + v', 'ctrl + v'], function () {
|
|
38106
|
-
if (!keyboardOptions.enabled) return;
|
|
38107
|
-
if (graph.textEditElement) return;
|
|
38147
|
+
if (!keyboardOptions.enabled) return true;
|
|
38148
|
+
if (graph.textEditElement) return true;
|
|
38108
38149
|
|
|
38109
38150
|
if (selected && (selected.nodes || selected.edges)) {
|
|
38110
38151
|
lf.clearSelectElements();
|
|
38111
38152
|
var addElements = lf.addElements(selected);
|
|
38112
|
-
if (!addElements) return;
|
|
38153
|
+
if (!addElements) return true;
|
|
38113
38154
|
addElements.nodes.forEach(function (node) {
|
|
38114
38155
|
return lf.selectElementById(node.id, true);
|
|
38115
38156
|
});
|
|
@@ -38128,22 +38169,22 @@ function initDefaultShortcut(lf, graph) {
|
|
|
38128
38169
|
}); // undo
|
|
38129
38170
|
|
|
38130
38171
|
keyboard.on(['cmd + z', 'ctrl + z'], function () {
|
|
38131
|
-
if (!keyboardOptions.enabled) return;
|
|
38132
|
-
if (graph.textEditElement) return;
|
|
38172
|
+
if (!keyboardOptions.enabled) return true;
|
|
38173
|
+
if (graph.textEditElement) return true;
|
|
38133
38174
|
lf.undo();
|
|
38134
38175
|
return false;
|
|
38135
38176
|
}); // redo
|
|
38136
38177
|
|
|
38137
38178
|
keyboard.on(['cmd + y', 'ctrl + y'], function () {
|
|
38138
|
-
if (!keyboardOptions.enabled) return;
|
|
38139
|
-
if (graph.textEditElement) return;
|
|
38179
|
+
if (!keyboardOptions.enabled) return true;
|
|
38180
|
+
if (graph.textEditElement) return true;
|
|
38140
38181
|
lf.redo();
|
|
38141
38182
|
return false;
|
|
38142
38183
|
}); // delete
|
|
38143
38184
|
|
|
38144
38185
|
keyboard.on(['backspace'], function () {
|
|
38145
|
-
if (!keyboardOptions.enabled) return;
|
|
38146
|
-
if (graph.textEditElement) return;
|
|
38186
|
+
if (!keyboardOptions.enabled) return true;
|
|
38187
|
+
if (graph.textEditElement) return true;
|
|
38147
38188
|
var elements = graph.getSelectElements(true);
|
|
38148
38189
|
lf.clearSelectElements();
|
|
38149
38190
|
elements.edges.forEach(function (edge) {
|