asdasd
This commit is contained in:
@@ -372,28 +372,37 @@
|
||||
el.__bridgeLastNormalized = snap.normalized;
|
||||
}
|
||||
};
|
||||
const syncTextFromView = (model) => {
|
||||
const target = resolveTextModel(model);
|
||||
if (!isTextLike(target) || !target.view || !target.view.el) return;
|
||||
const html = String(target.view.el.innerHTML || '').trim();
|
||||
if (!html) return;
|
||||
const current = target.get ? String(target.get('content') || '').trim() : '';
|
||||
if (current === html) return;
|
||||
try {
|
||||
syncing.add(target);
|
||||
if (target.components) {
|
||||
const comps = target.components();
|
||||
if (comps && comps.length) comps.reset();
|
||||
}
|
||||
if (target.set) target.set('content', html);
|
||||
target.trigger && target.trigger('change:content');
|
||||
} catch {} finally {
|
||||
syncing.delete(target);
|
||||
}
|
||||
};
|
||||
const rememberIfPresent = (model) => {
|
||||
const target = resolveTextModel(model);
|
||||
if (!isTextLike(target)) return;
|
||||
const snap = snapshotContent(target);
|
||||
if (!snap.normalized) return;
|
||||
if (!syncing.has(target)) {
|
||||
const currentContent = target.get ? String(target.get('content') || '').trim() : '';
|
||||
if (currentContent !== snap.html) {
|
||||
try {
|
||||
syncing.add(target);
|
||||
if (target.set) target.set('content', snap.html);
|
||||
if (target.components) target.components(snap.html);
|
||||
} catch {} finally {
|
||||
syncing.delete(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!syncing.has(target)) syncTextFromView(target);
|
||||
storeSnapshot(target, snap);
|
||||
};
|
||||
const restoreIfEmpty = (model) => {
|
||||
const target = resolveTextModel(model);
|
||||
if (!isTextLike(target) || !target.get) return;
|
||||
if (!syncing.has(target)) syncTextFromView(target);
|
||||
const current = snapshotContent(target);
|
||||
if (current.normalized) {
|
||||
rememberIfPresent(target);
|
||||
|
||||
Reference in New Issue
Block a user