This commit is contained in:
2026-01-16 01:59:36 +01:00
parent 38c746d45b
commit 979fbfd923

View File

@@ -830,29 +830,6 @@
.replace(/ /g, '') .replace(/ /g, '')
.trim(); .trim();
}; };
const syncFromDom = (model, reason) => {
const target = resolveTextModel(model);
if (!isTextLike(target)) return;
const el = target && target.view && target.view.el;
if (!el) return;
const html = String(el.innerHTML || '').trim();
if (!html) return;
try {
if (target.set) {
target.set('content', html);
target.trigger && target.trigger('change:content');
target.trigger && target.trigger('change:components');
}
try {
console.warn('[INLINE SYNC]', {
reason,
htmlLen: html.length,
modelType: target.get && target.get('type'),
modelId: target.getId ? target.getId() : target.get && target.get('id'),
});
} catch {}
} catch {}
};
const snapshotContent = (model) => { const snapshotContent = (model) => {
const rawContent = model && model.get ? model.get('content') : ''; const rawContent = model && model.get ? model.get('content') : '';
const el = model.view && model.view.el; const el = model.view && model.view.el;
@@ -909,14 +886,8 @@
} catch {} } catch {}
}; };
editor.on('component:update', (model) => restoreIfEmpty(model)); editor.on('component:update', (model) => restoreIfEmpty(model));
editor.on('component:input', (model) => { editor.on('component:input', (model) => restoreIfEmpty(model));
syncFromDom(model, 'component:input'); editor.on('component:deselected', (model) => restoreIfEmpty(model));
restoreIfEmpty(model);
});
editor.on('component:deselected', (model) => {
syncFromDom(model, 'component:deselected');
restoreIfEmpty(model);
});
editor.on('component:add', (model) => rememberIfPresent(model)); editor.on('component:add', (model) => rememberIfPresent(model));
editor.on('rte:disable', (model) => { editor.on('rte:disable', (model) => {
const target = model || (editor.getSelected && editor.getSelected()); const target = model || (editor.getSelected && editor.getSelected());