@flowgram.ai/fixed-layout-core 0.1.0-alpha.3 → 0.1.0-alpha.30
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 +1098 -93
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +43 -1
- package/dist/index.d.ts +43 -1
- package/dist/index.js +1036 -57
- package/dist/index.js.map +1 -1
- package/package.json +15 -13
package/dist/esm/index.js
CHANGED
|
@@ -22,13 +22,11 @@ import {
|
|
|
22
22
|
FlowLabelsLayer,
|
|
23
23
|
FlowLinesLayer,
|
|
24
24
|
FlowNodesContentLayer,
|
|
25
|
-
FlowNodesTransformLayer
|
|
26
|
-
FlowScrollBarLayer,
|
|
27
|
-
FlowScrollLimitLayer
|
|
25
|
+
FlowNodesTransformLayer
|
|
28
26
|
} from "@flowgram.ai/renderer";
|
|
29
27
|
import {
|
|
30
|
-
FlowNodeRenderData as
|
|
31
|
-
FlowNodeTransformData as
|
|
28
|
+
FlowNodeRenderData as FlowNodeRenderData4,
|
|
29
|
+
FlowNodeTransformData as FlowNodeTransformData5,
|
|
32
30
|
FlowNodeTransitionData
|
|
33
31
|
} from "@flowgram.ai/document";
|
|
34
32
|
import { PlaygroundLayer } from "@flowgram.ai/core";
|
|
@@ -104,6 +102,9 @@ var DynamicSplitRegistry = {
|
|
|
104
102
|
y: lastChildOutput ? lastChildOutput.y : transform.bounds.center.y
|
|
105
103
|
};
|
|
106
104
|
},
|
|
105
|
+
/**
|
|
106
|
+
* @depreacted
|
|
107
|
+
*/
|
|
107
108
|
addChild(node, json, options = {}) {
|
|
108
109
|
const { index } = options;
|
|
109
110
|
const document = node.document;
|
|
@@ -166,8 +167,8 @@ var BlockRegistry = {
|
|
|
166
167
|
const hasBranchDraggingAdder = currentTransform && currentTransform.entity.isInlineBlock && transition.renderData.draggable;
|
|
167
168
|
if (hasBranchDraggingAdder) {
|
|
168
169
|
if (isVertical) {
|
|
169
|
-
const currentOffsetRightX = currentTransform.firstChild
|
|
170
|
-
const nextOffsetLeftX = currentTransform.next?.firstChild?.bounds?.left || 0;
|
|
170
|
+
const currentOffsetRightX = currentTransform.firstChild ? currentTransform.firstChild.bounds.right : currentTransform.bounds.right;
|
|
171
|
+
const nextOffsetLeftX = (currentTransform.next?.firstChild ? currentTransform.next?.firstChild.bounds?.left : currentTransform.next?.bounds?.left) || 0;
|
|
171
172
|
const currentInputPointY = currentTransform.inputPoint.y;
|
|
172
173
|
if (currentTransform?.next) {
|
|
173
174
|
lines.push({
|
|
@@ -181,8 +182,8 @@ var BlockRegistry = {
|
|
|
181
182
|
});
|
|
182
183
|
}
|
|
183
184
|
} else {
|
|
184
|
-
const
|
|
185
|
-
const
|
|
185
|
+
const currentOffsetBottomX = currentTransform.firstChild ? currentTransform.firstChild.bounds.bottom : currentTransform.bounds.bottom;
|
|
186
|
+
const nextOffsetTopX = (currentTransform.next?.firstChild ? currentTransform.next?.firstChild.bounds?.top : currentTransform.next?.bounds?.top) || 0;
|
|
186
187
|
const currentInputPointX = currentTransform.inputPoint.x;
|
|
187
188
|
if (currentTransform?.next) {
|
|
188
189
|
lines.push({
|
|
@@ -190,7 +191,7 @@ var BlockRegistry = {
|
|
|
190
191
|
from: currentTransform.parent.inputPoint,
|
|
191
192
|
to: {
|
|
192
193
|
x: currentInputPointX,
|
|
193
|
-
y: (
|
|
194
|
+
y: (currentOffsetBottomX + nextOffsetTopX) / 2
|
|
194
195
|
},
|
|
195
196
|
side: LABEL_SIDE_TYPE.NORMAL_BRANCH
|
|
196
197
|
});
|
|
@@ -232,8 +233,8 @@ var BlockRegistry = {
|
|
|
232
233
|
const hasBranchDraggingAdder = currentTransform && currentTransform.entity.isInlineBlock && transition.renderData.draggable;
|
|
233
234
|
if (hasBranchDraggingAdder) {
|
|
234
235
|
if (isVertical) {
|
|
235
|
-
const currentOffsetRightX = currentTransform.firstChild
|
|
236
|
-
const nextOffsetLeftX = currentTransform.next?.firstChild?.bounds?.left || 0;
|
|
236
|
+
const currentOffsetRightX = currentTransform.firstChild ? currentTransform.firstChild.bounds.right : currentTransform.bounds.right;
|
|
237
|
+
const nextOffsetLeftX = (currentTransform.next?.firstChild ? currentTransform.next.firstChild.bounds?.left : currentTransform.next?.bounds?.left) || 0;
|
|
237
238
|
const currentInputPointY = currentTransform.inputPoint.y;
|
|
238
239
|
if (currentTransform?.next) {
|
|
239
240
|
draggingLabel.push({
|
|
@@ -249,17 +250,17 @@ var BlockRegistry = {
|
|
|
249
250
|
});
|
|
250
251
|
}
|
|
251
252
|
} else {
|
|
252
|
-
const
|
|
253
|
-
const
|
|
253
|
+
const currentOffsetBottomX = currentTransform.firstChild ? currentTransform.firstChild.bounds.bottom : currentTransform.bounds.bottom;
|
|
254
|
+
const nextOffsetTopX = (currentTransform.next?.firstChild ? currentTransform.next.firstChild.bounds?.top : currentTransform.next?.bounds?.top) || 0;
|
|
254
255
|
const currentInputPointX = currentTransform.inputPoint.x;
|
|
255
256
|
if (currentTransform?.next) {
|
|
256
257
|
draggingLabel.push({
|
|
257
258
|
offset: {
|
|
258
259
|
x: currentInputPointX,
|
|
259
|
-
y: (
|
|
260
|
+
y: (currentOffsetBottomX + nextOffsetTopX) / 2
|
|
260
261
|
},
|
|
261
262
|
type: FlowTransitionLabelEnum2.BRANCH_DRAGGING_LABEL,
|
|
262
|
-
width:
|
|
263
|
+
width: nextOffsetTopX - currentOffsetBottomX,
|
|
263
264
|
props: {
|
|
264
265
|
side: LABEL_SIDE_TYPE.NORMAL_BRANCH
|
|
265
266
|
}
|
|
@@ -269,6 +270,9 @@ var BlockRegistry = {
|
|
|
269
270
|
}
|
|
270
271
|
return [...draggingLabel];
|
|
271
272
|
},
|
|
273
|
+
/**
|
|
274
|
+
* @depreacted
|
|
275
|
+
*/
|
|
272
276
|
addChild(node, json, options = {}) {
|
|
273
277
|
const { index } = options;
|
|
274
278
|
const document = node.document;
|
|
@@ -300,8 +304,18 @@ var InlineBlocksRegistry = {
|
|
|
300
304
|
hidden: true,
|
|
301
305
|
spacing: (node) => getDefaultSpacing2(node.entity, ConstantKeys2.NODE_SPACING),
|
|
302
306
|
isInlineBlocks: true,
|
|
303
|
-
inlineSpacingPre:
|
|
304
|
-
|
|
307
|
+
inlineSpacingPre: (transform) => {
|
|
308
|
+
if (transform.entity.blocks.length === 0) {
|
|
309
|
+
return 0;
|
|
310
|
+
}
|
|
311
|
+
return getDefaultSpacing2(transform.entity, ConstantKeys2.INLINE_BLOCKS_PADDING_TOP) || DEFAULT_SPACING2.INLINE_BLOCKS_PADDING_TOP;
|
|
312
|
+
},
|
|
313
|
+
inlineSpacingAfter: (transform) => {
|
|
314
|
+
if (transform.entity.blocks.length === 0) {
|
|
315
|
+
return 0;
|
|
316
|
+
}
|
|
317
|
+
return getDefaultSpacing2(transform.entity, ConstantKeys2.INLINE_BLOCKS_PADDING_BOTTOM);
|
|
318
|
+
}
|
|
305
319
|
},
|
|
306
320
|
/**
|
|
307
321
|
* 控制子分支的间距
|
|
@@ -316,7 +330,7 @@ var InlineBlocksRegistry = {
|
|
|
316
330
|
const leftSpacing = preTransform.size.width + preTransform.originDeltaX;
|
|
317
331
|
const delta = Math.max(
|
|
318
332
|
child.parent.minInlineBlockSpacing - leftSpacing,
|
|
319
|
-
|
|
333
|
+
getDefaultSpacing2(child.entity, ConstantKeys2.BRANCH_SPACING) - child.originDeltaX
|
|
320
334
|
);
|
|
321
335
|
return {
|
|
322
336
|
// 这里需要加上原点的偏移量,并加上水平间距
|
|
@@ -327,7 +341,7 @@ var InlineBlocksRegistry = {
|
|
|
327
341
|
const bottomSpacing = preTransform.size.height + preTransform.originDeltaY;
|
|
328
342
|
const delta = Math.max(
|
|
329
343
|
child.parent.minInlineBlockSpacing - bottomSpacing,
|
|
330
|
-
|
|
344
|
+
getDefaultSpacing2(child.entity, ConstantKeys2.BRANCH_SPACING) - child.originDeltaY
|
|
331
345
|
);
|
|
332
346
|
return {
|
|
333
347
|
x: 0,
|
|
@@ -550,7 +564,7 @@ var StartRegistry = {
|
|
|
550
564
|
// src/activities/try-catch.ts
|
|
551
565
|
import {
|
|
552
566
|
FlowLayoutDefault as FlowLayoutDefault6,
|
|
553
|
-
FlowNodeBaseType as
|
|
567
|
+
FlowNodeBaseType as FlowNodeBaseType12
|
|
554
568
|
} from "@flowgram.ai/document";
|
|
555
569
|
|
|
556
570
|
// src/activities/try-catch-extends/catch-block.ts
|
|
@@ -717,12 +731,13 @@ var CatchInlineBlocksRegistry = {
|
|
|
717
731
|
// src/activities/try-catch-extends/main-inline-blocks.ts
|
|
718
732
|
import { FlowRendererKey as FlowRendererKey3, FlowTextKey } from "@flowgram.ai/renderer";
|
|
719
733
|
import {
|
|
720
|
-
DEFAULT_SPACING as DEFAULT_SPACING5,
|
|
721
734
|
FlowNodeBaseType as FlowNodeBaseType10,
|
|
722
735
|
FlowNodeTransformData as FlowNodeTransformData2,
|
|
723
736
|
FlowTransitionLabelEnum as FlowTransitionLabelEnum7,
|
|
724
737
|
FlowTransitionLineEnum as FlowTransitionLineEnum4,
|
|
725
|
-
FlowLayoutDefault as FlowLayoutDefault5
|
|
738
|
+
FlowLayoutDefault as FlowLayoutDefault5,
|
|
739
|
+
getDefaultSpacing as getDefaultSpacing5,
|
|
740
|
+
ConstantKeys as ConstantKeys3
|
|
726
741
|
} from "@flowgram.ai/document";
|
|
727
742
|
var MainInlineBlocksRegistry = {
|
|
728
743
|
extend: FlowNodeBaseType10.INLINE_BLOCKS,
|
|
@@ -812,12 +827,12 @@ var MainInlineBlocksRegistry = {
|
|
|
812
827
|
if (isVertical) {
|
|
813
828
|
delta = Math.max(
|
|
814
829
|
child.parent.minInlineBlockSpacing,
|
|
815
|
-
-child.originDeltaX +
|
|
830
|
+
-child.originDeltaX + getDefaultSpacing5(child.entity, ConstantKeys3.BRANCH_SPACING)
|
|
816
831
|
);
|
|
817
832
|
} else {
|
|
818
833
|
delta = Math.max(
|
|
819
834
|
child.parent.minInlineBlockSpacing,
|
|
820
|
-
-child.originDeltaY +
|
|
835
|
+
-child.originDeltaY + getDefaultSpacing5(child.entity, ConstantKeys3.BRANCH_SPACING)
|
|
821
836
|
);
|
|
822
837
|
}
|
|
823
838
|
return {
|
|
@@ -834,13 +849,13 @@ var MainInlineBlocksRegistry = {
|
|
|
834
849
|
};
|
|
835
850
|
|
|
836
851
|
// src/activities/try-catch-extends/try-block.ts
|
|
837
|
-
import { DEFAULT_SPACING as
|
|
852
|
+
import { DEFAULT_SPACING as DEFAULT_SPACING5, FlowNodeBaseType as FlowNodeBaseType11 } from "@flowgram.ai/document";
|
|
838
853
|
var TryBlockRegistry = {
|
|
839
854
|
extend: FlowNodeBaseType11.BLOCK,
|
|
840
855
|
type: "tryBlock" /* TRY_BLOCK */,
|
|
841
856
|
meta: {
|
|
842
857
|
hidden: true,
|
|
843
|
-
spacing:
|
|
858
|
+
spacing: DEFAULT_SPACING5.NULL
|
|
844
859
|
},
|
|
845
860
|
getLines() {
|
|
846
861
|
return [];
|
|
@@ -851,13 +866,41 @@ var TryBlockRegistry = {
|
|
|
851
866
|
};
|
|
852
867
|
|
|
853
868
|
// src/activities/try-catch-extends/try-slot.ts
|
|
854
|
-
import {
|
|
869
|
+
import { FlowTransitionLabelEnum as FlowTransitionLabelEnum8 } from "@flowgram.ai/document";
|
|
855
870
|
var TrySlotRegistry = {
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
871
|
+
type: "trySlot" /* TRY_SLOT */,
|
|
872
|
+
meta: {
|
|
873
|
+
inlineSpacingAfter: 16,
|
|
874
|
+
spacing: 0,
|
|
875
|
+
size: {
|
|
876
|
+
width: 16,
|
|
877
|
+
height: 0
|
|
878
|
+
}
|
|
879
|
+
},
|
|
880
|
+
onAfterUpdateLocalTransform(transform) {
|
|
881
|
+
if (transform.entity.isVertical) {
|
|
882
|
+
transform.data.size = {
|
|
883
|
+
width: 16,
|
|
884
|
+
height: 0
|
|
885
|
+
};
|
|
886
|
+
} else {
|
|
887
|
+
transform.data.size = {
|
|
888
|
+
width: 0,
|
|
889
|
+
height: 16
|
|
890
|
+
};
|
|
891
|
+
}
|
|
892
|
+
transform.transform.update({
|
|
893
|
+
size: transform.data.size
|
|
894
|
+
});
|
|
895
|
+
},
|
|
896
|
+
getLabels(transition) {
|
|
897
|
+
return [
|
|
898
|
+
{
|
|
899
|
+
offset: transition.transform.bounds.center,
|
|
900
|
+
type: FlowTransitionLabelEnum8.ADDER_LABEL
|
|
901
|
+
}
|
|
902
|
+
];
|
|
903
|
+
}
|
|
861
904
|
};
|
|
862
905
|
|
|
863
906
|
// src/activities/try-catch.ts
|
|
@@ -890,7 +933,7 @@ var TryCatchRegistry = {
|
|
|
890
933
|
const addedNodes = [];
|
|
891
934
|
const tryCatchIconNode = document.addNode({
|
|
892
935
|
id: `$tryCatchIcon$${node.id}`,
|
|
893
|
-
type:
|
|
936
|
+
type: FlowNodeBaseType12.BLOCK_ICON,
|
|
894
937
|
originParent: node,
|
|
895
938
|
parent: node
|
|
896
939
|
});
|
|
@@ -901,13 +944,15 @@ var TryCatchRegistry = {
|
|
|
901
944
|
parent: node
|
|
902
945
|
});
|
|
903
946
|
const tryBlockNode = document.addNode({
|
|
904
|
-
id:
|
|
905
|
-
type: "tryBlock" /* TRY_BLOCK */,
|
|
947
|
+
id: tryBlock.id,
|
|
948
|
+
type: tryBlock.type || "tryBlock" /* TRY_BLOCK */,
|
|
906
949
|
originParent: node,
|
|
907
|
-
parent: mainBlockNode
|
|
950
|
+
parent: mainBlockNode,
|
|
951
|
+
data: tryBlock.data
|
|
908
952
|
});
|
|
909
953
|
const trySlotNode = document.addNode({
|
|
910
|
-
id: tryBlock.id
|
|
954
|
+
id: `$trySlot$${tryBlock.id}`,
|
|
955
|
+
hidden: true,
|
|
911
956
|
type: "trySlot" /* TRY_SLOT */,
|
|
912
957
|
// 占位节点
|
|
913
958
|
originParent: node,
|
|
@@ -926,8 +971,17 @@ var TryCatchRegistry = {
|
|
|
926
971
|
trySlotNode,
|
|
927
972
|
catchInlineBlocksNode
|
|
928
973
|
);
|
|
974
|
+
(tryBlock.blocks || []).forEach((blockData) => {
|
|
975
|
+
document.addNode(
|
|
976
|
+
{
|
|
977
|
+
...blockData,
|
|
978
|
+
parent: tryBlockNode
|
|
979
|
+
},
|
|
980
|
+
addedNodes
|
|
981
|
+
);
|
|
982
|
+
});
|
|
929
983
|
catchBlocks.forEach((blockData) => {
|
|
930
|
-
|
|
984
|
+
document.addBlock(node, blockData, addedNodes);
|
|
931
985
|
});
|
|
932
986
|
return addedNodes;
|
|
933
987
|
},
|
|
@@ -941,13 +995,14 @@ var TryCatchRegistry = {
|
|
|
941
995
|
const parent = node.document.getNode(`$catchInlineBlocks$${node.id}`);
|
|
942
996
|
const block = node.document.addNode({
|
|
943
997
|
id: blockData.id,
|
|
944
|
-
type: "catchBlock" /* CATCH_BLOCK */,
|
|
998
|
+
type: blockData.type || "catchBlock" /* CATCH_BLOCK */,
|
|
945
999
|
originParent: node,
|
|
946
|
-
parent
|
|
1000
|
+
parent,
|
|
1001
|
+
data: blockData.data
|
|
947
1002
|
});
|
|
948
1003
|
const blockOrderIcon = node.document.addNode({
|
|
949
1004
|
id: `$blockOrderIcon$${blockData.id}`,
|
|
950
|
-
type:
|
|
1005
|
+
type: FlowNodeBaseType12.BLOCK_ORDER_ICON,
|
|
951
1006
|
originParent: node,
|
|
952
1007
|
parent: block
|
|
953
1008
|
});
|
|
@@ -983,7 +1038,7 @@ var TryCatchRegistry = {
|
|
|
983
1038
|
* icon 节点
|
|
984
1039
|
*/
|
|
985
1040
|
{
|
|
986
|
-
type:
|
|
1041
|
+
type: FlowNodeBaseType12.BLOCK_ICON,
|
|
987
1042
|
meta: {
|
|
988
1043
|
spacing: 54 /* INLINE_SPACING_TOP */
|
|
989
1044
|
},
|
|
@@ -1003,20 +1058,20 @@ var TryCatchRegistry = {
|
|
|
1003
1058
|
import { Point as Point5 } from "@flowgram.ai/utils";
|
|
1004
1059
|
import { FlowTextKey as FlowTextKey3 } from "@flowgram.ai/renderer";
|
|
1005
1060
|
import {
|
|
1006
|
-
FlowNodeBaseType as
|
|
1007
|
-
FlowTransitionLabelEnum as
|
|
1008
|
-
getDefaultSpacing as
|
|
1009
|
-
ConstantKeys as
|
|
1061
|
+
FlowNodeBaseType as FlowNodeBaseType14,
|
|
1062
|
+
FlowTransitionLabelEnum as FlowTransitionLabelEnum11,
|
|
1063
|
+
getDefaultSpacing as getDefaultSpacing7,
|
|
1064
|
+
ConstantKeys as ConstantKeys6
|
|
1010
1065
|
} from "@flowgram.ai/document";
|
|
1011
1066
|
|
|
1012
1067
|
// src/activities/loop-extends/constants.ts
|
|
1013
|
-
import { ConstantKeys as
|
|
1068
|
+
import { ConstantKeys as ConstantKeys4 } from "@flowgram.ai/document";
|
|
1014
1069
|
var LoopSpacings = {
|
|
1015
1070
|
SPACING: 16,
|
|
1016
1071
|
// 距离下面节点距离
|
|
1017
1072
|
COLLAPSE_INLINE_SPACING_BOTTOM: 60,
|
|
1018
1073
|
// 距离下面节点距离
|
|
1019
|
-
[
|
|
1074
|
+
[ConstantKeys4.INLINE_SPACING_BOTTOM]: 48,
|
|
1020
1075
|
// 下边空白
|
|
1021
1076
|
MIN_INLINE_BLOCK_SPACING: 280,
|
|
1022
1077
|
// 最小循环圈宽度
|
|
@@ -1028,7 +1083,7 @@ var LoopSpacings = {
|
|
|
1028
1083
|
// 左边空分支宽度
|
|
1029
1084
|
LOOP_BLOCK_ICON_SPACING: 13,
|
|
1030
1085
|
// inlineBlocks 的 inlineBottom
|
|
1031
|
-
[
|
|
1086
|
+
[ConstantKeys4.INLINE_BLOCKS_INLINE_SPACING_BOTTOM]: 23,
|
|
1032
1087
|
// inlineBlocks 的 inlineBottom
|
|
1033
1088
|
INLINE_BLOCKS_INLINE_SPACING_TOP: 30
|
|
1034
1089
|
// inlineBlocks 的 inlineTop
|
|
@@ -1080,7 +1135,7 @@ var LoopRightEmptyBlockRegistry = {
|
|
|
1080
1135
|
};
|
|
1081
1136
|
|
|
1082
1137
|
// src/activities/loop-extends/loop-empty-branch.ts
|
|
1083
|
-
import { FlowTransitionLabelEnum as
|
|
1138
|
+
import { FlowTransitionLabelEnum as FlowTransitionLabelEnum9 } from "@flowgram.ai/document";
|
|
1084
1139
|
var LoopEmptyBranchRegistry = {
|
|
1085
1140
|
type: "loopEmptyBranch" /* LOOP_EMPTY_BRANCH */,
|
|
1086
1141
|
meta: {
|
|
@@ -1097,7 +1152,7 @@ var LoopEmptyBranchRegistry = {
|
|
|
1097
1152
|
if (isVertical) {
|
|
1098
1153
|
return [
|
|
1099
1154
|
{
|
|
1100
|
-
type:
|
|
1155
|
+
type: FlowTransitionLabelEnum9.ADDER_LABEL,
|
|
1101
1156
|
offset: {
|
|
1102
1157
|
x: currentTransform.inputPoint.x,
|
|
1103
1158
|
y: currentTransform.bounds.center.y + 8
|
|
@@ -1108,7 +1163,7 @@ var LoopEmptyBranchRegistry = {
|
|
|
1108
1163
|
}
|
|
1109
1164
|
return [
|
|
1110
1165
|
{
|
|
1111
|
-
type:
|
|
1166
|
+
type: FlowTransitionLabelEnum9.ADDER_LABEL,
|
|
1112
1167
|
offset: {
|
|
1113
1168
|
x: currentTransform.bounds.center.x + 8,
|
|
1114
1169
|
y: currentTransform.inputPoint.y
|
|
@@ -1138,27 +1193,27 @@ var LoopEmptyBranchRegistry = {
|
|
|
1138
1193
|
import { Point as Point4 } from "@flowgram.ai/utils";
|
|
1139
1194
|
import { FlowTextKey as FlowTextKey2 } from "@flowgram.ai/renderer";
|
|
1140
1195
|
import {
|
|
1141
|
-
FlowNodeBaseType as
|
|
1142
|
-
FlowTransitionLabelEnum as
|
|
1196
|
+
FlowNodeBaseType as FlowNodeBaseType13,
|
|
1197
|
+
FlowTransitionLabelEnum as FlowTransitionLabelEnum10,
|
|
1143
1198
|
FlowTransitionLineEnum as FlowTransitionLineEnum5,
|
|
1144
|
-
getDefaultSpacing as
|
|
1145
|
-
ConstantKeys as
|
|
1199
|
+
getDefaultSpacing as getDefaultSpacing6,
|
|
1200
|
+
ConstantKeys as ConstantKeys5
|
|
1146
1201
|
} from "@flowgram.ai/document";
|
|
1147
1202
|
var LoopInlineBlocksNodeRegistry = {
|
|
1148
|
-
type:
|
|
1203
|
+
type: FlowNodeBaseType13.INLINE_BLOCKS,
|
|
1149
1204
|
meta: {
|
|
1150
1205
|
inlineSpacingPre: (node) => {
|
|
1151
|
-
const inlineBlocksInlineSpacingTop =
|
|
1206
|
+
const inlineBlocksInlineSpacingTop = getDefaultSpacing6(
|
|
1152
1207
|
node.entity,
|
|
1153
|
-
|
|
1208
|
+
ConstantKeys5.INLINE_BLOCKS_INLINE_SPACING_TOP,
|
|
1154
1209
|
LoopSpacings.INLINE_BLOCKS_INLINE_SPACING_TOP
|
|
1155
1210
|
);
|
|
1156
1211
|
return inlineBlocksInlineSpacingTop;
|
|
1157
1212
|
},
|
|
1158
1213
|
inlineSpacingAfter: (node) => {
|
|
1159
|
-
const inlineBlocksInlineSpacingBottom =
|
|
1214
|
+
const inlineBlocksInlineSpacingBottom = getDefaultSpacing6(
|
|
1160
1215
|
node.entity,
|
|
1161
|
-
|
|
1216
|
+
ConstantKeys5.INLINE_BLOCKS_INLINE_SPACING_BOTTOM,
|
|
1162
1217
|
LoopSpacings.INLINE_BLOCKS_INLINE_SPACING_BOTTOM
|
|
1163
1218
|
);
|
|
1164
1219
|
return inlineBlocksInlineSpacingBottom;
|
|
@@ -1218,7 +1273,7 @@ var LoopInlineBlocksNodeRegistry = {
|
|
|
1218
1273
|
const rightBlockTransform = currentTransform.children[1];
|
|
1219
1274
|
if (transition.entity.originParent?.id.startsWith("while_")) {
|
|
1220
1275
|
labels.push({
|
|
1221
|
-
type:
|
|
1276
|
+
type: FlowTransitionLabelEnum10.TEXT_LABEL,
|
|
1222
1277
|
renderKey: FlowTextKey2.LOOP_WHILE_TEXT,
|
|
1223
1278
|
rotate: isVertical ? "" : "-90deg",
|
|
1224
1279
|
offset: isVertical ? {
|
|
@@ -1231,7 +1286,7 @@ var LoopInlineBlocksNodeRegistry = {
|
|
|
1231
1286
|
});
|
|
1232
1287
|
} else {
|
|
1233
1288
|
labels.push({
|
|
1234
|
-
type:
|
|
1289
|
+
type: FlowTransitionLabelEnum10.TEXT_LABEL,
|
|
1235
1290
|
renderKey: FlowTextKey2.LOOP_TRAVERSE_TEXT,
|
|
1236
1291
|
// rotate: isVertical ? '' : '-90deg',
|
|
1237
1292
|
offset: isVertical ? { x: leftBlockTransform.inputPoint.x, y: currentTransform.bounds.center.y + 5 } : { x: currentTransform.bounds.center.x + 5, y: leftBlockTransform.inputPoint.y }
|
|
@@ -1250,9 +1305,9 @@ var LoopRegistry = {
|
|
|
1250
1305
|
if (node.collapsed) {
|
|
1251
1306
|
return LoopSpacings.COLLAPSE_INLINE_SPACING_BOTTOM;
|
|
1252
1307
|
}
|
|
1253
|
-
const inlineSpacingBottom =
|
|
1308
|
+
const inlineSpacingBottom = getDefaultSpacing7(
|
|
1254
1309
|
node.entity,
|
|
1255
|
-
|
|
1310
|
+
ConstantKeys6.INLINE_SPACING_BOTTOM,
|
|
1256
1311
|
LoopSpacings.INLINE_SPACING_BOTTOM
|
|
1257
1312
|
);
|
|
1258
1313
|
return inlineSpacingBottom;
|
|
@@ -1275,14 +1330,14 @@ var LoopRegistry = {
|
|
|
1275
1330
|
const loopBlocks = json.blocks || [];
|
|
1276
1331
|
const loopIconNode = document.addNode({
|
|
1277
1332
|
id: `$blockIcon$${node.id}`,
|
|
1278
|
-
type:
|
|
1333
|
+
type: FlowNodeBaseType14.BLOCK_ICON,
|
|
1279
1334
|
originParent: node,
|
|
1280
1335
|
parent: node
|
|
1281
1336
|
});
|
|
1282
1337
|
const loopInlineBlocks = document.addNode({
|
|
1283
1338
|
id: `$inlineBlocks$${node.id}`,
|
|
1284
1339
|
hidden: true,
|
|
1285
|
-
type:
|
|
1340
|
+
type: FlowNodeBaseType14.INLINE_BLOCKS,
|
|
1286
1341
|
originParent: node,
|
|
1287
1342
|
parent: node
|
|
1288
1343
|
});
|
|
@@ -1296,7 +1351,7 @@ var LoopRegistry = {
|
|
|
1296
1351
|
const loopBlockNode = document.addNode({
|
|
1297
1352
|
id: `$block$${node.id}`,
|
|
1298
1353
|
hidden: true,
|
|
1299
|
-
type:
|
|
1354
|
+
type: FlowNodeBaseType14.BLOCK,
|
|
1300
1355
|
// : LoopTypeEnum.LOOP_RIGHT_EMPTY_BLOCK,
|
|
1301
1356
|
originParent: node,
|
|
1302
1357
|
parent: loopInlineBlocks
|
|
@@ -1334,7 +1389,7 @@ var LoopRegistry = {
|
|
|
1334
1389
|
return [
|
|
1335
1390
|
// 循环结束
|
|
1336
1391
|
{
|
|
1337
|
-
type:
|
|
1392
|
+
type: FlowTransitionLabelEnum11.TEXT_LABEL,
|
|
1338
1393
|
renderKey: FlowTextKey3.LOOP_END_TEXT,
|
|
1339
1394
|
// 循环 label 垂直样式展示,而非 rotate 旋转文案
|
|
1340
1395
|
props: isVertical ? void 0 : {
|
|
@@ -1347,7 +1402,7 @@ var LoopRegistry = {
|
|
|
1347
1402
|
offset: Point5.move(currentTransform.outputPoint, isVertical ? { y: -26 } : { x: -26 })
|
|
1348
1403
|
},
|
|
1349
1404
|
{
|
|
1350
|
-
type:
|
|
1405
|
+
type: FlowTransitionLabelEnum11.ADDER_LABEL,
|
|
1351
1406
|
offset: currentTransform.outputPoint
|
|
1352
1407
|
}
|
|
1353
1408
|
];
|
|
@@ -1381,7 +1436,7 @@ var LoopRegistry = {
|
|
|
1381
1436
|
},
|
|
1382
1437
|
extendChildRegistries: [
|
|
1383
1438
|
{
|
|
1384
|
-
type:
|
|
1439
|
+
type: FlowNodeBaseType14.BLOCK_ICON,
|
|
1385
1440
|
meta: {
|
|
1386
1441
|
spacing: LoopSpacings.LOOP_BLOCK_ICON_SPACING
|
|
1387
1442
|
}
|
|
@@ -1391,6 +1446,9 @@ var LoopRegistry = {
|
|
|
1391
1446
|
LoopRightEmptyBlockRegistry,
|
|
1392
1447
|
LoopInlineBlocksNodeRegistry
|
|
1393
1448
|
],
|
|
1449
|
+
/**
|
|
1450
|
+
* @depreacted
|
|
1451
|
+
*/
|
|
1394
1452
|
addChild(node, json, options = {}) {
|
|
1395
1453
|
const { index } = options;
|
|
1396
1454
|
const document = node.document;
|
|
@@ -1404,33 +1462,33 @@ var LoopRegistry = {
|
|
|
1404
1462
|
};
|
|
1405
1463
|
|
|
1406
1464
|
// src/activities/root.ts
|
|
1407
|
-
import { DEFAULT_SPACING as
|
|
1465
|
+
import { DEFAULT_SPACING as DEFAULT_SPACING6, FlowNodeBaseType as FlowNodeBaseType15 } from "@flowgram.ai/document";
|
|
1408
1466
|
var RootRegistry = {
|
|
1409
|
-
type:
|
|
1467
|
+
type: FlowNodeBaseType15.ROOT,
|
|
1410
1468
|
meta: {
|
|
1411
|
-
spacing:
|
|
1469
|
+
spacing: DEFAULT_SPACING6.NULL,
|
|
1412
1470
|
hidden: true
|
|
1413
1471
|
},
|
|
1414
1472
|
getInputPoint(transform) {
|
|
1415
1473
|
return transform.firstChild?.inputPoint || transform.bounds.topCenter;
|
|
1416
1474
|
},
|
|
1417
1475
|
getOutputPoint(transform) {
|
|
1418
|
-
return transform.
|
|
1476
|
+
return transform.lastChild?.outputPoint || transform.bounds.bottomCenter;
|
|
1419
1477
|
}
|
|
1420
1478
|
};
|
|
1421
1479
|
|
|
1422
1480
|
// src/activities/empty.ts
|
|
1423
1481
|
import {
|
|
1424
|
-
FlowNodeBaseType as
|
|
1425
|
-
FlowTransitionLabelEnum as
|
|
1426
|
-
ConstantKeys as
|
|
1427
|
-
getDefaultSpacing as
|
|
1482
|
+
FlowNodeBaseType as FlowNodeBaseType16,
|
|
1483
|
+
FlowTransitionLabelEnum as FlowTransitionLabelEnum12,
|
|
1484
|
+
ConstantKeys as ConstantKeys7,
|
|
1485
|
+
getDefaultSpacing as getDefaultSpacing8
|
|
1428
1486
|
} from "@flowgram.ai/document";
|
|
1429
1487
|
var EmptyRegistry = {
|
|
1430
|
-
type:
|
|
1488
|
+
type: FlowNodeBaseType16.EMPTY,
|
|
1431
1489
|
meta: {
|
|
1432
1490
|
spacing: (node) => {
|
|
1433
|
-
const spacing =
|
|
1491
|
+
const spacing = getDefaultSpacing8(node.entity, ConstantKeys7.NODE_SPACING);
|
|
1434
1492
|
return spacing / 2;
|
|
1435
1493
|
},
|
|
1436
1494
|
size: { width: 0, height: 0 },
|
|
@@ -1440,12 +1498,946 @@ var EmptyRegistry = {
|
|
|
1440
1498
|
return [
|
|
1441
1499
|
{
|
|
1442
1500
|
offset: transition.transform.bounds,
|
|
1443
|
-
type:
|
|
1501
|
+
type: FlowTransitionLabelEnum12.ADDER_LABEL
|
|
1502
|
+
}
|
|
1503
|
+
];
|
|
1504
|
+
}
|
|
1505
|
+
};
|
|
1506
|
+
|
|
1507
|
+
// src/activities/simple-split.ts
|
|
1508
|
+
import {
|
|
1509
|
+
FlowNodeSplitType as FlowNodeSplitType3,
|
|
1510
|
+
FlowNodeBaseType as FlowNodeBaseType17
|
|
1511
|
+
} from "@flowgram.ai/document";
|
|
1512
|
+
var SimpleSplitRegistry = {
|
|
1513
|
+
type: FlowNodeSplitType3.SIMPLE_SPLIT,
|
|
1514
|
+
extend: FlowNodeSplitType3.DYNAMIC_SPLIT,
|
|
1515
|
+
onBlockChildCreate(originParent, blockData, addedNodes = []) {
|
|
1516
|
+
const { document } = originParent;
|
|
1517
|
+
const parent = document.getNode(`$inlineBlocks$${originParent.id}`);
|
|
1518
|
+
const realBlock = document.addNode(
|
|
1519
|
+
{
|
|
1520
|
+
...blockData,
|
|
1521
|
+
type: blockData.type || FlowNodeBaseType17.BLOCK,
|
|
1522
|
+
parent
|
|
1523
|
+
},
|
|
1524
|
+
addedNodes
|
|
1525
|
+
);
|
|
1526
|
+
addedNodes.push(realBlock);
|
|
1527
|
+
return realBlock;
|
|
1528
|
+
}
|
|
1529
|
+
// addChild(node, json, options = {}) {
|
|
1530
|
+
// const { index } = options;
|
|
1531
|
+
// const document = node.document;
|
|
1532
|
+
// return document.addBlock(node, json, undefined, undefined, index);
|
|
1533
|
+
// }
|
|
1534
|
+
};
|
|
1535
|
+
|
|
1536
|
+
// src/activities/break.ts
|
|
1537
|
+
import { FlowNodeBaseType as FlowNodeBaseType18 } from "@flowgram.ai/document";
|
|
1538
|
+
var BreakRegistry = {
|
|
1539
|
+
type: FlowNodeBaseType18.BREAK,
|
|
1540
|
+
extend: FlowNodeBaseType18.END
|
|
1541
|
+
};
|
|
1542
|
+
|
|
1543
|
+
// src/activities/input.ts
|
|
1544
|
+
import {
|
|
1545
|
+
FlowNodeBaseType as FlowNodeBaseType19,
|
|
1546
|
+
FlowTransitionLineEnum as FlowTransitionLineEnum6,
|
|
1547
|
+
LABEL_SIDE_TYPE as LABEL_SIDE_TYPE2,
|
|
1548
|
+
FlowTransitionLabelEnum as FlowTransitionLabelEnum13
|
|
1549
|
+
} from "@flowgram.ai/document";
|
|
1550
|
+
var InputRegistry = {
|
|
1551
|
+
type: FlowNodeBaseType19.INPUT,
|
|
1552
|
+
extend: FlowNodeBaseType19.BLOCK,
|
|
1553
|
+
meta: {
|
|
1554
|
+
hidden: false
|
|
1555
|
+
},
|
|
1556
|
+
getLines(transition, layout) {
|
|
1557
|
+
const currentTransform = transition.transform;
|
|
1558
|
+
const { isVertical } = transition.entity;
|
|
1559
|
+
const lines = [];
|
|
1560
|
+
const hasBranchDraggingAdder = currentTransform && currentTransform.entity.isInlineBlock && transition.renderData.draggable;
|
|
1561
|
+
if (hasBranchDraggingAdder) {
|
|
1562
|
+
if (isVertical) {
|
|
1563
|
+
const currentOffsetRightX = currentTransform.firstChild ? currentTransform.firstChild.bounds.right : currentTransform.bounds.right;
|
|
1564
|
+
const nextOffsetLeftX = (currentTransform.next?.firstChild ? currentTransform.next?.firstChild.bounds?.left : currentTransform.next?.bounds?.left) || 0;
|
|
1565
|
+
const currentInputPointY = currentTransform.outputPoint.y;
|
|
1566
|
+
if (currentTransform?.next) {
|
|
1567
|
+
lines.push({
|
|
1568
|
+
type: FlowTransitionLineEnum6.MERGE_LINE,
|
|
1569
|
+
isDraggingLine: true,
|
|
1570
|
+
from: {
|
|
1571
|
+
x: (currentOffsetRightX + nextOffsetLeftX) / 2,
|
|
1572
|
+
y: currentInputPointY
|
|
1573
|
+
},
|
|
1574
|
+
to: currentTransform.parent.outputPoint,
|
|
1575
|
+
side: LABEL_SIDE_TYPE2.NORMAL_BRANCH
|
|
1576
|
+
});
|
|
1577
|
+
}
|
|
1578
|
+
} else {
|
|
1579
|
+
const currentOffsetBottomX = currentTransform.firstChild ? currentTransform.firstChild.bounds.bottom : currentTransform.bounds.bottom;
|
|
1580
|
+
const nextOffsetTopX = (currentTransform.next?.firstChild ? currentTransform.next?.firstChild.bounds?.top : currentTransform.next?.bounds?.top) || 0;
|
|
1581
|
+
const currentInputPointX = currentTransform.outputPoint.x;
|
|
1582
|
+
if (currentTransform?.next) {
|
|
1583
|
+
lines.push({
|
|
1584
|
+
type: FlowTransitionLineEnum6.MERGE_LINE,
|
|
1585
|
+
isDraggingLine: true,
|
|
1586
|
+
from: {
|
|
1587
|
+
x: currentInputPointX,
|
|
1588
|
+
y: (currentOffsetBottomX + nextOffsetTopX) / 2
|
|
1589
|
+
},
|
|
1590
|
+
to: currentTransform.parent.outputPoint,
|
|
1591
|
+
side: LABEL_SIDE_TYPE2.NORMAL_BRANCH
|
|
1592
|
+
});
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
if (!transition.isNodeEnd) {
|
|
1597
|
+
lines.push({
|
|
1598
|
+
type: FlowTransitionLineEnum6.MERGE_LINE,
|
|
1599
|
+
from: currentTransform.outputPoint,
|
|
1600
|
+
to: currentTransform.parent.outputPoint,
|
|
1601
|
+
side: LABEL_SIDE_TYPE2.NORMAL_BRANCH
|
|
1602
|
+
});
|
|
1603
|
+
}
|
|
1604
|
+
return lines;
|
|
1605
|
+
},
|
|
1606
|
+
getLabels(transition) {
|
|
1607
|
+
const currentTransform = transition.transform;
|
|
1608
|
+
const { isVertical } = transition.entity;
|
|
1609
|
+
const draggingLabel = [];
|
|
1610
|
+
const hasBranchDraggingAdder = currentTransform && currentTransform.entity.isInlineBlock && transition.renderData.draggable;
|
|
1611
|
+
if (hasBranchDraggingAdder) {
|
|
1612
|
+
if (isVertical) {
|
|
1613
|
+
const currentOffsetRightX = currentTransform.firstChild ? currentTransform.firstChild.bounds.right : currentTransform.bounds.right;
|
|
1614
|
+
const nextOffsetLeftX = (currentTransform.next?.firstChild ? currentTransform.next.firstChild.bounds?.left : currentTransform.next?.bounds?.left) || 0;
|
|
1615
|
+
const currentInputPointY = currentTransform.outputPoint.y;
|
|
1616
|
+
if (currentTransform?.next) {
|
|
1617
|
+
draggingLabel.push({
|
|
1618
|
+
offset: {
|
|
1619
|
+
x: (currentOffsetRightX + nextOffsetLeftX) / 2,
|
|
1620
|
+
y: currentInputPointY
|
|
1621
|
+
},
|
|
1622
|
+
type: FlowTransitionLabelEnum13.BRANCH_DRAGGING_LABEL,
|
|
1623
|
+
width: nextOffsetLeftX - currentOffsetRightX,
|
|
1624
|
+
props: {
|
|
1625
|
+
side: LABEL_SIDE_TYPE2.NORMAL_BRANCH
|
|
1626
|
+
}
|
|
1627
|
+
});
|
|
1628
|
+
}
|
|
1629
|
+
} else {
|
|
1630
|
+
const currentOffsetBottomX = currentTransform.firstChild ? currentTransform.firstChild.bounds.bottom : currentTransform.bounds.bottom;
|
|
1631
|
+
const nextOffsetTopX = (currentTransform.next?.firstChild ? currentTransform.next.firstChild.bounds?.top : currentTransform.next?.bounds?.top) || 0;
|
|
1632
|
+
const currentInputPointX = currentTransform.outputPoint.x;
|
|
1633
|
+
if (currentTransform?.next) {
|
|
1634
|
+
draggingLabel.push({
|
|
1635
|
+
offset: {
|
|
1636
|
+
x: currentInputPointX,
|
|
1637
|
+
y: (currentOffsetBottomX + nextOffsetTopX) / 2
|
|
1638
|
+
},
|
|
1639
|
+
type: FlowTransitionLabelEnum13.BRANCH_DRAGGING_LABEL,
|
|
1640
|
+
width: nextOffsetTopX - currentOffsetBottomX,
|
|
1641
|
+
props: {
|
|
1642
|
+
side: LABEL_SIDE_TYPE2.NORMAL_BRANCH
|
|
1643
|
+
}
|
|
1644
|
+
});
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
return [...draggingLabel];
|
|
1649
|
+
}
|
|
1650
|
+
};
|
|
1651
|
+
|
|
1652
|
+
// src/activities/output.ts
|
|
1653
|
+
import { FlowNodeBaseType as FlowNodeBaseType20 } from "@flowgram.ai/document";
|
|
1654
|
+
var OuputRegistry = {
|
|
1655
|
+
type: FlowNodeBaseType20.OUTPUT,
|
|
1656
|
+
extend: FlowNodeBaseType20.BLOCK,
|
|
1657
|
+
meta: {
|
|
1658
|
+
hidden: false,
|
|
1659
|
+
isNodeEnd: true
|
|
1660
|
+
}
|
|
1661
|
+
};
|
|
1662
|
+
|
|
1663
|
+
// src/activities/multi-outputs.ts
|
|
1664
|
+
import {
|
|
1665
|
+
FlowLayoutDefault as FlowLayoutDefault7,
|
|
1666
|
+
FlowNodeSplitType as FlowNodeSplitType4,
|
|
1667
|
+
FlowNodeBaseType as FlowNodeBaseType21
|
|
1668
|
+
} from "@flowgram.ai/document";
|
|
1669
|
+
var MultiOuputsRegistry = {
|
|
1670
|
+
type: FlowNodeBaseType21.MULTI_OUTPUTS,
|
|
1671
|
+
extend: FlowNodeSplitType4.SIMPLE_SPLIT,
|
|
1672
|
+
meta: {
|
|
1673
|
+
isNodeEnd: true
|
|
1674
|
+
},
|
|
1675
|
+
getLines: (transition, layout) => {
|
|
1676
|
+
if (transition.entity.parent?.flowNodeType === FlowNodeBaseType21.INLINE_BLOCKS) {
|
|
1677
|
+
return BlockRegistry.getLines(transition, layout);
|
|
1678
|
+
}
|
|
1679
|
+
return [];
|
|
1680
|
+
},
|
|
1681
|
+
getLabels: (transition, layout) => [
|
|
1682
|
+
...DynamicSplitRegistry.getLabels(transition, layout),
|
|
1683
|
+
...BlockRegistry.getLabels(transition, layout)
|
|
1684
|
+
],
|
|
1685
|
+
getOutputPoint(transform, layout) {
|
|
1686
|
+
const isVertical = FlowLayoutDefault7.isVertical(layout);
|
|
1687
|
+
const lastChildOutput = transform.lastChild?.outputPoint;
|
|
1688
|
+
if (isVertical) {
|
|
1689
|
+
return {
|
|
1690
|
+
x: lastChildOutput ? lastChildOutput.x : transform.bounds.center.x,
|
|
1691
|
+
y: transform.bounds.bottom
|
|
1692
|
+
};
|
|
1693
|
+
}
|
|
1694
|
+
return {
|
|
1695
|
+
x: transform.bounds.right,
|
|
1696
|
+
y: lastChildOutput ? lastChildOutput.y : transform.bounds.center.y
|
|
1697
|
+
};
|
|
1698
|
+
},
|
|
1699
|
+
extendChildRegistries: [
|
|
1700
|
+
{
|
|
1701
|
+
type: FlowNodeBaseType21.BLOCK_ICON,
|
|
1702
|
+
meta: {
|
|
1703
|
+
// isNodeEnd: true
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
]
|
|
1707
|
+
};
|
|
1708
|
+
|
|
1709
|
+
// src/activities/multi-inputs.ts
|
|
1710
|
+
import { Point as Point6 } from "@flowgram.ai/utils";
|
|
1711
|
+
import { FlowRendererKey as FlowRendererKey4 } from "@flowgram.ai/renderer";
|
|
1712
|
+
import {
|
|
1713
|
+
FlowNodeBaseType as FlowNodeBaseType22,
|
|
1714
|
+
FlowNodeRenderData as FlowNodeRenderData3,
|
|
1715
|
+
FlowTransitionLabelEnum as FlowTransitionLabelEnum14,
|
|
1716
|
+
FlowNodeSplitType as FlowNodeSplitType5,
|
|
1717
|
+
getDefaultSpacing as getDefaultSpacing9,
|
|
1718
|
+
ConstantKeys as ConstantKeys8
|
|
1719
|
+
} from "@flowgram.ai/document";
|
|
1720
|
+
var MultiInputsRegistry = {
|
|
1721
|
+
type: FlowNodeBaseType22.MULTI_INPUTS,
|
|
1722
|
+
extend: FlowNodeSplitType5.SIMPLE_SPLIT,
|
|
1723
|
+
extendChildRegistries: [
|
|
1724
|
+
{
|
|
1725
|
+
type: FlowNodeBaseType22.BLOCK_ICON,
|
|
1726
|
+
meta: {
|
|
1727
|
+
hidden: true,
|
|
1728
|
+
spacing: 0
|
|
1729
|
+
},
|
|
1730
|
+
getLines() {
|
|
1731
|
+
return [];
|
|
1732
|
+
},
|
|
1733
|
+
getLabels() {
|
|
1734
|
+
return [];
|
|
1735
|
+
}
|
|
1736
|
+
},
|
|
1737
|
+
{
|
|
1738
|
+
type: FlowNodeBaseType22.INLINE_BLOCKS,
|
|
1739
|
+
meta: {
|
|
1740
|
+
inlineSpacingPre: 0
|
|
1741
|
+
},
|
|
1742
|
+
getLabels(transition) {
|
|
1743
|
+
const isVertical = transition.entity.isVertical;
|
|
1744
|
+
const currentTransform = transition.transform;
|
|
1745
|
+
const spacing = getDefaultSpacing9(
|
|
1746
|
+
transition.entity,
|
|
1747
|
+
ConstantKeys8.INLINE_BLOCKS_PADDING_BOTTOM
|
|
1748
|
+
);
|
|
1749
|
+
if (currentTransform.collapsed || transition.entity.childrenLength === 0) {
|
|
1750
|
+
return [
|
|
1751
|
+
{
|
|
1752
|
+
type: FlowTransitionLabelEnum14.CUSTOM_LABEL,
|
|
1753
|
+
renderKey: FlowRendererKey4.BRANCH_ADDER,
|
|
1754
|
+
offset: Point6.move(
|
|
1755
|
+
currentTransform.outputPoint,
|
|
1756
|
+
isVertical ? { y: spacing } : { x: spacing }
|
|
1757
|
+
),
|
|
1758
|
+
props: {
|
|
1759
|
+
// 激活状态
|
|
1760
|
+
activated: transition.entity.getData(FlowNodeRenderData3).activated,
|
|
1761
|
+
transform: currentTransform,
|
|
1762
|
+
// 传给外部使用的 node 信息
|
|
1763
|
+
node: currentTransform.originParent?.entity
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
];
|
|
1767
|
+
}
|
|
1768
|
+
return [
|
|
1769
|
+
{
|
|
1770
|
+
type: FlowTransitionLabelEnum14.CUSTOM_LABEL,
|
|
1771
|
+
renderKey: FlowRendererKey4.BRANCH_ADDER,
|
|
1772
|
+
offset: Point6.move(
|
|
1773
|
+
currentTransform.outputPoint,
|
|
1774
|
+
isVertical ? { y: -spacing / 2 } : { x: -spacing / 2 }
|
|
1775
|
+
),
|
|
1776
|
+
props: {
|
|
1777
|
+
// 激活状态
|
|
1778
|
+
activated: transition.entity.getData(FlowNodeRenderData3).activated,
|
|
1779
|
+
transform: currentTransform,
|
|
1780
|
+
// 传给外部使用的 node 信息
|
|
1781
|
+
node: currentTransform.originParent?.entity
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
];
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
],
|
|
1788
|
+
getLabels() {
|
|
1789
|
+
return [];
|
|
1790
|
+
}
|
|
1791
|
+
};
|
|
1792
|
+
|
|
1793
|
+
// src/activities/slot/slot.ts
|
|
1794
|
+
import { FlowNodeBaseType as FlowNodeBaseType28, getDefaultSpacing as getDefaultSpacing13 } from "@flowgram.ai/document";
|
|
1795
|
+
|
|
1796
|
+
// src/activities/slot/utils/transition.ts
|
|
1797
|
+
import { Point as Point7 } from "@flowgram.ai/utils";
|
|
1798
|
+
import {
|
|
1799
|
+
FlowTransitionLineEnum as FlowTransitionLineEnum7,
|
|
1800
|
+
FlowTransitionLabelEnum as FlowTransitionLabelEnum15,
|
|
1801
|
+
getDefaultSpacing as getDefaultSpacing10
|
|
1802
|
+
} from "@flowgram.ai/document";
|
|
1803
|
+
|
|
1804
|
+
// src/activities/slot/constants.ts
|
|
1805
|
+
import { FlowRendererKey as FlowRendererKey5 } from "@flowgram.ai/renderer";
|
|
1806
|
+
var RENDER_SLOT_ADDER_KEY = FlowRendererKey5.SLOT_ADDER;
|
|
1807
|
+
var RENDER_SLOT_LABEL_KEY = FlowRendererKey5.SLOT_LABEL;
|
|
1808
|
+
var RENDER_SLOT_COLLAPSE_KEY = FlowRendererKey5.SLOT_COLLAPSE;
|
|
1809
|
+
var SlotSpacingKey = {
|
|
1810
|
+
/**
|
|
1811
|
+
* = Next Node - Slot END
|
|
1812
|
+
*/
|
|
1813
|
+
SLOT_SPACING: "SLOT_SPACING",
|
|
1814
|
+
/**
|
|
1815
|
+
* = Slot Start Line - Slot Icon Right
|
|
1816
|
+
*/
|
|
1817
|
+
SLOT_START_DISTANCE: "SLOT_START_DISTANCE",
|
|
1818
|
+
/**
|
|
1819
|
+
* = Slot Radius
|
|
1820
|
+
*/
|
|
1821
|
+
SLOT_RADIUS: "SLOT_RADIUS",
|
|
1822
|
+
/**
|
|
1823
|
+
* = Slot Port - Slot Start
|
|
1824
|
+
*/
|
|
1825
|
+
SLOT_PORT_DISTANCE: "SLOT_PORT_DISTANCE",
|
|
1826
|
+
/**
|
|
1827
|
+
* = Slot Label - Slot Start
|
|
1828
|
+
*/
|
|
1829
|
+
SLOT_LABEL_DISTANCE: "SLOT_LABEL_DISTANCE",
|
|
1830
|
+
/**
|
|
1831
|
+
* = Slot Block - Slot Port
|
|
1832
|
+
*/
|
|
1833
|
+
SLOT_BLOCK_PORT_DISTANCE: "SLOT_BLOCK_PORT_DISTANCE",
|
|
1834
|
+
/**
|
|
1835
|
+
* Vertical Layout: Slot Block - Slot Block
|
|
1836
|
+
*/
|
|
1837
|
+
SLOT_BLOCK_VERTICAL_SPACING: "SLOT_BLOCK_VERTICAL_SPACING"
|
|
1838
|
+
};
|
|
1839
|
+
var SLOT_START_DISTANCE = 16;
|
|
1840
|
+
var SLOT_PORT_DISTANCE = 100;
|
|
1841
|
+
var SLOT_LABEL_DISTANCE = 32;
|
|
1842
|
+
var SLOT_BLOCK_PORT_DISTANCE = 32.5;
|
|
1843
|
+
var SLOT_RADIUS = 16;
|
|
1844
|
+
var SLOT_SPACING = 32;
|
|
1845
|
+
var SLOT_BLOCK_VERTICAL_SPACING = 32.5;
|
|
1846
|
+
var SLOT_NODE_LAST_SPACING = 10;
|
|
1847
|
+
|
|
1848
|
+
// src/activities/slot/typings.ts
|
|
1849
|
+
import { FlowNodeBaseType as FlowNodeBaseType23 } from "@flowgram.ai/document";
|
|
1850
|
+
var SlotNodeType = ((SlotNodeType2) => {
|
|
1851
|
+
SlotNodeType2[SlotNodeType2["Slot"] = FlowNodeBaseType23.SLOT] = "Slot";
|
|
1852
|
+
SlotNodeType2[SlotNodeType2["SlotBlock"] = FlowNodeBaseType23.SLOT_BLOCK] = "SlotBlock";
|
|
1853
|
+
SlotNodeType2["SlotInlineBlocks"] = "slotInlineBlocks";
|
|
1854
|
+
SlotNodeType2["SlotBlockInlineBlocks"] = "slotBlockInlineBlocks";
|
|
1855
|
+
return SlotNodeType2;
|
|
1856
|
+
})(SlotNodeType || {});
|
|
1857
|
+
|
|
1858
|
+
// src/activities/slot/utils/node.ts
|
|
1859
|
+
var canSlotDrilldown = (Slot) => !!Slot?.lastCollapsedChild?.blocks.length;
|
|
1860
|
+
var insideSlot = (entity) => !!entity?.parent?.isTypeOrExtendType(SlotNodeType.SlotBlock);
|
|
1861
|
+
var getDisplayFirstChildTransform = (transform) => {
|
|
1862
|
+
if (transform.firstChild) {
|
|
1863
|
+
return getDisplayFirstChildTransform(transform.firstChild);
|
|
1864
|
+
}
|
|
1865
|
+
return transform;
|
|
1866
|
+
};
|
|
1867
|
+
|
|
1868
|
+
// src/activities/slot/utils/transition.ts
|
|
1869
|
+
var getSlotChildLineStartPoint = (iconTransform) => {
|
|
1870
|
+
if (!iconTransform) {
|
|
1871
|
+
return { x: 0, y: 0 };
|
|
1872
|
+
}
|
|
1873
|
+
const startDistance = getDefaultSpacing10(
|
|
1874
|
+
iconTransform.entity,
|
|
1875
|
+
SlotSpacingKey.SLOT_START_DISTANCE,
|
|
1876
|
+
SLOT_START_DISTANCE
|
|
1877
|
+
);
|
|
1878
|
+
if (!iconTransform.entity.isVertical) {
|
|
1879
|
+
return {
|
|
1880
|
+
x: iconTransform?.bounds.center.x,
|
|
1881
|
+
y: iconTransform?.bounds.bottom + startDistance
|
|
1882
|
+
};
|
|
1883
|
+
}
|
|
1884
|
+
return {
|
|
1885
|
+
x: iconTransform?.bounds.right + startDistance,
|
|
1886
|
+
y: iconTransform?.bounds.center.y
|
|
1887
|
+
};
|
|
1888
|
+
};
|
|
1889
|
+
var getOutputPoint = (transform) => {
|
|
1890
|
+
const icon = transform.firstChild;
|
|
1891
|
+
if (!icon) {
|
|
1892
|
+
return { x: 0, y: 0 };
|
|
1893
|
+
}
|
|
1894
|
+
if (!transform.entity.isVertical) {
|
|
1895
|
+
return {
|
|
1896
|
+
x: transform.bounds.right,
|
|
1897
|
+
y: icon.outputPoint.y
|
|
1898
|
+
};
|
|
1899
|
+
}
|
|
1900
|
+
return {
|
|
1901
|
+
x: icon.outputPoint.x,
|
|
1902
|
+
y: transform.bounds.bottom
|
|
1903
|
+
};
|
|
1904
|
+
};
|
|
1905
|
+
var getInputPoint = (transform) => {
|
|
1906
|
+
const icon = transform.firstChild;
|
|
1907
|
+
if (!icon) {
|
|
1908
|
+
return { x: 0, y: 0 };
|
|
1909
|
+
}
|
|
1910
|
+
if (!transform.entity.isVertical) {
|
|
1911
|
+
return {
|
|
1912
|
+
x: transform.bounds.left,
|
|
1913
|
+
y: icon.outputPoint.y
|
|
1914
|
+
};
|
|
1915
|
+
}
|
|
1916
|
+
return icon.inputPoint;
|
|
1917
|
+
};
|
|
1918
|
+
var getTransitionToPoint = (transition) => {
|
|
1919
|
+
let toPoint = transition.transform.next?.inputPoint;
|
|
1920
|
+
const icon = transition.transform.firstChild;
|
|
1921
|
+
const parent = transition.transform.parent;
|
|
1922
|
+
if (!icon || !parent) {
|
|
1923
|
+
return { x: 0, y: 0 };
|
|
1924
|
+
}
|
|
1925
|
+
if (!transition.transform.next) {
|
|
1926
|
+
if (!transition.entity.isVertical) {
|
|
1927
|
+
toPoint = {
|
|
1928
|
+
x: parent.outputPoint.x,
|
|
1929
|
+
y: icon.outputPoint.y
|
|
1930
|
+
};
|
|
1931
|
+
} else {
|
|
1932
|
+
toPoint = {
|
|
1933
|
+
x: icon.outputPoint.x,
|
|
1934
|
+
y: parent.outputPoint.y
|
|
1935
|
+
};
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
return toPoint || { x: 0, y: 0 };
|
|
1939
|
+
};
|
|
1940
|
+
var drawStraightLine = (transition) => {
|
|
1941
|
+
const icon = transition.transform.firstChild;
|
|
1942
|
+
const toPoint = getTransitionToPoint(transition);
|
|
1943
|
+
if (!icon) {
|
|
1944
|
+
return [];
|
|
1945
|
+
}
|
|
1946
|
+
return [
|
|
1947
|
+
{
|
|
1948
|
+
type: FlowTransitionLineEnum7.STRAIGHT_LINE,
|
|
1949
|
+
from: icon.outputPoint,
|
|
1950
|
+
to: toPoint
|
|
1951
|
+
},
|
|
1952
|
+
{
|
|
1953
|
+
type: FlowTransitionLineEnum7.STRAIGHT_LINE,
|
|
1954
|
+
from: icon.inputPoint,
|
|
1955
|
+
to: transition.transform.inputPoint
|
|
1956
|
+
}
|
|
1957
|
+
];
|
|
1958
|
+
};
|
|
1959
|
+
var drawCollapseLabel = (transition) => {
|
|
1960
|
+
const icon = transition.transform;
|
|
1961
|
+
return [
|
|
1962
|
+
{
|
|
1963
|
+
type: FlowTransitionLabelEnum15.CUSTOM_LABEL,
|
|
1964
|
+
renderKey: RENDER_SLOT_COLLAPSE_KEY,
|
|
1965
|
+
offset: getSlotChildLineStartPoint(icon),
|
|
1966
|
+
props: {
|
|
1967
|
+
node: transition.entity.parent
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
];
|
|
1971
|
+
};
|
|
1972
|
+
var drawCollapseLine = (transition) => {
|
|
1973
|
+
const startDistance = getDefaultSpacing10(
|
|
1974
|
+
transition.transform.entity,
|
|
1975
|
+
SlotSpacingKey.SLOT_START_DISTANCE,
|
|
1976
|
+
SLOT_START_DISTANCE
|
|
1977
|
+
);
|
|
1978
|
+
return [
|
|
1979
|
+
{
|
|
1980
|
+
type: FlowTransitionLineEnum7.STRAIGHT_LINE,
|
|
1981
|
+
from: getSlotChildLineStartPoint(transition.transform),
|
|
1982
|
+
to: Point7.move(
|
|
1983
|
+
getSlotChildLineStartPoint(transition.transform),
|
|
1984
|
+
transition.entity.isVertical ? { x: -startDistance, y: 0 } : { x: 0, y: -startDistance }
|
|
1985
|
+
),
|
|
1986
|
+
style: {
|
|
1987
|
+
strokeDasharray: "5 5"
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
];
|
|
1991
|
+
};
|
|
1992
|
+
var drawStraightAdder = (transition) => {
|
|
1993
|
+
const toPoint = getTransitionToPoint(transition);
|
|
1994
|
+
const fromPoint = transition.transform.firstChild.outputPoint;
|
|
1995
|
+
const hoverProps = transition.entity.isVertical ? {
|
|
1996
|
+
hoverHeight: toPoint.y - fromPoint.y,
|
|
1997
|
+
hoverWidth: transition.transform.firstChild?.bounds.width
|
|
1998
|
+
} : {
|
|
1999
|
+
hoverHeight: transition.transform.firstChild?.bounds.height,
|
|
2000
|
+
hoverWidth: toPoint.x - fromPoint.x
|
|
2001
|
+
};
|
|
2002
|
+
return [
|
|
2003
|
+
{
|
|
2004
|
+
offset: Point7.getMiddlePoint(fromPoint, toPoint),
|
|
2005
|
+
type: FlowTransitionLabelEnum15.ADDER_LABEL,
|
|
2006
|
+
props: hoverProps
|
|
2007
|
+
}
|
|
2008
|
+
];
|
|
2009
|
+
};
|
|
2010
|
+
var getPortChildInput = (_child) => {
|
|
2011
|
+
if (!_child) {
|
|
2012
|
+
return { x: 0, y: 0 };
|
|
2013
|
+
}
|
|
2014
|
+
const firstChild = getDisplayFirstChildTransform(_child);
|
|
2015
|
+
return { x: _child.bounds.left, y: firstChild.bounds.center.y };
|
|
2016
|
+
};
|
|
2017
|
+
|
|
2018
|
+
// src/activities/slot/utils/layout.ts
|
|
2019
|
+
import { mean } from "lodash-es";
|
|
2020
|
+
var getDisplayFirstChildTop = (transform) => {
|
|
2021
|
+
if (transform.firstChild) {
|
|
2022
|
+
return transform.localBounds.top + getDisplayFirstChildTop(transform.firstChild);
|
|
2023
|
+
}
|
|
2024
|
+
return transform.localBounds.center.y;
|
|
2025
|
+
};
|
|
2026
|
+
var getPortMiddle = (_port) => {
|
|
2027
|
+
if (!_port.children.length) {
|
|
2028
|
+
return _port.localBounds.top;
|
|
2029
|
+
}
|
|
2030
|
+
const portChildInputs = [_port.firstChild, _port.lastChild].map(
|
|
2031
|
+
(_portChild) => getDisplayFirstChildTop(_portChild)
|
|
2032
|
+
);
|
|
2033
|
+
return _port.localBounds.top + mean(portChildInputs);
|
|
2034
|
+
};
|
|
2035
|
+
var getAllPortsMiddle = (inlineBlocks) => {
|
|
2036
|
+
if (!inlineBlocks.children.length) {
|
|
2037
|
+
return inlineBlocks.localBounds.height / 2;
|
|
2038
|
+
}
|
|
2039
|
+
const portInputs = [inlineBlocks.firstChild, inlineBlocks.lastChild].map(
|
|
2040
|
+
(_port) => getPortMiddle(_port)
|
|
2041
|
+
);
|
|
2042
|
+
return mean(portInputs);
|
|
2043
|
+
};
|
|
2044
|
+
|
|
2045
|
+
// src/activities/slot/utils/create.ts
|
|
2046
|
+
import { FlowNodeBaseType as FlowNodeBaseType24 } from "@flowgram.ai/document";
|
|
2047
|
+
var createSlotFromJSON = (node, json) => {
|
|
2048
|
+
const { document } = node;
|
|
2049
|
+
const addedNodes = [];
|
|
2050
|
+
const blockIconNode = document.addNode({
|
|
2051
|
+
id: `$slotIcon$${node.id}`,
|
|
2052
|
+
type: FlowNodeBaseType24.BLOCK_ICON,
|
|
2053
|
+
originParent: node,
|
|
2054
|
+
parent: node
|
|
2055
|
+
});
|
|
2056
|
+
const inlineBlocksNode = document.addNode({
|
|
2057
|
+
id: `$slotInlineBlocks$${node.id}`,
|
|
2058
|
+
type: "slotInlineBlocks" /* SlotInlineBlocks */,
|
|
2059
|
+
originParent: node,
|
|
2060
|
+
parent: node
|
|
2061
|
+
});
|
|
2062
|
+
addedNodes.push(blockIconNode);
|
|
2063
|
+
addedNodes.push(inlineBlocksNode);
|
|
2064
|
+
const portJSONList = json.blocks || [];
|
|
2065
|
+
portJSONList.forEach((_portJSON) => {
|
|
2066
|
+
const port = document.addNode({
|
|
2067
|
+
type: SlotNodeType.SlotBlock,
|
|
2068
|
+
..._portJSON,
|
|
2069
|
+
originParent: node,
|
|
2070
|
+
parent: inlineBlocksNode
|
|
2071
|
+
});
|
|
2072
|
+
addedNodes.push(port);
|
|
2073
|
+
(_portJSON.blocks || []).forEach((_portChild) => {
|
|
2074
|
+
document.addNode(
|
|
2075
|
+
{
|
|
2076
|
+
type: SlotNodeType.Slot,
|
|
2077
|
+
..._portChild,
|
|
2078
|
+
parent: port
|
|
2079
|
+
},
|
|
2080
|
+
addedNodes
|
|
2081
|
+
);
|
|
2082
|
+
});
|
|
2083
|
+
});
|
|
2084
|
+
return addedNodes;
|
|
2085
|
+
};
|
|
2086
|
+
|
|
2087
|
+
// src/activities/slot/extends/slot-icon.ts
|
|
2088
|
+
import { FlowNodeBaseType as FlowNodeBaseType25 } from "@flowgram.ai/document";
|
|
2089
|
+
var SlotIconRegistry = {
|
|
2090
|
+
type: FlowNodeBaseType25.BLOCK_ICON,
|
|
2091
|
+
meta: {
|
|
2092
|
+
defaultExpanded: false,
|
|
2093
|
+
spacing: 0
|
|
2094
|
+
},
|
|
2095
|
+
getLines: (transition) => [
|
|
2096
|
+
...canSlotDrilldown(transition.entity.parent) ? drawCollapseLine(transition) : []
|
|
2097
|
+
],
|
|
2098
|
+
getLabels: (transition) => [
|
|
2099
|
+
...canSlotDrilldown(transition.entity.parent) ? drawCollapseLabel(transition) : []
|
|
2100
|
+
],
|
|
2101
|
+
getDelta: (transform) => {
|
|
2102
|
+
if (insideSlot(transform.entity.parent)) {
|
|
2103
|
+
return transform.entity.isVertical ? { x: -transform.originDeltaX, y: 0 } : { x: 0, y: -transform.originDeltaY };
|
|
2104
|
+
}
|
|
2105
|
+
return { x: 0, y: 0 };
|
|
2106
|
+
}
|
|
2107
|
+
};
|
|
2108
|
+
|
|
2109
|
+
// src/activities/slot/extends/slot-inline-blocks.ts
|
|
2110
|
+
import { FlowNodeBaseType as FlowNodeBaseType26, getDefaultSpacing as getDefaultSpacing11 } from "@flowgram.ai/document";
|
|
2111
|
+
import { FlowNodeTransformData as FlowNodeTransformData3 } from "@flowgram.ai/document";
|
|
2112
|
+
var SlotInlineBlocksRegistry = {
|
|
2113
|
+
type: "slotInlineBlocks" /* SlotInlineBlocks */,
|
|
2114
|
+
extend: FlowNodeBaseType26.BLOCK,
|
|
2115
|
+
meta: {
|
|
2116
|
+
spacing: 0,
|
|
2117
|
+
inlineSpacingPre: 0,
|
|
2118
|
+
inlineSpacingAfter: 0,
|
|
2119
|
+
isInlineBlocks: (node) => !node.isVertical
|
|
2120
|
+
},
|
|
2121
|
+
getLines() {
|
|
2122
|
+
return [];
|
|
2123
|
+
},
|
|
2124
|
+
getLabels() {
|
|
2125
|
+
return [];
|
|
2126
|
+
},
|
|
2127
|
+
getChildDelta(child, layout) {
|
|
2128
|
+
if (child.entity.isVertical) {
|
|
2129
|
+
return { x: 0, y: 0 };
|
|
2130
|
+
}
|
|
2131
|
+
const preTransform = child.entity.pre?.getData(FlowNodeTransformData3);
|
|
2132
|
+
if (preTransform) {
|
|
2133
|
+
const { localBounds: preBounds } = preTransform;
|
|
2134
|
+
return {
|
|
2135
|
+
x: 0,
|
|
2136
|
+
y: preBounds.bottom + 30
|
|
2137
|
+
};
|
|
2138
|
+
}
|
|
2139
|
+
return { x: 0, y: 0 };
|
|
2140
|
+
},
|
|
2141
|
+
/**
|
|
2142
|
+
* 控制条件分支居右布局
|
|
2143
|
+
*/
|
|
2144
|
+
getDelta(transform) {
|
|
2145
|
+
if (!transform.children.length) {
|
|
2146
|
+
return { x: 0, y: 0 };
|
|
2147
|
+
}
|
|
2148
|
+
const icon = transform.pre;
|
|
2149
|
+
if (!icon) {
|
|
2150
|
+
return { x: 0, y: 0 };
|
|
2151
|
+
}
|
|
2152
|
+
const startDistance = getDefaultSpacing11(
|
|
2153
|
+
transform.entity,
|
|
2154
|
+
SlotSpacingKey.SLOT_START_DISTANCE,
|
|
2155
|
+
SLOT_START_DISTANCE
|
|
2156
|
+
);
|
|
2157
|
+
const portDistance = getDefaultSpacing11(
|
|
2158
|
+
transform.entity,
|
|
2159
|
+
SlotSpacingKey.SLOT_PORT_DISTANCE,
|
|
2160
|
+
SLOT_PORT_DISTANCE
|
|
2161
|
+
);
|
|
2162
|
+
const portBlockDistance = getDefaultSpacing11(
|
|
2163
|
+
transform.entity,
|
|
2164
|
+
SlotSpacingKey.SLOT_BLOCK_PORT_DISTANCE,
|
|
2165
|
+
SLOT_BLOCK_PORT_DISTANCE
|
|
2166
|
+
);
|
|
2167
|
+
if (!transform.entity.isVertical) {
|
|
2168
|
+
const noChildren = transform?.children?.every?.((_port) => !_port.children.length);
|
|
2169
|
+
if (noChildren) {
|
|
2170
|
+
return {
|
|
2171
|
+
x: portDistance - icon.localBounds.width / 2,
|
|
2172
|
+
y: icon.localBounds.bottom + startDistance
|
|
2173
|
+
};
|
|
2174
|
+
}
|
|
2175
|
+
return {
|
|
2176
|
+
x: portDistance + portBlockDistance - icon.localBounds.width / 2,
|
|
2177
|
+
y: icon.localBounds.bottom + startDistance
|
|
2178
|
+
};
|
|
2179
|
+
}
|
|
2180
|
+
const slotInlineBlockDelta = startDistance + portDistance + portBlockDistance;
|
|
2181
|
+
return {
|
|
2182
|
+
x: icon.localBounds.right + slotInlineBlockDelta,
|
|
2183
|
+
y: -icon.localBounds.height
|
|
2184
|
+
};
|
|
2185
|
+
}
|
|
2186
|
+
};
|
|
2187
|
+
|
|
2188
|
+
// src/activities/slot/extends/slot-block.ts
|
|
2189
|
+
import { mean as mean2 } from "lodash-es";
|
|
2190
|
+
import {
|
|
2191
|
+
FlowNodeBaseType as FlowNodeBaseType27,
|
|
2192
|
+
FlowTransitionLabelEnum as FlowTransitionLabelEnum16,
|
|
2193
|
+
FlowTransitionLineEnum as FlowTransitionLineEnum8,
|
|
2194
|
+
getDefaultSpacing as getDefaultSpacing12
|
|
2195
|
+
} from "@flowgram.ai/document";
|
|
2196
|
+
import { FlowNodeTransformData as FlowNodeTransformData4 } from "@flowgram.ai/document";
|
|
2197
|
+
var SlotBlockRegistry = {
|
|
2198
|
+
type: SlotNodeType.SlotBlock,
|
|
2199
|
+
extend: FlowNodeBaseType27.BLOCK,
|
|
2200
|
+
meta: {
|
|
2201
|
+
inlineSpacingAfter: 0,
|
|
2202
|
+
inlineSpacingPre: 0,
|
|
2203
|
+
spacing: (transform) => {
|
|
2204
|
+
if (!transform.entity.isVertical && transform.size.width === 0) {
|
|
2205
|
+
return 90;
|
|
1444
2206
|
}
|
|
2207
|
+
return getDefaultSpacing12(
|
|
2208
|
+
transform.entity,
|
|
2209
|
+
SlotSpacingKey.SLOT_BLOCK_VERTICAL_SPACING,
|
|
2210
|
+
SLOT_BLOCK_VERTICAL_SPACING
|
|
2211
|
+
);
|
|
2212
|
+
},
|
|
2213
|
+
isInlineBlocks: (node) => !node.isVertical
|
|
2214
|
+
},
|
|
2215
|
+
getLines(transition) {
|
|
2216
|
+
const icon = transition.transform.parent?.pre;
|
|
2217
|
+
const start = getSlotChildLineStartPoint(icon);
|
|
2218
|
+
const portPoint = transition.transform.inputPoint;
|
|
2219
|
+
const radius = getDefaultSpacing12(
|
|
2220
|
+
transition.transform.entity,
|
|
2221
|
+
SlotSpacingKey.SLOT_RADIUS,
|
|
2222
|
+
SLOT_RADIUS
|
|
2223
|
+
);
|
|
2224
|
+
let startPortVertices = [{ x: start.x, y: portPoint.y }];
|
|
2225
|
+
if (transition.entity.isVertical) {
|
|
2226
|
+
const deltaY = Math.abs(portPoint.y - start.y);
|
|
2227
|
+
let deltaX = radius;
|
|
2228
|
+
let isTruncated = false;
|
|
2229
|
+
if (deltaY < radius * 2) {
|
|
2230
|
+
isTruncated = true;
|
|
2231
|
+
if (deltaY < radius) {
|
|
2232
|
+
deltaX = Math.sqrt(radius ** 2 - (radius - deltaY) ** 2);
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
startPortVertices = [
|
|
2236
|
+
{
|
|
2237
|
+
x: start.x + deltaX,
|
|
2238
|
+
y: start.y,
|
|
2239
|
+
radiusX: radius,
|
|
2240
|
+
radiusY: radius,
|
|
2241
|
+
radiusOverflow: "truncate"
|
|
2242
|
+
},
|
|
2243
|
+
{
|
|
2244
|
+
x: start.x + deltaX,
|
|
2245
|
+
y: portPoint.y,
|
|
2246
|
+
...isTruncated ? { radiusX: 0, radiusY: 0 } : {}
|
|
2247
|
+
}
|
|
2248
|
+
];
|
|
2249
|
+
}
|
|
2250
|
+
if (transition.transform.children.length === 1) {
|
|
2251
|
+
return [
|
|
2252
|
+
{
|
|
2253
|
+
type: FlowTransitionLineEnum8.ROUNDED_LINE,
|
|
2254
|
+
from: start,
|
|
2255
|
+
to: getPortChildInput(transition.transform.children[0]),
|
|
2256
|
+
vertices: startPortVertices,
|
|
2257
|
+
style: {
|
|
2258
|
+
strokeDasharray: "5 5"
|
|
2259
|
+
},
|
|
2260
|
+
radius
|
|
2261
|
+
}
|
|
2262
|
+
];
|
|
2263
|
+
}
|
|
2264
|
+
return [
|
|
2265
|
+
{
|
|
2266
|
+
type: FlowTransitionLineEnum8.ROUNDED_LINE,
|
|
2267
|
+
from: start,
|
|
2268
|
+
to: portPoint,
|
|
2269
|
+
vertices: startPortVertices,
|
|
2270
|
+
style: {
|
|
2271
|
+
strokeDasharray: "5 5"
|
|
2272
|
+
},
|
|
2273
|
+
radius
|
|
2274
|
+
},
|
|
2275
|
+
...transition.transform.children.map((_child) => {
|
|
2276
|
+
const childInput = getPortChildInput(_child);
|
|
2277
|
+
return {
|
|
2278
|
+
type: FlowTransitionLineEnum8.ROUNDED_LINE,
|
|
2279
|
+
radius,
|
|
2280
|
+
from: portPoint,
|
|
2281
|
+
to: childInput,
|
|
2282
|
+
vertices: [{ x: portPoint.x, y: childInput.y }],
|
|
2283
|
+
style: {
|
|
2284
|
+
strokeDasharray: "5 5"
|
|
2285
|
+
}
|
|
2286
|
+
};
|
|
2287
|
+
})
|
|
1445
2288
|
];
|
|
2289
|
+
},
|
|
2290
|
+
getLabels(transition) {
|
|
2291
|
+
const icon = transition.transform.parent?.pre;
|
|
2292
|
+
const start = getSlotChildLineStartPoint(icon);
|
|
2293
|
+
const portPoint = transition.transform.inputPoint;
|
|
2294
|
+
return [
|
|
2295
|
+
{
|
|
2296
|
+
type: FlowTransitionLabelEnum16.CUSTOM_LABEL,
|
|
2297
|
+
renderKey: RENDER_SLOT_ADDER_KEY,
|
|
2298
|
+
props: {
|
|
2299
|
+
node: transition.entity
|
|
2300
|
+
},
|
|
2301
|
+
offset: portPoint
|
|
2302
|
+
},
|
|
2303
|
+
{
|
|
2304
|
+
type: FlowTransitionLabelEnum16.CUSTOM_LABEL,
|
|
2305
|
+
renderKey: RENDER_SLOT_LABEL_KEY,
|
|
2306
|
+
props: {
|
|
2307
|
+
node: transition.entity
|
|
2308
|
+
},
|
|
2309
|
+
offset: {
|
|
2310
|
+
x: start.x + getDefaultSpacing12(
|
|
2311
|
+
transition.entity,
|
|
2312
|
+
SlotSpacingKey.SLOT_LABEL_DISTANCE,
|
|
2313
|
+
SLOT_LABEL_DISTANCE
|
|
2314
|
+
),
|
|
2315
|
+
y: portPoint.y
|
|
2316
|
+
},
|
|
2317
|
+
origin: [0, 0.5]
|
|
2318
|
+
}
|
|
2319
|
+
];
|
|
2320
|
+
},
|
|
2321
|
+
getInputPoint(transform) {
|
|
2322
|
+
const icon = transform.parent?.pre;
|
|
2323
|
+
const start = getSlotChildLineStartPoint(icon);
|
|
2324
|
+
let inputY = transform.bounds.center.y;
|
|
2325
|
+
if (transform.children.length) {
|
|
2326
|
+
inputY = mean2([
|
|
2327
|
+
getPortChildInput(transform.firstChild).y,
|
|
2328
|
+
getPortChildInput(transform.lastChild).y
|
|
2329
|
+
]);
|
|
2330
|
+
}
|
|
2331
|
+
return {
|
|
2332
|
+
x: start.x + getDefaultSpacing12(transform.entity, SlotSpacingKey.SLOT_PORT_DISTANCE, SLOT_PORT_DISTANCE),
|
|
2333
|
+
y: inputY
|
|
2334
|
+
};
|
|
2335
|
+
},
|
|
2336
|
+
getChildDelta(child, layout) {
|
|
2337
|
+
const hasChild = !!child.firstChild;
|
|
2338
|
+
if (child.entity.isVertical) {
|
|
2339
|
+
let deltaX = hasChild ? 0 : -child.originDeltaX;
|
|
2340
|
+
return { x: deltaX, y: 0 };
|
|
2341
|
+
}
|
|
2342
|
+
let deltaY = hasChild ? 0 : -child.originDeltaY;
|
|
2343
|
+
const preTransform = child.entity.pre?.getData(FlowNodeTransformData4);
|
|
2344
|
+
if (preTransform) {
|
|
2345
|
+
const { localBounds: preBounds } = preTransform;
|
|
2346
|
+
return {
|
|
2347
|
+
x: 0,
|
|
2348
|
+
y: preBounds.bottom + 30 + deltaY
|
|
2349
|
+
};
|
|
2350
|
+
}
|
|
2351
|
+
return { x: 0, y: deltaY };
|
|
2352
|
+
},
|
|
2353
|
+
getChildLabels() {
|
|
2354
|
+
return [];
|
|
2355
|
+
},
|
|
2356
|
+
getChildLines() {
|
|
2357
|
+
return [];
|
|
2358
|
+
},
|
|
2359
|
+
getDelta(transform) {
|
|
2360
|
+
return {
|
|
2361
|
+
x: 0,
|
|
2362
|
+
y: 0
|
|
2363
|
+
};
|
|
1446
2364
|
}
|
|
1447
2365
|
};
|
|
1448
2366
|
|
|
2367
|
+
// src/activities/slot/slot.ts
|
|
2368
|
+
var SlotRegistry = {
|
|
2369
|
+
type: FlowNodeBaseType28.SLOT,
|
|
2370
|
+
extend: "block",
|
|
2371
|
+
meta: {
|
|
2372
|
+
// Slot 节点内部暂时不允许拖拽
|
|
2373
|
+
draggable: (node) => !insideSlot(node),
|
|
2374
|
+
hidden: true,
|
|
2375
|
+
spacing: (node) => getDefaultSpacing13(node.entity, SlotSpacingKey.SLOT_SPACING, SLOT_SPACING),
|
|
2376
|
+
padding: (node) => ({
|
|
2377
|
+
left: 0,
|
|
2378
|
+
right: node.collapsed ? getDefaultSpacing13(node.entity, SlotSpacingKey.SLOT_START_DISTANCE, SLOT_START_DISTANCE) : 0,
|
|
2379
|
+
bottom: !insideSlot(node.entity) && node.isLast ? SLOT_NODE_LAST_SPACING : 0,
|
|
2380
|
+
top: 0
|
|
2381
|
+
}),
|
|
2382
|
+
copyDisable: false,
|
|
2383
|
+
defaultExpanded: false
|
|
2384
|
+
},
|
|
2385
|
+
/**
|
|
2386
|
+
* 业务通常需要重载方法
|
|
2387
|
+
*/
|
|
2388
|
+
onCreate: createSlotFromJSON,
|
|
2389
|
+
getLines: (transition) => [
|
|
2390
|
+
...!insideSlot(transition.entity) ? drawStraightLine(transition) : []
|
|
2391
|
+
],
|
|
2392
|
+
getLabels: (transition) => [
|
|
2393
|
+
...!insideSlot(transition.entity) ? drawStraightAdder(transition) : []
|
|
2394
|
+
],
|
|
2395
|
+
getInputPoint,
|
|
2396
|
+
getOutputPoint,
|
|
2397
|
+
onAfterUpdateLocalTransform(transform) {
|
|
2398
|
+
const { isVertical } = transform.entity;
|
|
2399
|
+
if (!isVertical) {
|
|
2400
|
+
return;
|
|
2401
|
+
}
|
|
2402
|
+
const icon = transform.firstChild;
|
|
2403
|
+
const inlineBlocks = transform.lastChild;
|
|
2404
|
+
if (!icon || !inlineBlocks) {
|
|
2405
|
+
return;
|
|
2406
|
+
}
|
|
2407
|
+
const iconSize = icon.localBounds.height;
|
|
2408
|
+
const inlineBlocksSize = inlineBlocks.localBounds.height;
|
|
2409
|
+
if (transform.collapsed || !inlineBlocks) {
|
|
2410
|
+
return;
|
|
2411
|
+
}
|
|
2412
|
+
const portsMiddle = getAllPortsMiddle(inlineBlocks);
|
|
2413
|
+
icon.entity.clearMemoLocal();
|
|
2414
|
+
inlineBlocks.entity.clearMemoLocal();
|
|
2415
|
+
if (iconSize / 2 + portsMiddle > inlineBlocksSize || !inlineBlocks.children.length) {
|
|
2416
|
+
icon.transform.update({
|
|
2417
|
+
position: { x: icon.transform.position.x, y: 0 }
|
|
2418
|
+
});
|
|
2419
|
+
inlineBlocks.transform.update({
|
|
2420
|
+
position: {
|
|
2421
|
+
x: inlineBlocks.transform.position.x,
|
|
2422
|
+
y: Math.max(iconSize / 2 - inlineBlocksSize / 2, 0)
|
|
2423
|
+
}
|
|
2424
|
+
});
|
|
2425
|
+
return;
|
|
2426
|
+
}
|
|
2427
|
+
inlineBlocks.transform.update({
|
|
2428
|
+
position: { x: inlineBlocks.transform.position.x, y: 0 }
|
|
2429
|
+
});
|
|
2430
|
+
icon?.transform.update({
|
|
2431
|
+
position: {
|
|
2432
|
+
x: icon.transform.position.x,
|
|
2433
|
+
y: Math.max(portsMiddle - iconSize / 2, 0)
|
|
2434
|
+
// 所有 port 的中间点
|
|
2435
|
+
}
|
|
2436
|
+
});
|
|
2437
|
+
},
|
|
2438
|
+
extendChildRegistries: [SlotIconRegistry, SlotInlineBlocksRegistry]
|
|
2439
|
+
};
|
|
2440
|
+
|
|
1449
2441
|
// src/flow-registers.ts
|
|
1450
2442
|
var FlowRegisters = class {
|
|
1451
2443
|
/**
|
|
@@ -1462,6 +2454,8 @@ var FlowRegisters = class {
|
|
|
1462
2454
|
// 动态分支(并行、排他)
|
|
1463
2455
|
StaticSplitRegistry,
|
|
1464
2456
|
// 静态分支(审批)
|
|
2457
|
+
SimpleSplitRegistry,
|
|
2458
|
+
// 简单分支 (不带 orderIcon 节点)
|
|
1465
2459
|
BlockRegistry,
|
|
1466
2460
|
// 单条 block 注册
|
|
1467
2461
|
InlineBlocksRegistry,
|
|
@@ -1476,15 +2470,23 @@ var FlowRegisters = class {
|
|
|
1476
2470
|
// 结束节点
|
|
1477
2471
|
LoopRegistry,
|
|
1478
2472
|
// 循环节点
|
|
1479
|
-
EmptyRegistry
|
|
2473
|
+
EmptyRegistry,
|
|
1480
2474
|
// 占位节点
|
|
2475
|
+
BreakRegistry,
|
|
2476
|
+
// 分支断开
|
|
2477
|
+
MultiOuputsRegistry,
|
|
2478
|
+
MultiInputsRegistry,
|
|
2479
|
+
InputRegistry,
|
|
2480
|
+
OuputRegistry,
|
|
2481
|
+
SlotRegistry,
|
|
2482
|
+
SlotBlockRegistry
|
|
1481
2483
|
);
|
|
1482
2484
|
document.registerNodeDatas(
|
|
1483
|
-
|
|
2485
|
+
FlowNodeRenderData4,
|
|
1484
2486
|
// 渲染节点相关数据
|
|
1485
2487
|
FlowNodeTransitionData,
|
|
1486
2488
|
// 线条绘制数据
|
|
1487
|
-
|
|
2489
|
+
FlowNodeTransformData5
|
|
1488
2490
|
// 坐标计算数据
|
|
1489
2491
|
);
|
|
1490
2492
|
}
|
|
@@ -1502,12 +2504,8 @@ var FlowRegisters = class {
|
|
|
1502
2504
|
// 线条渲染
|
|
1503
2505
|
FlowLabelsLayer,
|
|
1504
2506
|
// Label 渲染
|
|
1505
|
-
PlaygroundLayer
|
|
2507
|
+
PlaygroundLayer
|
|
1506
2508
|
// 画布基础层,提供缩放、手势等能力
|
|
1507
|
-
FlowScrollLimitLayer,
|
|
1508
|
-
// 控制滚动范围
|
|
1509
|
-
FlowScrollBarLayer
|
|
1510
|
-
// 滚动条
|
|
1511
2509
|
);
|
|
1512
2510
|
}
|
|
1513
2511
|
/**
|
|
@@ -1545,10 +2543,17 @@ var FixedLayoutRegistries = {
|
|
|
1545
2543
|
StaticSplitRegistry,
|
|
1546
2544
|
TryCatchRegistry,
|
|
1547
2545
|
StartRegistry,
|
|
1548
|
-
RootRegistry
|
|
2546
|
+
RootRegistry,
|
|
2547
|
+
InlineBlocksRegistry,
|
|
2548
|
+
EndRegistry,
|
|
2549
|
+
SlotRegistry,
|
|
2550
|
+
SlotBlockRegistry,
|
|
2551
|
+
SlotIconRegistry,
|
|
2552
|
+
SlotInlineBlocksRegistry
|
|
1549
2553
|
};
|
|
1550
2554
|
export {
|
|
1551
2555
|
FixedLayoutContainerModule,
|
|
1552
|
-
FixedLayoutRegistries
|
|
2556
|
+
FixedLayoutRegistries,
|
|
2557
|
+
SlotSpacingKey
|
|
1553
2558
|
};
|
|
1554
2559
|
//# sourceMappingURL=index.js.map
|