@flowgram.ai/fixed-layout-core 0.1.0-alpha.5 → 0.1.0-alpha.7

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 CHANGED
@@ -300,7 +300,7 @@ var InlineBlocksRegistry = {
300
300
  hidden: true,
301
301
  spacing: (node) => getDefaultSpacing2(node.entity, ConstantKeys2.NODE_SPACING),
302
302
  isInlineBlocks: true,
303
- inlineSpacingPre: DEFAULT_SPACING2.INLINE_BLOCKS_PADDING_TOP,
303
+ inlineSpacingPre: (node) => getDefaultSpacing2(node.entity, ConstantKeys2.INLINE_BLOCKS_PADDING_TOP) || DEFAULT_SPACING2.INLINE_BLOCKS_PADDING_TOP,
304
304
  inlineSpacingAfter: (node) => getDefaultSpacing2(node.entity, ConstantKeys2.INLINE_BLOCKS_PADDING_BOTTOM)
305
305
  },
306
306
  /**
@@ -550,7 +550,7 @@ var StartRegistry = {
550
550
  // src/activities/try-catch.ts
551
551
  import {
552
552
  FlowLayoutDefault as FlowLayoutDefault6,
553
- FlowNodeBaseType as FlowNodeBaseType13
553
+ FlowNodeBaseType as FlowNodeBaseType12
554
554
  } from "@flowgram.ai/document";
555
555
 
556
556
  // src/activities/try-catch-extends/catch-block.ts
@@ -851,13 +851,41 @@ var TryBlockRegistry = {
851
851
  };
852
852
 
853
853
  // src/activities/try-catch-extends/try-slot.ts
854
- import { FlowNodeBaseType as FlowNodeBaseType12 } from "@flowgram.ai/document";
854
+ import { FlowTransitionLabelEnum as FlowTransitionLabelEnum8 } from "@flowgram.ai/document";
855
855
  var TrySlotRegistry = {
856
- extend: FlowNodeBaseType12.EMPTY,
857
- type: "trySlot" /* TRY_SLOT */
858
- // getLabels() {
859
- // return []
860
- // },
856
+ type: "trySlot" /* TRY_SLOT */,
857
+ meta: {
858
+ inlineSpacingAfter: 16,
859
+ spacing: 0,
860
+ size: {
861
+ width: 16,
862
+ height: 0
863
+ }
864
+ },
865
+ onAfterUpdateLocalTransform(transform) {
866
+ if (transform.entity.isVertical) {
867
+ transform.data.size = {
868
+ width: 16,
869
+ height: 0
870
+ };
871
+ } else {
872
+ transform.data.size = {
873
+ width: 0,
874
+ height: 16
875
+ };
876
+ }
877
+ transform.transform.update({
878
+ size: transform.data.size
879
+ });
880
+ },
881
+ getLabels(transition) {
882
+ return [
883
+ {
884
+ offset: transition.transform.bounds.center,
885
+ type: FlowTransitionLabelEnum8.ADDER_LABEL
886
+ }
887
+ ];
888
+ }
861
889
  };
862
890
 
863
891
  // src/activities/try-catch.ts
@@ -890,7 +918,7 @@ var TryCatchRegistry = {
890
918
  const addedNodes = [];
891
919
  const tryCatchIconNode = document.addNode({
892
920
  id: `$tryCatchIcon$${node.id}`,
893
- type: FlowNodeBaseType13.BLOCK_ICON,
921
+ type: FlowNodeBaseType12.BLOCK_ICON,
894
922
  originParent: node,
895
923
  parent: node
896
924
  });
@@ -901,13 +929,15 @@ var TryCatchRegistry = {
901
929
  parent: node
902
930
  });
903
931
  const tryBlockNode = document.addNode({
904
- id: `$tryBlock$${tryBlock.id}`,
932
+ id: tryBlock.id,
905
933
  type: "tryBlock" /* TRY_BLOCK */,
906
934
  originParent: node,
907
- parent: mainBlockNode
935
+ parent: mainBlockNode,
936
+ data: tryBlock.data
908
937
  });
