mirror of
https://gitee.com/ByteDance/flowgram.ai.git
synced 2025-07-07 17:43:29 +08:00
feat(canvas-core): container node use meta.isContainer tag instead of SUB_CANVAS type
This commit is contained in:
parent
5f1f2a6a03
commit
dba6190e1a
@ -18,6 +18,7 @@ export interface WorkflowNodeMeta extends FlowNodeMeta {
|
|||||||
defaultPorts?: WorkflowPorts; // 默认点位
|
defaultPorts?: WorkflowPorts; // 默认点位
|
||||||
useDynamicPort?: boolean; // 使用动态点位,会计算 data-port-key
|
useDynamicPort?: boolean; // 使用动态点位,会计算 data-port-key
|
||||||
subCanvas?: (node: WorkflowNodeEntity) => WorkflowSubCanvas | undefined;
|
subCanvas?: (node: WorkflowNodeEntity) => WorkflowSubCanvas | undefined;
|
||||||
|
isContainer?: boolean; // 是否容器节点
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -367,11 +367,11 @@ export class WorkflowDocument extends FlowDocument {
|
|||||||
const endNodeId = allNode.find((node) => node.isNodeEnd)!.id;
|
const endNodeId = allNode.find((node) => node.isNodeEnd)!.id;
|
||||||
|
|
||||||
// 子画布内节点无需开始/结束
|
// 子画布内节点无需开始/结束
|
||||||
const nodeInSubCanvas = allNode
|
const nodeInContainer = allNode
|
||||||
.filter((node) => node.parent?.flowNodeType === FlowNodeBaseType.SUB_CANVAS)
|
.filter((node) => node.parent?.getNodeMeta<WorkflowNodeMeta>().isContainer)
|
||||||
.map((node) => node.id);
|
.map((node) => node.id);
|
||||||
|
|
||||||
const associatedCache = new Set([endNodeId, ...nodeInSubCanvas]);
|
const associatedCache = new Set([endNodeId, ...nodeInContainer]);
|
||||||
const bfs = (nodeId: string) => {
|
const bfs = (nodeId: string) => {
|
||||||
if (associatedCache.has(nodeId)) {
|
if (associatedCache.has(nodeId)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -8,12 +8,12 @@ import {
|
|||||||
WorkflowPortEntity,
|
WorkflowPortEntity,
|
||||||
WorkflowNodePortsData,
|
WorkflowNodePortsData,
|
||||||
WorkflowNodeEntity,
|
WorkflowNodeEntity,
|
||||||
|
WorkflowNodeMeta,
|
||||||
} from '@flowgram.ai/free-layout-core';
|
} from '@flowgram.ai/free-layout-core';
|
||||||
import { WorkflowSelectService } from '@flowgram.ai/free-layout-core';
|
import { WorkflowSelectService } from '@flowgram.ai/free-layout-core';
|
||||||
import { WorkflowNodeJSON } from '@flowgram.ai/free-layout-core';
|
import { WorkflowNodeJSON } from '@flowgram.ai/free-layout-core';
|
||||||
import { FreeOperationType, HistoryService } from '@flowgram.ai/free-history-plugin';
|
import { FreeOperationType, HistoryService } from '@flowgram.ai/free-history-plugin';
|
||||||
import { FlowNodeTransformData } from '@flowgram.ai/document';
|
import { FlowNodeTransformData } from '@flowgram.ai/document';
|
||||||
import { FlowNodeBaseType } from '@flowgram.ai/document';
|
|
||||||
import { PlaygroundConfigEntity } from '@flowgram.ai/core';
|
import { PlaygroundConfigEntity } from '@flowgram.ai/core';
|
||||||
import { TransformData } from '@flowgram.ai/core';
|
import { TransformData } from '@flowgram.ai/core';
|
||||||
|
|
||||||
@ -293,7 +293,7 @@ export class WorkflowNodePanelService {
|
|||||||
}
|
}
|
||||||
const fromNode = fromPort?.node;
|
const fromNode = fromPort?.node;
|
||||||
const fromContainer = fromNode?.parent;
|
const fromContainer = fromNode?.parent;
|
||||||
if (fromNode?.flowNodeType === FlowNodeBaseType.SUB_CANVAS) {
|
if (this.isContainer(fromNode)) {
|
||||||
// 子画布内部输入连线
|
// 子画布内部输入连线
|
||||||
return fromNode;
|
return fromNode;
|
||||||
}
|
}
|
||||||
@ -303,7 +303,7 @@ export class WorkflowNodePanelService {
|
|||||||
/** 获取端口矩形 */
|
/** 获取端口矩形 */
|
||||||
private getPortBox(port: WorkflowPortEntity, offset: IPoint = { x: 0, y: 0 }): Rectangle {
|
private getPortBox(port: WorkflowPortEntity, offset: IPoint = { x: 0, y: 0 }): Rectangle {
|
||||||
const node = port.node;
|
const node = port.node;
|
||||||
if (node.flowNodeType === FlowNodeBaseType.SUB_CANVAS) {
|
if (this.isContainer(node)) {
|
||||||
// 子画布内部端口需要虚拟节点
|
// 子画布内部端口需要虚拟节点
|
||||||
const { point } = port;
|
const { point } = port;
|
||||||
if (port.portType === 'input') {
|
if (port.portType === 'input') {
|
||||||
@ -424,7 +424,7 @@ export class WorkflowNodePanelService {
|
|||||||
|
|
||||||
/** 获取后续节点 */
|
/** 获取后续节点 */
|
||||||
private getSubsequentNodes(node: WorkflowNodeEntity): WorkflowNodeEntity[] {
|
private getSubsequentNodes(node: WorkflowNodeEntity): WorkflowNodeEntity[] {
|
||||||
if (node.flowNodeType === FlowNodeBaseType.SUB_CANVAS) {
|
if (this.isContainer(node)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
const brothers = node.parent?.collapsedChildren ?? [];
|
const brothers = node.parent?.collapsedChildren ?? [];
|
||||||
@ -436,7 +436,7 @@ export class WorkflowNodePanelService {
|
|||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
!line.to?.id ||
|
!line.to?.id ||
|
||||||
line.to.flowNodeType === FlowNodeBaseType.SUB_CANVAS // 子画布内部成环
|
this.isContainer(line.to) // 子画布内部成环
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -519,4 +519,9 @@ export class WorkflowNodePanelService {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 是否容器节点 */
|
||||||
|
private isContainer(node?: WorkflowNodeEntity): boolean {
|
||||||
|
return node?.getNodeMeta<WorkflowNodeMeta>().isContainer ?? false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user