|
@@ -16,6 +16,7 @@ import { FlowGroupService, FlowNodeBaseType } from '@flowgram.ai/document';
|
|
|
import { TransformData } from '@flowgram.ai/core';
|
|
import { TransformData } from '@flowgram.ai/core';
|
|
|
|
|
|
|
|
import { WorkflowGroupUtils } from './utils';
|
|
import { WorkflowGroupUtils } from './utils';
|
|
|
|
|
+import { WorkflowGroupPluginOptions } from './type';
|
|
|
|
|
|
|
|
@injectable()
|
|
@injectable()
|
|
|
/** 分组服务 */
|
|
/** 分组服务 */
|
|
@@ -28,6 +29,8 @@ export class WorkflowGroupService extends FlowGroupService {
|
|
|
|
|
|
|
|
@inject(NodeIntoContainerService) private nodeIntoContainerService: NodeIntoContainerService;
|
|
@inject(NodeIntoContainerService) private nodeIntoContainerService: NodeIntoContainerService;
|
|
|
|
|
|
|
|
|
|
+ @inject(WorkflowGroupPluginOptions) private opts: WorkflowGroupPluginOptions;
|
|
|
|
|
+
|
|
|
private toDispose = new DisposableCollection();
|
|
private toDispose = new DisposableCollection();
|
|
|
|
|
|
|
|
public ready(): void {
|
|
public ready(): void {
|
|
@@ -44,10 +47,9 @@ export class WorkflowGroupService extends FlowGroupService {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
const parent = nodes[0].parent ?? this.document.root;
|
|
const parent = nodes[0].parent ?? this.document.root;
|
|
|
- const groupId = `group_${nanoid(5)}`;
|
|
|
|
|
- const groupJSON: WorkflowNodeJSON = {
|
|
|
|
|
|
|
+ let groupJSON: WorkflowNodeJSON = {
|
|
|
type: FlowNodeBaseType.GROUP,
|
|
type: FlowNodeBaseType.GROUP,
|
|
|
- id: groupId,
|
|
|
|
|
|
|
+ id: `group_${nanoid(5)}`,
|
|
|
meta: {
|
|
meta: {
|
|
|
position: {
|
|
position: {
|
|
|
x: 0,
|
|
x: 0,
|
|
@@ -56,6 +58,9 @@ export class WorkflowGroupService extends FlowGroupService {
|
|
|
},
|
|
},
|
|
|
data: {},
|
|
data: {},
|
|
|
};
|
|
};
|
|
|
|
|
+ if (this.opts.initGroupJSON) {
|
|
|
|
|
+ groupJSON = this.opts.initGroupJSON(groupJSON, nodes);
|
|
|
|
|
+ }
|
|
|
this.historyService.startTransaction();
|
|
this.historyService.startTransaction();
|
|
|
this.document.createWorkflowNodeByType(
|
|
this.document.createWorkflowNodeByType(
|
|
|
FlowNodeBaseType.GROUP,
|
|
FlowNodeBaseType.GROUP,
|
|
@@ -68,7 +73,7 @@ export class WorkflowGroupService extends FlowGroupService {
|
|
|
);
|
|
);
|
|
|
nodes.forEach((node) => {
|
|
nodes.forEach((node) => {
|
|
|
this.freeOperationService.moveNode(node, {
|
|
this.freeOperationService.moveNode(node, {
|
|
|
- parent: groupId,
|
|
|
|
|
|
|
+ parent: groupJSON.id,
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
this.historyService.endTransaction();
|
|
this.historyService.endTransaction();
|