blur ohne

This commit is contained in:
2026-02-05 03:17:51 +01:00
parent abfb597931
commit 0918e03780
2 changed files with 3 additions and 102 deletions

View File

@@ -1 +1 @@
1.2.58
1.2.59

View File

@@ -480,91 +480,16 @@
return;
}
// Minimaler Sync vor dem Speichern + Logging (nur echte Text-Components)
// Kein aktiver Sync vor dem Speichern, nur Logging
try {
const doc = editor.Canvas && editor.Canvas.getDocument ? editor.Canvas.getDocument() : null;
const active = doc && doc.activeElement;
const selectionNode = doc && doc.getSelection ? (doc.getSelection().focusNode || doc.getSelection().anchorNode) : null;
const selectionEl = selectionNode ? (selectionNode.nodeType === 1 ? selectionNode : selectionNode.parentElement) : null;
const selected = editor.getSelected && editor.getSelected();
const win = doc && doc.defaultView;
const lastEl = win && win.__bridgeLastEditableEl;
const lastCompId = win && win.__bridgeLastEditableCompId;
let syncResult = null;
let syncReason = 'no-editable-selection';
const syncFromElement = (comp, el, reason) => {
if (!comp || !comp.set || !el) return false;
const type = comp.get ? comp.get('type') : null;
if (type && type !== 'text' && type !== 'textnode') return false;
const html = el.innerHTML || '';
const before = typeof comp.get === 'function' ? (comp.get('content') || '') : '';
if (html.trim() || !String(before || '').trim()) {
// Keep components tree in sync when possible (matches bridge-core behavior)
if (comp.components) {
try { comp.components(html); } catch {}
}
comp.set('content', html);
comp.trigger && comp.trigger('change:content');
syncResult = {
compId: comp.getId ? comp.getId() : (comp.get && comp.get('id')),
beforeLen: String(before || '').length,
afterLen: String(html || '').length,
reason,
};
syncReason = reason;
return true;
}
return false;
};
// 1) Selection im DOM (bevorzugt)
if (!syncResult && doc && selectionEl && (selectionEl.isContentEditable || (selectionEl.getAttribute && selectionEl.getAttribute('contenteditable') === 'true'))) {
const root = selectionEl.closest ? selectionEl.closest('[data-gjs-type="text"]') : null;
if (root) {
const id = root.getAttribute ? root.getAttribute('id') : null;
const wrapper = editor.getWrapper && editor.getWrapper();
if (id && wrapper && wrapper.find) {
const found = wrapper.find(`#${id}`);
const comp = found && found[0];
syncFromElement(comp, root, 'selection:root');
}
}
}
// 2) zuletzt fokussiertes Element
if (!syncResult && lastEl && (lastEl.isContentEditable || (lastEl.getAttribute && lastEl.getAttribute('contenteditable') === 'true'))) {
const root = lastEl.closest ? lastEl.closest('[data-gjs-type="text"]') : null;
if (root) {
const id = root.getAttribute ? root.getAttribute('id') : null;
const wrapper = editor.getWrapper && editor.getWrapper();
if (id && wrapper && wrapper.find) {
const found = wrapper.find(`#${id}`);
const comp = found && found[0];
syncFromElement(comp, root, 'last:element');
}
}
}
if (!syncResult && lastCompId) {
const wrapper = editor.getWrapper && editor.getWrapper();
if (wrapper && wrapper.find) {
const found = wrapper.find(`#${lastCompId}`);
const comp = found && found[0];
const el = comp && comp.view && comp.view.el;
if (el && (el.isContentEditable || (el.getAttribute && el.getAttribute('contenteditable') === 'true'))) {
syncFromElement(comp, el, 'last:compId');
}
}
}
// 3) Fallback: ausgewähltes Component-Element
if (!syncResult && selected) {
const selEl = (selected.getEl && selected.getEl()) || (selected.view && selected.view.el);
if (selEl && (selEl.isContentEditable || (selEl.getAttribute && selEl.getAttribute('contenteditable') === 'true'))) {
syncFromElement(selected, selEl, 'selected:view');
}
}
writeDebugLog({
event: 'save:sync:minimal',
event: 'save:sync:skipped',
entityId: CURRENT_ENTITY_ID,
sectionId: SECTION_ID || null,
active: active ? {
@@ -580,36 +505,12 @@
type: selected.get ? selected.get('type') : null,
contentLen: selected.get ? String(selected.get('content') || '').length : 0,
} : null,
syncResult,
syncReason,
editorHtmlLen: (editor.getHtml && String(editor.getHtml() || '').length) || 0,
editorHtmlPreview: (editor.getHtml && String(editor.getHtml() || '').slice(0, 300)) || '',
});
} catch {}
// 1. Daten extrahieren
// Force-Sync: alle Text-Components aus der View ins Model schreiben,
// damit Save ohne Blur nicht den letzten UI-Stand verliert.
try {
const wrapper = editor.getWrapper && editor.getWrapper();
if (wrapper && wrapper.find) {
const texts = wrapper.find('[data-gjs-type="text"]') || [];
texts.forEach((comp) => {
if (!comp || !comp.set) return;
const type = comp.get ? comp.get('type') : null;
if (type && type !== 'text' && type !== 'textnode') return;
const el = comp.view && comp.view.el;
if (!el) return;
const html = el.innerHTML || '';
const before = typeof comp.get === 'function' ? (comp.get('content') || '') : '';
if (html !== before) {
comp.set('content', html);
comp.trigger && comp.trigger('change:content');
}
});
}
} catch {}
const fontCss = (B && typeof B.RTE_FONT_FACE_CSS === 'string' && B.RTE_FONT_FACE_CSS.trim())
? B.RTE_FONT_FACE_CSS.trim()
: '';