From 26539b8c10a0278fec90bd1e75088cc55f44d0b1 Mon Sep 17 00:00:00 2001 From: Aljaz Grilc Date: Wed, 21 Feb 2024 13:43:55 +0100 Subject: [PATCH] Add TODO comment and commented code for rich HTML text replacement --- online-editor.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/online-editor.js b/online-editor.js index d9c506d..89645f6 100644 --- a/online-editor.js +++ b/online-editor.js @@ -432,7 +432,10 @@ class BesEditor { return false } + // TODO: In rich HTML texts, match.offset has different value than in plain text. + // This function should be able to handle both cases or find a way that works for both. static replaceText(el, rect, match, replacement, editor) { + // const tags = this.getTagsAndText(el) const text = el.textContent const newText = text.substring(0, match.offset) + @@ -446,6 +449,20 @@ class BesEditor { editor.proof(el) } + // static getTagsAndText(node) { + // if (node.nodeType === Node.TEXT_NODE) { + // return node.textContent + // } else if (node.nodeType === Node.ELEMENT_NODE) { + // let tag = node.tagName.toLowerCase() + // let content = Array.from(node.childNodes) + // .map(BesEditor.getTagsAndText) + // .join('') + // return `<${tag}>${content}` + // } else { + // return '' + // } + // } + // This function clears a single mistake static clearSingleMistake(editor, el, rect) { const childToDelete = editor.children.filter(