import { EditorPluginContext, ClipboardService, SelectionService, EditorProps, FlowNodeType, PluginsProvider } from '@flowgram.ai/editor'; export * from '@flowgram.ai/editor'; import { WorkflowOperationBaseService, WorkflowJSON, WorkflowDocument, WorkflowNodeRegistry, LineColor, WorkflowContentChangeEvent, WorkflowPortEntity, WorkflowLinesManager, WorkflowLineEntity, onDragLineEndParams, LineRenderType, WorkflowNodeEntity, WorkflowLinePortInfo, EditorCursorState, InteractiveType } from '@flowgram.ai/free-layout-core'; export * from '@flowgram.ai/free-layout-core'; import React from 'react'; import { SelectBoxPluginOptions } from '@flowgram.ai/select-box-plugin'; import { HistoryService } from '@flowgram.ai/history'; import { FreeHistoryPluginOptions } from '@flowgram.ai/free-history-plugin'; export * from '@flowgram.ai/free-history-plugin'; import { LayoutOptions } from '@flowgram.ai/free-auto-layout-plugin'; export * from '@flowgram.ai/free-stack-plugin'; export { WorkflowPortRender, WorkflowPortRenderProps } from '@flowgram.ai/free-lines-plugin'; /** * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates * SPDX-License-Identifier: MIT */ interface WorkflowOperationService extends WorkflowOperationBaseService { /** * 开始事务 */ startTransaction(): void; /** * 结束事务 */ endTransaction(): void; fromJSON(json: WorkflowJSON): void; } declare const WorkflowOperationService: unique symbol; /** * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates * SPDX-License-Identifier: MIT */ type AutoLayoutResetFn = () => void; type AutoLayoutToolOptions = LayoutOptions; /** * Auto layout tool - 自动布局工具 * https://flowgram.ai/guide/plugin/free-auto-layout-plugin.html */ declare class WorkflowAutoLayoutTool { private document; private autoLayoutService; private historyService; handle(options?: AutoLayoutToolOptions): Promise; private autoLayout; private getNodePosition; private createResetFn; private updateHistory; } /** * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates * SPDX-License-Identifier: MIT */ interface FreeLayoutPluginTools { autoLayout: (options?: AutoLayoutToolOptions) => Promise; fitView: (easing?: boolean) => Promise; } declare const FreeLayoutPluginContext: symbol; interface FreeLayoutPluginContext extends EditorPluginContext { /** * 文档 */ document: WorkflowDocument; clipboard: ClipboardService; selection: SelectionService; /** * 提供对画布节点相关操作方法, 并 支持 redo/undo */ operation: WorkflowOperationService; history: HistoryService; tools: FreeLayoutPluginTools; } /** * Free layout configuration * 自由布局配置 */ interface FreeLayoutProps extends EditorProps { /** * SelectBox config * 选择框定义 */ selectBox?: SelectBoxPluginOptions; /** * Node registries * 节点注册 */ nodeRegistries?: WorkflowNodeRegistry[]; /** * By default, all nodes are expanded * 默认是否展开所有节点 */ allNodesDefaultExpanded?: boolean; cursors?: { grab?: string; grabbing?: string; }; /** * Line support both-way connection (default true) * 线条支持双向连接 */ twoWayConnection?: boolean; /** * Enable dragging of read-only nodes (default false) * 允许拖拽只读节点 */ enableReadonlyNodeDragging?: boolean; /** * History configuration */ history?: FreeHistoryPluginOptions & { disableShortcuts?: boolean; }; /** * Line color configuration * 线条颜色 */ lineColor?: LineColor; /** * Listen for content change * 监听画布内容更新 */ onContentChange?: (ctx: FreeLayoutPluginContext, event: WorkflowContentChangeEvent) => void; /** * Determine whether the line is marked as error * 判断线条是否标红 * @param ctx * @param fromPort * @param toPort * @param lines */ isErrorLine?: (ctx: FreeLayoutPluginContext, fromPort: WorkflowPortEntity, toPort: WorkflowPortEntity | undefined, lines: WorkflowLinesManager) => boolean; /** * Determine whether the port is marked as error * 判断端口是否标红 * @param ctx * @param port */ isErrorPort?: (ctx: FreeLayoutPluginContext, port: WorkflowPortEntity) => boolean; /** * Determine if the port is disabled * 判断端口是否禁用 * @param ctx * @param port */ isDisabledPort?: (ctx: FreeLayoutPluginContext, port: WorkflowPortEntity) => boolean; /** * Determine whether the line arrow is reversed * 判断线条箭头是否反转 * @param ctx * @param line */ isReverseLine?: (ctx: FreeLayoutPluginContext, line: WorkflowLineEntity) => boolean; /** * Determine if the line hides the arrow * 判断线条是否隐藏箭头 * @param ctx * @param line */ isHideArrowLine?: (ctx: FreeLayoutPluginContext, line: WorkflowLineEntity) => boolean; /** * Determine whether the line shows a flow effect * 判断线条是否展示流动效果 * @param ctx * @param line */ isFlowingLine?: (ctx: FreeLayoutPluginContext, line: WorkflowLineEntity) => boolean; /** * Determine if a line is disabled * 判断线条是否禁用 * @param ctx * @param line */ isDisabledLine?: (ctx: FreeLayoutPluginContext, line: WorkflowLineEntity) => boolean; /** * Listen for dragging the line to end * 拖拽线条结束 * @param ctx * @param params */ onDragLineEnd?: (ctx: FreeLayoutPluginContext, params: onDragLineEndParams) => Promise; /** * Set the line renderer type * 设置线条渲染器类型 * @param ctx * @param line */ setLineRenderType?: (ctx: FreeLayoutPluginContext, line: WorkflowLineEntity) => LineRenderType | undefined; /** * Set the line className * 设置线条样式 * @param ctx * @param line */ setLineClassName?: (ctx: FreeLayoutPluginContext, line: WorkflowLineEntity) => string | undefined; /** * Whether to create lines or not * 是否允许创建线条 * @param ctx * @param fromPort - Source port * @param toPort - Target port */ canAddLine?: (ctx: FreeLayoutPluginContext, fromPort: WorkflowPortEntity, toPort: WorkflowPortEntity, lines: WorkflowLinesManager, silent?: boolean) => boolean; /** * Whether to allow the deletion of nodes * 是否允许删除节点 * @param ctx * @param node - 目标节点 * @param silent - 如果为false,可以加 toast 弹窗 */ canDeleteNode?: (ctx: FreeLayoutPluginContext, node: WorkflowNodeEntity, silent?: boolean) => boolean; /** * * Whether to delete lines or not * 是否允许删除线条 * @param ctx * @param line - target line * @param newLineInfo - new line info * @param silent - If false, you can add a toast pop-up */ canDeleteLine?: (ctx: FreeLayoutPluginContext, line: WorkflowLineEntity, newLineInfo?: Required, silent?: boolean) => boolean; /** * Whether to allow lines to be reset * 是否允许重置线条 * @param ctx * @param oldLine - old line * @param newLineInfo - new line info * @param lines - lines manager */ canResetLine?: (ctx: FreeLayoutPluginContext, oldLine: WorkflowLineEntity, newLineInfo: Required, lines: WorkflowLinesManager) => boolean; /** * Whether to allow dragging into the sub-canvas (loop or group) * 是否允许拖入子画布 (loop or group) * @param params */ canDropToNode?: (ctx: FreeLayoutPluginContext, params: { dragNodeType?: FlowNodeType; dragNode?: WorkflowNodeEntity; dropNode?: WorkflowNodeEntity; dropNodeType?: FlowNodeType; }) => boolean; } declare namespace FreeLayoutProps { /** * 默认配置 */ const DEFAULT: FreeLayoutProps; } /** * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates * SPDX-License-Identifier: MIT */ declare function createFreeLayoutPreset(opts: FreeLayoutProps): PluginsProvider; /** * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates * SPDX-License-Identifier: MIT */ declare const FreeLayoutEditorProvider: React.ForwardRefExoticComponent>; /** * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates * SPDX-License-Identifier: MIT */ interface WorkflowNodeProps { node: WorkflowNodeEntity; className?: string; style?: React.CSSProperties; children?: React.ReactNode | null; portClassName?: string; portStyle?: React.CSSProperties; onPortClick?: (port: WorkflowPortEntity, e: React.MouseEvent | React.MouseEventHandler) => void; /** 端口激活状态颜色 (linked/hovered) */ portPrimaryColor?: string; /** 端口默认状态颜色 */ portSecondaryColor?: string; /** 端口错误状态颜色 */ portErrorColor?: string; /** 端口背景颜色 */ portBackgroundColor?: string; } declare const WorkflowNodeRenderer: React.FC; /** * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates * SPDX-License-Identifier: MIT */ /** * 自由布局编辑器 * @param props * @constructor */ declare const FreeLayoutEditor: React.ForwardRefExoticComponent>; /** * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates * SPDX-License-Identifier: MIT */ declare const useAutoLayout: () => (options?: AutoLayoutToolOptions) => Promise; /** * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates * SPDX-License-Identifier: MIT */ declare function useClientContext(): FreeLayoutPluginContext; /** * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates * SPDX-License-Identifier: MIT */ interface SetCursorStateCallbackEvent { isPressingSpaceBar: boolean; cursorState: EditorCursorState; } type SetCursorStateCallback = (e: SetCursorStateCallbackEvent) => EditorCursorState | undefined; interface PlaygroundTools { zoomin: (easing?: boolean) => void; zoomout: (easing?: boolean) => void; fitView: (easing?: boolean) => void; /** * Auto layout tool - 自动布局工具 * https://flowgram.ai/guide/plugin/free-auto-layout-plugin.html */ autoLayout: FreeLayoutPluginTools['autoLayout']; /** * 切换线条 */ switchLineType: (lineType?: LineRenderType) => LineRenderType; lineType: LineRenderType; zoom: number; cursorState: EditorCursorState; setCursorState: (stateId: EditorCursorState | SetCursorStateCallback) => void; /** 交互模式:鼠标 or 触控板 */ interactiveType: InteractiveType; setInteractiveType: (type: InteractiveType) => void; /** 设置鼠标缩放 delta */ setMouseScrollDelta: (mouseScrollDelta: number | ((zoom: number) => number)) => void; } interface PlaygroundToolsPropsType { /** * 最大缩放比,默认 2 */ maxZoom?: number; /** * 最小缩放比,默认 0.25 */ minZoom?: number; } declare function usePlaygroundTools(props?: PlaygroundToolsPropsType): PlaygroundTools; export { type AutoLayoutResetFn, type AutoLayoutToolOptions, FreeLayoutEditor, FreeLayoutEditorProvider, FreeLayoutPluginContext, type FreeLayoutPluginTools, FreeLayoutProps, type PlaygroundTools, WorkflowAutoLayoutTool, type WorkflowNodeProps, WorkflowNodeRenderer, createFreeLayoutPreset, useAutoLayout, useClientContext, usePlaygroundTools };