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)
let data = []
for (const el2 of node.childNodes) {
for (const el2 of node.childNodes)
data = data.concat(await this.proof(el2))
}
if (data.some(x => !x.markup && !/^\s*$/.test(x.text))) {
const requestData = {
format: 'plain',
@ -531,9 +530,7 @@ class BesService {
*/
static findParent(el) {
for (; el; el = el.parentNode) {
if (besServices.find(service => service.hostElement === el)) {
return el
}
if (besServices.find(service => service.hostElement === el)) return el
}
return null
}
@ -579,9 +576,8 @@ class BesService {
this.abortController.abort()
match.range.deleteContents()
match.range.insertNode(document.createTextNode(replacement))
if (this.textAreaService) {
if (this.textAreaService)
this.textAreaService.handleReplacement(this.hostElement)
}
this.clearMistakeMarkup(el)
// 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,
@ -672,7 +668,6 @@ class BesCKService extends BesService {
/**
* Updates grammar mistake markup positions.
*/
// TODO: Implement a more efficient solution for repositioning mistakes after scrolling etc.
repositionMistakes() {
this.children.forEach(child => {
this.clearMistakeMarkup(child.element)