From a7a936fac26fccf331783bbf79e02cced44a85d2 Mon Sep 17 00:00:00 2001 From: Lars Gebhardt-Kusche Date: Wed, 28 Jan 2026 00:19:31 +0100 Subject: [PATCH] asdasd --- config/current.ver | 2 +- public/editor/bridge-core.js | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/config/current.ver b/config/current.ver index 98924ab..474ad5b 100644 --- a/config/current.ver +++ b/config/current.ver @@ -1 +1 @@ -1.1.35 \ No newline at end of file +1.1.36 \ No newline at end of file diff --git a/public/editor/bridge-core.js b/public/editor/bridge-core.js index 503504b..30f48dc 100644 --- a/public/editor/bridge-core.js +++ b/public/editor/bridge-core.js @@ -360,6 +360,24 @@ normalized: normalizeHtml(composite), }; }; + const buildTextComponentsFromHtml = (html) => { + const wrapper = document.createElement('div'); + wrapper.innerHTML = String(html || ''); + const newComps = []; + wrapper.childNodes.forEach((node) => { + if (node.nodeType === 3) { + newComps.push({ type: 'textnode', content: node.textContent || '' }); + } else if (node.nodeType === 1) { + const tag = node.tagName ? node.tagName.toLowerCase() : ''; + if (tag === 'br') { + newComps.push({ tagName: 'br', void: true }); + } else { + newComps.push(node.outerHTML); + } + } + }); + return newComps.length ? newComps : html; + }; const storeSnapshot = (model, snap) => { if (!model || !snap) return; const key = model.cid || model; @@ -396,7 +414,7 @@ if (!stored || !stored.normalized) return; try { if (target.components) { - target.components(stored.html); + target.components(buildTextComponentsFromHtml(stored.html)); } target.set('content', stored.html); target.trigger && target.trigger('change:content'); @@ -429,7 +447,7 @@ if (viewHtml === modelHtml) return; try { syncing.add(target); - if (target.components) target.components(viewHtml); + if (target.components) target.components(buildTextComponentsFromHtml(viewHtml)); if (target.set) target.set('content', viewHtml); target.trigger && target.trigger('change:content'); const reapply = () => {