@flowgram.ai/free-history-plugin 0.2.2 → 0.2.3

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
@@ -212,14 +212,13 @@ import { injectable as injectable5, inject as inject3 } from "inversify";
212
212
  import { HistoryService as HistoryService3 } from "@flowgram.ai/history";
213
213
 
214
214
  // src/changes/delete-node-change.ts
215
- import { WorkflowDocument as WorkflowDocument2, WorkflowContentChangeType } from "@flowgram.ai/free-layout-core";
215
+ import { WorkflowContentChangeType } from "@flowgram.ai/free-layout-core";
216
216
  var deleteNodeChange = {
217
217
  type: WorkflowContentChangeType.DELETE_NODE,
218
218
  toOperation: (event, ctx) => {
219
219
  const config = ctx.get(FreeHistoryConfig);
220
- const document = ctx.get(WorkflowDocument2);
221
220
  const node = event.entity;
222
- const json = document.toNodeJSON(node);
221
+ const json = event.toJSON();
223
222
  const parentID = node.parent?.id;
224
223
  return {
225
224
  type: "deleteNode" /* deleteNode */,
@@ -255,13 +254,13 @@ var deleteLineChange = {
255
254
  };
256
255
 
257
256
  // src/changes/add-node-change.ts
258
- import { WorkflowDocument as WorkflowDocument3 } from "@flowgram.ai/free-layout-core";
257
+ import { WorkflowDocument as WorkflowDocument2 } from "@flowgram.ai/free-layout-core";
259
258
  import { WorkflowContentChangeType as WorkflowContentChangeType3 } from "@flowgram.ai/free-layout-core";
260
259
  var addNodeChange = {
261
260
  type: WorkflowContentChangeType3.ADD_NODE,
262
261
  toOperation: (event, ctx) => {
263
262
  const config = ctx.get(FreeHistoryConfig);
264
- const document = ctx.get(WorkflowDocument3);
263
+ const document = ctx.get(WorkflowDocument2);
265
264
  const node = event.entity;
266
265
  const parentID = node.parent?.id;
267
266
  const json = document.toNodeJSON(node);
@@ -367,7 +366,7 @@ var resetLayoutOperationMeta = {
367
366
  };
368
367
 
369
368
  // src/operation-metas/move-child-nodes.ts
370
- import { WorkflowDocument as WorkflowDocument4 } from "@flowgram.ai/free-layout-core";
369
+ import { WorkflowDocument as WorkflowDocument3 } from "@flowgram.ai/free-layout-core";
371
370
  import { OperationType } from "@flowgram.ai/document";
372
371
  import { FlowNodeBaseType } from "@flowgram.ai/document";
373
372
  import { TransformData as TransformData2 } from "@flowgram.ai/core";
@@ -385,7 +384,7 @@ var moveChildNodesOperationMeta = {
385
384
  }
386
385
  }),
387
386
  apply: (operation, ctx) => {
388
- const document = ctx.get(WorkflowDocument4);
387
+ const document = ctx.get(WorkflowDocument3);
389
388
  document.moveChildNodes(operation.value);
390
389
  const fromContainer = document.getNode(operation.value.fromParentId);
391
390
  requestAnimationFrame(() => {
@@ -398,7 +397,7 @@ var moveChildNodesOperationMeta = {
398
397
  };
399
398
 
400
399
  // src/operation-metas/drag-nodes.ts
401
- import { WorkflowDocument as WorkflowDocument5 } from "@flowgram.ai/free-layout-core";
400
+ import { WorkflowDocument as WorkflowDocument4 } from "@flowgram.ai/free-layout-core";
402
401
  import { TransformData as TransformData3 } from "@flowgram.ai/core";
403
402
  var dragNodesOperationMeta = {
404
403
  ...baseOperationMeta,
@@ -413,7 +412,7 @@ var dragNodesOperationMeta = {
413
412
  }),
414
413
  apply: (operation, ctx) => {
415
414
  operation.value.ids.forEach((id, index) => {
416
- const document = ctx.get(WorkflowDocument5);
415
+ const document = ctx.get(WorkflowDocument4);
417
416
  const node = document.getNode(id);
418
417
  if (!node) {
419
418
  return;
@@ -432,7 +431,7 @@ var dragNodesOperationMeta = {
432
431
  };
433
432
 
434
433
  // src/operation-metas/delete-node.ts
435
- import { WorkflowDocument as WorkflowDocument6 } from "@flowgram.ai/free-layout-core";
434
+ import { WorkflowDocument as WorkflowDocument5 } from "@flowgram.ai/free-layout-core";
436
435
  var deleteNodeOperationMeta = {
437
436
  ...baseOperationMeta,
438
437
  type: "deleteNode" /* deleteNode */,
@@ -441,7 +440,7 @@ var deleteNodeOperationMeta = {
441
440
  type: "addNode" /* addNode */
442
441
  }),
443
442
  apply: (operation, ctx) => {
444
- const document = ctx.get(WorkflowDocument6);
443
+ const document = ctx.get(WorkflowDocument5);
445
444
  const node = document.getNode(operation.value.node.id);
446
445
  if (node) {
447
446
  node.dispose();
@@ -462,7 +461,7 @@ var deleteNodeOperationMeta = {
462
461
  };
463
462
 
464
463
  // src/operation-metas/delete-line.ts
465
- import { WorkflowDocument as WorkflowDocument7 } from "@flowgram.ai/free-layout-core";
464
+ import { WorkflowDocument as WorkflowDocument6 } from "@flowgram.ai/free-layout-core";
466
465
  var deleteLineOperationMeta = {
467
466
  ...baseOperationMeta,
468
467
  type: "deleteLine" /* deleteLine */,
@@ -471,7 +470,7 @@ var deleteLineOperationMeta = {
471
470
  type: "addLine" /* addLine */
472
471
  }),
473
472
  apply: (operation, ctx) => {
474
- const document = ctx.get(WorkflowDocument7);
473
+ const document = ctx.get(WorkflowDocument6);
475
474
  document.removeNode(operation.value.id);
476
475
  },
477
476
  getLabel: (op, ctx) => "Delete Line",
@@ -489,7 +488,7 @@ var deleteLineOperationMeta = {
489
488
 
490
489
  // src/operation-metas/change-node-data.ts
491
490
  import { FlowNodeFormData as FlowNodeFormData2 } from "@flowgram.ai/form-core";
492
- import { WorkflowDocument as WorkflowDocument8 } from "@flowgram.ai/free-layout-core";
491
+ import { WorkflowDocument as WorkflowDocument7 } from "@flowgram.ai/free-layout-core";
493
492
  var changeNodeDataOperationMeta = {
494
493
  ...baseOperationMeta,
495
494
  type: "changeNodeData" /* changeNodeData */,
@@ -502,7 +501,7 @@ var changeNodeDataOperationMeta = {
502
501
  }
503
502
  }),
504
503
  apply: (operation, ctx) => {
505
- const document = ctx.get(WorkflowDocument8);
504
+ const document = ctx.get(WorkflowDocument7);
506
505
  const node = document.getNode(operation.value.id);
507
506
  if (!node) {
508
507
  return;
@@ -549,7 +548,7 @@ var changeNodeDataOperationMeta = {
549
548
 
550
549
  // src/operation-metas/add-node.ts
551
550
  import { cloneDeep as cloneDeep3 } from "lodash";
552
- import { WorkflowDocument as WorkflowDocument9 } from "@flowgram.ai/free-layout-core";
551
+ import { WorkflowDocument as WorkflowDocument8 } from "@flowgram.ai/free-layout-core";
553
552
  var addNodeOperationMeta = {
554
553
  ...baseOperationMeta,
555
554
  type: "addNode" /* addNode */,
@@ -558,7 +557,7 @@ var addNodeOperationMeta = {
558
557
  type: "deleteNode" /* deleteNode */
559
558
  }),
560
559
  apply: async (operation, ctx) => {
561
- const document = ctx.get(WorkflowDocument9);
560
+ const document = ctx.get(WorkflowDocument8);
562
561
  await document.createWorkflowNode(
563
562
  cloneDeep3(operation.value.node),
564
563
  false,
@@ -638,7 +637,7 @@ import { injectable as injectable7, inject as inject4, optional } from "inversif
638
637
  import { DisposableCollection as DisposableCollection2, Disposable } from "@flowgram.ai/utils";
639
638
  import { HistoryService as HistoryService4 } from "@flowgram.ai/history";
640
639
  import {
641
- WorkflowDocument as WorkflowDocument10,
640
+ WorkflowDocument as WorkflowDocument9,
642
641
  WorkflowResetLayoutService as WorkflowResetLayoutService2,
643
642
  WorkflowDragService,
644
643
  WorkflowOperationBaseService
@@ -652,7 +651,7 @@ var FreeHistoryManager = class {
652
651
  this._toDispose = new DisposableCollection2();
653
652
  }
654
653
  onInit(ctx, opts) {
655
- const document = ctx.get(WorkflowDocument10);
654
+ const document = ctx.get(WorkflowDocument9);
656
655
  const historyService = ctx.get(HistoryService4);
657
656
  const dragService = ctx.get(WorkflowDragService);
658
657
  const resetLayoutService = ctx.get(WorkflowResetLayoutService2);
@@ -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 { 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: (event: WorkflowContentChangeEvent, ctx: PluginContext) => 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 { HistoryService, Operation } from '@flowgram.ai/history';\nimport { type WorkflowContentChangeEvent } from '@flowgram.ai/free-layout-core';\nimport { type PluginContext } from '@flowgram.ai/core';\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 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: Operation | undefined = change.toOperation(event, ctx);\n if (!operation) {\n return;\n }\n\n this._historyService.pushOperation(operation, { noApply: true });\n }\n}\n","import { WorkflowDocument, WorkflowContentChangeType } 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: (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 = document.toNodeJSON(node);\n const parentID = node.parent?.id;\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, 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: (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 const json: WorkflowNodeJSON = 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 { 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 document.layout.updateAffectedTransform(node);\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((event) => {\n 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;AAA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AAClD,SAAK,kBAAkB,EAAE,OAAO,EAAE,iBAAiB;AACnD,SAAK,oBAAoB,EAAE,OAAO,EAAE,iBAAiB;AACrD,SAAK,gBAAgB,EAAE,OAAO,EAAE,iBAAiB;AACjD,SAAK,qBAAqB,EAAE,OAAO,EAAE,iBAAiB;AACtD,SAAK,oBAAoB,EAAE,OAAO,EAAE,iBAAiB;AAAA,EACvD;AAAA,EACA,OAAO,KAAK,MAAY;AACtB,QAAI,IAAuB,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,sBAAsB;AAC3C,CAAC;;;AwBhCD,cAAc;;;ACFd,SAAS,WAAW,gBAAgB;AAEpC,SAAS,kBAAkB;AAC3B,SAAS,kBAAAC,uBAAsB;AASxB,SAAS,cAAwB;AACtC,QAAM,iBAAiB,WAA2BA,eAAc;AAChE,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,KAAK;AAC5C,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,KAAK;AAE5C,YAAU,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":["injectable","FreeOperationType","injectable","cloneDeep","isEqual","injectable","inject","HistoryService","injectable","injectable","isEqual","cloneDeep","inject","HistoryService","injectable","injectable","inject","HistoryService","WorkflowDocument","WorkflowDocument","WorkflowContentChangeType","WorkflowContentChangeType","WorkflowDocument","WorkflowContentChangeType","WorkflowContentChangeType","WorkflowDocument","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: (event: WorkflowContentChangeEvent, ctx: PluginContext) => 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 { HistoryService, Operation } from '@flowgram.ai/history';\nimport { type WorkflowContentChangeEvent } from '@flowgram.ai/free-layout-core';\nimport { type PluginContext } from '@flowgram.ai/core';\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 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: Operation | undefined = change.toOperation(event, ctx);\n if (!operation) {\n return;\n }\n\n this._historyService.pushOperation(operation, { noApply: true });\n }\n}\n","import { WorkflowContentChangeType } 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: (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const node = event.entity as FlowNodeEntity;\n const json = event.toJSON();\n const parentID = node.parent?.id;\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, 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: (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 const json: WorkflowNodeJSON = 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 { 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 document.layout.updateAffectedTransform(node);\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((event) => {\n 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 und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,QAAI,IAA0B,oBAAoB,EAAE,QAAQ;AAAA,EAC9D;AAAA,EACA,kBAAkB,CAAC,sBAAsB;AAC3C,CAAC;;;AwBhCD,cAAc;;;ACFd,SAAS,WAAW,gBAAgB;AAEpC,SAAS,kBAAkB;AAC3B,SAAS,kBAAAC,uBAAsB;AASxB,SAAS,cAAwB;AACtC,QAAM,iBAAiB,WAA2BA,eAAc;AAChE,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,KAAK;AAC5C,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,KAAK;AAE5C,YAAU,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":["injectable","FreeOperationType","injectable","cloneDeep","isEqual","injectable","inject","HistoryService","injectable","injectable","isEqual","cloneDeep","inject","HistoryService","injectable","injectable","inject","HistoryService","WorkflowContentChangeType","WorkflowContentChangeType","WorkflowDocument","WorkflowContentChangeType","WorkflowContentChangeType","WorkflowDocument","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
@@ -245,9 +245,8 @@ var deleteNodeChange = {
245
245
  type: import_free_layout_core2.WorkflowContentChangeType.DELETE_NODE,
246
246
  toOperation: (event, ctx) => {
247
247
  const config = ctx.get(FreeHistoryConfig);
248
- const document = ctx.get(import_free_layout_core2.WorkflowDocument);
249
248
  const node = event.entity;
250
- const json = document.toNodeJSON(node);
249
+ const json = event.toJSON();
251
250
  const parentID = node.parent?.id;
252
251
  return {
253
252
  type: "deleteNode" /* deleteNode */,
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 { 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: (event: WorkflowContentChangeEvent, ctx: PluginContext) => 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 { HistoryService, Operation } from '@flowgram.ai/history';\nimport { type WorkflowContentChangeEvent } from '@flowgram.ai/free-layout-core';\nimport { type PluginContext } from '@flowgram.ai/core';\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 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: Operation | undefined = change.toOperation(event, ctx);\n if (!operation) {\n return;\n }\n\n this._historyService.pushOperation(operation, { noApply: true });\n }\n}\n","import { WorkflowDocument, WorkflowContentChangeType } 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: (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 = document.toNodeJSON(node);\n const parentID = node.parent?.id;\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, 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: (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 const json: WorkflowNodeJSON = 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 { 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 document.layout.updateAffectedTransform(node);\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((event) => {\n 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;A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AgB,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_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: (event: WorkflowContentChangeEvent, ctx: PluginContext) => 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 { HistoryService, Operation } from '@flowgram.ai/history';\nimport { type WorkflowContentChangeEvent } from '@flowgram.ai/free-layout-core';\nimport { type PluginContext } from '@flowgram.ai/core';\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 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: Operation | undefined = change.toOperation(event, ctx);\n if (!operation) {\n return;\n }\n\n this._historyService.pushOperation(operation, { noApply: true });\n }\n}\n","import { WorkflowContentChangeType } 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: (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const node = event.entity as FlowNodeEntity;\n const json = event.toJSON();\n const parentID = node.parent?.id;\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, 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: (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 const json: WorkflowNodeJSON = 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 { 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 document.layout.updateAffectedTransform(node);\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((event) => {\n 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 {\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AC5C,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_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.2.2",
3
+ "version": "0.2.3",
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.2.2",
23
- "@flowgram.ai/document": "0.2.2",
24
- "@flowgram.ai/form-core": "0.2.2",
25
- "@flowgram.ai/free-layout-core": "0.2.2",
26
- "@flowgram.ai/utils": "0.2.2",
27
- "@flowgram.ai/history": "0.2.2"
22
+ "@flowgram.ai/core": "0.2.3",
23
+ "@flowgram.ai/free-layout-core": "0.2.3",
24
+ "@flowgram.ai/document": "0.2.3",
25
+ "@flowgram.ai/form-core": "0.2.3",
26
+ "@flowgram.ai/history": "0.2.3",
27
+ "@flowgram.ai/utils": "0.2.3"
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.2.2",
39
- "@flowgram.ai/ts-config": "0.2.2"
38
+ "@flowgram.ai/eslint-config": "0.2.3",
39
+ "@flowgram.ai/ts-config": "0.2.3"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "react": ">=16.8",