@flowgram.ai/free-history-plugin 0.3.4 → 0.3.5
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 +92 -8
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +27 -9
- package/dist/index.d.ts +27 -9
- package/dist/index.js +110 -28
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
package/dist/esm/index.js
CHANGED
|
@@ -59,6 +59,7 @@ import { TransformData } from "@flowgram.ai/core";
|
|
|
59
59
|
var FreeOperationType = /* @__PURE__ */ ((FreeOperationType2) => {
|
|
60
60
|
FreeOperationType2["addLine"] = "addLine";
|
|
61
61
|
FreeOperationType2["deleteLine"] = "deleteLine";
|
|
62
|
+
FreeOperationType2["changeLineData"] = "changeLineData";
|
|
62
63
|
FreeOperationType2["moveNode"] = "moveNode";
|
|
63
64
|
FreeOperationType2["addNode"] = "addNode";
|
|
64
65
|
FreeOperationType2["deleteNode"] = "deleteNode";
|
|
@@ -114,6 +115,8 @@ import { HistoryService as HistoryService2 } from "@flowgram.ai/history";
|
|
|
114
115
|
import { injectable as injectable3 } from "inversify";
|
|
115
116
|
var FreeHistoryConfig = class {
|
|
116
117
|
constructor() {
|
|
118
|
+
this.enableChangeNode = true;
|
|
119
|
+
this.enableChangeLineData = true;
|
|
117
120
|
this.enable = false;
|
|
118
121
|
this.nodeToJSON = (node) => node.toJSON();
|
|
119
122
|
this.getNodeLabelById = (id) => id;
|
|
@@ -142,6 +145,12 @@ var FreeHistoryConfig = class {
|
|
|
142
145
|
if (options.getLineURI) {
|
|
143
146
|
this.getLineURI = options.getLineURI(ctx);
|
|
144
147
|
}
|
|
148
|
+
if (options.enableChangeNode !== void 0) {
|
|
149
|
+
this.enableChangeNode = options.enableChangeNode;
|
|
150
|
+
}
|
|
151
|
+
if (options.enableChangeLineData !== void 0) {
|
|
152
|
+
this.enableChangeLineData = options.enableChangeLineData;
|
|
153
|
+
}
|
|
145
154
|
}
|
|
146
155
|
};
|
|
147
156
|
FreeHistoryConfig = __decorateClass([
|
|
@@ -210,6 +219,9 @@ ChangeNodeDataHandler = __decorateClass([
|
|
|
210
219
|
// src/handlers/change-content-handler.ts
|
|
211
220
|
import { injectable as injectable5, inject as inject3 } from "inversify";
|
|
212
221
|
import { HistoryService as HistoryService3 } from "@flowgram.ai/history";
|
|
222
|
+
import {
|
|
223
|
+
WorkflowContentChangeType as WorkflowContentChangeType6
|
|
224
|
+
} from "@flowgram.ai/free-layout-core";
|
|
213
225
|
|
|
214
226
|
// src/changes/delete-node-change.ts
|
|
215
227
|
import { WorkflowContentChangeType } from "@flowgram.ai/free-layout-core";
|
|
@@ -243,6 +255,7 @@ var deleteLineChange = {
|
|
|
243
255
|
to: line.info.to || "",
|
|
244
256
|
fromPort: line.info.fromPort || "",
|
|
245
257
|
toPort: line.info.toPort || "",
|
|
258
|
+
data: line.info.data,
|
|
246
259
|
id: line.id
|
|
247
260
|
};
|
|
248
261
|
return {
|
|
@@ -253,11 +266,31 @@ var deleteLineChange = {
|
|
|
253
266
|
}
|
|
254
267
|
};
|
|
255
268
|
|
|
269
|
+
// src/changes/change-line-data.ts
|
|
270
|
+
import { WorkflowContentChangeType as WorkflowContentChangeType3 } from "@flowgram.ai/free-layout-core";
|
|
271
|
+
var changeLineData = {
|
|
272
|
+
type: WorkflowContentChangeType3.LINE_DATA_CHANGE,
|
|
273
|
+
toOperation: (event, ctx) => {
|
|
274
|
+
const config = ctx.get(FreeHistoryConfig);
|
|
275
|
+
const line = event.entity;
|
|
276
|
+
const value = {
|
|
277
|
+
id: line.id,
|
|
278
|
+
oldValue: event.oldValue,
|
|
279
|
+
newValue: line.lineData
|
|
280
|
+
};
|
|
281
|
+
return {
|
|
282
|
+
type: "changeLineData" /* changeLineData */,
|
|
283
|
+
value,
|
|
284
|
+
uri: config.getLineURI(line.id)
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
|
|
256
289
|
// src/changes/add-node-change.ts
|
|
257
290
|
import { WorkflowDocument as WorkflowDocument2 } from "@flowgram.ai/free-layout-core";
|
|
258
|
-
import { WorkflowContentChangeType as
|
|
291
|
+
import { WorkflowContentChangeType as WorkflowContentChangeType4 } from "@flowgram.ai/free-layout-core";
|
|
259
292
|
var addNodeChange = {
|
|
260
|
-
type:
|
|
293
|
+
type: WorkflowContentChangeType4.ADD_NODE,
|
|
261
294
|
toOperation: (event, ctx) => {
|
|
262
295
|
const config = ctx.get(FreeHistoryConfig);
|
|
263
296
|
const document = ctx.get(WorkflowDocument2);
|
|
@@ -276,9 +309,9 @@ var addNodeChange = {
|
|
|
276
309
|
};
|
|
277
310
|
|
|
278
311
|
// src/changes/add-line-change.ts
|
|
279
|
-
import { WorkflowContentChangeType as
|
|
312
|
+
import { WorkflowContentChangeType as WorkflowContentChangeType5 } from "@flowgram.ai/free-layout-core";
|
|
280
313
|
var addLineChange = {
|
|
281
|
-
type:
|
|
314
|
+
type: WorkflowContentChangeType5.ADD_LINE,
|
|
282
315
|
toOperation: (event, ctx) => {
|
|
283
316
|
const config = ctx.get(FreeHistoryConfig);
|
|
284
317
|
const line = event.entity;
|
|
@@ -287,6 +320,7 @@ var addLineChange = {
|
|
|
287
320
|
to: line.info.to || "",
|
|
288
321
|
fromPort: line.info.fromPort || "",
|
|
289
322
|
toPort: line.info.toPort || "",
|
|
323
|
+
data: line.info.data,
|
|
290
324
|
id: line.id
|
|
291
325
|
};
|
|
292
326
|
return {
|
|
@@ -298,7 +332,7 @@ var addLineChange = {
|
|
|
298
332
|
};
|
|
299
333
|
|
|
300
334
|
// src/changes/index.ts
|
|
301
|
-
var changes_default = [addLineChange, deleteLineChange, addNodeChange, deleteNodeChange];
|
|
335
|
+
var changes_default = [addLineChange, deleteLineChange, addNodeChange, deleteNodeChange, changeLineData];
|
|
302
336
|
|
|
303
337
|
// src/handlers/change-content-handler.ts
|
|
304
338
|
var ChangeContentHandler = class {
|
|
@@ -306,6 +340,9 @@ var ChangeContentHandler = class {
|
|
|
306
340
|
if (!this._historyService.undoRedoService.canPush()) {
|
|
307
341
|
return;
|
|
308
342
|
}
|
|
343
|
+
if (!this._historyConfig.enableChangeLineData && event.type === WorkflowContentChangeType6.LINE_DATA_CHANGE) {
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
309
346
|
const change = changes_default.find((c) => c.type === event.type);
|
|
310
347
|
if (!change) {
|
|
311
348
|
return;
|
|
@@ -320,6 +357,9 @@ var ChangeContentHandler = class {
|
|
|
320
357
|
__decorateClass([
|
|
321
358
|
inject3(HistoryService3)
|
|
322
359
|
], ChangeContentHandler.prototype, "_historyService", 2);
|
|
360
|
+
__decorateClass([
|
|
361
|
+
inject3(FreeHistoryConfig)
|
|
362
|
+
], ChangeContentHandler.prototype, "_historyConfig", 2);
|
|
323
363
|
ChangeContentHandler = __decorateClass([
|
|
324
364
|
injectable5()
|
|
325
365
|
], ChangeContentHandler);
|
|
@@ -546,6 +586,49 @@ var changeNodeDataOperationMeta = {
|
|
|
546
586
|
}
|
|
547
587
|
};
|
|
548
588
|
|
|
589
|
+
// src/operation-metas/change-line-data.ts
|
|
590
|
+
import { WorkflowLinesManager } from "@flowgram.ai/free-layout-core";
|
|
591
|
+
var changeLineDataOperationMeta = {
|
|
592
|
+
...baseOperationMeta,
|
|
593
|
+
type: "changeLineData" /* changeLineData */,
|
|
594
|
+
inverse: (op) => ({
|
|
595
|
+
...op,
|
|
596
|
+
value: {
|
|
597
|
+
...op.value,
|
|
598
|
+
newValue: op.value.oldValue,
|
|
599
|
+
oldValue: op.value.newValue
|
|
600
|
+
}
|
|
601
|
+
}),
|
|
602
|
+
apply: (op, ctx) => {
|
|
603
|
+
const linesManager = ctx.get(WorkflowLinesManager);
|
|
604
|
+
const line = linesManager.getLineById(op.value.id);
|
|
605
|
+
if (!line) {
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
line.lineData = op.value.newValue;
|
|
609
|
+
},
|
|
610
|
+
shouldMerge: (op, prev, element) => {
|
|
611
|
+
if (!prev) {
|
|
612
|
+
return false;
|
|
613
|
+
}
|
|
614
|
+
if (Date.now() - element.getTimestamp() < 500) {
|
|
615
|
+
if (op.type === prev.type && // 相同类型
|
|
616
|
+
op.value.id === prev.value.id) {
|
|
617
|
+
return {
|
|
618
|
+
type: op.type,
|
|
619
|
+
value: {
|
|
620
|
+
...op.value,
|
|
621
|
+
newValue: op.value.newValue,
|
|
622
|
+
oldValue: prev.value.oldValue
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
return true;
|
|
627
|
+
}
|
|
628
|
+
return false;
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
|
|
549
632
|
// src/operation-metas/add-node.ts
|
|
550
633
|
import { cloneDeep as cloneDeep3 } from "lodash";
|
|
551
634
|
import { WorkflowDocument as WorkflowDocument8 } from "@flowgram.ai/free-layout-core";
|
|
@@ -579,7 +662,7 @@ var addNodeOperationMeta = {
|
|
|
579
662
|
};
|
|
580
663
|
|
|
581
664
|
// src/operation-metas/add-line.ts
|
|
582
|
-
import { WorkflowLinesManager } from "@flowgram.ai/free-layout-core";
|
|
665
|
+
import { WorkflowLinesManager as WorkflowLinesManager2 } from "@flowgram.ai/free-layout-core";
|
|
583
666
|
var addLineOperationMeta = {
|
|
584
667
|
...baseOperationMeta,
|
|
585
668
|
type: "addLine" /* addLine */,
|
|
@@ -588,7 +671,7 @@ var addLineOperationMeta = {
|
|
|
588
671
|
type: "deleteLine" /* deleteLine */
|
|
589
672
|
}),
|
|
590
673
|
apply: (operation, ctx) => {
|
|
591
|
-
const linesManager = ctx.get(
|
|
674
|
+
const linesManager = ctx.get(WorkflowLinesManager2);
|
|
592
675
|
linesManager.createLine({
|
|
593
676
|
...operation.value,
|
|
594
677
|
key: operation.value.id
|
|
@@ -616,7 +699,8 @@ var operationMetas = [
|
|
|
616
699
|
changeNodeDataOperationMeta,
|
|
617
700
|
resetLayoutOperationMeta,
|
|
618
701
|
dragNodesOperationMeta,
|
|
619
|
-
moveChildNodesOperationMeta
|
|
702
|
+
moveChildNodesOperationMeta,
|
|
703
|
+
changeLineDataOperationMeta
|
|
620
704
|
];
|
|
621
705
|
|
|
622
706
|
// src/free-history-registers.ts
|
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/move-child-nodes.ts","../../src/operation-metas/drag-nodes.ts","../../src/operation-metas/delete-node.ts","../../src/operation-metas/delete-line.ts","../../src/operation-metas/change-node-data.ts","../../src/operation-metas/add-node.ts","../../src/operation-metas/add-line.ts","../../src/operation-metas/index.ts","../../src/free-history-manager.ts","../../src/index.ts","../../src/hooks/use-undo-redo.tsx"],"sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { 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","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\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","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\n/* eslint-disable @typescript-eslint/naming-convention */\nimport { injectable, inject } from 'inversify';\nimport { HistoryService } from '@flowgram.ai/history';\nimport { type NodesDragEndEvent } from '@flowgram.ai/free-layout-core';\nimport { TransformData } from '@flowgram.ai/core';\n\nimport { FreeOperationType, type IHandler } from '../types';\n\n@injectable()\nexport class DragNodesHandler implements IHandler<NodesDragEndEvent> {\n @inject(HistoryService)\n private _historyService: HistoryService;\n\n handle(event: NodesDragEndEvent) {\n if (event.type === 'onDragEnd') {\n this._dragNode(event);\n }\n }\n\n private _dragNode(event: NodesDragEndEvent) {\n this._historyService.pushOperation(\n {\n type: FreeOperationType.dragNodes,\n value: {\n ids: event.nodes.map((node) => node.id),\n value: event.nodes.map((node) => {\n const { x, y } = node.getData(TransformData).position;\n return {\n x,\n y,\n };\n }),\n oldValue: event.startPositions,\n },\n },\n { noApply: true }\n );\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\n/* eslint-disable @typescript-eslint/naming-convention */\nimport { type IPoint } from '@flowgram.ai/utils';\nimport { type Operation, type OperationMeta } from '@flowgram.ai/history';\nimport {\n type WorkflowContentChangeType,\n type WorkflowContentChangeEvent,\n type WorkflowLineEntity,\n type WorkflowLinePortInfo,\n type WorkflowNodeJSON,\n type PositionMap,\n} from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity, type FlowNodeJSON } from '@flowgram.ai/document';\nimport { type EntityData, type PluginContext } from '@flowgram.ai/core';\n\nexport enum FreeOperationType {\n addLine = 'addLine',\n deleteLine = 'deleteLine',\n moveNode = 'moveNode',\n addNode = 'addNode',\n deleteNode = 'deleteNode',\n changeNodeData = 'changeNodeData',\n resetLayout = 'resetLayout',\n dragNodes = 'dragNodes',\n moveChildNodes = 'moveChildNodes',\n}\n\nexport interface AddOrDeleteLineOperationValue extends WorkflowLinePortInfo {\n id: string;\n}\n\nexport interface AddOrDeleteWorkflowNodeOperationValue {\n node: WorkflowNodeJSON;\n parentID?: string;\n}\n\nexport interface AddLineOperation extends Operation {\n type: FreeOperationType.addLine;\n value: AddOrDeleteLineOperationValue;\n}\n\nexport interface DeleteLineOperation extends Operation {\n type: FreeOperationType.deleteLine;\n value: AddOrDeleteLineOperationValue;\n}\n\nexport interface MoveNodeOperation extends Operation {\n type: FreeOperationType.moveNode;\n value: MoveNodeOperationValue;\n}\n\nexport interface AddWorkflowNodeOperation extends Operation {\n type: FreeOperationType.addNode;\n value: AddOrDeleteWorkflowNodeOperationValue;\n}\n\nexport interface DeleteWorkflowNodeOperation extends Operation {\n type: FreeOperationType.deleteNode;\n value: AddOrDeleteWorkflowNodeOperationValue;\n}\n\nexport interface MoveNodeOperationValue {\n id: string;\n value: {\n x: number;\n y: number;\n };\n oldValue: {\n x: number;\n y: number;\n };\n}\n\nexport interface DragNodeOperationValue {\n ids: string[];\n value: IPoint[];\n oldValue: IPoint[];\n}\n\nexport interface ResetLayoutOperationValue {\n ids: string[];\n value: PositionMap;\n oldValue: PositionMap;\n}\n\nexport interface ContentChangeTypeToOperation<T extends Operation> {\n type: WorkflowContentChangeType;\n toOperation: (event: WorkflowContentChangeEvent, ctx: PluginContext) => T | undefined;\n}\n\nexport interface EntityDataType {\n type: FreeOperationType;\n toEntityData: (node: FlowNodeEntity, ctx: PluginContext) => EntityData;\n}\n\nexport interface ChangeNodeDataValue {\n id: string;\n value: unknown;\n oldValue: unknown;\n path: string;\n}\n\nexport interface ChangeNodeDataOperation extends Operation {\n type: FreeOperationType.changeNodeData;\n value: ChangeNodeDataValue;\n}\n\n/**\n * 将node转成json\n */\nexport type NodeToJson = (node: FlowNodeEntity) => FlowNodeJSON;\n/**\n * 将line转成json\n */\nexport type LineToJson = (node: WorkflowLineEntity) => FlowNodeJSON;\n/**\n * 根据节点id获取label\n */\nexport type GetNodeLabelById = (id: string) => string;\n/**\n * 根据节点获取label\n */\nexport type GetNodeLabel = (node: FlowNodeJSON) => string;\n/**\n * 根据分支获取label\n */\nexport type GetBlockLabel = (node: FlowNodeJSON) => string;\n/**\n * 根据节点获取URI\n */\nexport type GetNodeURI = (id: string) => string | any;\n/**\n * 根据连线获取URI\n */\nexport type GetLineURI = (id: string) => string | any;\n\n/**\n * 插件配置\n */\nexport interface FreeHistoryPluginOptions {\n enable?: boolean;\n limit?: number;\n nodeToJSON?: (ctx: PluginContext) => NodeToJson;\n getNodeLabelById?: (ctx: PluginContext) => GetNodeLabelById;\n getNodeLabel?: (ctx: PluginContext) => GetNodeLabel;\n getBlockLabel?: (ctx: PluginContext) => GetBlockLabel;\n getNodeURI?: (ctx: PluginContext) => GetNodeURI;\n getLineURI?: (ctx: PluginContext) => GetLineURI;\n operationMetas?: OperationMeta[];\n enableChangeNode?: boolean;\n uri?: string | any;\n}\n\nexport interface IHandler<E> {\n handle: (event: E, ctx: PluginContext) => void | Promise<void>;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\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","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { 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","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\n/* eslint-disable @typescript-eslint/naming-convention */\nimport { injectable, inject } from 'inversify';\nimport { HistoryService, Operation } from '@flowgram.ai/history';\nimport { type WorkflowContentChangeEvent } from '@flowgram.ai/free-layout-core';\nimport { type PluginContext } from '@flowgram.ai/core';\n\nimport { type IHandler } from '../types';\nimport changes from '../changes';\n\n@injectable()\nexport class ChangeContentHandler implements IHandler<WorkflowContentChangeEvent> {\n @inject(HistoryService)\n private _historyService: HistoryService;\n\n handle(event: WorkflowContentChangeEvent, ctx: PluginContext) {\n if (!this._historyService.undoRedoService.canPush()) {\n return;\n }\n\n const change = changes.find((c) => c.type === event.type);\n if (!change) {\n return;\n }\n const operation: Operation | undefined = change.toOperation(event, ctx);\n if (!operation) {\n return;\n }\n\n this._historyService.pushOperation(operation, { noApply: true });\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\n\nimport {\n type ContentChangeTypeToOperation,\n FreeOperationType,\n type DeleteWorkflowNodeOperation,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const deleteNodeChange: ContentChangeTypeToOperation<DeleteWorkflowNodeOperation> = {\n type: WorkflowContentChangeType.DELETE_NODE,\n toOperation: (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const node = event.entity as FlowNodeEntity;\n const json = event.toJSON();\n const parentID = node.parent?.id;\n\n return {\n type: FreeOperationType.deleteNode,\n value: {\n node: json,\n parentID,\n },\n uri: config.getNodeURI(node.id),\n };\n },\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { 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","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { WorkflowDocument, type WorkflowNodeJSON } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\n\nimport {\n type AddWorkflowNodeOperation,\n type ContentChangeTypeToOperation,\n FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const addNodeChange: ContentChangeTypeToOperation<AddWorkflowNodeOperation> = {\n type: WorkflowContentChangeType.ADD_NODE,\n toOperation: (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = event.entity as FlowNodeEntity;\n const parentID = node.parent?.id;\n const json: WorkflowNodeJSON = document.toNodeJSON(node);\n\n return {\n type: FreeOperationType.addNode,\n value: {\n node: json,\n parentID,\n },\n uri: config.getNodeURI(node.id),\n };\n },\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { 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","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { 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","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { 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","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { 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","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { 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","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { OperationMeta } from '@flowgram.ai/history';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { MoveChildNodesOperationValue, OperationType } from '@flowgram.ai/document';\nimport { FlowNodeBaseType } from '@flowgram.ai/document';\nimport { PluginContext, TransformData } from '@flowgram.ai/core';\n\nimport { baseOperationMeta } from './base';\n\nexport const moveChildNodesOperationMeta: OperationMeta<\n MoveChildNodesOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: OperationType.moveChildNodes,\n inverse: (op) => ({\n ...op,\n value: {\n ...op.value,\n fromIndex: op.value.toIndex,\n toIndex: op.value.fromIndex,\n fromParentId: op.value.toParentId,\n toParentId: op.value.fromParentId,\n },\n }),\n apply: (operation, ctx: PluginContext) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n document.moveChildNodes(operation.value);\n const fromContainer = document.getNode(operation.value.fromParentId);\n requestAnimationFrame(() => {\n if (fromContainer && fromContainer.flowNodeType !== FlowNodeBaseType.ROOT) {\n const fromContainerTransformData = fromContainer.getData(TransformData);\n fromContainerTransformData.fireChange();\n }\n });\n },\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { type OperationMeta } from '@flowgram.ai/history';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { type PluginContext, TransformData } from '@flowgram.ai/core';\n\nimport { type DragNodeOperationValue, FreeOperationType } from '../types';\nimport { baseOperationMeta } from './base';\n\nexport const dragNodesOperationMeta: OperationMeta<DragNodeOperationValue, PluginContext, void> = {\n ...baseOperationMeta,\n type: FreeOperationType.dragNodes,\n inverse: (op) => ({\n ...op,\n value: {\n ...op.value,\n value: op.value.oldValue,\n oldValue: op.value.value,\n },\n }),\n apply: (operation, ctx) => {\n operation.value.ids.forEach((id, index) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = document.getNode(id);\n if (!node) {\n return;\n }\n\n const transform = node.getData(TransformData);\n const point = operation.value.value[index];\n transform.update({\n position: {\n x: point.x,\n y: point.y,\n },\n });\n document.layout.updateAffectedTransform(node);\n });\n },\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { 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","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { 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","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { 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","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { 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","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { 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","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { resetLayoutOperationMeta } from './reset-layout';\nimport { moveChildNodesOperationMeta } from './move-child-nodes';\nimport { dragNodesOperationMeta } from './drag-nodes';\nimport { deleteNodeOperationMeta } from './delete-node';\nimport { deleteLineOperationMeta } from './delete-line';\nimport { changeNodeDataOperationMeta } from './change-node-data';\nimport { addNodeOperationMeta } from './add-node';\nimport { addLineOperationMeta } from './add-line';\n\nexport const operationMetas = [\n addLineOperationMeta,\n deleteLineOperationMeta,\n addNodeOperationMeta,\n deleteNodeOperationMeta,\n changeNodeDataOperationMeta,\n resetLayoutOperationMeta,\n dragNodesOperationMeta,\n moveChildNodesOperationMeta,\n];\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\n/* eslint-disable @typescript-eslint/naming-convention */\nimport { cloneDeep } from 'lodash';\nimport { injectable, inject, optional } from 'inversify';\nimport { DisposableCollection, Disposable } from '@flowgram.ai/utils';\nimport { HistoryService } from '@flowgram.ai/history';\nimport {\n WorkflowDocument,\n WorkflowResetLayoutService,\n WorkflowDragService,\n WorkflowOperationBaseService,\n} from '@flowgram.ai/free-layout-core';\nimport { FlowNodeFormData } from '@flowgram.ai/form-core';\nimport { FormManager } from '@flowgram.ai/form-core';\nimport { OperationType } from '@flowgram.ai/document';\nimport { type PluginContext, PositionData } from '@flowgram.ai/core';\n\nimport { DragNodeOperationValue, type FreeHistoryPluginOptions, FreeOperationType } from './types';\nimport { HistoryEntityManager } from './history-entity-manager';\nimport { DragNodesHandler } from './handlers/drag-nodes-handler';\nimport { ChangeNodeDataHandler } from './handlers/change-node-data-handler';\nimport { ChangeContentHandler } from './handlers/change-content-handler';\n\n/**\n * 历史管理\n */\n@injectable()\nexport class FreeHistoryManager {\n @inject(DragNodesHandler)\n private _dragNodesHandler: DragNodesHandler;\n\n @inject(ChangeNodeDataHandler)\n private _changeNodeDataHandler: ChangeNodeDataHandler;\n\n @inject(ChangeContentHandler)\n private _changeContentHandler: ChangeContentHandler;\n\n @inject(HistoryEntityManager)\n private _entityManager: HistoryEntityManager;\n\n @inject(FormManager)\n @optional()\n private _formManager?: FormManager;\n\n private _toDispose: DisposableCollection = new DisposableCollection();\n\n @inject(WorkflowOperationBaseService)\n private _operationService: WorkflowOperationBaseService;\n\n onInit(ctx: PluginContext, opts: FreeHistoryPluginOptions) {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const historyService = ctx.get<HistoryService>(HistoryService);\n const dragService = ctx.get<WorkflowDragService>(WorkflowDragService);\n\n const resetLayoutService = ctx.get<WorkflowResetLayoutService>(WorkflowResetLayoutService);\n\n if (opts?.limit) {\n historyService.limit(opts.limit);\n }\n historyService.context.source = ctx;\n\n this._toDispose.pushAll([\n dragService.onNodesDrag(async (event) => {\n if (event.type !== 'onDragEnd') {\n return;\n }\n this._dragNodesHandler.handle(event);\n }),\n document.onNodeCreate(({ node, data }) => {\n const positionData = node.getData(PositionData);\n if (positionData) {\n this._entityManager.addEntityData(positionData);\n }\n }),\n this._formManager\n ? this._formManager.onFormModelWillInit(({ model, data }) => {\n const node = model.flowNodeEntity;\n const formData = node.getData<FlowNodeFormData>(FlowNodeFormData);\n\n if (formData) {\n this._entityManager.setValue(formData, cloneDeep(data));\n\n this._toDispose.push(\n formData.onDetailChange((event) => {\n this._changeNodeDataHandler.handle({\n ...event,\n node,\n });\n })\n );\n }\n })\n : Disposable.NULL,\n document.onContentChange((event) => {\n this._changeContentHandler.handle(event, ctx);\n }),\n document.onReload((_event) => {\n historyService.clear();\n }),\n resetLayoutService.onResetLayout((event) => {\n historyService.pushOperation(\n {\n type: FreeOperationType.resetLayout,\n value: {\n ids: event.nodeIds,\n value: event.positionMap,\n oldValue: event.oldPositionMap,\n },\n },\n { noApply: true }\n );\n }),\n this._operationService.onNodeMove(({ node, fromParent, fromIndex, toParent, toIndex }) => {\n historyService.pushOperation(\n {\n type: OperationType.moveChildNodes,\n value: {\n fromParentId: fromParent.id,\n fromIndex,\n nodeIds: [node.id],\n toParentId: toParent.id,\n toIndex,\n },\n },\n {\n noApply: true,\n }\n );\n }),\n this._operationService.onNodePostionUpdate((event) => {\n const value: DragNodeOperationValue = {\n ids: [event.node.id],\n value: [event.newPosition],\n oldValue: [event.oldPosition],\n };\n historyService.pushOperation(\n {\n type: FreeOperationType.dragNodes,\n value,\n },\n {\n noApply: true,\n }\n );\n }),\n ]);\n }\n\n dispose() {\n this._entityManager.dispose();\n this._toDispose.dispose();\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nexport * 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","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { 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":";;;;;;;;;;;;AAKA,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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AAE,iBAAiB;AACtD,SAAK,oBAAoB,EAAE,OAAO,EAAE,iBAAiB;AAAA,EACvD;AAAA,EACA,OAAO,KAAK,MAAY;AACtB,QAAI,IAAuB,iBAAiB,EAAE,KAAK,KAAK,IAAI;AAE5D,QAAI,CAAC,KAAK,QAAQ;AAChB;AAAA,IACF;AACA,QAAI,IAAwB,kBAAkB,EAAE,OAAO,KAAK,IAAI;AAAA,EAClE;AAAA,EACA,UAAU,KAAK;AACb,QAAI,IAA0B,oBAAoB,EAAE,QAAQ;AAAA,EAC9D;AAAA,EACA,kBAAkB,CAAC,sBAAsB;AAC3C,CAAC;;;AwBhCD,cAAc;;;ACFd,SAAS,WAAW,gBAAgB;AAEpC,SAAS,kBAAkB;AAC3B,SAAS,kBAAAC,uBAAsB;AASxB,SAAS,cAAwB;AACtC,QAAM,iBAAiB,WAA2BA,eAAc;AAChE,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,KAAK;AAC5C,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,KAAK;AAE5C,YAAU,MAAM;AACd,UAAM,YAAY,eAAe,gBAAgB,SAAS,MAAM;AAC9D,iBAAW,eAAe,QAAQ,CAAC;AACnC,iBAAW,eAAe,QAAQ,CAAC;AAAA,IACrC,CAAC;AACD,WAAO,MAAM;AACX,gBAAU,QAAQ;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,MAAM,MAAM,eAAe,KAAK;AAAA,IAChC,MAAM,MAAM,eAAe,KAAK;AAAA,EAClC;AACF;","names":["injectable","FreeOperationType","injectable","cloneDeep","isEqual","injectable","inject","HistoryService","injectable","injectable","isEqual","cloneDeep","inject","HistoryService","injectable","injectable","inject","HistoryService","WorkflowContentChangeType","WorkflowContentChangeType","WorkflowDocument","WorkflowContentChangeType","WorkflowContentChangeType","WorkflowDocument","WorkflowContentChangeType","WorkflowContentChangeType","inject","HistoryService","injectable","injectable","WorkflowDocument","TransformData","WorkflowDocument","TransformData","WorkflowDocument","TransformData","WorkflowDocument","TransformData","WorkflowDocument","WorkflowDocument","WorkflowDocument","WorkflowDocument","FlowNodeFormData","WorkflowDocument","WorkflowDocument","FlowNodeFormData","cloneDeep","WorkflowDocument","WorkflowDocument","cloneDeep","injectable","cloneDeep","injectable","inject","DisposableCollection","HistoryService","WorkflowDocument","WorkflowResetLayoutService","FlowNodeFormData","OperationType","DisposableCollection","WorkflowDocument","HistoryService","WorkflowResetLayoutService","FlowNodeFormData","cloneDeep","OperationType","inject","injectable","HistoryService"]}
|
|
1
|
+
{"version":3,"sources":["../../src/create-free-history-plugin.ts","../../src/history-entity-manager.ts","../../src/handlers/drag-nodes-handler.ts","../../src/types.ts","../../src/handlers/change-node-data-handler.ts","../../src/free-history-config.ts","../../src/handlers/change-content-handler.ts","../../src/changes/delete-node-change.ts","../../src/changes/delete-line-change.ts","../../src/changes/change-line-data.ts","../../src/changes/add-node-change.ts","../../src/changes/add-line-change.ts","../../src/changes/index.ts","../../src/free-history-registers.ts","../../src/operation-metas/reset-layout.ts","../../src/operation-metas/base.ts","../../src/operation-metas/move-child-nodes.ts","../../src/operation-metas/drag-nodes.ts","../../src/operation-metas/delete-node.ts","../../src/operation-metas/delete-line.ts","../../src/operation-metas/change-node-data.ts","../../src/operation-metas/change-line-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":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { 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","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\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","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\n/* eslint-disable @typescript-eslint/naming-convention */\nimport { injectable, inject } from 'inversify';\nimport { HistoryService } from '@flowgram.ai/history';\nimport { type NodesDragEndEvent } from '@flowgram.ai/free-layout-core';\nimport { TransformData } from '@flowgram.ai/core';\n\nimport { FreeOperationType, type IHandler } from '../types';\n\n@injectable()\nexport class DragNodesHandler implements IHandler<NodesDragEndEvent> {\n @inject(HistoryService)\n private _historyService: HistoryService;\n\n handle(event: NodesDragEndEvent) {\n if (event.type === 'onDragEnd') {\n this._dragNode(event);\n }\n }\n\n private _dragNode(event: NodesDragEndEvent) {\n this._historyService.pushOperation(\n {\n type: FreeOperationType.dragNodes,\n value: {\n ids: event.nodes.map((node) => node.id),\n value: event.nodes.map((node) => {\n const { x, y } = node.getData(TransformData).position;\n return {\n x,\n y,\n };\n }),\n oldValue: event.startPositions,\n },\n },\n { noApply: true }\n );\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\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 changeLineData = 'changeLineData',\n moveNode = 'moveNode',\n addNode = 'addNode',\n deleteNode = 'deleteNode',\n changeNodeData = 'changeNodeData',\n resetLayout = 'resetLayout',\n dragNodes = 'dragNodes',\n moveChildNodes = 'moveChildNodes',\n}\n\nexport interface AddOrDeleteLineOperationValue extends WorkflowLinePortInfo {\n id: string;\n}\n\nexport interface ChangeLineDataValue {\n id: string;\n oldValue: unknown;\n newValue: unknown;\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 ChangeLineDataOperation extends Operation {\n type: FreeOperationType.changeLineData;\n value: ChangeLineDataValue;\n}\n\nexport interface DeleteLineOperation extends Operation {\n type: FreeOperationType.deleteLine;\n value: AddOrDeleteLineOperationValue;\n}\n\nexport interface MoveNodeOperation extends Operation {\n type: FreeOperationType.moveNode;\n value: MoveNodeOperationValue;\n}\n\nexport interface AddWorkflowNodeOperation extends Operation {\n type: FreeOperationType.addNode;\n value: AddOrDeleteWorkflowNodeOperationValue;\n}\n\nexport interface DeleteWorkflowNodeOperation extends Operation {\n type: FreeOperationType.deleteNode;\n value: AddOrDeleteWorkflowNodeOperationValue;\n}\n\nexport interface MoveNodeOperationValue {\n id: string;\n value: {\n x: number;\n y: number;\n };\n oldValue: {\n x: number;\n y: number;\n };\n}\n\nexport interface DragNodeOperationValue {\n ids: string[];\n value: IPoint[];\n oldValue: IPoint[];\n}\n\nexport interface ResetLayoutOperationValue {\n ids: string[];\n value: PositionMap;\n oldValue: PositionMap;\n}\n\nexport interface ContentChangeTypeToOperation<T extends Operation> {\n type: WorkflowContentChangeType;\n toOperation: (event: WorkflowContentChangeEvent, ctx: PluginContext) => T | undefined;\n}\n\nexport interface EntityDataType {\n type: FreeOperationType;\n toEntityData: (node: FlowNodeEntity, ctx: PluginContext) => EntityData;\n}\n\nexport interface ChangeNodeDataValue {\n id: string;\n value: unknown;\n oldValue: unknown;\n path: string;\n}\n\nexport interface ChangeLineDataValue {\n id: string;\n newValue: unknown;\n oldValue: unknown;\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<CTX extends PluginContext = PluginContext> {\n enable?: boolean;\n limit?: number;\n nodeToJSON?: (ctx: CTX) => NodeToJson;\n getNodeLabelById?: (ctx: CTX) => GetNodeLabelById;\n getNodeLabel?: (ctx: CTX) => GetNodeLabel;\n getBlockLabel?: (ctx: CTX) => GetBlockLabel;\n getNodeURI?: (ctx: CTX) => GetNodeURI;\n getLineURI?: (ctx: CTX) => GetLineURI;\n operationMetas?: OperationMeta[];\n enableChangeNode?: boolean; // default true\n enableChangeLineData?: boolean; // default true\n uri?: string | any;\n}\n\nexport interface IHandler<E> {\n handle: (event: E, ctx: PluginContext) => void | Promise<void>;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\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","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { 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 if (options.enableChangeNode !== undefined) {\n this.enableChangeNode = options.enableChangeNode;\n }\n if (options.enableChangeLineData !== undefined) {\n this.enableChangeLineData = options.enableChangeLineData;\n }\n }\n\n enableChangeNode = true;\n\n enableChangeLineData = true;\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","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\n/* eslint-disable @typescript-eslint/naming-convention */\nimport { injectable, inject } from 'inversify';\nimport { HistoryService, Operation } from '@flowgram.ai/history';\nimport {\n type WorkflowContentChangeEvent,\n WorkflowContentChangeType,\n} from '@flowgram.ai/free-layout-core';\nimport { type PluginContext } from '@flowgram.ai/core';\n\nimport { type IHandler } from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\nimport changes from '../changes';\n\n@injectable()\nexport class ChangeContentHandler implements IHandler<WorkflowContentChangeEvent> {\n @inject(HistoryService)\n private _historyService: HistoryService;\n\n @inject(FreeHistoryConfig) private _historyConfig: FreeHistoryConfig;\n\n handle(event: WorkflowContentChangeEvent, ctx: PluginContext) {\n if (!this._historyService.undoRedoService.canPush()) {\n return;\n }\n if (\n !this._historyConfig.enableChangeLineData &&\n event.type === WorkflowContentChangeType.LINE_DATA_CHANGE\n ) {\n return;\n }\n\n const change = changes.find((c) => c.type === event.type);\n if (!change) {\n return;\n }\n const operation: Operation | undefined = change.toOperation(event, ctx);\n if (!operation) {\n return;\n }\n\n this._historyService.pushOperation(operation, { noApply: true });\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\n\nimport {\n type ContentChangeTypeToOperation,\n FreeOperationType,\n type DeleteWorkflowNodeOperation,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const deleteNodeChange: ContentChangeTypeToOperation<DeleteWorkflowNodeOperation> = {\n type: WorkflowContentChangeType.DELETE_NODE,\n toOperation: (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const node = event.entity as FlowNodeEntity;\n const json = event.toJSON();\n const parentID = node.parent?.id;\n\n return {\n type: FreeOperationType.deleteNode,\n value: {\n node: json,\n parentID,\n },\n uri: config.getNodeURI(node.id),\n };\n },\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { 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 data: line.info.data,\n id: line.id,\n };\n return {\n type: FreeOperationType.deleteLine,\n value,\n uri: config.getNodeURI(line.id),\n };\n },\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { type WorkflowLineEntity } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\n\nimport {\n type ChangeLineDataOperation,\n type ChangeLineDataValue,\n type ContentChangeTypeToOperation,\n FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const changeLineData: ContentChangeTypeToOperation<ChangeLineDataOperation> = {\n type: WorkflowContentChangeType.LINE_DATA_CHANGE,\n toOperation: (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const line = event.entity as WorkflowLineEntity;\n const value: ChangeLineDataValue = {\n id: line.id,\n oldValue: event.oldValue,\n newValue: line.lineData,\n };\n return {\n type: FreeOperationType.changeLineData,\n value,\n uri: config.getLineURI(line.id),\n };\n },\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { WorkflowDocument, type WorkflowNodeJSON } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\n\nimport {\n type AddWorkflowNodeOperation,\n type ContentChangeTypeToOperation,\n FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const addNodeChange: ContentChangeTypeToOperation<AddWorkflowNodeOperation> = {\n type: WorkflowContentChangeType.ADD_NODE,\n toOperation: (event, ctx) => {\n const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = event.entity as FlowNodeEntity;\n const parentID = node.parent?.id;\n const json: WorkflowNodeJSON = document.toNodeJSON(node);\n\n return {\n type: FreeOperationType.addNode,\n value: {\n node: json,\n parentID,\n },\n uri: config.getNodeURI(node.id),\n };\n },\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { 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 data: line.info.data,\n id: line.id,\n };\n return {\n type: FreeOperationType.addLine,\n value,\n uri: config.getLineURI(line.id),\n };\n },\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { deleteNodeChange } from './delete-node-change';\nimport { deleteLineChange } from './delete-line-change';\nimport { changeLineData } from './change-line-data';\nimport { addNodeChange } from './add-node-change';\nimport { addLineChange } from './add-line-change';\n\nexport default [addLineChange, deleteLineChange, addNodeChange, deleteNodeChange, changeLineData];\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { 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","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { 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","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { 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","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { OperationMeta } from '@flowgram.ai/history';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { MoveChildNodesOperationValue, OperationType } from '@flowgram.ai/document';\nimport { FlowNodeBaseType } from '@flowgram.ai/document';\nimport { PluginContext, TransformData } from '@flowgram.ai/core';\n\nimport { baseOperationMeta } from './base';\n\nexport const moveChildNodesOperationMeta: OperationMeta<\n MoveChildNodesOperationValue,\n PluginContext,\n void\n> = {\n ...baseOperationMeta,\n type: OperationType.moveChildNodes,\n inverse: (op) => ({\n ...op,\n value: {\n ...op.value,\n fromIndex: op.value.toIndex,\n toIndex: op.value.fromIndex,\n fromParentId: op.value.toParentId,\n toParentId: op.value.fromParentId,\n },\n }),\n apply: (operation, ctx: PluginContext) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n document.moveChildNodes(operation.value);\n const fromContainer = document.getNode(operation.value.fromParentId);\n requestAnimationFrame(() => {\n if (fromContainer && fromContainer.flowNodeType !== FlowNodeBaseType.ROOT) {\n const fromContainerTransformData = fromContainer.getData(TransformData);\n fromContainerTransformData.fireChange();\n }\n });\n },\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { type OperationMeta } from '@flowgram.ai/history';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { type PluginContext, TransformData } from '@flowgram.ai/core';\n\nimport { type DragNodeOperationValue, FreeOperationType } from '../types';\nimport { baseOperationMeta } from './base';\n\nexport const dragNodesOperationMeta: OperationMeta<DragNodeOperationValue, PluginContext, void> = {\n ...baseOperationMeta,\n type: FreeOperationType.dragNodes,\n inverse: (op) => ({\n ...op,\n value: {\n ...op.value,\n value: op.value.oldValue,\n oldValue: op.value.value,\n },\n }),\n apply: (operation, ctx) => {\n operation.value.ids.forEach((id, index) => {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const node = document.getNode(id);\n if (!node) {\n return;\n }\n\n const transform = node.getData(TransformData);\n const point = operation.value.value[index];\n transform.update({\n position: {\n x: point.x,\n y: point.y,\n },\n });\n document.layout.updateAffectedTransform(node);\n });\n },\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { 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","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { 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","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { 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","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { type OperationMeta } from '@flowgram.ai/history';\nimport { WorkflowLinesManager } from '@flowgram.ai/free-layout-core';\nimport { type PluginContext } from '@flowgram.ai/core';\n\nimport { FreeOperationType, type ChangeLineDataValue } from '../types';\nimport { baseOperationMeta } from './base';\n\nexport const changeLineDataOperationMeta: OperationMeta<ChangeLineDataValue, PluginContext, void> =\n {\n ...baseOperationMeta,\n type: FreeOperationType.changeLineData,\n inverse: (op) => ({\n ...op,\n value: {\n ...op.value,\n newValue: op.value.oldValue,\n oldValue: op.value.newValue,\n },\n }),\n apply: (op, ctx: PluginContext) => {\n const linesManager = ctx.get<WorkflowLinesManager>(WorkflowLinesManager);\n const line = linesManager.getLineById(op.value.id);\n\n if (!line) {\n return;\n }\n\n line.lineData = op.value.newValue;\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 ) {\n return {\n type: op.type,\n value: {\n ...op.value,\n newValue: op.value.newValue,\n oldValue: prev.value.oldValue,\n },\n };\n }\n return true;\n }\n return false;\n },\n };\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { 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","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { 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","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { resetLayoutOperationMeta } from './reset-layout';\nimport { moveChildNodesOperationMeta } from './move-child-nodes';\nimport { dragNodesOperationMeta } from './drag-nodes';\nimport { deleteNodeOperationMeta } from './delete-node';\nimport { deleteLineOperationMeta } from './delete-line';\nimport { changeNodeDataOperationMeta } from './change-node-data';\nimport { changeLineDataOperationMeta } from './change-line-data';\nimport { addNodeOperationMeta } from './add-node';\nimport { addLineOperationMeta } from './add-line';\n\nexport const operationMetas = [\n addLineOperationMeta,\n deleteLineOperationMeta,\n addNodeOperationMeta,\n deleteNodeOperationMeta,\n changeNodeDataOperationMeta,\n resetLayoutOperationMeta,\n dragNodesOperationMeta,\n moveChildNodesOperationMeta,\n changeLineDataOperationMeta,\n];\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\n/* eslint-disable @typescript-eslint/naming-convention */\nimport { cloneDeep } from 'lodash';\nimport { injectable, inject, optional } from 'inversify';\nimport { DisposableCollection, Disposable } from '@flowgram.ai/utils';\nimport { HistoryService } from '@flowgram.ai/history';\nimport {\n WorkflowDocument,\n WorkflowResetLayoutService,\n WorkflowDragService,\n WorkflowOperationBaseService,\n} from '@flowgram.ai/free-layout-core';\nimport { FlowNodeFormData } from '@flowgram.ai/form-core';\nimport { FormManager } from '@flowgram.ai/form-core';\nimport { OperationType } from '@flowgram.ai/document';\nimport { type PluginContext, PositionData } from '@flowgram.ai/core';\n\nimport { DragNodeOperationValue, type FreeHistoryPluginOptions, FreeOperationType } from './types';\nimport { HistoryEntityManager } from './history-entity-manager';\nimport { DragNodesHandler } from './handlers/drag-nodes-handler';\nimport { ChangeNodeDataHandler } from './handlers/change-node-data-handler';\nimport { ChangeContentHandler } from './handlers/change-content-handler';\n\n/**\n * 历史管理\n */\n@injectable()\nexport class FreeHistoryManager {\n @inject(DragNodesHandler)\n private _dragNodesHandler: DragNodesHandler;\n\n @inject(ChangeNodeDataHandler)\n private _changeNodeDataHandler: ChangeNodeDataHandler;\n\n @inject(ChangeContentHandler)\n private _changeContentHandler: ChangeContentHandler;\n\n @inject(HistoryEntityManager)\n private _entityManager: HistoryEntityManager;\n\n @inject(FormManager)\n @optional()\n private _formManager?: FormManager;\n\n private _toDispose: DisposableCollection = new DisposableCollection();\n\n @inject(WorkflowOperationBaseService)\n private _operationService: WorkflowOperationBaseService;\n\n onInit(ctx: PluginContext, opts: FreeHistoryPluginOptions) {\n const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n const historyService = ctx.get<HistoryService>(HistoryService);\n const dragService = ctx.get<WorkflowDragService>(WorkflowDragService);\n\n const resetLayoutService = ctx.get<WorkflowResetLayoutService>(WorkflowResetLayoutService);\n\n if (opts?.limit) {\n historyService.limit(opts.limit);\n }\n historyService.context.source = ctx;\n\n this._toDispose.pushAll([\n dragService.onNodesDrag(async (event) => {\n if (event.type !== 'onDragEnd') {\n return;\n }\n this._dragNodesHandler.handle(event);\n }),\n document.onNodeCreate(({ node, data }) => {\n const positionData = node.getData(PositionData);\n if (positionData) {\n this._entityManager.addEntityData(positionData);\n }\n }),\n this._formManager\n ? this._formManager.onFormModelWillInit(({ model, data }) => {\n const node = model.flowNodeEntity;\n const formData = node.getData<FlowNodeFormData>(FlowNodeFormData);\n\n if (formData) {\n this._entityManager.setValue(formData, cloneDeep(data));\n\n this._toDispose.push(\n formData.onDetailChange((event) => {\n this._changeNodeDataHandler.handle({\n ...event,\n node,\n });\n })\n );\n }\n })\n : Disposable.NULL,\n document.onContentChange((event) => {\n this._changeContentHandler.handle(event, ctx);\n }),\n document.onReload((_event) => {\n historyService.clear();\n }),\n resetLayoutService.onResetLayout((event) => {\n historyService.pushOperation(\n {\n type: FreeOperationType.resetLayout,\n value: {\n ids: event.nodeIds,\n value: event.positionMap,\n oldValue: event.oldPositionMap,\n },\n },\n { noApply: true }\n );\n }),\n this._operationService.onNodeMove(({ node, fromParent, fromIndex, toParent, toIndex }) => {\n historyService.pushOperation(\n {\n type: OperationType.moveChildNodes,\n value: {\n fromParentId: fromParent.id,\n fromIndex,\n nodeIds: [node.id],\n toParentId: toParent.id,\n toIndex,\n },\n },\n {\n noApply: true,\n }\n );\n }),\n this._operationService.onNodePostionUpdate((event) => {\n const value: DragNodeOperationValue = {\n ids: [event.node.id],\n value: [event.newPosition],\n oldValue: [event.oldPosition],\n };\n historyService.pushOperation(\n {\n type: FreeOperationType.dragNodes,\n value,\n },\n {\n noApply: true,\n }\n );\n }),\n ]);\n }\n\n dispose() {\n this._entityManager.dispose();\n this._toDispose.dispose();\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nexport * 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","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { 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":";;;;;;;;;;;;AAKA,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,sBAAsB;AAE/B,SAAS,qBAAqB;;;ACUvB,IAAK,oBAAL,kBAAKC,uBAAL;AACL,EAAAA,mBAAA,aAAU;AACV,EAAAA,mBAAA,gBAAa;AACb,EAAAA,mBAAA,oBAAiB;AACjB,EAAAA,m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AK;AAAA,EAClC;AACF;","names":["injectable","FreeOperationType","injectable","cloneDeep","isEqual","injectable","inject","HistoryService","injectable","injectable","isEqual","cloneDeep","inject","HistoryService","injectable","injectable","inject","HistoryService","WorkflowContentChangeType","WorkflowContentChangeType","WorkflowContentChangeType","WorkflowContentChangeType","WorkflowContentChangeType","WorkflowDocument","WorkflowContentChangeType","WorkflowContentChangeType","WorkflowDocument","WorkflowContentChangeType","WorkflowContentChangeType","WorkflowContentChangeType","inject","HistoryService","injectable","injectable","WorkflowDocument","TransformData","WorkflowDocument","TransformData","WorkflowDocument","TransformData","WorkflowDocument","TransformData","WorkflowDocument","WorkflowDocument","WorkflowDocument","WorkflowDocument","FlowNodeFormData","WorkflowDocument","WorkflowDocument","FlowNodeFormData","cloneDeep","WorkflowDocument","WorkflowDocument","cloneDeep","WorkflowLinesManager","WorkflowLinesManager","injectable","cloneDeep","injectable","inject","DisposableCollection","HistoryService","WorkflowDocument","WorkflowResetLayoutService","FlowNodeFormData","OperationType","DisposableCollection","WorkflowDocument","HistoryService","WorkflowResetLayoutService","FlowNodeFormData","cloneDeep","OperationType","inject","injectable","HistoryService"]}
|
package/dist/index.d.mts
CHANGED
|
@@ -14,6 +14,7 @@ import { FlowNodeEntity, FlowNodeJSON } from '@flowgram.ai/document';
|
|
|
14
14
|
declare enum FreeOperationType {
|
|
15
15
|
addLine = "addLine",
|
|
16
16
|
deleteLine = "deleteLine",
|
|
17
|
+
changeLineData = "changeLineData",
|
|
17
18
|
moveNode = "moveNode",
|
|
18
19
|
addNode = "addNode",
|
|
19
20
|
deleteNode = "deleteNode",
|
|
@@ -33,6 +34,10 @@ interface AddLineOperation extends Operation {
|
|
|
33
34
|
type: FreeOperationType.addLine;
|
|
34
35
|
value: AddOrDeleteLineOperationValue;
|
|
35
36
|
}
|
|
37
|
+
interface ChangeLineDataOperation extends Operation {
|
|
38
|
+
type: FreeOperationType.changeLineData;
|
|
39
|
+
value: ChangeLineDataValue;
|
|
40
|
+
}
|
|
36
41
|
interface DeleteLineOperation extends Operation {
|
|
37
42
|
type: FreeOperationType.deleteLine;
|
|
38
43
|
value: AddOrDeleteLineOperationValue;
|
|
@@ -84,6 +89,16 @@ interface ChangeNodeDataValue {
|
|
|
84
89
|
oldValue: unknown;
|
|
85
90
|
path: string;
|
|
86
91
|
}
|
|
92
|
+
interface ChangeLineDataValue {
|
|
93
|
+
id: string;
|
|
94
|
+
oldValue: unknown;
|
|
95
|
+
newValue: unknown;
|
|
96
|
+
}
|
|
97
|
+
interface ChangeLineDataValue {
|
|
98
|
+
id: string;
|
|
99
|
+
newValue: unknown;
|
|
100
|
+
oldValue: unknown;
|
|
101
|
+
}
|
|
87
102
|
interface ChangeNodeDataOperation extends Operation {
|
|
88
103
|
type: FreeOperationType.changeNodeData;
|
|
89
104
|
value: ChangeNodeDataValue;
|
|
@@ -119,24 +134,25 @@ type GetLineURI = (id: string) => string | any;
|
|
|
119
134
|
/**
|
|
120
135
|
* 插件配置
|
|
121
136
|
*/
|
|
122
|
-
interface FreeHistoryPluginOptions {
|
|
137
|
+
interface FreeHistoryPluginOptions<CTX extends PluginContext = PluginContext> {
|
|
123
138
|
enable?: boolean;
|
|
124
139
|
limit?: number;
|
|
125
|
-
nodeToJSON?: (ctx:
|
|
126
|
-
getNodeLabelById?: (ctx:
|
|
127
|
-
getNodeLabel?: (ctx:
|
|
128
|
-
getBlockLabel?: (ctx:
|
|
129
|
-
getNodeURI?: (ctx:
|
|
130
|
-
getLineURI?: (ctx:
|
|
140
|
+
nodeToJSON?: (ctx: CTX) => NodeToJson;
|
|
141
|
+
getNodeLabelById?: (ctx: CTX) => GetNodeLabelById;
|
|
142
|
+
getNodeLabel?: (ctx: CTX) => GetNodeLabel;
|
|
143
|
+
getBlockLabel?: (ctx: CTX) => GetBlockLabel;
|
|
144
|
+
getNodeURI?: (ctx: CTX) => GetNodeURI;
|
|
145
|
+
getLineURI?: (ctx: CTX) => GetLineURI;
|
|
131
146
|
operationMetas?: OperationMeta[];
|
|
132
147
|
enableChangeNode?: boolean;
|
|
148
|
+
enableChangeLineData?: boolean;
|
|
133
149
|
uri?: string | any;
|
|
134
150
|
}
|
|
135
151
|
interface IHandler<E> {
|
|
136
152
|
handle: (event: E, ctx: PluginContext) => void | Promise<void>;
|
|
137
153
|
}
|
|
138
154
|
|
|
139
|
-
declare const createFreeHistoryPlugin: _flowgram_ai_core.PluginCreator<FreeHistoryPluginOptions
|
|
155
|
+
declare const createFreeHistoryPlugin: _flowgram_ai_core.PluginCreator<FreeHistoryPluginOptions<_flowgram_ai_core.PluginContext>>;
|
|
140
156
|
|
|
141
157
|
/**
|
|
142
158
|
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
@@ -145,6 +161,8 @@ declare const createFreeHistoryPlugin: _flowgram_ai_core.PluginCreator<FreeHisto
|
|
|
145
161
|
|
|
146
162
|
declare class FreeHistoryConfig {
|
|
147
163
|
init(ctx: PluginContext, options: FreeHistoryPluginOptions): void;
|
|
164
|
+
enableChangeNode: boolean;
|
|
165
|
+
enableChangeLineData: boolean;
|
|
148
166
|
enable: boolean;
|
|
149
167
|
nodeToJSON: NodeToJson;
|
|
150
168
|
getNodeLabelById: GetNodeLabelById;
|
|
@@ -175,4 +193,4 @@ declare class FreeHistoryRegisters implements OperationContribution {
|
|
|
175
193
|
registerOperationMeta(operationRegistry: OperationRegistry): void;
|
|
176
194
|
}
|
|
177
195
|
|
|
178
|
-
export { type AddLineOperation, type AddOrDeleteLineOperationValue, type AddOrDeleteWorkflowNodeOperationValue, type AddWorkflowNodeOperation, type ChangeNodeDataOperation, type ChangeNodeDataValue, type ContentChangeTypeToOperation, type DeleteLineOperation, type DeleteWorkflowNodeOperation, type DragNodeOperationValue, type EntityDataType, FreeHistoryConfig, type FreeHistoryPluginOptions, FreeHistoryRegisters, FreeOperationType, type GetBlockLabel, type GetLineURI, type GetNodeLabel, type GetNodeLabelById, type GetNodeURI, type IHandler, type LineToJson, type MoveNodeOperation, type MoveNodeOperationValue, type NodeToJson, type ResetLayoutOperationValue, createFreeHistoryPlugin, useUndoRedo };
|
|
196
|
+
export { type AddLineOperation, type AddOrDeleteLineOperationValue, type AddOrDeleteWorkflowNodeOperationValue, type AddWorkflowNodeOperation, type ChangeLineDataOperation, type ChangeLineDataValue, type ChangeNodeDataOperation, type ChangeNodeDataValue, type ContentChangeTypeToOperation, type DeleteLineOperation, type DeleteWorkflowNodeOperation, type DragNodeOperationValue, type EntityDataType, FreeHistoryConfig, type FreeHistoryPluginOptions, FreeHistoryRegisters, FreeOperationType, type GetBlockLabel, type GetLineURI, type GetNodeLabel, type GetNodeLabelById, type GetNodeURI, type IHandler, type LineToJson, type MoveNodeOperation, type MoveNodeOperationValue, type NodeToJson, type ResetLayoutOperationValue, createFreeHistoryPlugin, useUndoRedo };
|