From ccbd80dcb71097a04368dba7b730f6cd150bf21e Mon Sep 17 00:00:00 2001 From: Aljaz Grilc Date: Thu, 4 Apr 2024 14:19:31 +0200 Subject: [PATCH] Resolve issue with handling multiple mistakes in single CKEditor block element --- service.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/service.js b/service.js index 19a0335..f1bcf9a 100644 --- a/service.js +++ b/service.js @@ -717,7 +717,11 @@ class BesCKService extends BesService { super.markProofed(el, matches) // This is a solution for displaying mistakes in CKEditor. It is not the best solution, but it works for now. - if (this.ckEditorInstance) window.dispatchEvent(new Event('resize')) + if (this.ckEditorInstance) { + setTimeout(() => { + window.dispatchEvent(new Event('resize')) + }, 100) + } } /** @@ -751,13 +755,13 @@ class BesCKService extends BesService { match.range ) const modelRange = ckEditorInstance.editing.mapper.toModelRange(viewRange) + this.clearMistakeMarkup(el) ckEditorInstance.model.change(writer => { const attributes = ckEditorInstance.model.document.selection.getAttributes() writer.remove(modelRange) writer.insertText(replacement, attributes, modelRange.start) }) - 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, // rather than re-evaluating the entire document or a larger set of elements.