@flowgram-vue/fixed-layout-core 0.2.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/LICENSE +22 -0
- package/dist/index.cjs +2327 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.js +2323 -0
- package/dist/index.js.map +1 -0
- package/package.json +56 -0
- package/src/activities/block-icon.ts +55 -0
- package/src/activities/block-order-icon.ts +64 -0
- package/src/activities/block.ts +192 -0
- package/src/activities/break.ts +14 -0
- package/src/activities/dynamic-split.ts +94 -0
- package/src/activities/empty.ts +35 -0
- package/src/activities/end.ts +26 -0
- package/src/activities/index.ts +24 -0
- package/src/activities/inline-blocks.ts +197 -0
- package/src/activities/input.ts +152 -0
- package/src/activities/loop-extends/constants.ts +25 -0
- package/src/activities/loop-extends/index.ts +10 -0
- package/src/activities/loop-extends/loop-empty-branch.ts +60 -0
- package/src/activities/loop-extends/loop-inline-blocks.ts +140 -0
- package/src/activities/loop-extends/loop-left-empty-block.ts +43 -0
- package/src/activities/loop-extends/loop-right-empty-block.ts +18 -0
- package/src/activities/loop.ts +198 -0
- package/src/activities/multi-inputs.ts +98 -0
- package/src/activities/multi-outputs.ts +65 -0
- package/src/activities/output.ts +18 -0
- package/src/activities/root.ts +23 -0
- package/src/activities/simple-split.ts +47 -0
- package/src/activities/slot/constants.ts +56 -0
- package/src/activities/slot/extends/index.ts +8 -0
- package/src/activities/slot/extends/slot-block.ts +229 -0
- package/src/activities/slot/extends/slot-icon.ts +32 -0
- package/src/activities/slot/extends/slot-inline-blocks.ts +102 -0
- package/src/activities/slot/index.ts +8 -0
- package/src/activities/slot/slot.ts +108 -0
- package/src/activities/slot/typings.ts +13 -0
- package/src/activities/slot/utils/create.ts +105 -0
- package/src/activities/slot/utils/layout.ts +49 -0
- package/src/activities/slot/utils/node.ts +38 -0
- package/src/activities/slot/utils/transition.ts +222 -0
- package/src/activities/start.ts +21 -0
- package/src/activities/static-split.ts +29 -0
- package/src/activities/try-catch-extends/catch-block.ts +78 -0
- package/src/activities/try-catch-extends/catch-inline-blocks.ts +122 -0
- package/src/activities/try-catch-extends/constants.ts +27 -0
- package/src/activities/try-catch-extends/index.ts +11 -0
- package/src/activities/try-catch-extends/main-inline-blocks.ts +147 -0
- package/src/activities/try-catch-extends/try-block.ts +26 -0
- package/src/activities/try-catch-extends/try-slot.ts +48 -0
- package/src/activities/try-catch.ts +176 -0
- package/src/fixed-layout-container-module.ts +20 -0
- package/src/flow-registers.ts +117 -0
- package/src/index.ts +45 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,2323 @@
|
|
|
1
|
+
import { injectable, ContainerModule } from 'inversify';
|
|
2
|
+
import { FlowRendererKey, FlowRendererContribution, FlowTextKey, FlowNodesTransformLayer, FlowNodesContentLayer, FlowLinesLayer, FlowLabelsLayer } from '@flowgram-vue/renderer';
|
|
3
|
+
import { FlowNodeBaseType, FlowNodeSplitType, DEFAULT_SPACING, ConstantKeys, getDefaultSpacing, FlowTransitionLabelEnum, FlowNodeRenderData, FlowDocumentContribution, FlowNodeTransformData, FlowLayoutDefault, FlowTransitionLineEnum, LABEL_SIDE_TYPE, FlowNodeTransitionData, DefaultSpacingKey } from '@flowgram-vue/document';
|
|
4
|
+
import { PlaygroundContribution, PlaygroundLayer } from '@flowgram-vue/core';
|
|
5
|
+
import { Point, bindContributions } from '@flowgram-vue/utils';
|
|
6
|
+
import { mean } from 'lodash-es';
|
|
7
|
+
|
|
8
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
10
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
11
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
12
|
+
if (decorator = decorators[i])
|
|
13
|
+
result = (decorator(result)) || result;
|
|
14
|
+
return result;
|
|
15
|
+
};
|
|
16
|
+
var EndRegistry = {
|
|
17
|
+
type: FlowNodeBaseType.END,
|
|
18
|
+
meta: {
|
|
19
|
+
draggable: false,
|
|
20
|
+
isNodeEnd: true,
|
|
21
|
+
selectable: false,
|
|
22
|
+
copyDisable: true
|
|
23
|
+
},
|
|
24
|
+
// 结束节点没有出边和 label
|
|
25
|
+
getLines() {
|
|
26
|
+
return [];
|
|
27
|
+
},
|
|
28
|
+
getLabels() {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
var DynamicSplitRegistry = {
|
|
33
|
+
type: FlowNodeSplitType.DYNAMIC_SPLIT,
|
|
34
|
+
meta: {
|
|
35
|
+
hidden: true,
|
|
36
|
+
inlineSpacingAfter: (node) => node.collapsed && node.entity.collapsedChildren.length > 1 ? 21 : 0,
|
|
37
|
+
// 判断是否有分支节点
|
|
38
|
+
spacing: (node) => {
|
|
39
|
+
const spacing = getDefaultSpacing(node.entity, ConstantKeys.NODE_SPACING);
|
|
40
|
+
return node.children.length === 1 ? spacing : spacing / 2;
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
getLabels(transition) {
|
|
44
|
+
if (transition.isNodeEnd) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
return [
|
|
48
|
+
{
|
|
49
|
+
type: FlowTransitionLabelEnum.ADDER_LABEL,
|
|
50
|
+
offset: transition.transform.outputPoint
|
|
51
|
+
}
|
|
52
|
+
];
|
|
53
|
+
},
|
|
54
|
+
onCreate(node, json) {
|
|
55
|
+
return node.document.addInlineBlocks(node, json.blocks || []);
|
|
56
|
+
},
|
|
57
|
+
getInputPoint(transform) {
|
|
58
|
+
return transform.firstChild?.inputPoint || transform.defaultInputPoint;
|
|
59
|
+
},
|
|
60
|
+
getOutputPoint(transform, layout) {
|
|
61
|
+
const isVertical = FlowLayoutDefault.isVertical(layout);
|
|
62
|
+
const noInlineBlocks = transform.children.length === 1;
|
|
63
|
+
const lastChildOutput = transform.lastChild?.outputPoint;
|
|
64
|
+
const spacing = getDefaultSpacing(transform.entity, ConstantKeys.NODE_SPACING);
|
|
65
|
+
if (isVertical) {
|
|
66
|
+
return {
|
|
67
|
+
x: lastChildOutput ? lastChildOutput.x : transform.bounds.center.x,
|
|
68
|
+
y: transform.bounds.bottom + (noInlineBlocks ? spacing / 2 : 0)
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
x: transform.bounds.right + (noInlineBlocks ? spacing / 2 : 0),
|
|
73
|
+
y: lastChildOutput ? lastChildOutput.y : transform.bounds.center.y
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
/**
|
|
77
|
+
* @depreacted
|
|
78
|
+
*/
|
|
79
|
+
addChild(node, json, options = {}) {
|
|
80
|
+
const { index } = options;
|
|
81
|
+
const document = node.document;
|
|
82
|
+
const parentId = `$inlineBlocks$${node.id}`;
|
|
83
|
+
let parent = document.getNode(parentId);
|
|
84
|
+
if (!parent) {
|
|
85
|
+
parent = document.addNode({
|
|
86
|
+
id: parentId,
|
|
87
|
+
type: "inlineBlocks",
|
|
88
|
+
originParent: node,
|
|
89
|
+
parent: node
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return document.addBlock(node, json, void 0, void 0, index);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
var StaticSplitRegistry = {
|
|
96
|
+
extend: FlowNodeSplitType.DYNAMIC_SPLIT,
|
|
97
|
+
type: FlowNodeSplitType.STATIC_SPLIT,
|
|
98
|
+
extendChildRegistries: [
|
|
99
|
+
{
|
|
100
|
+
type: FlowNodeBaseType.INLINE_BLOCKS,
|
|
101
|
+
getLabels() {
|
|
102
|
+
return [];
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
};
|
|
107
|
+
var BlockRegistry = {
|
|
108
|
+
type: FlowNodeBaseType.BLOCK,
|
|
109
|
+
meta: {
|
|
110
|
+
spacing: DEFAULT_SPACING.NULL,
|
|
111
|
+
inlineSpacingAfter: DEFAULT_SPACING.INLINE_BLOCK_PADDING_BOTTOM,
|
|
112
|
+
hidden: true
|
|
113
|
+
},
|
|
114
|
+
getLines(transition) {
|
|
115
|
+
const currentTransform = transition.transform;
|
|
116
|
+
const { isVertical } = transition.entity;
|
|
117
|
+
const lines = [
|
|
118
|
+
{
|
|
119
|
+
type: FlowTransitionLineEnum.DIVERGE_LINE,
|
|
120
|
+
from: currentTransform.parent.inputPoint,
|
|
121
|
+
to: currentTransform.inputPoint,
|
|
122
|
+
side: LABEL_SIDE_TYPE.NORMAL_BRANCH
|
|
123
|
+
}
|
|
124
|
+
];
|
|
125
|
+
const hasBranchDraggingAdder = currentTransform && currentTransform.entity.isInlineBlock && transition.renderData.draggable;
|
|
126
|
+
if (hasBranchDraggingAdder) {
|
|
127
|
+
if (isVertical) {
|
|
128
|
+
const currentOffsetRightX = currentTransform.firstChild ? currentTransform.firstChild.bounds.right : currentTransform.bounds.right;
|
|
129
|
+
const nextOffsetLeftX = (currentTransform.next?.firstChild ? currentTransform.next?.firstChild.bounds?.left : currentTransform.next?.bounds?.left) || 0;
|
|
130
|
+
const currentInputPointY = currentTransform.inputPoint.y;
|
|
131
|
+
if (currentTransform?.next) {
|
|
132
|
+
lines.push({
|
|
133
|
+
type: FlowTransitionLineEnum.DRAGGING_LINE,
|
|
134
|
+
from: currentTransform.parent.inputPoint,
|
|
135
|
+
to: {
|
|
136
|
+
x: (currentOffsetRightX + nextOffsetLeftX) / 2,
|
|
137
|
+
y: currentInputPointY
|
|
138
|
+
},
|
|
139
|
+
side: LABEL_SIDE_TYPE.NORMAL_BRANCH
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
} else {
|
|
143
|
+
const currentOffsetBottomX = currentTransform.firstChild ? currentTransform.firstChild.bounds.bottom : currentTransform.bounds.bottom;
|
|
144
|
+
const nextOffsetTopX = (currentTransform.next?.firstChild ? currentTransform.next?.firstChild.bounds?.top : currentTransform.next?.bounds?.top) || 0;
|
|
145
|
+
const currentInputPointX = currentTransform.inputPoint.x;
|
|
146
|
+
if (currentTransform?.next) {
|
|
147
|
+
lines.push({
|
|
148
|
+
type: FlowTransitionLineEnum.DRAGGING_LINE,
|
|
149
|
+
from: currentTransform.parent.inputPoint,
|
|
150
|
+
to: {
|
|
151
|
+
x: currentInputPointX,
|
|
152
|
+
y: (currentOffsetBottomX + nextOffsetTopX) / 2
|
|
153
|
+
},
|
|
154
|
+
side: LABEL_SIDE_TYPE.NORMAL_BRANCH
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (!transition.isNodeEnd) {
|
|
160
|
+
lines.push({
|
|
161
|
+
type: FlowTransitionLineEnum.MERGE_LINE,
|
|
162
|
+
from: currentTransform.outputPoint,
|
|
163
|
+
to: currentTransform.parent.outputPoint,
|
|
164
|
+
side: LABEL_SIDE_TYPE.NORMAL_BRANCH
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
return lines;
|
|
168
|
+
},
|
|
169
|
+
getInputPoint(trans) {
|
|
170
|
+
const child = trans.firstChild;
|
|
171
|
+
return child ? child.inputPoint : trans.defaultInputPoint;
|
|
172
|
+
},
|
|
173
|
+
getOutputPoint(trans, layout) {
|
|
174
|
+
const isVertical = FlowLayoutDefault.isVertical(layout);
|
|
175
|
+
const child = trans.lastChild;
|
|
176
|
+
if (isVertical) {
|
|
177
|
+
return {
|
|
178
|
+
x: child ? child.outputPoint.x : trans.bounds.bottomCenter.x,
|
|
179
|
+
y: trans.bounds.bottom
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
x: trans.bounds.right,
|
|
184
|
+
y: child ? child.outputPoint.y : trans.bounds.rightCenter.y
|
|
185
|
+
};
|
|
186
|
+
},
|
|
187
|
+
getLabels(transition) {
|
|
188
|
+
const currentTransform = transition.transform;
|
|
189
|
+
const { isVertical } = transition.entity;
|
|
190
|
+
const draggingLabel = [];
|
|
191
|
+
const hasBranchDraggingAdder = currentTransform && currentTransform.entity.isInlineBlock && transition.renderData.draggable;
|
|
192
|
+
if (hasBranchDraggingAdder) {
|
|
193
|
+
if (isVertical) {
|
|
194
|
+
const currentOffsetRightX = currentTransform.firstChild ? currentTransform.firstChild.bounds.right : currentTransform.bounds.right;
|
|
195
|
+
const nextOffsetLeftX = (currentTransform.next?.firstChild ? currentTransform.next.firstChild.bounds?.left : currentTransform.next?.bounds?.left) || 0;
|
|
196
|
+
const currentInputPointY = currentTransform.inputPoint.y;
|
|
197
|
+
if (currentTransform?.next) {
|
|
198
|
+
draggingLabel.push({
|
|
199
|
+
offset: {
|
|
200
|
+
x: (currentOffsetRightX + nextOffsetLeftX) / 2,
|
|
201
|
+
y: currentInputPointY
|
|
202
|
+
},
|
|
203
|
+
type: FlowTransitionLabelEnum.BRANCH_DRAGGING_LABEL,
|
|
204
|
+
width: nextOffsetLeftX - currentOffsetRightX,
|
|
205
|
+
props: {
|
|
206
|
+
side: LABEL_SIDE_TYPE.NORMAL_BRANCH
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
} else {
|
|
211
|
+
const currentOffsetBottomX = currentTransform.firstChild ? currentTransform.firstChild.bounds.bottom : currentTransform.bounds.bottom;
|
|
212
|
+
const nextOffsetTopX = (currentTransform.next?.firstChild ? currentTransform.next.firstChild.bounds?.top : currentTransform.next?.bounds?.top) || 0;
|
|
213
|
+
const currentInputPointX = currentTransform.inputPoint.x;
|
|
214
|
+
if (currentTransform?.next) {
|
|
215
|
+
draggingLabel.push({
|
|
216
|
+
offset: {
|
|
217
|
+
x: currentInputPointX,
|
|
218
|
+
y: (currentOffsetBottomX + nextOffsetTopX) / 2
|
|
219
|
+
},
|
|
220
|
+
type: FlowTransitionLabelEnum.BRANCH_DRAGGING_LABEL,
|
|
221
|
+
width: nextOffsetTopX - currentOffsetBottomX,
|
|
222
|
+
props: {
|
|
223
|
+
side: LABEL_SIDE_TYPE.NORMAL_BRANCH
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return [...draggingLabel];
|
|
230
|
+
},
|
|
231
|
+
/**
|
|
232
|
+
* @depreacted
|
|
233
|
+
*/
|
|
234
|
+
addChild(node, json, options = {}) {
|
|
235
|
+
const { index } = options;
|
|
236
|
+
const document = node.document;
|
|
237
|
+
return document.addNode({
|
|
238
|
+
...json,
|
|
239
|
+
...options,
|
|
240
|
+
parent: node,
|
|
241
|
+
index: typeof index === "number" ? index + 1 : void 0
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
var InlineBlocksRegistry = {
|
|
246
|
+
type: FlowNodeBaseType.INLINE_BLOCKS,
|
|
247
|
+
meta: {
|
|
248
|
+
hidden: true,
|
|
249
|
+
spacing: (node) => getDefaultSpacing(node.entity, ConstantKeys.NODE_SPACING),
|
|
250
|
+
isInlineBlocks: true,
|
|
251
|
+
inlineSpacingPre: (transform) => {
|
|
252
|
+
if (transform.entity.blocks.length === 0) {
|
|
253
|
+
return 0;
|
|
254
|
+
}
|
|
255
|
+
return getDefaultSpacing(transform.entity, ConstantKeys.INLINE_BLOCKS_PADDING_TOP) || DEFAULT_SPACING.INLINE_BLOCKS_PADDING_TOP;
|
|
256
|
+
},
|
|
257
|
+
inlineSpacingAfter: (transform) => {
|
|
258
|
+
if (transform.entity.blocks.length === 0) {
|
|
259
|
+
return 0;
|
|
260
|
+
}
|
|
261
|
+
return getDefaultSpacing(transform.entity, ConstantKeys.INLINE_BLOCKS_PADDING_BOTTOM);
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
/**
|
|
265
|
+
* 控制子分支的间距
|
|
266
|
+
* @param child
|
|
267
|
+
*/
|
|
268
|
+
getChildDelta(child, layout) {
|
|
269
|
+
const isVertical = FlowLayoutDefault.isVertical(layout);
|
|
270
|
+
const preTransform = child.entity.pre?.getData(FlowNodeTransformData);
|
|
271
|
+
if (preTransform) {
|
|
272
|
+
const { localBounds: preBounds } = preTransform;
|
|
273
|
+
if (isVertical) {
|
|
274
|
+
const leftSpacing = preTransform.size.width + preTransform.originDeltaX;
|
|
275
|
+
const delta = Math.max(
|
|
276
|
+
child.parent.minInlineBlockSpacing - leftSpacing,
|
|
277
|
+
getDefaultSpacing(child.entity, ConstantKeys.BRANCH_SPACING) - child.originDeltaX
|
|
278
|
+
);
|
|
279
|
+
return {
|
|
280
|
+
// 这里需要加上原点的偏移量,并加上水平间距
|
|
281
|
+
x: preBounds.right + delta,
|
|
282
|
+
y: 0
|
|
283
|
+
};
|
|
284
|
+
} else {
|
|
285
|
+
const bottomSpacing = preTransform.size.height + preTransform.originDeltaY;
|
|
286
|
+
const delta = Math.max(
|
|
287
|
+
child.parent.minInlineBlockSpacing - bottomSpacing,
|
|
288
|
+
getDefaultSpacing(child.entity, ConstantKeys.BRANCH_SPACING) - child.originDeltaY
|
|
289
|
+
);
|
|
290
|
+
return {
|
|
291
|
+
x: 0,
|
|
292
|
+
// 这里需要加上原点的偏移量,并加上垂直间距
|
|
293
|
+
y: preBounds.bottom + delta
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return {
|
|
298
|
+
x: 0,
|
|
299
|
+
y: 0
|
|
300
|
+
};
|
|
301
|
+
},
|
|
302
|
+
/**
|
|
303
|
+
* 控制条件分支居中布局
|
|
304
|
+
* @param trans
|
|
305
|
+
*/
|
|
306
|
+
getDelta(trans, layout) {
|
|
307
|
+
const isVertical = FlowLayoutDefault.isVertical(layout);
|
|
308
|
+
const { pre, collapsed } = trans;
|
|
309
|
+
if (collapsed) {
|
|
310
|
+
return { x: 0, y: 0 };
|
|
311
|
+
}
|
|
312
|
+
if (isVertical) {
|
|
313
|
+
const preCenter2 = pre.localBounds.center.x;
|
|
314
|
+
const firstBlockX = trans.firstChild?.transform.position.x || 0;
|
|
315
|
+
const lastBlockX = trans.lastChild?.transform.position.x || 0;
|
|
316
|
+
const currentCenter2 = (lastBlockX - firstBlockX) / 2;
|
|
317
|
+
return {
|
|
318
|
+
x: preCenter2 - currentCenter2,
|
|
319
|
+
y: 0
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
const preCenter = pre.localBounds.center.y;
|
|
323
|
+
const firstBlockY = trans.firstChild?.transform.position.y || 0;
|
|
324
|
+
const lastBlockY = trans.lastChild?.transform.position.y || 0;
|
|
325
|
+
const currentCenter = (lastBlockY - firstBlockY) / 2;
|
|
326
|
+
return {
|
|
327
|
+
x: 0,
|
|
328
|
+
y: preCenter - currentCenter
|
|
329
|
+
};
|
|
330
|
+
},
|
|
331
|
+
getLabels(transition) {
|
|
332
|
+
return getBranchAdderLabel(transition);
|
|
333
|
+
},
|
|
334
|
+
getLines() {
|
|
335
|
+
return [];
|
|
336
|
+
},
|
|
337
|
+
// 和前序节点对齐
|
|
338
|
+
getInputPoint(transform, layout) {
|
|
339
|
+
const isVertical = FlowLayoutDefault.isVertical(layout);
|
|
340
|
+
if (isVertical) {
|
|
341
|
+
return {
|
|
342
|
+
x: transform.pre?.outputPoint.x || 0,
|
|
343
|
+
y: transform.bounds.top
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
return {
|
|
347
|
+
x: transform.bounds.left,
|
|
348
|
+
y: transform.pre?.outputPoint.y || 0
|
|
349
|
+
};
|
|
350
|
+
},
|
|
351
|
+
getOutputPoint(transform, layout) {
|
|
352
|
+
const isVertical = FlowLayoutDefault.isVertical(layout);
|
|
353
|
+
if (transform.collapsed) {
|
|
354
|
+
return transform.inputPoint;
|
|
355
|
+
}
|
|
356
|
+
if (isVertical) {
|
|
357
|
+
return {
|
|
358
|
+
x: transform.pre?.outputPoint.x || 0,
|
|
359
|
+
y: transform.bounds.bottom
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
return {
|
|
363
|
+
x: transform.bounds.right,
|
|
364
|
+
y: transform.pre?.outputPoint.y || 0
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
function getBranchAdderLabel(transition) {
|
|
369
|
+
const { isVertical } = transition.entity;
|
|
370
|
+
const currentTransform = transition.transform;
|
|
371
|
+
if (currentTransform.collapsed) {
|
|
372
|
+
return [
|
|
373
|
+
{
|
|
374
|
+
type: FlowTransitionLabelEnum.COLLAPSE_LABEL,
|
|
375
|
+
offset: Point.move(currentTransform.inputPoint, isVertical ? { y: 10 } : { x: 10 }),
|
|
376
|
+
props: {
|
|
377
|
+
activateNode: transition.entity.pre
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
];
|
|
381
|
+
}
|
|
382
|
+
return [
|
|
383
|
+
{
|
|
384
|
+
type: FlowTransitionLabelEnum.CUSTOM_LABEL,
|
|
385
|
+
renderKey: FlowRendererKey.BRANCH_ADDER,
|
|
386
|
+
offset: Point.move(currentTransform.inputPoint, isVertical ? { y: 10 } : { x: 10 }),
|
|
387
|
+
props: {
|
|
388
|
+
// 激活状态
|
|
389
|
+
activated: transition.entity.getData(FlowNodeRenderData).activated,
|
|
390
|
+
transform: currentTransform,
|
|
391
|
+
// 传给外部使用的 node 信息
|
|
392
|
+
node: currentTransform.originParent?.entity
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
];
|
|
396
|
+
}
|
|
397
|
+
var BlockIconRegistry = {
|
|
398
|
+
type: FlowNodeBaseType.BLOCK_ICON,
|
|
399
|
+
meta: {
|
|
400
|
+
spacing: 20,
|
|
401
|
+
// 占位节点下边偏小
|
|
402
|
+
// 条件分支 icon 默认的高度比较高,在流程里下边有文字
|
|
403
|
+
size: { width: 250, height: 84 }
|
|
404
|
+
},
|
|
405
|
+
/**
|
|
406
|
+
* 是一个占位节点,后续要加上 label 展开收起的图标
|
|
407
|
+
*/
|
|
408
|
+
getLabels(transition) {
|
|
409
|
+
const currentTransform = transition.transform;
|
|
410
|
+
const { isVertical } = transition.entity;
|
|
411
|
+
if (transition.entity.parent.collapsedChildren.length <= 1) {
|
|
412
|
+
return [];
|
|
413
|
+
}
|
|
414
|
+
const collapsedSpacing = getDefaultSpacing(
|
|
415
|
+
transition.entity,
|
|
416
|
+
DefaultSpacingKey.COLLAPSED_SPACING
|
|
417
|
+
);
|
|
418
|
+
return [
|
|
419
|
+
{
|
|
420
|
+
type: FlowTransitionLabelEnum.COLLAPSE_LABEL,
|
|
421
|
+
offset: Point.move(
|
|
422
|
+
currentTransform.outputPoint,
|
|
423
|
+
isVertical ? { y: collapsedSpacing } : { x: collapsedSpacing }
|
|
424
|
+
),
|
|
425
|
+
props: {
|
|
426
|
+
collapseNode: transition.entity.parent,
|
|
427
|
+
activateNode: transition.entity
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
];
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
var BlockOrderIconRegistry = {
|
|
434
|
+
type: FlowNodeBaseType.BLOCK_ORDER_ICON,
|
|
435
|
+
meta: {
|
|
436
|
+
spacing: 40
|
|
437
|
+
},
|
|
438
|
+
getLabels(transition) {
|
|
439
|
+
const currentTransform = transition.transform;
|
|
440
|
+
const { isVertical } = transition.entity;
|
|
441
|
+
const currentOutput = currentTransform.outputPoint;
|
|
442
|
+
const nextTransform = currentTransform.next;
|
|
443
|
+
const parentTransform = currentTransform.parent;
|
|
444
|
+
if (transition.entity.parent.collapsedChildren.length <= 1) {
|
|
445
|
+
const parentOutput = parentTransform?.outputPoint;
|
|
446
|
+
return [
|
|
447
|
+
{
|
|
448
|
+
offset: parentOutput,
|
|
449
|
+
type: FlowTransitionLabelEnum.ADDER_LABEL
|
|
450
|
+
}
|
|
451
|
+
];
|
|
452
|
+
}
|
|
453
|
+
const collapsedSpacing = getDefaultSpacing(
|
|
454
|
+
transition.entity,
|
|
455
|
+
DefaultSpacingKey.COLLAPSED_SPACING
|
|
456
|
+
);
|
|
457
|
+
return [
|
|
458
|
+
{
|
|
459
|
+
offset: nextTransform ? Point.getMiddlePoint(currentOutput, nextTransform.inputPoint) : Point.move(
|
|
460
|
+
currentOutput,
|
|
461
|
+
isVertical ? { y: collapsedSpacing } : { x: collapsedSpacing }
|
|
462
|
+
),
|
|
463
|
+
// 收起展开复合按钮
|
|
464
|
+
type: FlowTransitionLabelEnum.COLLAPSE_ADDER_LABEL,
|
|
465
|
+
props: {
|
|
466
|
+
activateNode: transition.entity,
|
|
467
|
+
collapseNode: transition.entity.parent
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
];
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
var StartRegistry = {
|
|
474
|
+
type: FlowNodeBaseType.START,
|
|
475
|
+
meta: {
|
|
476
|
+
isStart: true,
|
|
477
|
+
draggable: false,
|
|
478
|
+
selectable: false,
|
|
479
|
+
// 触发器等开始节点不能被框选
|
|
480
|
+
deleteDisable: true,
|
|
481
|
+
// 禁止删除
|
|
482
|
+
copyDisable: true,
|
|
483
|
+
// 禁止copy
|
|
484
|
+
addDisable: true
|
|
485
|
+
// 禁止添加
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
var CatchBlockRegistry = {
|
|
489
|
+
extend: FlowNodeBaseType.BLOCK,
|
|
490
|
+
type: "catchBlock" /* CATCH_BLOCK */,
|
|
491
|
+
meta: {
|
|
492
|
+
hidden: true,
|
|
493
|
+
spacing: DEFAULT_SPACING.NULL
|
|
494
|
+
},
|
|
495
|
+
getLines(transition) {
|
|
496
|
+
const { transform } = transition;
|
|
497
|
+
const { isVertical } = transition.entity;
|
|
498
|
+
const parentPoint = transform.parent;
|
|
499
|
+
const { inputPoint, outputPoint } = transform;
|
|
500
|
+
let parentInputPoint;
|
|
501
|
+
if (isVertical) {
|
|
502
|
+
parentInputPoint = {
|
|
503
|
+
x: parentPoint.inputPoint.x,
|
|
504
|
+
y: parentPoint.inputPoint.y - 20 /* CATCH_INLINE_SPACING */
|
|
505
|
+
};
|
|
506
|
+
} else {
|
|
507
|
+
parentInputPoint = {
|
|
508
|
+
x: parentPoint.inputPoint.x - 20 /* CATCH_INLINE_SPACING */,
|
|
509
|
+
y: parentPoint.inputPoint.y
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
const lines = [
|
|
513
|
+
{
|
|
514
|
+
type: FlowTransitionLineEnum.DIVERGE_LINE,
|
|
515
|
+
from: parentInputPoint,
|
|
516
|
+
to: inputPoint
|
|
517
|
+
}
|
|
518
|
+
];
|
|
519
|
+
if (!transition.isNodeEnd) {
|
|
520
|
+
let mergePoint;
|
|
521
|
+
if (isVertical) {
|
|
522
|
+
mergePoint = {
|
|
523
|
+
x: parentPoint.outputPoint.x,
|
|
524
|
+
y: parentPoint.bounds.bottom
|
|
525
|
+
};
|
|
526
|
+
} else {
|
|
527
|
+
mergePoint = {
|
|
528
|
+
x: parentPoint.bounds.right,
|
|
529
|
+
y: parentPoint.outputPoint.y
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
lines.push({
|
|
533
|
+
type: FlowTransitionLineEnum.MERGE_LINE,
|
|
534
|
+
from: outputPoint,
|
|
535
|
+
to: mergePoint
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
return lines;
|
|
539
|
+
},
|
|
540
|
+
getLabels() {
|
|
541
|
+
return [];
|
|
542
|
+
}
|
|
543
|
+
};
|
|
544
|
+
var CatchInlineBlocksRegistry = {
|
|
545
|
+
extend: FlowNodeBaseType.INLINE_BLOCKS,
|
|
546
|
+
type: "catchInlineBlocks" /* CATCH_INLINE_BLOCKS */,
|
|
547
|
+
meta: {
|
|
548
|
+
spacing: DEFAULT_SPACING.NULL,
|
|
549
|
+
inlineSpacingPre: DEFAULT_SPACING.NULL
|
|
550
|
+
// inlineSpacingAfter: DEFAULT_SPACING.NULL,
|
|
551
|
+
},
|
|
552
|
+
getDelta() {
|
|
553
|
+
return void 0;
|
|
554
|
+
},
|
|
555
|
+
getLines(transition) {
|
|
556
|
+
const { transform } = transition;
|
|
557
|
+
const mainInlineBlocks = transform.parent;
|
|
558
|
+
const lines = [
|
|
559
|
+
{
|
|
560
|
+
type: FlowTransitionLineEnum.DIVERGE_LINE,
|
|
561
|
+
from: mainInlineBlocks.pre.outputPoint,
|
|
562
|
+
to: transform.inputPoint
|
|
563
|
+
}
|
|
564
|
+
];
|
|
565
|
+
if (!transform.entity.isNodeEnd) {
|
|
566
|
+
lines.push({
|
|
567
|
+
type: FlowTransitionLineEnum.MERGE_LINE,
|
|
568
|
+
from: transform.outputPoint,
|
|
569
|
+
to: mainInlineBlocks.outputPoint
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
return lines;
|
|
573
|
+
},
|
|
574
|
+
getOriginDeltaX(transform) {
|
|
575
|
+
const { firstChild } = transform;
|
|
576
|
+
if (!firstChild) return 0;
|
|
577
|
+
return firstChild.originDeltaX;
|
|
578
|
+
},
|
|
579
|
+
getLabels(transition) {
|
|
580
|
+
const { inputPoint } = transition.transform;
|
|
581
|
+
const { isVertical } = transition.entity;
|
|
582
|
+
const currentTransform = transition.transform;
|
|
583
|
+
const actualInputPoint = {
|
|
584
|
+
x: isVertical ? inputPoint.x : inputPoint.x - 20 /* CATCH_INLINE_SPACING */,
|
|
585
|
+
y: isVertical ? inputPoint.y - 20 /* CATCH_INLINE_SPACING */ : inputPoint.y
|
|
586
|
+
};
|
|
587
|
+
if (currentTransform.collapsed) {
|
|
588
|
+
return [];
|
|
589
|
+
}
|
|
590
|
+
return [
|
|
591
|
+
{
|
|
592
|
+
type: FlowTransitionLabelEnum.CUSTOM_LABEL,
|
|
593
|
+
renderKey: FlowRendererKey.BRANCH_ADDER,
|
|
594
|
+
offset: actualInputPoint,
|
|
595
|
+
props: {
|
|
596
|
+
// 激活状态
|
|
597
|
+
activated: transition.entity.getData(FlowNodeRenderData).activated,
|
|
598
|
+
transform: currentTransform,
|
|
599
|
+
// 传给外部使用的 node 信息
|
|
600
|
+
node: currentTransform.originParent?.entity
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
];
|
|
604
|
+
},
|
|
605
|
+
getInputPoint(transform, layout) {
|
|
606
|
+
const isVertical = FlowLayoutDefault.isVertical(layout);
|
|
607
|
+
const firstCatchBlock = transform.firstChild;
|
|
608
|
+
if (firstCatchBlock) {
|
|
609
|
+
return firstCatchBlock.inputPoint;
|
|
610
|
+
}
|
|
611
|
+
return isVertical ? transform.bounds.topCenter : transform.bounds.rightCenter;
|
|
612
|
+
},
|
|
613
|
+
getOutputPoint(transform, layout) {
|
|
614
|
+
const isVertical = FlowLayoutDefault.isVertical(layout);
|
|
615
|
+
if (transform.collapsed) {
|
|
616
|
+
return transform.inputPoint;
|
|
617
|
+
}
|
|
618
|
+
const firstCatchBlock = transform.firstChild;
|
|
619
|
+
if (firstCatchBlock) {
|
|
620
|
+
return isVertical ? {
|
|
621
|
+
x: firstCatchBlock.outputPoint?.x,
|
|
622
|
+
y: transform.bounds.bottom
|
|
623
|
+
} : {
|
|
624
|
+
x: transform.bounds.right,
|
|
625
|
+
y: firstCatchBlock.outputPoint?.y
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
return isVertical ? transform.bounds.bottomCenter : transform.bounds.rightCenter;
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
var MainInlineBlocksRegistry = {
|
|
632
|
+
extend: FlowNodeBaseType.INLINE_BLOCKS,
|
|
633
|
+
type: "mainInlineBlocks" /* MAIN_INLINE_BLOCKS */,
|
|
634
|
+
meta: {
|
|
635
|
+
inlineSpacingPre: 20 /* MAIN_INLINE_SPACING_TOP */,
|
|
636
|
+
inlineSpacingAfter: 40 /* MAIN_INLINE_SPACING_BOTTOM */
|
|
637
|
+
},
|
|
638
|
+
getLines(transition) {
|
|
639
|
+
const { transform } = transition;
|
|
640
|
+
const tryBranch = transform.firstChild;
|
|
641
|
+
const lines = [
|
|
642
|
+
{
|
|
643
|
+
type: FlowTransitionLineEnum.STRAIGHT_LINE,
|
|
644
|
+
from: tryBranch.outputPoint,
|
|
645
|
+
to: transform.originParent.outputPoint
|
|
646
|
+
}
|
|
647
|
+
];
|
|
648
|
+
return lines;
|
|
649
|
+
},
|
|
650
|
+
getLabels(transition) {
|
|
651
|
+
const { transform } = transition;
|
|
652
|
+
const { isVertical } = transition.entity;
|
|
653
|
+
const catchInlineBlocks = transform.children[1];
|
|
654
|
+
const errLabelX = isVertical ? (transform.parent.outputPoint.x + catchInlineBlocks.inputPoint.x) / 2 : transform.inputPoint.x - 54 /* INLINE_SPACING_TOP */;
|
|
655
|
+
const errLabelY = isVertical ? transform.inputPoint.y - 54 /* INLINE_SPACING_TOP */ : (transform.parent.outputPoint.y + catchInlineBlocks.inputPoint.y) / 2;
|
|
656
|
+
const errorLabelX = errLabelX;
|
|
657
|
+
const errorLabelY = errLabelY;
|
|
658
|
+
return [
|
|
659
|
+
{
|
|
660
|
+
type: FlowTransitionLabelEnum.TEXT_LABEL,
|
|
661
|
+
renderKey: FlowTextKey.TRY_START_TEXT,
|
|
662
|
+
offset: {
|
|
663
|
+
x: isVertical ? transform.inputPoint.x : transform.inputPoint.x + -20 /* TRY_START_LABEL_DELTA */,
|
|
664
|
+
y: isVertical ? transform.inputPoint.y + -20 /* TRY_START_LABEL_DELTA */ : transform.inputPoint.y
|
|
665
|
+
}
|
|
666
|
+
},
|
|
667
|
+
{
|
|
668
|
+
type: FlowTransitionLabelEnum.TEXT_LABEL,
|
|
669
|
+
renderKey: FlowTextKey.TRY_END_TEXT,
|
|
670
|
+
offset: {
|
|
671
|
+
x: isVertical ? transform.inputPoint.x : transform.originParent.outputPoint.x + -20 /* TRY_END_LABEL_DELTA */,
|
|
672
|
+
y: isVertical ? transform.originParent.outputPoint.y + -20 /* TRY_END_LABEL_DELTA */ : transform.inputPoint.y
|
|
673
|
+
}
|
|
674
|
+
},
|
|
675
|
+
// 错误分支收起
|
|
676
|
+
{
|
|
677
|
+
type: FlowTransitionLabelEnum.CUSTOM_LABEL,
|
|
678
|
+
renderKey: FlowRendererKey.TRY_CATCH_COLLAPSE,
|
|
679
|
+
offset: {
|
|
680
|
+
x: errorLabelX,
|
|
681
|
+
y: errorLabelY
|
|
682
|
+
},
|
|
683
|
+
props: {
|
|
684
|
+
node: transform.lastChild?.entity
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
];
|
|
688
|
+
},
|
|
689
|
+
getInputPoint(transform) {
|
|
690
|
+
const tryBlock = transform.firstChild;
|
|
691
|
+
return tryBlock.inputPoint;
|
|
692
|
+
},
|
|
693
|
+
getOutputPoint(transform, layout) {
|
|
694
|
+
const tryBlock = transform.firstChild;
|
|
695
|
+
const isVertical = FlowLayoutDefault.isVertical(layout);
|
|
696
|
+
if (isVertical) {
|
|
697
|
+
return {
|
|
698
|
+
x: tryBlock.outputPoint.x,
|
|
699
|
+
y: transform.bounds.bottom + 20 /* CATCH_INLINE_SPACING */
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
return {
|
|
703
|
+
x: transform.bounds.right + 20 /* CATCH_INLINE_SPACING */,
|
|
704
|
+
y: tryBlock.outputPoint.y
|
|
705
|
+
};
|
|
706
|
+
},
|
|
707
|
+
getDelta() {
|
|
708
|
+
return void 0;
|
|
709
|
+
},
|
|
710
|
+
getChildDelta(child, layout) {
|
|
711
|
+
const preTransform = child.entity.pre?.getData(FlowNodeTransformData);
|
|
712
|
+
const isVertical = FlowLayoutDefault.isVertical(layout);
|
|
713
|
+
if (preTransform) {
|
|
714
|
+
const { localBounds: preBounds } = preTransform;
|
|
715
|
+
let delta = 0;
|
|
716
|
+
if (isVertical) {
|
|
717
|
+
delta = Math.max(
|
|
718
|
+
child.parent.minInlineBlockSpacing,
|
|
719
|
+
-child.originDeltaX + getDefaultSpacing(child.entity, ConstantKeys.BRANCH_SPACING)
|
|
720
|
+
);
|
|
721
|
+
} else {
|
|
722
|
+
delta = Math.max(
|
|
723
|
+
child.parent.minInlineBlockSpacing,
|
|
724
|
+
-child.originDeltaY + getDefaultSpacing(child.entity, ConstantKeys.BRANCH_SPACING)
|
|
725
|
+
);
|
|
726
|
+
}
|
|
727
|
+
return {
|
|
728
|
+
// 分支只有两个所以这里可以写死间隔宽度
|
|
729
|
+
x: isVertical ? preBounds.right + delta : 0,
|
|
730
|
+
y: isVertical ? 0 : preBounds.bottom + delta
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
return {
|
|
734
|
+
x: 0,
|
|
735
|
+
y: 0
|
|
736
|
+
};
|
|
737
|
+
}
|
|
738
|
+
};
|
|
739
|
+
var TryBlockRegistry = {
|
|
740
|
+
extend: FlowNodeBaseType.BLOCK,
|
|
741
|
+
type: "tryBlock" /* TRY_BLOCK */,
|
|
742
|
+
meta: {
|
|
743
|
+
hidden: true,
|
|
744
|
+
spacing: DEFAULT_SPACING.NULL
|
|
745
|
+
},
|
|
746
|
+
getLines() {
|
|
747
|
+
return [];
|
|
748
|
+
},
|
|
749
|
+
getLabels() {
|
|
750
|
+
return [];
|
|
751
|
+
}
|
|
752
|
+
};
|
|
753
|
+
var TrySlotRegistry = {
|
|
754
|
+
type: "trySlot" /* TRY_SLOT */,
|
|
755
|
+
meta: {
|
|
756
|
+
inlineSpacingAfter: 16,
|
|
757
|
+
spacing: 0,
|
|
758
|
+
size: {
|
|
759
|
+
width: 16,
|
|
760
|
+
height: 0
|
|
761
|
+
}
|
|
762
|
+
},
|
|
763
|
+
onAfterUpdateLocalTransform(transform) {
|
|
764
|
+
if (transform.entity.isVertical) {
|
|
765
|
+
transform.data.size = {
|
|
766
|
+
width: 16,
|
|
767
|
+
height: 0
|
|
768
|
+
};
|
|
769
|
+
} else {
|
|
770
|
+
transform.data.size = {
|
|
771
|
+
width: 0,
|
|
772
|
+
height: 16
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
transform.transform.update({
|
|
776
|
+
size: transform.data.size
|
|
777
|
+
});
|
|
778
|
+
},
|
|
779
|
+
getLabels(transition) {
|
|
780
|
+
return [
|
|
781
|
+
{
|
|
782
|
+
offset: transition.transform.bounds.center,
|
|
783
|
+
type: FlowTransitionLabelEnum.ADDER_LABEL
|
|
784
|
+
}
|
|
785
|
+
];
|
|
786
|
+
}
|
|
787
|
+
};
|
|
788
|
+
|
|
789
|
+
// src/activities/try-catch.ts
|
|
790
|
+
var TryCatchRegistry = {
|
|
791
|
+
type: "tryCatch",
|
|
792
|
+
meta: {
|
|
793
|
+
hidden: true,
|
|
794
|
+
inlineSpacingAfter: 0 /* INLINE_SPACING_BOTTOM */
|
|
795
|
+
},
|
|
796
|
+
/**
|
|
797
|
+
* 结构
|
|
798
|
+
* tryCatch
|
|
799
|
+
* - tryCatchIcon
|
|
800
|
+
* - mainInlineBlocks
|
|
801
|
+
* - tryBlock // try 分支
|
|
802
|
+
* - trySlot // 空节点用来占位,try 分支一开始没有节点
|
|
803
|
+
* - catchInlineBlocks
|
|
804
|
+
* - catchBlock // catch 分支 1
|
|
805
|
+
* - blockOrderIcon
|
|
806
|
+
* - node1
|
|
807
|
+
* - catchBlock // catch 分支 2
|
|
808
|
+
* - blockOrderIcon
|
|
809
|
+
* - node 2
|
|
810
|
+
* @param node
|
|
811
|
+
* @param json
|
|
812
|
+
*/
|
|
813
|
+
onCreate(node, json) {
|
|
814
|
+
const { document } = node;
|
|
815
|
+
const [tryBlock, ...catchBlocks] = json.blocks || [];
|
|
816
|
+
const addedNodes = [];
|
|
817
|
+
const tryCatchIconNode = document.addNode({
|
|
818
|
+
id: `$tryCatchIcon$${node.id}`,
|
|
819
|
+
type: FlowNodeBaseType.BLOCK_ICON,
|
|
820
|
+
originParent: node,
|
|
821
|
+
parent: node
|
|
822
|
+
});
|
|
823
|
+
const mainBlockNode = document.addNode({
|
|
824
|
+
id: `$mainInlineBlocks$${node.id}`,
|
|
825
|
+
type: "mainInlineBlocks" /* MAIN_INLINE_BLOCKS */,
|
|
826
|
+
originParent: node,
|
|
827
|
+
parent: node
|
|
828
|
+
});
|
|
829
|
+
const tryBlockNode = document.addNode({
|
|
830
|
+
id: tryBlock.id,
|
|
831
|
+
type: tryBlock.type || "tryBlock" /* TRY_BLOCK */,
|
|
832
|
+
originParent: node,
|
|
833
|
+
parent: mainBlockNode,
|
|
834
|
+
data: tryBlock.data
|
|
835
|
+
});
|
|
836
|
+
const trySlotNode = document.addNode({
|
|
837
|
+
id: `$trySlot$${tryBlock.id}`,
|
|
838
|
+
hidden: true,
|
|
839
|
+
type: "trySlot" /* TRY_SLOT */,
|
|
840
|
+
// 占位节点
|
|
841
|
+
originParent: node,
|
|
842
|
+
parent: tryBlockNode
|
|
843
|
+
});
|
|
844
|
+
const catchInlineBlocksNode = document.addNode({
|
|
845
|
+
id: `$catchInlineBlocks$${node.id}`,
|
|
846
|
+
type: "catchInlineBlocks" /* CATCH_INLINE_BLOCKS */,
|
|
847
|
+
originParent: node,
|
|
848
|
+
parent: mainBlockNode
|
|
849
|
+
});
|
|
850
|
+
addedNodes.push(
|
|
851
|
+
tryCatchIconNode,
|
|
852
|
+
mainBlockNode,
|
|
853
|
+
tryBlockNode,
|
|
854
|
+
trySlotNode,
|
|
855
|
+
catchInlineBlocksNode
|
|
856
|
+
);
|
|
857
|
+
(tryBlock.blocks || []).forEach((blockData) => {
|
|
858
|
+
document.addNode(
|
|
859
|
+
{
|
|
860
|
+
...blockData,
|
|
861
|
+
parent: tryBlockNode
|
|
862
|
+
},
|
|
863
|
+
addedNodes
|
|
864
|
+
);
|
|
865
|
+
});
|
|
866
|
+
catchBlocks.forEach((blockData) => {
|
|
867
|
+
document.addBlock(node, blockData, addedNodes);
|
|
868
|
+
});
|
|
869
|
+
return addedNodes;
|
|
870
|
+
},
|
|
871
|
+
/**
|
|
872
|
+
* 添加 catch 分支
|
|
873
|
+
* @param node
|
|
874
|
+
* @param blockData
|
|
875
|
+
* @param addedNodes
|
|
876
|
+
*/
|
|
877
|
+
onBlockChildCreate(node, blockData, addedNodes) {
|
|
878
|
+
const parent = node.document.getNode(`$catchInlineBlocks$${node.id}`);
|
|
879
|
+
const block = node.document.addNode({
|
|
880
|
+
id: blockData.id,
|
|
881
|
+
type: blockData.type || "catchBlock" /* CATCH_BLOCK */,
|
|
882
|
+
originParent: node,
|
|
883
|
+
parent,
|
|
884
|
+
data: blockData.data
|
|
885
|
+
});
|
|
886
|
+
const blockOrderIcon = node.document.addNode({
|
|
887
|
+
id: `$blockOrderIcon$${blockData.id}`,
|
|
888
|
+
type: FlowNodeBaseType.BLOCK_ORDER_ICON,
|
|
889
|
+
originParent: node,
|
|
890
|
+
parent: block
|
|
891
|
+
});
|
|
892
|
+
if (blockData.blocks) {
|
|
893
|
+
node.document.addBlocksAsChildren(block, blockData.blocks || [], addedNodes);
|
|
894
|
+
}
|
|
895
|
+
addedNodes?.push(block, blockOrderIcon);
|
|
896
|
+
return block;
|
|
897
|
+
},
|
|
898
|
+
getInputPoint(transform) {
|
|
899
|
+
const tryCatchIcon = transform.firstChild;
|
|
900
|
+
return tryCatchIcon.inputPoint;
|
|
901
|
+
},
|
|
902
|
+
getOutputPoint(transform, layout) {
|
|
903
|
+
const isVertical = FlowLayoutDefault.isVertical(layout);
|
|
904
|
+
const tryCatchIcon = transform.firstChild;
|
|
905
|
+
if (isVertical) {
|
|
906
|
+
return {
|
|
907
|
+
x: tryCatchIcon.inputPoint.x,
|
|
908
|
+
y: transform.bounds.bottom
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
return {
|
|
912
|
+
x: transform.bounds.right,
|
|
913
|
+
y: tryCatchIcon.inputPoint.y
|
|
914
|
+
};
|
|
915
|
+
},
|
|
916
|
+
/**
|
|
917
|
+
* tryCatch 子节点配置
|
|
918
|
+
*/
|
|
919
|
+
extendChildRegistries: [
|
|
920
|
+
/**
|
|
921
|
+
* icon 节点
|
|
922
|
+
*/
|
|
923
|
+
{
|
|
924
|
+
type: FlowNodeBaseType.BLOCK_ICON,
|
|
925
|
+
meta: {
|
|
926
|
+
spacing: 54 /* INLINE_SPACING_TOP */
|
|
927
|
+
},
|
|
928
|
+
getLabels() {
|
|
929
|
+
return [];
|
|
930
|
+
}
|
|
931
|
+
},
|
|
932
|
+
MainInlineBlocksRegistry,
|
|
933
|
+
CatchInlineBlocksRegistry,
|
|
934
|
+
TryBlockRegistry,
|
|
935
|
+
CatchBlockRegistry,
|
|
936
|
+
TrySlotRegistry
|
|
937
|
+
]
|
|
938
|
+
};
|
|
939
|
+
var LoopSpacings = {
|
|
940
|
+
SPACING: 16,
|
|
941
|
+
// 距离下面节点距离
|
|
942
|
+
COLLAPSE_INLINE_SPACING_BOTTOM: 60,
|
|
943
|
+
// 距离下面节点距离
|
|
944
|
+
[ConstantKeys.INLINE_SPACING_BOTTOM]: 48,
|
|
945
|
+
// 下边空白
|
|
946
|
+
MIN_INLINE_BLOCK_SPACING: 280,
|
|
947
|
+
// 最小循环圈宽度
|
|
948
|
+
HORIZONTAL_MIN_INLINE_BLOCK_SPACING: 180,
|
|
949
|
+
// 水平布局下的最小循环圈高度
|
|
950
|
+
LEFT_EMPTY_BLOCK_WIDTH: 80,
|
|
951
|
+
// 左边空分支宽度
|
|
952
|
+
EMPTY_BRANCH_SPACING: 20,
|
|
953
|
+
// 左边空分支宽度
|
|
954
|
+
LOOP_BLOCK_ICON_SPACING: 13,
|
|
955
|
+
// inlineBlocks 的 inlineBottom
|
|
956
|
+
[ConstantKeys.INLINE_BLOCKS_INLINE_SPACING_BOTTOM]: 23,
|
|
957
|
+
// inlineBlocks 的 inlineBottom
|
|
958
|
+
INLINE_BLOCKS_INLINE_SPACING_TOP: 30
|
|
959
|
+
// inlineBlocks 的 inlineTop
|
|
960
|
+
};
|
|
961
|
+
|
|
962
|
+
// src/activities/loop-extends/loop-left-empty-block.ts
|
|
963
|
+
var LoopLeftEmptyBlockRegistry = {
|
|
964
|
+
type: "loopLeftEmptyBlock" /* LOOP_LEFT_EMPTY_BLOCK */,
|
|
965
|
+
meta: {
|
|
966
|
+
inlineSpacingAfter: 0,
|
|
967
|
+
spacing: 0,
|
|
968
|
+
size: {
|
|
969
|
+
width: LoopSpacings.LEFT_EMPTY_BLOCK_WIDTH,
|
|
970
|
+
height: 0
|
|
971
|
+
}
|
|
972
|
+
},
|
|
973
|
+
onAfterUpdateLocalTransform(transform) {
|
|
974
|
+
if (transform.entity.isVertical) {
|
|
975
|
+
transform.data.size = {
|
|
976
|
+
width: LoopSpacings.LEFT_EMPTY_BLOCK_WIDTH,
|
|
977
|
+
height: 0
|
|
978
|
+
};
|
|
979
|
+
} else {
|
|
980
|
+
transform.data.size = {
|
|
981
|
+
width: 0,
|
|
982
|
+
height: LoopSpacings.LEFT_EMPTY_BLOCK_WIDTH
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
transform.transform.update({
|
|
986
|
+
size: transform.data.size
|
|
987
|
+
});
|
|
988
|
+
},
|
|
989
|
+
getLines() {
|
|
990
|
+
return [];
|
|
991
|
+
},
|
|
992
|
+
getLabels() {
|
|
993
|
+
return [];
|
|
994
|
+
}
|
|
995
|
+
};
|
|
996
|
+
|
|
997
|
+
// src/activities/loop-extends/loop-right-empty-block.ts
|
|
998
|
+
var LoopRightEmptyBlockRegistry = {
|
|
999
|
+
...BlockRegistry,
|
|
1000
|
+
type: "loopRightEmptyBlock" /* LOOP_RIGHT_EMPTY_BLOCK */,
|
|
1001
|
+
meta: {
|
|
1002
|
+
...BlockRegistry.meta,
|
|
1003
|
+
inlineSpacingAfter: 0
|
|
1004
|
+
}
|
|
1005
|
+
};
|
|
1006
|
+
var LoopEmptyBranchRegistry = {
|
|
1007
|
+
type: "loopEmptyBranch" /* LOOP_EMPTY_BRANCH */,
|
|
1008
|
+
meta: {
|
|
1009
|
+
inlineSpacingAfter: 0,
|
|
1010
|
+
spacing: LoopSpacings.EMPTY_BRANCH_SPACING,
|
|
1011
|
+
size: {
|
|
1012
|
+
width: 100,
|
|
1013
|
+
height: 0
|
|
1014
|
+
}
|
|
1015
|
+
},
|
|
1016
|
+
getLabels(transition) {
|
|
1017
|
+
const { isVertical } = transition.entity;
|
|
1018
|
+
const currentTransform = transition.transform;
|
|
1019
|
+
if (isVertical) {
|
|
1020
|
+
return [
|
|
1021
|
+
{
|
|
1022
|
+
type: FlowTransitionLabelEnum.ADDER_LABEL,
|
|
1023
|
+
offset: {
|
|
1024
|
+
x: currentTransform.inputPoint.x,
|
|
1025
|
+
y: currentTransform.bounds.center.y + 8
|
|
1026
|
+
// 右边空节点
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
];
|
|
1030
|
+
}
|
|
1031
|
+
return [
|
|
1032
|
+
{
|
|
1033
|
+
type: FlowTransitionLabelEnum.ADDER_LABEL,
|
|
1034
|
+
offset: {
|
|
1035
|
+
x: currentTransform.bounds.center.x + 8,
|
|
1036
|
+
y: currentTransform.inputPoint.y
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
];
|
|
1040
|
+
},
|
|
1041
|
+
onAfterUpdateLocalTransform(transform) {
|
|
1042
|
+
if (transform.entity.isVertical) {
|
|
1043
|
+
transform.data.size = {
|
|
1044
|
+
width: 100,
|
|
1045
|
+
height: 0
|
|
1046
|
+
};
|
|
1047
|
+
} else {
|
|
1048
|
+
transform.data.size = {
|
|
1049
|
+
width: 0,
|
|
1050
|
+
height: 100
|
|
1051
|
+
};
|
|
1052
|
+
}
|
|
1053
|
+
transform.transform.update({
|
|
1054
|
+
size: transform.data.size
|
|
1055
|
+
});
|
|
1056
|
+
}
|
|
1057
|
+
};
|
|
1058
|
+
var LoopInlineBlocksNodeRegistry = {
|
|
1059
|
+
type: FlowNodeBaseType.INLINE_BLOCKS,
|
|
1060
|
+
meta: {
|
|
1061
|
+
inlineSpacingPre: (node) => {
|
|
1062
|
+
const inlineBlocksInlineSpacingTop = getDefaultSpacing(
|
|
1063
|
+
node.entity,
|
|
1064
|
+
ConstantKeys.INLINE_BLOCKS_INLINE_SPACING_TOP,
|
|
1065
|
+
LoopSpacings.INLINE_BLOCKS_INLINE_SPACING_TOP
|
|
1066
|
+
);
|
|
1067
|
+
return inlineBlocksInlineSpacingTop;
|
|
1068
|
+
},
|
|
1069
|
+
inlineSpacingAfter: (node) => {
|
|
1070
|
+
const inlineBlocksInlineSpacingBottom = getDefaultSpacing(
|
|
1071
|
+
node.entity,
|
|
1072
|
+
ConstantKeys.INLINE_BLOCKS_INLINE_SPACING_BOTTOM,
|
|
1073
|
+
LoopSpacings.INLINE_BLOCKS_INLINE_SPACING_BOTTOM
|
|
1074
|
+
);
|
|
1075
|
+
return inlineBlocksInlineSpacingBottom;
|
|
1076
|
+
},
|
|
1077
|
+
minInlineBlockSpacing: (node) => node.entity.isVertical ? LoopSpacings.MIN_INLINE_BLOCK_SPACING : LoopSpacings.HORIZONTAL_MIN_INLINE_BLOCK_SPACING
|
|
1078
|
+
},
|
|
1079
|
+
getLines(transition) {
|
|
1080
|
+
const currentTransform = transition.transform;
|
|
1081
|
+
const parentTransform = currentTransform.parent;
|
|
1082
|
+
const { isVertical } = transition.entity;
|
|
1083
|
+
const lines = [
|
|
1084
|
+
// 循环结束线
|
|
1085
|
+
{
|
|
1086
|
+
type: FlowTransitionLineEnum.STRAIGHT_LINE,
|
|
1087
|
+
from: currentTransform.outputPoint,
|
|
1088
|
+
to: parentTransform.outputPoint
|
|
1089
|
+
}
|
|
1090
|
+
];
|
|
1091
|
+
if (currentTransform.collapsed) {
|
|
1092
|
+
return lines;
|
|
1093
|
+
}
|
|
1094
|
+
const [leftBlockTransform] = currentTransform.children;
|
|
1095
|
+
return [
|
|
1096
|
+
...lines,
|
|
1097
|
+
// 循环回撤线 - 1 分成两段可以被 viewport 识别出矩阵区域
|
|
1098
|
+
{
|
|
1099
|
+
type: FlowTransitionLineEnum.ROUNDED_LINE,
|
|
1100
|
+
from: currentTransform.outputPoint,
|
|
1101
|
+
to: leftBlockTransform.outputPoint,
|
|
1102
|
+
vertices: [
|
|
1103
|
+
isVertical ? { x: leftBlockTransform.inputPoint.x, y: currentTransform.bounds.bottom } : { x: currentTransform.bounds.right, y: leftBlockTransform.inputPoint.y }
|
|
1104
|
+
]
|
|
1105
|
+
},
|
|
1106
|
+
// 循环回撤线 - 2
|
|
1107
|
+
{
|
|
1108
|
+
type: FlowTransitionLineEnum.ROUNDED_LINE,
|
|
1109
|
+
from: leftBlockTransform.outputPoint,
|
|
1110
|
+
to: Point.move(
|
|
1111
|
+
currentTransform.inputPoint,
|
|
1112
|
+
isVertical ? { x: -12, y: 10 } : { x: 10, y: -12 }
|
|
1113
|
+
),
|
|
1114
|
+
vertices: [
|
|
1115
|
+
isVertical ? { x: leftBlockTransform.inputPoint.x, y: currentTransform.bounds.top + 10 } : { x: currentTransform.bounds.left + 10, y: leftBlockTransform.inputPoint.y }
|
|
1116
|
+
],
|
|
1117
|
+
arrow: true
|
|
1118
|
+
}
|
|
1119
|
+
];
|
|
1120
|
+
},
|
|
1121
|
+
getLabels(transition) {
|
|
1122
|
+
const currentTransform = transition.transform;
|
|
1123
|
+
const { isVertical } = transition.entity;
|
|
1124
|
+
const labels = [];
|
|
1125
|
+
if (currentTransform.collapsed) {
|
|
1126
|
+
return labels;
|
|
1127
|
+
}
|
|
1128
|
+
const leftBlockTransform = currentTransform.children[0];
|
|
1129
|
+
const rightBlockTransform = currentTransform.children[1];
|
|
1130
|
+
if (transition.entity.originParent?.id.startsWith("while_")) {
|
|
1131
|
+
labels.push({
|
|
1132
|
+
type: FlowTransitionLabelEnum.TEXT_LABEL,
|
|
1133
|
+
renderKey: FlowTextKey.LOOP_WHILE_TEXT,
|
|
1134
|
+
rotate: isVertical ? "" : "-90deg",
|
|
1135
|
+
offset: isVertical ? {
|
|
1136
|
+
x: (currentTransform.inputPoint.x + rightBlockTransform.inputPoint.x) / 2,
|
|
1137
|
+
y: currentTransform.inputPoint.y + 10
|
|
1138
|
+
} : {
|
|
1139
|
+
x: currentTransform.inputPoint.x + 10,
|
|
1140
|
+
y: (currentTransform.inputPoint.y + rightBlockTransform.inputPoint.y) / 2
|
|
1141
|
+
}
|
|
1142
|
+
});
|
|
1143
|
+
} else {
|
|
1144
|
+
labels.push({
|
|
1145
|
+
type: FlowTransitionLabelEnum.TEXT_LABEL,
|
|
1146
|
+
renderKey: FlowTextKey.LOOP_TRAVERSE_TEXT,
|
|
1147
|
+
// rotate: isVertical ? '' : '-90deg',
|
|
1148
|
+
offset: isVertical ? { x: leftBlockTransform.inputPoint.x, y: currentTransform.bounds.center.y + 5 } : { x: currentTransform.bounds.center.x + 5, y: leftBlockTransform.inputPoint.y }
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
return labels;
|
|
1152
|
+
}
|
|
1153
|
+
};
|
|
1154
|
+
|
|
1155
|
+
// src/activities/loop.ts
|
|
1156
|
+
var LoopRegistry = {
|
|
1157
|
+
type: "loop",
|
|
1158
|
+
meta: {
|
|
1159
|
+
hidden: true,
|
|
1160
|
+
inlineSpacingAfter: (node) => {
|
|
1161
|
+
if (node.collapsed) {
|
|
1162
|
+
return LoopSpacings.COLLAPSE_INLINE_SPACING_BOTTOM;
|
|
1163
|
+
}
|
|
1164
|
+
const inlineSpacingBottom = getDefaultSpacing(
|
|
1165
|
+
node.entity,
|
|
1166
|
+
ConstantKeys.INLINE_SPACING_BOTTOM,
|
|
1167
|
+
LoopSpacings.INLINE_SPACING_BOTTOM
|
|
1168
|
+
);
|
|
1169
|
+
return inlineSpacingBottom;
|
|
1170
|
+
},
|
|
1171
|
+
spacing: LoopSpacings.SPACING
|
|
1172
|
+
},
|
|
1173
|
+
/**
|
|
1174
|
+
* - loopNode
|
|
1175
|
+
* - loopBlockIcon
|
|
1176
|
+
* - loopInlineBlocks
|
|
1177
|
+
* - loopEmptyBlock 左侧占位区域
|
|
1178
|
+
* - loopBlock
|
|
1179
|
+
* - xxx
|
|
1180
|
+
* - xxx
|
|
1181
|
+
* @param node
|
|
1182
|
+
* @param json
|
|
1183
|
+
*/
|
|
1184
|
+
onCreate(node, json) {
|
|
1185
|
+
const { document } = node;
|
|
1186
|
+
const loopBlocks = json.blocks || [];
|
|
1187
|
+
const loopIconNode = document.addNode({
|
|
1188
|
+
id: `$blockIcon$${node.id}`,
|
|
1189
|
+
type: FlowNodeBaseType.BLOCK_ICON,
|
|
1190
|
+
originParent: node,
|
|
1191
|
+
parent: node
|
|
1192
|
+
});
|
|
1193
|
+
const loopInlineBlocks = document.addNode({
|
|
1194
|
+
id: `$inlineBlocks$${node.id}`,
|
|
1195
|
+
hidden: true,
|
|
1196
|
+
type: FlowNodeBaseType.INLINE_BLOCKS,
|
|
1197
|
+
originParent: node,
|
|
1198
|
+
parent: node
|
|
1199
|
+
});
|
|
1200
|
+
const loopEmptyBlockNode = document.addNode({
|
|
1201
|
+
id: `$loopLeftEmpty$${node.id}`,
|
|
1202
|
+
hidden: true,
|
|
1203
|
+
type: "loopLeftEmptyBlock" /* LOOP_LEFT_EMPTY_BLOCK */,
|
|
1204
|
+
originParent: node,
|
|
1205
|
+
parent: loopInlineBlocks
|
|
1206
|
+
});
|
|
1207
|
+
const loopBlockNode = document.addNode({
|
|
1208
|
+
id: `$block$${node.id}`,
|
|
1209
|
+
hidden: true,
|
|
1210
|
+
type: FlowNodeBaseType.BLOCK,
|
|
1211
|
+
// : LoopTypeEnum.LOOP_RIGHT_EMPTY_BLOCK,
|
|
1212
|
+
originParent: node,
|
|
1213
|
+
parent: loopInlineBlocks
|
|
1214
|
+
});
|
|
1215
|
+
const loopBranch = document.addNode({
|
|
1216
|
+
id: `$loopRightEmpty$${node.id}`,
|
|
1217
|
+
hidden: true,
|
|
1218
|
+
type: "loopEmptyBranch" /* LOOP_EMPTY_BRANCH */,
|
|
1219
|
+
originParent: node,
|
|
1220
|
+
parent: loopBlockNode
|
|
1221
|
+
});
|
|
1222
|
+
const otherNodes = [];
|
|
1223
|
+
loopBlocks.forEach(
|
|
1224
|
+
(b) => document.addNode(
|
|
1225
|
+
{
|
|
1226
|
+
...b,
|
|
1227
|
+
type: b.type,
|
|
1228
|
+
parent: loopBlockNode
|
|
1229
|
+
},
|
|
1230
|
+
otherNodes
|
|
1231
|
+
)
|
|
1232
|
+
);
|
|
1233
|
+
return [
|
|
1234
|
+
loopIconNode,
|
|
1235
|
+
loopEmptyBlockNode,
|
|
1236
|
+
loopInlineBlocks,
|
|
1237
|
+
loopBlockNode,
|
|
1238
|
+
loopBranch,
|
|
1239
|
+
...otherNodes
|
|
1240
|
+
];
|
|
1241
|
+
},
|
|
1242
|
+
getLabels(transition) {
|
|
1243
|
+
const currentTransform = transition.transform;
|
|
1244
|
+
const { isVertical } = transition.entity;
|
|
1245
|
+
return [
|
|
1246
|
+
// 循环结束
|
|
1247
|
+
{
|
|
1248
|
+
type: FlowTransitionLabelEnum.TEXT_LABEL,
|
|
1249
|
+
renderKey: FlowTextKey.LOOP_END_TEXT,
|
|
1250
|
+
// 循环 label 垂直样式展示,而非 rotate 旋转文案
|
|
1251
|
+
props: isVertical ? void 0 : {
|
|
1252
|
+
style: {
|
|
1253
|
+
maxWidth: "20px",
|
|
1254
|
+
lineHeight: "12px",
|
|
1255
|
+
whiteSpace: "pre-wrap"
|
|
1256
|
+
}
|
|
1257
|
+
},
|
|
1258
|
+
offset: Point.move(currentTransform.outputPoint, isVertical ? { y: -26 } : { x: -26 })
|
|
1259
|
+
},
|
|
1260
|
+
{
|
|
1261
|
+
type: FlowTransitionLabelEnum.ADDER_LABEL,
|
|
1262
|
+
offset: currentTransform.outputPoint
|
|
1263
|
+
}
|
|
1264
|
+
];
|
|
1265
|
+
},
|
|
1266
|
+
// 和前序节点对齐
|
|
1267
|
+
getInputPoint(transform) {
|
|
1268
|
+
const { isVertical } = transform.entity;
|
|
1269
|
+
if (isVertical) {
|
|
1270
|
+
return {
|
|
1271
|
+
x: transform.pre?.outputPoint.x || transform.firstChild?.outputPoint.x || 0,
|
|
1272
|
+
y: transform.bounds.top
|
|
1273
|
+
};
|
|
1274
|
+
}
|
|
1275
|
+
return {
|
|
1276
|
+
x: transform.bounds.left,
|
|
1277
|
+
y: transform.pre?.outputPoint.y || transform.firstChild?.outputPoint.y || 0
|
|
1278
|
+
};
|
|
1279
|
+
},
|
|
1280
|
+
getOutputPoint(transform) {
|
|
1281
|
+
const { isVertical } = transform.entity;
|
|
1282
|
+
if (isVertical) {
|
|
1283
|
+
return {
|
|
1284
|
+
x: transform.pre?.outputPoint.x || transform.firstChild?.outputPoint.x || 0,
|
|
1285
|
+
y: transform.bounds.bottom
|
|
1286
|
+
};
|
|
1287
|
+
}
|
|
1288
|
+
return {
|
|
1289
|
+
x: transform.bounds.right,
|
|
1290
|
+
y: transform.pre?.outputPoint.y || transform.firstChild?.outputPoint.y || 0
|
|
1291
|
+
};
|
|
1292
|
+
},
|
|
1293
|
+
extendChildRegistries: [
|
|
1294
|
+
{
|
|
1295
|
+
type: FlowNodeBaseType.BLOCK_ICON,
|
|
1296
|
+
meta: {
|
|
1297
|
+
spacing: LoopSpacings.LOOP_BLOCK_ICON_SPACING
|
|
1298
|
+
}
|
|
1299
|
+
},
|
|
1300
|
+
LoopLeftEmptyBlockRegistry,
|
|
1301
|
+
LoopEmptyBranchRegistry,
|
|
1302
|
+
LoopRightEmptyBlockRegistry,
|
|
1303
|
+
LoopInlineBlocksNodeRegistry
|
|
1304
|
+
],
|
|
1305
|
+
/**
|
|
1306
|
+
* @depreacted
|
|
1307
|
+
*/
|
|
1308
|
+
addChild(node, json, options = {}) {
|
|
1309
|
+
const { index } = options;
|
|
1310
|
+
const document = node.document;
|
|
1311
|
+
return document.addNode({
|
|
1312
|
+
...json,
|
|
1313
|
+
...options,
|
|
1314
|
+
parent: document.getNode(`$block$${node.id}`),
|
|
1315
|
+
index: typeof index === "number" ? index + 1 : void 0
|
|
1316
|
+
});
|
|
1317
|
+
}
|
|
1318
|
+
};
|
|
1319
|
+
var RootRegistry = {
|
|
1320
|
+
type: FlowNodeBaseType.ROOT,
|
|
1321
|
+
meta: {
|
|
1322
|
+
spacing: DEFAULT_SPACING.NULL,
|
|
1323
|
+
hidden: true
|
|
1324
|
+
},
|
|
1325
|
+
getInputPoint(transform) {
|
|
1326
|
+
return transform.firstChild?.inputPoint || transform.bounds.topCenter;
|
|
1327
|
+
},
|
|
1328
|
+
getOutputPoint(transform) {
|
|
1329
|
+
return transform.lastChild?.outputPoint || transform.bounds.bottomCenter;
|
|
1330
|
+
}
|
|
1331
|
+
};
|
|
1332
|
+
var EmptyRegistry = {
|
|
1333
|
+
type: FlowNodeBaseType.EMPTY,
|
|
1334
|
+
meta: {
|
|
1335
|
+
spacing: (node) => {
|
|
1336
|
+
const spacing = getDefaultSpacing(node.entity, ConstantKeys.NODE_SPACING);
|
|
1337
|
+
return spacing / 2;
|
|
1338
|
+
},
|
|
1339
|
+
size: { width: 0, height: 0 },
|
|
1340
|
+
hidden: true
|
|
1341
|
+
},
|
|
1342
|
+
getLabels(transition) {
|
|
1343
|
+
return [
|
|
1344
|
+
{
|
|
1345
|
+
offset: transition.transform.bounds,
|
|
1346
|
+
type: FlowTransitionLabelEnum.ADDER_LABEL
|
|
1347
|
+
}
|
|
1348
|
+
];
|
|
1349
|
+
}
|
|
1350
|
+
};
|
|
1351
|
+
var SimpleSplitRegistry = {
|
|
1352
|
+
type: FlowNodeSplitType.SIMPLE_SPLIT,
|
|
1353
|
+
extend: FlowNodeSplitType.DYNAMIC_SPLIT,
|
|
1354
|
+
onBlockChildCreate(originParent, blockData, addedNodes = []) {
|
|
1355
|
+
const { document } = originParent;
|
|
1356
|
+
const parent = document.getNode(`$inlineBlocks$${originParent.id}`);
|
|
1357
|
+
const realBlock = document.addNode(
|
|
1358
|
+
{
|
|
1359
|
+
...blockData,
|
|
1360
|
+
type: blockData.type || FlowNodeBaseType.BLOCK,
|
|
1361
|
+
parent
|
|
1362
|
+
},
|
|
1363
|
+
addedNodes
|
|
1364
|
+
);
|
|
1365
|
+
addedNodes.push(realBlock);
|
|
1366
|
+
return realBlock;
|
|
1367
|
+
}
|
|
1368
|
+
// addChild(node, json, options = {}) {
|
|
1369
|
+
// const { index } = options;
|
|
1370
|
+
// const document = node.document;
|
|
1371
|
+
// return document.addBlock(node, json, undefined, undefined, index);
|
|
1372
|
+
// }
|
|
1373
|
+
};
|
|
1374
|
+
var BreakRegistry = {
|
|
1375
|
+
type: FlowNodeBaseType.BREAK,
|
|
1376
|
+
extend: FlowNodeBaseType.END
|
|
1377
|
+
};
|
|
1378
|
+
var InputRegistry = {
|
|
1379
|
+
type: FlowNodeBaseType.INPUT,
|
|
1380
|
+
extend: FlowNodeBaseType.BLOCK,
|
|
1381
|
+
meta: {
|
|
1382
|
+
hidden: false
|
|
1383
|
+
},
|
|
1384
|
+
getLines(transition, layout) {
|
|
1385
|
+
const currentTransform = transition.transform;
|
|
1386
|
+
const { isVertical } = transition.entity;
|
|
1387
|
+
const lines = [];
|
|
1388
|
+
const hasBranchDraggingAdder = currentTransform && currentTransform.entity.isInlineBlock && transition.renderData.draggable;
|
|
1389
|
+
if (hasBranchDraggingAdder) {
|
|
1390
|
+
if (isVertical) {
|
|
1391
|
+
const currentOffsetRightX = currentTransform.firstChild ? currentTransform.firstChild.bounds.right : currentTransform.bounds.right;
|
|
1392
|
+
const nextOffsetLeftX = (currentTransform.next?.firstChild ? currentTransform.next?.firstChild.bounds?.left : currentTransform.next?.bounds?.left) || 0;
|
|
1393
|
+
const currentInputPointY = currentTransform.outputPoint.y;
|
|
1394
|
+
if (currentTransform?.next) {
|
|
1395
|
+
lines.push({
|
|
1396
|
+
type: FlowTransitionLineEnum.MERGE_LINE,
|
|
1397
|
+
isDraggingLine: true,
|
|
1398
|
+
from: {
|
|
1399
|
+
x: (currentOffsetRightX + nextOffsetLeftX) / 2,
|
|
1400
|
+
y: currentInputPointY
|
|
1401
|
+
},
|
|
1402
|
+
to: currentTransform.parent.outputPoint,
|
|
1403
|
+
side: LABEL_SIDE_TYPE.NORMAL_BRANCH
|
|
1404
|
+
});
|
|
1405
|
+
}
|
|
1406
|
+
} else {
|
|
1407
|
+
const currentOffsetBottomX = currentTransform.firstChild ? currentTransform.firstChild.bounds.bottom : currentTransform.bounds.bottom;
|
|
1408
|
+
const nextOffsetTopX = (currentTransform.next?.firstChild ? currentTransform.next?.firstChild.bounds?.top : currentTransform.next?.bounds?.top) || 0;
|
|
1409
|
+
const currentInputPointX = currentTransform.outputPoint.x;
|
|
1410
|
+
if (currentTransform?.next) {
|
|
1411
|
+
lines.push({
|
|
1412
|
+
type: FlowTransitionLineEnum.MERGE_LINE,
|
|
1413
|
+
isDraggingLine: true,
|
|
1414
|
+
from: {
|
|
1415
|
+
x: currentInputPointX,
|
|
1416
|
+
y: (currentOffsetBottomX + nextOffsetTopX) / 2
|
|
1417
|
+
},
|
|
1418
|
+
to: currentTransform.parent.outputPoint,
|
|
1419
|
+
side: LABEL_SIDE_TYPE.NORMAL_BRANCH
|
|
1420
|
+
});
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
if (!transition.isNodeEnd) {
|
|
1425
|
+
lines.push({
|
|
1426
|
+
type: FlowTransitionLineEnum.MERGE_LINE,
|
|
1427
|
+
from: currentTransform.outputPoint,
|
|
1428
|
+
to: currentTransform.parent.outputPoint,
|
|
1429
|
+
side: LABEL_SIDE_TYPE.NORMAL_BRANCH
|
|
1430
|
+
});
|
|
1431
|
+
}
|
|
1432
|
+
return lines;
|
|
1433
|
+
},
|
|
1434
|
+
getLabels(transition) {
|
|
1435
|
+
const currentTransform = transition.transform;
|
|
1436
|
+
const { isVertical } = transition.entity;
|
|
1437
|
+
const draggingLabel = [];
|
|
1438
|
+
const hasBranchDraggingAdder = currentTransform && currentTransform.entity.isInlineBlock && transition.renderData.draggable;
|
|
1439
|
+
if (hasBranchDraggingAdder) {
|
|
1440
|
+
if (isVertical) {
|
|
1441
|
+
const currentOffsetRightX = currentTransform.firstChild ? currentTransform.firstChild.bounds.right : currentTransform.bounds.right;
|
|
1442
|
+
const nextOffsetLeftX = (currentTransform.next?.firstChild ? currentTransform.next.firstChild.bounds?.left : currentTransform.next?.bounds?.left) || 0;
|
|
1443
|
+
const currentInputPointY = currentTransform.outputPoint.y;
|
|
1444
|
+
if (currentTransform?.next) {
|
|
1445
|
+
draggingLabel.push({
|
|
1446
|
+
offset: {
|
|
1447
|
+
x: (currentOffsetRightX + nextOffsetLeftX) / 2,
|
|
1448
|
+
y: currentInputPointY
|
|
1449
|
+
},
|
|
1450
|
+
type: FlowTransitionLabelEnum.BRANCH_DRAGGING_LABEL,
|
|
1451
|
+
width: nextOffsetLeftX - currentOffsetRightX,
|
|
1452
|
+
props: {
|
|
1453
|
+
side: LABEL_SIDE_TYPE.NORMAL_BRANCH
|
|
1454
|
+
}
|
|
1455
|
+
});
|
|
1456
|
+
}
|
|
1457
|
+
} else {
|
|
1458
|
+
const currentOffsetBottomX = currentTransform.firstChild ? currentTransform.firstChild.bounds.bottom : currentTransform.bounds.bottom;
|
|
1459
|
+
const nextOffsetTopX = (currentTransform.next?.firstChild ? currentTransform.next.firstChild.bounds?.top : currentTransform.next?.bounds?.top) || 0;
|
|
1460
|
+
const currentInputPointX = currentTransform.outputPoint.x;
|
|
1461
|
+
if (currentTransform?.next) {
|
|
1462
|
+
draggingLabel.push({
|
|
1463
|
+
offset: {
|
|
1464
|
+
x: currentInputPointX,
|
|
1465
|
+
y: (currentOffsetBottomX + nextOffsetTopX) / 2
|
|
1466
|
+
},
|
|
1467
|
+
type: FlowTransitionLabelEnum.BRANCH_DRAGGING_LABEL,
|
|
1468
|
+
width: nextOffsetTopX - currentOffsetBottomX,
|
|
1469
|
+
props: {
|
|
1470
|
+
side: LABEL_SIDE_TYPE.NORMAL_BRANCH
|
|
1471
|
+
}
|
|
1472
|
+
});
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
return [...draggingLabel];
|
|
1477
|
+
}
|
|
1478
|
+
};
|
|
1479
|
+
var OuputRegistry = {
|
|
1480
|
+
type: FlowNodeBaseType.OUTPUT,
|
|
1481
|
+
extend: FlowNodeBaseType.BLOCK,
|
|
1482
|
+
meta: {
|
|
1483
|
+
hidden: false,
|
|
1484
|
+
isNodeEnd: true
|
|
1485
|
+
}
|
|
1486
|
+
};
|
|
1487
|
+
var MultiOuputsRegistry = {
|
|
1488
|
+
type: FlowNodeBaseType.MULTI_OUTPUTS,
|
|
1489
|
+
extend: FlowNodeSplitType.SIMPLE_SPLIT,
|
|
1490
|
+
meta: {
|
|
1491
|
+
isNodeEnd: true
|
|
1492
|
+
},
|
|
1493
|
+
getLines: (transition, layout) => {
|
|
1494
|
+
if (transition.entity.parent?.flowNodeType === FlowNodeBaseType.INLINE_BLOCKS) {
|
|
1495
|
+
return BlockRegistry.getLines(transition, layout);
|
|
1496
|
+
}
|
|
1497
|
+
return [];
|
|
1498
|
+
},
|
|
1499
|
+
getLabels: (transition, layout) => [
|
|
1500
|
+
...DynamicSplitRegistry.getLabels(transition, layout),
|
|
1501
|
+
...BlockRegistry.getLabels(transition, layout)
|
|
1502
|
+
],
|
|
1503
|
+
getOutputPoint(transform, layout) {
|
|
1504
|
+
const isVertical = FlowLayoutDefault.isVertical(layout);
|
|
1505
|
+
const lastChildOutput = transform.lastChild?.outputPoint;
|
|
1506
|
+
if (isVertical) {
|
|
1507
|
+
return {
|
|
1508
|
+
x: lastChildOutput ? lastChildOutput.x : transform.bounds.center.x,
|
|
1509
|
+
y: transform.bounds.bottom
|
|
1510
|
+
};
|
|
1511
|
+
}
|
|
1512
|
+
return {
|
|
1513
|
+
x: transform.bounds.right,
|
|
1514
|
+
y: lastChildOutput ? lastChildOutput.y : transform.bounds.center.y
|
|
1515
|
+
};
|
|
1516
|
+
},
|
|
1517
|
+
extendChildRegistries: [
|
|
1518
|
+
{
|
|
1519
|
+
type: FlowNodeBaseType.BLOCK_ICON,
|
|
1520
|
+
meta: {
|
|
1521
|
+
// isNodeEnd: true
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
]
|
|
1525
|
+
};
|
|
1526
|
+
var MultiInputsRegistry = {
|
|
1527
|
+
type: FlowNodeBaseType.MULTI_INPUTS,
|
|
1528
|
+
extend: FlowNodeSplitType.SIMPLE_SPLIT,
|
|
1529
|
+
extendChildRegistries: [
|
|
1530
|
+
{
|
|
1531
|
+
type: FlowNodeBaseType.BLOCK_ICON,
|
|
1532
|
+
meta: {
|
|
1533
|
+
hidden: true,
|
|
1534
|
+
spacing: 0
|
|
1535
|
+
},
|
|
1536
|
+
getLines() {
|
|
1537
|
+
return [];
|
|
1538
|
+
},
|
|
1539
|
+
getLabels() {
|
|
1540
|
+
return [];
|
|
1541
|
+
}
|
|
1542
|
+
},
|
|
1543
|
+
{
|
|
1544
|
+
type: FlowNodeBaseType.INLINE_BLOCKS,
|
|
1545
|
+
meta: {
|
|
1546
|
+
inlineSpacingPre: 0
|
|
1547
|
+
},
|
|
1548
|
+
getLabels(transition) {
|
|
1549
|
+
const isVertical = transition.entity.isVertical;
|
|
1550
|
+
const currentTransform = transition.transform;
|
|
1551
|
+
const spacing = getDefaultSpacing(
|
|
1552
|
+
transition.entity,
|
|
1553
|
+
ConstantKeys.INLINE_BLOCKS_PADDING_BOTTOM
|
|
1554
|
+
);
|
|
1555
|
+
if (currentTransform.collapsed || transition.entity.childrenLength === 0) {
|
|
1556
|
+
return [
|
|
1557
|
+
{
|
|
1558
|
+
type: FlowTransitionLabelEnum.CUSTOM_LABEL,
|
|
1559
|
+
renderKey: FlowRendererKey.BRANCH_ADDER,
|
|
1560
|
+
offset: Point.move(
|
|
1561
|
+
currentTransform.outputPoint,
|
|
1562
|
+
isVertical ? { y: spacing } : { x: spacing }
|
|
1563
|
+
),
|
|
1564
|
+
props: {
|
|
1565
|
+
// 激活状态
|
|
1566
|
+
activated: transition.entity.getData(FlowNodeRenderData).activated,
|
|
1567
|
+
transform: currentTransform,
|
|
1568
|
+
// 传给外部使用的 node 信息
|
|
1569
|
+
node: currentTransform.originParent?.entity
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
];
|
|
1573
|
+
}
|
|
1574
|
+
return [
|
|
1575
|
+
{
|
|
1576
|
+
type: FlowTransitionLabelEnum.CUSTOM_LABEL,
|
|
1577
|
+
renderKey: FlowRendererKey.BRANCH_ADDER,
|
|
1578
|
+
offset: Point.move(
|
|
1579
|
+
currentTransform.outputPoint,
|
|
1580
|
+
isVertical ? { y: -spacing / 2 } : { x: -spacing / 2 }
|
|
1581
|
+
),
|
|
1582
|
+
props: {
|
|
1583
|
+
// 激活状态
|
|
1584
|
+
activated: transition.entity.getData(FlowNodeRenderData).activated,
|
|
1585
|
+
transform: currentTransform,
|
|
1586
|
+
// 传给外部使用的 node 信息
|
|
1587
|
+
node: currentTransform.originParent?.entity
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
];
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
],
|
|
1594
|
+
getLabels() {
|
|
1595
|
+
return [];
|
|
1596
|
+
}
|
|
1597
|
+
};
|
|
1598
|
+
var RENDER_SLOT_ADDER_KEY = FlowRendererKey.SLOT_ADDER;
|
|
1599
|
+
var RENDER_SLOT_LABEL_KEY = FlowRendererKey.SLOT_LABEL;
|
|
1600
|
+
var RENDER_SLOT_COLLAPSE_KEY = FlowRendererKey.SLOT_COLLAPSE;
|
|
1601
|
+
var SlotSpacingKey = {
|
|
1602
|
+
/**
|
|
1603
|
+
* = Next Node - Slot END
|
|
1604
|
+
*/
|
|
1605
|
+
SLOT_SPACING: "SLOT_SPACING",
|
|
1606
|
+
/**
|
|
1607
|
+
* = Slot Start Line - Slot Icon Right
|
|
1608
|
+
*/
|
|
1609
|
+
SLOT_START_DISTANCE: "SLOT_START_DISTANCE",
|
|
1610
|
+
/**
|
|
1611
|
+
* = Slot Radius
|
|
1612
|
+
*/
|
|
1613
|
+
SLOT_RADIUS: "SLOT_RADIUS",
|
|
1614
|
+
/**
|
|
1615
|
+
* = Slot Port - Slot Start
|
|
1616
|
+
*/
|
|
1617
|
+
SLOT_PORT_DISTANCE: "SLOT_PORT_DISTANCE",
|
|
1618
|
+
/**
|
|
1619
|
+
* = Slot Label - Slot Start
|
|
1620
|
+
*/
|
|
1621
|
+
SLOT_LABEL_DISTANCE: "SLOT_LABEL_DISTANCE",
|
|
1622
|
+
/**
|
|
1623
|
+
* = Slot Block - Slot Port
|
|
1624
|
+
*/
|
|
1625
|
+
SLOT_BLOCK_PORT_DISTANCE: "SLOT_BLOCK_PORT_DISTANCE",
|
|
1626
|
+
/**
|
|
1627
|
+
* Vertical Layout: Slot Block - Slot Block
|
|
1628
|
+
*/
|
|
1629
|
+
SLOT_BLOCK_VERTICAL_SPACING: "SLOT_BLOCK_VERTICAL_SPACING"
|
|
1630
|
+
};
|
|
1631
|
+
var SLOT_START_DISTANCE = 16;
|
|
1632
|
+
var SLOT_PORT_DISTANCE = 100;
|
|
1633
|
+
var SLOT_LABEL_DISTANCE = 32;
|
|
1634
|
+
var SLOT_BLOCK_PORT_DISTANCE = 32.5;
|
|
1635
|
+
var SLOT_RADIUS = 16;
|
|
1636
|
+
var SLOT_SPACING = 32;
|
|
1637
|
+
var SLOT_BLOCK_VERTICAL_SPACING = 32.5;
|
|
1638
|
+
var SLOT_NODE_LAST_SPACING = 10;
|
|
1639
|
+
var SlotNodeType = ((SlotNodeType2) => {
|
|
1640
|
+
SlotNodeType2[SlotNodeType2["Slot"] = FlowNodeBaseType.SLOT] = "Slot";
|
|
1641
|
+
SlotNodeType2[SlotNodeType2["SlotBlock"] = FlowNodeBaseType.SLOT_BLOCK] = "SlotBlock";
|
|
1642
|
+
SlotNodeType2["SlotInlineBlocks"] = "slotInlineBlocks";
|
|
1643
|
+
SlotNodeType2["SlotBlockInlineBlocks"] = "slotBlockInlineBlocks";
|
|
1644
|
+
return SlotNodeType2;
|
|
1645
|
+
})(SlotNodeType || {});
|
|
1646
|
+
|
|
1647
|
+
// src/activities/slot/utils/node.ts
|
|
1648
|
+
var canSlotDrilldown = (Slot) => !!Slot?.lastCollapsedChild?.blocks.length;
|
|
1649
|
+
var insideSlot = (entity) => !!entity?.parent?.isTypeOrExtendType(SlotNodeType.SlotBlock);
|
|
1650
|
+
var getDisplayFirstChildTransform = (transform) => {
|
|
1651
|
+
if (transform.firstChild) {
|
|
1652
|
+
return getDisplayFirstChildTransform(transform.firstChild);
|
|
1653
|
+
}
|
|
1654
|
+
return transform;
|
|
1655
|
+
};
|
|
1656
|
+
|
|
1657
|
+
// src/activities/slot/utils/transition.ts
|
|
1658
|
+
var getSlotChildLineStartPoint = (iconTransform) => {
|
|
1659
|
+
if (!iconTransform) {
|
|
1660
|
+
return { x: 0, y: 0 };
|
|
1661
|
+
}
|
|
1662
|
+
const startDistance = getDefaultSpacing(
|
|
1663
|
+
iconTransform.entity,
|
|
1664
|
+
SlotSpacingKey.SLOT_START_DISTANCE,
|
|
1665
|
+
SLOT_START_DISTANCE
|
|
1666
|
+
);
|
|
1667
|
+
if (!iconTransform.entity.isVertical) {
|
|
1668
|
+
return {
|
|
1669
|
+
x: iconTransform?.bounds.center.x,
|
|
1670
|
+
y: iconTransform?.bounds.bottom + startDistance
|
|
1671
|
+
};
|
|
1672
|
+
}
|
|
1673
|
+
return {
|
|
1674
|
+
x: iconTransform?.bounds.right + startDistance,
|
|
1675
|
+
y: iconTransform?.bounds.center.y
|
|
1676
|
+
};
|
|
1677
|
+
};
|
|
1678
|
+
var getOutputPoint = (transform) => {
|
|
1679
|
+
const icon = transform.firstChild;
|
|
1680
|
+
if (!icon) {
|
|
1681
|
+
return { x: 0, y: 0 };
|
|
1682
|
+
}
|
|
1683
|
+
if (!transform.entity.isVertical) {
|
|
1684
|
+
return {
|
|
1685
|
+
x: transform.bounds.right,
|
|
1686
|
+
y: icon.outputPoint.y
|
|
1687
|
+
};
|
|
1688
|
+
}
|
|
1689
|
+
return {
|
|
1690
|
+
x: icon.outputPoint.x,
|
|
1691
|
+
y: transform.bounds.bottom
|
|
1692
|
+
};
|
|
1693
|
+
};
|
|
1694
|
+
var getInputPoint = (transform) => {
|
|
1695
|
+
const icon = transform.firstChild;
|
|
1696
|
+
if (!icon) {
|
|
1697
|
+
return { x: 0, y: 0 };
|
|
1698
|
+
}
|
|
1699
|
+
if (!transform.entity.isVertical) {
|
|
1700
|
+
return {
|
|
1701
|
+
x: transform.bounds.left,
|
|
1702
|
+
y: icon.outputPoint.y
|
|
1703
|
+
};
|
|
1704
|
+
}
|
|
1705
|
+
return icon.inputPoint;
|
|
1706
|
+
};
|
|
1707
|
+
var getTransitionToPoint = (transition) => {
|
|
1708
|
+
let toPoint = transition.transform.next?.inputPoint;
|
|
1709
|
+
const icon = transition.transform.firstChild;
|
|
1710
|
+
const parent = transition.transform.parent;
|
|
1711
|
+
if (!icon || !parent) {
|
|
1712
|
+
return { x: 0, y: 0 };
|
|
1713
|
+
}
|
|
1714
|
+
if (!transition.transform.next) {
|
|
1715
|
+
if (!transition.entity.isVertical) {
|
|
1716
|
+
toPoint = {
|
|
1717
|
+
x: parent.outputPoint.x,
|
|
1718
|
+
y: icon.outputPoint.y
|
|
1719
|
+
};
|
|
1720
|
+
} else {
|
|
1721
|
+
toPoint = {
|
|
1722
|
+
x: icon.outputPoint.x,
|
|
1723
|
+
y: parent.outputPoint.y
|
|
1724
|
+
};
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
return toPoint || { x: 0, y: 0 };
|
|
1728
|
+
};
|
|
1729
|
+
var drawStraightLine = (transition) => {
|
|
1730
|
+
const icon = transition.transform.firstChild;
|
|
1731
|
+
const toPoint = getTransitionToPoint(transition);
|
|
1732
|
+
if (!icon) {
|
|
1733
|
+
return [];
|
|
1734
|
+
}
|
|
1735
|
+
return [
|
|
1736
|
+
{
|
|
1737
|
+
type: FlowTransitionLineEnum.STRAIGHT_LINE,
|
|
1738
|
+
from: icon.outputPoint,
|
|
1739
|
+
to: toPoint
|
|
1740
|
+
},
|
|
1741
|
+
{
|
|
1742
|
+
type: FlowTransitionLineEnum.STRAIGHT_LINE,
|
|
1743
|
+
from: icon.inputPoint,
|
|
1744
|
+
to: transition.transform.inputPoint
|
|
1745
|
+
}
|
|
1746
|
+
];
|
|
1747
|
+
};
|
|
1748
|
+
var drawCollapseLabel = (transition) => {
|
|
1749
|
+
const icon = transition.transform;
|
|
1750
|
+
return [
|
|
1751
|
+
{
|
|
1752
|
+
type: FlowTransitionLabelEnum.CUSTOM_LABEL,
|
|
1753
|
+
renderKey: RENDER_SLOT_COLLAPSE_KEY,
|
|
1754
|
+
offset: getSlotChildLineStartPoint(icon),
|
|
1755
|
+
props: {
|
|
1756
|
+
node: transition.entity.parent
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
];
|
|
1760
|
+
};
|
|
1761
|
+
var drawCollapseLine = (transition) => {
|
|
1762
|
+
const startDistance = getDefaultSpacing(
|
|
1763
|
+
transition.transform.entity,
|
|
1764
|
+
SlotSpacingKey.SLOT_START_DISTANCE,
|
|
1765
|
+
SLOT_START_DISTANCE
|
|
1766
|
+
);
|
|
1767
|
+
return [
|
|
1768
|
+
{
|
|
1769
|
+
type: FlowTransitionLineEnum.STRAIGHT_LINE,
|
|
1770
|
+
from: getSlotChildLineStartPoint(transition.transform),
|
|
1771
|
+
to: Point.move(
|
|
1772
|
+
getSlotChildLineStartPoint(transition.transform),
|
|
1773
|
+
transition.entity.isVertical ? { x: -startDistance, y: 0 } : { x: 0, y: -startDistance }
|
|
1774
|
+
),
|
|
1775
|
+
style: {
|
|
1776
|
+
strokeDasharray: "5 5"
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
];
|
|
1780
|
+
};
|
|
1781
|
+
var drawStraightAdder = (transition) => {
|
|
1782
|
+
const toPoint = getTransitionToPoint(transition);
|
|
1783
|
+
const fromPoint = transition.transform.firstChild.outputPoint;
|
|
1784
|
+
const hoverProps = transition.entity.isVertical ? {
|
|
1785
|
+
hoverHeight: toPoint.y - fromPoint.y,
|
|
1786
|
+
hoverWidth: transition.transform.firstChild?.bounds.width
|
|
1787
|
+
} : {
|
|
1788
|
+
hoverHeight: transition.transform.firstChild?.bounds.height,
|
|
1789
|
+
hoverWidth: toPoint.x - fromPoint.x
|
|
1790
|
+
};
|
|
1791
|
+
return [
|
|
1792
|
+
{
|
|
1793
|
+
offset: Point.getMiddlePoint(fromPoint, toPoint),
|
|
1794
|
+
type: FlowTransitionLabelEnum.ADDER_LABEL,
|
|
1795
|
+
props: hoverProps
|
|
1796
|
+
}
|
|
1797
|
+
];
|
|
1798
|
+
};
|
|
1799
|
+
var getPortChildInput = (_child) => {
|
|
1800
|
+
if (!_child) {
|
|
1801
|
+
return { x: 0, y: 0 };
|
|
1802
|
+
}
|
|
1803
|
+
const firstChild = getDisplayFirstChildTransform(_child);
|
|
1804
|
+
return { x: _child.bounds.left, y: firstChild.bounds.center.y };
|
|
1805
|
+
};
|
|
1806
|
+
var getDisplayFirstChildTop = (transform) => {
|
|
1807
|
+
if (transform.firstChild) {
|
|
1808
|
+
return transform.localBounds.top + getDisplayFirstChildTop(transform.firstChild);
|
|
1809
|
+
}
|
|
1810
|
+
return transform.localBounds.center.y;
|
|
1811
|
+
};
|
|
1812
|
+
var getPortMiddle = (_port) => {
|
|
1813
|
+
if (!_port.children.length) {
|
|
1814
|
+
return _port.localBounds.top;
|
|
1815
|
+
}
|
|
1816
|
+
const portChildInputs = [_port.firstChild, _port.lastChild].map(
|
|
1817
|
+
(_portChild) => getDisplayFirstChildTop(_portChild)
|
|
1818
|
+
);
|
|
1819
|
+
return _port.localBounds.top + mean(portChildInputs);
|
|
1820
|
+
};
|
|
1821
|
+
var getAllPortsMiddle = (inlineBlocks) => {
|
|
1822
|
+
if (!inlineBlocks.children.length) {
|
|
1823
|
+
return inlineBlocks.localBounds.height / 2;
|
|
1824
|
+
}
|
|
1825
|
+
const portInputs = [inlineBlocks.firstChild, inlineBlocks.lastChild].map(
|
|
1826
|
+
(_port) => getPortMiddle(_port)
|
|
1827
|
+
);
|
|
1828
|
+
return mean(portInputs);
|
|
1829
|
+
};
|
|
1830
|
+
var createSlotFromJSON = (node, json) => {
|
|
1831
|
+
const { document } = node;
|
|
1832
|
+
const addedNodes = [];
|
|
1833
|
+
const blockIconNode = document.addNode({
|
|
1834
|
+
id: `$slotIcon$${node.id}`,
|
|
1835
|
+
type: FlowNodeBaseType.BLOCK_ICON,
|
|
1836
|
+
originParent: node,
|
|
1837
|
+
parent: node
|
|
1838
|
+
});
|
|
1839
|
+
const inlineBlocksNode = document.addNode({
|
|
1840
|
+
id: `$slotInlineBlocks$${node.id}`,
|
|
1841
|
+
type: "slotInlineBlocks" /* SlotInlineBlocks */,
|
|
1842
|
+
originParent: node,
|
|
1843
|
+
parent: node
|
|
1844
|
+
});
|
|
1845
|
+
addedNodes.push(blockIconNode);
|
|
1846
|
+
addedNodes.push(inlineBlocksNode);
|
|
1847
|
+
const portJSONList = json.blocks || [];
|
|
1848
|
+
portJSONList.forEach((_portJSON) => {
|
|
1849
|
+
const port = document.addNode({
|
|
1850
|
+
type: SlotNodeType.SlotBlock,
|
|
1851
|
+
..._portJSON,
|
|
1852
|
+
originParent: node,
|
|
1853
|
+
parent: inlineBlocksNode
|
|
1854
|
+
});
|
|
1855
|
+
addedNodes.push(port);
|
|
1856
|
+
(_portJSON.blocks || []).forEach((_portChild) => {
|
|
1857
|
+
document.addNode(
|
|
1858
|
+
{
|
|
1859
|
+
type: SlotNodeType.Slot,
|
|
1860
|
+
..._portChild,
|
|
1861
|
+
parent: port
|
|
1862
|
+
},
|
|
1863
|
+
addedNodes
|
|
1864
|
+
);
|
|
1865
|
+
});
|
|
1866
|
+
});
|
|
1867
|
+
return addedNodes;
|
|
1868
|
+
};
|
|
1869
|
+
var SlotIconRegistry = {
|
|
1870
|
+
type: FlowNodeBaseType.BLOCK_ICON,
|
|
1871
|
+
meta: {
|
|
1872
|
+
defaultExpanded: false,
|
|
1873
|
+
spacing: 0
|
|
1874
|
+
},
|
|
1875
|
+
getLines: (transition) => [
|
|
1876
|
+
...canSlotDrilldown(transition.entity.parent) ? drawCollapseLine(transition) : []
|
|
1877
|
+
],
|
|
1878
|
+
getLabels: (transition) => [
|
|
1879
|
+
...canSlotDrilldown(transition.entity.parent) ? drawCollapseLabel(transition) : []
|
|
1880
|
+
],
|
|
1881
|
+
getDelta: (transform) => {
|
|
1882
|
+
if (insideSlot(transform.entity.parent)) {
|
|
1883
|
+
return transform.entity.isVertical ? { x: -transform.originDeltaX, y: 0 } : { x: 0, y: -transform.originDeltaY };
|
|
1884
|
+
}
|
|
1885
|
+
return { x: 0, y: 0 };
|
|
1886
|
+
}
|
|
1887
|
+
};
|
|
1888
|
+
var SlotInlineBlocksRegistry = {
|
|
1889
|
+
type: "slotInlineBlocks" /* SlotInlineBlocks */,
|
|
1890
|
+
extend: FlowNodeBaseType.BLOCK,
|
|
1891
|
+
meta: {
|
|
1892
|
+
spacing: 0,
|
|
1893
|
+
inlineSpacingPre: 0,
|
|
1894
|
+
inlineSpacingAfter: 0,
|
|
1895
|
+
isInlineBlocks: (node) => !node.isVertical
|
|
1896
|
+
},
|
|
1897
|
+
getLines() {
|
|
1898
|
+
return [];
|
|
1899
|
+
},
|
|
1900
|
+
getLabels() {
|
|
1901
|
+
return [];
|
|
1902
|
+
},
|
|
1903
|
+
getChildDelta(child, layout) {
|
|
1904
|
+
if (child.entity.isVertical) {
|
|
1905
|
+
return { x: 0, y: 0 };
|
|
1906
|
+
}
|
|
1907
|
+
const preTransform = child.entity.pre?.getData(FlowNodeTransformData);
|
|
1908
|
+
if (preTransform) {
|
|
1909
|
+
const { localBounds: preBounds } = preTransform;
|
|
1910
|
+
return {
|
|
1911
|
+
x: 0,
|
|
1912
|
+
y: preBounds.bottom + 30
|
|
1913
|
+
};
|
|
1914
|
+
}
|
|
1915
|
+
return { x: 0, y: 0 };
|
|
1916
|
+
},
|
|
1917
|
+
/**
|
|
1918
|
+
* 控制条件分支居右布局
|
|
1919
|
+
*/
|
|
1920
|
+
getDelta(transform) {
|
|
1921
|
+
if (!transform.children.length) {
|
|
1922
|
+
return { x: 0, y: 0 };
|
|
1923
|
+
}
|
|
1924
|
+
const icon = transform.pre;
|
|
1925
|
+
if (!icon) {
|
|
1926
|
+
return { x: 0, y: 0 };
|
|
1927
|
+
}
|
|
1928
|
+
const startDistance = getDefaultSpacing(
|
|
1929
|
+
transform.entity,
|
|
1930
|
+
SlotSpacingKey.SLOT_START_DISTANCE,
|
|
1931
|
+
SLOT_START_DISTANCE
|
|
1932
|
+
);
|
|
1933
|
+
const portDistance = getDefaultSpacing(
|
|
1934
|
+
transform.entity,
|
|
1935
|
+
SlotSpacingKey.SLOT_PORT_DISTANCE,
|
|
1936
|
+
SLOT_PORT_DISTANCE
|
|
1937
|
+
);
|
|
1938
|
+
const portBlockDistance = getDefaultSpacing(
|
|
1939
|
+
transform.entity,
|
|
1940
|
+
SlotSpacingKey.SLOT_BLOCK_PORT_DISTANCE,
|
|
1941
|
+
SLOT_BLOCK_PORT_DISTANCE
|
|
1942
|
+
);
|
|
1943
|
+
if (!transform.entity.isVertical) {
|
|
1944
|
+
const noChildren = transform?.children?.every?.((_port) => !_port.children.length);
|
|
1945
|
+
if (noChildren) {
|
|
1946
|
+
return {
|
|
1947
|
+
x: portDistance - icon.localBounds.width / 2,
|
|
1948
|
+
y: icon.localBounds.bottom + startDistance
|
|
1949
|
+
};
|
|
1950
|
+
}
|
|
1951
|
+
return {
|
|
1952
|
+
x: portDistance + portBlockDistance - icon.localBounds.width / 2,
|
|
1953
|
+
y: icon.localBounds.bottom + startDistance
|
|
1954
|
+
};
|
|
1955
|
+
}
|
|
1956
|
+
const slotInlineBlockDelta = startDistance + portDistance + portBlockDistance;
|
|
1957
|
+
return {
|
|
1958
|
+
x: icon.localBounds.right + slotInlineBlockDelta,
|
|
1959
|
+
y: -icon.localBounds.height
|
|
1960
|
+
};
|
|
1961
|
+
}
|
|
1962
|
+
};
|
|
1963
|
+
var SlotBlockRegistry = {
|
|
1964
|
+
type: SlotNodeType.SlotBlock,
|
|
1965
|
+
extend: FlowNodeBaseType.BLOCK,
|
|
1966
|
+
meta: {
|
|
1967
|
+
inlineSpacingAfter: 0,
|
|
1968
|
+
inlineSpacingPre: 0,
|
|
1969
|
+
spacing: (transform) => {
|
|
1970
|
+
if (!transform.entity.isVertical && transform.size.width === 0) {
|
|
1971
|
+
return 90;
|
|
1972
|
+
}
|
|
1973
|
+
return getDefaultSpacing(
|
|
1974
|
+
transform.entity,
|
|
1975
|
+
SlotSpacingKey.SLOT_BLOCK_VERTICAL_SPACING,
|
|
1976
|
+
SLOT_BLOCK_VERTICAL_SPACING
|
|
1977
|
+
);
|
|
1978
|
+
},
|
|
1979
|
+
isInlineBlocks: (node) => !node.isVertical
|
|
1980
|
+
},
|
|
1981
|
+
getLines(transition) {
|
|
1982
|
+
const icon = transition.transform.parent?.pre;
|
|
1983
|
+
const start = getSlotChildLineStartPoint(icon);
|
|
1984
|
+
const portPoint = transition.transform.inputPoint;
|
|
1985
|
+
const radius = getDefaultSpacing(
|
|
1986
|
+
transition.transform.entity,
|
|
1987
|
+
SlotSpacingKey.SLOT_RADIUS,
|
|
1988
|
+
SLOT_RADIUS
|
|
1989
|
+
);
|
|
1990
|
+
let startPortVertices = [{ x: start.x, y: portPoint.y }];
|
|
1991
|
+
if (transition.entity.isVertical) {
|
|
1992
|
+
const deltaY = Math.abs(portPoint.y - start.y);
|
|
1993
|
+
let deltaX = radius;
|
|
1994
|
+
let isTruncated = false;
|
|
1995
|
+
if (deltaY < radius * 2) {
|
|
1996
|
+
isTruncated = true;
|
|
1997
|
+
if (deltaY < radius) {
|
|
1998
|
+
deltaX = Math.sqrt(radius ** 2 - (radius - deltaY) ** 2);
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
startPortVertices = [
|
|
2002
|
+
{
|
|
2003
|
+
x: start.x + deltaX,
|
|
2004
|
+
y: start.y,
|
|
2005
|
+
radiusX: radius,
|
|
2006
|
+
radiusY: radius,
|
|
2007
|
+
radiusOverflow: "truncate"
|
|
2008
|
+
},
|
|
2009
|
+
{
|
|
2010
|
+
x: start.x + deltaX,
|
|
2011
|
+
y: portPoint.y,
|
|
2012
|
+
...isTruncated ? { radiusX: 0, radiusY: 0 } : {}
|
|
2013
|
+
}
|
|
2014
|
+
];
|
|
2015
|
+
}
|
|
2016
|
+
if (transition.transform.children.length === 1) {
|
|
2017
|
+
return [
|
|
2018
|
+
{
|
|
2019
|
+
type: FlowTransitionLineEnum.ROUNDED_LINE,
|
|
2020
|
+
from: start,
|
|
2021
|
+
to: getPortChildInput(transition.transform.children[0]),
|
|
2022
|
+
vertices: startPortVertices,
|
|
2023
|
+
style: {
|
|
2024
|
+
strokeDasharray: "5 5"
|
|
2025
|
+
},
|
|
2026
|
+
radius
|
|
2027
|
+
}
|
|
2028
|
+
];
|
|
2029
|
+
}
|
|
2030
|
+
return [
|
|
2031
|
+
{
|
|
2032
|
+
type: FlowTransitionLineEnum.ROUNDED_LINE,
|
|
2033
|
+
from: start,
|
|
2034
|
+
to: portPoint,
|
|
2035
|
+
vertices: startPortVertices,
|
|
2036
|
+
style: {
|
|
2037
|
+
strokeDasharray: "5 5"
|
|
2038
|
+
},
|
|
2039
|
+
radius
|
|
2040
|
+
},
|
|
2041
|
+
...transition.transform.children.map((_child) => {
|
|
2042
|
+
const childInput = getPortChildInput(_child);
|
|
2043
|
+
return {
|
|
2044
|
+
type: FlowTransitionLineEnum.ROUNDED_LINE,
|
|
2045
|
+
radius,
|
|
2046
|
+
from: portPoint,
|
|
2047
|
+
to: childInput,
|
|
2048
|
+
vertices: [{ x: portPoint.x, y: childInput.y }],
|
|
2049
|
+
style: {
|
|
2050
|
+
strokeDasharray: "5 5"
|
|
2051
|
+
}
|
|
2052
|
+
};
|
|
2053
|
+
})
|
|
2054
|
+
];
|
|
2055
|
+
},
|
|
2056
|
+
getLabels(transition) {
|
|
2057
|
+
const icon = transition.transform.parent?.pre;
|
|
2058
|
+
const start = getSlotChildLineStartPoint(icon);
|
|
2059
|
+
const portPoint = transition.transform.inputPoint;
|
|
2060
|
+
return [
|
|
2061
|
+
{
|
|
2062
|
+
type: FlowTransitionLabelEnum.CUSTOM_LABEL,
|
|
2063
|
+
renderKey: RENDER_SLOT_ADDER_KEY,
|
|
2064
|
+
props: {
|
|
2065
|
+
node: transition.entity
|
|
2066
|
+
},
|
|
2067
|
+
offset: portPoint
|
|
2068
|
+
},
|
|
2069
|
+
{
|
|
2070
|
+
type: FlowTransitionLabelEnum.CUSTOM_LABEL,
|
|
2071
|
+
renderKey: RENDER_SLOT_LABEL_KEY,
|
|
2072
|
+
props: {
|
|
2073
|
+
node: transition.entity
|
|
2074
|
+
},
|
|
2075
|
+
offset: {
|
|
2076
|
+
x: start.x + getDefaultSpacing(
|
|
2077
|
+
transition.entity,
|
|
2078
|
+
SlotSpacingKey.SLOT_LABEL_DISTANCE,
|
|
2079
|
+
SLOT_LABEL_DISTANCE
|
|
2080
|
+
),
|
|
2081
|
+
y: portPoint.y
|
|
2082
|
+
},
|
|
2083
|
+
origin: [0, 0.5]
|
|
2084
|
+
}
|
|
2085
|
+
];
|
|
2086
|
+
},
|
|
2087
|
+
getInputPoint(transform) {
|
|
2088
|
+
const icon = transform.parent?.pre;
|
|
2089
|
+
const start = getSlotChildLineStartPoint(icon);
|
|
2090
|
+
let inputY = transform.bounds.center.y;
|
|
2091
|
+
if (transform.children.length) {
|
|
2092
|
+
inputY = mean([
|
|
2093
|
+
getPortChildInput(transform.firstChild).y,
|
|
2094
|
+
getPortChildInput(transform.lastChild).y
|
|
2095
|
+
]);
|
|
2096
|
+
}
|
|
2097
|
+
return {
|
|
2098
|
+
x: start.x + getDefaultSpacing(transform.entity, SlotSpacingKey.SLOT_PORT_DISTANCE, SLOT_PORT_DISTANCE),
|
|
2099
|
+
y: inputY
|
|
2100
|
+
};
|
|
2101
|
+
},
|
|
2102
|
+
getChildDelta(child, layout) {
|
|
2103
|
+
const hasChild = !!child.firstChild;
|
|
2104
|
+
if (child.entity.isVertical) {
|
|
2105
|
+
let deltaX = hasChild ? 0 : -child.originDeltaX;
|
|
2106
|
+
return { x: deltaX, y: 0 };
|
|
2107
|
+
}
|
|
2108
|
+
let deltaY = hasChild ? 0 : -child.originDeltaY;
|
|
2109
|
+
const preTransform = child.entity.pre?.getData(FlowNodeTransformData);
|
|
2110
|
+
if (preTransform) {
|
|
2111
|
+
const { localBounds: preBounds } = preTransform;
|
|
2112
|
+
return {
|
|
2113
|
+
x: 0,
|
|
2114
|
+
y: preBounds.bottom + 30 + deltaY
|
|
2115
|
+
};
|
|
2116
|
+
}
|
|
2117
|
+
return { x: 0, y: deltaY };
|
|
2118
|
+
},
|
|
2119
|
+
getChildLabels() {
|
|
2120
|
+
return [];
|
|
2121
|
+
},
|
|
2122
|
+
getChildLines() {
|
|
2123
|
+
return [];
|
|
2124
|
+
},
|
|
2125
|
+
getDelta(transform) {
|
|
2126
|
+
return {
|
|
2127
|
+
x: 0,
|
|
2128
|
+
y: 0
|
|
2129
|
+
};
|
|
2130
|
+
}
|
|
2131
|
+
};
|
|
2132
|
+
|
|
2133
|
+
// src/activities/slot/slot.ts
|
|
2134
|
+
var SlotRegistry = {
|
|
2135
|
+
type: FlowNodeBaseType.SLOT,
|
|
2136
|
+
extend: "block",
|
|
2137
|
+
meta: {
|
|
2138
|
+
// Slot 节点内部暂时不允许拖拽
|
|
2139
|
+
draggable: (node) => !insideSlot(node),
|
|
2140
|
+
hidden: true,
|
|
2141
|
+
spacing: (node) => getDefaultSpacing(node.entity, SlotSpacingKey.SLOT_SPACING, SLOT_SPACING),
|
|
2142
|
+
padding: (node) => ({
|
|
2143
|
+
left: 0,
|
|
2144
|
+
right: node.collapsed ? getDefaultSpacing(node.entity, SlotSpacingKey.SLOT_START_DISTANCE, SLOT_START_DISTANCE) : 0,
|
|
2145
|
+
bottom: !insideSlot(node.entity) && node.isLast ? SLOT_NODE_LAST_SPACING : 0,
|
|
2146
|
+
top: 0
|
|
2147
|
+
}),
|
|
2148
|
+
copyDisable: false,
|
|
2149
|
+
defaultExpanded: false
|
|
2150
|
+
},
|
|
2151
|
+
/**
|
|
2152
|
+
* 业务通常需要重载方法
|
|
2153
|
+
*/
|
|
2154
|
+
onCreate: createSlotFromJSON,
|
|
2155
|
+
getLines: (transition) => [
|
|
2156
|
+
...!insideSlot(transition.entity) ? drawStraightLine(transition) : []
|
|
2157
|
+
],
|
|
2158
|
+
getLabels: (transition) => [
|
|
2159
|
+
...!insideSlot(transition.entity) ? drawStraightAdder(transition) : []
|
|
2160
|
+
],
|
|
2161
|
+
getInputPoint,
|
|
2162
|
+
getOutputPoint,
|
|
2163
|
+
onAfterUpdateLocalTransform(transform) {
|
|
2164
|
+
const { isVertical } = transform.entity;
|
|
2165
|
+
if (!isVertical) {
|
|
2166
|
+
return;
|
|
2167
|
+
}
|
|
2168
|
+
const icon = transform.firstChild;
|
|
2169
|
+
const inlineBlocks = transform.lastChild;
|
|
2170
|
+
if (!icon || !inlineBlocks) {
|
|
2171
|
+
return;
|
|
2172
|
+
}
|
|
2173
|
+
const iconSize = icon.localBounds.height;
|
|
2174
|
+
const inlineBlocksSize = inlineBlocks.localBounds.height;
|
|
2175
|
+
if (transform.collapsed || !inlineBlocks) {
|
|
2176
|
+
return;
|
|
2177
|
+
}
|
|
2178
|
+
const portsMiddle = getAllPortsMiddle(inlineBlocks);
|
|
2179
|
+
icon.entity.clearMemoLocal();
|
|
2180
|
+
inlineBlocks.entity.clearMemoLocal();
|
|
2181
|
+
if (iconSize / 2 + portsMiddle > inlineBlocksSize || !inlineBlocks.children.length) {
|
|
2182
|
+
icon.transform.update({
|
|
2183
|
+
position: { x: icon.transform.position.x, y: 0 }
|
|
2184
|
+
});
|
|
2185
|
+
inlineBlocks.transform.update({
|
|
2186
|
+
position: {
|
|
2187
|
+
x: inlineBlocks.transform.position.x,
|
|
2188
|
+
y: Math.max(iconSize / 2 - inlineBlocksSize / 2, 0)
|
|
2189
|
+
}
|
|
2190
|
+
});
|
|
2191
|
+
return;
|
|
2192
|
+
}
|
|
2193
|
+
inlineBlocks.transform.update({
|
|
2194
|
+
position: { x: inlineBlocks.transform.position.x, y: 0 }
|
|
2195
|
+
});
|
|
2196
|
+
icon?.transform.update({
|
|
2197
|
+
position: {
|
|
2198
|
+
x: icon.transform.position.x,
|
|
2199
|
+
y: Math.max(portsMiddle - iconSize / 2, 0)
|
|
2200
|
+
// 所有 port 的中间点
|
|
2201
|
+
}
|
|
2202
|
+
});
|
|
2203
|
+
},
|
|
2204
|
+
extendChildRegistries: [SlotIconRegistry, SlotInlineBlocksRegistry]
|
|
2205
|
+
};
|
|
2206
|
+
|
|
2207
|
+
// src/flow-registers.ts
|
|
2208
|
+
var FlowRegisters = class {
|
|
2209
|
+
/**
|
|
2210
|
+
* 注册数据层
|
|
2211
|
+
* @param document
|
|
2212
|
+
*/
|
|
2213
|
+
registerDocument(document) {
|
|
2214
|
+
document.registerFlowNodes(
|
|
2215
|
+
RootRegistry,
|
|
2216
|
+
// 根节点
|
|
2217
|
+
StartRegistry,
|
|
2218
|
+
// 开始节点
|
|
2219
|
+
DynamicSplitRegistry,
|
|
2220
|
+
// 动态分支(并行、排他)
|
|
2221
|
+
StaticSplitRegistry,
|
|
2222
|
+
// 静态分支(审批)
|
|
2223
|
+
SimpleSplitRegistry,
|
|
2224
|
+
// 简单分支 (不带 orderIcon 节点)
|
|
2225
|
+
BlockRegistry,
|
|
2226
|
+
// 单条 block 注册
|
|
2227
|
+
InlineBlocksRegistry,
|
|
2228
|
+
// 多个 block 组成的 block 列表
|
|
2229
|
+
BlockIconRegistry,
|
|
2230
|
+
// icon 节点,如条件分支的菱形图标
|
|
2231
|
+
BlockOrderIconRegistry,
|
|
2232
|
+
// 带顺序的图标节点,一般为 block 第一个分支节点
|
|
2233
|
+
TryCatchRegistry,
|
|
2234
|
+
// TryCatch
|
|
2235
|
+
EndRegistry,
|
|
2236
|
+
// 结束节点
|
|
2237
|
+
LoopRegistry,
|
|
2238
|
+
// 循环节点
|
|
2239
|
+
EmptyRegistry,
|
|
2240
|
+
// 占位节点
|
|
2241
|
+
BreakRegistry,
|
|
2242
|
+
// 分支断开
|
|
2243
|
+
MultiOuputsRegistry,
|
|
2244
|
+
MultiInputsRegistry,
|
|
2245
|
+
InputRegistry,
|
|
2246
|
+
OuputRegistry,
|
|
2247
|
+
SlotRegistry,
|
|
2248
|
+
SlotBlockRegistry
|
|
2249
|
+
);
|
|
2250
|
+
document.registerNodeDatas(
|
|
2251
|
+
FlowNodeRenderData,
|
|
2252
|
+
// 渲染节点相关数据
|
|
2253
|
+
FlowNodeTransitionData,
|
|
2254
|
+
// 线条绘制数据
|
|
2255
|
+
FlowNodeTransformData
|
|
2256
|
+
// 坐标计算数据
|
|
2257
|
+
);
|
|
2258
|
+
}
|
|
2259
|
+
/**
|
|
2260
|
+
* 注册渲染层
|
|
2261
|
+
* @param renderer
|
|
2262
|
+
*/
|
|
2263
|
+
registerRenderer(renderer) {
|
|
2264
|
+
renderer.registerLayers(
|
|
2265
|
+
FlowNodesTransformLayer,
|
|
2266
|
+
// 节点位置渲染
|
|
2267
|
+
FlowNodesContentLayer,
|
|
2268
|
+
// 节点内容渲染
|
|
2269
|
+
FlowLinesLayer,
|
|
2270
|
+
// 线条渲染
|
|
2271
|
+
FlowLabelsLayer,
|
|
2272
|
+
// Label 渲染
|
|
2273
|
+
PlaygroundLayer
|
|
2274
|
+
// 画布基础层,提供缩放、手势等能力
|
|
2275
|
+
);
|
|
2276
|
+
}
|
|
2277
|
+
/**
|
|
2278
|
+
* 画布开始渲染 (hook)
|
|
2279
|
+
*/
|
|
2280
|
+
onReady() {
|
|
2281
|
+
}
|
|
2282
|
+
/**
|
|
2283
|
+
* 画布销毁 (hook)
|
|
2284
|
+
*/
|
|
2285
|
+
onDispose() {
|
|
2286
|
+
}
|
|
2287
|
+
};
|
|
2288
|
+
FlowRegisters = __decorateClass([
|
|
2289
|
+
injectable()
|
|
2290
|
+
], FlowRegisters);
|
|
2291
|
+
|
|
2292
|
+
// src/fixed-layout-container-module.ts
|
|
2293
|
+
var FixedLayoutContainerModule = new ContainerModule((bind) => {
|
|
2294
|
+
bindContributions(bind, FlowRegisters, [
|
|
2295
|
+
FlowDocumentContribution,
|
|
2296
|
+
FlowRendererContribution,
|
|
2297
|
+
PlaygroundContribution
|
|
2298
|
+
]);
|
|
2299
|
+
});
|
|
2300
|
+
|
|
2301
|
+
// src/index.ts
|
|
2302
|
+
var FixedLayoutRegistries = {
|
|
2303
|
+
BlockIconRegistry,
|
|
2304
|
+
BlockOrderIconRegistry,
|
|
2305
|
+
BlockRegistry,
|
|
2306
|
+
DynamicSplitRegistry,
|
|
2307
|
+
EmptyRegistry,
|
|
2308
|
+
LoopRegistry,
|
|
2309
|
+
StaticSplitRegistry,
|
|
2310
|
+
TryCatchRegistry,
|
|
2311
|
+
StartRegistry,
|
|
2312
|
+
RootRegistry,
|
|
2313
|
+
InlineBlocksRegistry,
|
|
2314
|
+
EndRegistry,
|
|
2315
|
+
SlotRegistry,
|
|
2316
|
+
SlotBlockRegistry,
|
|
2317
|
+
SlotIconRegistry,
|
|
2318
|
+
SlotInlineBlocksRegistry
|
|
2319
|
+
};
|
|
2320
|
+
|
|
2321
|
+
export { FixedLayoutContainerModule, FixedLayoutRegistries, SlotSpacingKey };
|
|
2322
|
+
//# sourceMappingURL=index.js.map
|
|
2323
|
+
//# sourceMappingURL=index.js.map
|