ohne blur repair

This commit is contained in:
2026-02-05 00:26:05 +01:00
parent ca3f40dd88
commit f63fae7023
2 changed files with 15 additions and 11 deletions

View File

@@ -1 +1 @@
1.2.50 1.2.51

View File

@@ -509,15 +509,7 @@
return false; return false;
}; };
// 1) Wenn ein ContentEditable aktiv ist, Blur auslösen, damit GrapesJS den Model-Content übernimmt // 1) Selection im DOM suchen (bevorzugt)
if (active && (active.isContentEditable || (active.getAttribute && active.getAttribute('contenteditable') === 'true'))) {
try {
active.dispatchEvent(new Event('blur', { bubbles: true }));
syncReason = 'blur:dispatched';
} catch {}
}
// 2) Fallback: Selection im DOM suchen
if (!syncResult && doc && selectionEl && (selectionEl.isContentEditable || (selectionEl.getAttribute && selectionEl.getAttribute('contenteditable') === 'true'))) { if (!syncResult && doc && selectionEl && (selectionEl.isContentEditable || (selectionEl.getAttribute && selectionEl.getAttribute('contenteditable') === 'true'))) {
const root = (selectionEl.closest && selectionEl.closest('[data-gjs-type="text"]')) || selectionEl; const root = (selectionEl.closest && selectionEl.closest('[data-gjs-type="text"]')) || selectionEl;
const id = root && root.getAttribute ? root.getAttribute('id') : null; const id = root && root.getAttribute ? root.getAttribute('id') : null;
@@ -525,7 +517,19 @@
if (id && wrapper && wrapper.find) { if (id && wrapper && wrapper.find) {
const found = wrapper.find(`#${id}`); const found = wrapper.find(`#${id}`);
const comp = found && found[0]; const comp = found && found[0];
syncFromElement(comp, root, 'selection:root'); const type = comp && comp.get ? comp.get('type') : null;
if (!type || type === 'text' || type === 'textnode') {
syncFromElement(comp, root, 'selection:root');
}
}
}
// 2) Fallback: ausgewähltes Component-Element aus der View
if (!syncResult && selected) {
const selEl = (selected.getEl && selected.getEl()) || (selected.view && selected.view.el);
const type = selected.get ? selected.get('type') : null;
if (selEl && (!type || type === 'text' || type === 'textnode') &&
(selEl.isContentEditable || (selEl.getAttribute && selEl.getAttribute('contenteditable') === 'true'))) {
syncFromElement(selected, selEl, 'selected:view');
} }
} }