This commit is contained in:
2026-01-26 21:34:39 +01:00
parent 6ad550e354
commit 7d577568a0

View File

@@ -470,10 +470,23 @@
: ''; : '';
const cssPayload = (fontCss ? fontCss + '\n' : '') + editor.getCss(); const cssPayload = (fontCss ? fontCss + '\n' : '') + editor.getCss();
const serializeHtml = () => { const serializeHtml = () => {
const rawHtml = editor.getHtml() || '';
if (B && B.BridgeRTE && typeof B.BridgeRTE.serializeHtml === 'function') { 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(/<body[^>]*>([\s\S]*?)<\/body>/i);
if (bodyMatch) patched = bodyMatch[1];
} }
return editor.getHtml(); if (!patched || (rawHtml && patched.length < rawHtml.length * 0.6)) {
return rawHtml;
}
return patched;
} catch {
return rawHtml;
}
}
return rawHtml;
}; };
const htmlContent = serializeHtml() + '<style>' + cssPayload + '</style>'; const htmlContent = serializeHtml() + '<style>' + cssPayload + '</style>';
// 2. KRITISCH: Holt die JSON-Repräsentation des Editors // 2. KRITISCH: Holt die JSON-Repräsentation des Editors