mirror of
https://github.com/langgenius/dify.git
synced 2026-04-03 21:51:14 +08:00
fix: HumanInput node should unable to paste into container (#34077)
This commit is contained in:
parent
7fbb1c96db
commit
0e6d97acf9
@ -1820,21 +1820,26 @@ export const useNodesInteractions = () => {
|
||||
newChildren.push(newLoopStartNode!)
|
||||
}
|
||||
else {
|
||||
// single node paste
|
||||
// Paste a single regular node. Loop/Iteration nodes are handled above.
|
||||
const selectedNode = nodes.find(node => node.selected)
|
||||
let pastedToNestedBlock = false
|
||||
|
||||
if (selectedNode) {
|
||||
// Keep this list aligned with availableBlocksFilter(inContainer)
|
||||
// in use-available-blocks.ts.
|
||||
const commonNestedDisallowPasteNodes = [
|
||||
// end node only can be placed outermost layer
|
||||
BlockEnum.End,
|
||||
BlockEnum.Iteration,
|
||||
BlockEnum.Loop,
|
||||
BlockEnum.DataSource,
|
||||
BlockEnum.KnowledgeBase,
|
||||
BlockEnum.HumanInput,
|
||||
]
|
||||
|
||||
// handle disallow paste node
|
||||
if (commonNestedDisallowPasteNodes.includes(nodeToPaste.data.type))
|
||||
return
|
||||
|
||||
// handle paste to nested block
|
||||
// If a Loop/Iteration container is selected, paste into it as a child.
|
||||
if (selectedNode.data.type === BlockEnum.Iteration || selectedNode.data.type === BlockEnum.Loop) {
|
||||
const isIteration = selectedNode.data.type === BlockEnum.Iteration
|
||||
|
||||
@ -1849,10 +1854,10 @@ export const useNodesInteractions = () => {
|
||||
x: newNode.position.x,
|
||||
y: newNode.position.y,
|
||||
}
|
||||
// set position base on parent node
|
||||
// Rebase position into the selected container coordinate system.
|
||||
newNode.position = getNestedNodePosition(newNode, selectedNode)
|
||||
|
||||
// update parent children array like native add
|
||||
// Mirror native add behavior by appending parent._children.
|
||||
parentChildrenToAppend.push({ parentId: selectedNode.id, childId: newNode.id, childType: newNode.data.type })
|
||||
|
||||
pastedToNestedBlock = true
|
||||
|
||||
Loading…
Reference in New Issue
Block a user