Fix out-of-bounds index in BesQuillService
This commit is contained in:
parent
675ecdc7a4
commit
5b10a90814
29
service.js
29
service.js
@ -1209,17 +1209,26 @@ class BesQuillService extends BesTreeService {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (reproofNeeded) {
|
if (reproofNeeded) {
|
||||||
const [leaf, offset] = this.quillInstance.getLeaf(index)
|
const editorLength = this.quillInstance.getLength()
|
||||||
let domElement = leaf.domNode
|
const clampedIndex = Math.min(index, editorLength - 1)
|
||||||
while (domElement && domElement.tagName !== 'P') {
|
|
||||||
domElement = domElement.parentNode
|
|
||||||
}
|
|
||||||
this.clearProofing(domElement)
|
|
||||||
|
|
||||||
setTimeout(() => {
|
const [leaf, offset] = this.quillInstance.getLeaf(clampedIndex)
|
||||||
this.repositionAllMarkup()
|
if (leaf) {
|
||||||
this.scheduleProofing(1000)
|
let domElement = leaf.domNode
|
||||||
}, 0)
|
while (domElement && domElement.tagName !== 'P') {
|
||||||
|
domElement = domElement.parentNode
|
||||||
|
}
|
||||||
|
this.clearProofing(domElement)
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.repositionAllMarkup()
|
||||||
|
this.scheduleProofing(1000)
|
||||||
|
}, 0)
|
||||||
|
} else {
|
||||||
|
console.warn(
|
||||||
|
'Leaf is null. The index might be out of bounds or the editor content is empty.'
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user