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

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
@@ -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,14 @@ 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;
178
+ ROUNDED_LINE_RADIUS: string;
160
179
  ROUNDED_LINE_X_RADIUS: string;
161
180
  ROUNDED_LINE_Y_RADIUS: string;
162
181
  INLINE_BLOCKS_PADDING_BOTTOM: string;
@@ -164,6 +183,11 @@ declare const ConstantKeys: {
164
183
  HOVER_AREA_WIDTH: string;
165
184
  };
166
185
 
186
+ /**
187
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
188
+ * SPDX-License-Identifier: MIT
189
+ */
190
+
167
191
  declare const FlowDocumentContribution: unique symbol;
168
192
  interface FlowDocumentContribution<T extends FlowDocument = FlowDocument> {
169
193
  /**
@@ -178,6 +202,10 @@ interface FlowDocumentContribution<T extends FlowDocument = FlowDocument> {
178
202
  loadDocument?(document: T): Promise<void>;
179
203
  }
180
204
 
205
+ /**
206
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
207
+ * SPDX-License-Identifier: MIT
208
+ */
181
209
  declare const FlowDocumentConfigDefaultData: unique symbol;
182
210
  /**
183
211
  * 用于文档扩展配置
@@ -212,11 +240,21 @@ declare class FlowDocument<T = FlowDocumentJSON> implements Disposable {
212
240
  protected currentLayoutKey: string;
213
241
  protected onNodeUpdateEmitter: Emitter<{
214
242
  node: FlowNodeEntity;
243
+ /**
244
+ * use 'json' instead
245
+ * @deprecated
246
+ */
215
247
  data: FlowNodeJSON;
248
+ json: FlowNodeJSON;
216
249
  }>;
217
250
  protected onNodeCreateEmitter: Emitter<{
218
251
  node: FlowNodeEntity;
252
+ /**
253
+ * use 'json' instead
254
+ * @deprecated
255
+ */
219
256
  data: FlowNodeJSON;
257
+ json: FlowNodeJSON;
220
258
  }>;
