@flowgram.ai/document 0.1.0-alpha.2 → 0.1.0-alpha.20

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.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _flowgram_ai_utils from '@flowgram.ai/utils';
2
2
  import { Disposable, Emitter, IPoint, Rectangle, Event, PaddingSchema, SizeSchema as SizeSchema$1, ScrollSchema, PositionSchema as PositionSchema$1, DisposableCollection } from '@flowgram.ai/utils';
3
- import { EntityManager, EntityDataRegistry, EntityData, SizeSchema, TransformData, PositionSchema, EntityOpts, Entity, ConfigEntity, OriginSchema } from '@flowgram.ai/core';
3
+ import { EntityManager, EntityDataRegistry, EntityData, SizeSchema, TransformData, PositionSchema, Entity, EntityOpts, ConfigEntity, OriginSchema } from '@flowgram.ai/core';
4
4
  import { ContainerModule } from 'inversify';
5
5
 
6
6
  /**
@@ -9,6 +9,7 @@ import { ContainerModule } from 'inversify';
9
9
  */
10
10
  declare class FlowVirtualTree<T extends {
11
11
  id: string;
12
+ flowNodeType?: FlowNodeType;
12
13
  }> implements Disposable {
13
14
  readonly root: T;
14
15
  protected onTreeChangeEmitter: Emitter<void>;
@@ -45,7 +46,7 @@ declare class FlowVirtualTree<T extends {
45
46
  */
46
47
  fireTreeChange(): void;
47
48
  get size(): number;
48
- toString(): string;
49
+ toString(showType?: boolean): string;
49
50
  }
50
51
  declare namespace FlowVirtualTree {
51
52
  interface NodeInfo<T> {
@@ -56,6 +57,11 @@ declare namespace FlowVirtualTree {
56
57
  }
57
58
  }
58
59
 
60
+ /**
61
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
62
+ * SPDX-License-Identifier: MIT
63
+ */
64
+
59
65
  /**
60
66
  * Render Tree 会只读模式,不具备操作 tree 结构元素
61
67
  */
@@ -105,6 +111,11 @@ declare class FlowRenderTree<T extends FlowNodeEntity> extends FlowVirtualTree<T
105
111
  removeParent(): void;
106
112
  }
107
113
 
114
+ /**
115
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
116
+ * SPDX-License-Identifier: MIT
117
+ */
118
+
108
119
  declare const FlowDocumentOptions: unique symbol;
109
120
  /**
110
121
  * 流程画布配置
@@ -119,10 +130,11 @@ interface FlowDocumentOptions {
119
130
  */
120
131
  allNodesDefaultExpanded?: boolean;
121
132
  toNodeJSON?(node: FlowNodeEntity): FlowNodeJSON;
122
- fromNodeJSON?(node: FlowNodeEntity, json: FlowNodeJSON): void;
133
+ fromNodeJSON?(node: FlowNodeEntity, json: FlowNodeJSON, isFirstCreate: boolean): void;
123
134
  constants?: Record<string, any>;
124
135
  formatNodeLines?: (node: FlowNodeEntity, lines: FlowTransitionLine[]) => FlowTransitionLine[];
125
136
  formatNodeLabels?: (node: FlowNodeEntity, lines: FlowTransitionLabel[]) => FlowTransitionLabel[];
137
+ preNodeCreate?: (node: FlowNodeEntity) => void;
126
138
  /**
127
139
  * 获取默认的节点配置
128
140
  */
@@ -156,7 +168,13 @@ declare const ConstantKeys: {
156
168
  * 线条、label 激活后的颜色
157
169
  */
158
170
  BASE_ACTIVATED_COLOR: string;
171
+ /**
172
+ * Branch bottom margin
173
+ * 分支下边距
174
+ */
175
+ INLINE_BLOCKS_PADDING_TOP: string;
159
176
  NODE_SPACING: string;
177
+ BRANCH_SPACING: string;
160
178
  ROUNDED_LINE_X_RADIUS: string;
161
179
  ROUNDED_LINE_Y_RADIUS: string;
162
180
  INLINE_BLOCKS_PADDING_BOTTOM: string;
@@ -164,6 +182,11 @@ declare const ConstantKeys: {
164
182
  HOVER_AREA_WIDTH: string;
165
183
  };
166
184
 
185
+ /**
186
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
187
+ * SPDX-License-Identifier: MIT
188
+ */
189
+
167
190
  declare const FlowDocumentContribution: unique symbol;
168
191
  interface FlowDocumentContribution<T extends FlowDocument = FlowDocument> {
169
192
  /**
@@ -178,6 +201,10 @@ interface FlowDocumentContribution<T extends FlowDocument = FlowDocument> {
178
201
  loadDocument?(document: T): Promise<void>;
179
202
  }
180
203
 
204
+ /**
205
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
206
+ * SPDX-License-Identifier: MIT
207
+ */
181
208
  declare const FlowDocumentConfigDefaultData: unique symbol;
182
209
  /**
183
210
  * 用于文档扩展配置
@@ -212,11 +239,21 @@ declare class FlowDocument<T = FlowDocumentJSON> implements Disposable {
212
239
  protected currentLayoutKey: string;
213
240
  protected onNodeUpdateEmitter: Emitter<{
214
241
  node: FlowNodeEntity;
242
+ /**
243
+ * use 'json' instead
244
+ * @deprecated
245
+ */
215
246
  data: FlowNodeJSON;
247
+ json: FlowNodeJSON;
216
248
  }>;
217
249
  protected onNodeCreateEmitter: Emitter<{
218
250
  node: FlowNodeEntity;
251
+ /**
252
+ * use 'json' instead
253
+ * @deprecated
254
+ */
219
255
  data: FlowNodeJSON;
256
+ json: FlowNodeJSON;
220
257
  }>;
221
258
  protected onNodeDisposeEmitter: Emitter<{
222
259
  node: FlowNodeEntity;
@@ -224,16 +261,27 @@ declare class FlowDocument<T = FlowDocumentJSON> implements Disposable {
224
261
  protected onLayoutChangeEmitter: Emitter<FlowLayout>;
225
262
  readonly onNodeUpdate: _flowgram_ai_utils.Event<{
226
263
  node: FlowNodeEntity;
264
+ /**
265
+ * use 'json' instead
266
+ * @deprecated
267
+ */
227
268
  data: FlowNodeJSON;
269
+ json: FlowNodeJSON;
228
270
  }>;
229
271
  readonly onNodeCreate: _flowgram_ai_utils.Event<{
230
272
  node: FlowNodeEntity;
273
+ /**
274
+ * use 'json' instead
275
+ * @deprecated
276
+ */
231
277
  data: FlowNodeJSON;
278
+ json: FlowNodeJSON;
232
279
  }>;
233
280
  readonly onNodeDispose: _flowgram_ai_utils.Event<{
234
281
  node: FlowNodeEntity;
235
282
  }>;
236
283
  readonly onLayoutChange: _flowgram_ai_utils.Event<FlowLayout>;
284
+ private _disposed;
237
285
  root: FlowNodeEntity;
238
286
  /**
239
287
  * 原始的 tree 结构
@@ -248,6 +296,10 @@ declare class FlowDocument<T = FlowDocumentJSON> implements Disposable {
248
296
  * 渲染后的 tree 结构
249
297
  */
250
298
  renderTree: FlowRenderTree<FlowNodeEntity>;
299
+ /**
300
+ *
301
+ */
302
+ get disposed(): boolean;
251
303
  init(): void;
252
304
  /**
253
305
  * 从数据初始化 O(n)
@@ -278,7 +330,7 @@ declare class FlowDocument<T = FlowDocumentJSON> implements Disposable {
278
330
  * @param data
279
331
  * @param addedNodes
280
332
  */
281
- addNode(data: AddNodeData, addedNodes?: FlowNodeEntity[], ignoreCreateEvent?: boolean): FlowNodeEntity;
333
+ addNode(data: AddNodeData, addedNodes?: FlowNodeEntity[]): FlowNodeEntity;
282
334
  addBlocksAsChildren(parent: FlowNodeEntity, blocks: FlowNodeJSON[], addedNodes?: FlowNodeEntity[]): void;
283
335
  /**
284
336
  * block 格式:
@@ -312,6 +364,18 @@ declare class FlowDocument<T = FlowDocumentJSON> implements Disposable {
312
364
  * @param registries
313
365
  */
314
366
  registerFlowNodes<T extends FlowNodeRegistry<any>>(...registries: T[]): void;
367
+ /**
368
+ * Check node extend
369
+ * @param currentType
370
+ * @param extendType
371
+ */
372
+ isExtend(currentType: FlowNodeType, extendType: FlowNodeType): boolean;
373
+ /**
374
+ * Check node type
375
+ * @param currentType
376
+ * @param extendType
377
+ */
378
+ isTypeOrExtendType(currentType: FlowNodeType, extendType: FlowNodeType): boolean;
315
379
  /**
316
380
  * 导出数据,可以重载
317
381
  */
@@ -359,11 +423,12 @@ declare class FlowDocument<T = FlowDocumentJSON> implements Disposable {
359
423
  get size(): number;
360
424
  hasNode(nodeId: string): boolean;
361
425
  getAllNodes(): FlowNodeEntity[];
362
- toString(): string;
426
+ toString(showType?: boolean): string;
363
427
  /**
364
428
  * 返回需要渲染的数据
365
429
  */
366
430
  getRenderDatas<T extends EntityData>(dataRegistry: EntityDataRegistry<T>, containHiddenNodes?: boolean): T[];
431
+ toNodeJSON(node: FlowNodeEntity): FlowNodeJSON;
367
432
  /**
368
433
  * 移动节点
369
434
  * @param param0
@@ -409,6 +474,7 @@ interface FlowNodeRenderSchema {
409
474
  activated: boolean;
410
475
  hovered: boolean;
411
476
  dragging: boolean;
477
+ stackIndex: number;
412
478
  extInfo?: Record<string, any>;
413
479
  }
414
480
  /**
@@ -428,7 +494,7 @@ declare class FlowNodeRenderData extends EntityData<FlowNodeRenderSchema> {
428
494
  }>;
429
495
  get key(): string;
430
496
  getDefaultData(): FlowNodeRenderSchema;
431
- updateExtInfo(info: Record<string, any>): void;
497
+ updateExtInfo(info: Record<string, any>, fullUpdate?: boolean): void;
432
498
  getExtInfo(): Record<string, any> | undefined;
433
499
  constructor(entity: FlowNodeEntity);
434
500
  get addable(): boolean;
@@ -447,6 +513,8 @@ declare class FlowNodeRenderData extends EntityData<FlowNodeRenderSchema> {
447
513
  set dragging(dragging: boolean);
448
514
  set activated(activated: boolean);
449
515
  get activated(): boolean;
516
+ get stackIndex(): number;
517
+ set stackIndex(index: number);
450
518
  get lineActivated(): boolean;
451
519
  get node(): HTMLDivElement;
452
520
  dispose(): void;
@@ -475,6 +543,7 @@ declare class FlowNodeTransformData extends EntityData<FlowNodeTransformSchema>
475
543
  */
476
544
  get size(): SizeSchema;
477
545
  get position(): PositionSchema;
546
+ set position(position: PositionSchema);
478
547
  set size(size: SizeSchema);
479
548
  get inputPoint(): IPoint;
480
549
  get defaultInputPoint(): IPoint;
@@ -551,6 +620,11 @@ declare class FlowNodeTransitionData extends EntityData<FlowNodeTransitionSchema
551
620
  get isNodeEnd(): boolean;
552
621
  }
553
622
 
623
+ /**
624
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
625
+ * SPDX-License-Identifier: MIT
626
+ */
627
+
554
628
  interface FlowNodeEntityConfig extends EntityOpts {
555
629
  document: FlowDocument;
556
630
  flowNodeType: FlowNodeType;
@@ -617,7 +691,9 @@ declare class FlowNodeEntity extends Entity<FlowNodeEntityConfig> {
617
691
  get pre(): FlowNodeEntity | undefined;
618
692
  get next(): FlowNodeEntity | undefined;
619
693
  get parent(): FlowNodeEntity | undefined;
620
- getNodeRegistry<M extends FlowNodeRegistry = FlowNodeRegistry>(): M;
694
+ getNodeRegistry<M extends FlowNodeRegistry = FlowNodeRegistry & {
695
+ meta: FlowNodeMeta;
696
+ }>(): M;
621
697
  /**
622
698
  * @deprecated
623
699
  * use getNodeRegistry instead
@@ -681,7 +757,7 @@ declare class FlowNodeEntity extends Entity<FlowNodeEntityConfig> {
681
757
  * 修改节点扩展信息
682
758
  * @param info
683
759
  */
684
- updateExtInfo<T extends Record<string, any> = Record<string, any>>(extInfo: T): void;
760
+ updateExtInfo<T extends Record<string, any> = Record<string, any>>(extInfo: T, fullUpdate?: boolean): void;
685
761
  /**
686
762
  * 获取节点扩展信息
687
763
  */
@@ -702,6 +778,15 @@ declare class FlowNodeEntity extends Entity<FlowNodeEntityConfig> {
702
778
  * 获取节点的位置及大小矩形
703
779
  */
704
780
  get bounds(): Rectangle;
781
+ /**
782
+ * Check node extend type
783
+ */
784
+ isExtend(parentType: FlowNodeType): boolean;
785
+ /**
786
+ * Check node type
787
+ * @param parentType
788
+ */
789
+ isTypeOrExtendType(parentType: FlowNodeType): boolean;
705
790
  }
706
791
  declare namespace FlowNodeEntity {
707
792
  function is(obj: Entity): obj is FlowNodeEntity;
@@ -742,6 +827,11 @@ declare class FlowDocumentTransformerEntity extends ConfigEntity<{
742
827
  refresh(): void;
743
828
  }
744
829
 
830
+ /**
831
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
832
+ * SPDX-License-Identifier: MIT
833
+ */
834
+
745
835
  interface FlowRendererStateEntityConfig extends EntityOpts {
746
836
  }
747
837
  interface FlowRendererState {
@@ -751,6 +841,8 @@ interface FlowRendererState {
751
841
  nodeDragIds?: string[];
752
842
  nodeDragIdsWithChildren?: string[];
753
843
  dragLabelSide?: LABEL_SIDE_TYPE;
844
+ dragging?: boolean;
845
+ isBranch?: boolean;
754
846
  }
755
847
  /**
756
848
  * 渲染相关的全局状态管理
@@ -761,6 +853,10 @@ declare class FlowRendererStateEntity extends ConfigEntity<FlowRendererState, Fl
761
853
  constructor(conf: FlowRendererStateEntityConfig);
762
854
  getNodeHovered(): FlowNodeEntity | undefined;
763
855
  setNodeHovered(node: FlowNodeEntity | undefined): void;
856
+ get dragging(): boolean | undefined;
857
+ setDragging(dragging: boolean): void;
858
+ get isBranch(): boolean | undefined;
859
+ setIsBranch(isBranch: boolean): void;
764
860
  getDragLabelSide(): LABEL_SIDE_TYPE | undefined;
765
861
  setDragLabelSide(dragLabelSide?: LABEL_SIDE_TYPE): void;
766
862
  getNodeDroppingId(): string | undefined;
@@ -772,12 +868,17 @@ declare class FlowRendererStateEntity extends ConfigEntity<FlowRendererState, Fl
772
868
  onNodeHoveredChange(fn: (hoveredNode: FlowNodeEntity | undefined) => void, debounceTime?: number): Disposable;
773
869
  }
774
870
 
871
+ /**
872
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
873
+ * SPDX-License-Identifier: MIT
874
+ */
875
+
775
876
  declare enum FlowTransitionLineEnum {
776
- STRAIGHT_LINE = 0,
777
- DIVERGE_LINE = 1,
778
- MERGE_LINE = 2,
779
- ROUNDED_LINE = 3,
780
- CUSTOM_LINE = 4,
877
+ STRAIGHT_LINE = 0,// 直线
878
+ DIVERGE_LINE = 1,// 分支线 (一种 ROUNDED_LINE)
879
+ MERGE_LINE = 2,// 汇聚线 (一种 ROUNDED_LINE)
880
+ ROUNDED_LINE = 3,// 自定义圆角转弯线
881
+ CUSTOM_LINE = 4,// 自定义,用于处理循环节点等自定义线条
781
882
  DRAGGING_LINE = 5
782
883
  }
783
884
  interface Vertex extends IPoint {
@@ -785,6 +886,10 @@ interface Vertex extends IPoint {
785
886
  radiusY?: number;
786
887
  moveX?: number;
787
888
  moveY?: number;
889
+ /**
890
+ * Strategy for handling arc curvature when space is insufficient, defaults to compress
891
+ */
892
+ radiusOverflow?: 'compress' | 'truncate';
788
893
  }
789
894
  interface FlowTransitionLine {
790
895
  type: FlowTransitionLineEnum;
@@ -794,16 +899,18 @@ interface FlowTransitionLine {
794
899
  arrow?: boolean;
795
900
  renderKey?: string;
796
901
  isHorizontal?: boolean;
902
+ isDraggingLine?: boolean;
797
903
  activated?: boolean;
798
904
  side?: LABEL_SIDE_TYPE;
799
905
  style?: React.CSSProperties;
906
+ lineId?: string;
800
907
  }
801
908
  declare enum FlowTransitionLabelEnum {
802
- ADDER_LABEL = 0,
803
- TEXT_LABEL = 1,
804
- COLLAPSE_LABEL = 2,
805
- COLLAPSE_ADDER_LABEL = 3,
806
- CUSTOM_LABEL = 4,
909
+ ADDER_LABEL = 0,// 添加按钮
910
+ TEXT_LABEL = 1,// 文本标签
911
+ COLLAPSE_LABEL = 2,// 复合节点收起的展开标签
912
+ COLLAPSE_ADDER_LABEL = 3,// 复合节点收起 + 加号复合标签
913
+ CUSTOM_LABEL = 4,// 自定义,用于处理循环节点等自定义标签
807
914
  BRANCH_DRAGGING_LABEL = 5
808
915
  }
809
916
  interface FlowTransitionLabel {
@@ -812,7 +919,16 @@ interface FlowTransitionLabel {
812
919
  offset: IPoint;
813
920
  width?: number;
814
921
  rotate?: string;
922
+ /**
923
+ * Anchor point for positioning, relative to the label's bounding box
924
+ * 重心偏移量,相对于标签边界框
925
+ *
926
+ * Format: [x, y] / 格式:[x, y]
927
+ * Default Value: [0.5, 0.5] indicates center / 默认值:[0.5, 0.5] 表示居中
928
+ */
929
+ origin?: [number, number];
815
930
  props?: Record<string, any>;
931
+ labelId?: string;
816
932
  }
817
933
  interface AdderProps {
818
934
  node: FlowNodeEntity;
@@ -839,8 +955,13 @@ interface DragNodeProps {
839
955
  node: FlowNodeEntity;
840
956
  }
841
957
 
958
+ /**
959
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
960
+ * SPDX-License-Identifier: MIT
961
+ */
962
+
842
963
  declare enum FlowLayoutDefault {
843
- VERTICAL_FIXED_LAYOUT = "vertical-fixed-layout",
964
+ VERTICAL_FIXED_LAYOUT = "vertical-fixed-layout",// 垂直固定布局
844
965
  HORIZONTAL_FIXED_LAYOUT = "horizontal-fixed-layout"
845
966
  }
846
967
  declare namespace FlowLayoutDefault {
@@ -891,6 +1012,11 @@ interface FlowLayout {
891
1012
  getDefaultNodeOrigin(): IPoint;
892
1013
  }
893
1014
 
1015
+ /**
1016
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1017
+ * SPDX-License-Identifier: MIT
1018
+ */
1019
+
894
1020
  /**
895
1021
  * 节点渲染相关配置信息,可扩展
896
1022
  */
@@ -905,13 +1031,13 @@ interface FlowNodeMeta {
905
1031
  addDisable?: boolean;
906
1032
  hidden?: boolean;
907
1033
  size?: SizeSchema;
1034
+ autoResizeDisable?: boolean;
908
1035
  /**
909
1036
  * @deprecated 使用 NodeRegister.getOrigin 代替
910
1037
  */
911
1038
  origin?: OriginSchema;
912
1039
  defaultExpanded?: boolean;
913
1040
  defaultCollapsed?: boolean;
914
- expandedSize?: SizeSchema;
915
1041
  spacing?: number | ((transform: FlowNodeTransformData) => number);
916
1042
  padding?: PaddingSchema | ((transform: FlowNodeTransformData) => PaddingSchema);
917
1043
  inlineSpacingPre?: number | ((transform: FlowNodeTransformData) => number);
@@ -930,6 +1056,10 @@ declare const DefaultSpacingKey: {
930
1056
  * 普通节点间距。垂直 / 水平
931
1057
  */
932
1058
  NODE_SPACING: string;
1059
+ /**
1060
+ * 分支节点间距
1061
+ */
1062
+ BRANCH_SPACING: string;
933
1063
  /**
934
1064
  * 圆弧线条 x radius
935
1065
  */
@@ -956,8 +1086,17 @@ declare const DefaultSpacingKey: {
956
1086
  * 默认一些间隔参数
957
1087
  */
958
1088
  declare const DEFAULT_SPACING: {
959
- [x: string]: number;
1089
+ [DefaultSpacingKey.NODE_SPACING]: number;
1090
+ [DefaultSpacingKey.BRANCH_SPACING]: number;
1091
+ [DefaultSpacingKey.INLINE_BLOCKS_PADDING_BOTTOM]: number;
1092
+ [DefaultSpacingKey.COLLAPSED_SPACING]: number;
1093
+ [DefaultSpacingKey.ROUNDED_LINE_X_RADIUS]: number;
1094
+ [DefaultSpacingKey.ROUNDED_LINE_Y_RADIUS]: number;
1095
+ [DefaultSpacingKey.HOVER_AREA_WIDTH]: number;
960
1096
  NULL: number;
1097
+ /**
1098
+ * @deprecated use 'BRANCH_SPACING' instead
1099
+ */
961
1100
  MARGIN_RIGHT: number;
962
1101
  INLINE_BLOCK_PADDING_BOTTOM: number;
963
1102
  INLINE_BLOCKS_PADDING_TOP: number;
@@ -1082,6 +1221,7 @@ interface FlowNodeRegistry<M extends FlowNodeMeta = FlowNodeMeta> {
1082
1221
  */
1083
1222
  extendChildRegistries?: FlowNodeRegistry[];
1084
1223
  /**
1224
+ * @deprecated
1085
1225
  * 自定义子节点添加逻辑
1086
1226
  * @param node 节点
1087
1227
  * @param json 添加的节点 JSON
@@ -1092,23 +1232,33 @@ interface FlowNodeRegistry<M extends FlowNodeMeta = FlowNodeMeta> {
1092
1232
  hidden?: boolean;
1093
1233
  index?: number;
1094
1234
  }) => FlowNodeEntity;
1235
+ /**
1236
+ * 内部用于继承逻辑判断,不要使用
1237
+ */
1238
+ __extends__?: FlowNodeType[];
1095
1239
  /**
1096
1240
  * 扩展注册器
1097
1241
  */
1098
1242
  [key: string]: any;
1099
1243
  }
1100
1244
  declare namespace FlowNodeRegistry {
1245
+ function mergeChildRegistries(r1?: FlowNodeRegistry[], r2?: FlowNodeRegistry[]): FlowNodeRegistry[];
1101
1246
  function merge(registry1: FlowNodeRegistry, registry2: FlowNodeRegistry, finalType: FlowNodeType): FlowNodeRegistry;
1102
1247
  function extend(registry: FlowNodeRegistry, extendRegistries: FlowNodeRegistry[]): FlowNodeRegistry;
1103
1248
  }
1104
1249
 
1250
+ /**
1251
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1252
+ * SPDX-License-Identifier: MIT
1253
+ */
1254
+
1105
1255
  type FlowNodeType = string | number;
1106
1256
  /**
1107
1257
  * Flow node json data
1108
1258
  */
1109
1259
  interface FlowNodeJSON {
1110
1260
  id: string;
1111
- type?: FlowNodeType;
1261
+ type?: FlowNodeBaseType | FlowNodeSplitType | FlowNodeType;
1112
1262
  data?: Record<string, any>;
1113
1263
  meta?: FlowNodeMeta;
1114
1264
  blocks?: FlowNodeJSON[];
@@ -1117,21 +1267,29 @@ type FlowDocumentJSON = {
1117
1267
  nodes: FlowNodeJSON[];
1118
1268
  };
1119
1269
  declare enum FlowNodeBaseType {
1120
- START = "start",
1121
- DEFAULT = "default",
1122
- ROOT = "root",
1123
- EMPTY = "empty",
1124
- INLINE_BLOCKS = "inlineBlocks",
1125
- BLOCK_ICON = "blockIcon",
1126
- BLOCK = "block",
1127
- BLOCK_ORDER_ICON = "blockOrderIcon",
1128
- GROUP = "group",
1129
- END = "end",
1130
- CONDITION = "condition",
1131
- SUB_CANVAS = "subCanvas"
1270
+ START = "start",// 开始节点
1271
+ DEFAULT = "default",// 默认节点类型
1272
+ ROOT = "root",// 根节点
1273
+ EMPTY = "empty",// 空节点,宽和高为 0
1274
+ INLINE_BLOCKS = "inlineBlocks",// 所有块合并为 InlineBlocks
1275
+ BLOCK_ICON = "blockIcon",// 图标节点,如条件分支的头部的 菱形图标
1276
+ BLOCK = "block",// 块节点
1277
+ BLOCK_ORDER_ICON = "blockOrderIcon",// 带顺序的图标节点,一般为 block 第一个分支节点
1278
+ GROUP = "group",// 分组节点
1279
+ END = "end",// 结束节点
1280
+ BREAK = "break",// 分支结束
1281
+ CONDITION = "condition",// 可以连接多条线的条件判断节点,目前只支持横向布局
1282
+ SUB_CANVAS = "subCanvas",// 自由布局子画布
1283
+ MULTI_INPUTS = "multiInputs",// 多输入
1284
+ MULTI_OUTPUTS = "multiOutputs",// 多输出
1285
+ INPUT = "input",// 输入节点
1286
+ OUTPUT = "output",// 输出节点
1287
+ SLOT = "slot",// 插槽节点
1288
+ SLOT_BLOCK = "slotBlock"
1132
1289
  }
1133
1290
  declare enum FlowNodeSplitType {
1134
- DYNAMIC_SPLIT = "dynamicSplit",
1291
+ SIMPLE_SPLIT = "simpleSplit",// 无 BlockOrderIcon
1292
+ DYNAMIC_SPLIT = "dynamicSplit",// 动态分支
1135
1293
  STATIC_SPLIT = "staticSplit"
1136
1294
  }
1137
1295
  declare enum FlowDocumentConfigEnum {
@@ -1145,6 +1303,11 @@ type AddNodeData = FlowNodeJSON & {
1145
1303
  index?: number;
1146
1304
  };
1147
1305
 
1306
+ /**
1307
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1308
+ * SPDX-License-Identifier: MIT
1309
+ */
1310
+
1148
1311
  declare enum OperationType {
1149
1312
  addFromNode = "addFromNode",
1150
1313
  deleteFromNode = "deleteFromNode",
@@ -1157,7 +1320,6 @@ declare enum OperationType {
1157
1320
  moveChildNodes = "moveChildNodes",
1158
1321
  addNodes = "addNodes",
1159
1322
  deleteNodes = "deleteNodes",
1160
- changeNode = "changeNode",
1161
1323
  addChildNode = "addChildNode",
1162
1324
  deleteChildNode = "deleteChildNode",
1163
1325
  addNode = "addNode",
@@ -1227,16 +1389,6 @@ interface DeleteNodesOperation {
1227
1389
  type: OperationType.deleteNodes;
1228
1390
  value: AddOrDeleteNodesOperationValue;
1229
1391
  }
1230
- interface ChangeNodeOperationValue {
1231
- id: string;
1232
- path: string;
1233
- oldValue: any;
1234
- value: any;
1235
- }
1236
- interface ChangeNodeOperation {
1237
- type: OperationType.changeNode;
1238
- value: ChangeNodeOperationValue;
1239
- }
1240
1392
  interface MoveChildNodesOperationValue {
1241
1393
  nodeIds: string[];
1242
1394
  fromParentId: string;
@@ -1288,7 +1440,7 @@ interface AddOrDeleteNodeValue {
1288
1440
  index?: number;
1289
1441
  hidden?: boolean;
1290
1442
  }
1291
- type FlowOperation = AddFromNodeOperation | DeleteFromNodeOperation | AddBlockOperation | DeleteBlockOperation | CreateGroupOperation | UngroupOperation | MoveNodesOperation | AddNodesOperation | DeleteNodesOperation | ChangeNodeOperation | MoveBlockOperation | AddChildNodeOperation | DeleteChildNodeOperation | MoveChildNodesOperation | AddNodeOperation | DeleteNodeOperation;
1443
+ type FlowOperation = AddFromNodeOperation | DeleteFromNodeOperation | AddBlockOperation | DeleteBlockOperation | CreateGroupOperation | UngroupOperation | MoveNodesOperation | AddNodesOperation | DeleteNodesOperation | MoveBlockOperation | AddChildNodeOperation | DeleteChildNodeOperation | MoveChildNodesOperation | AddNodeOperation | DeleteNodeOperation;
1292
1444
  type FlowNodeEntityOrId = string | FlowNodeEntity;
1293
1445
  type AddNodeConfig = {
1294
1446
  parent?: FlowNodeEntityOrId;
@@ -1316,6 +1468,16 @@ interface OnNodeAddEvent {
1316
1468
  node: FlowNodeEntity;
1317
1469
  data: AddNodeData;
1318
1470
  }
1471
+ /**
1472
+ * 节点移动事件
1473
+ */
1474
+ interface OnNodeMoveEvent {
1475
+ node: FlowNodeEntity;
1476
+ fromParent: FlowNodeEntity;
1477
+ fromIndex: number;
1478
+ toParent: FlowNodeEntity;
1479
+ toIndex: number;
1480
+ }
1319
1481
  interface FlowOperationBaseService extends Disposable {
1320
1482
  /**
1321
1483
  * 执行操作
@@ -1374,13 +1536,26 @@ interface FlowOperationBaseService extends Disposable {
1374
1536
  * 添加节点的回调
1375
1537
  */
1376
1538
  onNodeAdd: Event<OnNodeAddEvent>;
1539
+ /**
1540
+ * 节点移动的回调
1541
+ */
1542
+ onNodeMove: Event<OnNodeMoveEvent>;
1377
1543
  }
1378
1544
  declare const FlowOperationBaseService: unique symbol;
1379
1545
 
1546
+ /**
1547
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1548
+ * SPDX-License-Identifier: MIT
1549
+ */
1380
1550
  interface FlowGroupJSON {
1381
1551
  nodeIDs: string[];
1382
1552
  }
1383
1553
 
1554
+ /**
1555
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1556
+ * SPDX-License-Identifier: MIT
1557
+ */
1558
+
1384
1559
  declare const FlowDocumentContainerModule: ContainerModule;
1385
1560
 
1386
1561
  /**
@@ -1394,10 +1569,12 @@ declare class FlowDragService {
1394
1569
  protected onDropEmitter: Emitter<{
1395
1570
  dropNode: FlowNodeEntity;
1396
1571
  dragNodes: FlowNodeEntity[];
1572
+ dragJSON?: FlowNodeJSON;
1397
1573
  }>;
1398
1574
  readonly onDrop: _flowgram_ai_utils.Event<{
1399
1575
  dropNode: FlowNodeEntity;
1400
1576
  dragNodes: FlowNodeEntity[];
1577
+ dragJSON?: FlowNodeJSON;
1401
1578
  }>;
1402
1579
  get renderState(): FlowRendererStateEntity;
1403
1580
  get dragStartNode(): FlowNodeEntity;
@@ -1411,6 +1588,11 @@ declare class FlowDragService {
1411
1588
  * 放置到目标分支
1412
1589
  */
1413
1590
  dropBranch(): void;
1591
+ /**
1592
+ * 移动并且创建节点
1593
+ * Move and create node
1594
+ */
1595
+ dropCreateNode(json: FlowNodeJSON, onCreateNode?: (json: FlowNodeJSON, dropEntity: FlowNodeEntity) => Promise<FlowNodeEntity>): Promise<void>;
1414
1596
  /**
1415
1597
  * 移动到目标节点
1416
1598
  */
@@ -1436,6 +1618,8 @@ declare class FlowOperationBaseServiceImpl implements FlowOperationBaseService {
1436
1618
  protected onNodeAddEmitter: Emitter<OnNodeAddEvent>;
1437
1619
  readonly onNodeAdd: _flowgram_ai_utils.Event<OnNodeAddEvent>;
1438
1620
  protected toDispose: DisposableCollection;
1621
+ private onNodeMoveEmitter;
1622
+ readonly onNodeMove: _flowgram_ai_utils.Event<OnNodeMoveEvent>;
1439
1623
  protected init(): void;
1440
1624
  addNode(nodeJSON: FlowNodeJSON, config?: AddNodeConfig): FlowNodeEntity;
1441
1625
  addFromNode(fromNode: FlowNodeEntityOrId, nodeJSON: FlowNodeJSON): FlowNodeEntity;
@@ -1470,21 +1654,11 @@ declare class FlowOperationBaseServiceImpl implements FlowOperationBaseService {
1470
1654
  protected doMoveNode(node: FlowNodeEntity, newParent: FlowNodeEntity, index: number): void;
1471
1655
  }
1472
1656
 
1473
- declare class FlowGroupService {
1474
- readonly entityManager: EntityManager;
1475
- readonly operationService: FlowOperationBaseService;
1476
- /** 创建分组节点 */
1477
- createGroup(nodes: FlowNodeEntity[]): FlowNodeEntity | undefined;
1478
- /** 删除分组 */
1479
- deleteGroup(groupNode: FlowNodeEntity): void;
1480
- /** 取消分组 */
1481
- ungroup(groupNode: FlowNodeEntity): void;
1482
- /** 返回所有分组节点 */
1483
- getAllGroups(): FlowGroupController[];
1484
- /** 获取分组控制器*/
1485
- groupController(group: FlowNodeEntity): FlowGroupController | undefined;
1486
- static validate(nodes: FlowNodeEntity[]): boolean;
1487
- }
1657
+ /**
1658
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1659
+ * SPDX-License-Identifier: MIT
1660
+ */
1661
+
1488
1662
  /** 分组控制器 */
1489
1663
  declare class FlowGroupController {
1490
1664
  readonly groupNode: FlowNodeEntity;
@@ -1508,20 +1682,34 @@ declare class FlowGroupController {
1508
1682
  set hovered(hovered: boolean);
1509
1683
  get hovered(): boolean;
1510
1684
  static create(groupNode?: FlowNodeEntity): FlowGroupController | undefined;
1511
- /** 判断节点能否组成分组 */
1685
+ }
1686
+
1687
+ /**
1688
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1689
+ * SPDX-License-Identifier: MIT
1690
+ */
1691
+
1692
+ declare class FlowGroupService {
1693
+ readonly entityManager: EntityManager;
1694
+ readonly operationService: FlowOperationBaseService;
1695
+ /** 创建分组节点 */
1696
+ createGroup(nodes: FlowNodeEntity[]): FlowNodeEntity | undefined;
1697
+ /** 删除分组 */
1698
+ deleteGroup(groupNode: FlowNodeEntity): void;
1699
+ /** 取消分组 */
1700
+ ungroup(groupNode: FlowNodeEntity): void;
1701
+ /** 返回所有分组节点 */
1702
+ getAllGroups(): FlowGroupController[];
1703
+ /** 获取分组控制器*/
1704
+ groupController(group: FlowNodeEntity): FlowGroupController | undefined;
1512
1705
  static validate(nodes: FlowNodeEntity[]): boolean;
1513
- /** 获取节点分组控制 */
1514
- static getNodeGroupController(node?: FlowNodeEntity): FlowGroupController | undefined;
1515
- /** 向上递归查找分组递归控制 */
1516
- static getNodeRecursionGroupController(node?: FlowNodeEntity): FlowGroupController | undefined;
1517
- /** 是否分组节点 */
1518
- static isGroupNode(group: FlowNodeEntity): boolean;
1519
- /** 找到节点所有上级 */
1520
- private static findNodeParents;
1521
- /** 节点是否处于分组中 */
1522
- private static isNodeInGroup;
1523
1706
  }
1524
1707
 
1708
+ /**
1709
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1710
+ * SPDX-License-Identifier: MIT
1711
+ */
1712
+
1525
1713
  /**
1526
1714
  *
1527
1715
  * @param node 节点 entity
@@ -1531,4 +1719,4 @@ declare class FlowGroupController {
1531
1719
  */
1532
1720
  declare const getDefaultSpacing: (node: FlowNodeEntity, key: string, defaultSpacing?: number) => any;
1533
1721
 
1534
- export { type AddBlockConfig, type AddBlockOperation, type AddChildNodeOperation, type AddFromNodeOperation, type AddNodeConfig, type AddNodeData, type AddNodeOperation, type AddNodesOperation, type AddOrDeleteBlockValue, type AddOrDeleteChildNodeValue, type AddOrDeleteFromNodeOperationValue, type AddOrDeleteNodeOperationValue, type AddOrDeleteNodeValue, type AddOrDeleteNodesOperationValue, type AdderProps, type ChangeNodeOperation, type ChangeNodeOperationValue, type CollapseAdderProps, type CollapseProps, ConstantKeys, type CreateGroupOperation, type CustomLabelProps, DEFAULT_FLOW_NODE_META, DEFAULT_SIZE, DEFAULT_SPACING, DRAGGING_TYPE, DefaultSpacingKey, type DeleteBlockOperation, type DeleteChildNodeOperation, type DeleteFromNodeOperation, type DeleteNodeOperation, type DeleteNodesOperation, type DragNodeProps, FLOW_DEFAULT_HIDDEN_TYPES, FlowDocument, FlowDocumentConfig, FlowDocumentConfigDefaultData, FlowDocumentConfigEnum, FlowDocumentContainerModule, FlowDocumentContribution, type FlowDocumentJSON, FlowDocumentOptions, FlowDocumentOptionsDefault, FlowDocumentProvider, FlowDocumentTransformerEntity, FlowDragService, FlowGroupController, type FlowGroupJSON, FlowGroupService, FlowLayout, FlowLayoutContribution, FlowLayoutDefault, FlowNodeBaseType, FlowNodeEntity, type FlowNodeEntityConfig, type FlowNodeEntityOrId, type FlowNodeInitData, type FlowNodeJSON, type FlowNodeMeta, FlowNodeRegistry, FlowNodeRenderData, type FlowNodeRenderSchema, FlowNodeSplitType, FlowNodeTransformData, type FlowNodeTransformSchema, FlowNodeTransitionData, type FlowNodeTransitionSchema, type FlowNodeType, type FlowOperation, FlowOperationBaseService, FlowOperationBaseServiceImpl, FlowRendererStateEntity, type FlowTransitionLabel, FlowTransitionLabelEnum, type FlowTransitionLine, FlowTransitionLineEnum, FlowVirtualTree, LABEL_SIDE_TYPE, type MoveBlockOperation, type MoveBlockOperationValue, type MoveChildNodesOperation, type MoveChildNodesOperationValue, type MoveNodeConfig, type MoveNodesOperation, type MoveNodesOperationValue, type OnNodeAddEvent, OperationType, type UngroupOperation, type Vertex, type createOrUngroupValue, drawLineToBottom, drawLineToNext, getDefaultSpacing };
1722
+ export { type AddBlockConfig, type AddBlockOperation, type AddChildNodeOperation, type AddFromNodeOperation, type AddNodeConfig, type AddNodeData, type AddNodeOperation, type AddNodesOperation, type AddOrDeleteBlockValue, type AddOrDeleteChildNodeValue, type AddOrDeleteFromNodeOperationValue, type AddOrDeleteNodeOperationValue, type AddOrDeleteNodeValue, type AddOrDeleteNodesOperationValue, type AdderProps, type CollapseAdderProps, type CollapseProps, ConstantKeys, type CreateGroupOperation, type CustomLabelProps, DEFAULT_FLOW_NODE_META, DEFAULT_SIZE, DEFAULT_SPACING, DRAGGING_TYPE, DefaultSpacingKey, type DeleteBlockOperation, type DeleteChildNodeOperation, type DeleteFromNodeOperation, type DeleteNodeOperation, type DeleteNodesOperation, type DragNodeProps, FLOW_DEFAULT_HIDDEN_TYPES, FlowDocument, FlowDocumentConfig, FlowDocumentConfigDefaultData, FlowDocumentConfigEnum, FlowDocumentContainerModule, FlowDocumentContribution, type FlowDocumentJSON, FlowDocumentOptions, FlowDocumentOptionsDefault, FlowDocumentProvider, FlowDocumentTransformerEntity, FlowDragService, FlowGroupController, type FlowGroupJSON, FlowGroupService, FlowLayout, FlowLayoutContribution, FlowLayoutDefault, FlowNodeBaseType, FlowNodeEntity, type FlowNodeEntityConfig, type FlowNodeEntityOrId, type FlowNodeInitData, type FlowNodeJSON, type FlowNodeMeta, FlowNodeRegistry, FlowNodeRenderData, type FlowNodeRenderSchema, FlowNodeSplitType, FlowNodeTransformData, type FlowNodeTransformSchema, FlowNodeTransitionData, type FlowNodeTransitionSchema, type FlowNodeType, type FlowOperation, FlowOperationBaseService, FlowOperationBaseServiceImpl, FlowRendererStateEntity, type FlowTransitionLabel, FlowTransitionLabelEnum, type FlowTransitionLine, FlowTransitionLineEnum, FlowVirtualTree, LABEL_SIDE_TYPE, type MoveBlockOperation, type MoveBlockOperationValue, type MoveChildNodesOperation, type MoveChildNodesOperationValue, type MoveNodeConfig, type MoveNodesOperation, type MoveNodesOperationValue, type OnNodeAddEvent, type OnNodeMoveEvent, OperationType, type UngroupOperation, type Vertex, type createOrUngroupValue, drawLineToBottom, drawLineToNext, getDefaultSpacing };