@logicflow/extension 1.1.11 → 1.2.0-alpha.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 +8 -8
- package/cjs/NodeResize/Control/Util.js +11 -11
- package/cjs/bpmn-adapter/index.js +124 -76
- package/cjs/bpmn-adapter/json2xml.js +5 -2
- package/cjs/bpmn-adapter/xml2json.js +38 -284
- package/cjs/components/context-menu/index.js +2 -2
- package/cjs/components/menu/index.js +23 -23
- package/cjs/components/mini-map/index.js +2 -2
- package/cjs/components/selection-select/index.js +5 -5
- package/cjs/insert-node-in-polyline/edge.js +4 -4
- package/cjs/insert-node-in-polyline/index.js +1 -1
- package/cjs/materials/group/GroupNode.js +2 -2
- package/cjs/materials/group/index.js +3 -3
- package/cjs/tools/auto-layout/index.js +9 -9
- package/cjs/turbo-adapter/index.js +2 -2
- package/es/NodeResize/Control/Control.d.ts +1 -1
- package/es/NodeResize/Control/Control.js +9 -9
- package/es/NodeResize/Control/Util.d.ts +3 -3
- package/es/NodeResize/Control/Util.js +7 -7
- package/es/bpmn-adapter/index.d.ts +41 -33
- package/es/bpmn-adapter/index.js +124 -76
- package/es/bpmn-adapter/json2xml.js +5 -2
- package/es/bpmn-adapter/xml2json.js +38 -284
- package/es/components/context-menu/index.js +2 -2
- package/es/components/menu/index.js +23 -23
- package/es/components/mini-map/index.js +2 -2
- package/es/components/selection-select/index.d.ts +1 -1
- package/es/components/selection-select/index.js +5 -5
- package/es/insert-node-in-polyline/edge.d.ts +3 -3
- package/es/insert-node-in-polyline/edge.js +3 -3
- package/es/insert-node-in-polyline/index.js +2 -2
- package/es/materials/group/GroupNode.d.ts +1 -1
- package/es/materials/group/GroupNode.js +2 -2
- package/es/materials/group/index.d.ts +1 -1
- package/es/materials/group/index.js +3 -3
- package/es/tools/auto-layout/index.d.ts +2 -2
- package/es/tools/auto-layout/index.js +9 -9
- package/es/turbo-adapter/index.js +2 -2
- 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/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/Control/Control.d.ts +1 -1
- package/types/NodeResize/Control/Util.d.ts +3 -3
- package/types/bpmn-adapter/index.d.ts +41 -33
- package/types/components/selection-select/index.d.ts +1 -1
- package/types/insert-node-in-polyline/edge.d.ts +3 -3
- package/types/materials/group/GroupNode.d.ts +1 -1
- package/types/materials/group/index.d.ts +1 -1
- package/types/tools/auto-layout/index.d.ts +2 -2
|
@@ -40,7 +40,7 @@ var Group = /** @class */ (function () {
|
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
-
this.
|
|
43
|
+
this.appendNodeToGroup = function (_a) {
|
|
44
44
|
var data = _a.data;
|
|
45
45
|
// 如果这个节点之前已经在group中了,则将其从之前的group中移除
|
|
46
46
|
var preGroupId = _this.nodeGroupMap.get(data.id);
|
|
@@ -114,9 +114,9 @@ var Group = /** @class */ (function () {
|
|
|
114
114
|
return true;
|
|
115
115
|
});
|
|
116
116
|
lf.graphModel.group = this;
|
|
117
|
-
lf.on('node:add', this.
|
|
117
|
+
lf.on('node:add', this.appendNodeToGroup);
|
|
118
118
|
lf.on('node:delete', this.deleteGroupChild);
|
|
119
|
-
lf.on('node:drop', this.
|
|
119
|
+
lf.on('node:drop', this.appendNodeToGroup);
|
|
120
120
|
lf.on('node:dnd-drag', this.setActiveGroup);
|
|
121
121
|
lf.on('node:drag', this.setActiveGroup);
|
|
122
122
|
lf.on('graph:rendered', this.graphRendered);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* 自动布局插件
|
|
4
|
-
* 依赖
|
|
4
|
+
* 依赖flow-path插件
|
|
5
5
|
* 未完善
|
|
6
6
|
*/
|
|
7
7
|
var __assign = (this && this.__assign) || function () {
|
|
@@ -141,7 +141,7 @@ var AutoLayout = /** @class */ (function () {
|
|
|
141
141
|
var target = this.newNodeMap.get(targetNodeId);
|
|
142
142
|
var _a = this.getShape(sourceNodeId), width = _a.width, height = _a.height;
|
|
143
143
|
var _b = this.getShape(targetNodeId), targetWidth = _b.width, targetHeight = _b.height;
|
|
144
|
-
var
|
|
144
|
+
var positionType = this.getRelativePosition(source, target);
|
|
145
145
|
var startPoint = {
|
|
146
146
|
x: source.x,
|
|
147
147
|
y: source.y,
|
|
@@ -150,7 +150,7 @@ var AutoLayout = /** @class */ (function () {
|
|
|
150
150
|
x: target.x,
|
|
151
151
|
y: target.y,
|
|
152
152
|
};
|
|
153
|
-
switch (
|
|
153
|
+
switch (positionType) {
|
|
154
154
|
case POSITION_TYPE.LEFT:
|
|
155
155
|
startPoint.x = source.x + width / 2;
|
|
156
156
|
endPoint.x = target.x - targetWidth / 2;
|
|
@@ -176,22 +176,22 @@ var AutoLayout = /** @class */ (function () {
|
|
|
176
176
|
* source一定在target左边。
|
|
177
177
|
* 1. 如果source和target在同一x, y坐标内容。
|
|
178
178
|
* 2. 如果source在target左上方。
|
|
179
|
-
* 3. 如果
|
|
179
|
+
* 3. 如果source在target左下方。
|
|
180
180
|
*/
|
|
181
181
|
AutoLayout.prototype.getRelativePosition = function (source, target) {
|
|
182
182
|
var y = source.y;
|
|
183
183
|
var y1 = target.y;
|
|
184
|
-
var
|
|
184
|
+
var positionType;
|
|
185
185
|
if (y < y1) {
|
|
186
|
-
|
|
186
|
+
positionType = -1;
|
|
187
187
|
}
|
|
188
188
|
else if (y === y1) {
|
|
189
|
-
|
|
189
|
+
positionType = 0;
|
|
190
190
|
}
|
|
191
191
|
else {
|
|
192
|
-
|
|
192
|
+
positionType = 1;
|
|
193
193
|
}
|
|
194
|
-
return
|
|
194
|
+
return positionType;
|
|
195
195
|
};
|
|
196
196
|
/**
|
|
197
197
|
* 获取边节点图形的宽高。
|
|
@@ -54,7 +54,7 @@ function convertNodeToTurboElement(node) {
|
|
|
54
54
|
key: id,
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
-
// 将LogicFlow中的
|
|
57
|
+
// 将LogicFlow中的Edge数据转换为Turbo元素数据
|
|
58
58
|
function convertEdgeToTurboElement(edge) {
|
|
59
59
|
var id = edge.id, type = edge.type, sourceNodeId = edge.sourceNodeId, targetNodeId = edge.targetNodeId, startPoint = edge.startPoint, endPoint = edge.endPoint, pointsList = edge.pointsList, _a = edge.text, text = _a === void 0 ? '' : _a, properties = edge.properties;
|
|
60
60
|
return {
|
|
@@ -91,7 +91,7 @@ function toTurboData(data) {
|
|
|
91
91
|
return turboData;
|
|
92
92
|
}
|
|
93
93
|
exports.toTurboData = toTurboData;
|
|
94
|
-
// 将Turbo元素数据转换为LogicFlow中的
|
|
94
|
+
// 将Turbo元素数据转换为LogicFlow中的Edge数据
|
|
95
95
|
function convertFlowElementToEdge(element) {
|
|
96
96
|
var incoming = element.incoming, outgoing = element.outgoing, properties = element.properties, key = element.key;
|
|
97
97
|
var text = properties.text, startPoint = properties.startPoint, endPoint = properties.endPoint, pointsList = properties.pointsList, logicFlowType = properties.logicFlowType;
|
|
@@ -25,7 +25,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
25
25
|
import { h, Component } from 'preact';
|
|
26
26
|
import { LogicFlowUtil } from '@logicflow/core';
|
|
27
27
|
import Rect from '../BasicShape/Rect';
|
|
28
|
-
import {
|
|
28
|
+
import { getDiamondResizeEdgePoint, getEllipseResizeEdgePoint, getRectResizeEdgePoint, ModelType } from './Util';
|
|
29
29
|
var StepDrag = LogicFlowUtil.StepDrag;
|
|
30
30
|
var Control = /** @class */ (function (_super) {
|
|
31
31
|
__extends(Control, _super);
|
|
@@ -123,12 +123,12 @@ var Control = /** @class */ (function (_super) {
|
|
|
123
123
|
var afterPoint;
|
|
124
124
|
edges.sourceEdges.forEach(function (item) {
|
|
125
125
|
params.point = item.startPoint;
|
|
126
|
-
afterPoint =
|
|
126
|
+
afterPoint = getRectResizeEdgePoint(params);
|
|
127
127
|
item.updateStartPoint(afterPoint);
|
|
128
128
|
});
|
|
129
129
|
edges.targetEdges.forEach(function (item) {
|
|
130
130
|
params.point = item.endPoint;
|
|
131
|
-
afterPoint =
|
|
131
|
+
afterPoint = getRectResizeEdgePoint(params);
|
|
132
132
|
item.updateEndPoint(afterPoint);
|
|
133
133
|
});
|
|
134
134
|
_this.eventEmit({ beforeNode: beforeNode, afterNode: afterNode });
|
|
@@ -187,12 +187,12 @@ var Control = /** @class */ (function (_super) {
|
|
|
187
187
|
var afterPoint;
|
|
188
188
|
edges.sourceEdges.forEach(function (item) {
|
|
189
189
|
params.point = item.startPoint;
|
|
190
|
-
afterPoint =
|
|
190
|
+
afterPoint = getEllipseResizeEdgePoint(params);
|
|
191
191
|
item.updateStartPoint(afterPoint);
|
|
192
192
|
});
|
|
193
193
|
edges.targetEdges.forEach(function (item) {
|
|
194
194
|
params.point = item.endPoint;
|
|
195
|
-
afterPoint =
|
|
195
|
+
afterPoint = getEllipseResizeEdgePoint(params);
|
|
196
196
|
item.updateEndPoint(afterPoint);
|
|
197
197
|
});
|
|
198
198
|
_this.eventEmit({ beforeNode: __assign(__assign({}, beforeNode), { rx: rx, ry: ry }), afterNode: afterNode });
|
|
@@ -251,12 +251,12 @@ var Control = /** @class */ (function (_super) {
|
|
|
251
251
|
var edges = _this.getNodeEdges(id);
|
|
252
252
|
edges.sourceEdges.forEach(function (item) {
|
|
253
253
|
params.point = item.startPoint;
|
|
254
|
-
afterPoint =
|
|
254
|
+
afterPoint = getDiamondResizeEdgePoint(params);
|
|
255
255
|
item.updateStartPoint(afterPoint);
|
|
256
256
|
});
|
|
257
257
|
edges.targetEdges.forEach(function (item) {
|
|
258
258
|
params.point = item.endPoint;
|
|
259
|
-
afterPoint =
|
|
259
|
+
afterPoint = getDiamondResizeEdgePoint(params);
|
|
260
260
|
item.updateEndPoint(afterPoint);
|
|
261
261
|
});
|
|
262
262
|
_this.eventEmit({ beforeNode: beforeNode, afterNode: afterNode });
|
|
@@ -268,7 +268,7 @@ var Control = /** @class */ (function (_super) {
|
|
|
268
268
|
var newNodeSize = __assign({ id: id, modelType: modelType, type: type }, afterNode);
|
|
269
269
|
_this.graphModel.eventCenter.emit('node:resize', { oldNodeSize: oldNodeSize, newNodeSize: newNodeSize });
|
|
270
270
|
};
|
|
271
|
-
_this.
|
|
271
|
+
_this.onDragging = function (_a) {
|
|
272
272
|
var deltaX = _a.deltaX, deltaY = _a.deltaY;
|
|
273
273
|
var modelType = _this.nodeModel.modelType;
|
|
274
274
|
// html和矩形的计算方式是一样的,共用一个方法
|
|
@@ -298,7 +298,7 @@ var Control = /** @class */ (function (_super) {
|
|
|
298
298
|
}
|
|
299
299
|
_this.state = {};
|
|
300
300
|
_this.dragHandler = new StepDrag({
|
|
301
|
-
|
|
301
|
+
onDragging: _this.onDragging,
|
|
302
302
|
step: step,
|
|
303
303
|
});
|
|
304
304
|
return _this;
|
|
@@ -13,7 +13,7 @@ export declare enum ModelType {
|
|
|
13
13
|
BEZIER_EDGE = "bezier-edge",
|
|
14
14
|
GRAPH = "graph"
|
|
15
15
|
}
|
|
16
|
-
export declare function
|
|
16
|
+
export declare function getRectResizeEdgePoint({ point, beforeNode, afterNode }: {
|
|
17
17
|
point: any;
|
|
18
18
|
beforeNode: any;
|
|
19
19
|
afterNode: any;
|
|
@@ -21,12 +21,12 @@ export declare function getRectReizeEdgePoint({ point, beforeNode, afterNode }:
|
|
|
21
21
|
x: any;
|
|
22
22
|
y: any;
|
|
23
23
|
};
|
|
24
|
-
export declare function
|
|
24
|
+
export declare function getEllipseResizeEdgePoint({ point, beforeNode, afterNode }: {
|
|
25
25
|
point: any;
|
|
26
26
|
beforeNode: any;
|
|
27
27
|
afterNode: any;
|
|
28
28
|
}): any;
|
|
29
|
-
export declare function
|
|
29
|
+
export declare function getDiamondResizeEdgePoint({ point, beforeNode, afterNode }: {
|
|
30
30
|
point: any;
|
|
31
31
|
beforeNode: any;
|
|
32
32
|
afterNode: any;
|
|
@@ -25,7 +25,7 @@ function getNodeBox(node) {
|
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
// 计算矩形radius设置后,四个圆角的圆心
|
|
28
|
-
function
|
|
28
|
+
function getRadiusCenter(node) {
|
|
29
29
|
var nodeBox = getNodeBox(node);
|
|
30
30
|
var radius = node.radius;
|
|
31
31
|
var minX = nodeBox.minX, minY = nodeBox.minY, maxX = nodeBox.maxX, maxY = nodeBox.maxY;
|
|
@@ -49,7 +49,7 @@ function getRidusCenter(node) {
|
|
|
49
49
|
];
|
|
50
50
|
}
|
|
51
51
|
// 获取矩形resize之后,与矩形连接边的新端点
|
|
52
|
-
export function
|
|
52
|
+
export function getRectResizeEdgePoint(_a) {
|
|
53
53
|
var point = _a.point, beforeNode = _a.beforeNode, afterNode = _a.afterNode;
|
|
54
54
|
var x = point.x, y = point.y;
|
|
55
55
|
var afterPoint = {
|
|
@@ -104,8 +104,8 @@ export function getRectReizeEdgePoint(_a) {
|
|
|
104
104
|
}
|
|
105
105
|
else {
|
|
106
106
|
// 在圆角部分
|
|
107
|
-
var
|
|
108
|
-
var afterCoc =
|
|
107
|
+
var beforeCoc = getRadiusCenter(beforeNode);
|
|
108
|
+
var afterCoc = getRadiusCenter(afterNode);
|
|
109
109
|
var nodeBox = getNodeBox(beforeNode);
|
|
110
110
|
var minX = nodeBox.minX, minY = nodeBox.minY, maxX = nodeBox.maxX, maxY = nodeBox.maxY;
|
|
111
111
|
var index = -1;
|
|
@@ -127,7 +127,7 @@ export function getRectReizeEdgePoint(_a) {
|
|
|
127
127
|
}
|
|
128
128
|
if (index > -1) {
|
|
129
129
|
// 根据夹角角度计算位置
|
|
130
|
-
var angle = Math.atan2((y -
|
|
130
|
+
var angle = Math.atan2((y - beforeCoc[index].y), (x - beforeCoc[index].x));
|
|
131
131
|
afterPoint.x = afterCoc[index].x + radius * Math.cos(angle);
|
|
132
132
|
afterPoint.y = afterCoc[index].y + radius * Math.sin(angle);
|
|
133
133
|
}
|
|
@@ -135,7 +135,7 @@ export function getRectReizeEdgePoint(_a) {
|
|
|
135
135
|
return afterPoint;
|
|
136
136
|
}
|
|
137
137
|
// 获取椭圆resize之后,与椭圆连接边的新端点
|
|
138
|
-
export function
|
|
138
|
+
export function getEllipseResizeEdgePoint(_a) {
|
|
139
139
|
var point = _a.point, beforeNode = _a.beforeNode, afterNode = _a.afterNode;
|
|
140
140
|
var rx = afterNode.rx, ry = afterNode.ry;
|
|
141
141
|
var afterPoint = point;
|
|
@@ -173,7 +173,7 @@ export function getEllipseReizeEdgePoint(_a) {
|
|
|
173
173
|
return afterPoint;
|
|
174
174
|
}
|
|
175
175
|
// 获取菱形resize之后,与菱形连接边的新端点
|
|
176
|
-
export function
|
|
176
|
+
export function getDiamondResizeEdgePoint(_a) {
|
|
177
177
|
var point = _a.point, beforeNode = _a.beforeNode, afterNode = _a.afterNode;
|
|
178
178
|
var afterPoint = point;
|
|
179
179
|
var x;
|
|
@@ -1,45 +1,53 @@
|
|
|
1
|
-
declare
|
|
2
|
-
pluginName: string;
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
declare class BpmnAdapter {
|
|
2
|
+
static pluginName: string;
|
|
3
|
+
static shapeConfigMap: Map<any, any>;
|
|
4
|
+
processAttributes: {
|
|
5
|
+
['-isExecutable']: string;
|
|
6
|
+
['-id']: string;
|
|
7
|
+
};
|
|
8
|
+
definitionAttributes: {
|
|
9
|
+
['-id']: string;
|
|
10
|
+
['-xmlns:xsi']: string;
|
|
11
|
+
['-xmlns:bpmn']: string;
|
|
12
|
+
['-xmlns:bpmndi']: string;
|
|
13
|
+
['-xmlns:dc']: string;
|
|
14
|
+
['-xmlns:di']: string;
|
|
15
|
+
['-targetNamespace']: string;
|
|
16
|
+
['-exporter']: string;
|
|
17
|
+
['-exporterVersion']: string;
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
};
|
|
20
|
+
constructor({ lf }: {
|
|
21
|
+
lf: any;
|
|
22
|
+
});
|
|
5
23
|
setCustomShape(key: any, val: any): void;
|
|
6
|
-
adapterOut(data: any)
|
|
24
|
+
adapterOut: (data: any) => {
|
|
7
25
|
'bpmn:definitions': {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
'-id': string;
|
|
19
|
-
'-isExecutable': string;
|
|
20
|
-
};
|
|
21
|
-
'bpmndi:BPMNDiagram': {
|
|
22
|
-
'-id': string;
|
|
23
|
-
'bpmndi:BPMNPlane': {
|
|
24
|
-
'-id': string;
|
|
25
|
-
'-bpmnElement': string;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
"-id": string;
|
|
28
|
+
"-xmlns:xsi": string;
|
|
29
|
+
"-xmlns:bpmn": string;
|
|
30
|
+
"-xmlns:bpmndi": string;
|
|
31
|
+
"-xmlns:dc": string;
|
|
32
|
+
"-xmlns:di": string;
|
|
33
|
+
"-targetNamespace": string;
|
|
34
|
+
"-exporter": string;
|
|
35
|
+
"-exporterVersion": string;
|
|
28
36
|
};
|
|
29
37
|
};
|
|
30
|
-
adapterIn(bpmnData: any)
|
|
38
|
+
adapterIn: (bpmnData: any) => {
|
|
31
39
|
nodes: any[];
|
|
32
40
|
edges: any[];
|
|
33
41
|
};
|
|
34
|
-
}
|
|
35
|
-
declare
|
|
36
|
-
pluginName: string;
|
|
37
|
-
|
|
38
|
-
adapterXmlIn(bpmnData: any)
|
|
42
|
+
}
|
|
43
|
+
declare class BpmnXmlAdapter extends BpmnAdapter {
|
|
44
|
+
static pluginName: string;
|
|
45
|
+
constructor(data: any);
|
|
46
|
+
adapterXmlIn: (bpmnData: any) => {
|
|
39
47
|
nodes: any[];
|
|
40
48
|
edges: any[];
|
|
41
49
|
};
|
|
42
|
-
adapterXmlOut(data: any)
|
|
43
|
-
}
|
|
50
|
+
adapterXmlOut: (data: any) => string;
|
|
51
|
+
}
|
|
44
52
|
export { BpmnAdapter, BpmnXmlAdapter, };
|
|
45
53
|
export default BpmnAdapter;
|
package/es/bpmn-adapter/index.js
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
extendStatics(d, b);
|
|
10
|
+
function __() { this.constructor = d; }
|
|
11
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
12
|
+
};
|
|
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
|
+
};
|
|
1
25
|
var __read = (this && this.__read) || function (o, n) {
|
|
2
26
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
27
|
if (!m) return o;
|
|
@@ -29,8 +53,8 @@ var BpmnElements;
|
|
|
29
53
|
})(BpmnElements || (BpmnElements = {}));
|
|
30
54
|
var defaultAttrs = ['-name', '-id', 'bpmn:incoming', 'bpmn:outgoing', '-sourceRef', '-targetRef'];
|
|
31
55
|
/**
|
|
32
|
-
* 将普通json转换为
|
|
33
|
-
*
|
|
56
|
+
* 将普通json转换为xmlJson
|
|
57
|
+
* xmlJson中property会以“-”开头
|
|
34
58
|
* 如果没有“-”表示为子节点
|
|
35
59
|
*/
|
|
36
60
|
function toXmlJson(json) {
|
|
@@ -114,8 +138,6 @@ function convertLf2ProcessData(bpmnProcessData, data) {
|
|
|
114
138
|
var sequenceFlow = data.edges.map(function (edge) {
|
|
115
139
|
var _a, _b;
|
|
116
140
|
var targetNode = nodeMap.get(edge.targetNodeId);
|
|
117
|
-
// @see https://github.com/didi/LogicFlow/issues/325
|
|
118
|
-
// 需要保证incomming在outgoing之前
|
|
119
141
|
if (!targetNode['bpmn:incoming']) {
|
|
120
142
|
targetNode['bpmn:incoming'] = edge.id;
|
|
121
143
|
}
|
|
@@ -128,19 +150,17 @@ function convertLf2ProcessData(bpmnProcessData, data) {
|
|
|
128
150
|
edge.id,
|
|
129
151
|
];
|
|
130
152
|
}
|
|
131
|
-
|
|
132
|
-
if (!sourceNode['bpmn:outgoing']) {
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
];
|
|
143
|
-
}
|
|
153
|
+
// const sourceNode = nodeMap.get(edge.sourceNodeId);
|
|
154
|
+
// if (!sourceNode['bpmn:outgoing']) {
|
|
155
|
+
// sourceNode['bpmn:outgoing'] = edge.id;
|
|
156
|
+
// } else if (Array.isArray(sourceNode['bpmn:outgoing'])) {
|
|
157
|
+
// sourceNode['bpmn:outgoing'].push(edge.id);
|
|
158
|
+
// } else { // 字符串转数组
|
|
159
|
+
// sourceNode['bpmn:outgoing'] = [
|
|
160
|
+
// sourceNode['bpmn:outgoing'],
|
|
161
|
+
// edge.id,
|
|
162
|
+
// ];
|
|
163
|
+
// }
|
|
144
164
|
var edgeConfig = {
|
|
145
165
|
'-id': edge.id,
|
|
146
166
|
'-sourceRef': edge.sourceNodeId,
|
|
@@ -155,6 +175,23 @@ function convertLf2ProcessData(bpmnProcessData, data) {
|
|
|
155
175
|
}
|
|
156
176
|
return edgeConfig;
|
|
157
177
|
});
|
|
178
|
+
// @see https://github.com/didi/LogicFlow/issues/325
|
|
179
|
+
// 需要保证incomming在outgoing之前
|
|
180
|
+
data.edges.forEach(function (edge) {
|
|
181
|
+
var sourceNode = nodeMap.get(edge.sourceNodeId);
|
|
182
|
+
if (!sourceNode['bpmn:outgoing']) {
|
|
183
|
+
sourceNode['bpmn:outgoing'] = edge.id;
|
|
184
|
+
}
|
|
185
|
+
else if (Array.isArray(sourceNode['bpmn:outgoing'])) {
|
|
186
|
+
sourceNode['bpmn:outgoing'].push(edge.id);
|
|
187
|
+
}
|
|
188
|
+
else { // 字符串转数组
|
|
189
|
+
sourceNode['bpmn:outgoing'] = [
|
|
190
|
+
sourceNode['bpmn:outgoing'],
|
|
191
|
+
edge.id,
|
|
192
|
+
];
|
|
193
|
+
}
|
|
194
|
+
});
|
|
158
195
|
bpmnProcessData[BpmnElements.FLOW] = sequenceFlow;
|
|
159
196
|
}
|
|
160
197
|
/**
|
|
@@ -399,53 +436,59 @@ function getEdgeConfig(edgeValue, processValue) {
|
|
|
399
436
|
}
|
|
400
437
|
return edge;
|
|
401
438
|
}
|
|
402
|
-
var BpmnAdapter = {
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
lf
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
'
|
|
439
|
+
var BpmnAdapter = /** @class */ (function () {
|
|
440
|
+
function BpmnAdapter(_a) {
|
|
441
|
+
var _this = this;
|
|
442
|
+
var lf = _a.lf;
|
|
443
|
+
this.adapterOut = function (data) {
|
|
444
|
+
var bpmnProcessData = __assign({}, _this.processAttributes);
|
|
445
|
+
convertLf2ProcessData(bpmnProcessData, data);
|
|
446
|
+
var bpmnDiagramData = {
|
|
447
|
+
'-id': 'BPMNPlane_1',
|
|
448
|
+
'-bpmnElement': bpmnProcessData['-id'],
|
|
449
|
+
};
|
|
450
|
+
convertLf2DiagramData(bpmnDiagramData, data);
|
|
451
|
+
var definitions = _this.definitionAttributes;
|
|
452
|
+
definitions['bpmn:process'] = bpmnProcessData;
|
|
453
|
+
definitions['bpmndi:BPMNDiagram'] = {
|
|
454
|
+
'-id': 'BPMNDiagram_1',
|
|
455
|
+
'bpmndi:BPMNPlane': bpmnDiagramData,
|
|
456
|
+
};
|
|
457
|
+
var bpmnData = {
|
|
458
|
+
'bpmn:definitions': definitions,
|
|
459
|
+
};
|
|
460
|
+
return bpmnData;
|
|
461
|
+
};
|
|
462
|
+
this.adapterIn = function (bpmnData) {
|
|
463
|
+
if (bpmnData) {
|
|
464
|
+
return convertBpmn2LfData(bpmnData);
|
|
465
|
+
}
|
|
416
466
|
};
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
'-
|
|
467
|
+
lf.adapterIn = function (data) { return _this.adapterIn(data); };
|
|
468
|
+
lf.adapterOut = function (data) { return _this.adapterOut(data); };
|
|
469
|
+
this.processAttributes = {
|
|
470
|
+
'-isExecutable': 'true',
|
|
471
|
+
'-id': "Process_" + getBpmnId(),
|
|
421
472
|
};
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
'
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
'-exporter': 'bpmn-js (https://demo.bpmn.io)',
|
|
433
|
-
'-exporterVersion': '7.3.0',
|
|
434
|
-
'bpmn:process': bpmnProcessData,
|
|
435
|
-
'bpmndi:BPMNDiagram': {
|
|
436
|
-
'-id': 'BPMNDiagram_1',
|
|
437
|
-
'bpmndi:BPMNPlane': bpmnDiagramData,
|
|
438
|
-
},
|
|
439
|
-
},
|
|
473
|
+
this.definitionAttributes = {
|
|
474
|
+
'-id': "Definitions_" + getBpmnId(),
|
|
475
|
+
'-xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
|
|
476
|
+
'-xmlns:bpmn': 'http://www.omg.org/spec/BPMN/20100524/MODEL',
|
|
477
|
+
'-xmlns:bpmndi': 'http://www.omg.org/spec/BPMN/20100524/DI',
|
|
478
|
+
'-xmlns:dc': 'http://www.omg.org/spec/DD/20100524/DC',
|
|
479
|
+
'-xmlns:di': 'http://www.omg.org/spec/DD/20100524/DI',
|
|
480
|
+
'-targetNamespace': 'http://logic-flow.org',
|
|
481
|
+
'-exporter': 'logicflow',
|
|
482
|
+
'-exporterVersion': '1.2.0',
|
|
440
483
|
};
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
};
|
|
484
|
+
}
|
|
485
|
+
BpmnAdapter.prototype.setCustomShape = function (key, val) {
|
|
486
|
+
BpmnAdapter.shapeConfigMap.set(key, val);
|
|
487
|
+
};
|
|
488
|
+
BpmnAdapter.pluginName = 'bpmn-adapter';
|
|
489
|
+
BpmnAdapter.shapeConfigMap = new Map();
|
|
490
|
+
return BpmnAdapter;
|
|
491
|
+
}());
|
|
449
492
|
BpmnAdapter.shapeConfigMap.set(BpmnElements.START, {
|
|
450
493
|
width: StartEventConfig.width,
|
|
451
494
|
height: StartEventConfig.height,
|
|
@@ -466,20 +509,25 @@ BpmnAdapter.shapeConfigMap.set(BpmnElements.USER, {
|
|
|
466
509
|
width: UserTaskConfig.width,
|
|
467
510
|
height: UserTaskConfig.height,
|
|
468
511
|
});
|
|
469
|
-
var BpmnXmlAdapter = {
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
512
|
+
var BpmnXmlAdapter = /** @class */ (function (_super) {
|
|
513
|
+
__extends(BpmnXmlAdapter, _super);
|
|
514
|
+
function BpmnXmlAdapter(data) {
|
|
515
|
+
var _this = _super.call(this, data) || this;
|
|
516
|
+
_this.adapterXmlIn = function (bpmnData) {
|
|
517
|
+
var json = lfXml2Json(bpmnData);
|
|
518
|
+
return _this.adapterIn(json);
|
|
519
|
+
};
|
|
520
|
+
_this.adapterXmlOut = function (data) {
|
|
521
|
+
var outData = _this.adapterOut(data);
|
|
522
|
+
return lfJson2Xml(outData);
|
|
523
|
+
};
|
|
524
|
+
var lf = data.lf;
|
|
525
|
+
lf.adapterIn = _this.adapterXmlIn;
|
|
526
|
+
lf.adapterOut = _this.adapterXmlOut;
|
|
527
|
+
return _this;
|
|
528
|
+
}
|
|
529
|
+
BpmnXmlAdapter.pluginName = 'bpmnXmlAdapter';
|
|
530
|
+
return BpmnXmlAdapter;
|
|
531
|
+
}(BpmnAdapter));
|
|
484
532
|
export { BpmnAdapter, BpmnXmlAdapter, };
|
|
485
533
|
export default BpmnAdapter;
|
|
@@ -22,10 +22,13 @@ function toXml(v, name, ind, deep) {
|
|
|
22
22
|
var hasChild = false;
|
|
23
23
|
xml += addIndSpace(ind, deep) + "<" + name;
|
|
24
24
|
for (var m in v) {
|
|
25
|
-
if (m.charAt(0) == "-")
|
|
25
|
+
if (m.charAt(0) == "-") {
|
|
26
|
+
console.log(m, v[m]);
|
|
26
27
|
xml += " " + m.substr(1) + "=\"" + v[m].toString() + "\"";
|
|
27
|
-
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
28
30
|
hasChild = true;
|
|
31
|
+
}
|
|
29
32
|
}
|
|
30
33
|
xml += hasChild ? ">" : " />";
|
|
31
34
|
if (hasChild) {
|