@flowgram.ai/document 0.2.15 → 0.2.17

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/index.d.mts CHANGED
@@ -57,6 +57,11 @@ declare namespace FlowVirtualTree {
57
57
  }
58
58
  }
59
59
 
60
+ /**
61
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
62
+ * SPDX-License-Identifier: MIT
63
+ */
64
+
60
65
  /**
61
66
  * Render Tree 会只读模式,不具备操作 tree 结构元素
62
67
  */
@@ -106,6 +111,11 @@ declare class FlowRenderTree<T extends FlowNodeEntity> extends FlowVirtualTree<T
106
111
  removeParent(): void;
107
112
  }
108
113
 
114
+ /**
115
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
116
+ * SPDX-License-Identifier: MIT
117
+ */
118
+
109
119
  declare const FlowDocumentOptions: unique symbol;
110
120
  /**
111
121
  * 流程画布配置
@@ -163,6 +173,7 @@ declare const ConstantKeys: {
163
173
  */
164
174
  INLINE_BLOCKS_PADDING_TOP: string;
165
175
  NODE_SPACING: string;
176
+ BRANCH_SPACING: string;
166
177
  ROUNDED_LINE_X_RADIUS: string;
167
178
  ROUNDED_LINE_Y_RADIUS: string;
168
179
  INLINE_BLOCKS_PADDING_BOTTOM: string;
@@ -170,6 +181,11 @@ declare const ConstantKeys: {
170
181
  HOVER_AREA_WIDTH: string;
171
182
  };
172
183
 
184
+ /**
185
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
186
+ * SPDX-License-Identifier: MIT
187
+ */
188
+
173
189
  declare const FlowDocumentContribution: unique symbol;
