This commit is contained in:
2026-01-27 02:03:42 +01:00
parent 5c04fe2c4c
commit 6187bfcded
2 changed files with 1 additions and 33 deletions

View File

@@ -372,37 +372,16 @@
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)) 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);
@@ -436,18 +415,7 @@
if (!editor || !editor.Canvas || !editor.Canvas.getBody) return;
const logComponentInput = (model, label) => {
try {
// Force-sync direct edits from view -> model before logging.
const viewEl = model && model.view && model.view.el ? model.view.el : null;
const modelType = model && model.get ? model.get('type') : undefined;
if (modelType === 'text' && model && model.get && viewEl && !model.__bridgeUiSyncing && label !== 'INPUT') {
const viewHtml = String(viewEl.innerHTML || '').trim();
const modelHtml = String(model.get('content') || '').trim();
if (viewHtml && viewHtml !== modelHtml) {
model.__bridgeUiSyncing = true;
try { model.set('content', viewHtml); } catch {}
model.__bridgeUiSyncing = false;
}
}
const selectedEl = model && model.view && model.view.el;
const viewOuter = selectedEl ? String(selectedEl.outerHTML || '') : '';
const modelContent = model && model.get ? String(model.get('content') || '') : '';