From 6c09e30e7a49515d1ee8bca7caa5f64a1f865600 Mon Sep 17 00:00:00 2001 From: Lars Gebhardt-Kusche Date: Wed, 10 Dec 2025 21:40:26 +0100 Subject: [PATCH] ydsad --- public/assets/js/bridge/category-config.js | 2 +- public/editor/bridge-core.js | 79 +++++++++++++++------- 2 files changed, 54 insertions(+), 27 deletions(-) diff --git a/public/assets/js/bridge/category-config.js b/public/assets/js/bridge/category-config.js index e8a637d..0a2cfaf 100644 --- a/public/assets/js/bridge/category-config.js +++ b/public/assets/js/bridge/category-config.js @@ -22,7 +22,7 @@ open: true, label: '🔖 Placeholder', files: ['blocks-placeholder.js'], - registration_mode: 'plugin', + registration_mode: 'sync', },         // --- 2. BAUSTEINE (bausteine) ---         bausteine: { diff --git a/public/editor/bridge-core.js b/public/editor/bridge-core.js index 47872bf..3e8bcd2 100644 --- a/public/editor/bridge-core.js +++ b/public/editor/bridge-core.js @@ -252,7 +252,6 @@ 'bridge-blocks-api', 'bridge-categorization-master', 'bridge-categorization-cleanup', - 'bridge-blocks-placeholder', ];         if (LOAD_NEWSLETTER_PRESET) { @@ -304,40 +303,68 @@         log('BLOCK REGISTER', 'Registriere Bridge Blöcke, um Preset-Defaults zu überschreiben.', 'purple');         // 🛑 DYNAMISCHE AKTIVIERUNG DER SYNCHRONEN BLÖCKE (Ersetzt die fixen Aufrufe) -        if (B.CATEGORY_CONFIG && ed) { -            log('DYNAMIC ACTIVATION', 'Starte Aktivierung synchroner Block-Plugins (via Config).', 'purple'); -             -            // Iteriere über die konfigurierten Kategorien -            Object.keys(B.CATEGORY_CONFIG).forEach(catId => { -                const config = B.CATEGORY_CONFIG[catId]; -                 -                // Verarbeite nur SYNCHRONE Plugins, die Dateien angeben -                if (config.registration_mode === 'sync' && Array.isArray(config.files)) { -                     -                    config.files.forEach(fileName => { -                         -                        // Korrigierte Funktion liefert jetzt z.B. 'BridgeBlocksCustom' -                        const objectName = getPluginObjectName(fileName);  + if (B.CATEGORY_CONFIG && ed) { + log('DYNAMIC ACTIVATION', 'Starte Aktivierung synchroner Block-Plugins (via Config).', 'purple'); + + // Iteriere über die konfigurierten Kategorien + Object.keys(B.CATEGORY_CONFIG).forEach(catId => { + const config = B.CATEGORY_CONFIG[catId]; + + // Verarbeite nur SYNCHRONE Plugins, die Dateien angeben + if ((config.registration_mode || 'sync') === 'sync' && Array.isArray(config.files)) { + + config.files.forEach(fileName => { + + // Korrigierte Funktion liefert jetzt z.B. 'BridgeBlocksCustom' + const objectName = getPluginObjectName(fileName);                         const plugin = window[objectName];                                                  // Prüfen, ob das Skript geladen wurde und die Register-Funktion vorhanden ist                         if (plugin && typeof plugin.register === 'function') {                             log('DYNAMIC ACTIVATION', `Registriere sync Plugin: ${objectName} (${fileName})`, 'lime'); -                            try { -                                plugin.register(ed); -                            } catch(e) { -                                log('DYNAMIC ACTIVATION ERROR', `Fehler beim Registrieren von ${objectName}: ${e.message}`, 'red', 'error'); -                            } + try { + plugin.register(ed); + if (objectName === 'BridgeBlocksPlaceholder') { + ed.__bridgePlaceholderActive = true; + } + } catch(e) { + log('DYNAMIC ACTIVATION ERROR', `Fehler beim Registrieren von ${objectName}: ${e.message}`, 'red', 'error'); + }                         } else {                             log('DYNAMIC ACTIVATION WARNING', `Sync Plugin Objekt oder .register() Methode nicht gefunden: ${objectName} (${fileName})`, 'orange', 'warn');                         } -                    }); -                } -            }); -        } -        // --------------------------------------------------- + }); + } + }); + } + const ensurePlaceholderBlocks = () => { + if (ed.__bridgePlaceholderActive) { + return true; + } + if (window.BridgeBlocksPlaceholder && typeof window.BridgeBlocksPlaceholder.register === 'function') { + try { + window.BridgeBlocksPlaceholder.register(ed); + ed.__bridgePlaceholderActive = true; + log('PLACEHOLDER SYNC', 'Placeholder-Plugin nachträglich aktiviert.', 'lime'); + } catch (err) { + log('PLACEHOLDER ERROR', `Fehler beim Aktivieren des Placeholder-Plugins: ${err.message}`, 'red', 'error'); + } + return true; + } + return false; + }; + if (!ensurePlaceholderBlocks()) { + const fallbackSrc = B.BASE_PATH_BRIDGE + 'blocks-placeholder.js'; + log('PLACEHOLDER LOAD', 'Placeholder-Plugin fehlt – lade Fallback-Skript.', '#B45309', 'warn'); + loadScript(fallbackSrc, () => { + if (!ensurePlaceholderBlocks()) { + log('PLACEHOLDER ERROR', 'Placeholder-Plugin konnte auch nach Fallback nicht initialisiert werden.', 'red', 'error'); + } + }); + } + // --------------------------------------------------- -        log('INIT API', 'API-Elemente werden nun durch das Plugin bridge-blocks-api geladen. (ASYNCHRON)', 'orange');  + log('INIT API', 'API-Elemente werden nun durch das Plugin bridge-blocks-api geladen. (ASYNCHRON)', 'orange');         // ----------------------------------------------------------------------         // DEBUGGING: ZÄHLE REKURSIVE EVENTS