From e6324c55b35d5df40943d7c9fdf8018510b9b89d Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Tue, 2 Apr 2024 13:22:25 +0200 Subject: [PATCH] Cleanup --- service.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/service.js b/service.js index 6b7d9ad..91e8c93 100644 --- a/service.js +++ b/service.js @@ -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)