174
190
  interface FlowDocumentContribution<T extends FlowDocument = FlowDocument> {
175
191
  /**
@@ -184,6 +200,10 @@ interface FlowDocumentContribution<T extends FlowDocument = FlowDocument> {
184
200
  loadDocument?(document: T): Promise<void>;
185
201
  }
186
202
 
203
+ /**
204
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
205
+ * SPDX-License-Identifier: MIT
206
+ */
187
207
  declare const FlowDocumentConfigDefaultData: unique symbol;
188
208
  /**
189
209
  * 用于文档扩展配置
@@ -401,6 +421,7 @@ declare class FlowDocument<T = FlowDocumentJSON> implements Disposable {
401
421
  * 返回需要渲染的数据
402
422
  */
403
423
  getRenderDatas<T extends EntityData>(dataRegistry: EntityDataRegistry<T>, containHiddenNodes?: boolean): T[];
424
+ toNodeJSON(node: FlowNodeEntity): FlowNodeJSON;
404
425
  /**
405
426
  * 移动节点
406
427
  * @param param0
@@ -591,6 +612,11 @@ declare class FlowNodeTransitionData extends EntityData<FlowNodeTransitionSchema
591
612
  get isNodeEnd(): boolean;
592
613
  }
593
614
 
615
+ /**
616
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
617
+ * SPDX-License-Identifier: MIT
618
+ */
619
+
594
620
  interface FlowNodeEntityConfig extends EntityOpts {
595
621
  document: FlowDocument;
596
622
  flowNodeType: FlowNodeType;
@@ -784,6 +810,11 @@ declare class FlowDocumentTransformerEntity extends ConfigEntity<{
784
810
  refresh(): void;
785
811
  }
786
812
 
813
+ /**
814
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
815
+ * SPDX-License-Identifier: MIT
816
+ */
817
+
787
818
  interface FlowRendererStateEntityConfig extends EntityOpts {
788
819
  }
789
820
  interface FlowRendererState {
@@ -814,6 +845,11 @@ declare class FlowRendererStateEntity extends ConfigEntity<FlowRendererState, Fl
814
845
  onNodeHoveredChange(fn: (hoveredNode: FlowNodeEntity | undefined) => void, debounceTime?: number): Disposable;
815
846
  }
816
847
 
848
+ /**
849
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
850
+ * SPDX-License-Identifier: MIT
851
+ */
852
+
817
853
  declare enum FlowTransitionLineEnum {
818
854
  STRAIGHT_LINE = 0,
819
855
  DIVERGE_LINE = 1,
@@ -884,6 +920,11 @@ interface DragNodeProps {
884
920
  node: FlowNodeEntity;
885
921
  }
886
922
 
923
+ /**
924
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
925
+ * SPDX-License-Identifier: MIT
926
+ */
927
+
887
928
  declare enum FlowLayoutDefault {
888
929
  VERTICAL_FIXED_LAYOUT = "vertical-fixed-layout",
889
930
  HORIZONTAL_FIXED_LAYOUT = "horizontal-fixed-layout"
@@ -936,6 +977,11 @@ interface FlowLayout {
936
977
  getDefaultNodeOrigin(): IPoint;
937
978
  }
938
979
 
980
+ /**
981
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
982
+ * SPDX-License-Identifier: MIT
983
+ */
984
+
939
985
  /**
940
986
  * 节点渲染相关配置信息,可扩展
941
987
  */
@@ -975,6 +1021,10 @@ declare const DefaultSpacingKey: {
975
1021
  * 普通节点间距。垂直 / 水平
976
1022
  */
977
1023
  NODE_SPACING: string;
1024
+ /**
1025
+ * 分支节点间距
1026
+ */
1027
+ BRANCH_SPACING: string;
978
1028
  /**
979
1029
  * 圆弧线条 x radius
980
1030
  */
@@ -1003,6 +1053,9 @@ declare const DefaultSpacingKey: {
1003
1053
  declare const DEFAULT_SPACING: {
1004
1054
  [x: string]: number;
1005
1055
  NULL: number;
1056
+ /**
1057
+ * @deprecated use 'BRANCH_SPACING' instead
1058
+ */
1006
1059
  MARGIN_RIGHT: number;
1007
1060
  INLINE_BLOCK_PADDING_BOTTOM: number;
1008
1061
  INLINE_BLOCKS_PADDING_TOP: number;
@@ -1153,6 +1206,11 @@ declare namespace FlowNodeRegistry {
1153
1206
  function extend(registry: FlowNodeRegistry, extendRegistries: FlowNodeRegistry[]): FlowNodeRegistry;
1154
1207
  }
1155
1208
 
1209
+ /**
1210
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1211
+ * SPDX-License-Identifier: MIT
1212
+ */
1213
+
1156
1214
  type FlowNodeType = string | number;
1157
1215
  /**
1158
1216
  * Flow node json data
@@ -1202,6 +1260,11 @@ type AddNodeData = FlowNodeJSON & {
1202
1260
  index?: number;
1203
1261
  };
1204
1262
 
1263
+ /**
1264
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1265
+ * SPDX-License-Identifier: MIT
1266
+ */
1267
+
1205
1268
  declare enum OperationType {
1206
1269
  addFromNode = "addFromNode",
1207
1270
  deleteFromNode = "deleteFromNode",
@@ -1448,10 +1511,19 @@ interface FlowOperationBaseService extends Disposable {
1448
1511
  }
1449
1512
  declare const FlowOperationBaseService: unique symbol;
1450
1513
 
1514
+ /**
1515
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1516
+ * SPDX-License-Identifier: MIT
1517
+ */
1451
1518
  interface FlowGroupJSON {
1452
1519
  nodeIDs: string[];
1453
1520
  }
1454
1521
 
1522
+ /**
1523
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1524
+ * SPDX-License-Identifier: MIT
1525
+ */
1526
+
1455
1527
  declare const FlowDocumentContainerModule: ContainerModule;
1456
1528
 
1457
1529
  /**
@@ -1543,6 +1615,11 @@ declare class FlowOperationBaseServiceImpl implements FlowOperationBaseService {
1543
1615
  protected doMoveNode(node: FlowNodeEntity, newParent: FlowNodeEntity, index: number): void;
1544
1616
  }
1545
1617
 
1618
+ /**
1619
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1620
+ * SPDX-License-Identifier: MIT
1621
+ */
1622
+
1546
1623
  /** 分组控制器 */
1547
1624
  declare class FlowGroupController {
1548
1625
  readonly groupNode: FlowNodeEntity;
@@ -1568,6 +1645,11 @@ declare class FlowGroupController {
1568
1645
  static create(groupNode?: FlowNodeEntity): FlowGroupController | undefined;
1569
1646
  }
1570
1647
 
1648
+ /**
1649
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1650
+ * SPDX-License-Identifier: MIT
1651
+ */
1652
+
1571
1653
  declare class FlowGroupService {
1572
1654
  readonly entityManager: EntityManager;
1573
1655
  readonly operationService: FlowOperationBaseService;
@@ -1584,6 +1666,11 @@ declare class FlowGroupService {
1584
1666
  static validate(nodes: FlowNodeEntity[]): boolean;
1585
1667
  }
1586
1668
 
1669
+ /**
1670
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1671
+ * SPDX-License-Identifier: MIT
1672
+ */
1673
+
1587
1674
  /**
1588
1675
  *
1589
1676
  * @param node 节点 entity
package/dist/index.d.ts CHANGED
@@ -57,6 +57,11 @@ declare namespace FlowVirtualTree {
57
57
  }
58
58
  }
59
59
 
60
+ /**
61
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
62
+ * SPDX-License-Identifier: MIT
63
+ */
64
+
60
65
  /**
61
66
  * Render Tree 会只读模式,不具备操作 tree 结构元素
62
67
  */
@@ -106,6 +111,11 @@ declare class FlowRenderTree<T extends FlowNodeEntity> extends FlowVirtualTree<T
106
111
  removeParent(): void;
107
112
  }
108
113
 
114
+ /**
115
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
116
+ * SPDX-License-Identifier: MIT
117
+ */
118
+
109
119
  declare const FlowDocumentOptions: unique symbol;
110
120
  /**
111
121
  * 流程画布配置
@@ -163,6 +173,7 @@ declare const ConstantKeys: {
163
173
  */
164
174
  INLINE_BLOCKS_PADDING_TOP: string;
165
175
  NODE_SPACING: string;
176
+ BRANCH_SPACING: string;
166
177
  ROUNDED_LINE_X_RADIUS: string;
167
178
  ROUNDED_LINE_Y_RADIUS: string;
168
179
  INLINE_BLOCKS_PADDING_BOTTOM: string;
@@ -170,6 +181,11 @@ declare const ConstantKeys: {
170
181
  HOVER_AREA_WIDTH: string;
171
182
  };
172
183
 
184
+ /**
185
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
186
+ * SPDX-License-Identifier: MIT
187
+ */
188
+
173
189
  declare const FlowDocumentContribution: unique symbol;
174
190
  interface FlowDocumentContribution<T extends FlowDocument = FlowDocument> {
175
191
  /**
@@ -184,6 +200,10 @@ interface FlowDocumentContribution<T extends FlowDocument = FlowDocument> {
184
200
  loadDocument?(document: T): Promise<void>;
185
201
  }
186
202
 
203
+ /**
204
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
205
+ * SPDX-License-Identifier: MIT
206
+ */
187
207
  declare const FlowDocumentConfigDefaultData: unique symbol;
188
208
  /**
189
209
  * 用于文档扩展配置
@@ -401,6 +421,7 @@ declare class FlowDocument<T = FlowDocumentJSON> implements Disposable {
401
421
  * 返回需要渲染的数据
402
422
  */
403
423
  getRenderDatas<T extends EntityData>(dataRegistry: EntityDataRegistry<T>, containHiddenNodes?: boolean): T[];
424
+ toNodeJSON(node: FlowNodeEntity): FlowNodeJSON;
404
425
  /**
405
426
  * 移动节点
406
427
  * @param param0
@@ -591,6 +612,11 @@ declare class FlowNodeTransitionData extends EntityData<FlowNodeTransitionSchema
591
612
  get isNodeEnd(): boolean;
592
613
  }
593
614
 
615
+ /**
616
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
617
+ * SPDX-License-Identifier: MIT
618
+ */
619
+
594
620
  interface FlowNodeEntityConfig extends EntityOpts {
595
621
  document: FlowDocument;
596
622
  flowNodeType: FlowNodeType;
@@ -784,6 +810,11 @@ declare class FlowDocumentTransformerEntity extends ConfigEntity<{
784
810
  refresh(): void;
785
811
  }
786
812
 
813
+ /**
814
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
815
+ * SPDX-License-Identifier: MIT
816
+ */
817
+
787
818
  interface FlowRendererStateEntityConfig extends EntityOpts {
788
819
  }
789
820
  interface FlowRendererState {
@@ -814,6 +845,11 @@ declare class FlowRendererStateEntity extends ConfigEntity<FlowRendererState, Fl
814
845
  onNodeHoveredChange(fn: (hoveredNode: FlowNodeEntity | undefined) => void, debounceTime?: number): Disposable;
815
846
  }
816
847
 
848
+ /**
849
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
850
+ * SPDX-License-Identifier: MIT
851
+ */
852
+
817
853
  declare enum FlowTransitionLineEnum {
818
854
  STRAIGHT_LINE = 0,
819
855
  DIVERGE_LINE = 1,
@@ -884,6 +920,11 @@ interface DragNodeProps {
884
920
  node: FlowNodeEntity;
885
921
  }
886
922
 
923
+ /**
924
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
925
+ * SPDX-License-Identifier: MIT
926
+ */
927
+
887
928
  declare enum FlowLayoutDefault {
888
929
  VERTICAL_FIXED_LAYOUT = "vertical-fixed-layout",
889
930
  HORIZONTAL_FIXED_LAYOUT = "horizontal-fixed-layout"
@@ -936,6 +977,11 @@ interface FlowLayout {
936
977
  getDefaultNodeOrigin(): IPoint;
937
978
  }
938
979
 
980
+ /**
981
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
982
+ * SPDX-License-Identifier: MIT
983
+ */
984
+
939
985
  /**
940
986
  * 节点渲染相关配置信息,可扩展
941
987
  */
@@ -975,6 +1021,10 @@ declare const DefaultSpacingKey: {
975
1021
  * 普通节点间距。垂直 / 水平
976
1022
  */
977
1023
  NODE_SPACING: string;
1024
+ /**
1025
+ * 分支节点间距
1026
+ */
1027
+ BRANCH_SPACING: string;
978
1028
  /**
979
1029
  * 圆弧线条 x radius
980
1030
  */
@@ -1003,6 +1053,9 @@ declare const DefaultSpacingKey: {
1003
1053
  declare const DEFAULT_SPACING: {
1004
1054
  [x: string]: number;
1005
1055
  NULL: number;
1056
+ /**
1057
+ * @deprecated use 'BRANCH_SPACING' instead
1058
+ */
1006
1059
  MARGIN_RIGHT: number;
1007
1060
  INLINE_BLOCK_PADDING_BOTTOM: number;
1008
1061
  INLINE_BLOCKS_PADDING_TOP: number;
@@ -1153,6 +1206,11 @@ declare namespace FlowNodeRegistry {
1153
1206
  function extend(registry: FlowNodeRegistry, extendRegistries: FlowNodeRegistry[]): FlowNodeRegistry;
1154
1207
  }
1155
1208
 
1209
+ /**
1210
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1211
+ * SPDX-License-Identifier: MIT
1212
+ */
1213
+
1156
1214
  type FlowNodeType = string | number;
1157
1215
  /**
1158
1216
  * Flow node json data
@@ -1202,6 +1260,11 @@ type AddNodeData = FlowNodeJSON & {
1202
1260
  index?: number;
1203
1261
  };
1204
1262
 
1263
+ /**
1264
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1265
+ * SPDX-License-Identifier: MIT
1266
+ */
1267
+
1205
1268
  declare enum OperationType {
1206
1269
  addFromNode = "addFromNode",
1207
1270
  deleteFromNode = "deleteFromNode",
@@ -1448,10 +1511,19 @@ interface FlowOperationBaseService extends Disposable {
1448
1511
  }
1449
1512
  declare const FlowOperationBaseService: unique symbol;
1450
1513
 
1514
+ /**
1515
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1516
+ * SPDX-License-Identifier: MIT
1517
+ */
1451
1518
  interface FlowGroupJSON {
1452
1519
  nodeIDs: string[];
1453
1520
  }
1454
1521
 
1522
+ /**
1523
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1524
+ * SPDX-License-Identifier: MIT
1525
+ */
1526
+
1455
1527
  declare const FlowDocumentContainerModule: ContainerModule;
1456
1528
 
1457
1529
  /**
@@ -1543,6 +1615,11 @@ declare class FlowOperationBaseServiceImpl implements FlowOperationBaseService {
1543
1615
  protected doMoveNode(node: FlowNodeEntity, newParent: FlowNodeEntity, index: number): void;
1544
1616
  }
1545
1617
 
1618
+ /**
1619
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1620
+ * SPDX-License-Identifier: MIT
1621
+ */
1622
+
1546
1623
  /** 分组控制器 */
1547
1624
  declare class FlowGroupController {
1548
1625
  readonly groupNode: FlowNodeEntity;
@@ -1568,6 +1645,11 @@ declare class FlowGroupController {
1568
1645
  static create(groupNode?: FlowNodeEntity): FlowGroupController | undefined;
1569
1646
  }
1570
1647
 
1648
+ /**
1649
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1650
+ * SPDX-License-Identifier: MIT
1651
+ */
1652
+
1571
1653
  declare class FlowGroupService {
1572
1654
  readonly entityManager: EntityManager;
1573
1655
  readonly operationService: FlowOperationBaseService;
@@ -1584,6 +1666,11 @@ declare class FlowGroupService {
1584
1666
  static validate(nodes: FlowNodeEntity[]): boolean;
1585
1667
  }
1586
1668
 
1669
+ /**
1670
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1671
+ * SPDX-License-Identifier: MIT
1672
+ */
1673
+
1587
1674
  /**
1588
1675
  *
1589
1676
  * @param node 节点 entity
package/dist/index.js CHANGED
@@ -151,6 +151,10 @@ var DefaultSpacingKey = {
151
151
  * 普通节点间距。垂直 / 水平
152
152
  */
153
153
  NODE_SPACING: "SPACING",
154
+ /**
155
+ * 分支节点间距
156
+ */
157
+ BRANCH_SPACING: "BRANCH_SPACING",
154
158
  /**
155
159
  * 圆弧线条 x radius
156
160
  */
@@ -177,8 +181,13 @@ var DEFAULT_SPACING = {
177
181
  NULL: 0,
178
182
  [DefaultSpacingKey.NODE_SPACING]: 32,
179
183
  // 普通节点间距。垂直 / 水平
184
+ [DefaultSpacingKey.BRANCH_SPACING]: 20,
185
+ // 分支节点间距
186
+ /**
187
+ * @deprecated use 'BRANCH_SPACING' instead
188
+ */
180
189
  MARGIN_RIGHT: 20,
181
- // 普通节点右边间距
190
+ // 分支节点右边间距
182
191
  INLINE_BLOCK_PADDING_BOTTOM: 16,
183
192
  // block 底部留白
184
193
  INLINE_BLOCKS_PADDING_TOP: 30,
@@ -1074,37 +1083,7 @@ var FlowNodeEntity = class extends import_core4.Entity {
1074
1083
  * @param newId
1075
1084
  */
1076
1085
  toJSON() {
1077
- if (this.document.options.toNodeJSON) {
1078
- return this.document.options.toNodeJSON(this);
1079
- }
1080
- const nodesMap = {};
1081
- let startNodeJSON;
1082
- this.document.traverse((node) => {
1083
- const isSystemNode = node.id.startsWith("$");
1084
- if (isSystemNode) return;
1085
- const nodeJSONData = this.getJSONData();
1086
- const nodeJSON = {
1087
- id: node.id,
1088
- type: node.flowNodeType
1089
- };
1090
- if (nodeJSONData !== void 0) {
1091
- nodeJSON.data = nodeJSONData;
1092
- }
1093
- if (!startNodeJSON) startNodeJSON = nodeJSON;
1094
- let { parent } = node;
1095
- if (parent && parent.id.startsWith("$")) {
1096
- parent = parent.originParent;
1097
- }
1098
- const parentJSON = parent ? nodesMap[parent.id] : void 0;
1099
- if (parentJSON) {
1100
- if (!parentJSON.blocks) {
1101
- parentJSON.blocks = [];
1102
- }
1103
- parentJSON.blocks.push(nodeJSON);
1104
- }
1105
- nodesMap[node.id] = nodeJSON;
1106
- }, this);
1107
- return startNodeJSON;
1086
+ return this.document.toNodeJSON(this);
1108
1087
  }
1109
1088
  get isVertical() {
1110
1089
  return this.document.layout.name === "vertical-fixed-layout" /* VERTICAL_FIXED_LAYOUT */;
@@ -2153,6 +2132,39 @@ var FlowDocument = class {
2153
2132
  });
2154
2133
  return result;
2155
2134
  }
2135
+ toNodeJSON(node) {
2136
+ if (this.options.toNodeJSON) {
2137
+ return this.options.toNodeJSON(node);
2138
+ }
2139
+ const nodesMap = {};
2140
+ let startNodeJSON;
2141
+ this.traverse((node2) => {
2142
+ const isSystemNode = node2.id.startsWith("$");
2143
+ if (isSystemNode) return;
2144
+ const nodeJSONData = node2.getJSONData();
2145
+ const nodeJSON = {
2146
+ id: node2.id,
2147
+ type: node2.flowNodeType
2148
+ };
2149
+ if (nodeJSONData !== void 0) {
2150
+ nodeJSON.data = nodeJSONData;
2151
+ }
2152
+ if (!startNodeJSON) startNodeJSON = nodeJSON;
2153
+ let { parent } = node2;
2154
+ if (parent && parent.id.startsWith("$")) {
2155
+ parent = parent.originParent;
2156
+ }
2157
+ const parentJSON = parent ? nodesMap[parent.id] : void 0;
2158
+ if (parentJSON) {
2159
+ if (!parentJSON.blocks) {
2160
+ parentJSON.blocks = [];
2161
+ }
2162
+ parentJSON.blocks.push(nodeJSON);
2163
+ }
2164
+ nodesMap[node2.id] = nodeJSON;
2165
+ }, node);
2166
+ return startNodeJSON;
2167
+ }
2156
2168
  /**
2157
2169
  * 移动节点
2158
2170
  * @param param0