asddd
This commit is contained in:
@@ -1 +1 @@
|
|||||||
1.1.48
|
1.1.49
|
||||||
@@ -368,6 +368,33 @@
|
|||||||
.replace(/\scontenteditable="[^"]*"/gi, '')
|
.replace(/\scontenteditable="[^"]*"/gi, '')
|
||||||
.trim();
|
.trim();
|
||||||
};
|
};
|
||||||
|
const getModelHtml = (model) => {
|
||||||
|
if (!model) return '';
|
||||||
|
let html = '';
|
||||||
|
try {
|
||||||
|
html = String(model.get ? model.get('content') || '' : '').trim();
|
||||||
|
} catch {}
|
||||||
|
if (!html && model.components) {
|
||||||
|
try {
|
||||||
|
const comps = model.components();
|
||||||
|
if (comps && typeof comps.toHTML === 'function') {
|
||||||
|
html = String(comps.toHTML() || '').trim();
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
if (!html && typeof model.toHTML === 'function') {
|
||||||
|
try {
|
||||||
|
const full = String(model.toHTML() || '').trim();
|
||||||
|
if (full) {
|
||||||
|
const wrapper = document.createElement('div');
|
||||||
|
wrapper.innerHTML = full;
|
||||||
|
const first = wrapper.firstElementChild;
|
||||||
|
html = first ? String(first.innerHTML || '').trim() : String(wrapper.innerHTML || '').trim();
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
return html;
|
||||||
|
};
|
||||||
const storeSnapshot = (model, snap) => {
|
const storeSnapshot = (model, snap) => {
|
||||||
if (!model || !snap) return;
|
if (!model || !snap) return;
|
||||||
const key = model.cid || model;
|
const key = model.cid || model;
|
||||||
@@ -413,7 +440,7 @@
|
|||||||
if (!isTextLike(target) || !target.view || !target.view.el) return;
|
if (!isTextLike(target) || !target.view || !target.view.el) return;
|
||||||
const el = target.view.el;
|
const el = target.view.el;
|
||||||
if (el.isContentEditable || el.getAttribute('contenteditable') === 'true') return;
|
if (el.isContentEditable || el.getAttribute('contenteditable') === 'true') return;
|
||||||
const modelHtml = String(target.get ? target.get('content') || '' : '').trim();
|
const modelHtml = String(getModelHtml(target) || '').trim();
|
||||||
if (!modelHtml) return;
|
if (!modelHtml) return;
|
||||||
const viewHtml = String(el.innerHTML || '').trim();
|
const viewHtml = String(el.innerHTML || '').trim();
|
||||||
if (viewHtml) return;
|
if (viewHtml) return;
|
||||||
@@ -433,17 +460,12 @@
|
|||||||
if (window.__bridgeRteOpen) return;
|
if (window.__bridgeRteOpen) return;
|
||||||
const viewHtml = normalizeViewHtmlForModel(target.view.el.innerHTML || '');
|
const viewHtml = normalizeViewHtmlForModel(target.view.el.innerHTML || '');
|
||||||
if (!viewHtml) return;
|
if (!viewHtml) return;
|
||||||
const modelHtml = normalizeViewHtmlForModel(target.get ? target.get('content') || '' : '');
|
const modelHtml = normalizeViewHtmlForModel(getModelHtml(target));
|
||||||
if (viewHtml === modelHtml) return;
|
if (viewHtml === modelHtml) return;
|
||||||
try {
|
try {
|
||||||
syncing.add(target);
|
syncing.add(target);
|
||||||
if (target.components) {
|
if (target.components) {
|
||||||
try {
|
try { target.components(viewHtml); } catch {}
|
||||||
const comps = target.components();
|
|
||||||
if (!comps || !comps.length) {
|
|
||||||
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');
|
||||||
@@ -471,18 +493,14 @@
|
|||||||
if (window.__bridgeRteOpen) return;
|
if (window.__bridgeRteOpen) return;
|
||||||
const viewHtml = normalizeViewHtmlForModel(target.view.el.innerHTML || '');
|
const viewHtml = normalizeViewHtmlForModel(target.view.el.innerHTML || '');
|
||||||
if (!viewHtml) return;
|
if (!viewHtml) return;
|
||||||
const modelHtml = normalizeViewHtmlForModel(target.get ? target.get('content') || '' : '');
|
const modelHtml = normalizeViewHtmlForModel(getModelHtml(target));
|
||||||
const comps = target.components ? target.components() : null;
|
const comps = target.components ? target.components() : null;
|
||||||
const hasComps = !!(comps && comps.length);
|
const hasComps = !!(comps && comps.length);
|
||||||
if (viewHtml === modelHtml && hasComps) return;
|
if (viewHtml === modelHtml && hasComps) return;
|
||||||
try {
|
try {
|
||||||
syncing.add(target);
|
syncing.add(target);
|
||||||
if (target.components) {
|
if (target.components) {
|
||||||
try {
|
try { target.components(viewHtml); } catch {}
|
||||||
if (!hasComps) {
|
|
||||||
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');
|
||||||
@@ -516,12 +534,39 @@
|
|||||||
|
|
||||||
const setupBlurLogger = (editor) => {
|
const setupBlurLogger = (editor) => {
|
||||||
if (!editor || !editor.Canvas || !editor.Canvas.getBody) return;
|
if (!editor || !editor.Canvas || !editor.Canvas.getBody) return;
|
||||||
|
const getModelHtmlForLog = (model) => {
|
||||||
|
if (!model) return '';
|
||||||
|
let html = '';
|
||||||
|
try {
|
||||||
|
html = String(model.get ? model.get('content') || '' : '').trim();
|
||||||
|
} catch {}
|
||||||
|
if (!html && model.components) {
|
||||||
|
try {
|
||||||
|
const comps = model.components();
|
||||||
|
if (comps && typeof comps.toHTML === 'function') {
|
||||||
|
html = String(comps.toHTML() || '').trim();
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
if (!html && typeof model.toHTML === 'function') {
|
||||||
|
try {
|
||||||
|
const full = String(model.toHTML() || '').trim();
|
||||||
|
if (full) {
|
||||||
|
const wrapper = document.createElement('div');
|
||||||
|
wrapper.innerHTML = full;
|
||||||
|
const first = wrapper.firstElementChild;
|
||||||
|
html = first ? String(first.innerHTML || '').trim() : String(wrapper.innerHTML || '').trim();
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
return html;
|
||||||
|
};
|
||||||
const logComponentInput = (model, label) => {
|
const logComponentInput = (model, label) => {
|
||||||
try {
|
try {
|
||||||
const modelType = model && model.get ? model.get('type') : undefined;
|
const modelType = model && model.get ? model.get('type') : undefined;
|
||||||
const selectedEl = model && model.view && model.view.el;
|
const selectedEl = model && model.view && model.view.el;
|
||||||
const viewOuter = selectedEl ? String(selectedEl.outerHTML || '') : '';
|
const viewOuter = selectedEl ? String(selectedEl.outerHTML || '') : '';
|
||||||
const modelContent = model && model.get ? String(model.get('content') || '') : '';
|
const modelContent = String(getModelHtmlForLog(model) || '');
|
||||||
const editorHtml = editor && typeof editor.getHtml === 'function' ? String(editor.getHtml() || '') : '';
|
const editorHtml = editor && typeof editor.getHtml === 'function' ? String(editor.getHtml() || '') : '';
|
||||||
console.warn(`[UI EDIT ${label}]`, {
|
console.warn(`[UI EDIT ${label}]`, {
|
||||||
modelType,
|
modelType,
|
||||||
@@ -575,7 +620,7 @@
|
|||||||
const buildSnapshot = (target, selected, selectedEl, editorHtml) => {
|
const buildSnapshot = (target, selected, selectedEl, editorHtml) => {
|
||||||
let modelContent = '';
|
let modelContent = '';
|
||||||
try {
|
try {
|
||||||
modelContent = selected && selected.get ? String(selected.get('content') || '') : '';
|
modelContent = String(getModelHtmlForLog(selected) || '');
|
||||||
} catch {}
|
} catch {}
|
||||||
let viewOuter = '';
|
let viewOuter = '';
|
||||||
try {
|
try {
|
||||||
@@ -616,17 +661,12 @@
|
|||||||
if (!viewEl) return;
|
if (!viewEl) return;
|
||||||
const viewHtml = normalizeViewHtml(viewEl.innerHTML || '');
|
const viewHtml = normalizeViewHtml(viewEl.innerHTML || '');
|
||||||
if (!viewHtml) return;
|
if (!viewHtml) return;
|
||||||
const modelHtml = normalizeViewHtml(component.get ? component.get('content') || '' : '');
|
const modelHtml = normalizeViewHtml(getModelHtml(component));
|
||||||
if (viewHtml === modelHtml) return;
|
if (viewHtml === modelHtml) return;
|
||||||
try {
|
try {
|
||||||
syncing.add(component);
|
syncing.add(component);
|
||||||
if (component.components) {
|
if (component.components) {
|
||||||
try {
|
try { component.components(viewHtml); } catch {}
|
||||||
const comps = component.components();
|
|
||||||
if (!comps || !comps.length) {
|
|
||||||
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');
|
||||||
@@ -693,12 +733,7 @@
|
|||||||
if (!viewHtml) return;
|
if (!viewHtml) return;
|
||||||
syncing.add(selected);
|
syncing.add(selected);
|
||||||
if (selected.components) {
|
if (selected.components) {
|
||||||
try {
|
try { selected.components(viewHtml); } catch {}
|
||||||
const comps = selected.components();
|
|
||||||
if (!comps || !comps.length) {
|
|
||||||
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');
|
||||||
|
|||||||
Reference in New Issue
Block a user