@flowgram.ai/free-history-plugin 0.1.6 → 0.1.8
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 +12 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/index.js +11 -4
- package/dist/index.js.map +1 -1
- package/package.json +11 -9
package/dist/esm/index.js
CHANGED
|
@@ -611,15 +611,16 @@ FreeHistoryRegisters = __decorateClass([
|
|
|
611
611
|
// src/free-history-manager.ts
|
|
612
612
|
import { cloneDeep as cloneDeep4 } from "lodash";
|
|
613
613
|
import { injectable as injectable7, inject as inject4 } from "inversify";
|
|
614
|
-
import {
|
|
615
|
-
import {
|
|
614
|
+
import { DisposableCollection as DisposableCollection2 } from "@flowgram.ai/utils";
|
|
615
|
+
import { HistoryService as HistoryService4 } from "@flowgram.ai/history";
|
|
616
616
|
import {
|
|
617
617
|
WorkflowDocument as WorkflowDocument9,
|
|
618
618
|
WorkflowResetLayoutService as WorkflowResetLayoutService2,
|
|
619
619
|
WorkflowDragService
|
|
620
620
|
} from "@flowgram.ai/free-layout-core";
|
|
621
|
-
import {
|
|
622
|
-
import {
|
|
621
|
+
import { FlowNodeFormData as FlowNodeFormData3 } from "@flowgram.ai/form-core";
|
|
622
|
+
import { FormManager } from "@flowgram.ai/form-core";
|
|
623
|
+
import { PositionData } from "@flowgram.ai/core";
|
|
623
624
|
var FreeHistoryManager = class {
|
|
624
625
|
constructor() {
|
|
625
626
|
this._toDispose = new DisposableCollection2();
|
|
@@ -645,9 +646,12 @@ var FreeHistoryManager = class {
|
|
|
645
646
|
if (positionData) {
|
|
646
647
|
this._entityManager.addEntityData(positionData);
|
|
647
648
|
}
|
|
649
|
+
}),
|
|
650
|
+
this._formManager.onFormModelWillInit(({ model, data }) => {
|
|
651
|
+
const node = model.flowNodeEntity;
|
|
648
652
|
const formData = node.getData(FlowNodeFormData3);
|
|
649
653
|
if (formData) {
|
|
650
|
-
this._entityManager.setValue(formData, cloneDeep4(data
|
|
654
|
+
this._entityManager.setValue(formData, cloneDeep4(data));
|
|
651
655
|
this._toDispose.push(
|
|
652
656
|
formData.onDetailChange((event) => {
|
|
653
657
|
this._changeNodeDataHandler.handle({
|
|
@@ -696,6 +700,9 @@ __decorateClass([
|
|
|
696
700
|
__decorateClass([
|
|
697
701
|
inject4(HistoryEntityManager)
|
|
698
702
|
], FreeHistoryManager.prototype, "_entityManager", 2);
|
|
703
|
+
__decorateClass([
|
|
704
|
+
inject4(FormManager)
|
|
705
|
+
], FreeHistoryManager.prototype, "_formManager", 2);
|
|
699
706
|
FreeHistoryManager = __decorateClass([
|
|
700
707
|
injectable7()
|
|
701
708
|
], FreeHistoryManager);
|
package/dist/esm/index.js.map
CHANGED
|
@@ -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/drag-nodes.ts","../../src/operation-metas/delete-node.ts","../../src/operation-metas/delete-line.ts","../../src/operation-metas/change-node-data.ts","../../src/operation-metas/add-node.ts","../../src/operation-metas/add-line.ts","../../src/operation-metas/index.ts","../../src/free-history-manager.ts","../../src/index.ts","../../src/hooks/use-undo-redo.tsx"],"sourcesContent":["import { bindContributions, definePluginCreator } from '@flowgram.ai/core';\nimport { HistoryContainerModule, OperationContribution } from '@flowgram.ai/history';\n\nimport { type FreeHistoryPluginOptions } from './types';\nimport { HistoryEntityManager } from './history-entity-manager';\nimport { DragNodesHandler } from './handlers/drag-nodes-handler';\nimport { ChangeNodeDataHandler } from './handlers/change-node-data-handler';\nimport { ChangeContentHandler } from './handlers/change-content-handler';\nimport { FreeHistoryRegisters } from './free-history-registers';\nimport { FreeHistoryManager } from './free-history-manager';\nimport { FreeHistoryConfig } from './free-history-config';\n\nexport const createFreeHistoryPlugin = definePluginCreator<FreeHistoryPluginOptions>({\n onBind: ({ bind }) => {\n bindContributions(bind, FreeHistoryRegisters, [OperationContribution]);\n bind(FreeHistoryConfig).toSelf().inSingletonScope();\n bind(FreeHistoryManager).toSelf().inSingletonScope();\n bind(HistoryEntityManager).toSelf().inSingletonScope();\n bind(DragNodesHandler).toSelf().inSingletonScope();\n bind(ChangeNodeDataHandler).toSelf().inSingletonScope();\n bind(ChangeContentHandler).toSelf().inSingletonScope();\n },\n onInit(ctx, opts): void {\n ctx.get<FreeHistoryConfig>(FreeHistoryConfig).init(ctx, opts);\n\n if (!opts.enable) {\n return;\n }\n ctx.get<FreeHistoryManager>(FreeHistoryManager).onInit(ctx, opts);\n },\n onDispose(ctx) {\n ctx.get<HistoryEntityManager>(HistoryEntityManager).dispose();\n },\n containerModules: [HistoryContainerModule],\n});\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { cloneDeep, isEqual } from 'lodash';\nimport { injectable } from 'inversify';\nimport { type EntityData } from '@flowgram.ai/core';\nimport { type Disposable, DisposableCollection } from '@flowgram.ai/utils';\n\n@injectable()\nexport class HistoryEntityManager implements Disposable {\n private _entityDataValues: Map<EntityData, unknown> = new Map();\n\n private _toDispose: DisposableCollection = new DisposableCollection();\n\n addEntityData(entityData: EntityData) {\n this._entityDataValues.set(entityData, cloneDeep(entityData.toJSON()));\n this._toDispose.push(\n entityData.onWillChange(event => {\n const value = event.toJSON();\n const oldValue = this._entityDataValues.get(entityData);\n if (isEqual(value, oldValue)) {\n return;\n }\n this._entityDataValues.set(entityData, cloneDeep(value));\n }),\n );\n }\n\n getValue(entityData: EntityData) {\n return this._entityDataValues.get(entityData);\n }\n\n setValue(entityData: EntityData, value: unknown) {\n return this._entityDataValues.set(entityData, value);\n }\n\n dispose() {\n this._entityDataValues.clear();\n this._toDispose.dispose();\n }\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { injectable, inject } from 'inversify';\nimport { TransformData } from '@flowgram.ai/core';\nimport { type NodesDragEndEvent } from '@flowgram.ai/free-layout-core';\nimport { HistoryService } from '@flowgram.ai/history';\n\nimport { FreeOperationType, type IHandler } from '../types';\n\n@injectable()\nexport class DragNodesHandler implements IHandler<NodesDragEndEvent> {\n @inject(HistoryService)\n private _historyService: HistoryService;\n\n handle(event: NodesDragEndEvent) {\n if (\n event.type === 'onDragEnd' &&\n !event.altKey // altKey代表创建,这个通过add-node监听处理\n ) {\n this._dragNode(event);\n }\n }\n\n private _dragNode(event: NodesDragEndEvent) {\n this._historyService.pushOperation(\n {\n type: FreeOperationType.dragNodes,\n value: {\n ids: event.nodes.map(node => node.id),\n value: event.nodes.map(node => {\n const { x, y } = node.getData(TransformData).position;\n return {\n x,\n y,\n };\n }),\n oldValue: event.startPositions,\n },\n },\n { noApply: true },\n );\n }\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { type IPoint } from '@flowgram.ai/utils';\nimport { type Operation, type OperationMeta } from '@flowgram.ai/history';\nimport {\n type WorkflowContentChangeType,\n type WorkflowContentChangeEvent,\n type WorkflowLineEntity,\n type WorkflowLinePortInfo,\n type WorkflowNodeJSON,\n type PositionMap,\n} from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity, type FlowNodeJSON } from '@flowgram.ai/document';\nimport { type EntityData, type PluginContext } from '@flowgram.ai/core';\n\nexport enum FreeOperationType {\n addLine = 'addLine',\n deleteLine = 'deleteLine',\n moveNode = 'moveNode',\n addNode = 'addNode',\n deleteNode = 'deleteNode',\n changeNodeData = 'changeNodeData',\n resetLayout = 'resetLayout',\n dragNodes = 'dragNodes',\n}\n\nexport interface AddOrDeleteLineOperationValue extends WorkflowLinePortInfo {\n id: string;\n}\n\nexport interface AddOrDeleteWorkflowNodeOperationValue {\n node: WorkflowNodeJSON;\n parentID?: string;\n}\n\nexport interface AddLineOperation extends Operation {\n type: FreeOperationType.addLine;\n value: AddOrDeleteLineOperationValue;\n}\n\nexport interface DeleteLineOperation extends Operation {\n type: FreeOperationType.deleteLine;\n value: AddOrDeleteLineOperationValue;\n}\n\nexport interface MoveNodeOperation extends Operation {\n type: FreeOperationType.moveNode;\n value: MoveNodeOperationValue;\n}\n\nexport interface AddWorkflowNodeOperation extends Operation {\n type: FreeOperationType.addNode;\n value: AddOrDeleteWorkflowNodeOperationValue;\n}\n\nexport interface DeleteWorkflowNodeOperation extends Operation {\n type: FreeOperationType.deleteNode;\n value: AddOrDeleteWorkflowNodeOperationValue;\n}\n\nexport interface MoveNodeOperationValue {\n id: string;\n value: {\n x: number;\n y: number;\n };\n oldValue: {\n x: number;\n y: number;\n };\n}\n\nexport interface DragNodeOperationValue {\n ids: string[];\n value: IPoint[];\n oldValue: IPoint[];\n}\n\nexport interface ResetLayoutOperationValue {\n ids: string[];\n value: PositionMap;\n oldValue: PositionMap;\n}\n\nexport interface ContentChangeTypeToOperation<T extends Operation> {\n type: WorkflowContentChangeType;\n toOperation: (\n event: WorkflowContentChangeEvent,\n ctx: PluginContext\n ) => T | undefined | Promise<T | undefined>;\n}\n\nexport interface EntityDataType {\n type: FreeOperationType;\n toEntityData: (node: FlowNodeEntity, ctx: PluginContext) => EntityData;\n}\n\nexport interface ChangeNodeDataValue {\n id: string;\n value: unknown;\n oldValue: unknown;\n path: string;\n}\n\nexport interface ChangeNodeDataOperation extends Operation {\n type: FreeOperationType.changeNodeData;\n value: ChangeNodeDataValue;\n}\n\n/**\n * 将node转成json\n */\nexport type NodeToJson = (node: FlowNodeEntity) => FlowNodeJSON;\n/**\n * 将line转成json\n */\nexport type LineToJson = (node: WorkflowLineEntity) => FlowNodeJSON;\n/**\n * 根据节点id获取label\n */\nexport type GetNodeLabelById = (id: string) => string;\n/**\n * 根据节点获取label\n */\nexport type GetNodeLabel = (node: FlowNodeJSON) => string;\n/**\n * 根据分支获取label\n */\nexport type GetBlockLabel = (node: FlowNodeJSON) => string;\n/**\n * 根据节点获取URI\n */\nexport type GetNodeURI = (id: string) => string | any;\n/**\n * 根据连线获取URI\n */\nexport type GetLineURI = (id: string) => string | any;\n\n/**\n * 插件配置\n */\nexport interface FreeHistoryPluginOptions {\n enable?: boolean;\n limit?: number;\n nodeToJSON?: (ctx: PluginContext) => NodeToJson;\n getNodeLabelById?: (ctx: PluginContext) => GetNodeLabelById;\n getNodeLabel?: (ctx: PluginContext) => GetNodeLabel;\n getBlockLabel?: (ctx: PluginContext) => GetBlockLabel;\n getNodeURI?: (ctx: PluginContext) => GetNodeURI;\n getLineURI?: (ctx: PluginContext) => GetLineURI;\n operationMetas?: OperationMeta[];\n enableChangeNode?: boolean;\n uri?: string | any;\n}\n\nexport interface IHandler<E> {\n handle: (event: E, ctx: PluginContext) => void | Promise<void>;\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { cloneDeep, get, isEqual, set } from 'lodash';\nimport { injectable, inject } from 'inversify';\nimport { FlowNodeFormData, type DetailChangeEvent } from '@flowgram.ai/form-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { HistoryService } from '@flowgram.ai/history';\n\nimport { FreeOperationType, type IHandler } from '../types';\nimport { HistoryEntityManager } from '../history-entity-manager';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport interface ChangeNodeDataEvent extends DetailChangeEvent {\n node: FlowNodeEntity;\n}\n\n@injectable()\nexport class ChangeNodeDataHandler implements IHandler<ChangeNodeDataEvent> {\n @inject(HistoryService)\n private _historyService: HistoryService;\n\n @inject(WorkflowDocument) document: WorkflowDocument;\n\n @inject(HistoryEntityManager)\n private _entityManager: HistoryEntityManager;\n\n @inject(FreeHistoryConfig)\n private _config: FreeHistoryConfig;\n\n handle(event: ChangeNodeDataEvent) {\n const { path, value, initialized, node } = event;\n const formData = node.getData<FlowNodeFormData>(FlowNodeFormData);\n const oldValue = this._entityManager.getValue(formData) as object;\n const propPath = path.split('/').filter(Boolean).join('.');\n\n const propOldValue = propPath ? get(oldValue, propPath) : oldValue;\n if (isEqual(value, propOldValue)) {\n return;\n }\n\n if (initialized) {\n let operationPath = path;\n let operationValue = cloneDeep(value);\n let operationOldValue = propOldValue;\n // 只存储一层的数据,因为formModel无法获取数组下的某项的值\n if (path !== '/') {\n const clonedOldValue = cloneDeep(oldValue);\n set(clonedOldValue, propPath, value);\n operationPath = path.split('/').filter(Boolean)[0];\n operationValue = get(clonedOldValue, operationPath);\n operationOldValue = get(oldValue, operationPath);\n }\n\n this._historyService.pushOperation(\n {\n type: FreeOperationType.changeNodeData,\n value: {\n id: node.id,\n path: operationPath,\n value: operationValue,\n oldValue: operationOldValue,\n },\n uri: this._config.getNodeURI(node.id),\n },\n { noApply: true },\n );\n }\n\n if (propPath) {\n set(oldValue, propPath, cloneDeep(value));\n } else {\n this._entityManager.setValue(formData, cloneDeep(value));\n }\n }\n}\n","import { injectable } from 'inversify';\nimport { type FlowNodeEntity, type FlowNodeJSON } from '@flowgram.ai/document';\nimport { type PluginContext } from '@flowgram.ai/core';\n\nimport {\n type FreeHistoryPluginOptions,\n type GetBlockLabel,\n type GetLineURI,\n type GetNodeLabel,\n type GetNodeLabelById,\n type GetNodeURI,\n type NodeToJson,\n} from './types';\n\n@injectable()\nexport class FreeHistoryConfig {\n init(ctx: PluginContext, options: FreeHistoryPluginOptions) {\n this.enable = !!options?.enable;\n\n if (options.nodeToJSON) {\n this.nodeToJSON = options.nodeToJSON(ctx);\n }\n\n if (options.getNodeLabelById) {\n this.getNodeLabelById = options.getNodeLabelById(ctx);\n }\n\n if (options.getNodeLabel) {\n this.getNodeLabel = options.getNodeLabel(ctx);\n }\n\n if (options.getBlockLabel) {\n this.getBlockLabel = options.getBlockLabel(ctx);\n }\n\n if (options.getNodeURI) {\n this.getNodeURI = options.getNodeURI(ctx);\n }\n\n if (options.getLineURI) {\n this.getLineURI = options.getLineURI(ctx);\n }\n }\n\n enable = false;\n\n nodeToJSON: NodeToJson = (node: FlowNodeEntity) => node.toJSON();\n\n getNodeLabelById: GetNodeLabelById = (id: string) => id;\n\n getNodeLabel: GetNodeLabel = (node: FlowNodeJSON) => node.id;\n\n getBlockLabel: GetBlockLabel = (node: FlowNodeJSON) => node.id;\n\n getNodeURI: GetNodeURI = (id: string) => `node:${id}`;\n\n getLineURI: GetLineURI = (id: string) => `line:${id}`;\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { injectable, inject } from 'inversify';\nimport { type PluginContext } from '@flowgram.ai/core';\nimport { type WorkflowContentChangeEvent } from '@flowgram.ai/free-layout-core';\nimport { HistoryService } from '@flowgram.ai/history';\n\nimport { type IHandler } from '../types';\nimport changes from '../changes';\n\n@injectable()\nexport class ChangeContentHandler implements IHandler<WorkflowContentChangeEvent> {\n @inject(HistoryService)\n private _historyService: HistoryService;\n\n async handle(event: WorkflowContentChangeEvent, ctx: PluginContext) {\n if (!this._historyService.undoRedoService.canPush()) {\n return;\n }\n\n const change = changes.find(c => c.type === event.type);\n if (!change) {\n return;\n }\n const operation = await change.toOperation(event, ctx);\n if (!operation) {\n return;\n }\n\n this._historyService.pushOperation(operation, { noApply: true });\n }\n}\n","import { WorkflowDocument, WorkflowContentChangeType, delay } from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\n\nimport {\n type ContentChangeTypeToOperation,\n FreeOperationType,\n type DeleteWorkflowNodeOperation,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const deleteNodeChange: ContentChangeTypeToOperation<DeleteWorkflowNodeOperation> = {\n type: WorkflowContentChangeType.DELETE_NODE,\n toOperation: async (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = event.entity as FlowNodeEntity;\n const json = await document.toNodeJSON(node);\n const parentID = node.parent?.id;\n\n // 删除节点和删除连线同时触发,删除节点需放在后面执行\n await delay(0);\n\n return {\n type: FreeOperationType.deleteNode,\n value: {\n node: json,\n parentID,\n },\n uri: config.getNodeURI(node.id),\n };\n },\n};\n","import { type WorkflowLineEntity } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\n\nimport {\n type AddOrDeleteLineOperationValue,\n type ContentChangeTypeToOperation,\n type DeleteLineOperation,\n FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const deleteLineChange: ContentChangeTypeToOperation<DeleteLineOperation> = {\n type: WorkflowContentChangeType.DELETE_LINE,\n toOperation: (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const line = event.entity as WorkflowLineEntity;\n const value: AddOrDeleteLineOperationValue = {\n from: line.info.from,\n to: line.info.to || '',\n fromPort: line.info.fromPort || '',\n toPort: line.info.toPort || '',\n id: line.id,\n };\n return {\n type: FreeOperationType.deleteLine,\n value,\n uri: config.getNodeURI(line.id),\n };\n },\n};\n","import { WorkflowDocument, delay, type WorkflowNodeJSON } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\n\nimport {\n type AddWorkflowNodeOperation,\n type ContentChangeTypeToOperation,\n FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const addNodeChange: ContentChangeTypeToOperation<AddWorkflowNodeOperation> = {\n type: WorkflowContentChangeType.ADD_NODE,\n toOperation: async (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = event.entity as FlowNodeEntity;\n const parentID = node.parent?.id;\n /**\n * 由于document.toNodeJSON依赖表单里面的default的值初始化,故此处需要等表单的初始化完成\n * 比如dataset-node/index.ts中formatOnSubmit实现需要value被初始化\n */\n await delay(10);\n const json: WorkflowNodeJSON = await document.toNodeJSON(node);\n\n return {\n type: FreeOperationType.addNode,\n value: {\n node: json,\n parentID,\n },\n uri: config.getNodeURI(node.id),\n };\n },\n};\n","import { type WorkflowLineEntity } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\n\nimport {\n type AddLineOperation,\n type AddOrDeleteLineOperationValue,\n type ContentChangeTypeToOperation,\n FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const addLineChange: ContentChangeTypeToOperation<AddLineOperation> = {\n type: WorkflowContentChangeType.ADD_LINE,\n toOperation: (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const line = event.entity as WorkflowLineEntity;\n const value: AddOrDeleteLineOperationValue = {\n from: line.info.from,\n to: line.info.to || '',\n fromPort: line.info.fromPort || '',\n toPort: line.info.toPort || '',\n id: line.id,\n };\n return {\n type: FreeOperationType.addLine,\n value,\n uri: config.getLineURI(line.id),\n };\n },\n};\n","import { deleteNodeChange } from './delete-node-change';\nimport { deleteLineChange } from './delete-line-change';\nimport { addNodeChange } from './add-node-change';\nimport { addLineChange } from './add-line-change';\n\nexport default [addLineChange, deleteLineChange, addNodeChange, deleteNodeChange];\n","import { injectable } from 'inversify';\nimport { type OperationContribution, type OperationRegistry } from '@flowgram.ai/history';\n\nimport { operationMetas } from './operation-metas';\n\n@injectable()\nexport class FreeHistoryRegisters implements OperationContribution {\n registerOperationMeta(operationRegistry: OperationRegistry): void {\n operationMetas.forEach(operationMeta => {\n operationRegistry.registerOperationMeta(operationMeta);\n });\n }\n}\n","import { type PluginContext } from '@flowgram.ai/core';\nimport { WorkflowResetLayoutService } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { FreeOperationType, type ResetLayoutOperationValue } from '../types';\nimport { baseOperationMeta } from './base';\n\nexport const resetLayoutOperationMeta: OperationMeta<\n ResetLayoutOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: FreeOperationType.resetLayout,\n inverse: op => ({\n ...op,\n value: {\n ...op.value,\n value: op.value.oldValue,\n oldValue: op.value.value,\n },\n }),\n apply: async (operation, ctx: PluginContext) => {\n const reset = ctx.get<WorkflowResetLayoutService>(WorkflowResetLayoutService);\n await reset.layoutToPositions(operation.value.ids, operation.value.value);\n },\n shouldMerge: () => false,\n};\n","import { type OperationMeta } from '@flowgram.ai/history';\n\nexport const baseOperationMeta: Partial<OperationMeta> = {\n shouldMerge: (_op, prev, element) => {\n if (!prev) {\n return false;\n }\n\n if (\n // 合并500ms内的操作, 如删除节点会联动删除线条\n Date.now() - element.getTimestamp() <\n 500\n ) {\n return true;\n }\n return false;\n },\n};\n","import { FlowNodeTransformData } from '@flowgram.ai/document';\nimport { type PluginContext, TransformData } from '@flowgram.ai/core';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { type DragNodeOperationValue, FreeOperationType } from '../types';\nimport { baseOperationMeta } from './base';\n\nexport const dragNodesOperationMeta: OperationMeta<DragNodeOperationValue, PluginContext, void> = {\n ...baseOperationMeta,\n type: FreeOperationType.dragNodes,\n inverse: op => ({\n ...op,\n value: {\n ...op.value,\n value: op.value.oldValue,\n oldValue: op.value.value,\n },\n }),\n apply: (operation, ctx) => {\n operation.value.ids.forEach((id, index) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = document.getNode(id);\n if (!node) {\n return;\n }\n\n const transform = node.getData(TransformData);\n const point = operation.value.value[index];\n transform.update({\n position: {\n x: point.x,\n y: point.y,\n },\n });\n // 嵌套情况下需将子节点 transform 设为 dirty\n if (node.collapsedChildren?.length > 0) {\n node.collapsedChildren.forEach(childNode => {\n const childNodeTransformData =\n childNode.getData<FlowNodeTransformData>(FlowNodeTransformData);\n childNodeTransformData.fireChange();\n });\n }\n });\n },\n shouldMerge: () => false,\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 { 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];\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { cloneDeep } from 'lodash';\nimport { injectable, inject } from 'inversify';\nimport { FlowNodeFormData } from '@flowgram.ai/form-core';\nimport { type PluginContext, PositionData } from '@flowgram.ai/core';\nimport {\n WorkflowDocument,\n WorkflowResetLayoutService,\n WorkflowDragService,\n} from '@flowgram.ai/free-layout-core';\nimport { DisposableCollection } from '@flowgram.ai/utils';\nimport { HistoryService } from '@flowgram.ai/history';\n\nimport { 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 private _toDispose: DisposableCollection = new DisposableCollection();\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 const formData = node.getData<FlowNodeFormData>(FlowNodeFormData);\n\n if (formData) {\n this._entityManager.setValue(formData, cloneDeep(data.data));\n\n this._toDispose.push(\n formData.onDetailChange(event => {\n this._changeNodeDataHandler.handle({\n ...event,\n node,\n });\n }),\n );\n }\n }),\n document.onContentChange(async event => {\n await this._changeContentHandler.handle(event, ctx);\n }),\n document.onReload(_event => {\n historyService.clear();\n }),\n resetLayoutService.onResetLayout(event => {\n historyService.pushOperation(\n {\n type: FreeOperationType.resetLayout,\n value: {\n ids: event.nodeIds,\n value: event.positionMap,\n oldValue: event.oldPositionMap,\n },\n },\n { noApply: true },\n );\n }),\n ]);\n }\n\n dispose() {\n this._entityManager.dispose();\n this._toDispose.dispose();\n }\n}\n","export * from './create-free-history-plugin';\nexport * from './types';\nexport * from '@flowgram.ai/history';\nexport * from './free-history-config';\nexport * from './hooks';\nexport * from './free-history-registers';\n","import { useEffect, useState } from 'react';\n\nimport { useService } from '@flowgram.ai/core';\nimport { HistoryService } from '@flowgram.ai/history';\n\ninterface UndoRedo {\n canUndo: boolean;\n canRedo: boolean;\n undo: () => Promise<void>;\n redo: () => Promise<void>;\n}\n\nexport function useUndoRedo(): UndoRedo {\n const historyService = useService<HistoryService>(HistoryService);\n const [canUndo, setCanUndo] = useState(false);\n const [canRedo, setCanRedo] = useState(false);\n\n useEffect(() => {\n const toDispose = historyService.undoRedoService.onChange(() => {\n setCanUndo(historyService.canUndo());\n setCanRedo(historyService.canRedo());\n });\n return () => {\n toDispose.dispose();\n };\n }, []);\n\n return {\n canUndo,\n canRedo,\n undo: () => historyService.undo(),\n redo: () => historyService.redo(),\n };\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,mBAAmB,2BAA2B;AACvD,SAAS,wBAAwB,6BAA6B;;;ACA9D,SAAS,WAAW,eAAe;AACnC,SAAS,kBAAkB;AAE3B,SAA0B,4BAA4B;AAG/C,IAAM,uBAAN,MAAiD;AAAA,EAAjD;AACL,SAAQ,oBAA8C,oBAAI,IAAI;AAE9D,SAAQ,aAAmC,IAAI,qBAAqB;AAAA;AAAA,EAEpE,cAAc,YAAwB;AACpC,SAAK,kBAAkB,IAAI,YAAY,UAAU,WAAW,OAAO,CAAC,CAAC;AACrE,SAAK,WAAW;AAAA,MACd,WAAW,aAAa,WAAS;AAC/B,cAAM,QAAQ,MAAM,OAAO;AAC3B,cAAM,WAAW,KAAK,kBAAkB,IAAI,UAAU;AACtD,YAAI,QAAQ,OAAO,QAAQ,GAAG;AAC5B;AAAA,QACF;AACA,aAAK,kBAAkB,IAAI,YAAY,UAAU,KAAK,CAAC;AAAA,MACzD,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEA,SAAS,YAAwB;AAC/B,WAAO,KAAK,kBAAkB,IAAI,UAAU;AAAA,EAC9C;AAAA,EAEA,SAAS,YAAwB,OAAgB;AAC/C,WAAO,KAAK,kBAAkB,IAAI,YAAY,KAAK;AAAA,EACrD;AAAA,EAEA,UAAU;AACR,SAAK,kBAAkB,MAAM;AAC7B,SAAK,WAAW,QAAQ;AAAA,EAC1B;AACF;AA/Ba,uBAAN;AAAA,EADN,WAAW;AAAA,GACC;;;ACNb,SAAS,cAAAA,aAAY,cAAc;AACnC,SAAS,qBAAqB;AAE9B,SA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AoB,EAAE,QAAQ;AAAA,EAC9D;AAAA,EACA,kBAAkB,CAAC,sBAAsB;AAC3C,CAAC;;;AuBhCD,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","delay","WorkflowContentChangeType","WorkflowContentChangeType","WorkflowDocument","delay","WorkflowContentChangeType","WorkflowContentChangeType","inject","HistoryService","injectable","injectable","TransformData","WorkflowDocument","WorkflowDocument","TransformData","WorkflowDocument","WorkflowDocument","WorkflowDocument","WorkflowDocument","FlowNodeFormData","WorkflowDocument","WorkflowDocument","FlowNodeFormData","cloneDeep","WorkflowDocument","WorkflowDocument","cloneDeep","injectable","cloneDeep","injectable","inject","FlowNodeFormData","WorkflowDocument","WorkflowResetLayoutService","DisposableCollection","HistoryService","DisposableCollection","WorkflowDocument","HistoryService","WorkflowResetLayoutService","FlowNodeFormData","cloneDeep","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/drag-nodes.ts","../../src/operation-metas/delete-node.ts","../../src/operation-metas/delete-line.ts","../../src/operation-metas/change-node-data.ts","../../src/operation-metas/add-node.ts","../../src/operation-metas/add-line.ts","../../src/operation-metas/index.ts","../../src/free-history-manager.ts","../../src/index.ts","../../src/hooks/use-undo-redo.tsx"],"sourcesContent":["import { bindContributions, definePluginCreator } from '@flowgram.ai/core';\nimport { HistoryContainerModule, OperationContribution } from '@flowgram.ai/history';\n\nimport { type FreeHistoryPluginOptions } from './types';\nimport { HistoryEntityManager } from './history-entity-manager';\nimport { DragNodesHandler } from './handlers/drag-nodes-handler';\nimport { ChangeNodeDataHandler } from './handlers/change-node-data-handler';\nimport { ChangeContentHandler } from './handlers/change-content-handler';\nimport { FreeHistoryRegisters } from './free-history-registers';\nimport { FreeHistoryManager } from './free-history-manager';\nimport { FreeHistoryConfig } from './free-history-config';\n\nexport const createFreeHistoryPlugin = definePluginCreator<FreeHistoryPluginOptions>({\n onBind: ({ bind }) => {\n bindContributions(bind, FreeHistoryRegisters, [OperationContribution]);\n bind(FreeHistoryConfig).toSelf().inSingletonScope();\n bind(FreeHistoryManager).toSelf().inSingletonScope();\n bind(HistoryEntityManager).toSelf().inSingletonScope();\n bind(DragNodesHandler).toSelf().inSingletonScope();\n bind(ChangeNodeDataHandler).toSelf().inSingletonScope();\n bind(ChangeContentHandler).toSelf().inSingletonScope();\n },\n onInit(ctx, opts): void {\n ctx.get<FreeHistoryConfig>(FreeHistoryConfig).init(ctx, opts);\n\n if (!opts.enable) {\n return;\n }\n ctx.get<FreeHistoryManager>(FreeHistoryManager).onInit(ctx, opts);\n },\n onDispose(ctx) {\n ctx.get<HistoryEntityManager>(HistoryEntityManager).dispose();\n },\n containerModules: [HistoryContainerModule],\n});\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { cloneDeep, isEqual } from 'lodash';\nimport { injectable } from 'inversify';\nimport { type EntityData } from '@flowgram.ai/core';\nimport { type Disposable, DisposableCollection } from '@flowgram.ai/utils';\n\n@injectable()\nexport class HistoryEntityManager implements Disposable {\n private _entityDataValues: Map<EntityData, unknown> = new Map();\n\n private _toDispose: DisposableCollection = new DisposableCollection();\n\n addEntityData(entityData: EntityData) {\n this._entityDataValues.set(entityData, cloneDeep(entityData.toJSON()));\n this._toDispose.push(\n entityData.onWillChange(event => {\n const value = event.toJSON();\n const oldValue = this._entityDataValues.get(entityData);\n if (isEqual(value, oldValue)) {\n return;\n }\n this._entityDataValues.set(entityData, cloneDeep(value));\n }),\n );\n }\n\n getValue(entityData: EntityData) {\n return this._entityDataValues.get(entityData);\n }\n\n setValue(entityData: EntityData, value: unknown) {\n return this._entityDataValues.set(entityData, value);\n }\n\n dispose() {\n this._entityDataValues.clear();\n this._toDispose.dispose();\n }\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { injectable, inject } from 'inversify';\nimport { TransformData } from '@flowgram.ai/core';\nimport { type NodesDragEndEvent } from '@flowgram.ai/free-layout-core';\nimport { HistoryService } from '@flowgram.ai/history';\n\nimport { FreeOperationType, type IHandler } from '../types';\n\n@injectable()\nexport class DragNodesHandler implements IHandler<NodesDragEndEvent> {\n @inject(HistoryService)\n private _historyService: HistoryService;\n\n handle(event: NodesDragEndEvent) {\n if (\n event.type === 'onDragEnd' &&\n !event.altKey // altKey代表创建,这个通过add-node监听处理\n ) {\n this._dragNode(event);\n }\n }\n\n private _dragNode(event: NodesDragEndEvent) {\n this._historyService.pushOperation(\n {\n type: FreeOperationType.dragNodes,\n value: {\n ids: event.nodes.map(node => node.id),\n value: event.nodes.map(node => {\n const { x, y } = node.getData(TransformData).position;\n return {\n x,\n y,\n };\n }),\n oldValue: event.startPositions,\n },\n },\n { noApply: true },\n );\n }\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { type IPoint } from '@flowgram.ai/utils';\nimport { type Operation, type OperationMeta } from '@flowgram.ai/history';\nimport {\n type WorkflowContentChangeType,\n type WorkflowContentChangeEvent,\n type WorkflowLineEntity,\n type WorkflowLinePortInfo,\n type WorkflowNodeJSON,\n type PositionMap,\n} from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity, type FlowNodeJSON } from '@flowgram.ai/document';\nimport { type EntityData, type PluginContext } from '@flowgram.ai/core';\n\nexport enum FreeOperationType {\n addLine = 'addLine',\n deleteLine = 'deleteLine',\n moveNode = 'moveNode',\n addNode = 'addNode',\n deleteNode = 'deleteNode',\n changeNodeData = 'changeNodeData',\n resetLayout = 'resetLayout',\n dragNodes = 'dragNodes',\n}\n\nexport interface AddOrDeleteLineOperationValue extends WorkflowLinePortInfo {\n id: string;\n}\n\nexport interface AddOrDeleteWorkflowNodeOperationValue {\n node: WorkflowNodeJSON;\n parentID?: string;\n}\n\nexport interface AddLineOperation extends Operation {\n type: FreeOperationType.addLine;\n value: AddOrDeleteLineOperationValue;\n}\n\nexport interface DeleteLineOperation extends Operation {\n type: FreeOperationType.deleteLine;\n value: AddOrDeleteLineOperationValue;\n}\n\nexport interface MoveNodeOperation extends Operation {\n type: FreeOperationType.moveNode;\n value: MoveNodeOperationValue;\n}\n\nexport interface AddWorkflowNodeOperation extends Operation {\n type: FreeOperationType.addNode;\n value: AddOrDeleteWorkflowNodeOperationValue;\n}\n\nexport interface DeleteWorkflowNodeOperation extends Operation {\n type: FreeOperationType.deleteNode;\n value: AddOrDeleteWorkflowNodeOperationValue;\n}\n\nexport interface MoveNodeOperationValue {\n id: string;\n value: {\n x: number;\n y: number;\n };\n oldValue: {\n x: number;\n y: number;\n };\n}\n\nexport interface DragNodeOperationValue {\n ids: string[];\n value: IPoint[];\n oldValue: IPoint[];\n}\n\nexport interface ResetLayoutOperationValue {\n ids: string[];\n value: PositionMap;\n oldValue: PositionMap;\n}\n\nexport interface ContentChangeTypeToOperation<T extends Operation> {\n type: WorkflowContentChangeType;\n toOperation: (\n event: WorkflowContentChangeEvent,\n ctx: PluginContext\n ) => T | undefined | Promise<T | undefined>;\n}\n\nexport interface EntityDataType {\n type: FreeOperationType;\n toEntityData: (node: FlowNodeEntity, ctx: PluginContext) => EntityData;\n}\n\nexport interface ChangeNodeDataValue {\n id: string;\n value: unknown;\n oldValue: unknown;\n path: string;\n}\n\nexport interface ChangeNodeDataOperation extends Operation {\n type: FreeOperationType.changeNodeData;\n value: ChangeNodeDataValue;\n}\n\n/**\n * 将node转成json\n */\nexport type NodeToJson = (node: FlowNodeEntity) => FlowNodeJSON;\n/**\n * 将line转成json\n */\nexport type LineToJson = (node: WorkflowLineEntity) => FlowNodeJSON;\n/**\n * 根据节点id获取label\n */\nexport type GetNodeLabelById = (id: string) => string;\n/**\n * 根据节点获取label\n */\nexport type GetNodeLabel = (node: FlowNodeJSON) => string;\n/**\n * 根据分支获取label\n */\nexport type GetBlockLabel = (node: FlowNodeJSON) => string;\n/**\n * 根据节点获取URI\n */\nexport type GetNodeURI = (id: string) => string | any;\n/**\n * 根据连线获取URI\n */\nexport type GetLineURI = (id: string) => string | any;\n\n/**\n * 插件配置\n */\nexport interface FreeHistoryPluginOptions {\n enable?: boolean;\n limit?: number;\n nodeToJSON?: (ctx: PluginContext) => NodeToJson;\n getNodeLabelById?: (ctx: PluginContext) => GetNodeLabelById;\n getNodeLabel?: (ctx: PluginContext) => GetNodeLabel;\n getBlockLabel?: (ctx: PluginContext) => GetBlockLabel;\n getNodeURI?: (ctx: PluginContext) => GetNodeURI;\n getLineURI?: (ctx: PluginContext) => GetLineURI;\n operationMetas?: OperationMeta[];\n enableChangeNode?: boolean;\n uri?: string | any;\n}\n\nexport interface IHandler<E> {\n handle: (event: E, ctx: PluginContext) => void | Promise<void>;\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { cloneDeep, get, isEqual, set } from 'lodash';\nimport { injectable, inject } from 'inversify';\nimport { FlowNodeFormData, type DetailChangeEvent } from '@flowgram.ai/form-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { HistoryService } from '@flowgram.ai/history';\n\nimport { FreeOperationType, type IHandler } from '../types';\nimport { HistoryEntityManager } from '../history-entity-manager';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport interface ChangeNodeDataEvent extends DetailChangeEvent {\n node: FlowNodeEntity;\n}\n\n@injectable()\nexport class ChangeNodeDataHandler implements IHandler<ChangeNodeDataEvent> {\n @inject(HistoryService)\n private _historyService: HistoryService;\n\n @inject(WorkflowDocument) document: WorkflowDocument;\n\n @inject(HistoryEntityManager)\n private _entityManager: HistoryEntityManager;\n\n @inject(FreeHistoryConfig)\n private _config: FreeHistoryConfig;\n\n handle(event: ChangeNodeDataEvent) {\n const { path, value, initialized, node } = event;\n const formData = node.getData<FlowNodeFormData>(FlowNodeFormData);\n const oldValue = this._entityManager.getValue(formData) as object;\n const propPath = path.split('/').filter(Boolean).join('.');\n\n const propOldValue = propPath ? get(oldValue, propPath) : oldValue;\n if (isEqual(value, propOldValue)) {\n return;\n }\n\n if (initialized) {\n let operationPath = path;\n let operationValue = cloneDeep(value);\n let operationOldValue = propOldValue;\n // 只存储一层的数据,因为formModel无法获取数组下的某项的值\n if (path !== '/') {\n const clonedOldValue = cloneDeep(oldValue);\n set(clonedOldValue, propPath, value);\n operationPath = path.split('/').filter(Boolean)[0];\n operationValue = get(clonedOldValue, operationPath);\n operationOldValue = get(oldValue, operationPath);\n }\n\n this._historyService.pushOperation(\n {\n type: FreeOperationType.changeNodeData,\n value: {\n id: node.id,\n path: operationPath,\n value: operationValue,\n oldValue: operationOldValue,\n },\n uri: this._config.getNodeURI(node.id),\n },\n { noApply: true },\n );\n }\n\n if (propPath) {\n set(oldValue, propPath, cloneDeep(value));\n } else {\n this._entityManager.setValue(formData, cloneDeep(value));\n }\n }\n}\n","import { injectable } from 'inversify';\nimport { type FlowNodeEntity, type FlowNodeJSON } from '@flowgram.ai/document';\nimport { type PluginContext } from '@flowgram.ai/core';\n\nimport {\n type FreeHistoryPluginOptions,\n type GetBlockLabel,\n type GetLineURI,\n type GetNodeLabel,\n type GetNodeLabelById,\n type GetNodeURI,\n type NodeToJson,\n} from './types';\n\n@injectable()\nexport class FreeHistoryConfig {\n init(ctx: PluginContext, options: FreeHistoryPluginOptions) {\n this.enable = !!options?.enable;\n\n if (options.nodeToJSON) {\n this.nodeToJSON = options.nodeToJSON(ctx);\n }\n\n if (options.getNodeLabelById) {\n this.getNodeLabelById = options.getNodeLabelById(ctx);\n }\n\n if (options.getNodeLabel) {\n this.getNodeLabel = options.getNodeLabel(ctx);\n }\n\n if (options.getBlockLabel) {\n this.getBlockLabel = options.getBlockLabel(ctx);\n }\n\n if (options.getNodeURI) {\n this.getNodeURI = options.getNodeURI(ctx);\n }\n\n if (options.getLineURI) {\n this.getLineURI = options.getLineURI(ctx);\n }\n }\n\n enable = false;\n\n nodeToJSON: NodeToJson = (node: FlowNodeEntity) => node.toJSON();\n\n getNodeLabelById: GetNodeLabelById = (id: string) => id;\n\n getNodeLabel: GetNodeLabel = (node: FlowNodeJSON) => node.id;\n\n getBlockLabel: GetBlockLabel = (node: FlowNodeJSON) => node.id;\n\n getNodeURI: GetNodeURI = (id: string) => `node:${id}`;\n\n getLineURI: GetLineURI = (id: string) => `line:${id}`;\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { injectable, inject } from 'inversify';\nimport { type PluginContext } from '@flowgram.ai/core';\nimport { type WorkflowContentChangeEvent } from '@flowgram.ai/free-layout-core';\nimport { HistoryService } from '@flowgram.ai/history';\n\nimport { type IHandler } from '../types';\nimport changes from '../changes';\n\n@injectable()\nexport class ChangeContentHandler implements IHandler<WorkflowContentChangeEvent> {\n @inject(HistoryService)\n private _historyService: HistoryService;\n\n async handle(event: WorkflowContentChangeEvent, ctx: PluginContext) {\n if (!this._historyService.undoRedoService.canPush()) {\n return;\n }\n\n const change = changes.find(c => c.type === event.type);\n if (!change) {\n return;\n }\n const operation = await change.toOperation(event, ctx);\n if (!operation) {\n return;\n }\n\n this._historyService.pushOperation(operation, { noApply: true });\n }\n}\n","import { WorkflowDocument, WorkflowContentChangeType, delay } from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\n\nimport {\n type ContentChangeTypeToOperation,\n FreeOperationType,\n type DeleteWorkflowNodeOperation,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const deleteNodeChange: ContentChangeTypeToOperation<DeleteWorkflowNodeOperation> = {\n type: WorkflowContentChangeType.DELETE_NODE,\n toOperation: async (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = event.entity as FlowNodeEntity;\n const json = await document.toNodeJSON(node);\n const parentID = node.parent?.id;\n\n // 删除节点和删除连线同时触发,删除节点需放在后面执行\n await delay(0);\n\n return {\n type: FreeOperationType.deleteNode,\n value: {\n node: json,\n parentID,\n },\n uri: config.getNodeURI(node.id),\n };\n },\n};\n","import { type WorkflowLineEntity } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\n\nimport {\n type AddOrDeleteLineOperationValue,\n type ContentChangeTypeToOperation,\n type DeleteLineOperation,\n FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const deleteLineChange: ContentChangeTypeToOperation<DeleteLineOperation> = {\n type: WorkflowContentChangeType.DELETE_LINE,\n toOperation: (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const line = event.entity as WorkflowLineEntity;\n const value: AddOrDeleteLineOperationValue = {\n from: line.info.from,\n to: line.info.to || '',\n fromPort: line.info.fromPort || '',\n toPort: line.info.toPort || '',\n id: line.id,\n };\n return {\n type: FreeOperationType.deleteLine,\n value,\n uri: config.getNodeURI(line.id),\n };\n },\n};\n","import { WorkflowDocument, delay, type WorkflowNodeJSON } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\n\nimport {\n type AddWorkflowNodeOperation,\n type ContentChangeTypeToOperation,\n FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const addNodeChange: ContentChangeTypeToOperation<AddWorkflowNodeOperation> = {\n type: WorkflowContentChangeType.ADD_NODE,\n toOperation: async (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = event.entity as FlowNodeEntity;\n const parentID = node.parent?.id;\n /**\n * 由于document.toNodeJSON依赖表单里面的default的值初始化,故此处需要等表单的初始化完成\n * 比如dataset-node/index.ts中formatOnSubmit实现需要value被初始化\n */\n await delay(10);\n const json: WorkflowNodeJSON = await document.toNodeJSON(node);\n\n return {\n type: FreeOperationType.addNode,\n value: {\n node: json,\n parentID,\n },\n uri: config.getNodeURI(node.id),\n };\n },\n};\n","import { type WorkflowLineEntity } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\n\nimport {\n type AddLineOperation,\n type AddOrDeleteLineOperationValue,\n type ContentChangeTypeToOperation,\n FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const addLineChange: ContentChangeTypeToOperation<AddLineOperation> = {\n type: WorkflowContentChangeType.ADD_LINE,\n toOperation: (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const line = event.entity as WorkflowLineEntity;\n const value: AddOrDeleteLineOperationValue = {\n from: line.info.from,\n to: line.info.to || '',\n fromPort: line.info.fromPort || '',\n toPort: line.info.toPort || '',\n id: line.id,\n };\n return {\n type: FreeOperationType.addLine,\n value,\n uri: config.getLineURI(line.id),\n };\n },\n};\n","import { deleteNodeChange } from './delete-node-change';\nimport { deleteLineChange } from './delete-line-change';\nimport { addNodeChange } from './add-node-change';\nimport { addLineChange } from './add-line-change';\n\nexport default [addLineChange, deleteLineChange, addNodeChange, deleteNodeChange];\n","import { injectable } from 'inversify';\nimport { type OperationContribution, type OperationRegistry } from '@flowgram.ai/history';\n\nimport { operationMetas } from './operation-metas';\n\n@injectable()\nexport class FreeHistoryRegisters implements OperationContribution {\n registerOperationMeta(operationRegistry: OperationRegistry): void {\n operationMetas.forEach(operationMeta => {\n operationRegistry.registerOperationMeta(operationMeta);\n });\n }\n}\n","import { type PluginContext } from '@flowgram.ai/core';\nimport { WorkflowResetLayoutService } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { FreeOperationType, type ResetLayoutOperationValue } from '../types';\nimport { baseOperationMeta } from './base';\n\nexport const resetLayoutOperationMeta: OperationMeta<\n ResetLayoutOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: FreeOperationType.resetLayout,\n inverse: op => ({\n ...op,\n value: {\n ...op.value,\n value: op.value.oldValue,\n oldValue: op.value.value,\n },\n }),\n apply: async (operation, ctx: PluginContext) => {\n const reset = ctx.get<WorkflowResetLayoutService>(WorkflowResetLayoutService);\n await reset.layoutToPositions(operation.value.ids, operation.value.value);\n },\n shouldMerge: () => false,\n};\n","import { type OperationMeta } from '@flowgram.ai/history';\n\nexport const baseOperationMeta: Partial<OperationMeta> = {\n shouldMerge: (_op, prev, element) => {\n if (!prev) {\n return false;\n }\n\n if (\n // 合并500ms内的操作, 如删除节点会联动删除线条\n Date.now() - element.getTimestamp() <\n 500\n ) {\n return true;\n }\n return false;\n },\n};\n","import { FlowNodeTransformData } from '@flowgram.ai/document';\nimport { type PluginContext, TransformData } from '@flowgram.ai/core';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { type DragNodeOperationValue, FreeOperationType } from '../types';\nimport { baseOperationMeta } from './base';\n\nexport const dragNodesOperationMeta: OperationMeta<DragNodeOperationValue, PluginContext, void> = {\n ...baseOperationMeta,\n type: FreeOperationType.dragNodes,\n inverse: op => ({\n ...op,\n value: {\n ...op.value,\n value: op.value.oldValue,\n oldValue: op.value.value,\n },\n }),\n apply: (operation, ctx) => {\n operation.value.ids.forEach((id, index) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = document.getNode(id);\n if (!node) {\n return;\n }\n\n const transform = node.getData(TransformData);\n const point = operation.value.value[index];\n transform.update({\n position: {\n x: point.x,\n y: point.y,\n },\n });\n // 嵌套情况下需将子节点 transform 设为 dirty\n if (node.collapsedChildren?.length > 0) {\n node.collapsedChildren.forEach(childNode => {\n const childNodeTransformData =\n childNode.getData<FlowNodeTransformData>(FlowNodeTransformData);\n childNodeTransformData.fireChange();\n });\n }\n });\n },\n shouldMerge: () => false,\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 { 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];\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { cloneDeep } from 'lodash';\nimport { injectable, inject } from 'inversify';\nimport { DisposableCollection } from '@flowgram.ai/utils';\nimport { HistoryService } from '@flowgram.ai/history';\nimport {\n WorkflowDocument,\n WorkflowResetLayoutService,\n WorkflowDragService,\n} from '@flowgram.ai/free-layout-core';\nimport { FlowNodeFormData } from '@flowgram.ai/form-core';\nimport { FormManager } from '@flowgram.ai/form-core';\nimport { type PluginContext, PositionData } from '@flowgram.ai/core';\n\nimport { type FreeHistoryPluginOptions, FreeOperationType } from './types';\nimport { HistoryEntityManager } from './history-entity-manager';\nimport { DragNodesHandler } from './handlers/drag-nodes-handler';\nimport { ChangeNodeDataHandler } from './handlers/change-node-data-handler';\nimport { ChangeContentHandler } from './handlers/change-content-handler';\n\n/**\n * 历史管理\n */\n@injectable()\nexport class FreeHistoryManager {\n @inject(DragNodesHandler)\n private _dragNodesHandler: DragNodesHandler;\n\n @inject(ChangeNodeDataHandler)\n private _changeNodeDataHandler: ChangeNodeDataHandler;\n\n @inject(ChangeContentHandler)\n private _changeContentHandler: ChangeContentHandler;\n\n @inject(HistoryEntityManager)\n private _entityManager: HistoryEntityManager;\n\n @inject(FormManager)\n private _formManager: FormManager;\n\n private _toDispose: DisposableCollection = new DisposableCollection();\n\n onInit(ctx: PluginContext, opts: FreeHistoryPluginOptions) {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const historyService = ctx.get<HistoryService>(HistoryService);\n const dragService = ctx.get<WorkflowDragService>(WorkflowDragService);\n\n const resetLayoutService = ctx.get<WorkflowResetLayoutService>(WorkflowResetLayoutService);\n\n if (opts?.limit) {\n historyService.limit(opts.limit);\n }\n historyService.context.source = ctx;\n\n this._toDispose.pushAll([\n dragService.onNodesDrag(async (event) => {\n if (event.type !== 'onDragEnd') {\n return;\n }\n this._dragNodesHandler.handle(event);\n }),\n document.onNodeCreate(({ node, data }) => {\n const positionData = node.getData(PositionData);\n if (positionData) {\n this._entityManager.addEntityData(positionData);\n }\n }),\n this._formManager.onFormModelWillInit(({ model, data }) => {\n const node = model.flowNodeEntity;\n const formData = node.getData<FlowNodeFormData>(FlowNodeFormData);\n\n if (formData) {\n this._entityManager.setValue(formData, cloneDeep(data));\n\n this._toDispose.push(\n formData.onDetailChange((event) => {\n this._changeNodeDataHandler.handle({\n ...event,\n node,\n });\n })\n );\n }\n }),\n document.onContentChange(async (event) => {\n await this._changeContentHandler.handle(event, ctx);\n }),\n document.onReload((_event) => {\n historyService.clear();\n }),\n resetLayoutService.onResetLayout((event) => {\n historyService.pushOperation(\n {\n type: FreeOperationType.resetLayout,\n value: {\n ids: event.nodeIds,\n value: event.positionMap,\n oldValue: event.oldPositionMap,\n },\n },\n { noApply: true }\n );\n }),\n ]);\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,S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;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","delay","WorkflowContentChangeType","WorkflowContentChangeType","WorkflowDocument","delay","WorkflowContentChangeType","WorkflowContentChangeType","inject","HistoryService","injectable","injectable","TransformData","WorkflowDocument","WorkflowDocument","TransformData","WorkflowDocument","WorkflowDocument","WorkflowDocument","WorkflowDocument","FlowNodeFormData","WorkflowDocument","WorkflowDocument","FlowNodeFormData","cloneDeep","WorkflowDocument","WorkflowDocument","cloneDeep","injectable","cloneDeep","injectable","inject","DisposableCollection","HistoryService","WorkflowDocument","WorkflowResetLayoutService","FlowNodeFormData","DisposableCollection","WorkflowDocument","HistoryService","WorkflowResetLayoutService","FlowNodeFormData","cloneDeep","inject","injectable","HistoryService"]}
|
package/dist/index.js
CHANGED
|
@@ -639,11 +639,12 @@ FreeHistoryRegisters = __decorateClass([
|
|
|
639
639
|
// src/free-history-manager.ts
|
|
640
640
|
var import_lodash4 = require("lodash");
|
|
641
641
|
var import_inversify7 = require("inversify");
|
|
642
|
-
var import_form_core3 = require("@flowgram.ai/form-core");
|
|
643
|
-
var import_core3 = require("@flowgram.ai/core");
|
|
644
|
-
var import_free_layout_core14 = require("@flowgram.ai/free-layout-core");
|
|
645
642
|
var import_utils2 = require("@flowgram.ai/utils");
|
|
646
643
|
var import_history4 = require("@flowgram.ai/history");
|
|
644
|
+
var import_free_layout_core14 = require("@flowgram.ai/free-layout-core");
|
|
645
|
+
var import_form_core3 = require("@flowgram.ai/form-core");
|
|
646
|
+
var import_form_core4 = require("@flowgram.ai/form-core");
|
|
647
|
+
var import_core3 = require("@flowgram.ai/core");
|
|
647
648
|
var FreeHistoryManager = class {
|
|
648
649
|
constructor() {
|
|
649
650
|
this._toDispose = new import_utils2.DisposableCollection();
|
|
@@ -669,9 +670,12 @@ var FreeHistoryManager = class {
|
|
|
669
670
|
if (positionData) {
|
|
670
671
|
this._entityManager.addEntityData(positionData);
|
|
671
672
|
}
|
|
673
|
+
}),
|
|
674
|
+
this._formManager.onFormModelWillInit(({ model, data }) => {
|
|
675
|
+
const node = model.flowNodeEntity;
|
|
672
676
|
const formData = node.getData(import_form_core3.FlowNodeFormData);
|
|
673
677
|
if (formData) {
|
|
674
|
-
this._entityManager.setValue(formData, (0, import_lodash4.cloneDeep)(data
|
|
678
|
+
this._entityManager.setValue(formData, (0, import_lodash4.cloneDeep)(data));
|
|
675
679
|
this._toDispose.push(
|
|
676
680
|
formData.onDetailChange((event) => {
|
|
677
681
|
this._changeNodeDataHandler.handle({
|
|
@@ -720,6 +724,9 @@ __decorateClass([
|
|
|
720
724
|
__decorateClass([
|
|
721
725
|
(0, import_inversify7.inject)(HistoryEntityManager)
|
|
722
726
|
], FreeHistoryManager.prototype, "_entityManager", 2);
|
|
727
|
+
__decorateClass([
|
|
728
|
+
(0, import_inversify7.inject)(import_form_core4.FormManager)
|
|
729
|
+
], FreeHistoryManager.prototype, "_formManager", 2);
|
|
723
730
|
FreeHistoryManager = __decorateClass([
|
|
724
731
|
(0, import_inversify7.injectable)()
|
|
725
732
|
], FreeHistoryManager);
|
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/drag-nodes.ts","../src/operation-metas/delete-node.ts","../src/operation-metas/delete-line.ts","../src/operation-metas/change-node-data.ts","../src/operation-metas/add-node.ts","../src/operation-metas/add-line.ts","../src/operation-metas/index.ts","../src/free-history-manager.ts","../src/hooks/use-undo-redo.tsx"],"sourcesContent":["export * from './create-free-history-plugin';\nexport * from './types';\nexport * from '@flowgram.ai/history';\nexport * from './free-history-config';\nexport * from './hooks';\nexport * from './free-history-registers';\n","import { bindContributions, definePluginCreator } from '@flowgram.ai/core';\nimport { HistoryContainerModule, OperationContribution } from '@flowgram.ai/history';\n\nimport { type FreeHistoryPluginOptions } from './types';\nimport { HistoryEntityManager } from './history-entity-manager';\nimport { DragNodesHandler } from './handlers/drag-nodes-handler';\nimport { ChangeNodeDataHandler } from './handlers/change-node-data-handler';\nimport { ChangeContentHandler } from './handlers/change-content-handler';\nimport { FreeHistoryRegisters } from './free-history-registers';\nimport { FreeHistoryManager } from './free-history-manager';\nimport { FreeHistoryConfig } from './free-history-config';\n\nexport const createFreeHistoryPlugin = definePluginCreator<FreeHistoryPluginOptions>({\n onBind: ({ bind }) => {\n bindContributions(bind, FreeHistoryRegisters, [OperationContribution]);\n bind(FreeHistoryConfig).toSelf().inSingletonScope();\n bind(FreeHistoryManager).toSelf().inSingletonScope();\n bind(HistoryEntityManager).toSelf().inSingletonScope();\n bind(DragNodesHandler).toSelf().inSingletonScope();\n bind(ChangeNodeDataHandler).toSelf().inSingletonScope();\n bind(ChangeContentHandler).toSelf().inSingletonScope();\n },\n onInit(ctx, opts): void {\n ctx.get<FreeHistoryConfig>(FreeHistoryConfig).init(ctx, opts);\n\n if (!opts.enable) {\n return;\n }\n ctx.get<FreeHistoryManager>(FreeHistoryManager).onInit(ctx, opts);\n },\n onDispose(ctx) {\n ctx.get<HistoryEntityManager>(HistoryEntityManager).dispose();\n },\n containerModules: [HistoryContainerModule],\n});\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { cloneDeep, isEqual } from 'lodash';\nimport { injectable } from 'inversify';\nimport { type EntityData } from '@flowgram.ai/core';\nimport { type Disposable, DisposableCollection } from '@flowgram.ai/utils';\n\n@injectable()\nexport class HistoryEntityManager implements Disposable {\n private _entityDataValues: Map<EntityData, unknown> = new Map();\n\n private _toDispose: DisposableCollection = new DisposableCollection();\n\n addEntityData(entityData: EntityData) {\n this._entityDataValues.set(entityData, cloneDeep(entityData.toJSON()));\n this._toDispose.push(\n entityData.onWillChange(event => {\n const value = event.toJSON();\n const oldValue = this._entityDataValues.get(entityData);\n if (isEqual(value, oldValue)) {\n return;\n }\n this._entityDataValues.set(entityData, cloneDeep(value));\n }),\n );\n }\n\n getValue(entityData: EntityData) {\n return this._entityDataValues.get(entityData);\n }\n\n setValue(entityData: EntityData, value: unknown) {\n return this._entityDataValues.set(entityData, value);\n }\n\n dispose() {\n this._entityDataValues.clear();\n this._toDispose.dispose();\n }\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { injectable, inject } from 'inversify';\nimport { TransformData } from '@flowgram.ai/core';\nimport { type NodesDragEndEvent } from '@flowgram.ai/free-layout-core';\nimport { HistoryService } from '@flowgram.ai/history';\n\nimport { FreeOperationType, type IHandler } from '../types';\n\n@injectable()\nexport class DragNodesHandler implements IHandler<NodesDragEndEvent> {\n @inject(HistoryService)\n private _historyService: HistoryService;\n\n handle(event: NodesDragEndEvent) {\n if (\n event.type === 'onDragEnd' &&\n !event.altKey // altKey代表创建,这个通过add-node监听处理\n ) {\n this._dragNode(event);\n }\n }\n\n private _dragNode(event: NodesDragEndEvent) {\n this._historyService.pushOperation(\n {\n type: FreeOperationType.dragNodes,\n value: {\n ids: event.nodes.map(node => node.id),\n value: event.nodes.map(node => {\n const { x, y } = node.getData(TransformData).position;\n return {\n x,\n y,\n };\n }),\n oldValue: event.startPositions,\n },\n },\n { noApply: true },\n );\n }\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { type IPoint } from '@flowgram.ai/utils';\nimport { type Operation, type OperationMeta } from '@flowgram.ai/history';\nimport {\n type WorkflowContentChangeType,\n type WorkflowContentChangeEvent,\n type WorkflowLineEntity,\n type WorkflowLinePortInfo,\n type WorkflowNodeJSON,\n type PositionMap,\n} from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity, type FlowNodeJSON } from '@flowgram.ai/document';\nimport { type EntityData, type PluginContext } from '@flowgram.ai/core';\n\nexport enum FreeOperationType {\n addLine = 'addLine',\n deleteLine = 'deleteLine',\n moveNode = 'moveNode',\n addNode = 'addNode',\n deleteNode = 'deleteNode',\n changeNodeData = 'changeNodeData',\n resetLayout = 'resetLayout',\n dragNodes = 'dragNodes',\n}\n\nexport interface AddOrDeleteLineOperationValue extends WorkflowLinePortInfo {\n id: string;\n}\n\nexport interface AddOrDeleteWorkflowNodeOperationValue {\n node: WorkflowNodeJSON;\n parentID?: string;\n}\n\nexport interface AddLineOperation extends Operation {\n type: FreeOperationType.addLine;\n value: AddOrDeleteLineOperationValue;\n}\n\nexport interface DeleteLineOperation extends Operation {\n type: FreeOperationType.deleteLine;\n value: AddOrDeleteLineOperationValue;\n}\n\nexport interface MoveNodeOperation extends Operation {\n type: FreeOperationType.moveNode;\n value: MoveNodeOperationValue;\n}\n\nexport interface AddWorkflowNodeOperation extends Operation {\n type: FreeOperationType.addNode;\n value: AddOrDeleteWorkflowNodeOperationValue;\n}\n\nexport interface DeleteWorkflowNodeOperation extends Operation {\n type: FreeOperationType.deleteNode;\n value: AddOrDeleteWorkflowNodeOperationValue;\n}\n\nexport interface MoveNodeOperationValue {\n id: string;\n value: {\n x: number;\n y: number;\n };\n oldValue: {\n x: number;\n y: number;\n };\n}\n\nexport interface DragNodeOperationValue {\n ids: string[];\n value: IPoint[];\n oldValue: IPoint[];\n}\n\nexport interface ResetLayoutOperationValue {\n ids: string[];\n value: PositionMap;\n oldValue: PositionMap;\n}\n\nexport interface ContentChangeTypeToOperation<T extends Operation> {\n type: WorkflowContentChangeType;\n toOperation: (\n event: WorkflowContentChangeEvent,\n ctx: PluginContext\n ) => T | undefined | Promise<T | undefined>;\n}\n\nexport interface EntityDataType {\n type: FreeOperationType;\n toEntityData: (node: FlowNodeEntity, ctx: PluginContext) => EntityData;\n}\n\nexport interface ChangeNodeDataValue {\n id: string;\n value: unknown;\n oldValue: unknown;\n path: string;\n}\n\nexport interface ChangeNodeDataOperation extends Operation {\n type: FreeOperationType.changeNodeData;\n value: ChangeNodeDataValue;\n}\n\n/**\n * 将node转成json\n */\nexport type NodeToJson = (node: FlowNodeEntity) => FlowNodeJSON;\n/**\n * 将line转成json\n */\nexport type LineToJson = (node: WorkflowLineEntity) => FlowNodeJSON;\n/**\n * 根据节点id获取label\n */\nexport type GetNodeLabelById = (id: string) => string;\n/**\n * 根据节点获取label\n */\nexport type GetNodeLabel = (node: FlowNodeJSON) => string;\n/**\n * 根据分支获取label\n */\nexport type GetBlockLabel = (node: FlowNodeJSON) => string;\n/**\n * 根据节点获取URI\n */\nexport type GetNodeURI = (id: string) => string | any;\n/**\n * 根据连线获取URI\n */\nexport type GetLineURI = (id: string) => string | any;\n\n/**\n * 插件配置\n */\nexport interface FreeHistoryPluginOptions {\n enable?: boolean;\n limit?: number;\n nodeToJSON?: (ctx: PluginContext) => NodeToJson;\n getNodeLabelById?: (ctx: PluginContext) => GetNodeLabelById;\n getNodeLabel?: (ctx: PluginContext) => GetNodeLabel;\n getBlockLabel?: (ctx: PluginContext) => GetBlockLabel;\n getNodeURI?: (ctx: PluginContext) => GetNodeURI;\n getLineURI?: (ctx: PluginContext) => GetLineURI;\n operationMetas?: OperationMeta[];\n enableChangeNode?: boolean;\n uri?: string | any;\n}\n\nexport interface IHandler<E> {\n handle: (event: E, ctx: PluginContext) => void | Promise<void>;\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { cloneDeep, get, isEqual, set } from 'lodash';\nimport { injectable, inject } from 'inversify';\nimport { FlowNodeFormData, type DetailChangeEvent } from '@flowgram.ai/form-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { HistoryService } from '@flowgram.ai/history';\n\nimport { FreeOperationType, type IHandler } from '../types';\nimport { HistoryEntityManager } from '../history-entity-manager';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport interface ChangeNodeDataEvent extends DetailChangeEvent {\n node: FlowNodeEntity;\n}\n\n@injectable()\nexport class ChangeNodeDataHandler implements IHandler<ChangeNodeDataEvent> {\n @inject(HistoryService)\n private _historyService: HistoryService;\n\n @inject(WorkflowDocument) document: WorkflowDocument;\n\n @inject(HistoryEntityManager)\n private _entityManager: HistoryEntityManager;\n\n @inject(FreeHistoryConfig)\n private _config: FreeHistoryConfig;\n\n handle(event: ChangeNodeDataEvent) {\n const { path, value, initialized, node } = event;\n const formData = node.getData<FlowNodeFormData>(FlowNodeFormData);\n const oldValue = this._entityManager.getValue(formData) as object;\n const propPath = path.split('/').filter(Boolean).join('.');\n\n const propOldValue = propPath ? get(oldValue, propPath) : oldValue;\n if (isEqual(value, propOldValue)) {\n return;\n }\n\n if (initialized) {\n let operationPath = path;\n let operationValue = cloneDeep(value);\n let operationOldValue = propOldValue;\n // 只存储一层的数据,因为formModel无法获取数组下的某项的值\n if (path !== '/') {\n const clonedOldValue = cloneDeep(oldValue);\n set(clonedOldValue, propPath, value);\n operationPath = path.split('/').filter(Boolean)[0];\n operationValue = get(clonedOldValue, operationPath);\n operationOldValue = get(oldValue, operationPath);\n }\n\n this._historyService.pushOperation(\n {\n type: FreeOperationType.changeNodeData,\n value: {\n id: node.id,\n path: operationPath,\n value: operationValue,\n oldValue: operationOldValue,\n },\n uri: this._config.getNodeURI(node.id),\n },\n { noApply: true },\n );\n }\n\n if (propPath) {\n set(oldValue, propPath, cloneDeep(value));\n } else {\n this._entityManager.setValue(formData, cloneDeep(value));\n }\n }\n}\n","import { injectable } from 'inversify';\nimport { type FlowNodeEntity, type FlowNodeJSON } from '@flowgram.ai/document';\nimport { type PluginContext } from '@flowgram.ai/core';\n\nimport {\n type FreeHistoryPluginOptions,\n type GetBlockLabel,\n type GetLineURI,\n type GetNodeLabel,\n type GetNodeLabelById,\n type GetNodeURI,\n type NodeToJson,\n} from './types';\n\n@injectable()\nexport class FreeHistoryConfig {\n init(ctx: PluginContext, options: FreeHistoryPluginOptions) {\n this.enable = !!options?.enable;\n\n if (options.nodeToJSON) {\n this.nodeToJSON = options.nodeToJSON(ctx);\n }\n\n if (options.getNodeLabelById) {\n this.getNodeLabelById = options.getNodeLabelById(ctx);\n }\n\n if (options.getNodeLabel) {\n this.getNodeLabel = options.getNodeLabel(ctx);\n }\n\n if (options.getBlockLabel) {\n this.getBlockLabel = options.getBlockLabel(ctx);\n }\n\n if (options.getNodeURI) {\n this.getNodeURI = options.getNodeURI(ctx);\n }\n\n if (options.getLineURI) {\n this.getLineURI = options.getLineURI(ctx);\n }\n }\n\n enable = false;\n\n nodeToJSON: NodeToJson = (node: FlowNodeEntity) => node.toJSON();\n\n getNodeLabelById: GetNodeLabelById = (id: string) => id;\n\n getNodeLabel: GetNodeLabel = (node: FlowNodeJSON) => node.id;\n\n getBlockLabel: GetBlockLabel = (node: FlowNodeJSON) => node.id;\n\n getNodeURI: GetNodeURI = (id: string) => `node:${id}`;\n\n getLineURI: GetLineURI = (id: string) => `line:${id}`;\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { injectable, inject } from 'inversify';\nimport { type PluginContext } from '@flowgram.ai/core';\nimport { type WorkflowContentChangeEvent } from '@flowgram.ai/free-layout-core';\nimport { HistoryService } from '@flowgram.ai/history';\n\nimport { type IHandler } from '../types';\nimport changes from '../changes';\n\n@injectable()\nexport class ChangeContentHandler implements IHandler<WorkflowContentChangeEvent> {\n @inject(HistoryService)\n private _historyService: HistoryService;\n\n async handle(event: WorkflowContentChangeEvent, ctx: PluginContext) {\n if (!this._historyService.undoRedoService.canPush()) {\n return;\n }\n\n const change = changes.find(c => c.type === event.type);\n if (!change) {\n return;\n }\n const operation = await change.toOperation(event, ctx);\n if (!operation) {\n return;\n }\n\n this._historyService.pushOperation(operation, { noApply: true });\n }\n}\n","import { WorkflowDocument, WorkflowContentChangeType, delay } from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\n\nimport {\n type ContentChangeTypeToOperation,\n FreeOperationType,\n type DeleteWorkflowNodeOperation,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const deleteNodeChange: ContentChangeTypeToOperation<DeleteWorkflowNodeOperation> = {\n type: WorkflowContentChangeType.DELETE_NODE,\n toOperation: async (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = event.entity as FlowNodeEntity;\n const json = await document.toNodeJSON(node);\n const parentID = node.parent?.id;\n\n // 删除节点和删除连线同时触发,删除节点需放在后面执行\n await delay(0);\n\n return {\n type: FreeOperationType.deleteNode,\n value: {\n node: json,\n parentID,\n },\n uri: config.getNodeURI(node.id),\n };\n },\n};\n","import { type WorkflowLineEntity } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\n\nimport {\n type AddOrDeleteLineOperationValue,\n type ContentChangeTypeToOperation,\n type DeleteLineOperation,\n FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const deleteLineChange: ContentChangeTypeToOperation<DeleteLineOperation> = {\n type: WorkflowContentChangeType.DELETE_LINE,\n toOperation: (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const line = event.entity as WorkflowLineEntity;\n const value: AddOrDeleteLineOperationValue = {\n from: line.info.from,\n to: line.info.to || '',\n fromPort: line.info.fromPort || '',\n toPort: line.info.toPort || '',\n id: line.id,\n };\n return {\n type: FreeOperationType.deleteLine,\n value,\n uri: config.getNodeURI(line.id),\n };\n },\n};\n","import { WorkflowDocument, delay, type WorkflowNodeJSON } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\n\nimport {\n type AddWorkflowNodeOperation,\n type ContentChangeTypeToOperation,\n FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const addNodeChange: ContentChangeTypeToOperation<AddWorkflowNodeOperation> = {\n type: WorkflowContentChangeType.ADD_NODE,\n toOperation: async (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = event.entity as FlowNodeEntity;\n const parentID = node.parent?.id;\n /**\n * 由于document.toNodeJSON依赖表单里面的default的值初始化,故此处需要等表单的初始化完成\n * 比如dataset-node/index.ts中formatOnSubmit实现需要value被初始化\n */\n await delay(10);\n const json: WorkflowNodeJSON = await document.toNodeJSON(node);\n\n return {\n type: FreeOperationType.addNode,\n value: {\n node: json,\n parentID,\n },\n uri: config.getNodeURI(node.id),\n };\n },\n};\n","import { type WorkflowLineEntity } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\n\nimport {\n type AddLineOperation,\n type AddOrDeleteLineOperationValue,\n type ContentChangeTypeToOperation,\n FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const addLineChange: ContentChangeTypeToOperation<AddLineOperation> = {\n type: WorkflowContentChangeType.ADD_LINE,\n toOperation: (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const line = event.entity as WorkflowLineEntity;\n const value: AddOrDeleteLineOperationValue = {\n from: line.info.from,\n to: line.info.to || '',\n fromPort: line.info.fromPort || '',\n toPort: line.info.toPort || '',\n id: line.id,\n };\n return {\n type: FreeOperationType.addLine,\n value,\n uri: config.getLineURI(line.id),\n };\n },\n};\n","import { deleteNodeChange } from './delete-node-change';\nimport { deleteLineChange } from './delete-line-change';\nimport { addNodeChange } from './add-node-change';\nimport { addLineChange } from './add-line-change';\n\nexport default [addLineChange, deleteLineChange, addNodeChange, deleteNodeChange];\n","import { injectable } from 'inversify';\nimport { type OperationContribution, type OperationRegistry } from '@flowgram.ai/history';\n\nimport { operationMetas } from './operation-metas';\n\n@injectable()\nexport class FreeHistoryRegisters implements OperationContribution {\n registerOperationMeta(operationRegistry: OperationRegistry): void {\n operationMetas.forEach(operationMeta => {\n operationRegistry.registerOperationMeta(operationMeta);\n });\n }\n}\n","import { type PluginContext } from '@flowgram.ai/core';\nimport { WorkflowResetLayoutService } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { FreeOperationType, type ResetLayoutOperationValue } from '../types';\nimport { baseOperationMeta } from './base';\n\nexport const resetLayoutOperationMeta: OperationMeta<\n ResetLayoutOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: FreeOperationType.resetLayout,\n inverse: op => ({\n ...op,\n value: {\n ...op.value,\n value: op.value.oldValue,\n oldValue: op.value.value,\n },\n }),\n apply: async (operation, ctx: PluginContext) => {\n const reset = ctx.get<WorkflowResetLayoutService>(WorkflowResetLayoutService);\n await reset.layoutToPositions(operation.value.ids, operation.value.value);\n },\n shouldMerge: () => false,\n};\n","import { type OperationMeta } from '@flowgram.ai/history';\n\nexport const baseOperationMeta: Partial<OperationMeta> = {\n shouldMerge: (_op, prev, element) => {\n if (!prev) {\n return false;\n }\n\n if (\n // 合并500ms内的操作, 如删除节点会联动删除线条\n Date.now() - element.getTimestamp() <\n 500\n ) {\n return true;\n }\n return false;\n },\n};\n","import { FlowNodeTransformData } from '@flowgram.ai/document';\nimport { type PluginContext, TransformData } from '@flowgram.ai/core';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { type DragNodeOperationValue, FreeOperationType } from '../types';\nimport { baseOperationMeta } from './base';\n\nexport const dragNodesOperationMeta: OperationMeta<DragNodeOperationValue, PluginContext, void> = {\n ...baseOperationMeta,\n type: FreeOperationType.dragNodes,\n inverse: op => ({\n ...op,\n value: {\n ...op.value,\n value: op.value.oldValue,\n oldValue: op.value.value,\n },\n }),\n apply: (operation, ctx) => {\n operation.value.ids.forEach((id, index) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = document.getNode(id);\n if (!node) {\n return;\n }\n\n const transform = node.getData(TransformData);\n const point = operation.value.value[index];\n transform.update({\n position: {\n x: point.x,\n y: point.y,\n },\n });\n // 嵌套情况下需将子节点 transform 设为 dirty\n if (node.collapsedChildren?.length > 0) {\n node.collapsedChildren.forEach(childNode => {\n const childNodeTransformData =\n childNode.getData<FlowNodeTransformData>(FlowNodeTransformData);\n childNodeTransformData.fireChange();\n });\n }\n });\n },\n shouldMerge: () => false,\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 { 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];\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { cloneDeep } from 'lodash';\nimport { injectable, inject } from 'inversify';\nimport { FlowNodeFormData } from '@flowgram.ai/form-core';\nimport { type PluginContext, PositionData } from '@flowgram.ai/core';\nimport {\n WorkflowDocument,\n WorkflowResetLayoutService,\n WorkflowDragService,\n} from '@flowgram.ai/free-layout-core';\nimport { DisposableCollection } from '@flowgram.ai/utils';\nimport { HistoryService } from '@flowgram.ai/history';\n\nimport { 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 private _toDispose: DisposableCollection = new DisposableCollection();\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 const formData = node.getData<FlowNodeFormData>(FlowNodeFormData);\n\n if (formData) {\n this._entityManager.setValue(formData, cloneDeep(data.data));\n\n this._toDispose.push(\n formData.onDetailChange(event => {\n this._changeNodeDataHandler.handle({\n ...event,\n node,\n });\n }),\n );\n }\n }),\n document.onContentChange(async event => {\n await this._changeContentHandler.handle(event, ctx);\n }),\n document.onReload(_event => {\n historyService.clear();\n }),\n resetLayoutService.onResetLayout(event => {\n historyService.pushOperation(\n {\n type: FreeOperationType.resetLayout,\n value: {\n ids: event.nodeIds,\n value: event.positionMap,\n oldValue: event.oldPositionMap,\n },\n },\n { noApply: true },\n );\n }),\n ]);\n }\n\n dispose() {\n this._entityManager.dispose();\n this._toDispose.dispose();\n }\n}\n","import { useEffect, useState } from 'react';\n\nimport { useService } from '@flowgram.ai/core';\nimport { HistoryService } from '@flowgram.ai/history';\n\ninterface UndoRedo {\n canUndo: boolean;\n canRedo: boolean;\n undo: () => Promise<void>;\n redo: () => Promise<void>;\n}\n\nexport function useUndoRedo(): UndoRedo {\n const historyService = useService<HistoryService>(HistoryService);\n const [canUndo, setCanUndo] = useState(false);\n const [canRedo, setCanRedo] = useState(false);\n\n useEffect(() => {\n const toDispose = historyService.undoRedoService.onChange(() => {\n setCanUndo(historyService.canUndo());\n setCanRedo(historyService.canRedo());\n });\n return () => {\n toDispose.dispose();\n };\n }, []);\n\n return {\n canUndo,\n canRedo,\n undo: () => historyService.undo(),\n redo: () => historyService.redo(),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eAAuD;AACvD,IAAAC,kBAA8D;;;ACA9D,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eOperationType","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_core","import_free_layout_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_form_core","import_core","import_free_layout_core","import_utils","import_history","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/drag-nodes.ts","../src/operation-metas/delete-node.ts","../src/operation-metas/delete-line.ts","../src/operation-metas/change-node-data.ts","../src/operation-metas/add-node.ts","../src/operation-metas/add-line.ts","../src/operation-metas/index.ts","../src/free-history-manager.ts","../src/hooks/use-undo-redo.tsx"],"sourcesContent":["export * from './create-free-history-plugin';\nexport * from './types';\nexport * from '@flowgram.ai/history';\nexport * from './free-history-config';\nexport * from './hooks';\nexport * from './free-history-registers';\n","import { bindContributions, definePluginCreator } from '@flowgram.ai/core';\nimport { HistoryContainerModule, OperationContribution } from '@flowgram.ai/history';\n\nimport { type FreeHistoryPluginOptions } from './types';\nimport { HistoryEntityManager } from './history-entity-manager';\nimport { DragNodesHandler } from './handlers/drag-nodes-handler';\nimport { ChangeNodeDataHandler } from './handlers/change-node-data-handler';\nimport { ChangeContentHandler } from './handlers/change-content-handler';\nimport { FreeHistoryRegisters } from './free-history-registers';\nimport { FreeHistoryManager } from './free-history-manager';\nimport { FreeHistoryConfig } from './free-history-config';\n\nexport const createFreeHistoryPlugin = definePluginCreator<FreeHistoryPluginOptions>({\n onBind: ({ bind }) => {\n bindContributions(bind, FreeHistoryRegisters, [OperationContribution]);\n bind(FreeHistoryConfig).toSelf().inSingletonScope();\n bind(FreeHistoryManager).toSelf().inSingletonScope();\n bind(HistoryEntityManager).toSelf().inSingletonScope();\n bind(DragNodesHandler).toSelf().inSingletonScope();\n bind(ChangeNodeDataHandler).toSelf().inSingletonScope();\n bind(ChangeContentHandler).toSelf().inSingletonScope();\n },\n onInit(ctx, opts): void {\n ctx.get<FreeHistoryConfig>(FreeHistoryConfig).init(ctx, opts);\n\n if (!opts.enable) {\n return;\n }\n ctx.get<FreeHistoryManager>(FreeHistoryManager).onInit(ctx, opts);\n },\n onDispose(ctx) {\n ctx.get<HistoryEntityManager>(HistoryEntityManager).dispose();\n },\n containerModules: [HistoryContainerModule],\n});\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { cloneDeep, isEqual } from 'lodash';\nimport { injectable } from 'inversify';\nimport { type EntityData } from '@flowgram.ai/core';\nimport { type Disposable, DisposableCollection } from '@flowgram.ai/utils';\n\n@injectable()\nexport class HistoryEntityManager implements Disposable {\n private _entityDataValues: Map<EntityData, unknown> = new Map();\n\n private _toDispose: DisposableCollection = new DisposableCollection();\n\n addEntityData(entityData: EntityData) {\n this._entityDataValues.set(entityData, cloneDeep(entityData.toJSON()));\n this._toDispose.push(\n entityData.onWillChange(event => {\n const value = event.toJSON();\n const oldValue = this._entityDataValues.get(entityData);\n if (isEqual(value, oldValue)) {\n return;\n }\n this._entityDataValues.set(entityData, cloneDeep(value));\n }),\n );\n }\n\n getValue(entityData: EntityData) {\n return this._entityDataValues.get(entityData);\n }\n\n setValue(entityData: EntityData, value: unknown) {\n return this._entityDataValues.set(entityData, value);\n }\n\n dispose() {\n this._entityDataValues.clear();\n this._toDispose.dispose();\n }\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { injectable, inject } from 'inversify';\nimport { TransformData } from '@flowgram.ai/core';\nimport { type NodesDragEndEvent } from '@flowgram.ai/free-layout-core';\nimport { HistoryService } from '@flowgram.ai/history';\n\nimport { FreeOperationType, type IHandler } from '../types';\n\n@injectable()\nexport class DragNodesHandler implements IHandler<NodesDragEndEvent> {\n @inject(HistoryService)\n private _historyService: HistoryService;\n\n handle(event: NodesDragEndEvent) {\n if (\n event.type === 'onDragEnd' &&\n !event.altKey // altKey代表创建,这个通过add-node监听处理\n ) {\n this._dragNode(event);\n }\n }\n\n private _dragNode(event: NodesDragEndEvent) {\n this._historyService.pushOperation(\n {\n type: FreeOperationType.dragNodes,\n value: {\n ids: event.nodes.map(node => node.id),\n value: event.nodes.map(node => {\n const { x, y } = node.getData(TransformData).position;\n return {\n x,\n y,\n };\n }),\n oldValue: event.startPositions,\n },\n },\n { noApply: true },\n );\n }\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { type IPoint } from '@flowgram.ai/utils';\nimport { type Operation, type OperationMeta } from '@flowgram.ai/history';\nimport {\n type WorkflowContentChangeType,\n type WorkflowContentChangeEvent,\n type WorkflowLineEntity,\n type WorkflowLinePortInfo,\n type WorkflowNodeJSON,\n type PositionMap,\n} from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity, type FlowNodeJSON } from '@flowgram.ai/document';\nimport { type EntityData, type PluginContext } from '@flowgram.ai/core';\n\nexport enum FreeOperationType {\n addLine = 'addLine',\n deleteLine = 'deleteLine',\n moveNode = 'moveNode',\n addNode = 'addNode',\n deleteNode = 'deleteNode',\n changeNodeData = 'changeNodeData',\n resetLayout = 'resetLayout',\n dragNodes = 'dragNodes',\n}\n\nexport interface AddOrDeleteLineOperationValue extends WorkflowLinePortInfo {\n id: string;\n}\n\nexport interface AddOrDeleteWorkflowNodeOperationValue {\n node: WorkflowNodeJSON;\n parentID?: string;\n}\n\nexport interface AddLineOperation extends Operation {\n type: FreeOperationType.addLine;\n value: AddOrDeleteLineOperationValue;\n}\n\nexport interface DeleteLineOperation extends Operation {\n type: FreeOperationType.deleteLine;\n value: AddOrDeleteLineOperationValue;\n}\n\nexport interface MoveNodeOperation extends Operation {\n type: FreeOperationType.moveNode;\n value: MoveNodeOperationValue;\n}\n\nexport interface AddWorkflowNodeOperation extends Operation {\n type: FreeOperationType.addNode;\n value: AddOrDeleteWorkflowNodeOperationValue;\n}\n\nexport interface DeleteWorkflowNodeOperation extends Operation {\n type: FreeOperationType.deleteNode;\n value: AddOrDeleteWorkflowNodeOperationValue;\n}\n\nexport interface MoveNodeOperationValue {\n id: string;\n value: {\n x: number;\n y: number;\n };\n oldValue: {\n x: number;\n y: number;\n };\n}\n\nexport interface DragNodeOperationValue {\n ids: string[];\n value: IPoint[];\n oldValue: IPoint[];\n}\n\nexport interface ResetLayoutOperationValue {\n ids: string[];\n value: PositionMap;\n oldValue: PositionMap;\n}\n\nexport interface ContentChangeTypeToOperation<T extends Operation> {\n type: WorkflowContentChangeType;\n toOperation: (\n event: WorkflowContentChangeEvent,\n ctx: PluginContext\n ) => T | undefined | Promise<T | undefined>;\n}\n\nexport interface EntityDataType {\n type: FreeOperationType;\n toEntityData: (node: FlowNodeEntity, ctx: PluginContext) => EntityData;\n}\n\nexport interface ChangeNodeDataValue {\n id: string;\n value: unknown;\n oldValue: unknown;\n path: string;\n}\n\nexport interface ChangeNodeDataOperation extends Operation {\n type: FreeOperationType.changeNodeData;\n value: ChangeNodeDataValue;\n}\n\n/**\n * 将node转成json\n */\nexport type NodeToJson = (node: FlowNodeEntity) => FlowNodeJSON;\n/**\n * 将line转成json\n */\nexport type LineToJson = (node: WorkflowLineEntity) => FlowNodeJSON;\n/**\n * 根据节点id获取label\n */\nexport type GetNodeLabelById = (id: string) => string;\n/**\n * 根据节点获取label\n */\nexport type GetNodeLabel = (node: FlowNodeJSON) => string;\n/**\n * 根据分支获取label\n */\nexport type GetBlockLabel = (node: FlowNodeJSON) => string;\n/**\n * 根据节点获取URI\n */\nexport type GetNodeURI = (id: string) => string | any;\n/**\n * 根据连线获取URI\n */\nexport type GetLineURI = (id: string) => string | any;\n\n/**\n * 插件配置\n */\nexport interface FreeHistoryPluginOptions {\n enable?: boolean;\n limit?: number;\n nodeToJSON?: (ctx: PluginContext) => NodeToJson;\n getNodeLabelById?: (ctx: PluginContext) => GetNodeLabelById;\n getNodeLabel?: (ctx: PluginContext) => GetNodeLabel;\n getBlockLabel?: (ctx: PluginContext) => GetBlockLabel;\n getNodeURI?: (ctx: PluginContext) => GetNodeURI;\n getLineURI?: (ctx: PluginContext) => GetLineURI;\n operationMetas?: OperationMeta[];\n enableChangeNode?: boolean;\n uri?: string | any;\n}\n\nexport interface IHandler<E> {\n handle: (event: E, ctx: PluginContext) => void | Promise<void>;\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { cloneDeep, get, isEqual, set } from 'lodash';\nimport { injectable, inject } from 'inversify';\nimport { FlowNodeFormData, type DetailChangeEvent } from '@flowgram.ai/form-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { HistoryService } from '@flowgram.ai/history';\n\nimport { FreeOperationType, type IHandler } from '../types';\nimport { HistoryEntityManager } from '../history-entity-manager';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport interface ChangeNodeDataEvent extends DetailChangeEvent {\n node: FlowNodeEntity;\n}\n\n@injectable()\nexport class ChangeNodeDataHandler implements IHandler<ChangeNodeDataEvent> {\n @inject(HistoryService)\n private _historyService: HistoryService;\n\n @inject(WorkflowDocument) document: WorkflowDocument;\n\n @inject(HistoryEntityManager)\n private _entityManager: HistoryEntityManager;\n\n @inject(FreeHistoryConfig)\n private _config: FreeHistoryConfig;\n\n handle(event: ChangeNodeDataEvent) {\n const { path, value, initialized, node } = event;\n const formData = node.getData<FlowNodeFormData>(FlowNodeFormData);\n const oldValue = this._entityManager.getValue(formData) as object;\n const propPath = path.split('/').filter(Boolean).join('.');\n\n const propOldValue = propPath ? get(oldValue, propPath) : oldValue;\n if (isEqual(value, propOldValue)) {\n return;\n }\n\n if (initialized) {\n let operationPath = path;\n let operationValue = cloneDeep(value);\n let operationOldValue = propOldValue;\n // 只存储一层的数据,因为formModel无法获取数组下的某项的值\n if (path !== '/') {\n const clonedOldValue = cloneDeep(oldValue);\n set(clonedOldValue, propPath, value);\n operationPath = path.split('/').filter(Boolean)[0];\n operationValue = get(clonedOldValue, operationPath);\n operationOldValue = get(oldValue, operationPath);\n }\n\n this._historyService.pushOperation(\n {\n type: FreeOperationType.changeNodeData,\n value: {\n id: node.id,\n path: operationPath,\n value: operationValue,\n oldValue: operationOldValue,\n },\n uri: this._config.getNodeURI(node.id),\n },\n { noApply: true },\n );\n }\n\n if (propPath) {\n set(oldValue, propPath, cloneDeep(value));\n } else {\n this._entityManager.setValue(formData, cloneDeep(value));\n }\n }\n}\n","import { injectable } from 'inversify';\nimport { type FlowNodeEntity, type FlowNodeJSON } from '@flowgram.ai/document';\nimport { type PluginContext } from '@flowgram.ai/core';\n\nimport {\n type FreeHistoryPluginOptions,\n type GetBlockLabel,\n type GetLineURI,\n type GetNodeLabel,\n type GetNodeLabelById,\n type GetNodeURI,\n type NodeToJson,\n} from './types';\n\n@injectable()\nexport class FreeHistoryConfig {\n init(ctx: PluginContext, options: FreeHistoryPluginOptions) {\n this.enable = !!options?.enable;\n\n if (options.nodeToJSON) {\n this.nodeToJSON = options.nodeToJSON(ctx);\n }\n\n if (options.getNodeLabelById) {\n this.getNodeLabelById = options.getNodeLabelById(ctx);\n }\n\n if (options.getNodeLabel) {\n this.getNodeLabel = options.getNodeLabel(ctx);\n }\n\n if (options.getBlockLabel) {\n this.getBlockLabel = options.getBlockLabel(ctx);\n }\n\n if (options.getNodeURI) {\n this.getNodeURI = options.getNodeURI(ctx);\n }\n\n if (options.getLineURI) {\n this.getLineURI = options.getLineURI(ctx);\n }\n }\n\n enable = false;\n\n nodeToJSON: NodeToJson = (node: FlowNodeEntity) => node.toJSON();\n\n getNodeLabelById: GetNodeLabelById = (id: string) => id;\n\n getNodeLabel: GetNodeLabel = (node: FlowNodeJSON) => node.id;\n\n getBlockLabel: GetBlockLabel = (node: FlowNodeJSON) => node.id;\n\n getNodeURI: GetNodeURI = (id: string) => `node:${id}`;\n\n getLineURI: GetLineURI = (id: string) => `line:${id}`;\n}\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { injectable, inject } from 'inversify';\nimport { type PluginContext } from '@flowgram.ai/core';\nimport { type WorkflowContentChangeEvent } from '@flowgram.ai/free-layout-core';\nimport { HistoryService } from '@flowgram.ai/history';\n\nimport { type IHandler } from '../types';\nimport changes from '../changes';\n\n@injectable()\nexport class ChangeContentHandler implements IHandler<WorkflowContentChangeEvent> {\n @inject(HistoryService)\n private _historyService: HistoryService;\n\n async handle(event: WorkflowContentChangeEvent, ctx: PluginContext) {\n if (!this._historyService.undoRedoService.canPush()) {\n return;\n }\n\n const change = changes.find(c => c.type === event.type);\n if (!change) {\n return;\n }\n const operation = await change.toOperation(event, ctx);\n if (!operation) {\n return;\n }\n\n this._historyService.pushOperation(operation, { noApply: true });\n }\n}\n","import { WorkflowDocument, WorkflowContentChangeType, delay } from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\n\nimport {\n type ContentChangeTypeToOperation,\n FreeOperationType,\n type DeleteWorkflowNodeOperation,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const deleteNodeChange: ContentChangeTypeToOperation<DeleteWorkflowNodeOperation> = {\n type: WorkflowContentChangeType.DELETE_NODE,\n toOperation: async (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = event.entity as FlowNodeEntity;\n const json = await document.toNodeJSON(node);\n const parentID = node.parent?.id;\n\n // 删除节点和删除连线同时触发,删除节点需放在后面执行\n await delay(0);\n\n return {\n type: FreeOperationType.deleteNode,\n value: {\n node: json,\n parentID,\n },\n uri: config.getNodeURI(node.id),\n };\n },\n};\n","import { type WorkflowLineEntity } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\n\nimport {\n type AddOrDeleteLineOperationValue,\n type ContentChangeTypeToOperation,\n type DeleteLineOperation,\n FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const deleteLineChange: ContentChangeTypeToOperation<DeleteLineOperation> = {\n type: WorkflowContentChangeType.DELETE_LINE,\n toOperation: (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const line = event.entity as WorkflowLineEntity;\n const value: AddOrDeleteLineOperationValue = {\n from: line.info.from,\n to: line.info.to || '',\n fromPort: line.info.fromPort || '',\n toPort: line.info.toPort || '',\n id: line.id,\n };\n return {\n type: FreeOperationType.deleteLine,\n value,\n uri: config.getNodeURI(line.id),\n };\n },\n};\n","import { WorkflowDocument, delay, type WorkflowNodeJSON } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\n\nimport {\n type AddWorkflowNodeOperation,\n type ContentChangeTypeToOperation,\n FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const addNodeChange: ContentChangeTypeToOperation<AddWorkflowNodeOperation> = {\n type: WorkflowContentChangeType.ADD_NODE,\n toOperation: async (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = event.entity as FlowNodeEntity;\n const parentID = node.parent?.id;\n /**\n * 由于document.toNodeJSON依赖表单里面的default的值初始化,故此处需要等表单的初始化完成\n * 比如dataset-node/index.ts中formatOnSubmit实现需要value被初始化\n */\n await delay(10);\n const json: WorkflowNodeJSON = await document.toNodeJSON(node);\n\n return {\n type: FreeOperationType.addNode,\n value: {\n node: json,\n parentID,\n },\n uri: config.getNodeURI(node.id),\n };\n },\n};\n","import { type WorkflowLineEntity } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\n\nimport {\n type AddLineOperation,\n type AddOrDeleteLineOperationValue,\n type ContentChangeTypeToOperation,\n FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const addLineChange: ContentChangeTypeToOperation<AddLineOperation> = {\n type: WorkflowContentChangeType.ADD_LINE,\n toOperation: (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const line = event.entity as WorkflowLineEntity;\n const value: AddOrDeleteLineOperationValue = {\n from: line.info.from,\n to: line.info.to || '',\n fromPort: line.info.fromPort || '',\n toPort: line.info.toPort || '',\n id: line.id,\n };\n return {\n type: FreeOperationType.addLine,\n value,\n uri: config.getLineURI(line.id),\n };\n },\n};\n","import { deleteNodeChange } from './delete-node-change';\nimport { deleteLineChange } from './delete-line-change';\nimport { addNodeChange } from './add-node-change';\nimport { addLineChange } from './add-line-change';\n\nexport default [addLineChange, deleteLineChange, addNodeChange, deleteNodeChange];\n","import { injectable } from 'inversify';\nimport { type OperationContribution, type OperationRegistry } from '@flowgram.ai/history';\n\nimport { operationMetas } from './operation-metas';\n\n@injectable()\nexport class FreeHistoryRegisters implements OperationContribution {\n registerOperationMeta(operationRegistry: OperationRegistry): void {\n operationMetas.forEach(operationMeta => {\n operationRegistry.registerOperationMeta(operationMeta);\n });\n }\n}\n","import { type PluginContext } from '@flowgram.ai/core';\nimport { WorkflowResetLayoutService } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { FreeOperationType, type ResetLayoutOperationValue } from '../types';\nimport { baseOperationMeta } from './base';\n\nexport const resetLayoutOperationMeta: OperationMeta<\n ResetLayoutOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: FreeOperationType.resetLayout,\n inverse: op => ({\n ...op,\n value: {\n ...op.value,\n value: op.value.oldValue,\n oldValue: op.value.value,\n },\n }),\n apply: async (operation, ctx: PluginContext) => {\n const reset = ctx.get<WorkflowResetLayoutService>(WorkflowResetLayoutService);\n await reset.layoutToPositions(operation.value.ids, operation.value.value);\n },\n shouldMerge: () => false,\n};\n","import { type OperationMeta } from '@flowgram.ai/history';\n\nexport const baseOperationMeta: Partial<OperationMeta> = {\n shouldMerge: (_op, prev, element) => {\n if (!prev) {\n return false;\n }\n\n if (\n // 合并500ms内的操作, 如删除节点会联动删除线条\n Date.now() - element.getTimestamp() <\n 500\n ) {\n return true;\n }\n return false;\n },\n};\n","import { FlowNodeTransformData } from '@flowgram.ai/document';\nimport { type PluginContext, TransformData } from '@flowgram.ai/core';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { type DragNodeOperationValue, FreeOperationType } from '../types';\nimport { baseOperationMeta } from './base';\n\nexport const dragNodesOperationMeta: OperationMeta<DragNodeOperationValue, PluginContext, void> = {\n ...baseOperationMeta,\n type: FreeOperationType.dragNodes,\n inverse: op => ({\n ...op,\n value: {\n ...op.value,\n value: op.value.oldValue,\n oldValue: op.value.value,\n },\n }),\n apply: (operation, ctx) => {\n operation.value.ids.forEach((id, index) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = document.getNode(id);\n if (!node) {\n return;\n }\n\n const transform = node.getData(TransformData);\n const point = operation.value.value[index];\n transform.update({\n position: {\n x: point.x,\n y: point.y,\n },\n });\n // 嵌套情况下需将子节点 transform 设为 dirty\n if (node.collapsedChildren?.length > 0) {\n node.collapsedChildren.forEach(childNode => {\n const childNodeTransformData =\n childNode.getData<FlowNodeTransformData>(FlowNodeTransformData);\n childNodeTransformData.fireChange();\n });\n }\n });\n },\n shouldMerge: () => false,\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 { 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];\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { cloneDeep } from 'lodash';\nimport { injectable, inject } from 'inversify';\nimport { DisposableCollection } from '@flowgram.ai/utils';\nimport { HistoryService } from '@flowgram.ai/history';\nimport {\n WorkflowDocument,\n WorkflowResetLayoutService,\n WorkflowDragService,\n} from '@flowgram.ai/free-layout-core';\nimport { FlowNodeFormData } from '@flowgram.ai/form-core';\nimport { FormManager } from '@flowgram.ai/form-core';\nimport { type PluginContext, PositionData } from '@flowgram.ai/core';\n\nimport { type FreeHistoryPluginOptions, FreeOperationType } from './types';\nimport { HistoryEntityManager } from './history-entity-manager';\nimport { DragNodesHandler } from './handlers/drag-nodes-handler';\nimport { ChangeNodeDataHandler } from './handlers/change-node-data-handler';\nimport { ChangeContentHandler } from './handlers/change-content-handler';\n\n/**\n * 历史管理\n */\n@injectable()\nexport class FreeHistoryManager {\n @inject(DragNodesHandler)\n private _dragNodesHandler: DragNodesHandler;\n\n @inject(ChangeNodeDataHandler)\n private _changeNodeDataHandler: ChangeNodeDataHandler;\n\n @inject(ChangeContentHandler)\n private _changeContentHandler: ChangeContentHandler;\n\n @inject(HistoryEntityManager)\n private _entityManager: HistoryEntityManager;\n\n @inject(FormManager)\n private _formManager: FormManager;\n\n private _toDispose: DisposableCollection = new DisposableCollection();\n\n onInit(ctx: PluginContext, opts: FreeHistoryPluginOptions) {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const historyService = ctx.get<HistoryService>(HistoryService);\n const dragService = ctx.get<WorkflowDragService>(WorkflowDragService);\n\n const resetLayoutService = ctx.get<WorkflowResetLayoutService>(WorkflowResetLayoutService);\n\n if (opts?.limit) {\n historyService.limit(opts.limit);\n }\n historyService.context.source = ctx;\n\n this._toDispose.pushAll([\n dragService.onNodesDrag(async (event) => {\n if (event.type !== 'onDragEnd') {\n return;\n }\n this._dragNodesHandler.handle(event);\n }),\n document.onNodeCreate(({ node, data }) => {\n const positionData = node.getData(PositionData);\n if (positionData) {\n this._entityManager.addEntityData(positionData);\n }\n }),\n this._formManager.onFormModelWillInit(({ model, data }) => {\n const node = model.flowNodeEntity;\n const formData = node.getData<FlowNodeFormData>(FlowNodeFormData);\n\n if (formData) {\n this._entityManager.setValue(formData, cloneDeep(data));\n\n this._toDispose.push(\n formData.onDetailChange((event) => {\n this._changeNodeDataHandler.handle({\n ...event,\n node,\n });\n })\n );\n }\n }),\n document.onContentChange(async (event) => {\n await this._changeContentHandler.handle(event, ctx);\n }),\n document.onReload((_event) => {\n historyService.clear();\n }),\n resetLayoutService.onResetLayout((event) => {\n historyService.pushOperation(\n {\n type: FreeOperationType.resetLayout,\n value: {\n ids: event.nodeIds,\n value: event.positionMap,\n oldValue: event.oldPositionMap,\n },\n },\n { noApply: true }\n );\n }),\n ]);\n }\n\n dispose() {\n this._entityManager.dispose();\n this._toDispose.dispose();\n }\n}\n","import { useEffect, useState } from 'react';\n\nimport { useService } from '@flowgram.ai/core';\nimport { HistoryService } from '@flowgram.ai/history';\n\ninterface UndoRedo {\n canUndo: boolean;\n canRedo: boolean;\n undo: () => Promise<void>;\n redo: () => Promise<void>;\n}\n\nexport function useUndoRedo(): UndoRedo {\n const historyService = useService<HistoryService>(HistoryService);\n const [canUndo, setCanUndo] = useState(false);\n const [canRedo, setCanRedo] = useState(false);\n\n useEffect(() => {\n const toDispose = historyService.undoRedoService.onChange(() => {\n setCanUndo(historyService.canUndo());\n setCanRedo(historyService.canRedo());\n });\n return () => {\n toDispose.dispose();\n };\n }, []);\n\n return {\n canUndo,\n canRedo,\n undo: () => historyService.undo(),\n redo: () => historyService.redo(),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eAAuD;AACvD,IAAAC,kBAA8D;;;ACA9D,oBAAmC;AACnC,uBAA2B;AAE3B,mBAAsD;AAG/C,IAAM,uBAAN,MAAiD;AAAA,EAAjD;AACL,SAAQ,oBAA8C,oBAAI,IAAI;AAE9D,SAAQ,aAAmC,IAAI,kCAAqB;AAAA;AAAA,EAEpE,cAAc,YAAwB;AACpC,SAAK,kBAAkB,IAAI,gBAAY,yBAAU,WAAW,OAAO,CAAC,CAAC;AACrE,SAAK,WAAW;AAAA,MACd,WAAW,aAAa,WAAS;AAC/B,cAAM,QAAQ,MAAM,OAAO;AAC3B,cAAM,WAAW,KAAK,kBAAkB,IAAI,UAAU;AACtD,gBAAI,uBAAQ,OAAO,QAAQ,GAAG;AAC5B;AAAA,QACF;AACA,aAAK,kBAAkB,IAAI,gBAAY,yBAAU,KAAK,CAAC;AAAA,MACzD,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEA,SAAS,YAAwB;AAC/B,WAAO,KAAK,kBAAkB,IAAI,UAAU;AAAA,EAC9C;AAAA,EAEA,SAAS,YAAwB,OAAgB;AAC/C,WAAO,KAAK,kBAAkB,IAAI,YAAY,KAAK;AAAA,EACrD;AAAA,EAEA,UAAU;AACR,SAAK,kBAAkB,MAAM;AAC7B,SAAK,WAAW,QAAQ;AAAA,EAC1B;AACF;AA/Ba,uBAAN;AAAA,MADN,6BAAW;AAAA,GACC;;;ACNb,IAAAC,oBAAmC;AACnC,kBAA8B;AAE9B,qBAA+B;;;ACUxB,IAAK,oBAAL,kBAAKC,uBAAL;AACL,EAAAA,mBAAA,aAAU;AACV,EAAAA,mBAAA,gBAAa;AACb,EAAAA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AU,QAAI,uBAAS,KAAK;AAC5C,QAAM,CAAC,SAAS,UAAU,QAAI,uBAAS,KAAK;AAE5C,8BAAU,MAAM;AACd,UAAM,YAAY,eAAe,gBAAgB,SAAS,MAAM;AAC9D,iBAAW,eAAe,QAAQ,CAAC;AACnC,iBAAW,eAAe,QAAQ,CAAC;AAAA,IACrC,CAAC;AACD,WAAO,MAAM;AACX,gBAAU,QAAQ;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,MAAM,MAAM,eAAe,KAAK;AAAA,IAChC,MAAM,MAAM,eAAe,KAAK;AAAA,EAClC;AACF;","names":["import_core","import_history","import_inversify","FreeOperationType","import_lodash","import_inversify","import_history","import_inversify","import_inversify","import_history","import_free_layout_core","import_free_layout_core","import_free_layout_core","import_free_layout_core","import_inversify","import_free_layout_core","import_core","import_free_layout_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_core","import_core","import_history"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowgram.ai/free-history-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
|
+
"homepage": "https://flowgram.ai/",
|
|
5
|
+
"repository": "https://github.com/bytedance/flowgram.ai",
|
|
4
6
|
"license": "MIT",
|
|
5
7
|
"exports": {
|
|
6
8
|
"types": "./dist/index.d.ts",
|
|
@@ -16,12 +18,12 @@
|
|
|
16
18
|
"dependencies": {
|
|
17
19
|
"inversify": "^6.0.1",
|
|
18
20
|
"lodash": "^4.17.21",
|
|
19
|
-
"@flowgram.ai/core": "0.1.
|
|
20
|
-
"@flowgram.ai/
|
|
21
|
-
"@flowgram.ai/
|
|
22
|
-
"@flowgram.ai/
|
|
23
|
-
"@flowgram.ai/
|
|
24
|
-
"@flowgram.ai/utils": "0.1.
|
|
21
|
+
"@flowgram.ai/core": "0.1.8",
|
|
22
|
+
"@flowgram.ai/form-core": "0.1.8",
|
|
23
|
+
"@flowgram.ai/document": "0.1.8",
|
|
24
|
+
"@flowgram.ai/history": "0.1.8",
|
|
25
|
+
"@flowgram.ai/free-layout-core": "0.1.8",
|
|
26
|
+
"@flowgram.ai/utils": "0.1.8"
|
|
25
27
|
},
|
|
26
28
|
"devDependencies": {
|
|
27
29
|
"@types/lodash": "^4.14.137",
|
|
@@ -32,8 +34,8 @@
|
|
|
32
34
|
"tsup": "^8.0.1",
|
|
33
35
|
"typescript": "^5.0.4",
|
|
34
36
|
"vitest": "^0.34.6",
|
|
35
|
-
"@flowgram.ai/
|
|
36
|
-
"@flowgram.ai/
|
|
37
|
+
"@flowgram.ai/ts-config": "0.1.8",
|
|
38
|
+
"@flowgram.ai/eslint-config": "0.1.8"
|
|
37
39
|
},
|
|
38
40
|
"peerDependencies": {
|
|
39
41
|
"react": ">=17",
|