|
@@ -4,9 +4,8 @@
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
|
-import { cloneDeep } from 'lodash-es';
|
|
|
|
|
-import { injectable, inject, optional } from 'inversify';
|
|
|
|
|
-import { DisposableCollection, Disposable } from '@flowgram.ai/utils';
|
|
|
|
|
|
|
+import { injectable, inject } from 'inversify';
|
|
|
|
|
+import { DisposableCollection } from '@flowgram.ai/utils';
|
|
|
import { HistoryService } from '@flowgram.ai/history';
|
|
import { HistoryService } from '@flowgram.ai/history';
|
|
|
import {
|
|
import {
|
|
|
WorkflowDocument,
|
|
WorkflowDocument,
|
|
@@ -14,15 +13,12 @@ import {
|
|
|
WorkflowDragService,
|
|
WorkflowDragService,
|
|
|
WorkflowOperationBaseService,
|
|
WorkflowOperationBaseService,
|
|
|
} from '@flowgram.ai/free-layout-core';
|
|
} from '@flowgram.ai/free-layout-core';
|
|
|
-import { FlowNodeFormData } from '@flowgram.ai/form-core';
|
|
|
|
|
-import { FormManager } from '@flowgram.ai/form-core';
|
|
|
|
|
import { OperationType } from '@flowgram.ai/document';
|
|
import { OperationType } from '@flowgram.ai/document';
|
|
|
import { type PluginContext, PositionData } from '@flowgram.ai/core';
|
|
import { type PluginContext, PositionData } from '@flowgram.ai/core';
|
|
|
|
|
|
|
|
import { DragNodeOperationValue, type FreeHistoryPluginOptions, FreeOperationType } from './types';
|
|
import { DragNodeOperationValue, type FreeHistoryPluginOptions, FreeOperationType } from './types';
|
|
|
import { HistoryEntityManager } from './history-entity-manager';
|
|
import { HistoryEntityManager } from './history-entity-manager';
|
|
|
import { DragNodesHandler } from './handlers/drag-nodes-handler';
|
|
import { DragNodesHandler } from './handlers/drag-nodes-handler';
|
|
|
-import { ChangeNodeDataHandler } from './handlers/change-node-data-handler';
|
|
|
|
|
import { ChangeContentHandler } from './handlers/change-content-handler';
|
|
import { ChangeContentHandler } from './handlers/change-content-handler';
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -33,19 +29,12 @@ export class FreeHistoryManager {
|
|
|
@inject(DragNodesHandler)
|
|
@inject(DragNodesHandler)
|
|
|
private _dragNodesHandler: DragNodesHandler;
|
|
private _dragNodesHandler: DragNodesHandler;
|
|
|
|
|
|
|
|
- @inject(ChangeNodeDataHandler)
|
|
|
|
|
- private _changeNodeDataHandler: ChangeNodeDataHandler;
|
|
|
|
|
-
|
|
|
|
|
@inject(ChangeContentHandler)
|
|
@inject(ChangeContentHandler)
|
|
|
private _changeContentHandler: ChangeContentHandler;
|
|
private _changeContentHandler: ChangeContentHandler;
|
|
|
|
|
|
|
|
@inject(HistoryEntityManager)
|
|
@inject(HistoryEntityManager)
|
|
|
private _entityManager: HistoryEntityManager;
|
|
private _entityManager: HistoryEntityManager;
|
|
|
|
|
|
|
|
- @inject(FormManager)
|
|
|
|
|
- @optional()
|
|
|
|
|
- private _formManager?: FormManager;
|
|
|
|
|
-
|
|
|
|
|
private _toDispose: DisposableCollection = new DisposableCollection();
|
|
private _toDispose: DisposableCollection = new DisposableCollection();
|
|
|
|
|
|
|
|
@inject(WorkflowOperationBaseService)
|
|
@inject(WorkflowOperationBaseService)
|
|
@@ -76,25 +65,6 @@ export class FreeHistoryManager {
|
|
|
this._entityManager.addEntityData(positionData);
|
|
this._entityManager.addEntityData(positionData);
|
|
|
}
|
|
}
|
|
|
}),
|
|
}),
|
|
|
- this._formManager
|
|
|
|
|
- ? this._formManager.onFormModelWillInit(({ model, data }) => {
|
|
|
|
|
- const node = model.flowNodeEntity;
|
|
|
|
|
- const formData = node.getData<FlowNodeFormData>(FlowNodeFormData);
|
|
|
|
|
-
|
|
|
|
|
- if (formData) {
|
|
|
|
|
- this._entityManager.setValue(formData, cloneDeep(data));
|
|
|
|
|
-
|
|
|
|
|
- this._toDispose.push(
|
|
|
|
|
- formData.onDetailChange((event) => {
|
|
|
|
|
- this._changeNodeDataHandler.handle({
|
|
|
|
|
- ...event,
|
|
|
|
|
- node,
|
|
|
|
|
- });
|
|
|
|
|
- })
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- : Disposable.NULL,
|
|
|
|
|
document.onContentChange((event) => {
|
|
document.onContentChange((event) => {
|
|
|
this._changeContentHandler.handle(event, ctx);
|
|
this._changeContentHandler.handle(event, ctx);
|
|
|
}),
|
|
}),
|