This commit is contained in:
Simon Rozman 2024-04-02 13:22:25 +02:00
parent 7d7682ae9a
commit e6324c55b3

View File

@ -90,9 +90,8 @@ class BesService {
} }
this.clearMistakeMarkup(node) this.clearMistakeMarkup(node)
let data = [] let data = []
for (const el2 of node.childNodes) { for (const el2 of node.childNodes)
data = data.concat(await this.proof(el2)) data = data.concat(await this.proof(el2))
}
if (data.some(x => !x.markup && !/^\s*$/.test(x.text))) { if (data.some(x => !x.markup && !/^\s*$/.test(x.text))) {
const requestData = { const requestData = {
format: 'plain', format: 'plain',
@ -531,9 +530,7 @@ class BesService {
*/ */
static findParent(el) { static findParent(el) {
for (; el; el = el.parentNode) { for (; el; el = el.parentNode) {
if (besServices.find(service => service.hostElement === el)) { if (besServices.find(service => service.hostElement === el)) return el
return el
}
} }
return null return null
} }
@ -579,9 +576,8 @@ class BesService {
this.abortController.abort() this.abortController.abort()
match.range.deleteContents() match.range.deleteContents()
match.range.insertNode(document.createTextNode(replacement)) match.range.insertNode(document.createTextNode(replacement))
if (this.textAreaService) { if (this.textAreaService)
this.textAreaService.handleReplacement(this.hostElement) this.textAreaService.handleReplacement(this.hostElement)
}
this.clearMistakeMarkup(el) this.clearMistakeMarkup(el)
// In my opinion, this approach provides the most straightforward solution for repositioning mistakes after a change. // In my opinion, this approach provides the most straightforward solution for repositioning mistakes after a change.
// It maintains reasonable performance as it only checks the block element that has been modified, // It maintains reasonable performance as it only checks the block element that has been modified,
@ -672,7 +668,6 @@ class BesCKService extends BesService {
/** /**
* Updates grammar mistake markup positions. * Updates grammar mistake markup positions.
*/ */
// TODO: Implement a more efficient solution for repositioning mistakes after scrolling etc.
repositionMistakes() { repositionMistakes() {
this.children.forEach(child => { this.children.forEach(child => {
this.clearMistakeMarkup(child.element) this.clearMistakeMarkup(child.element)