fix: the edges between the nodes inside the copied iteration node are… (#12692)

This commit is contained in:
JonSnow
2025-02-28 19:33:47 +08:00
committed by GitHub
parent f49b0822aa
commit 1eb072fd43
2 changed files with 40 additions and 3 deletions

View File

@@ -105,12 +105,13 @@ export const useNodeIterationInteractions = () => {
handleNodeIterationRerender(parentId)
}, [store, handleNodeIterationRerender])
const handleNodeIterationChildrenCopy = useCallback((nodeId: string, newNodeId: string) => {
const handleNodeIterationChildrenCopy = useCallback((nodeId: string, newNodeId: string, idMapping: Record<string, string>) => {
const { getNodes } = store.getState()
const nodes = getNodes()
const childrenNodes = nodes.filter(n => n.parentId === nodeId && n.type !== CUSTOM_ITERATION_START_NODE)
const newIdMapping = { ...idMapping }
return childrenNodes.map((child, index) => {
const copyChildren = childrenNodes.map((child, index) => {
const childNodeType = child.data.type as BlockEnum
const nodesWithSameType = nodes.filter(node => node.data.type === childNodeType)
const { newNode } = generateNewNode({
@@ -131,8 +132,14 @@ export const useNodeIterationInteractions = () => {
zIndex: child.zIndex,
})
newNode.id = `${newNodeId}${newNode.id + index}`
newIdMapping[child.id] = newNode.id
return newNode
})
return {
copyChildren,
newIdMapping,
}
}, [store, t])
return {