From 16a50b0ca9af301482b5d1ad32a5e16d99ec3e7e Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Sat, 9 May 2026 19:36:43 +0100 Subject: [PATCH] Lexical: Fixed updating of TextNode text on export --- .../js/wysiwyg/lexical/core/nodes/LexicalTextNode.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/resources/js/wysiwyg/lexical/core/nodes/LexicalTextNode.ts b/resources/js/wysiwyg/lexical/core/nodes/LexicalTextNode.ts index 6588b7e10..860f03925 100644 --- a/resources/js/wysiwyg/lexical/core/nodes/LexicalTextNode.ts +++ b/resources/js/wysiwyg/lexical/core/nodes/LexicalTextNode.ts @@ -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,