Commit 3ed50b19 by pangchong

feat: 对比渲染优化

parent 9fa38c4b
......@@ -14,8 +14,25 @@ export const handleLeftDifferent = (dataForOld: OldTreeModification, treeNew: Tr
const containerLeft = compareLeftRef.value?.editorRef.getEditableContainer()
const containerRight = compareRightRef.value?.editorRef.getEditableContainer()
//新增
dataForOld.Deleted.map((item) => {
const node = containerLeft!.querySelector(`[data-key="${item.key}"]`)
if (node.childNodes.length == 1 && node.childNodes[0].nodeName == 'SPAN') {
//处理左边
node.classList.add('bg-errorColorSuppl')
//处理右边
const parentPath = item.chained.slice(0, item.chained.length - 1)
const index = item.chained[item.chained.length - 1]
const parentData = findNodeByChained(treeNew, parentPath)
const parentNode = containerRight!.querySelector(`[data-key="${parentData?.key}"]`)
// 创建一个新节点
const newDiv = document.createElement('div')
newDiv.style.height = `${node.offsetHeight}px`
newDiv.classList.add('bg-dividerColor')
parentNode && parentNode.insertBefore(newDiv, parentNode.childNodes[index])
}
})
//修改
dataForOld.Changed.map((item: any) => {
dataForOld.Changed.map((item) => {
const node = containerLeft!.querySelector(`[data-key="${item.key}"]`)
if (node.childNodes.length == 1 && node.childNodes[0].nodeName == 'SPAN') {
node.classList.add('bg-warningColorSuppl')
......@@ -43,8 +60,6 @@ export const handleRightDifferent = (dataForNew: NewTreeModification, treeOld: T
newDiv.style.height = `${node.offsetHeight}px`
newDiv.classList.add('bg-dividerColor')
parentNode && parentNode.insertBefore(newDiv, parentNode.childNodes[index])
console.log(parentNode)
console.log(node)
}
})
//修改
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment