feat: when copy/paste multi nodes not require reconnect them (#32631)

This commit is contained in:
非法操作
2026-03-09 13:55:12 +08:00
committed by GitHub
parent 654e41d47f
commit 4a2ba058bb
2 changed files with 51 additions and 5 deletions

View File

@ -108,12 +108,13 @@ export const useNodeLoopInteractions = () => {
handleNodeLoopRerender(parentId)
}, [store, handleNodeLoopRerender])
const handleNodeLoopChildrenCopy = useCallback((nodeId: string, newNodeId: string) => {
const handleNodeLoopChildrenCopy = 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_LOOP_START_NODE)
const newIdMapping = { ...idMapping }
return childrenNodes.map((child, index) => {
const copyChildren = childrenNodes.map((child, index) => {
const childNodeType = child.data.type as BlockEnum
const { defaultValue } = nodesMetaDataMap![childNodeType]
const nodesWithSameType = nodes.filter(node => node.data.type === childNodeType)
@ -139,8 +140,14 @@ export const useNodeLoopInteractions = () => {
zIndex: LOOP_CHILDREN_Z_INDEX,
})
newNode.id = `${newNodeId}${newNode.id + index}`
newIdMapping[child.id] = newNode.id
return newNode
})
return {
copyChildren,
newIdMapping,
}
}, [store, nodesMetaDataMap])
return {