/* /assets/js/bridge/blocks-standard.js (FINAL & LOG-KONTROLLIERT) */ (function () { const PluginName = 'blocks-standard'; const B = window.BridgeParts || (window.BridgeParts = {}); // ---------------------------------------------------------------------- // 🎯 NEU: LOKALE LOG-KONFIGURATION UND WRAPPER // ---------------------------------------------------------------------- // Setzen Sie dies auf 'false' in der config.js oder hier, um alle Logs NUR für dieses Plugin zu deaktivieren. if (B.LOG_CONFIG && B.LOG_CONFIG.PLUGINS) { B.LOG_CONFIG.PLUGINS[PluginName] = false; // <-- HIER IST IHR SCHALTER } // NEUER LOKALER WRAPPER, der die zentrale B.log Funktion verwendet: const log = (type, message, color = '#0000FF', logType = 'info', force = false) => { if (typeof B.log === 'function') { B.log(PluginName, `[${type}] ${message}`, color, logType, force); } else if (logType === 'error') { // Fallback für kritische Fehler, wenn B.log fehlt console.error(`%c[${PluginName} - ${type}] %c${message}`, `color:red; font-weight:bold;`, 'color:inherit;'); } else { // Fallback für sonstige Logs console.log(`%c[${PluginName} - ${type}] %c${message}`, `color:${color}; font-weight:bold;`, 'color:inherit;'); } }; // ---------------------------------------------------------------------- log('FILE CHECK', 'Datei-IIFE startet.'); // Kritische Prüfung, um doppelte Ausführung zu verhindern if (window.__STANDARD_BLOCKS_LOADED) return; window.__STANDARD_BLOCKS_LOADED = true; const TARGET_CAT_ID = 'mysnips'; const TARGET_CAT_LABEL = 'Bibliothek'; const ALL_STANDARD_BLOCK_IDS = []; const css = o => Object.entries(o).map(([k,v]) => `${k}:${v}`).join(';'); /** * Fügt einen Block hinzu oder aktualisiert ihn SICHER */ function addOrUpdate(bm, id, def) { if (bm.get(id)) { bm.remove(id); log('UPDATE', `Entferne alte Block-Definition: ${id}`, 'gray'); } const finalDef = { ...def, category: TARGET_CAT_ID, force: true }; try { bm.add(id, finalDef); } catch (e) { log('CRITICAL ERROR', `KRITISCHER FEHLER beim Hinzufügen von '${id}': ${e.message}`, 'red', 'error'); return; } ALL_STANDARD_BLOCK_IDS.push(id); } /** * Die eigentliche Plugin-Funktion, die von GrapesJS/Bridge aufgerufen wird. */ const pluginFunction = (editor) => { // Aggressiver Log zur Prüfung der Ausführung log('EXECUTION CHECK', `Starte Block-Registrierung für ${TARGET_CAT_ID}.`, '#993300'); if (!editor || !editor.BlockManager) { log('EXECUTION CHECK', 'Fehler: GrapesJS Editor Instanz ist ungültig.', 'red', 'error'); return; } const bm = editor.BlockManager; // ======================================================= // I. GRAPESJS DEFAULT BLÖCKE (ALLE STANDARD ELEMENTE) // ======================================================= // TEXT (Registriert als 'std-text') addOrUpdate(bm, 'std-text', { label:'Text (Basis)', content:`
| Spalte A | Spalte B |
|---|---|
| Zeile 1 | ... |
| Zeile 2 | ... |