From 6d85d5819483b429c3275360d3e9b26e0c1d0753 Mon Sep 17 00:00:00 2001 From: Lars Gebhardt-Kusche Date: Mon, 19 Jan 2026 01:51:32 +0100 Subject: [PATCH] asdsad --- public/assets/js/bridge/rte-editor.js | 31 ++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/public/assets/js/bridge/rte-editor.js b/public/assets/js/bridge/rte-editor.js index 38cacb4..fb2eaca 100644 --- a/public/assets/js/bridge/rte-editor.js +++ b/public/assets/js/bridge/rte-editor.js @@ -204,7 +204,23 @@ const modelContent = (component.get && component.get('content')) || ''; const viewHtml = (component.view && component.view.el && component.view.el.innerHTML) || ''; - const initialHtml = sanitizeInlineHtml(viewHtml || modelContent, modelContent || ''); + let htmlSource = viewHtml || modelContent || ''; + if (!htmlSource && component && typeof component.toHTML === 'function') { + try { + const fullHtml = String(component.toHTML() || ''); + if (fullHtml) { + const wrapper = document.createElement('div'); + wrapper.innerHTML = fullHtml; + const first = wrapper.firstElementChild; + if (first && first.innerHTML !== undefined) { + htmlSource = first.innerHTML; + } else { + htmlSource = wrapper.innerHTML; + } + } + } catch {} + } + const initialHtml = sanitizeInlineHtml(htmlSource, modelContent || ''); content.innerHTML = initialHtml; const existingStyle = component && component.get && component.get('style') ? component.get('style') : null; if (existingStyle && typeof existingStyle === 'object') { @@ -388,14 +404,23 @@ }); return; } + const normalizeKeys = (obj) => { + const out = {}; + Object.entries(obj || {}).forEach(([key, val]) => { + if (key === 'fontFamily') out['font-family'] = val; + else if (key === 'fontSize') out['font-size'] = val; + else out[key] = val; + }); + return out; + }; if (component && component.setStyle && component.getStyle) { const current = component.getStyle() || {}; const safeCurrent = (current && typeof current === 'object' && !Array.isArray(current)) ? current : {}; - component.setStyle({ ...safeCurrent, ...styleObj }); + component.setStyle({ ...safeCurrent, ...normalizeKeys(styleObj) }); } else if (component && component.set) { const current = component.get && component.get('style') ? component.get('style') : {}; const safeCurrent = (current && typeof current === 'object' && !Array.isArray(current)) ? current : {}; - component.set('style', { ...safeCurrent, ...styleObj }); + component.set('style', { ...safeCurrent, ...normalizeKeys(styleObj) }); } if (component && component.view && component.view.el) { Object.entries(styleObj).forEach(([key, val]) => {