Compare commits

..

No commits in common. "master" and "api-v1" have entirely different histories.

View File

@ -1857,7 +1857,6 @@ class BesQuillService extends BesTreeService {
onChangeData(delta) { onChangeData(delta) {
let index = 0 let index = 0
let reproofNeeded = false let reproofNeeded = false
const affectedBlocks = new Set()
delta.ops.forEach(op => { delta.ops.forEach(op => {
if (op.retain) { if (op.retain) {
@ -1867,12 +1866,11 @@ class BesQuillService extends BesTreeService {
} }
} else if (op.insert) { } else if (op.insert) {
reproofNeeded = true reproofNeeded = true
index += typeof op.insert === 'string' ? op.insert.length : 1 // Handle string or embed index += op.insert.length
} else if (op.delete) { } else if (op.delete) {
reproofNeeded = true reproofNeeded = true
} }
}) })
if (reproofNeeded) { if (reproofNeeded) {
const editorLength = this.quillInstance.getLength() const editorLength = this.quillInstance.getLength()
const clampedIndex = Math.min(index, editorLength - 1) const clampedIndex = Math.min(index, editorLength - 1)
@ -1881,55 +1879,22 @@ class BesQuillService extends BesTreeService {
if (leaf) { if (leaf) {
let domElement = leaf.domNode let domElement = leaf.domNode
// Traverse up to find the block element
while (domElement && !this.isBlockElement(domElement)) { while (domElement && !this.isBlockElement(domElement)) {
domElement = domElement.parentNode domElement = domElement.parentNode
} }
if (domElement) {
this.clearProofing(domElement)
if (domElement) affectedBlocks.add(domElement) setTimeout(() => {
this.redrawAllMistakeMarkup()
this.scheduleProofing(1000)
}, 0)
}
} else { } else {
console.warn( console.warn(
'Leaf is null. The index might be out of bounds or the editor content is empty.' 'Leaf is null. The index might be out of bounds or the editor content is empty.'
) )
} }
// Handle pasted content spanning multiple blocks
const selection = this.quillInstance.getSelection()
if (selection) {
const [startLeaf] = this.quillInstance.getLeaf(selection.index)
const [endLeaf] = this.quillInstance.getLeaf(
selection.index + selection.length
)
if (startLeaf && endLeaf) {
let startElement = startLeaf.domNode
let endElement = endLeaf.domNode
while (startElement && !this.isBlockElement(startElement)) {
startElement = startElement.parentNode
}
while (endElement && !this.isBlockElement(endElement)) {
endElement = endElement.parentNode
}
if (startElement && endElement) {
let currentElement = startElement
while (currentElement) {
affectedBlocks.add(currentElement)
if (currentElement === endElement) break
currentElement = currentElement.nextElementSibling
}
}
}
}
// Clear proofing for all affected blocks
affectedBlocks.forEach(block => this.clearProofing(block))
// Schedule proofing for all affected blocks
setTimeout(() => {
this.scheduleProofing(1000)
}, 0)
} }
} }