This commit is contained in:
2026-01-27 01:36:23 +01:00
parent b66d0c5d49
commit cf476632e2
3 changed files with 25 additions and 15 deletions

View File

@@ -1 +1 @@
1.1.14 1.1.15

View File

@@ -173,12 +173,13 @@
const isText = (component.is && component.is('text')) const isText = (component.is && component.is('text'))
|| (component.get && component.get('type') === 'text'); || (component.get && component.get('type') === 'text');
try { try {
if (component.set) component.set('content', content);
if (isText && component.components) { if (isText && component.components) {
try { try {
component.components(content); const comps = component.components();
if (comps && comps.length) comps.reset();
} catch {} } catch {}
} }
if (component.set) component.set('content', content);
} catch {} } catch {}
if (isText && component.view && component.view.el) { if (isText && component.view && component.view.el) {
try { try {

View File

@@ -372,28 +372,37 @@
el.__bridgeLastNormalized = snap.normalized; 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 rememberIfPresent = (model) => {
const target = resolveTextModel(model); const target = resolveTextModel(model);
if (!isTextLike(target)) return; if (!isTextLike(target)) return;
const snap = snapshotContent(target); const snap = snapshotContent(target);
if (!snap.normalized) return; if (!snap.normalized) return;
if (!syncing.has(target)) { if (!syncing.has(target)) syncTextFromView(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);
}
}
}
storeSnapshot(target, snap); storeSnapshot(target, snap);
}; };
const restoreIfEmpty = (model) => { const restoreIfEmpty = (model) => {
const target = resolveTextModel(model); const target = resolveTextModel(model);
if (!isTextLike(target) || !target.get) return; if (!isTextLike(target) || !target.get) return;
if (!syncing.has(target)) syncTextFromView(target);
const current = snapshotContent(target); const current = snapshotContent(target);
if (current.normalized) { if (current.normalized) {
rememberIfPresent(target); rememberIfPresent(target);