gggg
This commit is contained in:
@@ -1 +1 @@
|
|||||||
1.1.45
|
1.1.46
|
||||||
@@ -590,11 +590,52 @@
|
|||||||
editorHtml: editorHtml.slice(0, 1000),
|
editorHtml: editorHtml.slice(0, 1000),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
const resolveComponentFromTarget = (target) => {
|
||||||
|
if (!target || !target.closest) return null;
|
||||||
|
const rootEl = target.closest('[data-gjs-type="text"]') || target;
|
||||||
|
const id = rootEl && rootEl.getAttribute ? rootEl.getAttribute('id') : null;
|
||||||
|
if (!id || !editor.getWrapper || !editor.getWrapper().find) return null;
|
||||||
|
const found = editor.getWrapper().find(`#${id}`);
|
||||||
|
return found && found[0];
|
||||||
|
};
|
||||||
|
const syncFromBlur = (evt) => {
|
||||||
|
const target = evt && evt.target;
|
||||||
|
if (!target || window.__bridgeRteOpen) return;
|
||||||
|
const isEditable = !!(target.isContentEditable || (target.getAttribute && target.getAttribute('contenteditable') === 'true'));
|
||||||
|
if (!isEditable) return;
|
||||||
|
const component = resolveComponentFromTarget(target) || (editor.getSelected && editor.getSelected());
|
||||||
|
if (!component || syncing.has(component)) return;
|
||||||
|
const type = component.get && component.get('type');
|
||||||
|
if (type && type !== 'text' && type !== 'textnode') return;
|
||||||
|
const viewEl = component.view && component.view.el;
|
||||||
|
if (!viewEl) return;
|
||||||
|
const viewHtml = normalizeViewHtml(viewEl.innerHTML || '');
|
||||||
|
if (!viewHtml) return;
|
||||||
|
const modelHtml = normalizeViewHtml(component.get ? component.get('content') || '' : '');
|
||||||
|
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') {
|
||||||
|
component.view.render();
|
||||||
|
}
|
||||||
|
if (editor && typeof editor.trigger === 'function') {
|
||||||
|
editor.trigger('component:update', component);
|
||||||
|
}
|
||||||
|
} catch {} finally {
|
||||||
|
syncing.delete(component);
|
||||||
|
}
|
||||||
|
};
|
||||||
const logBlur = (evt) => {
|
const logBlur = (evt) => {
|
||||||
const target = evt && evt.target;
|
const target = evt && evt.target;
|
||||||
if (!target) return;
|
if (!target) 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;
|
||||||
|
syncFromBlur(evt);
|
||||||
const selected = editor.getSelected && editor.getSelected();
|
const selected = editor.getSelected && editor.getSelected();
|
||||||
const selectedEl = selected && selected.view && selected.view.el;
|
const selectedEl = selected && selected.view && selected.view.el;
|
||||||
const inSelected = !!(selectedEl && (selectedEl === target || selectedEl.contains(target)));
|
const inSelected = !!(selectedEl && (selectedEl === target || selectedEl.contains(target)));
|
||||||
|
|||||||
Reference in New Issue
Block a user