This commit is contained in:
2026-01-17 00:35:27 +01:00
parent 4ff0f4ba89
commit 565ea0030d

View File

@@ -75,9 +75,6 @@
if (!component) return;
const content = String(html || '');
try {
if (component.components) {
component.components(content);
}
if (component.set) component.set('content', content);
} catch {}
if (component.view && component.view.el) {
@@ -291,6 +288,7 @@
saveBtn.addEventListener('click', () => {
const rawHtml = content.innerHTML || '';
const html = sanitizeInlineHtml(rawHtml, content.textContent || '');
component.__bridgeRteLastContent = html;
applyContentToComponent(editor, component, html);
closeModal();
});
@@ -341,6 +339,20 @@
if (!actions.includes('bridge-open-richtext')) actions.push('bridge-open-richtext');
cfg.richTextEditor.actions = actions;
const restoreIfCollapsed = (model) => {
if (!model || model.__bridgeRteRestoring) return;
const last = model.__bridgeRteLastContent;
if (!last || !model.get) return;
const current = String(model.get('content') || '').trim();
if (!current || current === '<div></div>' || current === '<div><br></div>' || current === '<div><br></div><br>') {
model.__bridgeRteRestoring = true;
applyContentToComponent(editor, model, last);
model.__bridgeRteRestoring = false;
}
};
editor.on('component:update', (model) => restoreIfCollapsed(model));
editor.on('component:input', (model) => restoreIfCollapsed(model));
editor.on('component:selected', (model) => ensureTextToolbarButton(model));
editor.on('component:add', (model) => ensureTextToolbarButton(model));
editor.on('component:dblclick', (model) => {