Feat:INSERT_NODE、INSERT_MULIT_NODE、INSERT_CHILD_NODE、INSERT_MULIT_CHILD_NODE命令不会覆盖指定新插入节点数据的uid

This commit is contained in:
街角小林 2024-02-22 10:18:00 +08:00
parent 3effff95fa
commit 8487e148ea

View File

@ -649,7 +649,7 @@ class Render {
uid: createUid(), uid: createUid(),
...(appointData || {}) ...(appointData || {})
}, },
children: [...createUidForAppointNodes(appointChildren, true)] children: [...createUidForAppointNodes(appointChildren)]
} }
parent.nodeData.children.splice(index + 1, 0, newNodeData) parent.nodeData.children.splice(index + 1, 0, newNodeData)
}) })
@ -685,10 +685,7 @@ class Render {
const parent = node.parent const parent = node.parent
// 计算插入位置 // 计算插入位置
const index = getNodeDataIndex(node) const index = getNodeDataIndex(node)
const newNodeList = createUidForAppointNodes( const newNodeList = createUidForAppointNodes(simpleDeepClone(nodeList))
simpleDeepClone(nodeList),
true
)
parent.nodeData.children.splice(index + 1, 0, ...newNodeList) parent.nodeData.children.splice(index + 1, 0, ...newNodeList)
}) })
if (focusNewNode) { if (focusNewNode) {
@ -748,7 +745,7 @@ class Render {
...params, ...params,
...(appointData || {}) ...(appointData || {})
}, },
children: [...createUidForAppointNodes(appointChildren, true)] children: [...createUidForAppointNodes(appointChildren)]
} }
node.nodeData.children.push(newNode) node.nodeData.children.push(newNode)
// 插入子节点时自动展开子节点 // 插入子节点时自动展开子节点
@ -788,7 +785,7 @@ class Render {
if (!node.nodeData.children) { if (!node.nodeData.children) {
node.nodeData.children = [] node.nodeData.children = []
} }
childList = createUidForAppointNodes(childList, true) childList = createUidForAppointNodes(childList)
node.nodeData.children.push(...childList) node.nodeData.children.push(...childList)
// 插入子节点时自动展开子节点 // 插入子节点时自动展开子节点
node.setData({ node.setData({