909
938
  const trySlotNode = document.addNode({
910
- id: tryBlock.id,
939
+ id: `$trySlot$${tryBlock.id}`,
940
+ hidden: true,
911
941
  type: "trySlot" /* TRY_SLOT */,
912
942
  // 占位节点
913
943
  originParent: node,
@@ -926,8 +956,17 @@ var TryCatchRegistry = {
926
956
  trySlotNode,
927
957
  catchInlineBlocksNode
928
958
  );
959
+ (tryBlock.blocks || []).forEach((blockData) => {
960
+ document.addNode(
961
+ {
962
+ ...blockData,
963
+ parent: tryBlockNode
964
+ },
965
+ addedNodes
966
+ );
967
+ });
929
968
  catchBlocks.forEach((blockData) => {
930
- node.document.addBlock(node, blockData, addedNodes);
969
+ document.addBlock(node, blockData, addedNodes);
931
970
  });
932
971
  return addedNodes;
933
972
  },
@@ -943,11 +982,12 @@ var TryCatchRegistry = {
943
982
  id: blockData.id,
944
983
  type: "catchBlock" /* CATCH_BLOCK */,
945
984
  originParent: node,
946
- parent
985
+ parent,
986
+ data: blockData.data
947
987
  });
948
988
  const blockOrderIcon = node.document.addNode({
949
989
  id: `$blockOrderIcon$${blockData.id}`,
950
- type: FlowNodeBaseType13.BLOCK_ORDER_ICON,
990
+ type: FlowNodeBaseType12.BLOCK_ORDER_ICON,
951
991
  originParent: node,
952
992
  parent: block
953
993
  });
