cyxcyx
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -437,11 +437,6 @@
|
||||
if (viewHtml === modelHtml) return;
|
||||
try {
|
||||
syncing.add(target);
|
||||
if (target.components) {
|
||||
try {
|
||||
target.components(viewHtml);
|
||||
} catch {}
|
||||
}
|
||||
if (target.set) target.set('content', viewHtml);
|
||||
target.trigger && target.trigger('change:content');
|
||||
if (target.view && typeof target.view.render === 'function') {
|
||||
@@ -474,11 +469,6 @@
|
||||
if (viewHtml === modelHtml && hasComps) return;
|
||||
try {
|
||||
syncing.add(target);
|
||||
if (target.components) {
|
||||
try {
|
||||
target.components(viewHtml);
|
||||
} catch {}
|
||||
}
|
||||
if (target.set) target.set('content', viewHtml);
|
||||
target.trigger && target.trigger('change:content');
|
||||
if (target.view && typeof target.view.render === 'function') {
|
||||
@@ -615,9 +605,6 @@
|
||||
if (viewHtml === modelHtml) return;
|
||||
try {
|
||||
syncing.add(component);
|
||||
if (component.components) {
|
||||
try { component.components(viewHtml); } catch {}
|
||||
}
|
||||
if (component.set) component.set('content', viewHtml);
|
||||
component.trigger && component.trigger('change:content');
|
||||
if (component.view && typeof component.view.render === 'function') {
|
||||
@@ -674,18 +661,14 @@
|
||||
if (window.__bridgeRteOpen) return;
|
||||
const isEditable = !!(target.isContentEditable || (target.getAttribute && target.getAttribute('contenteditable') === 'true'));
|
||||
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;
|
||||
if (!selected || !selectedEl) return;
|
||||
if (!(selectedEl === target || selectedEl.contains(target))) return;
|
||||
if (syncing.has(selected)) return;
|
||||
try {
|
||||
const viewHtml = normalizeViewHtml(target.innerHTML || '');
|
||||
const viewHtml = normalizeViewHtml(selectedEl.innerHTML || '');
|
||||
if (!viewHtml) return;
|
||||
syncing.add(selected);
|
||||
if (selected.components) {
|
||||
try { selected.components(viewHtml); } catch {}
|
||||
}
|
||||
if (selected.set) selected.set('content', viewHtml);
|
||||
selected.trigger && selected.trigger('change:content');
|
||||
if (selected.view && typeof selected.view.render === 'function') {
|
||||
|
||||
Reference in New Issue
Block a user