wanglin2 / mind-map

一个还算强大的Web思维导图。A relatively powerful web mind map.
https://wanglin2.github.io/mind-map-docs/
MIT License
5.97k stars 845 forks source link

创建节点后,产生了多余的操作记录 #572

Open zcc0329 opened 6 months ago

zcc0329 commented 6 months ago

从根节点创建节点后,发现操作记录(mindMap.command.history)数组中个数为3,对比第二条和第三条记录,第三条记录中新增了 resetRichText: false。猜测可能因此导致对比数据状态时不一致,然后添加了新的操作记录。我从您的在线演示网站上也发现了此问题

zcc0329 commented 6 months ago

function repairStore(node) { // 仓库源码bug if (node.isRoot) return; // 根节点 const nodeTree = mindMap.getData(); console.log("nodeTree", nodeTree, node.nodeData); // 如果是第二层节点,添加resetRichText:false // 如果是第三层节点,删除resetRichText属性

const isTwoLevelNode = nodeTree.children.some( (curNode) => curNode.data.uid === node.nodeData.data.uid ); if (isTwoLevelNode) { node.nodeData.data.resetRichText = false; } else { delete node.nodeData.data.resetRichText; } } 暂时通过在node_active事件中,延时执行,去除影响操作记录的属性,就可以不用点击两次回退了