From 0143adbc962b3672bebb8190fa64e5d5a11fbf9b Mon Sep 17 00:00:00 2001 From: Lars Gebhardt-Kusche Date: Thu, 15 Jan 2026 03:20:49 +0100 Subject: [PATCH] adsads --- public/editor/bridge-core.js | 41 +++++++++++++++++++++++++++++++++++ public/editor/editor-core.php | 1 - 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/public/editor/bridge-core.js b/public/editor/bridge-core.js index e07577c..ce31d61 100644 --- a/public/editor/bridge-core.js +++ b/public/editor/bridge-core.js @@ -721,6 +721,46 @@ }); }; + const setupPlainTextPreserver = (editor) => { + const isTextLike = (model) => !!(model && model.is && (model.is('text') || model.is('button') || model.is('link'))); + const lastContent = new Map(); + const snapshotContent = (model) => { + const el = model.view && model.view.el; + const html = String(model.get ? (model.get('content') || '') : '').trim(); + const inner = el && el.innerHTML ? String(el.innerHTML).trim() : ''; + const text = el && el.textContent ? String(el.textContent).trim() : ''; + const composite = html || inner || text; + return { + html: composite, + text, + }; + }; + const rememberIfPresent = (model) => { + if (!isTextLike(model)) return; + const snap = snapshotContent(model); + if (!snap.html) return; + lastContent.set(model.cid || model, snap); + }; + const restoreIfEmpty = (model) => { + if (!isTextLike(model) || !model.get) return; + const current = snapshotContent(model); + if (current.html) { + rememberIfPresent(model); + return; + } + const stored = lastContent.get(model.cid || model); + if (!stored || !stored.html) return; + if (model.components && model.components().length) return; + try { + model.set('content', stored.html); + model.trigger && model.trigger('change:content'); + } catch {} + }; + editor.on('component:update', (model) => restoreIfEmpty(model)); + editor.on('component:input', (model) => restoreIfEmpty(model)); + editor.on('component:add', (model) => rememberIfPresent(model)); + }; + const setupTableBuilder = (editor) => { const domc = editor.DomComponents; if (!domc) return; @@ -1024,6 +1064,7 @@ setupRichTextEditor(ed); setupTableBuilder(ed); + setupPlainTextPreserver(ed); loadDynamicFonts(); // Entfernt: jegliche Blur/RTE-Handler, die Inhalte verändern. diff --git a/public/editor/editor-core.php b/public/editor/editor-core.php index 2b6d992..63d0246 100644 --- a/public/editor/editor-core.php +++ b/public/editor/editor-core.php @@ -53,7 +53,6 @@ if ($fontSources) { window.BridgeParts.API_KERNEL_URL = window.BridgeParts.API_KERNEL_URL || '/api.php'; window.BridgeParts.API_BASE = window.BridgeParts.API_BASE || window.BridgeParts.API_KERNEL_URL; window.BridgeParts.STORAGE_URL_BASE = window.BridgeParts.STORAGE_URL_BASE || window.BridgeParts.API_BASE; - window.BridgeParts.DISABLE_PLACEHOLDERS = true; window.BridgeParts.RTE_FONTS = window.BridgeParts.RTE_FONTS || [ { label: 'Kids Handwriting', value: "'Kids Handwriting', 'Comic Sans MS', cursive" }, { label: 'Arial', value: 'Arial, sans-serif' },