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

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