diff --git a/config/current.ver b/config/current.ver index bb3653f..457d1be 100644 --- a/config/current.ver +++ b/config/current.ver @@ -1 +1 @@ -1.2.43 \ No newline at end of file +1.2.44 \ 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 f6bb420..2a6d93b 100644 --- a/public/assets/js/bridge/blocks-api.js +++ b/public/assets/js/bridge/blocks-api.js @@ -466,13 +466,38 @@ // Sicherstellen, dass ggf. aktive Text-Edits vor dem Speichern synchronisiert werden try { + const wrapper = editor.getWrapper && editor.getWrapper(); + const resolveComponent = (el) => { + if (!el || !wrapper || !wrapper.find) return null; + const root = (el.closest && el.closest('[data-gjs-type="text"]')) || el; + const id = root && root.getAttribute ? root.getAttribute('id') : null; + if (!id) return null; + const found = wrapper.find(`#${id}`); + return found && found[0]; + }; + const syncElement = (el) => { + const comp = resolveComponent(el); + if (!comp || !comp.set) return; + const root = (el.closest && el.closest('[data-gjs-type="text"]')) || el; + const html = root && root.innerHTML ? root.innerHTML : ''; + const current = typeof comp.get === 'function' ? (comp.get('content') || '') : ''; + if (!html.trim() && current.trim()) return; + comp.set('content', html); + comp.trigger && comp.trigger('change:content'); + }; + + const doc = editor.Canvas && editor.Canvas.getDocument ? editor.Canvas.getDocument() : null; + const active = doc && doc.activeElement; + if (active && (active.isContentEditable || (active.getAttribute && active.getAttribute('contenteditable') === 'true'))) { + syncElement(active); + } + const selected = editor.getSelected && editor.getSelected(); const view = selected && selected.view; - if (view && view.el && view.el.isContentEditable) { - view.el.blur(); - } - if (selected && view && view.el && typeof selected.is === 'function' && selected.is('text')) { - selected.set('content', view.el.innerHTML); + if (view && view.el && (view.el.isContentEditable || (view.el.getAttribute && view.el.getAttribute('contenteditable') === 'true'))) { + syncElement(view.el); + } else if (selected && typeof selected.is === 'function' && (selected.is('text') || selected.is('textnode')) && view && view.el) { + syncElement(view.el); } } catch (e) { // kein Block, falls Sync nicht moeglich