@flowgram.ai/fixed-layout-core 0.1.0-alpha.6 → 0.1.0-alpha.8
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/dist/esm/index.js +372 -46
- package/dist/esm/index.js.map +1 -1
- package/dist/index.js +368 -61
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
package/dist/esm/index.js
CHANGED
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
FlowScrollLimitLayer
|
|
28
28
|
} from "@flowgram.ai/renderer";
|
|
29
29
|
import {
|
|
30
|
-
FlowNodeRenderData as
|
|
30
|
+
FlowNodeRenderData as FlowNodeRenderData4,
|
|
31
31
|
FlowNodeTransformData as FlowNodeTransformData3,
|
|
32
32
|
FlowNodeTransitionData
|
|
33
33
|
} from "@flowgram.ai/document";
|
|
@@ -86,12 +86,14 @@ var DynamicSplitRegistry = {
|
|
|
86
86
|
return node.document.addInlineBlocks(node, json.blocks || []);
|
|
87
87
|
},
|
|
88
88
|
getInputPoint(transform) {
|
|
89
|
-
|
|
89
|
+
var _a;
|
|
90
|
+
return ((_a = transform.firstChild) == null ? void 0 : _a.inputPoint) || transform.defaultInputPoint;
|
|
90
91
|
},
|
|
91
92
|
getOutputPoint(transform, layout) {
|
|
93
|
+
var _a;
|
|
92
94
|
const isVertical = FlowLayoutDefault.isVertical(layout);
|
|
93
95
|
const noInlineBlocks = transform.children.length === 1;
|
|
94
|
-
const lastChildOutput = transform.lastChild
|
|
96
|
+
const lastChildOutput = (_a = transform.lastChild) == null ? void 0 : _a.outputPoint;
|
|
95
97
|
const spacing = getDefaultSpacing(transform.entity, ConstantKeys.NODE_SPACING);
|
|
96
98
|
if (isVertical) {
|
|
97
99
|
return {
|
|
@@ -104,6 +106,9 @@ var DynamicSplitRegistry = {
|
|
|
104
106
|
y: lastChildOutput ? lastChildOutput.y : transform.bounds.center.y
|
|
105
107
|
};
|
|
106
108
|
},
|
|
109
|
+
/**
|
|
110
|
+
* @depreacted
|
|
111
|
+
*/
|
|
107
112
|
addChild(node, json, options = {}) {
|
|
108
113
|
const { index } = options;
|
|
109
114
|
const document = node.document;
|
|
@@ -153,6 +158,7 @@ var BlockRegistry = {
|
|
|
153
158
|
hidden: true
|
|
154
159
|
},
|
|
155
160
|
getLines(transition) {
|
|
161
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
156
162
|
const currentTransform = transition.transform;
|
|
157
163
|
const { isVertical } = transition.entity;
|
|
158
164
|
const lines = [
|
|
@@ -166,10 +172,10 @@ var BlockRegistry = {
|
|
|
166
172
|
const hasBranchDraggingAdder = currentTransform && currentTransform.entity.isInlineBlock && transition.renderData.draggable;
|
|
167
173
|
if (hasBranchDraggingAdder) {
|
|
168
174
|
if (isVertical) {
|
|
169
|
-
const currentOffsetRightX = currentTransform.firstChild
|
|
170
|
-
const nextOffsetLeftX = currentTransform.next
|
|
175
|
+
const currentOffsetRightX = currentTransform.firstChild ? currentTransform.firstChild.bounds.right : currentTransform.bounds.right;
|
|
176
|
+
const nextOffsetLeftX = (((_a = currentTransform.next) == null ? void 0 : _a.firstChild) ? (_c = (_b = currentTransform.next) == null ? void 0 : _b.firstChild.bounds) == null ? void 0 : _c.left : (_e = (_d = currentTransform.next) == null ? void 0 : _d.bounds) == null ? void 0 : _e.left) || 0;
|
|
171
177
|
const currentInputPointY = currentTransform.inputPoint.y;
|
|
172
|
-
if (currentTransform
|
|
178
|
+
if (currentTransform == null ? void 0 : currentTransform.next) {
|
|
173
179
|
lines.push({
|
|
174
180
|
type: FlowTransitionLineEnum.DRAGGING_LINE,
|
|
175
181
|
from: currentTransform.parent.inputPoint,
|
|
@@ -181,16 +187,16 @@ var BlockRegistry = {
|
|
|
181
187
|
});
|
|
182
188
|
}
|
|
183
189
|
} else {
|
|
184
|
-
const
|
|
185
|
-
const
|
|
190
|
+
const currentOffsetBottomX = currentTransform.firstChild ? currentTransform.firstChild.bounds.bottom : currentTransform.bounds.bottom;
|
|
191
|
+
const nextOffsetTopX = (((_f = currentTransform.next) == null ? void 0 : _f.firstChild) ? (_h = (_g = currentTransform.next) == null ? void 0 : _g.firstChild.bounds) == null ? void 0 : _h.top : (_j = (_i = currentTransform.next) == null ? void 0 : _i.bounds) == null ? void 0 : _j.top) || 0;
|
|
186
192
|
const currentInputPointX = currentTransform.inputPoint.x;
|
|
187
|
-
if (currentTransform
|
|
193
|
+
if (currentTransform == null ? void 0 : currentTransform.next) {
|
|
188
194
|
lines.push({
|
|
189
195
|
type: FlowTransitionLineEnum.DRAGGING_LINE,
|
|
190
196
|
from: currentTransform.parent.inputPoint,
|
|
191
197
|
to: {
|
|
192
198
|
x: currentInputPointX,
|
|
193
|
-
y: (
|
|
199
|
+
y: (currentOffsetBottomX + nextOffsetTopX) / 2
|
|
194
200
|
},
|
|
195
201
|
side: LABEL_SIDE_TYPE.NORMAL_BRANCH
|
|
196
202
|
});
|
|
@@ -226,16 +232,17 @@ var BlockRegistry = {
|
|
|
226
232
|
};
|
|
227
233
|
},
|
|
228
234
|
getLabels(transition) {
|
|
235
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
229
236
|
const currentTransform = transition.transform;
|
|
230
237
|
const { isVertical } = transition.entity;
|
|
231
238
|
const draggingLabel = [];
|
|
232
239
|
const hasBranchDraggingAdder = currentTransform && currentTransform.entity.isInlineBlock && transition.renderData.draggable;
|
|
233
240
|
if (hasBranchDraggingAdder) {
|
|
234
241
|
if (isVertical) {
|
|
235
|
-
const currentOffsetRightX = currentTransform.firstChild
|
|
236
|
-
const nextOffsetLeftX = currentTransform.next
|
|
242
|
+
const currentOffsetRightX = currentTransform.firstChild ? currentTransform.firstChild.bounds.right : currentTransform.bounds.right;
|
|
243
|
+
const nextOffsetLeftX = (((_a = currentTransform.next) == null ? void 0 : _a.firstChild) ? (_b = currentTransform.next.firstChild.bounds) == null ? void 0 : _b.left : (_d = (_c = currentTransform.next) == null ? void 0 : _c.bounds) == null ? void 0 : _d.left) || 0;
|
|
237
244
|
const currentInputPointY = currentTransform.inputPoint.y;
|
|
238
|
-
if (currentTransform
|
|
245
|
+
if (currentTransform == null ? void 0 : currentTransform.next) {
|
|
239
246
|
draggingLabel.push({
|
|
240
247
|
offset: {
|
|
241
248
|
x: (currentOffsetRightX + nextOffsetLeftX) / 2,
|
|
@@ -249,17 +256,17 @@ var BlockRegistry = {
|
|
|
249
256
|
});
|
|
250
257
|
}
|
|
251
258
|
} else {
|
|
252
|
-
const
|
|
253
|
-
const
|
|
259
|
+
const currentOffsetBottomX = currentTransform.firstChild ? currentTransform.firstChild.bounds.bottom : currentTransform.bounds.bottom;
|
|
260
|
+
const nextOffsetTopX = (((_e = currentTransform.next) == null ? void 0 : _e.firstChild) ? (_f = currentTransform.next.firstChild.bounds) == null ? void 0 : _f.top : (_h = (_g = currentTransform.next) == null ? void 0 : _g.bounds) == null ? void 0 : _h.top) || 0;
|
|
254
261
|
const currentInputPointX = currentTransform.inputPoint.x;
|
|
255
|
-
if (currentTransform
|
|
262
|
+
if (currentTransform == null ? void 0 : currentTransform.next) {
|
|
256
263
|
draggingLabel.push({
|
|
257
264
|
offset: {
|
|
258
265
|
x: currentInputPointX,
|
|
259
|
-
y: (
|
|
266
|
+
y: (currentOffsetBottomX + nextOffsetTopX) / 2
|
|
260
267
|
},
|
|
261
268
|
type: FlowTransitionLabelEnum2.BRANCH_DRAGGING_LABEL,
|
|
262
|
-
width:
|
|
269
|
+
width: nextOffsetTopX - currentOffsetBottomX,
|
|
263
270
|
props: {
|
|
264
271
|
side: LABEL_SIDE_TYPE.NORMAL_BRANCH
|
|
265
272
|
}
|
|
@@ -269,6 +276,9 @@ var BlockRegistry = {
|
|
|
269
276
|
}
|
|
270
277
|
return [...draggingLabel];
|
|
271
278
|
},
|
|
279
|
+
/**
|
|
280
|
+
* @depreacted
|
|
281
|
+
*/
|
|
272
282
|
addChild(node, json, options = {}) {
|
|
273
283
|
const { index } = options;
|
|
274
284
|
const document = node.document;
|
|
@@ -308,8 +318,9 @@ var InlineBlocksRegistry = {
|
|
|
308
318
|
* @param child
|
|
309
319
|
*/
|
|
310
320
|
getChildDelta(child, layout) {
|
|
321
|
+
var _a;
|
|
311
322
|
const isVertical = FlowLayoutDefault3.isVertical(layout);
|
|
312
|
-
const preTransform = child.entity.pre
|
|
323
|
+
const preTransform = (_a = child.entity.pre) == null ? void 0 : _a.getData(FlowNodeTransformData);
|
|
313
324
|
if (preTransform) {
|
|
314
325
|
const { localBounds: preBounds } = preTransform;
|
|
315
326
|
if (isVertical) {
|
|
@@ -346,6 +357,7 @@ var InlineBlocksRegistry = {
|
|
|
346
357
|
* @param trans
|
|
347
358
|
*/
|
|
348
359
|
getDelta(trans, layout) {
|
|
360
|
+
var _a, _b, _c, _d;
|
|
349
361
|
const isVertical = FlowLayoutDefault3.isVertical(layout);
|
|
350
362
|
const { pre, collapsed } = trans;
|
|
351
363
|
if (collapsed) {
|
|
@@ -353,8 +365,8 @@ var InlineBlocksRegistry = {
|
|
|
353
365
|
}
|
|
354
366
|
if (isVertical) {
|
|
355
367
|
const preCenter2 = pre.localBounds.center.x;
|
|
356
|
-
const firstBlockX = trans.firstChild
|
|
357
|
-
const lastBlockX = trans.lastChild
|
|
368
|
+
const firstBlockX = ((_a = trans.firstChild) == null ? void 0 : _a.transform.position.x) || 0;
|
|
369
|
+
const lastBlockX = ((_b = trans.lastChild) == null ? void 0 : _b.transform.position.x) || 0;
|
|
358
370
|
const currentCenter2 = (lastBlockX - firstBlockX) / 2;
|
|
359
371
|
return {
|
|
360
372
|
x: preCenter2 - currentCenter2,
|
|
@@ -362,8 +374,8 @@ var InlineBlocksRegistry = {
|
|
|
362
374
|
};
|
|
363
375
|
}
|
|
364
376
|
const preCenter = pre.localBounds.center.y;
|
|
365
|
-
const firstBlockY = trans.firstChild
|
|
366
|
-
const lastBlockY = trans.lastChild
|
|
377
|
+
const firstBlockY = ((_c = trans.firstChild) == null ? void 0 : _c.transform.position.y) || 0;
|
|
378
|
+
const lastBlockY = ((_d = trans.lastChild) == null ? void 0 : _d.transform.position.y) || 0;
|
|
367
379
|
const currentCenter = (lastBlockY - firstBlockY) / 2;
|
|
368
380
|
return {
|
|
369
381
|
x: 0,
|
|
@@ -378,36 +390,39 @@ var InlineBlocksRegistry = {
|
|
|
378
390
|
},
|
|
379
391
|
// 和前序节点对齐
|
|
380
392
|
getInputPoint(transform, layout) {
|
|
393
|
+
var _a, _b;
|
|
381
394
|
const isVertical = FlowLayoutDefault3.isVertical(layout);
|
|
382
395
|
if (isVertical) {
|
|
383
396
|
return {
|
|
384
|
-
x: transform.pre
|
|
397
|
+
x: ((_a = transform.pre) == null ? void 0 : _a.outputPoint.x) || 0,
|
|
385
398
|
y: transform.bounds.top
|
|
386
399
|
};
|
|
387
400
|
}
|
|
388
401
|
return {
|
|
389
402
|
x: transform.bounds.left,
|
|
390
|
-
y: transform.pre
|
|
403
|
+
y: ((_b = transform.pre) == null ? void 0 : _b.outputPoint.y) || 0
|
|
391
404
|
};
|
|
392
405
|
},
|
|
393
406
|
getOutputPoint(transform, layout) {
|
|
407
|
+
var _a, _b;
|
|
394
408
|
const isVertical = FlowLayoutDefault3.isVertical(layout);
|
|
395
409
|
if (transform.collapsed) {
|
|
396
410
|
return transform.inputPoint;
|
|
397
411
|
}
|
|
398
412
|
if (isVertical) {
|
|
399
413
|
return {
|
|
400
|
-
x: transform.pre
|
|
414
|
+
x: ((_a = transform.pre) == null ? void 0 : _a.outputPoint.x) || 0,
|
|
401
415
|
y: transform.bounds.bottom
|
|
402
416
|
};
|
|
403
417
|
}
|
|
404
418
|
return {
|
|
405
419
|
x: transform.bounds.right,
|
|
406
|
-
y: transform.pre
|
|
420
|
+
y: ((_b = transform.pre) == null ? void 0 : _b.outputPoint.y) || 0
|
|
407
421
|
};
|
|
408
422
|
}
|
|
409
423
|
};
|
|
410
424
|
function getBranchAdderLabel(transition) {
|
|
425
|
+
var _a;
|
|
411
426
|
const { isVertical } = transition.entity;
|
|
412
427
|
const currentTransform = transition.transform;
|
|
413
428
|
if (currentTransform.collapsed) {
|
|
@@ -431,7 +446,7 @@ function getBranchAdderLabel(transition) {
|
|
|
431
446
|
activated: transition.entity.getData(FlowNodeRenderData).activated,
|
|
432
447
|
transform: currentTransform,
|
|
433
448
|
// 传给外部使用的 node 信息
|
|
434
|
-
node: currentTransform.originParent
|
|
449
|
+
node: (_a = currentTransform.originParent) == null ? void 0 : _a.entity
|
|
435
450
|
}
|
|
436
451
|
}
|
|
437
452
|
];
|
|
@@ -500,7 +515,7 @@ var BlockOrderIconRegistry = {
|
|
|
500
515
|
const nextTransform = currentTransform.next;
|
|
501
516
|
const parentTransform = currentTransform.parent;
|
|
502
517
|
if (transition.entity.parent.collapsedChildren.length <= 1) {
|
|
503
|
-
const parentOutput = parentTransform
|
|
518
|
+
const parentOutput = parentTransform == null ? void 0 : parentTransform.outputPoint;
|
|
504
519
|
return [
|
|
505
520
|
{
|
|
506
521
|
offset: parentOutput,
|
|
@@ -662,6 +677,7 @@ var CatchInlineBlocksRegistry = {
|
|
|
662
677
|
return firstChild.originDeltaX;
|
|
663
678
|
},
|
|
664
679
|
getLabels(transition) {
|
|
680
|
+
var _a;
|
|
665
681
|
const { inputPoint } = transition.transform;
|
|
666
682
|
const { isVertical } = transition.entity;
|
|
667
683
|
const currentTransform = transition.transform;
|
|
@@ -682,7 +698,7 @@ var CatchInlineBlocksRegistry = {
|
|
|
682
698
|
activated: transition.entity.getData(FlowNodeRenderData2).activated,
|
|
683
699
|
transform: currentTransform,
|
|
684
700
|
// 传给外部使用的 node 信息
|
|
685
|
-
node: currentTransform.originParent
|
|
701
|
+
node: (_a = currentTransform.originParent) == null ? void 0 : _a.entity
|
|
686
702
|
}
|
|
687
703
|
}
|
|
688
704
|
];
|
|
@@ -696,6 +712,7 @@ var CatchInlineBlocksRegistry = {
|
|
|
696
712
|
return isVertical ? transform.bounds.topCenter : transform.bounds.rightCenter;
|
|
697
713
|
},
|
|
698
714
|
getOutputPoint(transform, layout) {
|
|
715
|
+
var _a, _b;
|
|
699
716
|
const isVertical = FlowLayoutDefault4.isVertical(layout);
|
|
700
717
|
if (transform.collapsed) {
|
|
701
718
|
return transform.inputPoint;
|
|
@@ -703,11 +720,11 @@ var CatchInlineBlocksRegistry = {
|
|
|
703
720
|
const firstCatchBlock = transform.firstChild;
|
|
704
721
|
if (firstCatchBlock) {
|
|
705
722
|
return isVertical ? {
|
|
706
|
-
x: firstCatchBlock.outputPoint
|
|
723
|
+
x: (_a = firstCatchBlock.outputPoint) == null ? void 0 : _a.x,
|
|
707
724
|
y: transform.bounds.bottom
|
|
708
725
|
} : {
|
|
709
726
|
x: transform.bounds.right,
|
|
710
|
-
y: firstCatchBlock.outputPoint
|
|
727
|
+
y: (_b = firstCatchBlock.outputPoint) == null ? void 0 : _b.y
|
|
711
728
|
};
|
|
712
729
|
}
|
|
713
730
|
return isVertical ? transform.bounds.bottomCenter : transform.bounds.rightCenter;
|
|
@@ -744,6 +761,7 @@ var MainInlineBlocksRegistry = {
|
|
|
744
761
|
return lines;
|
|
745
762
|
},
|
|
746
763
|
getLabels(transition) {
|
|
764
|
+
var _a;
|
|
747
765
|
const { transform } = transition;
|
|
748
766
|
const { isVertical } = transition.entity;
|
|
749
767
|
const catchInlineBlocks = transform.children[1];
|
|
@@ -777,7 +795,7 @@ var MainInlineBlocksRegistry = {
|
|
|
777
795
|
y: errorLabelY
|
|
778
796
|
},
|
|
779
797
|
props: {
|
|
780
|
-
node: transform.lastChild
|
|
798
|
+
node: (_a = transform.lastChild) == null ? void 0 : _a.entity
|
|
781
799
|
}
|
|
782
800
|
}
|
|
783
801
|
];
|
|
@@ -804,7 +822,8 @@ var MainInlineBlocksRegistry = {
|
|
|
804
822
|
return void 0;
|
|
805
823
|
},
|
|
806
824
|
getChildDelta(child, layout) {
|
|
807
|
-
|
|
825
|
+
var _a;
|
|
826
|
+
const preTransform = (_a = child.entity.pre) == null ? void 0 : _a.getData(FlowNodeTransformData2);
|
|
808
827
|
const isVertical = FlowLayoutDefault5.isVertical(layout);
|
|
809
828
|
if (preTransform) {
|
|
810
829
|
const { localBounds: preBounds } = preTransform;
|
|
@@ -930,7 +949,7 @@ var TryCatchRegistry = {
|
|
|
930
949
|
});
|
|
931
950
|
const tryBlockNode = document.addNode({
|
|
932
951
|
id: tryBlock.id,
|
|
933
|
-
type: "tryBlock" /* TRY_BLOCK */,
|
|
952
|
+
type: tryBlock.type || "tryBlock" /* TRY_BLOCK */,
|
|
934
953
|
originParent: node,
|
|
935
954
|
parent: mainBlockNode,
|
|
936
955
|
data: tryBlock.data
|
|
@@ -980,7 +999,7 @@ var TryCatchRegistry = {
|
|
|
980
999
|
const parent = node.document.getNode(`$catchInlineBlocks$${node.id}`);
|
|
981
1000
|
const block = node.document.addNode({
|
|
982
1001
|
id: blockData.id,
|
|
983
|
-
type: "catchBlock" /* CATCH_BLOCK */,
|
|
1002
|
+
type: blockData.type || "catchBlock" /* CATCH_BLOCK */,
|
|
984
1003
|
originParent: node,
|
|
985
1004
|
parent,
|
|
986
1005
|
data: blockData.data
|
|
@@ -994,7 +1013,7 @@ var TryCatchRegistry = {
|
|
|
994
1013
|
if (blockData.blocks) {
|
|
995
1014
|
node.document.addBlocksAsChildren(block, blockData.blocks || [], addedNodes);
|
|
996
1015
|
}
|
|
997
|
-
addedNodes
|
|
1016
|
+
addedNodes == null ? void 0 : addedNodes.push(block, blockOrderIcon);
|
|
998
1017
|
return block;
|
|
999
1018
|
},
|
|
1000
1019
|
getInputPoint(transform) {
|
|
@@ -1248,6 +1267,7 @@ var LoopInlineBlocksNodeRegistry = {
|
|
|
1248
1267
|
];
|
|
1249
1268
|
},
|
|
1250
1269
|
getLabels(transition) {
|
|
1270
|
+
var _a;
|
|
1251
1271
|
const currentTransform = transition.transform;
|
|
1252
1272
|
const { isVertical } = transition.entity;
|
|
1253
1273
|
const labels = [];
|
|
@@ -1256,7 +1276,7 @@ var LoopInlineBlocksNodeRegistry = {
|
|
|
1256
1276
|
}
|
|
1257
1277
|
const leftBlockTransform = currentTransform.children[0];
|
|
1258
1278
|
const rightBlockTransform = currentTransform.children[1];
|
|
1259
|
-
if (transition.entity.originParent
|
|
1279
|
+
if ((_a = transition.entity.originParent) == null ? void 0 : _a.id.startsWith("while_")) {
|
|
1260
1280
|
labels.push({
|
|
1261
1281
|
type: FlowTransitionLabelEnum10.TEXT_LABEL,
|
|
1262
1282
|
renderKey: FlowTextKey2.LOOP_WHILE_TEXT,
|
|
@@ -1394,29 +1414,31 @@ var LoopRegistry = {
|
|
|
1394
1414
|
},
|
|
1395
1415
|
// 和前序节点对齐
|
|
1396
1416
|
getInputPoint(transform) {
|
|
1417
|
+
var _a, _b, _c, _d;
|
|
1397
1418
|
const { isVertical } = transform.entity;
|
|
1398
1419
|
if (isVertical) {
|
|
1399
1420
|
return {
|
|
1400
|
-
x: transform.pre
|
|
1421
|
+
x: ((_a = transform.pre) == null ? void 0 : _a.outputPoint.x) || ((_b = transform.firstChild) == null ? void 0 : _b.outputPoint.x) || 0,
|
|
1401
1422
|
y: transform.bounds.top
|
|
1402
1423
|
};
|
|
1403
1424
|
}
|
|
1404
1425
|
return {
|
|
1405
1426
|
x: transform.bounds.left,
|
|
1406
|
-
y: transform.pre
|
|
1427
|
+
y: ((_c = transform.pre) == null ? void 0 : _c.outputPoint.y) || ((_d = transform.firstChild) == null ? void 0 : _d.outputPoint.y) || 0
|
|
1407
1428
|
};
|
|
1408
1429
|
},
|
|
1409
1430
|
getOutputPoint(transform) {
|
|
1431
|
+
var _a, _b, _c, _d;
|
|
1410
1432
|
const { isVertical } = transform.entity;
|
|
1411
1433
|
if (isVertical) {
|
|
1412
1434
|
return {
|
|
1413
|
-
x: transform.pre
|
|
1435
|
+
x: ((_a = transform.pre) == null ? void 0 : _a.outputPoint.x) || ((_b = transform.firstChild) == null ? void 0 : _b.outputPoint.x) || 0,
|
|
1414
1436
|
y: transform.bounds.bottom
|
|
1415
1437
|
};
|
|
1416
1438
|
}
|
|
1417
1439
|
return {
|
|
1418
1440
|
x: transform.bounds.right,
|
|
1419
|
-
y: transform.pre
|
|
1441
|
+
y: ((_c = transform.pre) == null ? void 0 : _c.outputPoint.y) || ((_d = transform.firstChild) == null ? void 0 : _d.outputPoint.y) || 0
|
|
1420
1442
|
};
|
|
1421
1443
|
},
|
|
1422
1444
|
extendChildRegistries: [
|
|
@@ -1431,6 +1453,9 @@ var LoopRegistry = {
|
|
|
1431
1453
|
LoopRightEmptyBlockRegistry,
|
|
1432
1454
|
LoopInlineBlocksNodeRegistry
|
|
1433
1455
|
],
|
|
1456
|
+
/**
|
|
1457
|
+
* @depreacted
|
|
1458
|
+
*/
|
|
1434
1459
|
addChild(node, json, options = {}) {
|
|
1435
1460
|
const { index } = options;
|
|
1436
1461
|
const document = node.document;
|
|
@@ -1452,10 +1477,12 @@ var RootRegistry = {
|
|
|
1452
1477
|
hidden: true
|
|
1453
1478
|
},
|
|
1454
1479
|
getInputPoint(transform) {
|
|
1455
|
-
|
|
1480
|
+
var _a;
|
|
1481
|
+
return ((_a = transform.firstChild) == null ? void 0 : _a.inputPoint) || transform.bounds.topCenter;
|
|
1456
1482
|
},
|
|
1457
1483
|
getOutputPoint(transform) {
|
|
1458
|
-
|
|
1484
|
+
var _a;
|
|
1485
|
+
return ((_a = transform.firstChild) == null ? void 0 : _a.outputPoint) || transform.bounds.bottomCenter;
|
|
1459
1486
|
}
|
|
1460
1487
|
};
|
|
1461
1488
|
|
|
@@ -1486,6 +1513,297 @@ var EmptyRegistry = {
|
|
|
1486
1513
|
}
|
|
1487
1514
|
};
|
|
1488
1515
|
|
|
1516
|
+
// src/activities/simple-split.ts
|
|
1517
|
+
import {
|
|
1518
|
+
FlowNodeSplitType as FlowNodeSplitType3,
|
|
1519
|
+
FlowNodeBaseType as FlowNodeBaseType17
|
|
1520
|
+
} from "@flowgram.ai/document";
|
|
1521
|
+
var SimpleSplitRegistry = {
|
|
1522
|
+
type: FlowNodeSplitType3.SIMPLE_SPLIT,
|
|
1523
|
+
extend: FlowNodeSplitType3.DYNAMIC_SPLIT,
|
|
1524
|
+
onBlockChildCreate(originParent, blockData, addedNodes = []) {
|
|
1525
|
+
const { document } = originParent;
|
|
1526
|
+
const parent = document.getNode(`$inlineBlocks$${originParent.id}`);
|
|
1527
|
+
const realBlock = document.addNode(
|
|
1528
|
+
{
|
|
1529
|
+
...blockData,
|
|
1530
|
+
type: blockData.type || FlowNodeBaseType17.BLOCK,
|
|
1531
|
+
parent
|
|
1532
|
+
},
|
|
1533
|
+
addedNodes
|
|
1534
|
+
);
|
|
1535
|
+
addedNodes.push(realBlock);
|
|
1536
|
+
return realBlock;
|
|
1537
|
+
}
|
|
1538
|
+
// addChild(node, json, options = {}) {
|
|
1539
|
+
// const { index } = options;
|
|
1540
|
+
// const document = node.document;
|
|
1541
|
+
// return document.addBlock(node, json, undefined, undefined, index);
|
|
1542
|
+
// }
|
|
1543
|
+
};
|
|
1544
|
+
|
|
1545
|
+
// src/activities/break.ts
|
|
1546
|
+
import { FlowNodeBaseType as FlowNodeBaseType18 } from "@flowgram.ai/document";
|
|
1547
|
+
var BreakRegistry = {
|
|
1548
|
+
type: FlowNodeBaseType18.BREAK,
|
|
1549
|
+
extend: FlowNodeBaseType18.END
|
|
1550
|
+
};
|
|
1551
|
+
|
|
1552
|
+
// src/activities/input.ts
|
|
1553
|
+
import {
|
|
1554
|
+
FlowNodeBaseType as FlowNodeBaseType19,
|
|
1555
|
+
FlowTransitionLineEnum as FlowTransitionLineEnum6,
|
|
1556
|
+
LABEL_SIDE_TYPE as LABEL_SIDE_TYPE2,
|
|
1557
|
+
FlowTransitionLabelEnum as FlowTransitionLabelEnum13
|
|
1558
|
+
} from "@flowgram.ai/document";
|
|
1559
|
+
var InputRegistry = {
|
|
1560
|
+
type: FlowNodeBaseType19.INPUT,
|
|
1561
|
+
extend: FlowNodeBaseType19.BLOCK,
|
|
1562
|
+
meta: {
|
|
1563
|
+
hidden: false
|
|
1564
|
+
},
|
|
1565
|
+
getLines(transition, layout) {
|
|
1566
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1567
|
+
const currentTransform = transition.transform;
|
|
1568
|
+
const { isVertical } = transition.entity;
|
|
1569
|
+
const lines = [];
|
|
1570
|
+
const hasBranchDraggingAdder = currentTransform && currentTransform.entity.isInlineBlock && transition.renderData.draggable;
|
|
1571
|
+
if (hasBranchDraggingAdder) {
|
|
1572
|
+
if (isVertical) {
|
|
1573
|
+
const currentOffsetRightX = currentTransform.firstChild ? currentTransform.firstChild.bounds.right : currentTransform.bounds.right;
|
|
1574
|
+
const nextOffsetLeftX = (((_a = currentTransform.next) == null ? void 0 : _a.firstChild) ? (_c = (_b = currentTransform.next) == null ? void 0 : _b.firstChild.bounds) == null ? void 0 : _c.left : (_e = (_d = currentTransform.next) == null ? void 0 : _d.bounds) == null ? void 0 : _e.left) || 0;
|
|
1575
|
+
const currentInputPointY = currentTransform.outputPoint.y;
|
|
1576
|
+
if (currentTransform == null ? void 0 : currentTransform.next) {
|
|
1577
|
+
lines.push({
|
|
1578
|
+
type: FlowTransitionLineEnum6.MERGE_LINE,
|
|
1579
|
+
isDraggingLine: true,
|
|
1580
|
+
from: {
|
|
1581
|
+
x: (currentOffsetRightX + nextOffsetLeftX) / 2,
|
|
1582
|
+
y: currentInputPointY
|
|
1583
|
+
},
|
|
1584
|
+
to: currentTransform.parent.outputPoint,
|
|
1585
|
+
side: LABEL_SIDE_TYPE2.NORMAL_BRANCH
|
|
1586
|
+
});
|
|
1587
|
+
}
|
|
1588
|
+
} else {
|
|
1589
|
+
const currentOffsetBottomX = currentTransform.firstChild ? currentTransform.firstChild.bounds.bottom : currentTransform.bounds.bottom;
|
|
1590
|
+
const nextOffsetTopX = (((_f = currentTransform.next) == null ? void 0 : _f.firstChild) ? (_h = (_g = currentTransform.next) == null ? void 0 : _g.firstChild.bounds) == null ? void 0 : _h.top : (_j = (_i = currentTransform.next) == null ? void 0 : _i.bounds) == null ? void 0 : _j.top) || 0;
|
|
1591
|
+
const currentInputPointX = currentTransform.outputPoint.x;
|
|
1592
|
+
if (currentTransform == null ? void 0 : currentTransform.next) {
|
|
1593
|
+
lines.push({
|
|
1594
|
+
type: FlowTransitionLineEnum6.MERGE_LINE,
|
|
1595
|
+
isDraggingLine: true,
|
|
1596
|
+
from: {
|
|
1597
|
+
x: currentInputPointX,
|
|
1598
|
+
y: (currentOffsetBottomX + nextOffsetTopX) / 2
|
|
1599
|
+
},
|
|
1600
|
+
to: currentTransform.parent.outputPoint,
|
|
1601
|
+
side: LABEL_SIDE_TYPE2.NORMAL_BRANCH
|
|
1602
|
+
});
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
if (!transition.isNodeEnd) {
|
|
1607
|
+
lines.push({
|
|
1608
|
+
type: FlowTransitionLineEnum6.MERGE_LINE,
|
|
1609
|
+
from: currentTransform.outputPoint,
|
|
1610
|
+
to: currentTransform.parent.outputPoint,
|
|
1611
|
+
side: LABEL_SIDE_TYPE2.NORMAL_BRANCH
|
|
1612
|
+
});
|
|
1613
|
+
}
|
|
1614
|
+
return lines;
|
|
1615
|
+
},
|
|
1616
|
+
getLabels(transition) {
|
|
1617
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1618
|
+
const currentTransform = transition.transform;
|
|
1619
|
+
const { isVertical } = transition.entity;
|
|
1620
|
+
const draggingLabel = [];
|
|
1621
|
+
const hasBranchDraggingAdder = currentTransform && currentTransform.entity.isInlineBlock && transition.renderData.draggable;
|
|
1622
|
+
if (hasBranchDraggingAdder) {
|
|
1623
|
+
if (isVertical) {
|
|
1624
|
+
const currentOffsetRightX = currentTransform.firstChild ? currentTransform.firstChild.bounds.right : currentTransform.bounds.right;
|
|
1625
|
+
const nextOffsetLeftX = (((_a = currentTransform.next) == null ? void 0 : _a.firstChild) ? (_b = currentTransform.next.firstChild.bounds) == null ? void 0 : _b.left : (_d = (_c = currentTransform.next) == null ? void 0 : _c.bounds) == null ? void 0 : _d.left) || 0;
|
|
1626
|
+
const currentInputPointY = currentTransform.outputPoint.y;
|
|
1627
|
+
if (currentTransform == null ? void 0 : currentTransform.next) {
|
|
1628
|
+
draggingLabel.push({
|
|
1629
|
+
offset: {
|
|
1630
|
+
x: (currentOffsetRightX + nextOffsetLeftX) / 2,
|
|
1631
|
+
y: currentInputPointY
|
|
1632
|
+
},
|
|
1633
|
+
type: FlowTransitionLabelEnum13.BRANCH_DRAGGING_LABEL,
|
|
1634
|
+
width: nextOffsetLeftX - currentOffsetRightX,
|
|
1635
|
+
props: {
|
|
1636
|
+
side: LABEL_SIDE_TYPE2.NORMAL_BRANCH
|
|
1637
|
+
}
|
|
1638
|
+
});
|
|
1639
|
+
}
|
|
1640
|
+
} else {
|
|
1641
|
+
const currentOffsetBottomX = currentTransform.firstChild ? currentTransform.firstChild.bounds.bottom : currentTransform.bounds.bottom;
|
|
1642
|
+
const nextOffsetTopX = (((_e = currentTransform.next) == null ? void 0 : _e.firstChild) ? (_f = currentTransform.next.firstChild.bounds) == null ? void 0 : _f.top : (_h = (_g = currentTransform.next) == null ? void 0 : _g.bounds) == null ? void 0 : _h.top) || 0;
|
|
1643
|
+
const currentInputPointX = currentTransform.outputPoint.x;
|
|
1644
|
+
if (currentTransform == null ? void 0 : currentTransform.next) {
|
|
1645
|
+
draggingLabel.push({
|
|
1646
|
+
offset: {
|
|
1647
|
+
x: currentInputPointX,
|
|
1648
|
+
y: (currentOffsetBottomX + nextOffsetTopX) / 2
|
|
1649
|
+
},
|
|
1650
|
+
type: FlowTransitionLabelEnum13.BRANCH_DRAGGING_LABEL,
|
|
1651
|
+
width: nextOffsetTopX - currentOffsetBottomX,
|
|
1652
|
+
props: {
|
|
1653
|
+
side: LABEL_SIDE_TYPE2.NORMAL_BRANCH
|
|
1654
|
+
}
|
|
1655
|
+
});
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
return [...draggingLabel];
|
|
1660
|
+
}
|
|
1661
|
+
};
|
|
1662
|
+
|
|
1663
|
+
// src/activities/output.ts
|
|
1664
|
+
import { FlowNodeBaseType as FlowNodeBaseType20 } from "@flowgram.ai/document";
|
|
1665
|
+
var OuputRegistry = {
|
|
1666
|
+
type: FlowNodeBaseType20.OUTPUT,
|
|
1667
|
+
extend: FlowNodeBaseType20.BLOCK,
|
|
1668
|
+
meta: {
|
|
1669
|
+
hidden: false,
|
|
1670
|
+
isNodeEnd: true
|
|
1671
|
+
}
|
|
1672
|
+
};
|
|
1673
|
+
|
|
1674
|
+
// src/activities/multi-outputs.ts
|
|
1675
|
+
import {
|
|
1676
|
+
FlowLayoutDefault as FlowLayoutDefault7,
|
|
1677
|
+
FlowNodeSplitType as FlowNodeSplitType4,
|
|
1678
|
+
FlowNodeBaseType as FlowNodeBaseType21
|
|
1679
|
+
} from "@flowgram.ai/document";
|
|
1680
|
+
var MultiOuputsRegistry = {
|
|
1681
|
+
type: FlowNodeBaseType21.MULTI_OUTPUTS,
|
|
1682
|
+
extend: FlowNodeSplitType4.SIMPLE_SPLIT,
|
|
1683
|
+
meta: {
|
|
1684
|
+
isNodeEnd: true
|
|
1685
|
+
},
|
|
1686
|
+
getLines: (transition, layout) => {
|
|
1687
|
+
var _a;
|
|
1688
|
+
if (((_a = transition.entity.parent) == null ? void 0 : _a.flowNodeType) === FlowNodeBaseType21.INLINE_BLOCKS) {
|
|
1689
|
+
return BlockRegistry.getLines(transition, layout);
|
|
1690
|
+
}
|
|
1691
|
+
return [];
|
|
1692
|
+
},
|
|
1693
|
+
getLabels: (transition, layout) => [
|
|
1694
|
+
...DynamicSplitRegistry.getLabels(transition, layout),
|
|
1695
|
+
...BlockRegistry.getLabels(transition, layout)
|
|
1696
|
+
],
|
|
1697
|
+
getOutputPoint(transform, layout) {
|
|
1698
|
+
var _a;
|
|
1699
|
+
const isVertical = FlowLayoutDefault7.isVertical(layout);
|
|
1700
|
+
const lastChildOutput = (_a = transform.lastChild) == null ? void 0 : _a.outputPoint;
|
|
1701
|
+
if (isVertical) {
|
|
1702
|
+
return {
|
|
1703
|
+
x: lastChildOutput ? lastChildOutput.x : transform.bounds.center.x,
|
|
1704
|
+
y: transform.bounds.bottom
|
|
1705
|
+
};
|
|
1706
|
+
}
|
|
1707
|
+
return {
|
|
1708
|
+
x: transform.bounds.right,
|
|
1709
|
+
y: lastChildOutput ? lastChildOutput.y : transform.bounds.center.y
|
|
1710
|
+
};
|
|
1711
|
+
},
|
|
1712
|
+
extendChildRegistries: [
|
|
1713
|
+
{
|
|
1714
|
+
type: FlowNodeBaseType21.BLOCK_ICON,
|
|
1715
|
+
meta: {
|
|
1716
|
+
// isNodeEnd: true
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
]
|
|
1720
|
+
};
|
|
1721
|
+
|
|
1722
|
+
// src/activities/multi-inputs.ts
|
|
1723
|
+
import { Point as Point6 } from "@flowgram.ai/utils";
|
|
1724
|
+
import { FlowRendererKey as FlowRendererKey4 } from "@flowgram.ai/renderer";
|
|
1725
|
+
import {
|
|
1726
|
+
FlowNodeBaseType as FlowNodeBaseType22,
|
|
1727
|
+
FlowNodeRenderData as FlowNodeRenderData3,
|
|
1728
|
+
FlowTransitionLabelEnum as FlowTransitionLabelEnum14,
|
|
1729
|
+
FlowNodeSplitType as FlowNodeSplitType5,
|
|
1730
|
+
getDefaultSpacing as getDefaultSpacing8,
|
|
1731
|
+
ConstantKeys as ConstantKeys7
|
|
1732
|
+
} from "@flowgram.ai/document";
|
|
1733
|
+
var MultiInputsRegistry = {
|
|
1734
|
+
type: FlowNodeBaseType22.MULTI_INPUTS,
|
|
1735
|
+
extend: FlowNodeSplitType5.SIMPLE_SPLIT,
|
|
1736
|
+
extendChildRegistries: [
|
|
1737
|
+
{
|
|
1738
|
+
type: FlowNodeBaseType22.BLOCK_ICON,
|
|
1739
|
+
meta: {
|
|
1740
|
+
hidden: true,
|
|
1741
|
+
spacing: 0
|
|
1742
|
+
},
|
|
1743
|
+
getLines() {
|
|
1744
|
+
return [];
|
|
1745
|
+
},
|
|
1746
|
+
getLabels() {
|
|
1747
|
+
return [];
|
|
1748
|
+
}
|
|
1749
|
+
},
|
|
1750
|
+
{
|
|
1751
|
+
type: FlowNodeBaseType22.INLINE_BLOCKS,
|
|
1752
|
+
meta: {
|
|
1753
|
+
inlineSpacingPre: 0
|
|
1754
|
+
},
|
|
1755
|
+
getLabels(transition) {
|
|
1756
|
+
var _a, _b;
|
|
1757
|
+
const isVertical = transition.entity.isVertical;
|
|
1758
|
+
const currentTransform = transition.transform;
|
|
1759
|
+
const spacing = getDefaultSpacing8(
|
|
1760
|
+
transition.entity,
|
|
1761
|
+
ConstantKeys7.INLINE_BLOCKS_PADDING_BOTTOM
|
|
1762
|
+
);
|
|
1763
|
+
if (currentTransform.collapsed || transition.entity.childrenLength === 0) {
|
|
1764
|
+
return [
|
|
1765
|
+
{
|
|
1766
|
+
type: FlowTransitionLabelEnum14.CUSTOM_LABEL,
|
|
1767
|
+
renderKey: FlowRendererKey4.BRANCH_ADDER,
|
|
1768
|
+
offset: Point6.move(
|
|
1769
|
+
currentTransform.outputPoint,
|
|
1770
|
+
isVertical ? { y: spacing } : { x: spacing }
|
|
1771
|
+
),
|
|
1772
|
+
props: {
|
|
1773
|
+
// 激活状态
|
|
1774
|
+
activated: transition.entity.getData(FlowNodeRenderData3).activated,
|
|
1775
|
+
transform: currentTransform,
|
|
1776
|
+
// 传给外部使用的 node 信息
|
|
1777
|
+
node: (_a = currentTransform.originParent) == null ? void 0 : _a.entity
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
];
|
|
1781
|
+
}
|
|
1782
|
+
return [
|
|
1783
|
+
{
|
|
1784
|
+
type: FlowTransitionLabelEnum14.CUSTOM_LABEL,
|
|
1785
|
+
renderKey: FlowRendererKey4.BRANCH_ADDER,
|
|
1786
|
+
offset: Point6.move(
|
|
1787
|
+
currentTransform.outputPoint,
|
|
1788
|
+
isVertical ? { y: -spacing / 2 } : { x: -spacing / 2 }
|
|
1789
|
+
),
|
|
1790
|
+
props: {
|
|
1791
|
+
// 激活状态
|
|
1792
|
+
activated: transition.entity.getData(FlowNodeRenderData3).activated,
|
|
1793
|
+
transform: currentTransform,
|
|
1794
|
+
// 传给外部使用的 node 信息
|
|
1795
|
+
node: (_b = currentTransform.originParent) == null ? void 0 : _b.entity
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
];
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
],
|
|
1802
|
+
getLabels() {
|
|
1803
|
+
return [];
|
|
1804
|
+
}
|
|
1805
|
+
};
|
|
1806
|
+
|
|
1489
1807
|
// src/flow-registers.ts
|
|
1490
1808
|
var FlowRegisters = class {
|
|
1491
1809
|
/**
|
|
@@ -1502,6 +1820,8 @@ var FlowRegisters = class {
|
|
|
1502
1820
|
// 动态分支(并行、排他)
|
|
1503
1821
|
StaticSplitRegistry,
|
|
1504
1822
|
// 静态分支(审批)
|
|
1823
|
+
SimpleSplitRegistry,
|
|
1824
|
+
// 简单分支 (不带 orderIcon 节点)
|
|
1505
1825
|
BlockRegistry,
|
|
1506
1826
|
// 单条 block 注册
|
|
1507
1827
|
InlineBlocksRegistry,
|
|
@@ -1516,11 +1836,17 @@ var FlowRegisters = class {
|
|
|
1516
1836
|
// 结束节点
|
|
1517
1837
|
LoopRegistry,
|
|
1518
1838
|
// 循环节点
|
|
1519
|
-
EmptyRegistry
|
|
1839
|
+
EmptyRegistry,
|
|
1520
1840
|
// 占位节点
|
|
1841
|
+
BreakRegistry,
|
|
1842
|
+
// 分支断开
|
|
1843
|
+
MultiOuputsRegistry,
|
|
1844
|
+
MultiInputsRegistry,
|
|
1845
|
+
InputRegistry,
|
|
1846
|
+
OuputRegistry
|
|
1521
1847
|
);
|
|
1522
1848
|
document.registerNodeDatas(
|
|
1523
|
-
|
|
1849
|
+
FlowNodeRenderData4,
|
|
1524
1850
|
// 渲染节点相关数据
|
|
1525
1851
|
FlowNodeTransitionData,
|
|
1526
1852
|
// 线条绘制数据
|