From ff722e4a9e8f2c858c3fb4ef0b8bb41125fd0c3c Mon Sep 17 00:00:00 2001 From: Lars Gebhardt-Kusche Date: Wed, 4 Feb 2026 03:10:36 +0100 Subject: [PATCH] asdasd --- config/current.ver | 2 +- public/assets/js/bridge/blocks-api.js | 128 ++++---------------------- 2 files changed, 18 insertions(+), 112 deletions(-) diff --git a/config/current.ver b/config/current.ver index c3df286..4d668e7 100644 --- a/config/current.ver +++ b/config/current.ver @@ -1 +1 @@ -1.2.47 \ No newline at end of file +1.2.48 \ 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 0a8900d..8523a37 100644 --- a/public/assets/js/bridge/blocks-api.js +++ b/public/assets/js/bridge/blocks-api.js @@ -480,128 +480,34 @@ return; } - // Sicherstellen, dass ggf. aktive Text-Edits vor dem Speichern synchronisiert werden - let syncInfo = { stage: 'pre', active: null, selected: null, selection: null, synced: [] }; + // Kein aktives Sync mehr vor dem Speichern, nur Logging 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, label = '') => { - 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') || '') : ''; - const beforeLen = String(current || '').length; - const htmlLen = String(html || '').length; - if (!html.trim() && current.trim()) return; - comp.set('content', html); - comp.trigger && comp.trigger('change:content'); - 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 syncAllTextComponents = () => { - if (!doc || !wrapper || !wrapper.find) return 0; - const nodes = Array.from(doc.querySelectorAll('[data-gjs-type="text"]')); - let count = 0; - nodes.forEach((el) => { - const id = el.getAttribute && el.getAttribute('id'); - if (!id) return; - const found = wrapper.find(`#${id}`); - const comp = found && found[0]; - if (!comp || !comp.set) return; - const html = el.innerHTML || ''; - const before = typeof comp.get === 'function' ? (comp.get('content') || '') : ''; - if (!html.trim() && String(before || '').trim()) return; - comp.set('content', html); - comp.trigger && comp.trigger('change:content'); - if (editor && typeof editor.trigger === 'function') { - editor.trigger('component:update', comp); - } - count++; - }); - return count; - }; const active = doc && doc.activeElement; - if (active) { - syncInfo.active = { + 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(); + writeDebugLog({ + event: 'save:sync:skipped', + entityId: CURRENT_ENTITY_ID, + sectionId: SECTION_ID || null, + active: active ? { tag: active.tagName, isEditable: !!(active.isContentEditable || (active.getAttribute && active.getAttribute('contenteditable') === 'true')), - htmlLen: (active.innerHTML || '').length, - htmlPreview: (active.innerHTML || '').slice(0, 200), - }; - } - if (active && (active.isContentEditable || (active.getAttribute && active.getAttribute('contenteditable') === 'true'))) { - 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 view = selected && selected.view; - if (selected) { - syncInfo.selected = { + } : null, + selection: selectionEl ? { + tag: selectionEl.tagName, + isEditable: !!(selectionEl.isContentEditable || (selectionEl.getAttribute && selectionEl.getAttribute('contenteditable') === 'true')), + } : null, + selected: selected ? { id: selected.getId ? selected.getId() : (selected.get && selected.get('id')), type: selected.get ? selected.get('type') : null, contentLen: selected.get ? String(selected.get('content') || '').length : 0, - }; - } - if (view && view.el && (view.el.isContentEditable || (view.el.getAttribute && view.el.getAttribute('contenteditable') === 'true'))) { - syncElement(view.el, 'selectedView'); - } else if (selected && typeof selected.is === 'function' && (selected.is('text') || selected.is('textnode')) && view && view.el) { - syncElement(view.el, 'selectedFallback'); - } - const syncedAll = syncAllTextComponents(); - syncInfo.stage = 'post'; - writeDebugLog({ - event: 'save:sync', - entityId: CURRENT_ENTITY_ID, - sectionId: SECTION_ID || null, - syncInfo, - syncedAllCount: syncedAll, + } : null, 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, }); - } catch (e) { - writeDebugLog({ - event: 'save:sync:error', - entityId: CURRENT_ENTITY_ID, - error: String(e && e.message ? e.message : e), - }); - // kein Block, falls Sync nicht moeglich - } + } catch {} // 1. Daten extrahieren const fontCss = (B && typeof B.RTE_FONT_FACE_CSS === 'string' && B.RTE_FONT_FACE_CSS.trim())