From 06513cab057d61f838e4e1d72a3be5b1e443451d Mon Sep 17 00:00:00 2001 From: Aljaz Grilc Date: Wed, 22 May 2024 14:22:16 +0200 Subject: [PATCH] Reinstate setTimeout function in CKEditor to ensure proper handling of instances where a specific height value is assigned to the editable element --- samples/styles.css | 4 ++++ service2.js | 19 +++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/samples/styles.css b/samples/styles.css index 77c0ca4..01c0f85 100644 --- a/samples/styles.css +++ b/samples/styles.css @@ -15,3 +15,7 @@ box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); line-height: 20px; } + +.ck-editor__editable { + height: 400px; +} diff --git a/service2.js b/service2.js index 6e7ed00..af439f4 100644 --- a/service2.js +++ b/service2.js @@ -813,12 +813,19 @@ class BesCKService extends BesTreeService { this.clearProofing(domElement) } - this.repositionAllMarkup() - // Defer grammar-checking to reduce stress on grammar-checking server. - this.timer = setTimeout(() => { - this.proofAll() - delete this.timer - }, 1000) + // TODO: Research if input event or any other event that is called *after* the change is completed + // is possible with CKEditor, and move the code below this line there. + // SetTimeout is in fact necessary, because if we set specific height to the editable CKeditor element, it will not be updated immediately. + setTimeout(() => { + // Now that the text is done changing, we can correctly calculate markup position. + this.repositionAllMarkup() + + // Defer grammar-checking to reduce stress on grammar-checking server. + this.timer = setTimeout(() => { + this.proofAll() + delete this.timer + }, 1000) + }, 0) } /**