From f63fae70239ec7464957e76bb86a279f4d13ee26 Mon Sep 17 00:00:00 2001 From: Lars Gebhardt-Kusche Date: Thu, 5 Feb 2026 00:26:05 +0100 Subject: [PATCH] ohne blur repair --- config/current.ver | 2 +- public/assets/js/bridge/blocks-api.js | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/config/current.ver b/config/current.ver index f9b76f9..9030779 100644 --- a/config/current.ver +++ b/config/current.ver @@ -1 +1 @@ -1.2.50 \ No newline at end of file +1.2.51 \ No newline at end of file diff --git a/public/assets/js/bridge/blocks-api.js b/public/assets/js/bridge/blocks-api.js index a305238..eec5a09 100644 --- a/public/assets/js/bridge/blocks-api.js +++ b/public/assets/js/bridge/blocks-api.js @@ -509,15 +509,7 @@ return false; }; - // 1) Wenn ein ContentEditable aktiv ist, Blur auslösen, damit GrapesJS den Model-Content übernimmt - 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 + // 1) Selection im DOM suchen (bevorzugt) if (!syncResult && doc && selectionEl && (selectionEl.isContentEditable || (selectionEl.getAttribute && selectionEl.getAttribute('contenteditable') === 'true'))) { const root = (selectionEl.closest && selectionEl.closest('[data-gjs-type="text"]')) || selectionEl; const id = root && root.getAttribute ? root.getAttribute('id') : null; @@ -525,7 +517,19 @@ if (id && wrapper && wrapper.find) { const found = wrapper.find(`#${id}`); 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'); } }