@flowgram.ai/free-history-plugin 0.1.21 → 0.1.23

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/esm/index.js CHANGED
@@ -52,8 +52,8 @@ HistoryEntityManager = __decorateClass([
52
52
 
53
53
  // src/handlers/drag-nodes-handler.ts
54
54
  import { injectable as injectable2, inject } from "inversify";
55
- import { TransformData } from "@flowgram.ai/core";
56
55
  import { HistoryService } from "@flowgram.ai/history";
56
+ import { TransformData } from "@flowgram.ai/core";
57
57
 
58
58
  // src/types.ts
59
59
  var FreeOperationType = /* @__PURE__ */ ((FreeOperationType2) => {
@@ -72,7 +72,7 @@ var FreeOperationType = /* @__PURE__ */ ((FreeOperationType2) => {
72
72
  // src/handlers/drag-nodes-handler.ts
73
73
  var DragNodesHandler = class {
74
74
  handle(event) {
75
- if (event.type === "onDragEnd" && !event.altKey) {
75
+ if (event.type === "onDragEnd") {
76
76
  this._dragNode(event);
77
77
  }
78
78
  }
@@ -642,8 +642,8 @@ FreeHistoryRegisters = __decorateClass([
642
642
 
643
643
  // src/free-history-manager.ts
644
644
  import { cloneDeep as cloneDeep4 } from "lodash";
645
- import { injectable as injectable7, inject as inject4 } from "inversify";
646
- import { DisposableCollection as DisposableCollection2 } from "@flowgram.ai/utils";
645
+ import { injectable as injectable7, inject as inject4, optional } from "inversify";
646
+ import { DisposableCollection as DisposableCollection2, Disposable } from "@flowgram.ai/utils";
647
647
  import { HistoryService as HistoryService4 } from "@flowgram.ai/history";
648
648
  import {
649
649
  WorkflowDocument as WorkflowDocument10,
@@ -681,7 +681,7 @@ var FreeHistoryManager = class {
681
681
  this._entityManager.addEntityData(positionData);
682
682
  }
683
683
  }),
684
- this._formManager.onFormModelWillInit(({ model, data }) => {
684
+ this._formManager ? this._formManager.onFormModelWillInit(({ model, data }) => {
685
685
  const node = model.flowNodeEntity;
686
686
  const formData = node.getData(FlowNodeFormData3);
687
687
  if (formData) {
@@ -695,7 +695,7 @@ var FreeHistoryManager = class {
695
695
  })
696
696
  );
697
697
  }
698
- }),
698
+ }) : Disposable.NULL,
699
699
  document.onContentChange(async (event) => {
700
700
  await this._changeContentHandler.handle(event, ctx);
701
701
  }),
@@ -768,7 +768,8 @@ __decorateClass([
768
768
  inject4(HistoryEntityManager)
769
769
  ], FreeHistoryManager.prototype, "_entityManager", 2);
770
770
  __decorateClass([
771
- inject4(FormManager)
771
+ inject4(FormManager),
772
+ optional()
772
773
  ], FreeHistoryManager.prototype, "_formManager", 2);
773
774
  __decorateClass([
774
775
  inject4(WorkflowOperationBaseService)
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/create-free-history-plugin.ts","../../src/history-entity-manager.ts","../../src/handlers/drag-nodes-handler.ts","../../src/types.ts","../../src/handlers/change-node-data-handler.ts","../../src/free-history-config.ts","../../src/handlers/change-content-handler.ts","../../src/changes/delete-node-change.ts","../../src/changes/delete-line-change.ts","../../src/changes/add-node-change.ts","../../src/changes/add-line-change.ts","../../src/changes/index.ts","../../src/free-history-registers.ts","../../src/operation-metas/reset-layout.ts","../../src/operation-metas/base.ts","../../src/operation-metas/move-child-nodes.ts","../../src/operation-metas/drag-nodes.ts","../../src/operation-metas/delete-node.ts","../../src/operation-metas/delete-line.ts","../../src/operation-metas/change-node-data.ts","../../src/operation-metas/add-node.ts","../../src/operation-metas/add-line.ts","../../src/operation-metas/index.ts","../../src/free-history-manager.ts","../../src/index.ts","../../src/hooks/use-undo-redo.tsx"],"sourcesContent":["import { bindContributions, definePluginCreator } from '@flowgram.ai/core';\nimport { HistoryContainerModule, OperationContribution } from '@flowgram.ai/history';\n\nimport { type FreeHistoryPluginOptions } from './types';\nimport { HistoryEntityManager } from './history-entity-manager';\nimport { DragNodesHandler } from './handlers/drag-nodes-handler';\nimport { ChangeNodeDataHandler } from './handlers/change-node-data-handler';\nimport { ChangeContentHandler } from './handlers/change-content-handler';\nimport { FreeHistoryRegisters } from './free-history-registers';\nimport { FreeHistoryManager } from './free-history-manager';\nimport { FreeHistoryConfig } from './free-history-config';\n\nexport const createFreeHistoryPlugin = definePluginCreator<FreeHistoryPluginOptions>({\n onBind: ({ bind }) => {\n bindContributions(bind, FreeHistoryRegisters, [OperationContribution]);\n bind(FreeHistoryConfig).toSelf().inSingletonScope();\n bind(FreeHistoryManager).toSelf().inSingletonScope();\n bind(HistoryEntityManager).toSelf().inSingletonScope();\n bind(DragNodesHandler).toSelf().inSingletonScope();\n bind(ChangeNodeDataHandler).toSelf().inSingletonScope();\n bind(ChangeContentHandler).toSelf().inSingletonScope();\n },\n onInit(ctx, opts): void {\n ctx.get<FreeHistoryConfig>(FreeHistoryConfig).init(ctx, opts);\n\n if (!opts.enable) {\n return;\n }\n ctx.get<FreeHistoryManager>(FreeHistoryManager).onInit(ctx, opts);\n },\n onDispose(ctx) {\n ctx.get<HistoryEntityManager>(HistoryEntityManager).dispose();\n },\n containerModules: [HistoryContainerModule],\n});\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { cloneDeep, isEqual } from 'lodash';\nimport { injectable } from 'inversify';\nimport { type EntityData } from '@flowgram.ai/core';\nimport { type Disposable, DisposableCollection } from '@flowgram.ai/utils';\n\n@injectable()\nexport class HistoryEntityManager implements Disposable {\n private _entityDataValues: Map<EntityData, unknown> = new Map();\n\n private _toDispose: DisposableCollection = new DisposableCollection();\n\n addEntityData(entityData: EntityData) {\n this._entityDataValues.set(entityData, cloneDeep(entityData.toJSON()));\n this._toDispose.push(\n entityData.onWillChange(event => {\n const value = event.toJSON();\n const oldValue = this._entityDataValues.get(entityData);\n if (isEqual(value, oldValue)) {\n return;\n }\n this._entityDataValues.set(entityData, cloneDeep(value));\n }),\n );\n }\n\n getValue(entityData: EntityData) {\n return this._entityDataValues.get(entityData);\n }\n\n setValue(entityData: EntityData, value: unknown) {\n return this._entityDataValues.set(entityData, value);\n }\n\n dispose() {\n this._entityDataValues.clear();\n this._toDispose.dispose();\n }\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { injectable, inject } from 'inversify';\nimport { TransformData } from '@flowgram.ai/core';\nimport { type NodesDragEndEvent } from '@flowgram.ai/free-layout-core';\nimport { HistoryService } from '@flowgram.ai/history';\n\nimport { FreeOperationType, type IHandler } from '../types';\n\n@injectable()\nexport class DragNodesHandler implements IHandler<NodesDragEndEvent> {\n @inject(HistoryService)\n private _historyService: HistoryService;\n\n handle(event: NodesDragEndEvent) {\n if (\n event.type === 'onDragEnd' &&\n !event.altKey // altKey代表创建,这个通过add-node监听处理\n ) {\n this._dragNode(event);\n }\n }\n\n private _dragNode(event: NodesDragEndEvent) {\n this._historyService.pushOperation(\n {\n type: FreeOperationType.dragNodes,\n value: {\n ids: event.nodes.map(node => node.id),\n value: event.nodes.map(node => {\n const { x, y } = node.getData(TransformData).position;\n return {\n x,\n y,\n };\n }),\n oldValue: event.startPositions,\n },\n },\n { noApply: true },\n );\n }\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { type IPoint } from '@flowgram.ai/utils';\nimport { type Operation, type OperationMeta } from '@flowgram.ai/history';\nimport {\n type WorkflowContentChangeType,\n type WorkflowContentChangeEvent,\n type WorkflowLineEntity,\n type WorkflowLinePortInfo,\n type WorkflowNodeJSON,\n type PositionMap,\n} from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity, type FlowNodeJSON } from '@flowgram.ai/document';\nimport { type EntityData, type PluginContext } from '@flowgram.ai/core';\n\nexport enum FreeOperationType {\n addLine = 'addLine',\n deleteLine = 'deleteLine',\n moveNode = 'moveNode',\n addNode = 'addNode',\n deleteNode = 'deleteNode',\n changeNodeData = 'changeNodeData',\n resetLayout = 'resetLayout',\n dragNodes = 'dragNodes',\n moveChildNodes = 'moveChildNodes',\n}\n\nexport interface AddOrDeleteLineOperationValue extends WorkflowLinePortInfo {\n id: string;\n}\n\nexport interface AddOrDeleteWorkflowNodeOperationValue {\n node: WorkflowNodeJSON;\n parentID?: string;\n}\n\nexport interface AddLineOperation extends Operation {\n type: FreeOperationType.addLine;\n value: AddOrDeleteLineOperationValue;\n}\n\nexport interface DeleteLineOperation extends Operation {\n type: FreeOperationType.deleteLine;\n value: AddOrDeleteLineOperationValue;\n}\n\nexport interface MoveNodeOperation extends Operation {\n type: FreeOperationType.moveNode;\n value: MoveNodeOperationValue;\n}\n\nexport interface AddWorkflowNodeOperation extends Operation {\n type: FreeOperationType.addNode;\n value: AddOrDeleteWorkflowNodeOperationValue;\n}\n\nexport interface DeleteWorkflowNodeOperation extends Operation {\n type: FreeOperationType.deleteNode;\n value: AddOrDeleteWorkflowNodeOperationValue;\n}\n\nexport interface MoveNodeOperationValue {\n id: string;\n value: {\n x: number;\n y: number;\n };\n oldValue: {\n x: number;\n y: number;\n };\n}\n\nexport interface DragNodeOperationValue {\n ids: string[];\n value: IPoint[];\n oldValue: IPoint[];\n}\n\nexport interface ResetLayoutOperationValue {\n ids: string[];\n value: PositionMap;\n oldValue: PositionMap;\n}\n\nexport interface ContentChangeTypeToOperation<T extends Operation> {\n type: WorkflowContentChangeType;\n toOperation: (\n event: WorkflowContentChangeEvent,\n ctx: PluginContext\n ) => T | undefined | Promise<T | undefined>;\n}\n\nexport interface EntityDataType {\n type: FreeOperationType;\n toEntityData: (node: FlowNodeEntity, ctx: PluginContext) => EntityData;\n}\n\nexport interface ChangeNodeDataValue {\n id: string;\n value: unknown;\n oldValue: unknown;\n path: string;\n}\n\nexport interface ChangeNodeDataOperation extends Operation {\n type: FreeOperationType.changeNodeData;\n value: ChangeNodeDataValue;\n}\n\n/**\n * 将node转成json\n */\nexport type NodeToJson = (node: FlowNodeEntity) => FlowNodeJSON;\n/**\n * 将line转成json\n */\nexport type LineToJson = (node: WorkflowLineEntity) => FlowNodeJSON;\n/**\n * 根据节点id获取label\n */\nexport type GetNodeLabelById = (id: string) => string;\n/**\n * 根据节点获取label\n */\nexport type GetNodeLabel = (node: FlowNodeJSON) => string;\n/**\n * 根据分支获取label\n */\nexport type GetBlockLabel = (node: FlowNodeJSON) => string;\n/**\n * 根据节点获取URI\n */\nexport type GetNodeURI = (id: string) => string | any;\n/**\n * 根据连线获取URI\n */\nexport type GetLineURI = (id: string) => string | any;\n\n/**\n * 插件配置\n */\nexport interface FreeHistoryPluginOptions {\n enable?: boolean;\n limit?: number;\n nodeToJSON?: (ctx: PluginContext) => NodeToJson;\n getNodeLabelById?: (ctx: PluginContext) => GetNodeLabelById;\n getNodeLabel?: (ctx: PluginContext) => GetNodeLabel;\n getBlockLabel?: (ctx: PluginContext) => GetBlockLabel;\n getNodeURI?: (ctx: PluginContext) => GetNodeURI;\n getLineURI?: (ctx: PluginContext) => GetLineURI;\n operationMetas?: OperationMeta[];\n enableChangeNode?: boolean;\n uri?: string | any;\n}\n\nexport interface IHandler<E> {\n handle: (event: E, ctx: PluginContext) => void | Promise<void>;\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { cloneDeep, get, isEqual, set } from 'lodash';\nimport { injectable, inject } from 'inversify';\nimport { FlowNodeFormData, type DetailChangeEvent } from '@flowgram.ai/form-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { HistoryService } from '@flowgram.ai/history';\n\nimport { FreeOperationType, type IHandler } from '../types';\nimport { HistoryEntityManager } from '../history-entity-manager';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport interface ChangeNodeDataEvent extends DetailChangeEvent {\n node: FlowNodeEntity;\n}\n\n@injectable()\nexport class ChangeNodeDataHandler implements IHandler<ChangeNodeDataEvent> {\n @inject(HistoryService)\n private _historyService: HistoryService;\n\n @inject(WorkflowDocument) document: WorkflowDocument;\n\n @inject(HistoryEntityManager)\n private _entityManager: HistoryEntityManager;\n\n @inject(FreeHistoryConfig)\n private _config: FreeHistoryConfig;\n\n handle(event: ChangeNodeDataEvent) {\n const { path, value, initialized, node } = event;\n const formData = node.getData<FlowNodeFormData>(FlowNodeFormData);\n const oldValue = this._entityManager.getValue(formData) as object;\n const propPath = path.split('/').filter(Boolean).join('.');\n\n const propOldValue = propPath ? get(oldValue, propPath) : oldValue;\n if (isEqual(value, propOldValue)) {\n return;\n }\n\n if (initialized) {\n let operationPath = path;\n let operationValue = cloneDeep(value);\n let operationOldValue = propOldValue;\n // 只存储一层的数据,因为formModel无法获取数组下的某项的值\n if (path !== '/') {\n const clonedOldValue = cloneDeep(oldValue);\n set(clonedOldValue, propPath, value);\n operationPath = path.split('/').filter(Boolean)[0];\n operationValue = get(clonedOldValue, operationPath);\n operationOldValue = get(oldValue, operationPath);\n }\n\n this._historyService.pushOperation(\n {\n type: FreeOperationType.changeNodeData,\n value: {\n id: node.id,\n path: operationPath,\n value: operationValue,\n oldValue: operationOldValue,\n },\n uri: this._config.getNodeURI(node.id),\n },\n { noApply: true },\n );\n }\n\n if (propPath) {\n set(oldValue, propPath, cloneDeep(value));\n } else {\n this._entityManager.setValue(formData, cloneDeep(value));\n }\n }\n}\n","import { injectable } from 'inversify';\nimport { type FlowNodeEntity, type FlowNodeJSON } from '@flowgram.ai/document';\nimport { type PluginContext } from '@flowgram.ai/core';\n\nimport {\n type FreeHistoryPluginOptions,\n type GetBlockLabel,\n type GetLineURI,\n type GetNodeLabel,\n type GetNodeLabelById,\n type GetNodeURI,\n type NodeToJson,\n} from './types';\n\n@injectable()\nexport class FreeHistoryConfig {\n init(ctx: PluginContext, options: FreeHistoryPluginOptions) {\n this.enable = !!options?.enable;\n\n if (options.nodeToJSON) {\n this.nodeToJSON = options.nodeToJSON(ctx);\n }\n\n if (options.getNodeLabelById) {\n this.getNodeLabelById = options.getNodeLabelById(ctx);\n }\n\n if (options.getNodeLabel) {\n this.getNodeLabel = options.getNodeLabel(ctx);\n }\n\n if (options.getBlockLabel) {\n this.getBlockLabel = options.getBlockLabel(ctx);\n }\n\n if (options.getNodeURI) {\n this.getNodeURI = options.getNodeURI(ctx);\n }\n\n if (options.getLineURI) {\n this.getLineURI = options.getLineURI(ctx);\n }\n }\n\n enable = false;\n\n nodeToJSON: NodeToJson = (node: FlowNodeEntity) => node.toJSON();\n\n getNodeLabelById: GetNodeLabelById = (id: string) => id;\n\n getNodeLabel: GetNodeLabel = (node: FlowNodeJSON) => node.id;\n\n getBlockLabel: GetBlockLabel = (node: FlowNodeJSON) => node.id;\n\n getNodeURI: GetNodeURI = (id: string) => `node:${id}`;\n\n getLineURI: GetLineURI = (id: string) => `line:${id}`;\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { injectable, inject } from 'inversify';\nimport { type PluginContext } from '@flowgram.ai/core';\nimport { type WorkflowContentChangeEvent } from '@flowgram.ai/free-layout-core';\nimport { HistoryService } from '@flowgram.ai/history';\n\nimport { type IHandler } from '../types';\nimport changes from '../changes';\n\n@injectable()\nexport class ChangeContentHandler implements IHandler<WorkflowContentChangeEvent> {\n @inject(HistoryService)\n private _historyService: HistoryService;\n\n async handle(event: WorkflowContentChangeEvent, ctx: PluginContext) {\n if (!this._historyService.undoRedoService.canPush()) {\n return;\n }\n\n const change = changes.find(c => c.type === event.type);\n if (!change) {\n return;\n }\n const operation = await change.toOperation(event, ctx);\n if (!operation) {\n return;\n }\n\n this._historyService.pushOperation(operation, { noApply: true });\n }\n}\n","import { WorkflowDocument, WorkflowContentChangeType, delay } from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\n\nimport {\n type ContentChangeTypeToOperation,\n FreeOperationType,\n type DeleteWorkflowNodeOperation,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const deleteNodeChange: ContentChangeTypeToOperation<DeleteWorkflowNodeOperation> = {\n type: WorkflowContentChangeType.DELETE_NODE,\n toOperation: async (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = event.entity as FlowNodeEntity;\n const json = await document.toNodeJSON(node);\n const parentID = node.parent?.id;\n\n // 删除节点和删除连线同时触发,删除节点需放在后面执行\n await delay(0);\n\n return {\n type: FreeOperationType.deleteNode,\n value: {\n node: json,\n parentID,\n },\n uri: config.getNodeURI(node.id),\n };\n },\n};\n","import { type WorkflowLineEntity } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\n\nimport {\n type AddOrDeleteLineOperationValue,\n type ContentChangeTypeToOperation,\n type DeleteLineOperation,\n FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const deleteLineChange: ContentChangeTypeToOperation<DeleteLineOperation> = {\n type: WorkflowContentChangeType.DELETE_LINE,\n toOperation: (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const line = event.entity as WorkflowLineEntity;\n const value: AddOrDeleteLineOperationValue = {\n from: line.info.from,\n to: line.info.to || '',\n fromPort: line.info.fromPort || '',\n toPort: line.info.toPort || '',\n id: line.id,\n };\n return {\n type: FreeOperationType.deleteLine,\n value,\n uri: config.getNodeURI(line.id),\n };\n },\n};\n","import { WorkflowDocument, delay, type WorkflowNodeJSON } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\n\nimport {\n type AddWorkflowNodeOperation,\n type ContentChangeTypeToOperation,\n FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const addNodeChange: ContentChangeTypeToOperation<AddWorkflowNodeOperation> = {\n type: WorkflowContentChangeType.ADD_NODE,\n toOperation: async (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = event.entity as FlowNodeEntity;\n const parentID = node.parent?.id;\n /**\n * 由于document.toNodeJSON依赖表单里面的default的值初始化,故此处需要等表单的初始化完成\n * 比如dataset-node/index.ts中formatOnSubmit实现需要value被初始化\n */\n await delay(10);\n const json: WorkflowNodeJSON = await document.toNodeJSON(node);\n\n return {\n type: FreeOperationType.addNode,\n value: {\n node: json,\n parentID,\n },\n uri: config.getNodeURI(node.id),\n };\n },\n};\n","import { type WorkflowLineEntity } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\n\nimport {\n type AddLineOperation,\n type AddOrDeleteLineOperationValue,\n type ContentChangeTypeToOperation,\n FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const addLineChange: ContentChangeTypeToOperation<AddLineOperation> = {\n type: WorkflowContentChangeType.ADD_LINE,\n toOperation: (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const line = event.entity as WorkflowLineEntity;\n const value: AddOrDeleteLineOperationValue = {\n from: line.info.from,\n to: line.info.to || '',\n fromPort: line.info.fromPort || '',\n toPort: line.info.toPort || '',\n id: line.id,\n };\n return {\n type: FreeOperationType.addLine,\n value,\n uri: config.getLineURI(line.id),\n };\n },\n};\n","import { deleteNodeChange } from './delete-node-change';\nimport { deleteLineChange } from './delete-line-change';\nimport { addNodeChange } from './add-node-change';\nimport { addLineChange } from './add-line-change';\n\nexport default [addLineChange, deleteLineChange, addNodeChange, deleteNodeChange];\n","import { injectable } from 'inversify';\nimport { type OperationContribution, type OperationRegistry } from '@flowgram.ai/history';\n\nimport { operationMetas } from './operation-metas';\n\n@injectable()\nexport class FreeHistoryRegisters implements OperationContribution {\n registerOperationMeta(operationRegistry: OperationRegistry): void {\n operationMetas.forEach(operationMeta => {\n operationRegistry.registerOperationMeta(operationMeta);\n });\n }\n}\n","import { type PluginContext } from '@flowgram.ai/core';\nimport { WorkflowResetLayoutService } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { FreeOperationType, type ResetLayoutOperationValue } from '../types';\nimport { baseOperationMeta } from './base';\n\nexport const resetLayoutOperationMeta: OperationMeta<\n ResetLayoutOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: FreeOperationType.resetLayout,\n inverse: op => ({\n ...op,\n value: {\n ...op.value,\n value: op.value.oldValue,\n oldValue: op.value.value,\n },\n }),\n apply: async (operation, ctx: PluginContext) => {\n const reset = ctx.get<WorkflowResetLayoutService>(WorkflowResetLayoutService);\n await reset.layoutToPositions(operation.value.ids, operation.value.value);\n },\n shouldMerge: () => false,\n};\n","import { type OperationMeta } from '@flowgram.ai/history';\n\nexport const baseOperationMeta: Partial<OperationMeta> = {\n shouldMerge: (_op, prev, element) => {\n if (!prev) {\n return false;\n }\n\n if (\n // 合并500ms内的操作, 如删除节点会联动删除线条\n Date.now() - element.getTimestamp() <\n 500\n ) {\n return true;\n }\n return false;\n },\n};\n","import { OperationMeta } from '@flowgram.ai/history';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { MoveChildNodesOperationValue, OperationType } from '@flowgram.ai/document';\nimport { FlowNodeBaseType } from '@flowgram.ai/document';\nimport { PluginContext, TransformData } from '@flowgram.ai/core';\n\nimport { baseOperationMeta } from './base';\n\nexport const moveChildNodesOperationMeta: OperationMeta<\n MoveChildNodesOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: OperationType.moveChildNodes,\n inverse: (op) => ({\n ...op,\n value: {\n ...op.value,\n fromIndex: op.value.toIndex,\n toIndex: op.value.fromIndex,\n fromParentId: op.value.toParentId,\n toParentId: op.value.fromParentId,\n },\n }),\n apply: (operation, ctx: PluginContext) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n document.moveChildNodes(operation.value);\n const fromContainer = document.getNode(operation.value.fromParentId);\n requestAnimationFrame(() => {\n if (fromContainer && fromContainer.flowNodeType !== FlowNodeBaseType.ROOT) {\n const fromContainerTransformData = fromContainer.getData(TransformData);\n fromContainerTransformData.fireChange();\n }\n });\n },\n};\n","import { type OperationMeta } from '@flowgram.ai/history';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { FlowNodeTransformData } from '@flowgram.ai/document';\nimport { type PluginContext, TransformData } from '@flowgram.ai/core';\n\nimport { type DragNodeOperationValue, FreeOperationType } from '../types';\nimport { baseOperationMeta } from './base';\n\nexport const dragNodesOperationMeta: OperationMeta<DragNodeOperationValue, PluginContext, void> = {\n ...baseOperationMeta,\n type: FreeOperationType.dragNodes,\n inverse: (op) => ({\n ...op,\n value: {\n ...op.value,\n value: op.value.oldValue,\n oldValue: op.value.value,\n },\n }),\n apply: (operation, ctx) => {\n operation.value.ids.forEach((id, index) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = document.getNode(id);\n if (!node) {\n return;\n }\n\n const transform = node.getData(TransformData);\n const point = operation.value.value[index];\n transform.update({\n position: {\n x: point.x,\n y: point.y,\n },\n });\n // 嵌套情况下需将子节点 transform 设为 dirty\n if (node.collapsedChildren?.length > 0) {\n node.collapsedChildren.forEach((childNode) => {\n const childNodeTransformData =\n childNode.getData<FlowNodeTransformData>(FlowNodeTransformData);\n childNodeTransformData.fireChange();\n });\n }\n });\n },\n};\n","import { type PluginContext } from '@flowgram.ai/core';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { type AddOrDeleteWorkflowNodeOperationValue, FreeOperationType } from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\nimport { baseOperationMeta } from './base';\n\nexport const deleteNodeOperationMeta: OperationMeta<\n AddOrDeleteWorkflowNodeOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: FreeOperationType.deleteNode,\n inverse: op => ({\n ...op,\n type: FreeOperationType.addNode,\n }),\n apply: (operation, ctx: PluginContext) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = document.getNode(operation.value.node.id);\n if (node) {\n node.dispose();\n }\n },\n getLabel: (op, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n return `Delete Node ${config.getNodeLabel(op.value.node)}`;\n },\n getDescription: (op, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n let desc = `Delete Node ${config.getNodeLabel(op.value.node)}`;\n if (op.value.node.meta?.position) {\n desc += ` at ${op.value.node.meta.position.x},${op.value.node.meta.position.y}`;\n }\n return desc;\n },\n};\n","import { type OperationMeta } from '@flowgram.ai/history';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { type PluginContext } from '@flowgram.ai/core';\n\nimport { type AddOrDeleteLineOperationValue, FreeOperationType } from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\nimport { baseOperationMeta } from './base';\n\nexport const deleteLineOperationMeta: OperationMeta<\n AddOrDeleteLineOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: FreeOperationType.deleteLine,\n inverse: (op) => ({\n ...op,\n type: FreeOperationType.addLine,\n }),\n apply: (operation, ctx: PluginContext) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n document.removeNode(operation.value.id);\n },\n getLabel: (op, ctx) => 'Delete Line',\n getDescription: (op, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const { value } = op;\n if (!value.from || !value.to) {\n return 'Delete Line';\n }\n\n const fromName = config.getNodeLabelById(value.from);\n const toName = config.getNodeLabelById(value.to);\n return `Delete Line from ${fromName} to ${toName}`;\n },\n};\n","import { FlowNodeFormData } from '@flowgram.ai/form-core';\nimport { type PluginContext } from '@flowgram.ai/core';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { FreeOperationType, type ChangeNodeDataValue } from '../types';\nimport { baseOperationMeta } from './base';\n\nexport const changeNodeDataOperationMeta: OperationMeta<ChangeNodeDataValue, PluginContext, void> =\n {\n ...baseOperationMeta,\n type: FreeOperationType.changeNodeData,\n inverse: op => ({\n ...op,\n value: {\n ...op.value,\n value: op.value.oldValue,\n oldValue: op.value.value,\n },\n }),\n apply: (operation, ctx: PluginContext) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = document.getNode(operation.value.id);\n\n if (!node) {\n return;\n }\n const formData = node.getData(FlowNodeFormData);\n\n if (!formData) {\n return;\n }\n\n let { path } = operation.value;\n if (path.endsWith('/') && path !== '/') {\n path = path.slice(0, -1);\n }\n\n if (!path.startsWith('/')) {\n path = `/${path}`;\n }\n\n const formItem = formData.formModel.getFormItemByPath(path);\n\n if (!formItem) {\n return;\n }\n formItem.value = operation.value.value;\n },\n shouldMerge: (op, prev, element) => {\n if (!prev) {\n return false;\n }\n\n if (Date.now() - element.getTimestamp() < 500) {\n if (\n op.type === prev.type && // 相同类型\n op.value.id === prev.value.id && // 相同节点\n op.value?.path === prev.value?.path // 相同路径\n ) {\n return {\n type: op.type,\n value: {\n ...op.value,\n value: op.value.value,\n oldValue: prev.value.oldValue,\n },\n };\n }\n return true;\n }\n return false;\n },\n };\n","import { cloneDeep } from 'lodash';\nimport { type PluginContext } from '@flowgram.ai/core';\nimport { WorkflowDocument, type WorkflowNodeJSON } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { type AddOrDeleteWorkflowNodeOperationValue, FreeOperationType } from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\nimport { baseOperationMeta } from './base';\n\nexport const addNodeOperationMeta: OperationMeta<\n AddOrDeleteWorkflowNodeOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: FreeOperationType.addNode,\n inverse: op => ({\n ...op,\n type: FreeOperationType.deleteNode,\n }),\n apply: async (operation, ctx: PluginContext) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n await document.createWorkflowNode(\n cloneDeep(operation.value.node) as WorkflowNodeJSON,\n false,\n operation.value.parentID,\n );\n },\n getLabel: (op, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n return `Create Node ${config.getNodeLabel(op.value.node)}`;\n },\n getDescription: (op, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n let desc = `Create Node ${config.getNodeLabel(op.value.node)}`;\n if (op.value.node.meta?.position) {\n desc += ` at ${op.value.node.meta.position.x},${op.value.node.meta.position.y}`;\n }\n return desc;\n },\n};\n","import { type PluginContext } from '@flowgram.ai/core';\nimport { WorkflowLinesManager } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { type AddOrDeleteLineOperationValue, FreeOperationType } from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\nimport { baseOperationMeta } from './base';\n\nexport const addLineOperationMeta: OperationMeta<\n AddOrDeleteLineOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: FreeOperationType.addLine,\n inverse: op => ({\n ...op,\n type: FreeOperationType.deleteLine,\n }),\n apply: (operation, ctx: PluginContext) => {\n const linesManager = ctx.get<WorkflowLinesManager>(WorkflowLinesManager);\n linesManager.createLine({\n ...operation.value,\n key: operation.value.id,\n });\n },\n getLabel: (op, ctx) => 'Create Line',\n getDescription: (op, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const { value } = op;\n if (!value.from || !value.to) {\n return 'Create Line';\n }\n\n const fromName = config.getNodeLabelById(value.from);\n const toName = config.getNodeLabelById(value.to);\n return `Create Line from ${fromName} to ${toName}`;\n },\n};\n","import { resetLayoutOperationMeta } from './reset-layout';\nimport { moveChildNodesOperationMeta } from './move-child-nodes';\nimport { dragNodesOperationMeta } from './drag-nodes';\nimport { deleteNodeOperationMeta } from './delete-node';\nimport { deleteLineOperationMeta } from './delete-line';\nimport { changeNodeDataOperationMeta } from './change-node-data';\nimport { addNodeOperationMeta } from './add-node';\nimport { addLineOperationMeta } from './add-line';\n\nexport const operationMetas = [\n addLineOperationMeta,\n deleteLineOperationMeta,\n addNodeOperationMeta,\n deleteNodeOperationMeta,\n changeNodeDataOperationMeta,\n resetLayoutOperationMeta,\n dragNodesOperationMeta,\n moveChildNodesOperationMeta,\n];\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { cloneDeep } from 'lodash';\nimport { injectable, inject } from 'inversify';\nimport { DisposableCollection } from '@flowgram.ai/utils';\nimport { HistoryService } from '@flowgram.ai/history';\nimport {\n WorkflowDocument,\n WorkflowResetLayoutService,\n WorkflowDragService,\n WorkflowOperationBaseService,\n} from '@flowgram.ai/free-layout-core';\nimport { FlowNodeFormData } from '@flowgram.ai/form-core';\nimport { FormManager } from '@flowgram.ai/form-core';\nimport { OperationType } from '@flowgram.ai/document';\nimport { type PluginContext, PositionData } from '@flowgram.ai/core';\n\nimport { DragNodeOperationValue, type FreeHistoryPluginOptions, FreeOperationType } from './types';\nimport { HistoryEntityManager } from './history-entity-manager';\nimport { DragNodesHandler } from './handlers/drag-nodes-handler';\nimport { ChangeNodeDataHandler } from './handlers/change-node-data-handler';\nimport { ChangeContentHandler } from './handlers/change-content-handler';\n\n/**\n * 历史管理\n */\n@injectable()\nexport class FreeHistoryManager {\n @inject(DragNodesHandler)\n private _dragNodesHandler: DragNodesHandler;\n\n @inject(ChangeNodeDataHandler)\n private _changeNodeDataHandler: ChangeNodeDataHandler;\n\n @inject(ChangeContentHandler)\n private _changeContentHandler: ChangeContentHandler;\n\n @inject(HistoryEntityManager)\n private _entityManager: HistoryEntityManager;\n\n @inject(FormManager)\n private _formManager: FormManager;\n\n private _toDispose: DisposableCollection = new DisposableCollection();\n\n @inject(WorkflowOperationBaseService)\n private _operationService: WorkflowOperationBaseService;\n\n onInit(ctx: PluginContext, opts: FreeHistoryPluginOptions) {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const historyService = ctx.get<HistoryService>(HistoryService);\n const dragService = ctx.get<WorkflowDragService>(WorkflowDragService);\n\n const resetLayoutService = ctx.get<WorkflowResetLayoutService>(WorkflowResetLayoutService);\n\n if (opts?.limit) {\n historyService.limit(opts.limit);\n }\n historyService.context.source = ctx;\n\n this._toDispose.pushAll([\n dragService.onNodesDrag(async (event) => {\n if (event.type !== 'onDragEnd') {\n return;\n }\n this._dragNodesHandler.handle(event);\n }),\n document.onNodeCreate(({ node, data }) => {\n const positionData = node.getData(PositionData);\n if (positionData) {\n this._entityManager.addEntityData(positionData);\n }\n }),\n this._formManager.onFormModelWillInit(({ model, data }) => {\n const node = model.flowNodeEntity;\n const formData = node.getData<FlowNodeFormData>(FlowNodeFormData);\n\n if (formData) {\n this._entityManager.setValue(formData, cloneDeep(data));\n\n this._toDispose.push(\n formData.onDetailChange((event) => {\n this._changeNodeDataHandler.handle({\n ...event,\n node,\n });\n })\n );\n }\n }),\n document.onContentChange(async (event) => {\n await this._changeContentHandler.handle(event, ctx);\n }),\n document.onReload((_event) => {\n historyService.clear();\n }),\n resetLayoutService.onResetLayout((event) => {\n historyService.pushOperation(\n {\n type: FreeOperationType.resetLayout,\n value: {\n ids: event.nodeIds,\n value: event.positionMap,\n oldValue: event.oldPositionMap,\n },\n },\n { noApply: true }\n );\n }),\n this._operationService.onNodeMove(({ node, fromParent, fromIndex, toParent, toIndex }) => {\n historyService.pushOperation(\n {\n type: OperationType.moveChildNodes,\n value: {\n fromParentId: fromParent.id,\n fromIndex,\n nodeIds: [node.id],\n toParentId: toParent.id,\n toIndex,\n },\n },\n {\n noApply: true,\n }\n );\n }),\n this._operationService.onNodePostionUpdate((event) => {\n const value: DragNodeOperationValue = {\n ids: [event.node.id],\n value: [event.newPosition],\n oldValue: [event.oldPosition],\n };\n historyService.pushOperation(\n {\n type: FreeOperationType.dragNodes,\n value,\n },\n {\n noApply: true,\n }\n );\n }),\n ]);\n }\n\n dispose() {\n this._entityManager.dispose();\n this._toDispose.dispose();\n }\n}\n","export * from './create-free-history-plugin';\nexport * from './types';\nexport * from '@flowgram.ai/history';\nexport * from './free-history-config';\nexport * from './hooks';\nexport * from './free-history-registers';\n","import { useEffect, useState } from 'react';\n\nimport { useService } from '@flowgram.ai/core';\nimport { HistoryService } from '@flowgram.ai/history';\n\ninterface UndoRedo {\n canUndo: boolean;\n canRedo: boolean;\n undo: () => Promise<void>;\n redo: () => Promise<void>;\n}\n\nexport function useUndoRedo(): UndoRedo {\n const historyService = useService<HistoryService>(HistoryService);\n const [canUndo, setCanUndo] = useState(false);\n const [canRedo, setCanRedo] = useState(false);\n\n useEffect(() => {\n const toDispose = historyService.undoRedoService.onChange(() => {\n setCanUndo(historyService.canUndo());\n setCanRedo(historyService.canRedo());\n });\n return () => {\n toDispose.dispose();\n };\n }, []);\n\n return {\n canUndo,\n canRedo,\n undo: () => historyService.undo(),\n redo: () => historyService.redo(),\n };\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,mBAAmB,2BAA2B;AACvD,SAAS,wBAAwB,6BAA6B;;;ACA9D,SAAS,WAAW,eAAe;AACnC,SAAS,kBAAkB;AAE3B,SAA0B,4BAA4B;AAG/C,IAAM,uBAAN,MAAiD;AAAA,EAAjD;AACL,SAAQ,oBAA8C,oBAAI,IAAI;AAE9D,SAAQ,aAAmC,IAAI,qBAAqB;AAAA;AAAA,EAEpE,cAAc,YAAwB;AACpC,SAAK,kBAAkB,IAAI,YAAY,UAAU,WAAW,OAAO,CAAC,CAAC;AACrE,SAAK,WAAW;AAAA,MACd,WAAW,aAAa,WAAS;AAC/B,cAAM,QAAQ,MAAM,OAAO;AAC3B,cAAM,WAAW,KAAK,kBAAkB,IAAI,UAAU;AACtD,YAAI,QAAQ,OAAO,QAAQ,GAAG;AAC5B;AAAA,QACF;AACA,aAAK,kBAAkB,IAAI,YAAY,UAAU,KAAK,CAAC;AAAA,MACzD,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEA,SAAS,YAAwB;AAC/B,WAAO,KAAK,kBAAkB,IAAI,UAAU;AAAA,EAC9C;AAAA,EAEA,SAAS,YAAwB,OAAgB;AAC/C,WAAO,KAAK,kBAAkB,IAAI,YAAY,KAAK;AAAA,EACrD;AAAA,EAEA,UAAU;AACR,SAAK,kBAAkB,MAAM;AAC7B,SAAK,WAAW,QAAQ;AAAA,EAC1B;AACF;AA/Ba,uBAAN;AAAA,EADN,WAAW;AAAA,GACC;;;ACNb,SAAS,cAA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","inject","HistoryService","injectable","injectable","isEqual","cloneDeep","inject","HistoryService","injectable","injectable","inject","HistoryService","WorkflowDocument","WorkflowDocument","WorkflowContentChangeType","WorkflowContentChangeType","WorkflowDocument","delay","WorkflowContentChangeType","WorkflowContentChangeType","WorkflowDocument","delay","WorkflowContentChangeType","WorkflowContentChangeType","inject","HistoryService","injectable","injectable","WorkflowDocument","TransformData","WorkflowDocument","TransformData","WorkflowDocument","TransformData","WorkflowDocument","TransformData","WorkflowDocument","WorkflowDocument","WorkflowDocument","WorkflowDocument","FlowNodeFormData","WorkflowDocument","WorkflowDocument","FlowNodeFormData","cloneDeep","WorkflowDocument","WorkflowDocument","cloneDeep","injectable","cloneDeep","injectable","inject","DisposableCollection","HistoryService","WorkflowDocument","WorkflowResetLayoutService","FlowNodeFormData","OperationType","DisposableCollection","WorkflowDocument","HistoryService","WorkflowResetLayoutService","FlowNodeFormData","cloneDeep","OperationType","inject","injectable","HistoryService"]}
1
+ {"version":3,"sources":["../../src/create-free-history-plugin.ts","../../src/history-entity-manager.ts","../../src/handlers/drag-nodes-handler.ts","../../src/types.ts","../../src/handlers/change-node-data-handler.ts","../../src/free-history-config.ts","../../src/handlers/change-content-handler.ts","../../src/changes/delete-node-change.ts","../../src/changes/delete-line-change.ts","../../src/changes/add-node-change.ts","../../src/changes/add-line-change.ts","../../src/changes/index.ts","../../src/free-history-registers.ts","../../src/operation-metas/reset-layout.ts","../../src/operation-metas/base.ts","../../src/operation-metas/move-child-nodes.ts","../../src/operation-metas/drag-nodes.ts","../../src/operation-metas/delete-node.ts","../../src/operation-metas/delete-line.ts","../../src/operation-metas/change-node-data.ts","../../src/operation-metas/add-node.ts","../../src/operation-metas/add-line.ts","../../src/operation-metas/index.ts","../../src/free-history-manager.ts","../../src/index.ts","../../src/hooks/use-undo-redo.tsx"],"sourcesContent":["import { bindContributions, definePluginCreator } from '@flowgram.ai/core';\nimport { HistoryContainerModule, OperationContribution } from '@flowgram.ai/history';\n\nimport { type FreeHistoryPluginOptions } from './types';\nimport { HistoryEntityManager } from './history-entity-manager';\nimport { DragNodesHandler } from './handlers/drag-nodes-handler';\nimport { ChangeNodeDataHandler } from './handlers/change-node-data-handler';\nimport { ChangeContentHandler } from './handlers/change-content-handler';\nimport { FreeHistoryRegisters } from './free-history-registers';\nimport { FreeHistoryManager } from './free-history-manager';\nimport { FreeHistoryConfig } from './free-history-config';\n\nexport const createFreeHistoryPlugin = definePluginCreator<FreeHistoryPluginOptions>({\n onBind: ({ bind }) => {\n bindContributions(bind, FreeHistoryRegisters, [OperationContribution]);\n bind(FreeHistoryConfig).toSelf().inSingletonScope();\n bind(FreeHistoryManager).toSelf().inSingletonScope();\n bind(HistoryEntityManager).toSelf().inSingletonScope();\n bind(DragNodesHandler).toSelf().inSingletonScope();\n bind(ChangeNodeDataHandler).toSelf().inSingletonScope();\n bind(ChangeContentHandler).toSelf().inSingletonScope();\n },\n onInit(ctx, opts): void {\n ctx.get<FreeHistoryConfig>(FreeHistoryConfig).init(ctx, opts);\n\n if (!opts.enable) {\n return;\n }\n ctx.get<FreeHistoryManager>(FreeHistoryManager).onInit(ctx, opts);\n },\n onDispose(ctx) {\n ctx.get<HistoryEntityManager>(HistoryEntityManager).dispose();\n },\n containerModules: [HistoryContainerModule],\n});\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { cloneDeep, isEqual } from 'lodash';\nimport { injectable } from 'inversify';\nimport { type EntityData } from '@flowgram.ai/core';\nimport { type Disposable, DisposableCollection } from '@flowgram.ai/utils';\n\n@injectable()\nexport class HistoryEntityManager implements Disposable {\n private _entityDataValues: Map<EntityData, unknown> = new Map();\n\n private _toDispose: DisposableCollection = new DisposableCollection();\n\n addEntityData(entityData: EntityData) {\n this._entityDataValues.set(entityData, cloneDeep(entityData.toJSON()));\n this._toDispose.push(\n entityData.onWillChange(event => {\n const value = event.toJSON();\n const oldValue = this._entityDataValues.get(entityData);\n if (isEqual(value, oldValue)) {\n return;\n }\n this._entityDataValues.set(entityData, cloneDeep(value));\n }),\n );\n }\n\n getValue(entityData: EntityData) {\n return this._entityDataValues.get(entityData);\n }\n\n setValue(entityData: EntityData, value: unknown) {\n return this._entityDataValues.set(entityData, value);\n }\n\n dispose() {\n this._entityDataValues.clear();\n this._toDispose.dispose();\n }\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { injectable, inject } from 'inversify';\nimport { HistoryService } from '@flowgram.ai/history';\nimport { type NodesDragEndEvent } from '@flowgram.ai/free-layout-core';\nimport { TransformData } from '@flowgram.ai/core';\n\nimport { FreeOperationType, type IHandler } from '../types';\n\n@injectable()\nexport class DragNodesHandler implements IHandler<NodesDragEndEvent> {\n @inject(HistoryService)\n private _historyService: HistoryService;\n\n handle(event: NodesDragEndEvent) {\n if (event.type === 'onDragEnd') {\n this._dragNode(event);\n }\n }\n\n private _dragNode(event: NodesDragEndEvent) {\n this._historyService.pushOperation(\n {\n type: FreeOperationType.dragNodes,\n value: {\n ids: event.nodes.map((node) => node.id),\n value: event.nodes.map((node) => {\n const { x, y } = node.getData(TransformData).position;\n return {\n x,\n y,\n };\n }),\n oldValue: event.startPositions,\n },\n },\n { noApply: true }\n );\n }\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { type IPoint } from '@flowgram.ai/utils';\nimport { type Operation, type OperationMeta } from '@flowgram.ai/history';\nimport {\n type WorkflowContentChangeType,\n type WorkflowContentChangeEvent,\n type WorkflowLineEntity,\n type WorkflowLinePortInfo,\n type WorkflowNodeJSON,\n type PositionMap,\n} from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity, type FlowNodeJSON } from '@flowgram.ai/document';\nimport { type EntityData, type PluginContext } from '@flowgram.ai/core';\n\nexport enum FreeOperationType {\n addLine = 'addLine',\n deleteLine = 'deleteLine',\n moveNode = 'moveNode',\n addNode = 'addNode',\n deleteNode = 'deleteNode',\n changeNodeData = 'changeNodeData',\n resetLayout = 'resetLayout',\n dragNodes = 'dragNodes',\n moveChildNodes = 'moveChildNodes',\n}\n\nexport interface AddOrDeleteLineOperationValue extends WorkflowLinePortInfo {\n id: string;\n}\n\nexport interface AddOrDeleteWorkflowNodeOperationValue {\n node: WorkflowNodeJSON;\n parentID?: string;\n}\n\nexport interface AddLineOperation extends Operation {\n type: FreeOperationType.addLine;\n value: AddOrDeleteLineOperationValue;\n}\n\nexport interface DeleteLineOperation extends Operation {\n type: FreeOperationType.deleteLine;\n value: AddOrDeleteLineOperationValue;\n}\n\nexport interface MoveNodeOperation extends Operation {\n type: FreeOperationType.moveNode;\n value: MoveNodeOperationValue;\n}\n\nexport interface AddWorkflowNodeOperation extends Operation {\n type: FreeOperationType.addNode;\n value: AddOrDeleteWorkflowNodeOperationValue;\n}\n\nexport interface DeleteWorkflowNodeOperation extends Operation {\n type: FreeOperationType.deleteNode;\n value: AddOrDeleteWorkflowNodeOperationValue;\n}\n\nexport interface MoveNodeOperationValue {\n id: string;\n value: {\n x: number;\n y: number;\n };\n oldValue: {\n x: number;\n y: number;\n };\n}\n\nexport interface DragNodeOperationValue {\n ids: string[];\n value: IPoint[];\n oldValue: IPoint[];\n}\n\nexport interface ResetLayoutOperationValue {\n ids: string[];\n value: PositionMap;\n oldValue: PositionMap;\n}\n\nexport interface ContentChangeTypeToOperation<T extends Operation> {\n type: WorkflowContentChangeType;\n toOperation: (\n event: WorkflowContentChangeEvent,\n ctx: PluginContext\n ) => T | undefined | Promise<T | undefined>;\n}\n\nexport interface EntityDataType {\n type: FreeOperationType;\n toEntityData: (node: FlowNodeEntity, ctx: PluginContext) => EntityData;\n}\n\nexport interface ChangeNodeDataValue {\n id: string;\n value: unknown;\n oldValue: unknown;\n path: string;\n}\n\nexport interface ChangeNodeDataOperation extends Operation {\n type: FreeOperationType.changeNodeData;\n value: ChangeNodeDataValue;\n}\n\n/**\n * 将node转成json\n */\nexport type NodeToJson = (node: FlowNodeEntity) => FlowNodeJSON;\n/**\n * 将line转成json\n */\nexport type LineToJson = (node: WorkflowLineEntity) => FlowNodeJSON;\n/**\n * 根据节点id获取label\n */\nexport type GetNodeLabelById = (id: string) => string;\n/**\n * 根据节点获取label\n */\nexport type GetNodeLabel = (node: FlowNodeJSON) => string;\n/**\n * 根据分支获取label\n */\nexport type GetBlockLabel = (node: FlowNodeJSON) => string;\n/**\n * 根据节点获取URI\n */\nexport type GetNodeURI = (id: string) => string | any;\n/**\n * 根据连线获取URI\n */\nexport type GetLineURI = (id: string) => string | any;\n\n/**\n * 插件配置\n */\nexport interface FreeHistoryPluginOptions {\n enable?: boolean;\n limit?: number;\n nodeToJSON?: (ctx: PluginContext) => NodeToJson;\n getNodeLabelById?: (ctx: PluginContext) => GetNodeLabelById;\n getNodeLabel?: (ctx: PluginContext) => GetNodeLabel;\n getBlockLabel?: (ctx: PluginContext) => GetBlockLabel;\n getNodeURI?: (ctx: PluginContext) => GetNodeURI;\n getLineURI?: (ctx: PluginContext) => GetLineURI;\n operationMetas?: OperationMeta[];\n enableChangeNode?: boolean;\n uri?: string | any;\n}\n\nexport interface IHandler<E> {\n handle: (event: E, ctx: PluginContext) => void | Promise<void>;\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { cloneDeep, get, isEqual, set } from 'lodash';\nimport { injectable, inject } from 'inversify';\nimport { FlowNodeFormData, type DetailChangeEvent } from '@flowgram.ai/form-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { HistoryService } from '@flowgram.ai/history';\n\nimport { FreeOperationType, type IHandler } from '../types';\nimport { HistoryEntityManager } from '../history-entity-manager';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport interface ChangeNodeDataEvent extends DetailChangeEvent {\n node: FlowNodeEntity;\n}\n\n@injectable()\nexport class ChangeNodeDataHandler implements IHandler<ChangeNodeDataEvent> {\n @inject(HistoryService)\n private _historyService: HistoryService;\n\n @inject(WorkflowDocument) document: WorkflowDocument;\n\n @inject(HistoryEntityManager)\n private _entityManager: HistoryEntityManager;\n\n @inject(FreeHistoryConfig)\n private _config: FreeHistoryConfig;\n\n handle(event: ChangeNodeDataEvent) {\n const { path, value, initialized, node } = event;\n const formData = node.getData<FlowNodeFormData>(FlowNodeFormData);\n const oldValue = this._entityManager.getValue(formData) as object;\n const propPath = path.split('/').filter(Boolean).join('.');\n\n const propOldValue = propPath ? get(oldValue, propPath) : oldValue;\n if (isEqual(value, propOldValue)) {\n return;\n }\n\n if (initialized) {\n let operationPath = path;\n let operationValue = cloneDeep(value);\n let operationOldValue = propOldValue;\n // 只存储一层的数据,因为formModel无法获取数组下的某项的值\n if (path !== '/') {\n const clonedOldValue = cloneDeep(oldValue);\n set(clonedOldValue, propPath, value);\n operationPath = path.split('/').filter(Boolean)[0];\n operationValue = get(clonedOldValue, operationPath);\n operationOldValue = get(oldValue, operationPath);\n }\n\n this._historyService.pushOperation(\n {\n type: FreeOperationType.changeNodeData,\n value: {\n id: node.id,\n path: operationPath,\n value: operationValue,\n oldValue: operationOldValue,\n },\n uri: this._config.getNodeURI(node.id),\n },\n { noApply: true },\n );\n }\n\n if (propPath) {\n set(oldValue, propPath, cloneDeep(value));\n } else {\n this._entityManager.setValue(formData, cloneDeep(value));\n }\n }\n}\n","import { injectable } from 'inversify';\nimport { type FlowNodeEntity, type FlowNodeJSON } from '@flowgram.ai/document';\nimport { type PluginContext } from '@flowgram.ai/core';\n\nimport {\n type FreeHistoryPluginOptions,\n type GetBlockLabel,\n type GetLineURI,\n type GetNodeLabel,\n type GetNodeLabelById,\n type GetNodeURI,\n type NodeToJson,\n} from './types';\n\n@injectable()\nexport class FreeHistoryConfig {\n init(ctx: PluginContext, options: FreeHistoryPluginOptions) {\n this.enable = !!options?.enable;\n\n if (options.nodeToJSON) {\n this.nodeToJSON = options.nodeToJSON(ctx);\n }\n\n if (options.getNodeLabelById) {\n this.getNodeLabelById = options.getNodeLabelById(ctx);\n }\n\n if (options.getNodeLabel) {\n this.getNodeLabel = options.getNodeLabel(ctx);\n }\n\n if (options.getBlockLabel) {\n this.getBlockLabel = options.getBlockLabel(ctx);\n }\n\n if (options.getNodeURI) {\n this.getNodeURI = options.getNodeURI(ctx);\n }\n\n if (options.getLineURI) {\n this.getLineURI = options.getLineURI(ctx);\n }\n }\n\n enable = false;\n\n nodeToJSON: NodeToJson = (node: FlowNodeEntity) => node.toJSON();\n\n getNodeLabelById: GetNodeLabelById = (id: string) => id;\n\n getNodeLabel: GetNodeLabel = (node: FlowNodeJSON) => node.id;\n\n getBlockLabel: GetBlockLabel = (node: FlowNodeJSON) => node.id;\n\n getNodeURI: GetNodeURI = (id: string) => `node:${id}`;\n\n getLineURI: GetLineURI = (id: string) => `line:${id}`;\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { injectable, inject } from 'inversify';\nimport { type PluginContext } from '@flowgram.ai/core';\nimport { type WorkflowContentChangeEvent } from '@flowgram.ai/free-layout-core';\nimport { HistoryService } from '@flowgram.ai/history';\n\nimport { type IHandler } from '../types';\nimport changes from '../changes';\n\n@injectable()\nexport class ChangeContentHandler implements IHandler<WorkflowContentChangeEvent> {\n @inject(HistoryService)\n private _historyService: HistoryService;\n\n async handle(event: WorkflowContentChangeEvent, ctx: PluginContext) {\n if (!this._historyService.undoRedoService.canPush()) {\n return;\n }\n\n const change = changes.find(c => c.type === event.type);\n if (!change) {\n return;\n }\n const operation = await change.toOperation(event, ctx);\n if (!operation) {\n return;\n }\n\n this._historyService.pushOperation(operation, { noApply: true });\n }\n}\n","import { WorkflowDocument, WorkflowContentChangeType, delay } from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\n\nimport {\n type ContentChangeTypeToOperation,\n FreeOperationType,\n type DeleteWorkflowNodeOperation,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const deleteNodeChange: ContentChangeTypeToOperation<DeleteWorkflowNodeOperation> = {\n type: WorkflowContentChangeType.DELETE_NODE,\n toOperation: async (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = event.entity as FlowNodeEntity;\n const json = await document.toNodeJSON(node);\n const parentID = node.parent?.id;\n\n // 删除节点和删除连线同时触发,删除节点需放在后面执行\n await delay(0);\n\n return {\n type: FreeOperationType.deleteNode,\n value: {\n node: json,\n parentID,\n },\n uri: config.getNodeURI(node.id),\n };\n },\n};\n","import { type WorkflowLineEntity } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\n\nimport {\n type AddOrDeleteLineOperationValue,\n type ContentChangeTypeToOperation,\n type DeleteLineOperation,\n FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const deleteLineChange: ContentChangeTypeToOperation<DeleteLineOperation> = {\n type: WorkflowContentChangeType.DELETE_LINE,\n toOperation: (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const line = event.entity as WorkflowLineEntity;\n const value: AddOrDeleteLineOperationValue = {\n from: line.info.from,\n to: line.info.to || '',\n fromPort: line.info.fromPort || '',\n toPort: line.info.toPort || '',\n id: line.id,\n };\n return {\n type: FreeOperationType.deleteLine,\n value,\n uri: config.getNodeURI(line.id),\n };\n },\n};\n","import { WorkflowDocument, delay, type WorkflowNodeJSON } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\n\nimport {\n type AddWorkflowNodeOperation,\n type ContentChangeTypeToOperation,\n FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const addNodeChange: ContentChangeTypeToOperation<AddWorkflowNodeOperation> = {\n type: WorkflowContentChangeType.ADD_NODE,\n toOperation: async (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = event.entity as FlowNodeEntity;\n const parentID = node.parent?.id;\n /**\n * 由于document.toNodeJSON依赖表单里面的default的值初始化,故此处需要等表单的初始化完成\n * 比如dataset-node/index.ts中formatOnSubmit实现需要value被初始化\n */\n await delay(10);\n const json: WorkflowNodeJSON = await document.toNodeJSON(node);\n\n return {\n type: FreeOperationType.addNode,\n value: {\n node: json,\n parentID,\n },\n uri: config.getNodeURI(node.id),\n };\n },\n};\n","import { type WorkflowLineEntity } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\n\nimport {\n type AddLineOperation,\n type AddOrDeleteLineOperationValue,\n type ContentChangeTypeToOperation,\n FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const addLineChange: ContentChangeTypeToOperation<AddLineOperation> = {\n type: WorkflowContentChangeType.ADD_LINE,\n toOperation: (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const line = event.entity as WorkflowLineEntity;\n const value: AddOrDeleteLineOperationValue = {\n from: line.info.from,\n to: line.info.to || '',\n fromPort: line.info.fromPort || '',\n toPort: line.info.toPort || '',\n id: line.id,\n };\n return {\n type: FreeOperationType.addLine,\n value,\n uri: config.getLineURI(line.id),\n };\n },\n};\n","import { deleteNodeChange } from './delete-node-change';\nimport { deleteLineChange } from './delete-line-change';\nimport { addNodeChange } from './add-node-change';\nimport { addLineChange } from './add-line-change';\n\nexport default [addLineChange, deleteLineChange, addNodeChange, deleteNodeChange];\n","import { injectable } from 'inversify';\nimport { type OperationContribution, type OperationRegistry } from '@flowgram.ai/history';\n\nimport { operationMetas } from './operation-metas';\n\n@injectable()\nexport class FreeHistoryRegisters implements OperationContribution {\n registerOperationMeta(operationRegistry: OperationRegistry): void {\n operationMetas.forEach(operationMeta => {\n operationRegistry.registerOperationMeta(operationMeta);\n });\n }\n}\n","import { type PluginContext } from '@flowgram.ai/core';\nimport { WorkflowResetLayoutService } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { FreeOperationType, type ResetLayoutOperationValue } from '../types';\nimport { baseOperationMeta } from './base';\n\nexport const resetLayoutOperationMeta: OperationMeta<\n ResetLayoutOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: FreeOperationType.resetLayout,\n inverse: op => ({\n ...op,\n value: {\n ...op.value,\n value: op.value.oldValue,\n oldValue: op.value.value,\n },\n }),\n apply: async (operation, ctx: PluginContext) => {\n const reset = ctx.get<WorkflowResetLayoutService>(WorkflowResetLayoutService);\n await reset.layoutToPositions(operation.value.ids, operation.value.value);\n },\n shouldMerge: () => false,\n};\n","import { type OperationMeta } from '@flowgram.ai/history';\n\nexport const baseOperationMeta: Partial<OperationMeta> = {\n shouldMerge: (_op, prev, element) => {\n if (!prev) {\n return false;\n }\n\n if (\n // 合并500ms内的操作, 如删除节点会联动删除线条\n Date.now() - element.getTimestamp() <\n 500\n ) {\n return true;\n }\n return false;\n },\n};\n","import { OperationMeta } from '@flowgram.ai/history';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { MoveChildNodesOperationValue, OperationType } from '@flowgram.ai/document';\nimport { FlowNodeBaseType } from '@flowgram.ai/document';\nimport { PluginContext, TransformData } from '@flowgram.ai/core';\n\nimport { baseOperationMeta } from './base';\n\nexport const moveChildNodesOperationMeta: OperationMeta<\n MoveChildNodesOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: OperationType.moveChildNodes,\n inverse: (op) => ({\n ...op,\n value: {\n ...op.value,\n fromIndex: op.value.toIndex,\n toIndex: op.value.fromIndex,\n fromParentId: op.value.toParentId,\n toParentId: op.value.fromParentId,\n },\n }),\n apply: (operation, ctx: PluginContext) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n document.moveChildNodes(operation.value);\n const fromContainer = document.getNode(operation.value.fromParentId);\n requestAnimationFrame(() => {\n if (fromContainer && fromContainer.flowNodeType !== FlowNodeBaseType.ROOT) {\n const fromContainerTransformData = fromContainer.getData(TransformData);\n fromContainerTransformData.fireChange();\n }\n });\n },\n};\n","import { type OperationMeta } from '@flowgram.ai/history';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { FlowNodeTransformData } from '@flowgram.ai/document';\nimport { type PluginContext, TransformData } from '@flowgram.ai/core';\n\nimport { type DragNodeOperationValue, FreeOperationType } from '../types';\nimport { baseOperationMeta } from './base';\n\nexport const dragNodesOperationMeta: OperationMeta<DragNodeOperationValue, PluginContext, void> = {\n ...baseOperationMeta,\n type: FreeOperationType.dragNodes,\n inverse: (op) => ({\n ...op,\n value: {\n ...op.value,\n value: op.value.oldValue,\n oldValue: op.value.value,\n },\n }),\n apply: (operation, ctx) => {\n operation.value.ids.forEach((id, index) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = document.getNode(id);\n if (!node) {\n return;\n }\n\n const transform = node.getData(TransformData);\n const point = operation.value.value[index];\n transform.update({\n position: {\n x: point.x,\n y: point.y,\n },\n });\n // 嵌套情况下需将子节点 transform 设为 dirty\n if (node.collapsedChildren?.length > 0) {\n node.collapsedChildren.forEach((childNode) => {\n const childNodeTransformData =\n childNode.getData<FlowNodeTransformData>(FlowNodeTransformData);\n childNodeTransformData.fireChange();\n });\n }\n });\n },\n};\n","import { type PluginContext } from '@flowgram.ai/core';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { type AddOrDeleteWorkflowNodeOperationValue, FreeOperationType } from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\nimport { baseOperationMeta } from './base';\n\nexport const deleteNodeOperationMeta: OperationMeta<\n AddOrDeleteWorkflowNodeOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: FreeOperationType.deleteNode,\n inverse: op => ({\n ...op,\n type: FreeOperationType.addNode,\n }),\n apply: (operation, ctx: PluginContext) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = document.getNode(operation.value.node.id);\n if (node) {\n node.dispose();\n }\n },\n getLabel: (op, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n return `Delete Node ${config.getNodeLabel(op.value.node)}`;\n },\n getDescription: (op, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n let desc = `Delete Node ${config.getNodeLabel(op.value.node)}`;\n if (op.value.node.meta?.position) {\n desc += ` at ${op.value.node.meta.position.x},${op.value.node.meta.position.y}`;\n }\n return desc;\n },\n};\n","import { type OperationMeta } from '@flowgram.ai/history';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { type PluginContext } from '@flowgram.ai/core';\n\nimport { type AddOrDeleteLineOperationValue, FreeOperationType } from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\nimport { baseOperationMeta } from './base';\n\nexport const deleteLineOperationMeta: OperationMeta<\n AddOrDeleteLineOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: FreeOperationType.deleteLine,\n inverse: (op) => ({\n ...op,\n type: FreeOperationType.addLine,\n }),\n apply: (operation, ctx: PluginContext) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n document.removeNode(operation.value.id);\n },\n getLabel: (op, ctx) => 'Delete Line',\n getDescription: (op, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const { value } = op;\n if (!value.from || !value.to) {\n return 'Delete Line';\n }\n\n const fromName = config.getNodeLabelById(value.from);\n const toName = config.getNodeLabelById(value.to);\n return `Delete Line from ${fromName} to ${toName}`;\n },\n};\n","import { FlowNodeFormData } from '@flowgram.ai/form-core';\nimport { type PluginContext } from '@flowgram.ai/core';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { FreeOperationType, type ChangeNodeDataValue } from '../types';\nimport { baseOperationMeta } from './base';\n\nexport const changeNodeDataOperationMeta: OperationMeta<ChangeNodeDataValue, PluginContext, void> =\n {\n ...baseOperationMeta,\n type: FreeOperationType.changeNodeData,\n inverse: op => ({\n ...op,\n value: {\n ...op.value,\n value: op.value.oldValue,\n oldValue: op.value.value,\n },\n }),\n apply: (operation, ctx: PluginContext) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = document.getNode(operation.value.id);\n\n if (!node) {\n return;\n }\n const formData = node.getData(FlowNodeFormData);\n\n if (!formData) {\n return;\n }\n\n let { path } = operation.value;\n if (path.endsWith('/') && path !== '/') {\n path = path.slice(0, -1);\n }\n\n if (!path.startsWith('/')) {\n path = `/${path}`;\n }\n\n const formItem = formData.formModel.getFormItemByPath(path);\n\n if (!formItem) {\n return;\n }\n formItem.value = operation.value.value;\n },\n shouldMerge: (op, prev, element) => {\n if (!prev) {\n return false;\n }\n\n if (Date.now() - element.getTimestamp() < 500) {\n if (\n op.type === prev.type && // 相同类型\n op.value.id === prev.value.id && // 相同节点\n op.value?.path === prev.value?.path // 相同路径\n ) {\n return {\n type: op.type,\n value: {\n ...op.value,\n value: op.value.value,\n oldValue: prev.value.oldValue,\n },\n };\n }\n return true;\n }\n return false;\n },\n };\n","import { cloneDeep } from 'lodash';\nimport { type PluginContext } from '@flowgram.ai/core';\nimport { WorkflowDocument, type WorkflowNodeJSON } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { type AddOrDeleteWorkflowNodeOperationValue, FreeOperationType } from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\nimport { baseOperationMeta } from './base';\n\nexport const addNodeOperationMeta: OperationMeta<\n AddOrDeleteWorkflowNodeOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: FreeOperationType.addNode,\n inverse: op => ({\n ...op,\n type: FreeOperationType.deleteNode,\n }),\n apply: async (operation, ctx: PluginContext) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n await document.createWorkflowNode(\n cloneDeep(operation.value.node) as WorkflowNodeJSON,\n false,\n operation.value.parentID,\n );\n },\n getLabel: (op, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n return `Create Node ${config.getNodeLabel(op.value.node)}`;\n },\n getDescription: (op, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n let desc = `Create Node ${config.getNodeLabel(op.value.node)}`;\n if (op.value.node.meta?.position) {\n desc += ` at ${op.value.node.meta.position.x},${op.value.node.meta.position.y}`;\n }\n return desc;\n },\n};\n","import { type PluginContext } from '@flowgram.ai/core';\nimport { WorkflowLinesManager } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { type AddOrDeleteLineOperationValue, FreeOperationType } from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\nimport { baseOperationMeta } from './base';\n\nexport const addLineOperationMeta: OperationMeta<\n AddOrDeleteLineOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: FreeOperationType.addLine,\n inverse: op => ({\n ...op,\n type: FreeOperationType.deleteLine,\n }),\n apply: (operation, ctx: PluginContext) => {\n const linesManager = ctx.get<WorkflowLinesManager>(WorkflowLinesManager);\n linesManager.createLine({\n ...operation.value,\n key: operation.value.id,\n });\n },\n getLabel: (op, ctx) => 'Create Line',\n getDescription: (op, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const { value } = op;\n if (!value.from || !value.to) {\n return 'Create Line';\n }\n\n const fromName = config.getNodeLabelById(value.from);\n const toName = config.getNodeLabelById(value.to);\n return `Create Line from ${fromName} to ${toName}`;\n },\n};\n","import { resetLayoutOperationMeta } from './reset-layout';\nimport { moveChildNodesOperationMeta } from './move-child-nodes';\nimport { dragNodesOperationMeta } from './drag-nodes';\nimport { deleteNodeOperationMeta } from './delete-node';\nimport { deleteLineOperationMeta } from './delete-line';\nimport { changeNodeDataOperationMeta } from './change-node-data';\nimport { addNodeOperationMeta } from './add-node';\nimport { addLineOperationMeta } from './add-line';\n\nexport const operationMetas = [\n addLineOperationMeta,\n deleteLineOperationMeta,\n addNodeOperationMeta,\n deleteNodeOperationMeta,\n changeNodeDataOperationMeta,\n resetLayoutOperationMeta,\n dragNodesOperationMeta,\n moveChildNodesOperationMeta,\n];\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { cloneDeep } from 'lodash';\nimport { injectable, inject, optional } from 'inversify';\nimport { DisposableCollection, Disposable } from '@flowgram.ai/utils';\nimport { HistoryService } from '@flowgram.ai/history';\nimport {\n WorkflowDocument,\n WorkflowResetLayoutService,\n WorkflowDragService,\n WorkflowOperationBaseService,\n} from '@flowgram.ai/free-layout-core';\nimport { FlowNodeFormData } from '@flowgram.ai/form-core';\nimport { FormManager } from '@flowgram.ai/form-core';\nimport { OperationType } from '@flowgram.ai/document';\nimport { type PluginContext, PositionData } from '@flowgram.ai/core';\n\nimport { DragNodeOperationValue, type FreeHistoryPluginOptions, FreeOperationType } from './types';\nimport { HistoryEntityManager } from './history-entity-manager';\nimport { DragNodesHandler } from './handlers/drag-nodes-handler';\nimport { ChangeNodeDataHandler } from './handlers/change-node-data-handler';\nimport { ChangeContentHandler } from './handlers/change-content-handler';\n\n/**\n * 历史管理\n */\n@injectable()\nexport class FreeHistoryManager {\n @inject(DragNodesHandler)\n private _dragNodesHandler: DragNodesHandler;\n\n @inject(ChangeNodeDataHandler)\n private _changeNodeDataHandler: ChangeNodeDataHandler;\n\n @inject(ChangeContentHandler)\n private _changeContentHandler: ChangeContentHandler;\n\n @inject(HistoryEntityManager)\n private _entityManager: HistoryEntityManager;\n\n @inject(FormManager)\n @optional()\n private _formManager?: FormManager;\n\n private _toDispose: DisposableCollection = new DisposableCollection();\n\n @inject(WorkflowOperationBaseService)\n private _operationService: WorkflowOperationBaseService;\n\n onInit(ctx: PluginContext, opts: FreeHistoryPluginOptions) {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const historyService = ctx.get<HistoryService>(HistoryService);\n const dragService = ctx.get<WorkflowDragService>(WorkflowDragService);\n\n const resetLayoutService = ctx.get<WorkflowResetLayoutService>(WorkflowResetLayoutService);\n\n if (opts?.limit) {\n historyService.limit(opts.limit);\n }\n historyService.context.source = ctx;\n\n this._toDispose.pushAll([\n dragService.onNodesDrag(async (event) => {\n if (event.type !== 'onDragEnd') {\n return;\n }\n this._dragNodesHandler.handle(event);\n }),\n document.onNodeCreate(({ node, data }) => {\n const positionData = node.getData(PositionData);\n if (positionData) {\n this._entityManager.addEntityData(positionData);\n }\n }),\n this._formManager\n ? this._formManager.onFormModelWillInit(({ model, data }) => {\n const node = model.flowNodeEntity;\n const formData = node.getData<FlowNodeFormData>(FlowNodeFormData);\n\n if (formData) {\n this._entityManager.setValue(formData, cloneDeep(data));\n\n this._toDispose.push(\n formData.onDetailChange((event) => {\n this._changeNodeDataHandler.handle({\n ...event,\n node,\n });\n })\n );\n }\n })\n : Disposable.NULL,\n document.onContentChange(async (event) => {\n await this._changeContentHandler.handle(event, ctx);\n }),\n document.onReload((_event) => {\n historyService.clear();\n }),\n resetLayoutService.onResetLayout((event) => {\n historyService.pushOperation(\n {\n type: FreeOperationType.resetLayout,\n value: {\n ids: event.nodeIds,\n value: event.positionMap,\n oldValue: event.oldPositionMap,\n },\n },\n { noApply: true }\n );\n }),\n this._operationService.onNodeMove(({ node, fromParent, fromIndex, toParent, toIndex }) => {\n historyService.pushOperation(\n {\n type: OperationType.moveChildNodes,\n value: {\n fromParentId: fromParent.id,\n fromIndex,\n nodeIds: [node.id],\n toParentId: toParent.id,\n toIndex,\n },\n },\n {\n noApply: true,\n }\n );\n }),\n this._operationService.onNodePostionUpdate((event) => {\n const value: DragNodeOperationValue = {\n ids: [event.node.id],\n value: [event.newPosition],\n oldValue: [event.oldPosition],\n };\n historyService.pushOperation(\n {\n type: FreeOperationType.dragNodes,\n value,\n },\n {\n noApply: true,\n }\n );\n }),\n ]);\n }\n\n dispose() {\n this._entityManager.dispose();\n this._toDispose.dispose();\n }\n}\n","export * from './create-free-history-plugin';\nexport * from './types';\nexport * from '@flowgram.ai/history';\nexport * from './free-history-config';\nexport * from './hooks';\nexport * from './free-history-registers';\n","import { useEffect, useState } from 'react';\n\nimport { useService } from '@flowgram.ai/core';\nimport { HistoryService } from '@flowgram.ai/history';\n\ninterface UndoRedo {\n canUndo: boolean;\n canRedo: boolean;\n undo: () => Promise<void>;\n redo: () => Promise<void>;\n}\n\nexport function useUndoRedo(): UndoRedo {\n const historyService = useService<HistoryService>(HistoryService);\n const [canUndo, setCanUndo] = useState(false);\n const [canRedo, setCanRedo] = useState(false);\n\n useEffect(() => {\n const toDispose = historyService.undoRedoService.onChange(() => {\n setCanUndo(historyService.canUndo());\n setCanRedo(historyService.canRedo());\n });\n return () => {\n toDispose.dispose();\n };\n }, []);\n\n return {\n canUndo,\n canRedo,\n undo: () => historyService.undo(),\n redo: () => historyService.redo(),\n };\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,mBAAmB,2BAA2B;AACvD,SAAS,wBAAwB,6BAA6B;;;ACA9D,SAAS,WAAW,eAAe;AACnC,SAAS,kBAAkB;AAE3B,SAA0B,4BAA4B;AAG/C,IAAM,uBAAN,MAAiD;AAAA,EAAjD;AACL,SAAQ,oBAA8C,oBAAI,IAAI;AAE9D,SAAQ,aAAmC,IAAI,qBAAqB;AAAA;AAAA,EAEpE,cAAc,YAAwB;AACpC,SAAK,kBAAkB,IAAI,YAAY,UAAU,WAAW,OAAO,CAAC,CAAC;AACrE,SAAK,WAAW;AAAA,MACd,WAAW,aAAa,WAAS;AAC/B,cAAM,QAAQ,MAAM,OAAO;AAC3B,cAAM,WAAW,KAAK,kBAAkB,IAAI,UAAU;AACtD,YAAI,QAAQ,OAAO,QAAQ,GAAG;AAC5B;AAAA,QACF;AACA,aAAK,kBAAkB,IAAI,YAAY,UAAU,KAAK,CAAC;AAAA,MACzD,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEA,SAAS,YAAwB;AAC/B,WAAO,KAAK,kBAAkB,IAAI,UAAU;AAAA,EAC9C;AAAA,EAEA,SAAS,YAAwB,OAAgB;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AAC;AAAA,IACrC,CAAC;AACD,WAAO,MAAM;AACX,gBAAU,QAAQ;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,MAAM,MAAM,eAAe,KAAK;AAAA,IAChC,MAAM,MAAM,eAAe,KAAK;AAAA,EAClC;AACF;","names":["injectable","FreeOperationType","injectable","cloneDeep","isEqual","injectable","inject","HistoryService","injectable","injectable","isEqual","cloneDeep","inject","HistoryService","injectable","injectable","inject","HistoryService","WorkflowDocument","WorkflowDocument","WorkflowContentChangeType","WorkflowContentChangeType","WorkflowDocument","delay","WorkflowContentChangeType","WorkflowContentChangeType","WorkflowDocument","delay","WorkflowContentChangeType","WorkflowContentChangeType","inject","HistoryService","injectable","injectable","WorkflowDocument","TransformData","WorkflowDocument","TransformData","WorkflowDocument","TransformData","WorkflowDocument","TransformData","WorkflowDocument","WorkflowDocument","WorkflowDocument","WorkflowDocument","FlowNodeFormData","WorkflowDocument","WorkflowDocument","FlowNodeFormData","cloneDeep","WorkflowDocument","WorkflowDocument","cloneDeep","injectable","cloneDeep","injectable","inject","DisposableCollection","HistoryService","WorkflowDocument","WorkflowResetLayoutService","FlowNodeFormData","OperationType","DisposableCollection","WorkflowDocument","HistoryService","WorkflowResetLayoutService","FlowNodeFormData","cloneDeep","OperationType","inject","injectable","HistoryService"]}
package/dist/index.js CHANGED
@@ -80,8 +80,8 @@ HistoryEntityManager = __decorateClass([
80
80
 
81
81
  // src/handlers/drag-nodes-handler.ts
82
82
  var import_inversify2 = require("inversify");
83
- var import_core = require("@flowgram.ai/core");
84
83
  var import_history = require("@flowgram.ai/history");
84
+ var import_core = require("@flowgram.ai/core");
85
85
 
86
86
  // src/types.ts
87
87
  var FreeOperationType = /* @__PURE__ */ ((FreeOperationType2) => {
@@ -100,7 +100,7 @@ var FreeOperationType = /* @__PURE__ */ ((FreeOperationType2) => {
100
100
  // src/handlers/drag-nodes-handler.ts
101
101
  var DragNodesHandler = class {
102
102
  handle(event) {
103
- if (event.type === "onDragEnd" && !event.altKey) {
103
+ if (event.type === "onDragEnd") {
104
104
  this._dragNode(event);
105
105
  }
106
106
  }
@@ -704,7 +704,7 @@ var FreeHistoryManager = class {
704
704
  this._entityManager.addEntityData(positionData);
705
705
  }
706
706
  }),
707
- this._formManager.onFormModelWillInit(({ model, data }) => {
707
+ this._formManager ? this._formManager.onFormModelWillInit(({ model, data }) => {
708
708
  const node = model.flowNodeEntity;
709
709
  const formData = node.getData(import_form_core3.FlowNodeFormData);
710
710
  if (formData) {
@@ -718,7 +718,7 @@ var FreeHistoryManager = class {
718
718
  })
719
719
  );
720
720
  }
721
- }),
721
+ }) : import_utils2.Disposable.NULL,
722
722
  document.onContentChange(async (event) => {
723
723
  await this._changeContentHandler.handle(event, ctx);
724
724
  }),
@@ -791,7 +791,8 @@ __decorateClass([
791
791
  (0, import_inversify7.inject)(HistoryEntityManager)
792
792
  ], FreeHistoryManager.prototype, "_entityManager", 2);
793
793
  __decorateClass([
794
- (0, import_inversify7.inject)(import_form_core4.FormManager)
794
+ (0, import_inversify7.inject)(import_form_core4.FormManager),
795
+ (0, import_inversify7.optional)()
795
796
  ], FreeHistoryManager.prototype, "_formManager", 2);
796
797
  __decorateClass([
797
798
  (0, import_inversify7.inject)(import_free_layout_core15.WorkflowOperationBaseService)
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/create-free-history-plugin.ts","../src/history-entity-manager.ts","../src/handlers/drag-nodes-handler.ts","../src/types.ts","../src/handlers/change-node-data-handler.ts","../src/free-history-config.ts","../src/handlers/change-content-handler.ts","../src/changes/delete-node-change.ts","../src/changes/delete-line-change.ts","../src/changes/add-node-change.ts","../src/changes/add-line-change.ts","../src/changes/index.ts","../src/free-history-registers.ts","../src/operation-metas/reset-layout.ts","../src/operation-metas/base.ts","../src/operation-metas/move-child-nodes.ts","../src/operation-metas/drag-nodes.ts","../src/operation-metas/delete-node.ts","../src/operation-metas/delete-line.ts","../src/operation-metas/change-node-data.ts","../src/operation-metas/add-node.ts","../src/operation-metas/add-line.ts","../src/operation-metas/index.ts","../src/free-history-manager.ts","../src/hooks/use-undo-redo.tsx"],"sourcesContent":["export * from './create-free-history-plugin';\nexport * from './types';\nexport * from '@flowgram.ai/history';\nexport * from './free-history-config';\nexport * from './hooks';\nexport * from './free-history-registers';\n","import { bindContributions, definePluginCreator } from '@flowgram.ai/core';\nimport { HistoryContainerModule, OperationContribution } from '@flowgram.ai/history';\n\nimport { type FreeHistoryPluginOptions } from './types';\nimport { HistoryEntityManager } from './history-entity-manager';\nimport { DragNodesHandler } from './handlers/drag-nodes-handler';\nimport { ChangeNodeDataHandler } from './handlers/change-node-data-handler';\nimport { ChangeContentHandler } from './handlers/change-content-handler';\nimport { FreeHistoryRegisters } from './free-history-registers';\nimport { FreeHistoryManager } from './free-history-manager';\nimport { FreeHistoryConfig } from './free-history-config';\n\nexport const createFreeHistoryPlugin = definePluginCreator<FreeHistoryPluginOptions>({\n onBind: ({ bind }) => {\n bindContributions(bind, FreeHistoryRegisters, [OperationContribution]);\n bind(FreeHistoryConfig).toSelf().inSingletonScope();\n bind(FreeHistoryManager).toSelf().inSingletonScope();\n bind(HistoryEntityManager).toSelf().inSingletonScope();\n bind(DragNodesHandler).toSelf().inSingletonScope();\n bind(ChangeNodeDataHandler).toSelf().inSingletonScope();\n bind(ChangeContentHandler).toSelf().inSingletonScope();\n },\n onInit(ctx, opts): void {\n ctx.get<FreeHistoryConfig>(FreeHistoryConfig).init(ctx, opts);\n\n if (!opts.enable) {\n return;\n }\n ctx.get<FreeHistoryManager>(FreeHistoryManager).onInit(ctx, opts);\n },\n onDispose(ctx) {\n ctx.get<HistoryEntityManager>(HistoryEntityManager).dispose();\n },\n containerModules: [HistoryContainerModule],\n});\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { cloneDeep, isEqual } from 'lodash';\nimport { injectable } from 'inversify';\nimport { type EntityData } from '@flowgram.ai/core';\nimport { type Disposable, DisposableCollection } from '@flowgram.ai/utils';\n\n@injectable()\nexport class HistoryEntityManager implements Disposable {\n private _entityDataValues: Map<EntityData, unknown> = new Map();\n\n private _toDispose: DisposableCollection = new DisposableCollection();\n\n addEntityData(entityData: EntityData) {\n this._entityDataValues.set(entityData, cloneDeep(entityData.toJSON()));\n this._toDispose.push(\n entityData.onWillChange(event => {\n const value = event.toJSON();\n const oldValue = this._entityDataValues.get(entityData);\n if (isEqual(value, oldValue)) {\n return;\n }\n this._entityDataValues.set(entityData, cloneDeep(value));\n }),\n );\n }\n\n getValue(entityData: EntityData) {\n return this._entityDataValues.get(entityData);\n }\n\n setValue(entityData: EntityData, value: unknown) {\n return this._entityDataValues.set(entityData, value);\n }\n\n dispose() {\n this._entityDataValues.clear();\n this._toDispose.dispose();\n }\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { injectable, inject } from 'inversify';\nimport { TransformData } from '@flowgram.ai/core';\nimport { type NodesDragEndEvent } from '@flowgram.ai/free-layout-core';\nimport { HistoryService } from '@flowgram.ai/history';\n\nimport { FreeOperationType, type IHandler } from '../types';\n\n@injectable()\nexport class DragNodesHandler implements IHandler<NodesDragEndEvent> {\n @inject(HistoryService)\n private _historyService: HistoryService;\n\n handle(event: NodesDragEndEvent) {\n if (\n event.type === 'onDragEnd' &&\n !event.altKey // altKey代表创建,这个通过add-node监听处理\n ) {\n this._dragNode(event);\n }\n }\n\n private _dragNode(event: NodesDragEndEvent) {\n this._historyService.pushOperation(\n {\n type: FreeOperationType.dragNodes,\n value: {\n ids: event.nodes.map(node => node.id),\n value: event.nodes.map(node => {\n const { x, y } = node.getData(TransformData).position;\n return {\n x,\n y,\n };\n }),\n oldValue: event.startPositions,\n },\n },\n { noApply: true },\n );\n }\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { type IPoint } from '@flowgram.ai/utils';\nimport { type Operation, type OperationMeta } from '@flowgram.ai/history';\nimport {\n type WorkflowContentChangeType,\n type WorkflowContentChangeEvent,\n type WorkflowLineEntity,\n type WorkflowLinePortInfo,\n type WorkflowNodeJSON,\n type PositionMap,\n} from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity, type FlowNodeJSON } from '@flowgram.ai/document';\nimport { type EntityData, type PluginContext } from '@flowgram.ai/core';\n\nexport enum FreeOperationType {\n addLine = 'addLine',\n deleteLine = 'deleteLine',\n moveNode = 'moveNode',\n addNode = 'addNode',\n deleteNode = 'deleteNode',\n changeNodeData = 'changeNodeData',\n resetLayout = 'resetLayout',\n dragNodes = 'dragNodes',\n moveChildNodes = 'moveChildNodes',\n}\n\nexport interface AddOrDeleteLineOperationValue extends WorkflowLinePortInfo {\n id: string;\n}\n\nexport interface AddOrDeleteWorkflowNodeOperationValue {\n node: WorkflowNodeJSON;\n parentID?: string;\n}\n\nexport interface AddLineOperation extends Operation {\n type: FreeOperationType.addLine;\n value: AddOrDeleteLineOperationValue;\n}\n\nexport interface DeleteLineOperation extends Operation {\n type: FreeOperationType.deleteLine;\n value: AddOrDeleteLineOperationValue;\n}\n\nexport interface MoveNodeOperation extends Operation {\n type: FreeOperationType.moveNode;\n value: MoveNodeOperationValue;\n}\n\nexport interface AddWorkflowNodeOperation extends Operation {\n type: FreeOperationType.addNode;\n value: AddOrDeleteWorkflowNodeOperationValue;\n}\n\nexport interface DeleteWorkflowNodeOperation extends Operation {\n type: FreeOperationType.deleteNode;\n value: AddOrDeleteWorkflowNodeOperationValue;\n}\n\nexport interface MoveNodeOperationValue {\n id: string;\n value: {\n x: number;\n y: number;\n };\n oldValue: {\n x: number;\n y: number;\n };\n}\n\nexport interface DragNodeOperationValue {\n ids: string[];\n value: IPoint[];\n oldValue: IPoint[];\n}\n\nexport interface ResetLayoutOperationValue {\n ids: string[];\n value: PositionMap;\n oldValue: PositionMap;\n}\n\nexport interface ContentChangeTypeToOperation<T extends Operation> {\n type: WorkflowContentChangeType;\n toOperation: (\n event: WorkflowContentChangeEvent,\n ctx: PluginContext\n ) => T | undefined | Promise<T | undefined>;\n}\n\nexport interface EntityDataType {\n type: FreeOperationType;\n toEntityData: (node: FlowNodeEntity, ctx: PluginContext) => EntityData;\n}\n\nexport interface ChangeNodeDataValue {\n id: string;\n value: unknown;\n oldValue: unknown;\n path: string;\n}\n\nexport interface ChangeNodeDataOperation extends Operation {\n type: FreeOperationType.changeNodeData;\n value: ChangeNodeDataValue;\n}\n\n/**\n * 将node转成json\n */\nexport type NodeToJson = (node: FlowNodeEntity) => FlowNodeJSON;\n/**\n * 将line转成json\n */\nexport type LineToJson = (node: WorkflowLineEntity) => FlowNodeJSON;\n/**\n * 根据节点id获取label\n */\nexport type GetNodeLabelById = (id: string) => string;\n/**\n * 根据节点获取label\n */\nexport type GetNodeLabel = (node: FlowNodeJSON) => string;\n/**\n * 根据分支获取label\n */\nexport type GetBlockLabel = (node: FlowNodeJSON) => string;\n/**\n * 根据节点获取URI\n */\nexport type GetNodeURI = (id: string) => string | any;\n/**\n * 根据连线获取URI\n */\nexport type GetLineURI = (id: string) => string | any;\n\n/**\n * 插件配置\n */\nexport interface FreeHistoryPluginOptions {\n enable?: boolean;\n limit?: number;\n nodeToJSON?: (ctx: PluginContext) => NodeToJson;\n getNodeLabelById?: (ctx: PluginContext) => GetNodeLabelById;\n getNodeLabel?: (ctx: PluginContext) => GetNodeLabel;\n getBlockLabel?: (ctx: PluginContext) => GetBlockLabel;\n getNodeURI?: (ctx: PluginContext) => GetNodeURI;\n getLineURI?: (ctx: PluginContext) => GetLineURI;\n operationMetas?: OperationMeta[];\n enableChangeNode?: boolean;\n uri?: string | any;\n}\n\nexport interface IHandler<E> {\n handle: (event: E, ctx: PluginContext) => void | Promise<void>;\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { cloneDeep, get, isEqual, set } from 'lodash';\nimport { injectable, inject } from 'inversify';\nimport { FlowNodeFormData, type DetailChangeEvent } from '@flowgram.ai/form-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { HistoryService } from '@flowgram.ai/history';\n\nimport { FreeOperationType, type IHandler } from '../types';\nimport { HistoryEntityManager } from '../history-entity-manager';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport interface ChangeNodeDataEvent extends DetailChangeEvent {\n node: FlowNodeEntity;\n}\n\n@injectable()\nexport class ChangeNodeDataHandler implements IHandler<ChangeNodeDataEvent> {\n @inject(HistoryService)\n private _historyService: HistoryService;\n\n @inject(WorkflowDocument) document: WorkflowDocument;\n\n @inject(HistoryEntityManager)\n private _entityManager: HistoryEntityManager;\n\n @inject(FreeHistoryConfig)\n private _config: FreeHistoryConfig;\n\n handle(event: ChangeNodeDataEvent) {\n const { path, value, initialized, node } = event;\n const formData = node.getData<FlowNodeFormData>(FlowNodeFormData);\n const oldValue = this._entityManager.getValue(formData) as object;\n const propPath = path.split('/').filter(Boolean).join('.');\n\n const propOldValue = propPath ? get(oldValue, propPath) : oldValue;\n if (isEqual(value, propOldValue)) {\n return;\n }\n\n if (initialized) {\n let operationPath = path;\n let operationValue = cloneDeep(value);\n let operationOldValue = propOldValue;\n // 只存储一层的数据,因为formModel无法获取数组下的某项的值\n if (path !== '/') {\n const clonedOldValue = cloneDeep(oldValue);\n set(clonedOldValue, propPath, value);\n operationPath = path.split('/').filter(Boolean)[0];\n operationValue = get(clonedOldValue, operationPath);\n operationOldValue = get(oldValue, operationPath);\n }\n\n this._historyService.pushOperation(\n {\n type: FreeOperationType.changeNodeData,\n value: {\n id: node.id,\n path: operationPath,\n value: operationValue,\n oldValue: operationOldValue,\n },\n uri: this._config.getNodeURI(node.id),\n },\n { noApply: true },\n );\n }\n\n if (propPath) {\n set(oldValue, propPath, cloneDeep(value));\n } else {\n this._entityManager.setValue(formData, cloneDeep(value));\n }\n }\n}\n","import { injectable } from 'inversify';\nimport { type FlowNodeEntity, type FlowNodeJSON } from '@flowgram.ai/document';\nimport { type PluginContext } from '@flowgram.ai/core';\n\nimport {\n type FreeHistoryPluginOptions,\n type GetBlockLabel,\n type GetLineURI,\n type GetNodeLabel,\n type GetNodeLabelById,\n type GetNodeURI,\n type NodeToJson,\n} from './types';\n\n@injectable()\nexport class FreeHistoryConfig {\n init(ctx: PluginContext, options: FreeHistoryPluginOptions) {\n this.enable = !!options?.enable;\n\n if (options.nodeToJSON) {\n this.nodeToJSON = options.nodeToJSON(ctx);\n }\n\n if (options.getNodeLabelById) {\n this.getNodeLabelById = options.getNodeLabelById(ctx);\n }\n\n if (options.getNodeLabel) {\n this.getNodeLabel = options.getNodeLabel(ctx);\n }\n\n if (options.getBlockLabel) {\n this.getBlockLabel = options.getBlockLabel(ctx);\n }\n\n if (options.getNodeURI) {\n this.getNodeURI = options.getNodeURI(ctx);\n }\n\n if (options.getLineURI) {\n this.getLineURI = options.getLineURI(ctx);\n }\n }\n\n enable = false;\n\n nodeToJSON: NodeToJson = (node: FlowNodeEntity) => node.toJSON();\n\n getNodeLabelById: GetNodeLabelById = (id: string) => id;\n\n getNodeLabel: GetNodeLabel = (node: FlowNodeJSON) => node.id;\n\n getBlockLabel: GetBlockLabel = (node: FlowNodeJSON) => node.id;\n\n getNodeURI: GetNodeURI = (id: string) => `node:${id}`;\n\n getLineURI: GetLineURI = (id: string) => `line:${id}`;\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { injectable, inject } from 'inversify';\nimport { type PluginContext } from '@flowgram.ai/core';\nimport { type WorkflowContentChangeEvent } from '@flowgram.ai/free-layout-core';\nimport { HistoryService } from '@flowgram.ai/history';\n\nimport { type IHandler } from '../types';\nimport changes from '../changes';\n\n@injectable()\nexport class ChangeContentHandler implements IHandler<WorkflowContentChangeEvent> {\n @inject(HistoryService)\n private _historyService: HistoryService;\n\n async handle(event: WorkflowContentChangeEvent, ctx: PluginContext) {\n if (!this._historyService.undoRedoService.canPush()) {\n return;\n }\n\n const change = changes.find(c => c.type === event.type);\n if (!change) {\n return;\n }\n const operation = await change.toOperation(event, ctx);\n if (!operation) {\n return;\n }\n\n this._historyService.pushOperation(operation, { noApply: true });\n }\n}\n","import { WorkflowDocument, WorkflowContentChangeType, delay } from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\n\nimport {\n type ContentChangeTypeToOperation,\n FreeOperationType,\n type DeleteWorkflowNodeOperation,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const deleteNodeChange: ContentChangeTypeToOperation<DeleteWorkflowNodeOperation> = {\n type: WorkflowContentChangeType.DELETE_NODE,\n toOperation: async (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = event.entity as FlowNodeEntity;\n const json = await document.toNodeJSON(node);\n const parentID = node.parent?.id;\n\n // 删除节点和删除连线同时触发,删除节点需放在后面执行\n await delay(0);\n\n return {\n type: FreeOperationType.deleteNode,\n value: {\n node: json,\n parentID,\n },\n uri: config.getNodeURI(node.id),\n };\n },\n};\n","import { type WorkflowLineEntity } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\n\nimport {\n type AddOrDeleteLineOperationValue,\n type ContentChangeTypeToOperation,\n type DeleteLineOperation,\n FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const deleteLineChange: ContentChangeTypeToOperation<DeleteLineOperation> = {\n type: WorkflowContentChangeType.DELETE_LINE,\n toOperation: (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const line = event.entity as WorkflowLineEntity;\n const value: AddOrDeleteLineOperationValue = {\n from: line.info.from,\n to: line.info.to || '',\n fromPort: line.info.fromPort || '',\n toPort: line.info.toPort || '',\n id: line.id,\n };\n return {\n type: FreeOperationType.deleteLine,\n value,\n uri: config.getNodeURI(line.id),\n };\n },\n};\n","import { WorkflowDocument, delay, type WorkflowNodeJSON } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\n\nimport {\n type AddWorkflowNodeOperation,\n type ContentChangeTypeToOperation,\n FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const addNodeChange: ContentChangeTypeToOperation<AddWorkflowNodeOperation> = {\n type: WorkflowContentChangeType.ADD_NODE,\n toOperation: async (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = event.entity as FlowNodeEntity;\n const parentID = node.parent?.id;\n /**\n * 由于document.toNodeJSON依赖表单里面的default的值初始化,故此处需要等表单的初始化完成\n * 比如dataset-node/index.ts中formatOnSubmit实现需要value被初始化\n */\n await delay(10);\n const json: WorkflowNodeJSON = await document.toNodeJSON(node);\n\n return {\n type: FreeOperationType.addNode,\n value: {\n node: json,\n parentID,\n },\n uri: config.getNodeURI(node.id),\n };\n },\n};\n","import { type WorkflowLineEntity } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\n\nimport {\n type AddLineOperation,\n type AddOrDeleteLineOperationValue,\n type ContentChangeTypeToOperation,\n FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const addLineChange: ContentChangeTypeToOperation<AddLineOperation> = {\n type: WorkflowContentChangeType.ADD_LINE,\n toOperation: (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const line = event.entity as WorkflowLineEntity;\n const value: AddOrDeleteLineOperationValue = {\n from: line.info.from,\n to: line.info.to || '',\n fromPort: line.info.fromPort || '',\n toPort: line.info.toPort || '',\n id: line.id,\n };\n return {\n type: FreeOperationType.addLine,\n value,\n uri: config.getLineURI(line.id),\n };\n },\n};\n","import { deleteNodeChange } from './delete-node-change';\nimport { deleteLineChange } from './delete-line-change';\nimport { addNodeChange } from './add-node-change';\nimport { addLineChange } from './add-line-change';\n\nexport default [addLineChange, deleteLineChange, addNodeChange, deleteNodeChange];\n","import { injectable } from 'inversify';\nimport { type OperationContribution, type OperationRegistry } from '@flowgram.ai/history';\n\nimport { operationMetas } from './operation-metas';\n\n@injectable()\nexport class FreeHistoryRegisters implements OperationContribution {\n registerOperationMeta(operationRegistry: OperationRegistry): void {\n operationMetas.forEach(operationMeta => {\n operationRegistry.registerOperationMeta(operationMeta);\n });\n }\n}\n","import { type PluginContext } from '@flowgram.ai/core';\nimport { WorkflowResetLayoutService } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { FreeOperationType, type ResetLayoutOperationValue } from '../types';\nimport { baseOperationMeta } from './base';\n\nexport const resetLayoutOperationMeta: OperationMeta<\n ResetLayoutOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: FreeOperationType.resetLayout,\n inverse: op => ({\n ...op,\n value: {\n ...op.value,\n value: op.value.oldValue,\n oldValue: op.value.value,\n },\n }),\n apply: async (operation, ctx: PluginContext) => {\n const reset = ctx.get<WorkflowResetLayoutService>(WorkflowResetLayoutService);\n await reset.layoutToPositions(operation.value.ids, operation.value.value);\n },\n shouldMerge: () => false,\n};\n","import { type OperationMeta } from '@flowgram.ai/history';\n\nexport const baseOperationMeta: Partial<OperationMeta> = {\n shouldMerge: (_op, prev, element) => {\n if (!prev) {\n return false;\n }\n\n if (\n // 合并500ms内的操作, 如删除节点会联动删除线条\n Date.now() - element.getTimestamp() <\n 500\n ) {\n return true;\n }\n return false;\n },\n};\n","import { OperationMeta } from '@flowgram.ai/history';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { MoveChildNodesOperationValue, OperationType } from '@flowgram.ai/document';\nimport { FlowNodeBaseType } from '@flowgram.ai/document';\nimport { PluginContext, TransformData } from '@flowgram.ai/core';\n\nimport { baseOperationMeta } from './base';\n\nexport const moveChildNodesOperationMeta: OperationMeta<\n MoveChildNodesOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: OperationType.moveChildNodes,\n inverse: (op) => ({\n ...op,\n value: {\n ...op.value,\n fromIndex: op.value.toIndex,\n toIndex: op.value.fromIndex,\n fromParentId: op.value.toParentId,\n toParentId: op.value.fromParentId,\n },\n }),\n apply: (operation, ctx: PluginContext) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n document.moveChildNodes(operation.value);\n const fromContainer = document.getNode(operation.value.fromParentId);\n requestAnimationFrame(() => {\n if (fromContainer && fromContainer.flowNodeType !== FlowNodeBaseType.ROOT) {\n const fromContainerTransformData = fromContainer.getData(TransformData);\n fromContainerTransformData.fireChange();\n }\n });\n },\n};\n","import { type OperationMeta } from '@flowgram.ai/history';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { FlowNodeTransformData } from '@flowgram.ai/document';\nimport { type PluginContext, TransformData } from '@flowgram.ai/core';\n\nimport { type DragNodeOperationValue, FreeOperationType } from '../types';\nimport { baseOperationMeta } from './base';\n\nexport const dragNodesOperationMeta: OperationMeta<DragNodeOperationValue, PluginContext, void> = {\n ...baseOperationMeta,\n type: FreeOperationType.dragNodes,\n inverse: (op) => ({\n ...op,\n value: {\n ...op.value,\n value: op.value.oldValue,\n oldValue: op.value.value,\n },\n }),\n apply: (operation, ctx) => {\n operation.value.ids.forEach((id, index) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = document.getNode(id);\n if (!node) {\n return;\n }\n\n const transform = node.getData(TransformData);\n const point = operation.value.value[index];\n transform.update({\n position: {\n x: point.x,\n y: point.y,\n },\n });\n // 嵌套情况下需将子节点 transform 设为 dirty\n if (node.collapsedChildren?.length > 0) {\n node.collapsedChildren.forEach((childNode) => {\n const childNodeTransformData =\n childNode.getData<FlowNodeTransformData>(FlowNodeTransformData);\n childNodeTransformData.fireChange();\n });\n }\n });\n },\n};\n","import { type PluginContext } from '@flowgram.ai/core';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { type AddOrDeleteWorkflowNodeOperationValue, FreeOperationType } from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\nimport { baseOperationMeta } from './base';\n\nexport const deleteNodeOperationMeta: OperationMeta<\n AddOrDeleteWorkflowNodeOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: FreeOperationType.deleteNode,\n inverse: op => ({\n ...op,\n type: FreeOperationType.addNode,\n }),\n apply: (operation, ctx: PluginContext) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = document.getNode(operation.value.node.id);\n if (node) {\n node.dispose();\n }\n },\n getLabel: (op, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n return `Delete Node ${config.getNodeLabel(op.value.node)}`;\n },\n getDescription: (op, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n let desc = `Delete Node ${config.getNodeLabel(op.value.node)}`;\n if (op.value.node.meta?.position) {\n desc += ` at ${op.value.node.meta.position.x},${op.value.node.meta.position.y}`;\n }\n return desc;\n },\n};\n","import { type OperationMeta } from '@flowgram.ai/history';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { type PluginContext } from '@flowgram.ai/core';\n\nimport { type AddOrDeleteLineOperationValue, FreeOperationType } from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\nimport { baseOperationMeta } from './base';\n\nexport const deleteLineOperationMeta: OperationMeta<\n AddOrDeleteLineOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: FreeOperationType.deleteLine,\n inverse: (op) => ({\n ...op,\n type: FreeOperationType.addLine,\n }),\n apply: (operation, ctx: PluginContext) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n document.removeNode(operation.value.id);\n },\n getLabel: (op, ctx) => 'Delete Line',\n getDescription: (op, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const { value } = op;\n if (!value.from || !value.to) {\n return 'Delete Line';\n }\n\n const fromName = config.getNodeLabelById(value.from);\n const toName = config.getNodeLabelById(value.to);\n return `Delete Line from ${fromName} to ${toName}`;\n },\n};\n","import { FlowNodeFormData } from '@flowgram.ai/form-core';\nimport { type PluginContext } from '@flowgram.ai/core';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { FreeOperationType, type ChangeNodeDataValue } from '../types';\nimport { baseOperationMeta } from './base';\n\nexport const changeNodeDataOperationMeta: OperationMeta<ChangeNodeDataValue, PluginContext, void> =\n {\n ...baseOperationMeta,\n type: FreeOperationType.changeNodeData,\n inverse: op => ({\n ...op,\n value: {\n ...op.value,\n value: op.value.oldValue,\n oldValue: op.value.value,\n },\n }),\n apply: (operation, ctx: PluginContext) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = document.getNode(operation.value.id);\n\n if (!node) {\n return;\n }\n const formData = node.getData(FlowNodeFormData);\n\n if (!formData) {\n return;\n }\n\n let { path } = operation.value;\n if (path.endsWith('/') && path !== '/') {\n path = path.slice(0, -1);\n }\n\n if (!path.startsWith('/')) {\n path = `/${path}`;\n }\n\n const formItem = formData.formModel.getFormItemByPath(path);\n\n if (!formItem) {\n return;\n }\n formItem.value = operation.value.value;\n },\n shouldMerge: (op, prev, element) => {\n if (!prev) {\n return false;\n }\n\n if (Date.now() - element.getTimestamp() < 500) {\n if (\n op.type === prev.type && // 相同类型\n op.value.id === prev.value.id && // 相同节点\n op.value?.path === prev.value?.path // 相同路径\n ) {\n return {\n type: op.type,\n value: {\n ...op.value,\n value: op.value.value,\n oldValue: prev.value.oldValue,\n },\n };\n }\n return true;\n }\n return false;\n },\n };\n","import { cloneDeep } from 'lodash';\nimport { type PluginContext } from '@flowgram.ai/core';\nimport { WorkflowDocument, type WorkflowNodeJSON } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { type AddOrDeleteWorkflowNodeOperationValue, FreeOperationType } from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\nimport { baseOperationMeta } from './base';\n\nexport const addNodeOperationMeta: OperationMeta<\n AddOrDeleteWorkflowNodeOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: FreeOperationType.addNode,\n inverse: op => ({\n ...op,\n type: FreeOperationType.deleteNode,\n }),\n apply: async (operation, ctx: PluginContext) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n await document.createWorkflowNode(\n cloneDeep(operation.value.node) as WorkflowNodeJSON,\n false,\n operation.value.parentID,\n );\n },\n getLabel: (op, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n return `Create Node ${config.getNodeLabel(op.value.node)}`;\n },\n getDescription: (op, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n let desc = `Create Node ${config.getNodeLabel(op.value.node)}`;\n if (op.value.node.meta?.position) {\n desc += ` at ${op.value.node.meta.position.x},${op.value.node.meta.position.y}`;\n }\n return desc;\n },\n};\n","import { type PluginContext } from '@flowgram.ai/core';\nimport { WorkflowLinesManager } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { type AddOrDeleteLineOperationValue, FreeOperationType } from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\nimport { baseOperationMeta } from './base';\n\nexport const addLineOperationMeta: OperationMeta<\n AddOrDeleteLineOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: FreeOperationType.addLine,\n inverse: op => ({\n ...op,\n type: FreeOperationType.deleteLine,\n }),\n apply: (operation, ctx: PluginContext) => {\n const linesManager = ctx.get<WorkflowLinesManager>(WorkflowLinesManager);\n linesManager.createLine({\n ...operation.value,\n key: operation.value.id,\n });\n },\n getLabel: (op, ctx) => 'Create Line',\n getDescription: (op, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const { value } = op;\n if (!value.from || !value.to) {\n return 'Create Line';\n }\n\n const fromName = config.getNodeLabelById(value.from);\n const toName = config.getNodeLabelById(value.to);\n return `Create Line from ${fromName} to ${toName}`;\n },\n};\n","import { resetLayoutOperationMeta } from './reset-layout';\nimport { moveChildNodesOperationMeta } from './move-child-nodes';\nimport { dragNodesOperationMeta } from './drag-nodes';\nimport { deleteNodeOperationMeta } from './delete-node';\nimport { deleteLineOperationMeta } from './delete-line';\nimport { changeNodeDataOperationMeta } from './change-node-data';\nimport { addNodeOperationMeta } from './add-node';\nimport { addLineOperationMeta } from './add-line';\n\nexport const operationMetas = [\n addLineOperationMeta,\n deleteLineOperationMeta,\n addNodeOperationMeta,\n deleteNodeOperationMeta,\n changeNodeDataOperationMeta,\n resetLayoutOperationMeta,\n dragNodesOperationMeta,\n moveChildNodesOperationMeta,\n];\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { cloneDeep } from 'lodash';\nimport { injectable, inject } from 'inversify';\nimport { DisposableCollection } from '@flowgram.ai/utils';\nimport { HistoryService } from '@flowgram.ai/history';\nimport {\n WorkflowDocument,\n WorkflowResetLayoutService,\n WorkflowDragService,\n WorkflowOperationBaseService,\n} from '@flowgram.ai/free-layout-core';\nimport { FlowNodeFormData } from '@flowgram.ai/form-core';\nimport { FormManager } from '@flowgram.ai/form-core';\nimport { OperationType } from '@flowgram.ai/document';\nimport { type PluginContext, PositionData } from '@flowgram.ai/core';\n\nimport { DragNodeOperationValue, type FreeHistoryPluginOptions, FreeOperationType } from './types';\nimport { HistoryEntityManager } from './history-entity-manager';\nimport { DragNodesHandler } from './handlers/drag-nodes-handler';\nimport { ChangeNodeDataHandler } from './handlers/change-node-data-handler';\nimport { ChangeContentHandler } from './handlers/change-content-handler';\n\n/**\n * 历史管理\n */\n@injectable()\nexport class FreeHistoryManager {\n @inject(DragNodesHandler)\n private _dragNodesHandler: DragNodesHandler;\n\n @inject(ChangeNodeDataHandler)\n private _changeNodeDataHandler: ChangeNodeDataHandler;\n\n @inject(ChangeContentHandler)\n private _changeContentHandler: ChangeContentHandler;\n\n @inject(HistoryEntityManager)\n private _entityManager: HistoryEntityManager;\n\n @inject(FormManager)\n private _formManager: FormManager;\n\n private _toDispose: DisposableCollection = new DisposableCollection();\n\n @inject(WorkflowOperationBaseService)\n private _operationService: WorkflowOperationBaseService;\n\n onInit(ctx: PluginContext, opts: FreeHistoryPluginOptions) {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const historyService = ctx.get<HistoryService>(HistoryService);\n const dragService = ctx.get<WorkflowDragService>(WorkflowDragService);\n\n const resetLayoutService = ctx.get<WorkflowResetLayoutService>(WorkflowResetLayoutService);\n\n if (opts?.limit) {\n historyService.limit(opts.limit);\n }\n historyService.context.source = ctx;\n\n this._toDispose.pushAll([\n dragService.onNodesDrag(async (event) => {\n if (event.type !== 'onDragEnd') {\n return;\n }\n this._dragNodesHandler.handle(event);\n }),\n document.onNodeCreate(({ node, data }) => {\n const positionData = node.getData(PositionData);\n if (positionData) {\n this._entityManager.addEntityData(positionData);\n }\n }),\n this._formManager.onFormModelWillInit(({ model, data }) => {\n const node = model.flowNodeEntity;\n const formData = node.getData<FlowNodeFormData>(FlowNodeFormData);\n\n if (formData) {\n this._entityManager.setValue(formData, cloneDeep(data));\n\n this._toDispose.push(\n formData.onDetailChange((event) => {\n this._changeNodeDataHandler.handle({\n ...event,\n node,\n });\n })\n );\n }\n }),\n document.onContentChange(async (event) => {\n await this._changeContentHandler.handle(event, ctx);\n }),\n document.onReload((_event) => {\n historyService.clear();\n }),\n resetLayoutService.onResetLayout((event) => {\n historyService.pushOperation(\n {\n type: FreeOperationType.resetLayout,\n value: {\n ids: event.nodeIds,\n value: event.positionMap,\n oldValue: event.oldPositionMap,\n },\n },\n { noApply: true }\n );\n }),\n this._operationService.onNodeMove(({ node, fromParent, fromIndex, toParent, toIndex }) => {\n historyService.pushOperation(\n {\n type: OperationType.moveChildNodes,\n value: {\n fromParentId: fromParent.id,\n fromIndex,\n nodeIds: [node.id],\n toParentId: toParent.id,\n toIndex,\n },\n },\n {\n noApply: true,\n }\n );\n }),\n this._operationService.onNodePostionUpdate((event) => {\n const value: DragNodeOperationValue = {\n ids: [event.node.id],\n value: [event.newPosition],\n oldValue: [event.oldPosition],\n };\n historyService.pushOperation(\n {\n type: FreeOperationType.dragNodes,\n value,\n },\n {\n noApply: true,\n }\n );\n }),\n ]);\n }\n\n dispose() {\n this._entityManager.dispose();\n this._toDispose.dispose();\n }\n}\n","import { useEffect, useState } from 'react';\n\nimport { useService } from '@flowgram.ai/core';\nimport { HistoryService } from '@flowgram.ai/history';\n\ninterface UndoRedo {\n canUndo: boolean;\n canRedo: boolean;\n undo: () => Promise<void>;\n redo: () => Promise<void>;\n}\n\nexport function useUndoRedo(): UndoRedo {\n const historyService = useService<HistoryService>(HistoryService);\n const [canUndo, setCanUndo] = useState(false);\n const [canRedo, setCanRedo] = useState(false);\n\n useEffect(() => {\n const toDispose = historyService.undoRedoService.onChange(() => {\n setCanUndo(historyService.canUndo());\n setCanRedo(historyService.canRedo());\n });\n return () => {\n toDispose.dispose();\n };\n }, []);\n\n return {\n canUndo,\n canRedo,\n undo: () => historyService.undo(),\n redo: () => historyService.redo(),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eAAuD;AACvD,IAAAC,kBAA8D;;;ACA9D,oBAAmC;AACnC,uBAA2B;AAE3B,mBAAsD;AAG/C,IAAM,uBAAN,MAAiD;AAAA,EAAjD;AACL,SAAQ,oBAA8C,oBAAI,IAAI;AAE9D,SAAQ,aAAmC,IAAI,kCAAqB;AAAA;AAAA,EAEpE,cAAc,YAAwB;AACpC,SAAK,kBAAkB,IAAI,gBAAY,yBAAU,WAAW,OAAO,CAAC,CAAC;AACrE,SAAK,WAAW;AAAA,MACd,WAAW,aAAa,WAAS;AAC/B,cAAM,QAAQ,MAAM,OAAO;AAC3B,cAAM,WAAW,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,MAAM,eAAe,KAAK;AAAA,IAChC,MAAM,MAAM,eAAe,KAAK;AAAA,EAClC;AACF;","names":["import_core","import_history","import_inversify","FreeOperationType","import_lodash","import_inversify","import_history","import_inversify","import_inversify","import_history","import_free_layout_core","import_free_layout_core","import_free_layout_core","import_free_layout_core","import_inversify","import_free_layout_core","import_free_layout_core","import_document","import_core","import_free_layout_core","import_document","import_core","import_free_layout_core","import_free_layout_core","import_form_core","import_free_layout_core","import_lodash","import_free_layout_core","import_free_layout_core","import_lodash","import_inversify","import_utils","import_history","import_free_layout_core","import_form_core","import_document","import_core","import_core","import_history"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/create-free-history-plugin.ts","../src/history-entity-manager.ts","../src/handlers/drag-nodes-handler.ts","../src/types.ts","../src/handlers/change-node-data-handler.ts","../src/free-history-config.ts","../src/handlers/change-content-handler.ts","../src/changes/delete-node-change.ts","../src/changes/delete-line-change.ts","../src/changes/add-node-change.ts","../src/changes/add-line-change.ts","../src/changes/index.ts","../src/free-history-registers.ts","../src/operation-metas/reset-layout.ts","../src/operation-metas/base.ts","../src/operation-metas/move-child-nodes.ts","../src/operation-metas/drag-nodes.ts","../src/operation-metas/delete-node.ts","../src/operation-metas/delete-line.ts","../src/operation-metas/change-node-data.ts","../src/operation-metas/add-node.ts","../src/operation-metas/add-line.ts","../src/operation-metas/index.ts","../src/free-history-manager.ts","../src/hooks/use-undo-redo.tsx"],"sourcesContent":["export * from './create-free-history-plugin';\nexport * from './types';\nexport * from '@flowgram.ai/history';\nexport * from './free-history-config';\nexport * from './hooks';\nexport * from './free-history-registers';\n","import { bindContributions, definePluginCreator } from '@flowgram.ai/core';\nimport { HistoryContainerModule, OperationContribution } from '@flowgram.ai/history';\n\nimport { type FreeHistoryPluginOptions } from './types';\nimport { HistoryEntityManager } from './history-entity-manager';\nimport { DragNodesHandler } from './handlers/drag-nodes-handler';\nimport { ChangeNodeDataHandler } from './handlers/change-node-data-handler';\nimport { ChangeContentHandler } from './handlers/change-content-handler';\nimport { FreeHistoryRegisters } from './free-history-registers';\nimport { FreeHistoryManager } from './free-history-manager';\nimport { FreeHistoryConfig } from './free-history-config';\n\nexport const createFreeHistoryPlugin = definePluginCreator<FreeHistoryPluginOptions>({\n onBind: ({ bind }) => {\n bindContributions(bind, FreeHistoryRegisters, [OperationContribution]);\n bind(FreeHistoryConfig).toSelf().inSingletonScope();\n bind(FreeHistoryManager).toSelf().inSingletonScope();\n bind(HistoryEntityManager).toSelf().inSingletonScope();\n bind(DragNodesHandler).toSelf().inSingletonScope();\n bind(ChangeNodeDataHandler).toSelf().inSingletonScope();\n bind(ChangeContentHandler).toSelf().inSingletonScope();\n },\n onInit(ctx, opts): void {\n ctx.get<FreeHistoryConfig>(FreeHistoryConfig).init(ctx, opts);\n\n if (!opts.enable) {\n return;\n }\n ctx.get<FreeHistoryManager>(FreeHistoryManager).onInit(ctx, opts);\n },\n onDispose(ctx) {\n ctx.get<HistoryEntityManager>(HistoryEntityManager).dispose();\n },\n containerModules: [HistoryContainerModule],\n});\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { cloneDeep, isEqual } from 'lodash';\nimport { injectable } from 'inversify';\nimport { type EntityData } from '@flowgram.ai/core';\nimport { type Disposable, DisposableCollection } from '@flowgram.ai/utils';\n\n@injectable()\nexport class HistoryEntityManager implements Disposable {\n private _entityDataValues: Map<EntityData, unknown> = new Map();\n\n private _toDispose: DisposableCollection = new DisposableCollection();\n\n addEntityData(entityData: EntityData) {\n this._entityDataValues.set(entityData, cloneDeep(entityData.toJSON()));\n this._toDispose.push(\n entityData.onWillChange(event => {\n const value = event.toJSON();\n const oldValue = this._entityDataValues.get(entityData);\n if (isEqual(value, oldValue)) {\n return;\n }\n this._entityDataValues.set(entityData, cloneDeep(value));\n }),\n );\n }\n\n getValue(entityData: EntityData) {\n return this._entityDataValues.get(entityData);\n }\n\n setValue(entityData: EntityData, value: unknown) {\n return this._entityDataValues.set(entityData, value);\n }\n\n dispose() {\n this._entityDataValues.clear();\n this._toDispose.dispose();\n }\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { injectable, inject } from 'inversify';\nimport { HistoryService } from '@flowgram.ai/history';\nimport { type NodesDragEndEvent } from '@flowgram.ai/free-layout-core';\nimport { TransformData } from '@flowgram.ai/core';\n\nimport { FreeOperationType, type IHandler } from '../types';\n\n@injectable()\nexport class DragNodesHandler implements IHandler<NodesDragEndEvent> {\n @inject(HistoryService)\n private _historyService: HistoryService;\n\n handle(event: NodesDragEndEvent) {\n if (event.type === 'onDragEnd') {\n this._dragNode(event);\n }\n }\n\n private _dragNode(event: NodesDragEndEvent) {\n this._historyService.pushOperation(\n {\n type: FreeOperationType.dragNodes,\n value: {\n ids: event.nodes.map((node) => node.id),\n value: event.nodes.map((node) => {\n const { x, y } = node.getData(TransformData).position;\n return {\n x,\n y,\n };\n }),\n oldValue: event.startPositions,\n },\n },\n { noApply: true }\n );\n }\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { type IPoint } from '@flowgram.ai/utils';\nimport { type Operation, type OperationMeta } from '@flowgram.ai/history';\nimport {\n type WorkflowContentChangeType,\n type WorkflowContentChangeEvent,\n type WorkflowLineEntity,\n type WorkflowLinePortInfo,\n type WorkflowNodeJSON,\n type PositionMap,\n} from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity, type FlowNodeJSON } from '@flowgram.ai/document';\nimport { type EntityData, type PluginContext } from '@flowgram.ai/core';\n\nexport enum FreeOperationType {\n addLine = 'addLine',\n deleteLine = 'deleteLine',\n moveNode = 'moveNode',\n addNode = 'addNode',\n deleteNode = 'deleteNode',\n changeNodeData = 'changeNodeData',\n resetLayout = 'resetLayout',\n dragNodes = 'dragNodes',\n moveChildNodes = 'moveChildNodes',\n}\n\nexport interface AddOrDeleteLineOperationValue extends WorkflowLinePortInfo {\n id: string;\n}\n\nexport interface AddOrDeleteWorkflowNodeOperationValue {\n node: WorkflowNodeJSON;\n parentID?: string;\n}\n\nexport interface AddLineOperation extends Operation {\n type: FreeOperationType.addLine;\n value: AddOrDeleteLineOperationValue;\n}\n\nexport interface DeleteLineOperation extends Operation {\n type: FreeOperationType.deleteLine;\n value: AddOrDeleteLineOperationValue;\n}\n\nexport interface MoveNodeOperation extends Operation {\n type: FreeOperationType.moveNode;\n value: MoveNodeOperationValue;\n}\n\nexport interface AddWorkflowNodeOperation extends Operation {\n type: FreeOperationType.addNode;\n value: AddOrDeleteWorkflowNodeOperationValue;\n}\n\nexport interface DeleteWorkflowNodeOperation extends Operation {\n type: FreeOperationType.deleteNode;\n value: AddOrDeleteWorkflowNodeOperationValue;\n}\n\nexport interface MoveNodeOperationValue {\n id: string;\n value: {\n x: number;\n y: number;\n };\n oldValue: {\n x: number;\n y: number;\n };\n}\n\nexport interface DragNodeOperationValue {\n ids: string[];\n value: IPoint[];\n oldValue: IPoint[];\n}\n\nexport interface ResetLayoutOperationValue {\n ids: string[];\n value: PositionMap;\n oldValue: PositionMap;\n}\n\nexport interface ContentChangeTypeToOperation<T extends Operation> {\n type: WorkflowContentChangeType;\n toOperation: (\n event: WorkflowContentChangeEvent,\n ctx: PluginContext\n ) => T | undefined | Promise<T | undefined>;\n}\n\nexport interface EntityDataType {\n type: FreeOperationType;\n toEntityData: (node: FlowNodeEntity, ctx: PluginContext) => EntityData;\n}\n\nexport interface ChangeNodeDataValue {\n id: string;\n value: unknown;\n oldValue: unknown;\n path: string;\n}\n\nexport interface ChangeNodeDataOperation extends Operation {\n type: FreeOperationType.changeNodeData;\n value: ChangeNodeDataValue;\n}\n\n/**\n * 将node转成json\n */\nexport type NodeToJson = (node: FlowNodeEntity) => FlowNodeJSON;\n/**\n * 将line转成json\n */\nexport type LineToJson = (node: WorkflowLineEntity) => FlowNodeJSON;\n/**\n * 根据节点id获取label\n */\nexport type GetNodeLabelById = (id: string) => string;\n/**\n * 根据节点获取label\n */\nexport type GetNodeLabel = (node: FlowNodeJSON) => string;\n/**\n * 根据分支获取label\n */\nexport type GetBlockLabel = (node: FlowNodeJSON) => string;\n/**\n * 根据节点获取URI\n */\nexport type GetNodeURI = (id: string) => string | any;\n/**\n * 根据连线获取URI\n */\nexport type GetLineURI = (id: string) => string | any;\n\n/**\n * 插件配置\n */\nexport interface FreeHistoryPluginOptions {\n enable?: boolean;\n limit?: number;\n nodeToJSON?: (ctx: PluginContext) => NodeToJson;\n getNodeLabelById?: (ctx: PluginContext) => GetNodeLabelById;\n getNodeLabel?: (ctx: PluginContext) => GetNodeLabel;\n getBlockLabel?: (ctx: PluginContext) => GetBlockLabel;\n getNodeURI?: (ctx: PluginContext) => GetNodeURI;\n getLineURI?: (ctx: PluginContext) => GetLineURI;\n operationMetas?: OperationMeta[];\n enableChangeNode?: boolean;\n uri?: string | any;\n}\n\nexport interface IHandler<E> {\n handle: (event: E, ctx: PluginContext) => void | Promise<void>;\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { cloneDeep, get, isEqual, set } from 'lodash';\nimport { injectable, inject } from 'inversify';\nimport { FlowNodeFormData, type DetailChangeEvent } from '@flowgram.ai/form-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { HistoryService } from '@flowgram.ai/history';\n\nimport { FreeOperationType, type IHandler } from '../types';\nimport { HistoryEntityManager } from '../history-entity-manager';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport interface ChangeNodeDataEvent extends DetailChangeEvent {\n node: FlowNodeEntity;\n}\n\n@injectable()\nexport class ChangeNodeDataHandler implements IHandler<ChangeNodeDataEvent> {\n @inject(HistoryService)\n private _historyService: HistoryService;\n\n @inject(WorkflowDocument) document: WorkflowDocument;\n\n @inject(HistoryEntityManager)\n private _entityManager: HistoryEntityManager;\n\n @inject(FreeHistoryConfig)\n private _config: FreeHistoryConfig;\n\n handle(event: ChangeNodeDataEvent) {\n const { path, value, initialized, node } = event;\n const formData = node.getData<FlowNodeFormData>(FlowNodeFormData);\n const oldValue = this._entityManager.getValue(formData) as object;\n const propPath = path.split('/').filter(Boolean).join('.');\n\n const propOldValue = propPath ? get(oldValue, propPath) : oldValue;\n if (isEqual(value, propOldValue)) {\n return;\n }\n\n if (initialized) {\n let operationPath = path;\n let operationValue = cloneDeep(value);\n let operationOldValue = propOldValue;\n // 只存储一层的数据,因为formModel无法获取数组下的某项的值\n if (path !== '/') {\n const clonedOldValue = cloneDeep(oldValue);\n set(clonedOldValue, propPath, value);\n operationPath = path.split('/').filter(Boolean)[0];\n operationValue = get(clonedOldValue, operationPath);\n operationOldValue = get(oldValue, operationPath);\n }\n\n this._historyService.pushOperation(\n {\n type: FreeOperationType.changeNodeData,\n value: {\n id: node.id,\n path: operationPath,\n value: operationValue,\n oldValue: operationOldValue,\n },\n uri: this._config.getNodeURI(node.id),\n },\n { noApply: true },\n );\n }\n\n if (propPath) {\n set(oldValue, propPath, cloneDeep(value));\n } else {\n this._entityManager.setValue(formData, cloneDeep(value));\n }\n }\n}\n","import { injectable } from 'inversify';\nimport { type FlowNodeEntity, type FlowNodeJSON } from '@flowgram.ai/document';\nimport { type PluginContext } from '@flowgram.ai/core';\n\nimport {\n type FreeHistoryPluginOptions,\n type GetBlockLabel,\n type GetLineURI,\n type GetNodeLabel,\n type GetNodeLabelById,\n type GetNodeURI,\n type NodeToJson,\n} from './types';\n\n@injectable()\nexport class FreeHistoryConfig {\n init(ctx: PluginContext, options: FreeHistoryPluginOptions) {\n this.enable = !!options?.enable;\n\n if (options.nodeToJSON) {\n this.nodeToJSON = options.nodeToJSON(ctx);\n }\n\n if (options.getNodeLabelById) {\n this.getNodeLabelById = options.getNodeLabelById(ctx);\n }\n\n if (options.getNodeLabel) {\n this.getNodeLabel = options.getNodeLabel(ctx);\n }\n\n if (options.getBlockLabel) {\n this.getBlockLabel = options.getBlockLabel(ctx);\n }\n\n if (options.getNodeURI) {\n this.getNodeURI = options.getNodeURI(ctx);\n }\n\n if (options.getLineURI) {\n this.getLineURI = options.getLineURI(ctx);\n }\n }\n\n enable = false;\n\n nodeToJSON: NodeToJson = (node: FlowNodeEntity) => node.toJSON();\n\n getNodeLabelById: GetNodeLabelById = (id: string) => id;\n\n getNodeLabel: GetNodeLabel = (node: FlowNodeJSON) => node.id;\n\n getBlockLabel: GetBlockLabel = (node: FlowNodeJSON) => node.id;\n\n getNodeURI: GetNodeURI = (id: string) => `node:${id}`;\n\n getLineURI: GetLineURI = (id: string) => `line:${id}`;\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { injectable, inject } from 'inversify';\nimport { type PluginContext } from '@flowgram.ai/core';\nimport { type WorkflowContentChangeEvent } from '@flowgram.ai/free-layout-core';\nimport { HistoryService } from '@flowgram.ai/history';\n\nimport { type IHandler } from '../types';\nimport changes from '../changes';\n\n@injectable()\nexport class ChangeContentHandler implements IHandler<WorkflowContentChangeEvent> {\n @inject(HistoryService)\n private _historyService: HistoryService;\n\n async handle(event: WorkflowContentChangeEvent, ctx: PluginContext) {\n if (!this._historyService.undoRedoService.canPush()) {\n return;\n }\n\n const change = changes.find(c => c.type === event.type);\n if (!change) {\n return;\n }\n const operation = await change.toOperation(event, ctx);\n if (!operation) {\n return;\n }\n\n this._historyService.pushOperation(operation, { noApply: true });\n }\n}\n","import { WorkflowDocument, WorkflowContentChangeType, delay } from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\n\nimport {\n type ContentChangeTypeToOperation,\n FreeOperationType,\n type DeleteWorkflowNodeOperation,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const deleteNodeChange: ContentChangeTypeToOperation<DeleteWorkflowNodeOperation> = {\n type: WorkflowContentChangeType.DELETE_NODE,\n toOperation: async (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = event.entity as FlowNodeEntity;\n const json = await document.toNodeJSON(node);\n const parentID = node.parent?.id;\n\n // 删除节点和删除连线同时触发,删除节点需放在后面执行\n await delay(0);\n\n return {\n type: FreeOperationType.deleteNode,\n value: {\n node: json,\n parentID,\n },\n uri: config.getNodeURI(node.id),\n };\n },\n};\n","import { type WorkflowLineEntity } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\n\nimport {\n type AddOrDeleteLineOperationValue,\n type ContentChangeTypeToOperation,\n type DeleteLineOperation,\n FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const deleteLineChange: ContentChangeTypeToOperation<DeleteLineOperation> = {\n type: WorkflowContentChangeType.DELETE_LINE,\n toOperation: (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const line = event.entity as WorkflowLineEntity;\n const value: AddOrDeleteLineOperationValue = {\n from: line.info.from,\n to: line.info.to || '',\n fromPort: line.info.fromPort || '',\n toPort: line.info.toPort || '',\n id: line.id,\n };\n return {\n type: FreeOperationType.deleteLine,\n value,\n uri: config.getNodeURI(line.id),\n };\n },\n};\n","import { WorkflowDocument, delay, type WorkflowNodeJSON } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\n\nimport {\n type AddWorkflowNodeOperation,\n type ContentChangeTypeToOperation,\n FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const addNodeChange: ContentChangeTypeToOperation<AddWorkflowNodeOperation> = {\n type: WorkflowContentChangeType.ADD_NODE,\n toOperation: async (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = event.entity as FlowNodeEntity;\n const parentID = node.parent?.id;\n /**\n * 由于document.toNodeJSON依赖表单里面的default的值初始化,故此处需要等表单的初始化完成\n * 比如dataset-node/index.ts中formatOnSubmit实现需要value被初始化\n */\n await delay(10);\n const json: WorkflowNodeJSON = await document.toNodeJSON(node);\n\n return {\n type: FreeOperationType.addNode,\n value: {\n node: json,\n parentID,\n },\n uri: config.getNodeURI(node.id),\n };\n },\n};\n","import { type WorkflowLineEntity } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\n\nimport {\n type AddLineOperation,\n type AddOrDeleteLineOperationValue,\n type ContentChangeTypeToOperation,\n FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const addLineChange: ContentChangeTypeToOperation<AddLineOperation> = {\n type: WorkflowContentChangeType.ADD_LINE,\n toOperation: (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const line = event.entity as WorkflowLineEntity;\n const value: AddOrDeleteLineOperationValue = {\n from: line.info.from,\n to: line.info.to || '',\n fromPort: line.info.fromPort || '',\n toPort: line.info.toPort || '',\n id: line.id,\n };\n return {\n type: FreeOperationType.addLine,\n value,\n uri: config.getLineURI(line.id),\n };\n },\n};\n","import { deleteNodeChange } from './delete-node-change';\nimport { deleteLineChange } from './delete-line-change';\nimport { addNodeChange } from './add-node-change';\nimport { addLineChange } from './add-line-change';\n\nexport default [addLineChange, deleteLineChange, addNodeChange, deleteNodeChange];\n","import { injectable } from 'inversify';\nimport { type OperationContribution, type OperationRegistry } from '@flowgram.ai/history';\n\nimport { operationMetas } from './operation-metas';\n\n@injectable()\nexport class FreeHistoryRegisters implements OperationContribution {\n registerOperationMeta(operationRegistry: OperationRegistry): void {\n operationMetas.forEach(operationMeta => {\n operationRegistry.registerOperationMeta(operationMeta);\n });\n }\n}\n","import { type PluginContext } from '@flowgram.ai/core';\nimport { WorkflowResetLayoutService } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { FreeOperationType, type ResetLayoutOperationValue } from '../types';\nimport { baseOperationMeta } from './base';\n\nexport const resetLayoutOperationMeta: OperationMeta<\n ResetLayoutOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: FreeOperationType.resetLayout,\n inverse: op => ({\n ...op,\n value: {\n ...op.value,\n value: op.value.oldValue,\n oldValue: op.value.value,\n },\n }),\n apply: async (operation, ctx: PluginContext) => {\n const reset = ctx.get<WorkflowResetLayoutService>(WorkflowResetLayoutService);\n await reset.layoutToPositions(operation.value.ids, operation.value.value);\n },\n shouldMerge: () => false,\n};\n","import { type OperationMeta } from '@flowgram.ai/history';\n\nexport const baseOperationMeta: Partial<OperationMeta> = {\n shouldMerge: (_op, prev, element) => {\n if (!prev) {\n return false;\n }\n\n if (\n // 合并500ms内的操作, 如删除节点会联动删除线条\n Date.now() - element.getTimestamp() <\n 500\n ) {\n return true;\n }\n return false;\n },\n};\n","import { OperationMeta } from '@flowgram.ai/history';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { MoveChildNodesOperationValue, OperationType } from '@flowgram.ai/document';\nimport { FlowNodeBaseType } from '@flowgram.ai/document';\nimport { PluginContext, TransformData } from '@flowgram.ai/core';\n\nimport { baseOperationMeta } from './base';\n\nexport const moveChildNodesOperationMeta: OperationMeta<\n MoveChildNodesOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: OperationType.moveChildNodes,\n inverse: (op) => ({\n ...op,\n value: {\n ...op.value,\n fromIndex: op.value.toIndex,\n toIndex: op.value.fromIndex,\n fromParentId: op.value.toParentId,\n toParentId: op.value.fromParentId,\n },\n }),\n apply: (operation, ctx: PluginContext) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n document.moveChildNodes(operation.value);\n const fromContainer = document.getNode(operation.value.fromParentId);\n requestAnimationFrame(() => {\n if (fromContainer && fromContainer.flowNodeType !== FlowNodeBaseType.ROOT) {\n const fromContainerTransformData = fromContainer.getData(TransformData);\n fromContainerTransformData.fireChange();\n }\n });\n },\n};\n","import { type OperationMeta } from '@flowgram.ai/history';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { FlowNodeTransformData } from '@flowgram.ai/document';\nimport { type PluginContext, TransformData } from '@flowgram.ai/core';\n\nimport { type DragNodeOperationValue, FreeOperationType } from '../types';\nimport { baseOperationMeta } from './base';\n\nexport const dragNodesOperationMeta: OperationMeta<DragNodeOperationValue, PluginContext, void> = {\n ...baseOperationMeta,\n type: FreeOperationType.dragNodes,\n inverse: (op) => ({\n ...op,\n value: {\n ...op.value,\n value: op.value.oldValue,\n oldValue: op.value.value,\n },\n }),\n apply: (operation, ctx) => {\n operation.value.ids.forEach((id, index) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = document.getNode(id);\n if (!node) {\n return;\n }\n\n const transform = node.getData(TransformData);\n const point = operation.value.value[index];\n transform.update({\n position: {\n x: point.x,\n y: point.y,\n },\n });\n // 嵌套情况下需将子节点 transform 设为 dirty\n if (node.collapsedChildren?.length > 0) {\n node.collapsedChildren.forEach((childNode) => {\n const childNodeTransformData =\n childNode.getData<FlowNodeTransformData>(FlowNodeTransformData);\n childNodeTransformData.fireChange();\n });\n }\n });\n },\n};\n","import { type PluginContext } from '@flowgram.ai/core';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { type AddOrDeleteWorkflowNodeOperationValue, FreeOperationType } from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\nimport { baseOperationMeta } from './base';\n\nexport const deleteNodeOperationMeta: OperationMeta<\n AddOrDeleteWorkflowNodeOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: FreeOperationType.deleteNode,\n inverse: op => ({\n ...op,\n type: FreeOperationType.addNode,\n }),\n apply: (operation, ctx: PluginContext) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = document.getNode(operation.value.node.id);\n if (node) {\n node.dispose();\n }\n },\n getLabel: (op, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n return `Delete Node ${config.getNodeLabel(op.value.node)}`;\n },\n getDescription: (op, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n let desc = `Delete Node ${config.getNodeLabel(op.value.node)}`;\n if (op.value.node.meta?.position) {\n desc += ` at ${op.value.node.meta.position.x},${op.value.node.meta.position.y}`;\n }\n return desc;\n },\n};\n","import { type OperationMeta } from '@flowgram.ai/history';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { type PluginContext } from '@flowgram.ai/core';\n\nimport { type AddOrDeleteLineOperationValue, FreeOperationType } from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\nimport { baseOperationMeta } from './base';\n\nexport const deleteLineOperationMeta: OperationMeta<\n AddOrDeleteLineOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: FreeOperationType.deleteLine,\n inverse: (op) => ({\n ...op,\n type: FreeOperationType.addLine,\n }),\n apply: (operation, ctx: PluginContext) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n document.removeNode(operation.value.id);\n },\n getLabel: (op, ctx) => 'Delete Line',\n getDescription: (op, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const { value } = op;\n if (!value.from || !value.to) {\n return 'Delete Line';\n }\n\n const fromName = config.getNodeLabelById(value.from);\n const toName = config.getNodeLabelById(value.to);\n return `Delete Line from ${fromName} to ${toName}`;\n },\n};\n","import { FlowNodeFormData } from '@flowgram.ai/form-core';\nimport { type PluginContext } from '@flowgram.ai/core';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { FreeOperationType, type ChangeNodeDataValue } from '../types';\nimport { baseOperationMeta } from './base';\n\nexport const changeNodeDataOperationMeta: OperationMeta<ChangeNodeDataValue, PluginContext, void> =\n {\n ...baseOperationMeta,\n type: FreeOperationType.changeNodeData,\n inverse: op => ({\n ...op,\n value: {\n ...op.value,\n value: op.value.oldValue,\n oldValue: op.value.value,\n },\n }),\n apply: (operation, ctx: PluginContext) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = document.getNode(operation.value.id);\n\n if (!node) {\n return;\n }\n const formData = node.getData(FlowNodeFormData);\n\n if (!formData) {\n return;\n }\n\n let { path } = operation.value;\n if (path.endsWith('/') && path !== '/') {\n path = path.slice(0, -1);\n }\n\n if (!path.startsWith('/')) {\n path = `/${path}`;\n }\n\n const formItem = formData.formModel.getFormItemByPath(path);\n\n if (!formItem) {\n return;\n }\n formItem.value = operation.value.value;\n },\n shouldMerge: (op, prev, element) => {\n if (!prev) {\n return false;\n }\n\n if (Date.now() - element.getTimestamp() < 500) {\n if (\n op.type === prev.type && // 相同类型\n op.value.id === prev.value.id && // 相同节点\n op.value?.path === prev.value?.path // 相同路径\n ) {\n return {\n type: op.type,\n value: {\n ...op.value,\n value: op.value.value,\n oldValue: prev.value.oldValue,\n },\n };\n }\n return true;\n }\n return false;\n },\n };\n","import { cloneDeep } from 'lodash';\nimport { type PluginContext } from '@flowgram.ai/core';\nimport { WorkflowDocument, type WorkflowNodeJSON } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { type AddOrDeleteWorkflowNodeOperationValue, FreeOperationType } from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\nimport { baseOperationMeta } from './base';\n\nexport const addNodeOperationMeta: OperationMeta<\n AddOrDeleteWorkflowNodeOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: FreeOperationType.addNode,\n inverse: op => ({\n ...op,\n type: FreeOperationType.deleteNode,\n }),\n apply: async (operation, ctx: PluginContext) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n await document.createWorkflowNode(\n cloneDeep(operation.value.node) as WorkflowNodeJSON,\n false,\n operation.value.parentID,\n );\n },\n getLabel: (op, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n return `Create Node ${config.getNodeLabel(op.value.node)}`;\n },\n getDescription: (op, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n let desc = `Create Node ${config.getNodeLabel(op.value.node)}`;\n if (op.value.node.meta?.position) {\n desc += ` at ${op.value.node.meta.position.x},${op.value.node.meta.position.y}`;\n }\n return desc;\n },\n};\n","import { type PluginContext } from '@flowgram.ai/core';\nimport { WorkflowLinesManager } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { type AddOrDeleteLineOperationValue, FreeOperationType } from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\nimport { baseOperationMeta } from './base';\n\nexport const addLineOperationMeta: OperationMeta<\n AddOrDeleteLineOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: FreeOperationType.addLine,\n inverse: op => ({\n ...op,\n type: FreeOperationType.deleteLine,\n }),\n apply: (operation, ctx: PluginContext) => {\n const linesManager = ctx.get<WorkflowLinesManager>(WorkflowLinesManager);\n linesManager.createLine({\n ...operation.value,\n key: operation.value.id,\n });\n },\n getLabel: (op, ctx) => 'Create Line',\n getDescription: (op, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const { value } = op;\n if (!value.from || !value.to) {\n return 'Create Line';\n }\n\n const fromName = config.getNodeLabelById(value.from);\n const toName = config.getNodeLabelById(value.to);\n return `Create Line from ${fromName} to ${toName}`;\n },\n};\n","import { resetLayoutOperationMeta } from './reset-layout';\nimport { moveChildNodesOperationMeta } from './move-child-nodes';\nimport { dragNodesOperationMeta } from './drag-nodes';\nimport { deleteNodeOperationMeta } from './delete-node';\nimport { deleteLineOperationMeta } from './delete-line';\nimport { changeNodeDataOperationMeta } from './change-node-data';\nimport { addNodeOperationMeta } from './add-node';\nimport { addLineOperationMeta } from './add-line';\n\nexport const operationMetas = [\n addLineOperationMeta,\n deleteLineOperationMeta,\n addNodeOperationMeta,\n deleteNodeOperationMeta,\n changeNodeDataOperationMeta,\n resetLayoutOperationMeta,\n dragNodesOperationMeta,\n moveChildNodesOperationMeta,\n];\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { cloneDeep } from 'lodash';\nimport { injectable, inject, optional } from 'inversify';\nimport { DisposableCollection, Disposable } from '@flowgram.ai/utils';\nimport { HistoryService } from '@flowgram.ai/history';\nimport {\n WorkflowDocument,\n WorkflowResetLayoutService,\n WorkflowDragService,\n WorkflowOperationBaseService,\n} from '@flowgram.ai/free-layout-core';\nimport { FlowNodeFormData } from '@flowgram.ai/form-core';\nimport { FormManager } from '@flowgram.ai/form-core';\nimport { OperationType } from '@flowgram.ai/document';\nimport { type PluginContext, PositionData } from '@flowgram.ai/core';\n\nimport { DragNodeOperationValue, type FreeHistoryPluginOptions, FreeOperationType } from './types';\nimport { HistoryEntityManager } from './history-entity-manager';\nimport { DragNodesHandler } from './handlers/drag-nodes-handler';\nimport { ChangeNodeDataHandler } from './handlers/change-node-data-handler';\nimport { ChangeContentHandler } from './handlers/change-content-handler';\n\n/**\n * 历史管理\n */\n@injectable()\nexport class FreeHistoryManager {\n @inject(DragNodesHandler)\n private _dragNodesHandler: DragNodesHandler;\n\n @inject(ChangeNodeDataHandler)\n private _changeNodeDataHandler: ChangeNodeDataHandler;\n\n @inject(ChangeContentHandler)\n private _changeContentHandler: ChangeContentHandler;\n\n @inject(HistoryEntityManager)\n private _entityManager: HistoryEntityManager;\n\n @inject(FormManager)\n @optional()\n private _formManager?: FormManager;\n\n private _toDispose: DisposableCollection = new DisposableCollection();\n\n @inject(WorkflowOperationBaseService)\n private _operationService: WorkflowOperationBaseService;\n\n onInit(ctx: PluginContext, opts: FreeHistoryPluginOptions) {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const historyService = ctx.get<HistoryService>(HistoryService);\n const dragService = ctx.get<WorkflowDragService>(WorkflowDragService);\n\n const resetLayoutService = ctx.get<WorkflowResetLayoutService>(WorkflowResetLayoutService);\n\n if (opts?.limit) {\n historyService.limit(opts.limit);\n }\n historyService.context.source = ctx;\n\n this._toDispose.pushAll([\n dragService.onNodesDrag(async (event) => {\n if (event.type !== 'onDragEnd') {\n return;\n }\n this._dragNodesHandler.handle(event);\n }),\n document.onNodeCreate(({ node, data }) => {\n const positionData = node.getData(PositionData);\n if (positionData) {\n this._entityManager.addEntityData(positionData);\n }\n }),\n this._formManager\n ? this._formManager.onFormModelWillInit(({ model, data }) => {\n const node = model.flowNodeEntity;\n const formData = node.getData<FlowNodeFormData>(FlowNodeFormData);\n\n if (formData) {\n this._entityManager.setValue(formData, cloneDeep(data));\n\n this._toDispose.push(\n formData.onDetailChange((event) => {\n this._changeNodeDataHandler.handle({\n ...event,\n node,\n });\n })\n );\n }\n })\n : Disposable.NULL,\n document.onContentChange(async (event) => {\n await this._changeContentHandler.handle(event, ctx);\n }),\n document.onReload((_event) => {\n historyService.clear();\n }),\n resetLayoutService.onResetLayout((event) => {\n historyService.pushOperation(\n {\n type: FreeOperationType.resetLayout,\n value: {\n ids: event.nodeIds,\n value: event.positionMap,\n oldValue: event.oldPositionMap,\n },\n },\n { noApply: true }\n );\n }),\n this._operationService.onNodeMove(({ node, fromParent, fromIndex, toParent, toIndex }) => {\n historyService.pushOperation(\n {\n type: OperationType.moveChildNodes,\n value: {\n fromParentId: fromParent.id,\n fromIndex,\n nodeIds: [node.id],\n toParentId: toParent.id,\n toIndex,\n },\n },\n {\n noApply: true,\n }\n );\n }),\n this._operationService.onNodePostionUpdate((event) => {\n const value: DragNodeOperationValue = {\n ids: [event.node.id],\n value: [event.newPosition],\n oldValue: [event.oldPosition],\n };\n historyService.pushOperation(\n {\n type: FreeOperationType.dragNodes,\n value,\n },\n {\n noApply: true,\n }\n );\n }),\n ]);\n }\n\n dispose() {\n this._entityManager.dispose();\n this._toDispose.dispose();\n }\n}\n","import { useEffect, useState } from 'react';\n\nimport { useService } from '@flowgram.ai/core';\nimport { HistoryService } from '@flowgram.ai/history';\n\ninterface UndoRedo {\n canUndo: boolean;\n canRedo: boolean;\n undo: () => Promise<void>;\n redo: () => Promise<void>;\n}\n\nexport function useUndoRedo(): UndoRedo {\n const historyService = useService<HistoryService>(HistoryService);\n const [canUndo, setCanUndo] = useState(false);\n const [canRedo, setCanRedo] = useState(false);\n\n useEffect(() => {\n const toDispose = historyService.undoRedoService.onChange(() => {\n setCanUndo(historyService.canUndo());\n setCanRedo(historyService.canRedo());\n });\n return () => {\n toDispose.dispose();\n };\n }, []);\n\n return {\n canUndo,\n canRedo,\n undo: () => historyService.undo(),\n redo: () => historyService.redo(),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eAAuD;AACvD,IAAAC,kBAA8D;;;ACA9D,oBAAmC;AACnC,uBAA2B;AAE3B,mBAAsD;AAG/C,IAAM,uBAAN,MAAiD;AAAA,EAAjD;AACL,SAAQ,oBAA8C,oBAAI,IAAI;AAE9D,SAAQ,aAAmC,IAAI,kCAAqB;AAAA;AAAA,EAEpE,cAAc,YAAwB;AACpC,SAAK,kBAAkB,IAAI,gBAAY,yBAAU,WAAW,OAAO,CAAC,CAAC;AACrE,SAAK,WAAW;AAAA,MACd,WAAW,aAAa,WAAS;AAC/B,cAAM,QAAQ,MAAM,OAAO;AAC3B,cAAM,WAAW,KAAK,kBAAkB,IAAI,UAAU;AACtD,gBAAI,uBAAQ,OAAO,QAAQ,GAAG;AAC5B;AAAA,QACF;AACA,aAAK,kBAAkB,IAAI,gBAAY,yBAAU,KAAK,CAAC;AAAA,MACzD,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEA,SAAS,YAAwB;AAC/B,WAAO,KAAK,kBAAkB,IAAI,UAAU;AAAA,EAC9C;AAAA,EAEA,SAAS,YAAwB,OAAgB;AAC/C,WAAO,KAAK,kBAAkB,IAAI,YAAY,KAAK;AAAA,EACrD;AAAA,EAEA,UAAU;AACR,SAAK,kBAAkB,MAAM;AAC7B,SAAK,WAAW,QAAQ;AAAA,EAC1B;AACF;AA/Ba,uBAAN;AAAA,MADN,6BAAW;AAAA,GACC;;;ACNb,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uB,iBAAiB,EAAE,KAAK,KAAK,IAAI;AAE5D,QAAI,CAAC,KAAK,QAAQ;AAChB;AAAA,IACF;AACA,QAAI,IAAwB,kBAAkB,EAAE,OAAO,KAAK,IAAI;AAAA,EAClE;AAAA,EACA,UAAU,KAAK;AACb,QAAI,IAA0B,oBAAoB,EAAE,QAAQ;AAAA,EAC9D;AAAA,EACA,kBAAkB,CAAC,sCAAsB;AAC3C,CAAC;;;ADhCD,wBAAc,iCAFd;;;AyBAA,mBAAoC;AAEpC,IAAAC,eAA2B;AAC3B,IAAAC,kBAA+B;AASxB,SAAS,cAAwB;AACtC,QAAM,qBAAiB,yBAA2B,8BAAc;AAChE,QAAM,CAAC,SAAS,UAAU,QAAI,uBAAS,KAAK;AAC5C,QAAM,CAAC,SAAS,UAAU,QAAI,uBAAS,KAAK;AAE5C,8BAAU,MAAM;AACd,UAAM,YAAY,eAAe,gBAAgB,SAAS,MAAM;AAC9D,iBAAW,eAAe,QAAQ,CAAC;AACnC,iBAAW,eAAe,QAAQ,CAAC;AAAA,IACrC,CAAC;AACD,WAAO,MAAM;AACX,gBAAU,QAAQ;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,MAAM,MAAM,eAAe,KAAK;AAAA,IAChC,MAAM,MAAM,eAAe,KAAK;AAAA,EAClC;AACF;","names":["import_core","import_history","import_inversify","FreeOperationType","import_lodash","import_inversify","import_history","import_inversify","import_inversify","import_history","import_free_layout_core","import_free_layout_core","import_free_layout_core","import_free_layout_core","import_inversify","import_free_layout_core","import_free_layout_core","import_document","import_core","import_free_layout_core","import_document","import_core","import_free_layout_core","import_free_layout_core","import_form_core","import_free_layout_core","import_lodash","import_free_layout_core","import_free_layout_core","import_lodash","import_inversify","import_utils","import_history","import_free_layout_core","import_form_core","import_document","import_core","import_core","import_history"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowgram.ai/free-history-plugin",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
4
4
  "homepage": "https://flowgram.ai/",
5
5
  "repository": "https://github.com/bytedance/flowgram.ai",
6
6
  "license": "MIT",
@@ -19,12 +19,12 @@
19
19
  "inversify": "^6.0.1",
20
20
  "reflect-metadata": "~0.2.2",
21
21
  "lodash": "^4.17.21",
22
- "@flowgram.ai/core": "0.1.21",
23
- "@flowgram.ai/document": "0.1.21",
24
- "@flowgram.ai/form-core": "0.1.21",
25
- "@flowgram.ai/free-layout-core": "0.1.21",
26
- "@flowgram.ai/utils": "0.1.21",
27
- "@flowgram.ai/history": "0.1.21"
22
+ "@flowgram.ai/core": "0.1.23",
23
+ "@flowgram.ai/form-core": "0.1.23",
24
+ "@flowgram.ai/document": "0.1.23",
25
+ "@flowgram.ai/free-layout-core": "0.1.23",
26
+ "@flowgram.ai/utils": "0.1.23",
27
+ "@flowgram.ai/history": "0.1.23"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/lodash": "^4.14.137",
@@ -35,8 +35,8 @@
35
35
  "tsup": "^8.0.1",
36
36
  "typescript": "^5.0.4",
37
37
  "vitest": "^0.34.6",
38
- "@flowgram.ai/eslint-config": "0.1.21",
39
- "@flowgram.ai/ts-config": "0.1.21"
38
+ "@flowgram.ai/eslint-config": "0.1.23",
39
+ "@flowgram.ai/ts-config": "0.1.23"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "react": ">=17",