blur
This commit is contained in:
@@ -1 +1 @@
|
|||||||
1.2.45
|
1.2.46
|
||||||
@@ -481,7 +481,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sicherstellen, dass ggf. aktive Text-Edits vor dem Speichern synchronisiert werden
|
// Sicherstellen, dass ggf. aktive Text-Edits vor dem Speichern synchronisiert werden
|
||||||
let syncInfo = { stage: 'pre', active: null, selected: null, contentSynced: false };
|
let syncInfo = { stage: 'pre', active: null, selected: null, selection: null, synced: [] };
|
||||||
try {
|
try {
|
||||||
const wrapper = editor.getWrapper && editor.getWrapper();
|
const wrapper = editor.getWrapper && editor.getWrapper();
|
||||||
const resolveComponent = (el) => {
|
const resolveComponent = (el) => {
|
||||||
@@ -492,16 +492,29 @@
|
|||||||
const found = wrapper.find(`#${id}`);
|
const found = wrapper.find(`#${id}`);
|
||||||
return found && found[0];
|
return found && found[0];
|
||||||
};
|
};
|
||||||
const syncElement = (el) => {
|
const syncElement = (el, label = '') => {
|
||||||
const comp = resolveComponent(el);
|
const comp = resolveComponent(el);
|
||||||
if (!comp || !comp.set) return;
|
if (!comp || !comp.set) return;
|
||||||
const root = (el.closest && el.closest('[data-gjs-type="text"]')) || el;
|
const root = (el.closest && el.closest('[data-gjs-type="text"]')) || el;
|
||||||
const html = root && root.innerHTML ? root.innerHTML : '';
|
const html = root && root.innerHTML ? root.innerHTML : '';
|
||||||
const current = typeof comp.get === 'function' ? (comp.get('content') || '') : '';
|
const current = typeof comp.get === 'function' ? (comp.get('content') || '') : '';
|
||||||
|
const beforeLen = String(current || '').length;
|
||||||
|
const htmlLen = String(html || '').length;
|
||||||
if (!html.trim() && current.trim()) return;
|
if (!html.trim() && current.trim()) return;
|
||||||
comp.set('content', html);
|
comp.set('content', html);
|
||||||
comp.trigger && comp.trigger('change:content');
|
comp.trigger && comp.trigger('change:content');
|
||||||
syncInfo.contentSynced = true;
|
if (editor && typeof editor.trigger === 'function') {
|
||||||
|
editor.trigger('component:update', comp);
|
||||||
|
}
|
||||||
|
const after = typeof comp.get === 'function' ? (comp.get('content') || '') : '';
|
||||||
|
syncInfo.synced.push({
|
||||||
|
label,
|
||||||
|
compId: comp.getId ? comp.getId() : (comp.get && comp.get('id')),
|
||||||
|
htmlLen,
|
||||||
|
htmlPreview: String(html || '').slice(0, 200),
|
||||||
|
modelBeforeLen: beforeLen,
|
||||||
|
modelAfterLen: String(after || '').length,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const doc = editor.Canvas && editor.Canvas.getDocument ? editor.Canvas.getDocument() : null;
|
const doc = editor.Canvas && editor.Canvas.getDocument ? editor.Canvas.getDocument() : null;
|
||||||
@@ -515,7 +528,22 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (active && (active.isContentEditable || (active.getAttribute && active.getAttribute('contenteditable') === 'true'))) {
|
if (active && (active.isContentEditable || (active.getAttribute && active.getAttribute('contenteditable') === 'true'))) {
|
||||||
syncElement(active);
|
syncElement(active, 'activeElement');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doc && doc.getSelection) {
|
||||||
|
const sel = doc.getSelection();
|
||||||
|
const node = sel && (sel.focusNode || sel.anchorNode);
|
||||||
|
const el = node ? (node.nodeType === 1 ? node : node.parentElement) : null;
|
||||||
|
if (el) {
|
||||||
|
syncInfo.selection = {
|
||||||
|
tag: el.tagName,
|
||||||
|
isEditable: !!(el.isContentEditable || (el.getAttribute && el.getAttribute('contenteditable') === 'true')),
|
||||||
|
htmlLen: (el.innerHTML || '').length,
|
||||||
|
htmlPreview: (el.innerHTML || '').slice(0, 200),
|
||||||
|
};
|
||||||
|
syncElement(el, 'selection');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const selected = editor.getSelected && editor.getSelected();
|
const selected = editor.getSelected && editor.getSelected();
|
||||||
@@ -528,9 +556,9 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (view && view.el && (view.el.isContentEditable || (view.el.getAttribute && view.el.getAttribute('contenteditable') === 'true'))) {
|
if (view && view.el && (view.el.isContentEditable || (view.el.getAttribute && view.el.getAttribute('contenteditable') === 'true'))) {
|
||||||
syncElement(view.el);
|
syncElement(view.el, 'selectedView');
|
||||||
} else if (selected && typeof selected.is === 'function' && (selected.is('text') || selected.is('textnode')) && view && view.el) {
|
} else if (selected && typeof selected.is === 'function' && (selected.is('text') || selected.is('textnode')) && view && view.el) {
|
||||||
syncElement(view.el);
|
syncElement(view.el, 'selectedFallback');
|
||||||
}
|
}
|
||||||
syncInfo.stage = 'post';
|
syncInfo.stage = 'post';
|
||||||
writeDebugLog({
|
writeDebugLog({
|
||||||
@@ -539,6 +567,7 @@
|
|||||||
sectionId: SECTION_ID || null,
|
sectionId: SECTION_ID || null,
|
||||||
syncInfo,
|
syncInfo,
|
||||||
editorHtmlLen: (editor.getHtml && String(editor.getHtml() || '').length) || 0,
|
editorHtmlLen: (editor.getHtml && String(editor.getHtml() || '').length) || 0,
|
||||||
|
editorHtmlPreview: (editor.getHtml && String(editor.getHtml() || '').slice(0, 300)) || '',
|
||||||
editorCssLen: (editor.getCss && String(editor.getCss() || '').length) || 0,
|
editorCssLen: (editor.getCss && String(editor.getCss() || '').length) || 0,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user