@@ -983,7 +1023,7 @@ var TryCatchRegistry = {
983
1023
  * icon 节点
984
1024
  */
985
1025
  {
986
- type: FlowNodeBaseType13.BLOCK_ICON,
1026
+ type: FlowNodeBaseType12.BLOCK_ICON,
987
1027
  meta: {
988
1028
  spacing: 54 /* INLINE_SPACING_TOP */
989
1029
  },
@@ -1003,8 +1043,8 @@ var TryCatchRegistry = {
1003
1043
  import { Point as Point5 } from "@flowgram.ai/utils";
1004
1044
  import { FlowTextKey as FlowTextKey3 } from "@flowgram.ai/renderer";
1005
1045
  import {
1006
- FlowNodeBaseType as FlowNodeBaseType15,
1007
- FlowTransitionLabelEnum as FlowTransitionLabelEnum10,
1046
+ FlowNodeBaseType as FlowNodeBaseType14,
1047
+ FlowTransitionLabelEnum as FlowTransitionLabelEnum11,
1008
1048
  getDefaultSpacing as getDefaultSpacing6,
1009
1049
  ConstantKeys as ConstantKeys5
1010
1050
  } from "@flowgram.ai/document";
@@ -1080,7 +1120,7 @@ var LoopRightEmptyBlockRegistry = {
1080
1120
  };
1081
1121
 
1082
1122
  // src/activities/loop-extends/loop-empty-branch.ts
1083
- import { FlowTransitionLabelEnum as FlowTransitionLabelEnum8 } from "@flowgram.ai/document";
1123
+ import { FlowTransitionLabelEnum as FlowTransitionLabelEnum9 } from "@flowgram.ai/document";
1084
1124
  var LoopEmptyBranchRegistry = {
1085
1125
  type: "loopEmptyBranch" /* LOOP_EMPTY_BRANCH */,
1086
1126
  meta: {
@@ -1097,7 +1137,7 @@ var LoopEmptyBranchRegistry = {
1097
1137
  if (isVertical) {
1098
1138
  return [
1099
1139
  {
1100
- type: FlowTransitionLabelEnum8.ADDER_LABEL,
1140
+ type: FlowTransitionLabelEnum9.ADDER_LABEL,
1101
1141
  offset: {
1102
1142
  x: currentTransform.inputPoint.x,
1103
1143
  y: currentTransform.bounds.center.y + 8
@@ -1108,7 +1148,7 @@ var LoopEmptyBranchRegistry = {
1108
1148
  }
1109
1149
  return [
1110
1150
  {
1111
- type: FlowTransitionLabelEnum8.ADDER_LABEL,
1151
+ type: FlowTransitionLabelEnum9.ADDER_LABEL,
1112
1152
  offset: {
1113
1153
  x: currentTransform.bounds.center.x + 8,
1114
1154
  y: currentTransform.inputPoint.y
@@ -1138,14 +1178,14 @@ var LoopEmptyBranchRegistry = {
1138
1178
  import { Point as Point4 } from "@flowgram.ai/utils";
1139
1179
  import { FlowTextKey as FlowTextKey2 } from "@flowgram.ai/renderer";
1140
1180
  import {
1141
- FlowNodeBaseType as FlowNodeBaseType14,
1142
- FlowTransitionLabelEnum as FlowTransitionLabelEnum9,
1181
+ FlowNodeBaseType as FlowNodeBaseType13,
1182
+ FlowTransitionLabelEnum as FlowTransitionLabelEnum10,
1143
1183
  FlowTransitionLineEnum as FlowTransitionLineEnum5,
1144
1184
  getDefaultSpacing as getDefaultSpacing5,
1145
1185
  ConstantKeys as ConstantKeys4
1146
1186
  } from "@flowgram.ai/document";
1147
1187
  var LoopInlineBlocksNodeRegistry = {
1148
- type: FlowNodeBaseType14.INLINE_BLOCKS,
1188
+ type: FlowNodeBaseType13.INLINE_BLOCKS,
1149
1189
  meta: {
1150
1190
  inlineSpacingPre: (node) => {
1151
1191
  const inlineBlocksInlineSpacingTop = getDefaultSpacing5(
@@ -1218,7 +1258,7 @@ var LoopInlineBlocksNodeRegistry = {
1218
1258
  const rightBlockTransform = currentTransform.children[1];
1219
1259
  if (transition.entity.originParent?.id.startsWith("while_")) {
1220
1260
  labels.push({
1221
- type: FlowTransitionLabelEnum9.TEXT_LABEL,
1261
+ type: FlowTransitionLabelEnum10.TEXT_LABEL,
1222
1262
  renderKey: FlowTextKey2.LOOP_WHILE_TEXT,
1223
1263
  rotate: isVertical ? "" : "-90deg",
1224
1264
  offset: isVertical ? {
@@ -1231,7 +1271,7 @@ var LoopInlineBlocksNodeRegistry = {
1231
1271
  });
1232
1272
  } else {
1233
1273
  labels.push({
1234
- type: FlowTransitionLabelEnum9.TEXT_LABEL,
1274
+ type: FlowTransitionLabelEnum10.TEXT_LABEL,
1235
1275
  renderKey: FlowTextKey2.LOOP_TRAVERSE_TEXT,
1236
1276
  // rotate: isVertical ? '' : '-90deg',
1237
1277
  offset: isVertical ? { x: leftBlockTransform.inputPoint.x, y: currentTransform.bounds.center.y + 5 } : { x: currentTransform.bounds.center.x + 5, y: leftBlockTransform.inputPoint.y }
@@ -1275,14 +1315,14 @@ var LoopRegistry = {
1275
1315
  const loopBlocks = json.blocks || [];
1276
1316
  const loopIconNode = document.addNode({
1277
1317
  id: `$blockIcon$${node.id}`,
1278
- type: FlowNodeBaseType15.BLOCK_ICON,
1318
+ type: FlowNodeBaseType14.BLOCK_ICON,
1279
1319
  originParent: node,
1280
1320
  parent: node
1281
1321
  });
1282
1322
  const loopInlineBlocks = document.addNode({
1283
1323
  id: `$inlineBlocks$${node.id}`,
1284
1324
  hidden: true,
1285
- type: FlowNodeBaseType15.INLINE_BLOCKS,
1325
+ type: FlowNodeBaseType14.INLINE_BLOCKS,
1286
1326
  originParent: node,
1287
1327
  parent: node
1288
1328
  });
@@ -1296,7 +1336,7 @@ var LoopRegistry = {
1296
1336
  const loopBlockNode = document.addNode({
1297
1337
  id: `$block$${node.id}`,
1298
1338
  hidden: true,
1299
- type: FlowNodeBaseType15.BLOCK,
1339
+ type: FlowNodeBaseType14.BLOCK,
1300
1340
  // : LoopTypeEnum.LOOP_RIGHT_EMPTY_BLOCK,
1301
1341
  originParent: node,
1302
1342
  parent: loopInlineBlocks
@@ -1334,7 +1374,7 @@ var LoopRegistry = {
1334
1374
  return [
1335
1375
  // 循环结束
1336
1376
  {
1337
- type: FlowTransitionLabelEnum10.TEXT_LABEL,
1377
+ type: FlowTransitionLabelEnum11.TEXT_LABEL,
1338
1378
  renderKey: FlowTextKey3.LOOP_END_TEXT,
1339
1379
  // 循环 label 垂直样式展示,而非 rotate 旋转文案
1340
1380
  props: isVertical ? void 0 : {
@@ -1347,7 +1387,7 @@ var LoopRegistry = {
1347
1387
  offset: Point5.move(currentTransform.outputPoint, isVertical ? { y: -26 } : { x: -26 })
1348
1388
  },
1349
1389
  {
1350
- type: FlowTransitionLabelEnum10.ADDER_LABEL,
1390
+ type: FlowTransitionLabelEnum11.ADDER_LABEL,
1351
1391
  offset: currentTransform.outputPoint
1352
1392
  }
1353
1393
  ];
@@ -1381,7 +1421,7 @@ var LoopRegistry = {
1381
1421
  },
1382
1422
  extendChildRegistries: [
1383
1423
  {
1384
- type: FlowNodeBaseType15.BLOCK_ICON,
1424
+ type: FlowNodeBaseType14.BLOCK_ICON,
1385
1425
  meta: {
1386
1426
  spacing: LoopSpacings.LOOP_BLOCK_ICON_SPACING
1387
1427
  }
@@ -1404,9 +1444,9 @@ var LoopRegistry = {
1404
1444
  };
1405
1445
 
1406
1446
  // src/activities/root.ts
1407
- import { DEFAULT_SPACING as DEFAULT_SPACING7, FlowNodeBaseType as FlowNodeBaseType16 } from "@flowgram.ai/document";
1447
+ import { DEFAULT_SPACING as DEFAULT_SPACING7, FlowNodeBaseType as FlowNodeBaseType15 } from "@flowgram.ai/document";
1408
1448
  var RootRegistry = {
1409
- type: FlowNodeBaseType16.ROOT,
1449
+ type: FlowNodeBaseType15.ROOT,
1410
1450
  meta: {
1411
1451
  spacing: DEFAULT_SPACING7.NULL,
1412
1452
  hidden: true
@@ -1421,13 +1461,13 @@ var RootRegistry = {
1421
1461
 
1422
1462
  // src/activities/empty.ts
1423
1463
  import {
1424
- FlowNodeBaseType as FlowNodeBaseType17,
1425
- FlowTransitionLabelEnum as FlowTransitionLabelEnum11,
1464
+ FlowNodeBaseType as FlowNodeBaseType16,
1465
+ FlowTransitionLabelEnum as FlowTransitionLabelEnum12,
1426
1466
  ConstantKeys as ConstantKeys6,
1427
1467
  getDefaultSpacing as getDefaultSpacing7
1428
1468
  } from "@flowgram.ai/document";
1429
1469
  var EmptyRegistry = {
1430
- type: FlowNodeBaseType17.EMPTY,
1470
+ type: FlowNodeBaseType16.EMPTY,
1431
1471
  meta: {
1432
1472
  spacing: (node) => {
1433
1473
  const spacing = getDefaultSpacing7(node.entity, ConstantKeys6.NODE_SPACING);
@@ -1440,7 +1480,7 @@ var EmptyRegistry = {
1440
1480
  return [
1441
1481
  {
1442
1482
  offset: transition.transform.bounds,
1443
- type: FlowTransitionLabelEnum11.ADDER_LABEL
1483
+ type: FlowTransitionLabelEnum12.ADDER_LABEL
1444
1484
  }
1445
1485
  ];
1446
1486
  }
@@ -1545,7 +1585,9 @@ var FixedLayoutRegistries = {
1545
1585
  StaticSplitRegistry,
1546
1586
  TryCatchRegistry,
1547
1587
  StartRegistry,
1548
- RootRegistry
1588
+ RootRegistry,
1589
+ InlineBlocksRegistry,
1590
+ EndRegistry
1549
1591
  };
1550
1592
  export {
1551
1593
  FixedLayoutContainerModule,