adsad
This commit is contained in:
@@ -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));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user