This commit is contained in:
2026-01-28 00:09:57 +01:00
parent 90084c1d5f
commit 0850c365f5
2 changed files with 23 additions and 2 deletions

View File

@@ -403,6 +403,23 @@
try { console.log('[PLAIN TEXT RESTORE] Inhalt wiederhergestellt.'); } catch {}
} catch {}
};
const ensureViewMatchesModel = (model) => {
const target = resolveTextModel(model);
if (!isTextLike(target) || !target.view || !target.view.el) return;
const el = target.view.el;
if (el.isContentEditable || el.getAttribute('contenteditable') === 'true') return;
const modelHtml = String(target.get ? target.get('content') || '' : '').trim();
if (!modelHtml) return;
const apply = () => {
try {
const current = String(el.innerHTML || '').trim();
if (current !== modelHtml) el.innerHTML = modelHtml;
} catch {}
};
apply();
setTimeout(apply, 0);
setTimeout(apply, 60);
};
const syncTextFromViewOnDeselect = (model) => {
const target = resolveTextModel(model);
if (!isTextLike(target) || !target.view || !target.view.el || syncing.has(target)) return;
@@ -427,11 +444,15 @@
syncing.delete(target);
}
};
editor.on('component:update', (model) => restoreIfEmpty(model));
editor.on('component:update', (model) => {
restoreIfEmpty(model);
ensureViewMatchesModel(model);
});
editor.on('component:input', (model) => restoreIfEmpty(model));
editor.on('component:deselected', (model) => {
syncTextFromViewOnDeselect(model);
restoreIfEmpty(model);
ensureViewMatchesModel(model);
});
editor.on('component:add', (model) => rememberIfPresent(model));
};