Lexical: Fixed updating of TextNode text on export

This commit is contained in:
Dan Brown
2026-05-09 19:36:43 +01:00
parent 5f306801d7
commit 16a50b0ca9

View File

@@ -657,12 +657,17 @@ export class TextNode extends LexicalNode {
element.removeAttribute('class');
}
// Apply whitespace replacement to the element
element.textContent = text;
// Remove placeholder tag if redundant
if (element.nodeName === 'SPAN' && !element.getAttribute('style')) {
element = document.createTextNode(text);
} else {
// Apply whitespace replaced text to the element
// Search down the child chain in the event this element is already wrapped
let child: Element = element;
while (child.childElementCount > 0) {
child = child.children[0];
}
child.textContent = text;
}
// This is the only way to properly add support for most clients,