Add TODO comment and commented code for rich HTML text replacement

This commit is contained in:
Aljaž Grilc 2024-02-21 13:43:55 +01:00
parent 3f39889b0b
commit 26539b8c10

View File

@ -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}</${tag}>`
// } else {
// return ''
// }
// }
// This function clears a single mistake
static clearSingleMistake(editor, el, rect) {
const childToDelete = editor.children.filter(