feat: 拖动到循环体节点连线断开
This commit is contained in:
parent
dd31fbaef3
commit
add482aee2
@ -791,10 +791,21 @@ export const createFlowFacade = (store) => {
|
|||||||
const group = store.findNode(groupId);
|
const group = store.findNode(groupId);
|
||||||
const child = store.findNode(childId);
|
const child = store.findNode(childId);
|
||||||
if (!group || !child || GROUP_TYPES.has(child.data.flowType)) return;
|
if (!group || !child || GROUP_TYPES.has(child.data.flowType)) return;
|
||||||
|
const previousParentId = child.parentNode || child.data?.properties?.parentId;
|
||||||
const graph = facade.getGraphData();
|
const graph = facade.getGraphData();
|
||||||
const groupData = graph.nodes.find((node) => node.id === groupId);
|
const groupData = graph.nodes.find((node) => node.id === groupId);
|
||||||
const childData = graph.nodes.find((node) => node.id === childId);
|
const childData = graph.nodes.find((node) => node.id === childId);
|
||||||
if (!groupData || !childData) return;
|
if (!groupData || !childData) return;
|
||||||
|
|
||||||
|
// 节点从循环体外进入循环体后,原连线的两端已处于不同执行作用域,必须全部断开。
|
||||||
|
// 在重新渲染父子结构前直接过滤图数据,可保证入边、出边和层级变更在同一次更新中完成。
|
||||||
|
const enteringLoop = group.data.flowType === "loop" && previousParentId !== groupId;
|
||||||
|
if (enteringLoop) {
|
||||||
|
graph.edges = graph.edges.filter((edge) => (
|
||||||
|
edge.sourceNodeId !== childId && edge.targetNodeId !== childId
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
groupData.children = Array.from(new Set([...(groupData.children || []), childId]));
|
groupData.children = Array.from(new Set([...(groupData.children || []), childId]));
|
||||||
childData.properties = { ...(childData.properties || {}), parentId: groupId };
|
childData.properties = { ...(childData.properties || {}), parentId: groupId };
|
||||||
if (dropCenter) {
|
if (dropCenter) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user