diff --git a/public/assets/js/bridge/blocks-api.js b/public/assets/js/bridge/blocks-api.js index d961ab2..dd28798 100644 --- a/public/assets/js/bridge/blocks-api.js +++ b/public/assets/js/bridge/blocks-api.js @@ -470,10 +470,23 @@ : ''; const cssPayload = (fontCss ? fontCss + '\n' : '') + editor.getCss(); const serializeHtml = () => { + const rawHtml = editor.getHtml() || ''; if (B && B.BridgeRTE && typeof B.BridgeRTE.serializeHtml === 'function') { - return B.BridgeRTE.serializeHtml(editor); + try { + let patched = B.BridgeRTE.serializeHtml(editor) || ''; + if (patched) { + const bodyMatch = patched.match(/
]*>([\s\S]*?)<\/body>/i); + if (bodyMatch) patched = bodyMatch[1]; + } + if (!patched || (rawHtml && patched.length < rawHtml.length * 0.6)) { + return rawHtml; + } + return patched; + } catch { + return rawHtml; + } } - return editor.getHtml(); + return rawHtml; }; const htmlContent = serializeHtml() + ''; // 2. KRITISCH: Holt die JSON-Repräsentation des Editors