This commit is contained in:
lif 2025-12-29 14:52:41 +08:00 committed by GitHub
commit cd637528af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 0 deletions

View File

@ -1671,6 +1671,8 @@ export const useNodesInteractions = () => {
else { else {
// single node paste // single node paste
const selectedNode = nodes.find(node => node.selected) const selectedNode = nodes.find(node => node.selected)
let pastedToNestedBlock = false
if (selectedNode) { if (selectedNode) {
const commonNestedDisallowPasteNodes = [ const commonNestedDisallowPasteNodes = [
// end node only can be placed outermost layer // end node only can be placed outermost layer
@ -1692,6 +1694,7 @@ export const useNodesInteractions = () => {
} }
// set position base on parent node // set position base on parent node
newNode.position = getNestedNodePosition(newNode, selectedNode) newNode.position = getNestedNodePosition(newNode, selectedNode)
pastedToNestedBlock = true
} }
else if (selectedNode.data.type === BlockEnum.Loop) { else if (selectedNode.data.type === BlockEnum.Loop) {
newNode.data.isInLoop = true newNode.data.isInLoop = true
@ -1703,8 +1706,20 @@ export const useNodesInteractions = () => {
} }
// set position base on parent node // set position base on parent node
newNode.position = getNestedNodePosition(newNode, selectedNode) newNode.position = getNestedNodePosition(newNode, selectedNode)
pastedToNestedBlock = true
} }
} }
// Clear loop/iteration metadata when pasting outside nested blocks (fixes #29835)
// This ensures nodes copied from inside Loop/Iteration are properly independent
// when pasted outside
if (!pastedToNestedBlock) {
newNode.data.isInLoop = false
newNode.data.loop_id = undefined
newNode.data.isInIteration = false
newNode.data.iteration_id = undefined
newNode.parentId = undefined
}
} }
nodesToPaste.push(newNode) nodesToPaste.push(newNode)