221
259
  protected onNodeDisposeEmitter: Emitter<{
222
260
  node: FlowNodeEntity;
@@ -224,16 +262,27 @@ declare class FlowDocument<T = FlowDocumentJSON> implements Disposable {
224
262
  protected onLayoutChangeEmitter: Emitter<FlowLayout>;
225
263
  readonly onNodeUpdate: _flowgram_ai_utils.Event<{
226
264
  node: FlowNodeEntity;
265
+ /**
266
+ * use 'json' instead
267
+ * @deprecated
268
+ */
227
269
  data: FlowNodeJSON;
270
+ json: FlowNodeJSON;
228
271
  }>;
229
272
  readonly onNodeCreate: _flowgram_ai_utils.Event<{
230
273
  node: FlowNodeEntity;
274
+ /**
275
+ * use 'json' instead
276
+ * @deprecated
277
+ */
231
278
  data: FlowNodeJSON;
279
+ json: FlowNodeJSON;
232
280
  }>;
233
281
  readonly onNodeDispose: _flowgram_ai_utils.Event<{
234
282
  node: FlowNodeEntity;
235
283
  }>;
236
284
  readonly onLayoutChange: _flowgram_ai_utils.Event<FlowLayout>;
285
+ private _disposed;
237
286
  root: FlowNodeEntity;
238
287
  /**
239
288
  * 原始的 tree 结构
@@ -248,6 +297,10 @@ declare class FlowDocument<T = FlowDocumentJSON> implements Disposable {
248
297
  * 渲染后的 tree 结构
249
298
  */
250
299
  renderTree: FlowRenderTree<FlowNodeEntity>;
300
+ /**
301
+ *
302
+ */
303
+ get disposed(): boolean;
251
304
  init(): void;
252
305
  /**
253
306
  * 从数据初始化 O(n)
@@ -278,7 +331,7 @@ declare class FlowDocument<T = FlowDocumentJSON> implements Disposable {
278
331
  * @param data
279
332
  * @param addedNodes
280
333
  */
281
- addNode(data: AddNodeData, addedNodes?: FlowNodeEntity[], ignoreCreateEvent?: boolean): FlowNodeEntity;
334
+ addNode(data: AddNodeData, addedNodes?: FlowNodeEntity[]): FlowNodeEntity;
282
335
  addBlocksAsChildren(parent: FlowNodeEntity, blocks: FlowNodeJSON[], addedNodes?: FlowNodeEntity[]): void;
283
336
  /**
284
337
  * block 格式:
@@ -312,6 +365,18 @@ declare class FlowDocument<T = FlowDocumentJSON> implements Disposable {
312
365
  * @param registries
313
366
  */
314
367
  registerFlowNodes<T extends FlowNodeRegistry<any>>(...registries: T[]): void;
368
+ /**
369
+ * Check node extend
370
+ * @param currentType
371
+ * @param extendType
372
+ */
373
+ isExtend(currentType: FlowNodeType, extendType: FlowNodeType): boolean;
374
+ /**
375
+ * Check node type
376
+ * @param currentType
377
+ * @param extendType
378
+ */
379
+ isTypeOrExtendType(currentType: FlowNodeType, extendType: FlowNodeType): boolean;
315
380
  /**
316
381
  * 导出数据,可以重载
317
382
  */
@@ -359,11 +424,12 @@ declare class FlowDocument<T = FlowDocumentJSON> implements Disposable {
359
424
  get size(): number;
360
425
  hasNode(nodeId: string): boolean;
361
426
  getAllNodes(): FlowNodeEntity[];
362
- toString(): string;
427
+ toString(showType?: boolean): string;
363
428
  /**
364
429
  * 返回需要渲染的数据
365
430
  */
366
431
  getRenderDatas<T extends EntityData>(dataRegistry: EntityDataRegistry<T>, containHiddenNodes?: boolean): T[];
432
+ toNodeJSON(node: FlowNodeEntity): FlowNodeJSON;
367
433
  /**
368
434
  * 移动节点
369
435
  * @param param0
@@ -409,6 +475,7 @@ interface FlowNodeRenderSchema {
409
475
  activated: boolean;
410
476
  hovered: boolean;
411
477
  dragging: boolean;
478
+ stackIndex: number;
412
479
  extInfo?: Record<string, any>;
413
480
  }
414
481
  /**
@@ -428,7 +495,7 @@ declare class FlowNodeRenderData extends EntityData<FlowNodeRenderSchema> {
428
495
  }>;
429
496
  get key(): string;
430
497
  getDefaultData(): FlowNodeRenderSchema;
431
- updateExtInfo(info: Record<string, any>): void;
498
+ updateExtInfo(info: Record<string, any>, fullUpdate?: boolean): void;
432
499
  getExtInfo(): Record<string, any> | undefined;
433
500
  constructor(entity: FlowNodeEntity);
434
501
  get addable(): boolean;
@@ -447,6 +514,8 @@ declare class FlowNodeRenderData extends EntityData<FlowNodeRenderSchema> {
447
514
  set dragging(dragging: boolean);
448
515
  set activated(activated: boolean);
449
516
  get activated(): boolean;
517
+ get stackIndex(): number;
518
+ set stackIndex(index: number);
450
519
  get lineActivated(): boolean;
451
520
  get node(): HTMLDivElement;
452
521
  dispose(): void;
@@ -475,6 +544,7 @@ declare class FlowNodeTransformData extends EntityData<FlowNodeTransformSchema>
475
544
  */
476
545
  get size(): SizeSchema;
477
546
  get position(): PositionSchema;
547
+ set position(position: PositionSchema);
478
548
  set size(size: SizeSchema);
479
549
  get inputPoint(): IPoint;
480
550
  get defaultInputPoint(): IPoint;
@@ -551,6 +621,11 @@ declare class FlowNodeTransitionData extends EntityData<FlowNodeTransitionSchema
551
621
  get isNodeEnd(): boolean;
552
622
  }
553
623
 
624
+ /**
625
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
626
+ * SPDX-License-Identifier: MIT
627
+ */
628
+
554
629
  interface FlowNodeEntityConfig extends EntityOpts {
555
630
  document: FlowDocument;
556
631
  flowNodeType: FlowNodeType;
@@ -617,7 +692,9 @@ declare class FlowNodeEntity extends Entity<FlowNodeEntityConfig> {
617
692
  get pre(): FlowNodeEntity | undefined;
618
693
  get next(): FlowNodeEntity | undefined;
619
694
  get parent(): FlowNodeEntity | undefined;
620
- getNodeRegistry<M extends FlowNodeRegistry = FlowNodeRegistry>(): M;
695
+ getNodeRegistry<M extends FlowNodeRegistry = FlowNodeRegistry & {
696
+ meta: FlowNodeMeta;
697
+ }>(): M;
621
698
  /**
622
699
  * @deprecated
623
700
  * use getNodeRegistry instead
@@ -681,7 +758,7 @@ declare class FlowNodeEntity extends Entity<FlowNodeEntityConfig> {
681
758
  * 修改节点扩展信息
682
759
  * @param info
683
760
  */
684
- updateExtInfo<T extends Record<string, any> = Record<string, any>>(extInfo: T): void;
761
+ updateExtInfo<T extends Record<string, any> = Record<string, any>>(extInfo: T, fullUpdate?: boolean): void;
685
762
  /**
686
763
  * 获取节点扩展信息
687
764
  */
@@ -702,6 +779,15 @@ declare class FlowNodeEntity extends Entity<FlowNodeEntityConfig> {
702
779
  * 获取节点的位置及大小矩形
703
780
  */
704
781
  get bounds(): Rectangle;
782
+ /**
783
+ * Check node extend type
784
+ */
785
+ isExtend(parentType: FlowNodeType): boolean;
786
+ /**
787
+ * Check node type
788
+ * @param parentType
789
+ */
790
+ isTypeOrExtendType(parentType: FlowNodeType): boolean;
705
791
  }
706
792
  declare namespace FlowNodeEntity {
707
793
  function is(obj: Entity): obj is FlowNodeEntity;
@@ -742,6 +828,11 @@ declare class FlowDocumentTransformerEntity extends ConfigEntity<{
742
828
  refresh(): void;
743
829
  }
744
830
 
831
+ /**
832
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
833
+ * SPDX-License-Identifier: MIT
834
+ */
835
+
745
836
  interface FlowRendererStateEntityConfig extends EntityOpts {
746
837
  }
747
838
  interface FlowRendererState {
@@ -751,6 +842,8 @@ interface FlowRendererState {
751
842
  nodeDragIds?: string[];
752
843
  nodeDragIdsWithChildren?: string[];
753
844
  dragLabelSide?: LABEL_SIDE_TYPE;
845
+ dragging?: boolean;
846
+ isBranch?: boolean;
754
847
  }
755
848
  /**
756
849
  * 渲染相关的全局状态管理
@@ -761,6 +854,10 @@ declare class FlowRendererStateEntity extends ConfigEntity<FlowRendererState, Fl
761
854
  constructor(conf: FlowRendererStateEntityConfig);
762
855
  getNodeHovered(): FlowNodeEntity | undefined;
763
856
  setNodeHovered(node: FlowNodeEntity | undefined): void;
857
+ get dragging(): boolean | undefined;
858
+ setDragging(dragging: boolean): void;
859
+ get isBranch(): boolean | undefined;
860
+ setIsBranch(isBranch: boolean): void;
764
861
  getDragLabelSide(): LABEL_SIDE_TYPE | undefined;
765
862
  setDragLabelSide(dragLabelSide?: LABEL_SIDE_TYPE): void;
766
863
  getNodeDroppingId(): string | undefined;
@@ -772,12 +869,17 @@ declare class FlowRendererStateEntity extends ConfigEntity<FlowRendererState, Fl
772
869
  onNodeHoveredChange(fn: (hoveredNode: FlowNodeEntity | undefined) => void, debounceTime?: number): Disposable;
773
870
  }
774
871
 
872
+ /**
873
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
874
+ * SPDX-License-Identifier: MIT
875
+ */
876
+
775
877
  declare enum FlowTransitionLineEnum {
776
- STRAIGHT_LINE = 0,
777
- DIVERGE_LINE = 1,
778
- MERGE_LINE = 2,
779
- ROUNDED_LINE = 3,
780
- CUSTOM_LINE = 4,
878
+ STRAIGHT_LINE = 0,// 直线
879
+ DIVERGE_LINE = 1,// 分支线 (一种 ROUNDED_LINE)
880
+ MERGE_LINE = 2,// 汇聚线 (一种 ROUNDED_LINE)
881
+ ROUNDED_LINE = 3,// 自定义圆角转弯线
882
+ CUSTOM_LINE = 4,// 自定义,用于处理循环节点等自定义线条
781
883
  DRAGGING_LINE = 5
782
884
  }
783
885
  interface Vertex extends IPoint {
@@ -785,6 +887,10 @@ interface Vertex extends IPoint {
785
887
  radiusY?: number;
786
888
  moveX?: number;
787
889
  moveY?: number;
890
+ /**
891
+ * Strategy for handling arc curvature when space is insufficient, defaults to compress
892
+ */
893
+ radiusOverflow?: 'compress' | 'truncate';
788
894
  }
789
895
  interface FlowTransitionLine {
790
896
  type: FlowTransitionLineEnum;
@@ -794,16 +900,18 @@ interface FlowTransitionLine {
794
900
  arrow?: boolean;
795
901
  renderKey?: string;
796
902
  isHorizontal?: boolean;
903
+ isDraggingLine?: boolean;
797
904
  activated?: boolean;
798
905
  side?: LABEL_SIDE_TYPE;
799
906
  style?: React.CSSProperties;
907
+ lineId?: string;
800
908
  }
801
909
  declare enum FlowTransitionLabelEnum {
802
- ADDER_LABEL = 0,
803
- TEXT_LABEL = 1,
804
- COLLAPSE_LABEL = 2,
805
- COLLAPSE_ADDER_LABEL = 3,
806
- CUSTOM_LABEL = 4,
910
+ ADDER_LABEL = 0,// 添加按钮
911
+ TEXT_LABEL = 1,// 文本标签
912
+ COLLAPSE_LABEL = 2,// 复合节点收起的展开标签
913
+ COLLAPSE_ADDER_LABEL = 3,// 复合节点收起 + 加号复合标签
914
+ CUSTOM_LABEL = 4,// 自定义,用于处理循环节点等自定义标签
807
915
  BRANCH_DRAGGING_LABEL = 5
808
916
  }
809
917
  interface FlowTransitionLabel {
@@ -812,7 +920,16 @@ interface FlowTransitionLabel {
812
920
  offset: IPoint;
813
921
  width?: number;
814
922
  rotate?: string;
923
+ /**
924
+ * Anchor point for positioning, relative to the label's bounding box
925
+ * 重心偏移量,相对于标签边界框
926
+ *
927
+ * Format: [x, y] / 格式:[x, y]
928
+ * Default Value: [0.5, 0.5] indicates center / 默认值:[0.5, 0.5] 表示居中
929
+ */
930
+ origin?: [number, number];
815
931
  props?: Record<string, any>;
932
+ labelId?: string;
816
933
  }
817
934
  interface AdderProps {
818
935
  node: FlowNodeEntity;
@@ -839,8 +956,13 @@ interface DragNodeProps {
839
956
  node: FlowNodeEntity;
840
957
  }
841
958
 
959
+ /**
960
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
961
+ * SPDX-License-Identifier: MIT
962
+ */
963
+
842
964
  declare enum FlowLayoutDefault {
843
- VERTICAL_FIXED_LAYOUT = "vertical-fixed-layout",
965
+ VERTICAL_FIXED_LAYOUT = "vertical-fixed-layout",// 垂直固定布局
844
966
  HORIZONTAL_FIXED_LAYOUT = "horizontal-fixed-layout"
845
967
  }
846
968
  declare namespace FlowLayoutDefault {
@@ -891,6 +1013,11 @@ interface FlowLayout {
891
1013
  getDefaultNodeOrigin(): IPoint;
892
1014
  }
893
1015
 
1016
+ /**
1017
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1018
+ * SPDX-License-Identifier: MIT
1019
+ */
1020
+
894
1021
  /**
895
1022
  * 节点渲染相关配置信息,可扩展
896
1023
  */
@@ -905,13 +1032,13 @@ interface FlowNodeMeta {
905
1032
  addDisable?: boolean;
906
1033
  hidden?: boolean;
907
1034
  size?: SizeSchema;
1035
+ autoResizeDisable?: boolean;
908
1036
  /**
909
1037
  * @deprecated 使用 NodeRegister.getOrigin 代替
910
1038
  */
911
1039
  origin?: OriginSchema;
912
1040
  defaultExpanded?: boolean;
913
1041
  defaultCollapsed?: boolean;
914
- expandedSize?: SizeSchema;
915
1042
  spacing?: number | ((transform: FlowNodeTransformData) => number);
916
1043
  padding?: PaddingSchema | ((transform: FlowNodeTransformData) => PaddingSchema);
917
1044
  inlineSpacingPre?: number | ((transform: FlowNodeTransformData) => number);
@@ -930,6 +1057,14 @@ declare const DefaultSpacingKey: {
930
1057
  * 普通节点间距。垂直 / 水平
931
1058
  */
932
1059
  NODE_SPACING: string;
1060
+ /**
1061
+ * 分支节点间距
1062
+ */
1063
+ BRANCH_SPACING: string;
1064
+ /**
1065
+ * 圆弧线条拐角 radius
1066
+ */
1067
+ ROUNDED_LINE_RADIUS: string;
933
1068
  /**
934
1069
  * 圆弧线条 x radius
935
1070
  */
@@ -956,8 +1091,18 @@ declare const DefaultSpacingKey: {
956
1091
  * 默认一些间隔参数
957
1092
  */
958
1093
  declare const DEFAULT_SPACING: {
959
- [x: string]: number;
1094
+ [DefaultSpacingKey.NODE_SPACING]: number;
1095
+ [DefaultSpacingKey.BRANCH_SPACING]: number;
1096
+ [DefaultSpacingKey.INLINE_BLOCKS_PADDING_BOTTOM]: number;
1097
+ [DefaultSpacingKey.COLLAPSED_SPACING]: number;
1098
+ [DefaultSpacingKey.ROUNDED_LINE_RADIUS]: number;
1099
+ [DefaultSpacingKey.ROUNDED_LINE_X_RADIUS]: number;
1100
+ [DefaultSpacingKey.ROUNDED_LINE_Y_RADIUS]: number;
1101
+ [DefaultSpacingKey.HOVER_AREA_WIDTH]: number;
960
1102
  NULL: number;
1103
+ /**
1104
+ * @deprecated use 'BRANCH_SPACING' instead
1105
+ */
961
1106
  MARGIN_RIGHT: number;
962
1107
  INLINE_BLOCK_PADDING_BOTTOM: number;
963
1108
  INLINE_BLOCKS_PADDING_TOP: number;
@@ -1082,6 +1227,7 @@ interface FlowNodeRegistry<M extends FlowNodeMeta = FlowNodeMeta> {
1082
1227
  */
1083
1228
  extendChildRegistries?: FlowNodeRegistry[];
1084
1229
  /**
1230
+ * @deprecated
1085
1231
  * 自定义子节点添加逻辑
1086
1232
  * @param node 节点
1087
1233
  * @param json 添加的节点 JSON
@@ -1092,23 +1238,33 @@ interface FlowNodeRegistry<M extends FlowNodeMeta = FlowNodeMeta> {
1092
1238
  hidden?: boolean;
1093
1239
  index?: number;
1094
1240
  }) => FlowNodeEntity;
1241
+ /**
1242
+ * 内部用于继承逻辑判断,不要使用
1243
+ */
1244
+ __extends__?: FlowNodeType[];
1095
1245
  /**
1096
1246
  * 扩展注册器
1097
1247
  */
1098
1248
  [key: string]: any;
1099
1249
  }
1100
1250
  declare namespace FlowNodeRegistry {
1251
+ function mergeChildRegistries(r1?: FlowNodeRegistry[], r2?: FlowNodeRegistry[]): FlowNodeRegistry[];
1101
1252
  function merge(registry1: FlowNodeRegistry, registry2: FlowNodeRegistry, finalType: FlowNodeType): FlowNodeRegistry;
1102
1253
  function extend(registry: FlowNodeRegistry, extendRegistries: FlowNodeRegistry[]): FlowNodeRegistry;
1103
1254
  }
1104
1255
 
1256
+ /**
1257
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1258
+ * SPDX-License-Identifier: MIT
1259
+ */
1260
+
1105
1261
  type FlowNodeType = string | number;
1106
1262
  /**
1107
1263
  * Flow node json data
1108
1264
  */
1109
1265
  interface FlowNodeJSON {
1110
1266
  id: string;
1111
- type?: FlowNodeType;
1267
+ type?: FlowNodeBaseType | FlowNodeSplitType | FlowNodeType;
1112
1268
  data?: Record<string, any>;
1113
1269
  meta?: FlowNodeMeta;
1114
1270
  blocks?: FlowNodeJSON[];
@@ -1117,21 +1273,29 @@ type FlowDocumentJSON = {
1117
1273
  nodes: FlowNodeJSON[];
1118
1274
  };
1119
1275
  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"
1276
+ START = "start",// 开始节点
1277
+ DEFAULT = "default",// 默认节点类型
1278
+ ROOT = "root",// 根节点
1279
+ EMPTY = "empty",// 空节点,宽和高为 0
1280
+ INLINE_BLOCKS = "inlineBlocks",// 所有块合并为 InlineBlocks
1281
+ BLOCK_ICON = "blockIcon",// 图标节点,如条件分支的头部的 菱形图标
1282
+ BLOCK = "block",// 块节点
1283
+ BLOCK_ORDER_ICON = "blockOrderIcon",// 带顺序的图标节点,一般为 block 第一个分支节点
1284
+ GROUP = "group",// 分组节点
1285
+ END = "end",// 结束节点
1286
+ BREAK = "break",// 分支结束
1287
+ CONDITION = "condition",// 可以连接多条线的条件判断节点,目前只支持横向布局
1288
+ SUB_CANVAS = "subCanvas",// 自由布局子画布
1289
+ MULTI_INPUTS = "multiInputs",// 多输入
1290
+ MULTI_OUTPUTS = "multiOutputs",// 多输出
1291
+ INPUT = "input",// 输入节点
1292
+ OUTPUT = "output",// 输出节点
1293
+ SLOT = "slot",// 插槽节点
1294
+ SLOT_BLOCK = "slotBlock"
1132
1295
  }
1133
1296
  declare enum FlowNodeSplitType {
1134
- DYNAMIC_SPLIT = "dynamicSplit",
1297
+ SIMPLE_SPLIT = "simpleSplit",// 无 BlockOrderIcon
1298
+ DYNAMIC_SPLIT = "dynamicSplit",// 动态分支
1135
1299
  STATIC_SPLIT = "staticSplit"
1136
1300
  }
1137
1301
  declare enum FlowDocumentConfigEnum {
@@ -1145,6 +1309,11 @@ type AddNodeData = FlowNodeJSON & {
1145
1309
  index?: number;
1146
1310
  };
1147
1311
 
1312
+ /**
1313
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1314
+ * SPDX-License-Identifier: MIT
1315
+ */
1316
+
1148
1317
  declare enum OperationType {
1149
1318
  addFromNode = "addFromNode",
1150
1319
  deleteFromNode = "deleteFromNode",
@@ -1157,7 +1326,6 @@ declare enum OperationType {
1157
1326
  moveChildNodes = "moveChildNodes",
1158
1327
  addNodes = "addNodes",
1159
1328
  deleteNodes = "deleteNodes",
1160
- changeNode = "changeNode",
1161
1329
  addChildNode = "addChildNode",
1162
1330
  deleteChildNode = "deleteChildNode",
1163
1331
  addNode = "addNode",
@@ -1227,16 +1395,6 @@ interface DeleteNodesOperation {
1227
1395
  type: OperationType.deleteNodes;
1228
1396
  value: AddOrDeleteNodesOperationValue;
1229
1397
  }
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
1398
  interface MoveChildNodesOperationValue {
1241
1399
  nodeIds: string[];
1242
1400
  fromParentId: string;
@@ -1288,7 +1446,7 @@ interface AddOrDeleteNodeValue {
1288
1446
  index?: number;
1289
1447
  hidden?: boolean;
1290
1448
  }
1291
- type FlowOperation = AddFromNodeOperation | DeleteFromNodeOperation | AddBlockOperation | DeleteBlockOperation | CreateGroupOperation | UngroupOperation | MoveNodesOperation | AddNodesOperation | DeleteNodesOperation | ChangeNodeOperation | MoveBlockOperation | AddChildNodeOperation | DeleteChildNodeOperation | MoveChildNodesOperation | AddNodeOperation | DeleteNodeOperation;
1449
+ type FlowOperation = AddFromNodeOperation | DeleteFromNodeOperation | AddBlockOperation | DeleteBlockOperation | CreateGroupOperation | UngroupOperation | MoveNodesOperation | AddNodesOperation | DeleteNodesOperation | MoveBlockOperation | AddChildNodeOperation | DeleteChildNodeOperation | MoveChildNodesOperation | AddNodeOperation | DeleteNodeOperation;
1292
1450
  type FlowNodeEntityOrId = string | FlowNodeEntity;
1293
1451
  type AddNodeConfig = {
1294
1452
  parent?: FlowNodeEntityOrId;
@@ -1316,6 +1474,16 @@ interface OnNodeAddEvent {
1316
1474
  node: FlowNodeEntity;
1317
1475
  data: AddNodeData;
1318
1476
  }
1477
+ /**
1478
+ * 节点移动事件
1479
+ */
1480
+ interface OnNodeMoveEvent {
1481
+ node: FlowNodeEntity;
1482
+ fromParent: FlowNodeEntity;
1483
+ fromIndex: number;
1484
+ toParent: FlowNodeEntity;
1485
+ toIndex: number;
1486
+ }
1319
1487
  interface FlowOperationBaseService extends Disposable {
1320
1488
  /**
1321
1489
  * 执行操作
@@ -1374,13 +1542,26 @@ interface FlowOperationBaseService extends Disposable {
1374
1542
  * 添加节点的回调
1375
1543
  */
1376
1544
  onNodeAdd: Event<OnNodeAddEvent>;
1545
+ /**
1546
+ * 节点移动的回调
1547
+ */
1548
+ onNodeMove: Event<OnNodeMoveEvent>;
1377
1549
  }
1378
1550
  declare const FlowOperationBaseService: unique symbol;
1379
1551
 
1552
+ /**
1553
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1554
+ * SPDX-License-Identifier: MIT
1555
+ */
1380
1556
  interface FlowGroupJSON {
1381
1557
  nodeIDs: string[];
1382
1558
  }
1383
1559
 
1560
+ /**
1561
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1562
+ * SPDX-License-Identifier: MIT
1563
+ */
1564
+
1384
1565
  declare const FlowDocumentContainerModule: ContainerModule;
1385
1566
 
1386
1567
  /**
@@ -1394,10 +1575,12 @@ declare class FlowDragService {
1394
1575
  protected onDropEmitter: Emitter<{
1395
1576
  dropNode: FlowNodeEntity;
1396
1577
  dragNodes: FlowNodeEntity[];
1578
+ dragJSON?: FlowNodeJSON;
1397
1579
  }>;
1398
1580
  readonly onDrop: _flowgram_ai_utils.Event<{
1399
1581
  dropNode: FlowNodeEntity;
1400
1582
  dragNodes: FlowNodeEntity[];
1583
+ dragJSON?: FlowNodeJSON;
1401
1584
  }>;
1402
1585
  get renderState(): FlowRendererStateEntity;
1403
1586
  get dragStartNode(): FlowNodeEntity;
@@ -1411,6 +1594,11 @@ declare class FlowDragService {
1411
1594
  * 放置到目标分支
1412
1595
  */
1413
1596
  dropBranch(): void;
1597
+ /**
1598
+ * 移动并且创建节点
1599
+ * Move and create node
1600
+ */
1601
+ dropCreateNode(json: FlowNodeJSON, onCreateNode?: (json: FlowNodeJSON, dropEntity: FlowNodeEntity) => Promise<FlowNodeEntity>): Promise<void>;
1414
1602
  /**
1415
1603
  * 移动到目标节点
1416
1604
  */
@@ -1436,6 +1624,8 @@ declare class FlowOperationBaseServiceImpl implements FlowOperationBaseService {
1436
1624
  protected onNodeAddEmitter: Emitter<OnNodeAddEvent>;
1437
1625
  readonly onNodeAdd: _flowgram_ai_utils.Event<OnNodeAddEvent>;
1438
1626
  protected toDispose: DisposableCollection;
1627
+ private onNodeMoveEmitter;
1628
+ readonly onNodeMove: _flowgram_ai_utils.Event<OnNodeMoveEvent>;
1439
1629
  protected init(): void;
1440
1630
  addNode(nodeJSON: FlowNodeJSON, config?: AddNodeConfig): FlowNodeEntity;
1441
1631
  addFromNode(fromNode: FlowNodeEntityOrId, nodeJSON: FlowNodeJSON): FlowNodeEntity;
@@ -1470,21 +1660,11 @@ declare class FlowOperationBaseServiceImpl implements FlowOperationBaseService {
1470
1660
  protected doMoveNode(node: FlowNodeEntity, newParent: FlowNodeEntity, index: number): void;
1471
1661
  }
1472
1662
 
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
- }
1663
+ /**
1664
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1665
+ * SPDX-License-Identifier: MIT
1666
+ */
1667
+
1488
1668
  /** 分组控制器 */
1489
1669
  declare class FlowGroupController {
1490
1670
  readonly groupNode: FlowNodeEntity;
@@ -1508,20 +1688,34 @@ declare class FlowGroupController {
1508
1688
  set hovered(hovered: boolean);
1509
1689
  get hovered(): boolean;
1510
1690
  static create(groupNode?: FlowNodeEntity): FlowGroupController | undefined;
1511
- /** 判断节点能否组成分组 */
1691
+ }
1692
+
1693
+ /**
1694
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1695
+ * SPDX-License-Identifier: MIT
1696
+ */
1697
+
1698
+ declare class FlowGroupService {
1699
+ readonly entityManager: EntityManager;
1700
+ readonly operationService: FlowOperationBaseService;
1701
+ /** 创建分组节点 */
1702
+ createGroup(nodes: FlowNodeEntity[]): FlowNodeEntity | undefined;
1703
+ /** 删除分组 */
1704
+ deleteGroup(groupNode: FlowNodeEntity): void;
1705
+ /** 取消分组 */
1706
+ ungroup(groupNode: FlowNodeEntity): void;
1707
+ /** 返回所有分组节点 */
1708
+ getAllGroups(): FlowGroupController[];
1709
+ /** 获取分组控制器*/
1710
+ groupController(group: FlowNodeEntity): FlowGroupController | undefined;
1512
1711
  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
1712
  }
1524
1713
 
1714
+ /**
1715
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1716
+ * SPDX-License-Identifier: MIT
1717
+ */
1718
+
1525
1719
  /**
1526
1720
  *
1527
1721
  * @param node 节点 entity
@@ -1531,4 +1725,4 @@ declare class FlowGroupController {
1531
1725
  */
1532
1726
  declare const getDefaultSpacing: (node: FlowNodeEntity, key: string, defaultSpacing?: number) => any;
1533
1727
 
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 };
1728
+ 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 };