import * as _flowgram_ai_core from '@flowgram.ai/core'; import { PluginContext } from '@flowgram.ai/core'; import { HistoryPluginOptions, OperationMeta, HistoryService, OperationRegistry, Operation } from '@flowgram.ai/history'; export * from '@flowgram.ai/history'; import { FlowNodeEntity, FlowNodeJSON, FlowOperationBaseServiceImpl, FlowOperation, FlowDocument } from '@flowgram.ai/document'; import * as _flowgram_ai_form_core from '@flowgram.ai/form-core'; import { FlowNodeFormData } from '@flowgram.ai/form-core'; import * as _flowgram_ai_utils from '@flowgram.ai/utils'; import { Disposable } from '@flowgram.ai/utils'; /** * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates * SPDX-License-Identifier: MIT */ interface IHistoryDocument { addFromNode(fromNode: FlowNodeEntity | string, json: FlowNodeJSON): FlowNodeEntity; addBlock(target: FlowNodeEntity | string, blockData: FlowNodeJSON, parent?: FlowNodeEntity, index?: number): FlowNodeEntity; deleteNode(fromNode: FlowNodeEntity): void; } /** * 将node转成json */ type NodeToJson = (node: FlowNodeEntity) => 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; /** * 获取文档JSON */ type GetDocumentJSON = () => unknown; /** * 插件配置 */ interface FixedHistoryPluginOptions extends HistoryPluginOptions { nodeToJSON?: (ctx: CTX) => NodeToJson; getDocumentJSON?: (ctx: CTX) => GetDocumentJSON; getNodeLabelById?: (ctx: CTX) => GetNodeLabelById; getNodeLabel?: (ctx: CTX) => GetNodeLabel; getBlockLabel?: (ctx: CTX) => GetBlockLabel; getNodeURI?: (ctx: CTX) => GetNodeURI; operationMetas?: OperationMeta[]; uri?: string | any; } declare const createFixedHistoryPlugin: _flowgram_ai_core.PluginCreator>; /** * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates * SPDX-License-Identifier: MIT */ declare class FixedHistoryOperationService extends FlowOperationBaseServiceImpl { historyService: HistoryService; apply(operation: FlowOperation): any; originApply(operation: FlowOperation): any; transact(transaction: () => void): void; } /** * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates * SPDX-License-Identifier: MIT */ declare class FixedHistoryConfig { init(ctx: PluginContext, options: FixedHistoryPluginOptions): void; nodeToJSON: NodeToJson; getNodeLabelById: GetNodeLabelById; getNodeLabel: GetNodeLabel; getBlockLabel: GetBlockLabel; getNodeURI: GetNodeURI; getParentName(parentId?: string): string; } /** * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates * SPDX-License-Identifier: MIT */ declare class FixedHistoryService implements IHistoryDocument { historyService: HistoryService; operationRegistry: OperationRegistry; fixedHistoryOperationService: FixedHistoryOperationService; document: FlowDocument; config: FixedHistoryConfig; setSource(source: PluginContext): void; /** * 注册操作 * @param operationMetas */ registerOperationMetas(operationMetas: OperationMeta[]): void; /** * 事务 * @param transaction */ transact(transaction: () => void): void; /** * 撤销 */ undo(): Promise; /** * 重做 */ redo(): Promise; /** * 是否可重做 */ canRedo(): boolean; /** * 是否可撤销 */ canUndo(): boolean; /** * 添加一个操作 * @param operation */ pushHistoryOperation(operation: Operation): any; /** * 获取历史操作 */ getHistoryOperations(): Operation[]; /** * 添加节点 * @param value 添加节点配置 * @returns * @deprecated 请使用 `FlowOperationService.addFromNode` 代替 */ addFromNode(fromNode: FlowNodeEntity | string, json: FlowNodeJSON): FlowNodeEntity; /** * 删除节点 * @param node 节点 * @returns * @deprecated 请使用 `FlowOperationService.deleteNode` 代替 */ deleteNode(node: FlowNodeEntity): void; /** * 添加子节点 * @param data * @param parent * @param index * @param originParent * @returns * @deprecated 请使用 `FlowOperationService.addNode` 代替 */ addChildNode(data: FlowNodeJSON, parent?: FlowNodeEntity, index?: number, originParent?: FlowNodeEntity): any; /** * 批量删除 * @param nodes * @deprecated 请使用 `FlowOperationService.deleteNodes` 代替 */ deleteNodes(nodes: FlowNodeEntity[]): void; /** * 批量添加 * @param from * @param nodes */ addFromNodes(from: FlowNodeEntity, nodes: FlowNodeEntity[]): any; /** * 添加块级元素 * @param target 目标 * @param blockData 块数据 * @param parent 父级 * @returns * @deprecated 请使用 `FlowOperationService.addBlock` 代替 */ addBlock(target: string | FlowNodeEntity, blockData: FlowNodeJSON, parent?: FlowNodeEntity | undefined, index?: number): FlowNodeEntity; /** * 移动节点 * @param node 被移动的节点 * @param toNode 被放置的节点 * @returns */ moveNode(node: FlowNodeEntity, toNode: FlowNodeEntity): any; } declare class FixedHistoryFormDataService implements Disposable { document: FlowDocument; private _cache; private _formValueChangeByHistoryEmitter; onFormValueChangeByHistory: _flowgram_ai_utils.Event<{ formData: FlowNodeFormData; value: any; path: string; }>; resetCache(flowNodeFormData: FlowNodeFormData, value: any): void; setCache(flowNodeFormData: FlowNodeFormData, prop: string, value: any): void; getCache(flowNodeFormData: FlowNodeFormData, prop: string): any; /** * 获取表单数据 * @param id node id * @returns 表单数据 */ getFormDataByNodeId(id: string): FlowNodeFormData | undefined; getFormItemValue(formData: FlowNodeFormData, path: string): any; setFormItemValue(formData: FlowNodeFormData, path: string, value: any): void; getFormItem(formData: FlowNodeFormData, path: string): _flowgram_ai_form_core.FormItem | undefined; dispose(): void; } export { FixedHistoryConfig, FixedHistoryFormDataService, FixedHistoryOperationService, type FixedHistoryPluginOptions, FixedHistoryService, type GetBlockLabel, type GetDocumentJSON, type GetNodeLabel, type GetNodeLabelById, type GetNodeURI, type IHistoryDocument, type NodeToJson, createFixedHistoryPlugin };