This commit is contained in:
2026-01-28 02:24:28 +01:00
parent 664ffbca35
commit 6b794a5d18
3 changed files with 14 additions and 21 deletions

View File

@@ -1 +1 @@
1.1.46 1.1.47

View File

@@ -11,6 +11,8 @@
this.allowClose = false; this.allowClose = false;
this.lastContent = new WeakMap(); this.lastContent = new WeakMap();
this.restoring = new WeakSet(); this.restoring = new WeakSet();
this.restoreUntil = new WeakMap();
this.restoreWindowMs = 3000;
} }
static serializeHtml(editor) { static serializeHtml(editor) {
@@ -175,7 +177,10 @@
try { try {
if (isText && component.components) { if (isText && component.components) {
try { try {
component.components(content); const comps = component.components();
if (comps && comps.length) {
component.components([]);
}
} catch {} } catch {}
} }
if (component.set) component.set('content', content); if (component.set) component.set('content', content);
@@ -759,6 +764,9 @@
const rawHtml = content.innerHTML || ''; const rawHtml = content.innerHTML || '';
const html = this.sanitizeInlineHtml(rawHtml, content.textContent || ''); const html = this.sanitizeInlineHtml(rawHtml, content.textContent || '');
this.lastContent.set(component, html); this.lastContent.set(component, html);
try {
this.restoreUntil.set(component, Date.now() + this.restoreWindowMs);
} catch {}
this.logConsoleSnapshot(editor, component, 'before-save'); this.logConsoleSnapshot(editor, component, 'before-save');
const forceApply = () => { const forceApply = () => {
if (Object.keys(pendingComponentStyle).length) { if (Object.keys(pendingComponentStyle).length) {
@@ -888,6 +896,8 @@
const restoreIfCollapsed = (model) => { const restoreIfCollapsed = (model) => {
if (!model || this.restoring.has(model)) return; if (!model || this.restoring.has(model)) return;
const restoreDeadline = this.restoreUntil.get(model);
if (!restoreDeadline || Date.now() > restoreDeadline) return;
const last = this.lastContent.get(model); const last = this.lastContent.get(model);
if (!last || !model.get) return; if (!last || !model.get) return;
const viewEl = model.view && model.view.el; const viewEl = model.view && model.view.el;

View File

@@ -437,11 +437,6 @@
if (viewHtml === modelHtml) return; if (viewHtml === modelHtml) return;
try { try {
syncing.add(target); syncing.add(target);
if (target.components) {
try {
target.components(viewHtml);
} catch {}
}
if (target.set) target.set('content', viewHtml); if (target.set) target.set('content', viewHtml);
target.trigger && target.trigger('change:content'); target.trigger && target.trigger('change:content');
if (target.view && typeof target.view.render === 'function') { if (target.view && typeof target.view.render === 'function') {
@@ -474,11 +469,6 @@
if (viewHtml === modelHtml && hasComps) return; if (viewHtml === modelHtml && hasComps) return;
try { try {
syncing.add(target); syncing.add(target);
if (target.components) {
try {
target.components(viewHtml);
} catch {}
}
if (target.set) target.set('content', viewHtml); if (target.set) target.set('content', viewHtml);
target.trigger && target.trigger('change:content'); target.trigger && target.trigger('change:content');
if (target.view && typeof target.view.render === 'function') { if (target.view && typeof target.view.render === 'function') {
@@ -615,9 +605,6 @@
if (viewHtml === modelHtml) return; if (viewHtml === modelHtml) return;
try { try {
syncing.add(component); syncing.add(component);
if (component.components) {
try { component.components(viewHtml); } catch {}
}
if (component.set) component.set('content', viewHtml); if (component.set) component.set('content', viewHtml);
component.trigger && component.trigger('change:content'); component.trigger && component.trigger('change:content');
if (component.view && typeof component.view.render === 'function') { if (component.view && typeof component.view.render === 'function') {
@@ -674,18 +661,14 @@
if (window.__bridgeRteOpen) return; if (window.__bridgeRteOpen) return;
const isEditable = !!(target.isContentEditable || (target.getAttribute && target.getAttribute('contenteditable') === 'true')); const isEditable = !!(target.isContentEditable || (target.getAttribute && target.getAttribute('contenteditable') === 'true'));
if (!isEditable) return; if (!isEditable) return;
const selected = editor.getSelected && editor.getSelected(); const selected = resolveComponentFromTarget(target) || (editor.getSelected && editor.getSelected());
const selectedEl = selected && selected.view && selected.view.el; const selectedEl = selected && selected.view && selected.view.el;
if (!selected || !selectedEl) return; if (!selected || !selectedEl) return;
if (!(selectedEl === target || selectedEl.contains(target))) return;
if (syncing.has(selected)) return; if (syncing.has(selected)) return;
try { try {
const viewHtml = normalizeViewHtml(target.innerHTML || ''); const viewHtml = normalizeViewHtml(selectedEl.innerHTML || '');
if (!viewHtml) return; if (!viewHtml) return;
syncing.add(selected); syncing.add(selected);
if (selected.components) {
try { selected.components(viewHtml); } catch {}
}
if (selected.set) selected.set('content', viewHtml); if (selected.set) selected.set('content', viewHtml);
selected.trigger && selected.trigger('change:content'); selected.trigger && selected.trigger('change:content');
if (selected.view && typeof selected.view.render === 'function') { if (selected.view && typeof selected.view.render === 'function') {