This commit is contained in:
2025-12-10 21:40:26 +01:00
parent 8eb7244e41
commit 6c09e30e7a
2 changed files with 54 additions and 27 deletions

View File

@@ -22,7 +22,7 @@
open: true,
label: '🔖 Placeholder',
files: ['blocks-placeholder.js'],
registration_mode: 'plugin',
registration_mode: 'sync',
},
        // --- 2. BAUSTEINE (bausteine) ---
        bausteine: {

View File

@@ -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