import * as _flowgram_ai_core from '@flowgram.ai/core'; import { PluginContext, EntityData } from '@flowgram.ai/core'; import { IPoint } from '@flowgram.ai/utils'; import { OperationMeta, Operation, OperationContribution, OperationRegistry } from '@flowgram.ai/history'; export * from '@flowgram.ai/history'; import { WorkflowLinePortInfo, WorkflowNodeJSON, PositionMap, WorkflowContentChangeType, WorkflowContentChangeEvent, WorkflowLineEntity } from '@flowgram.ai/free-layout-core'; import { FlowNodeEntity, FlowNodeJSON } from '@flowgram.ai/document'; /** * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates * SPDX-License-Identifier: MIT */ declare enum FreeOperationType { addLine = "addLine", deleteLine = "deleteLine", changeLineData = "changeLineData", moveNode = "moveNode", addNode = "addNode", deleteNode = "deleteNode", changeNodeData = "changeNodeData", resetLayout = "resetLayout", dragNodes = "dragNodes", moveChildNodes = "moveChildNodes" } interface AddOrDeleteLineOperationValue extends WorkflowLinePortInfo { id: string; } interface AddOrDeleteWorkflowNodeOperationValue { node: WorkflowNodeJSON; parentID?: string; } interface AddLineOperation extends Operation { type: FreeOperationType.addLine; value: AddOrDeleteLineOperationValue; } interface ChangeLineDataOperation extends Operation { type: FreeOperationType.changeLineData; value: ChangeLineDataValue; } interface DeleteLineOperation extends Operation { type: FreeOperationType.deleteLine; value: AddOrDeleteLineOperationValue; } interface MoveNodeOperation extends Operation { type: FreeOperationType.moveNode; value: MoveNodeOperationValue; } interface AddWorkflowNodeOperation extends Operation { type: FreeOperationType.addNode; value: AddOrDeleteWorkflowNodeOperationValue; } interface DeleteWorkflowNodeOperation extends Operation { type: FreeOperationType.deleteNode; value: AddOrDeleteWorkflowNodeOperationValue; } interface MoveNodeOperationValue { id: string; value: { x: number; y: number; }; oldValue: { x: number; y: number; }; } interface DragNodeOperationValue { ids: string[]; value: IPoint[]; oldValue: IPoint[]; } interface ResetLayoutOperationValue { ids: string[]; value: PositionMap; oldValue: PositionMap; } interface ContentChangeTypeToOperation { type: WorkflowContentChangeType; toOperation: (event: WorkflowContentChangeEvent, ctx: PluginContext) => T | undefined; } interface EntityDataType { type: FreeOperationType; toEntityData: (node: FlowNodeEntity, ctx: PluginContext) => EntityData; } interface ChangeNodeDataValue { id: string; value: unknown; oldValue: unknown; path: string; } interface ChangeLineDataValue { id: string; oldValue: unknown; newValue: unknown; } interface ChangeLineDataValue { id: string; newValue: unknown; oldValue: unknown; } /** * 将node转成json */ type NodeToJson = (node: FlowNodeEntity) => FlowNodeJSON; /** * 将line转成json */ type LineToJson = (node: WorkflowLineEntity) => FlowNodeJSON; /** * 根据节点id获取label */ type GetNodeLabelById = (id: string) => string; /** * 根据节点获取label */ type GetNodeLabel = (node: FlowNodeJSON) => string; /** * 根据分支获取label */ type GetBlockLabel = (node: FlowNodeJSON) => string; /** * 根据节点获取URI */ type GetNodeURI = (id: string) => string | any; /** * 根据连线获取URI */ type GetLineURI = (id: string) => string | any; /** * 插件配置 */ interface FreeHistoryPluginOptions { enable?: boolean; limit?: number; nodeToJSON?: (ctx: CTX) => NodeToJson; getNodeLabelById?: (ctx: CTX) => GetNodeLabelById; getNodeLabel?: (ctx: CTX) => GetNodeLabel; getBlockLabel?: (ctx: CTX) => GetBlockLabel; getNodeURI?: (ctx: CTX) => GetNodeURI; getLineURI?: (ctx: CTX) => GetLineURI; operationMetas?: OperationMeta[]; enableChangeNode?: boolean; enableChangeLineData?: boolean; uri?: string | any; } interface IHandler { handle: (event: E, ctx: PluginContext) => void | Promise; } declare const createFreeHistoryPlugin: _flowgram_ai_core.PluginCreator>; /** * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates * SPDX-License-Identifier: MIT */ declare class FreeHistoryConfig { init(ctx: PluginContext, options: FreeHistoryPluginOptions): void; enableChangeNode: boolean; enableChangeLineData: boolean; enable: boolean; nodeToJSON: NodeToJson; getNodeLabelById: GetNodeLabelById; getNodeLabel: GetNodeLabel; getBlockLabel: GetBlockLabel; getNodeURI: GetNodeURI; getLineURI: GetLineURI; } /** * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates * SPDX-License-Identifier: MIT */ interface UndoRedo { canUndo: boolean; canRedo: boolean; undo: () => Promise; redo: () => Promise; } declare function useUndoRedo(): UndoRedo; /** * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates * SPDX-License-Identifier: MIT */ declare class FreeHistoryRegisters implements OperationContribution { registerOperationMeta(operationRegistry: OperationRegistry): void; } export { type AddLineOperation, type AddOrDeleteLineOperationValue, type AddOrDeleteWorkflowNodeOperationValue, type AddWorkflowNodeOperation, type ChangeLineDataOperation, type ChangeLineDataValue, type ChangeNodeDataValue, type ContentChangeTypeToOperation, type DeleteLineOperation, type DeleteWorkflowNodeOperation, type DragNodeOperationValue, type EntityDataType, FreeHistoryConfig, type FreeHistoryPluginOptions, FreeHistoryRegisters, FreeOperationType, type GetBlockLabel, type GetLineURI, type GetNodeLabel, type GetNodeLabelById, type GetNodeURI, type IHandler, type LineToJson, type MoveNodeOperation, type MoveNodeOperationValue, type NodeToJson, type ResetLayoutOperationValue, createFreeHistoryPlugin, useUndoRedo };