/* /assets/js/bridge/blocks-custom.js (FINAL & LOG-KONTROLLIERT) */ (function () { const PluginName = 'blocks-custom'; 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 = '#FFD700', 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;'); } }; // ---------------------------------------------------------------------- log('FILE CHECK', 'Datei-IIFE startet.'); // NEU: Kontrollierbarer Start-Log if (window.__CUSTOM_BLOCKS_LOADED) return; window.__CUSTOM_BLOCKS_LOADED = true; const TARGET_CAT_ID = 'bausteine'; const ALL_CUSTOM_BLOCK_IDS = []; function addOnce(bm, id, def, category = TARGET_CAT_ID) { // Hinzufügen des Blocks und Sicherstellen der Kategorie-Zuweisung try { bm.add(id, { ...def, category }); ALL_CUSTOM_BLOCK_IDS.push(id); log('BLOCK ADD', `Block '${id}' erfolgreich hinzugefügt.`, '#B8860B'); } catch (e) { log('BLOCK ERROR', `Fehler beim Hinzufügen von Block '${id}': ${e.message}`, 'red', 'error'); } } const css = o => Object.entries(o).map(([k,v]) => `${k}:${v}`).join(';'); function register(editor) { log('EXECUTION', `Starte Block-Registrierung für ${TARGET_CAT_ID}.`, '#DAA520'); const bm = editor.BlockManager; // TEXT 2 addOnce(bm, 'cust-text', { id:'cust-text', label:'📝 Text', content:{ type:'text', tagName:'p', content:'Dies ist ein Absatz. Doppelklick zum Bearbeiten.', style:{ 'font-family':'Arial,sans-serif', 'font-size':'14px', 'line-height':'1.5', color:'#0f172a', margin:'0 0 12px' } } }); // IMAGE addOnce(bm, 'cust-image', { id:'cust-image', label:'🖼️ Bild', content:`
Bild
` }); // BUTTON addOnce(bm, 'cust-button', { id:'cust-button', label:'🔘 Button', content:`
Call To Action
` }); // TABLE addOnce(bm, 'cust-table', { id:'cust-table', label:'🧩 Tabelle (2xN)', content:{ type:'default', tagName:'table', attributes:{ role:'presentation', width:'100%', cellpadding:'0', cellspacing:'0', 'data-bridge-table':'1', 'data-bridge-rows':'3', 'data-bridge-cols':'2' }, style:{ 'font-family':'Arial,sans-serif', 'border-collapse':'collapse', 'width':'100%', 'margin-bottom':'16px' }, components:` Spalte A Spalte B Zeile 1 ... Zeile 2 ... ` } }); // DIVIDER addOnce(bm, 'cust-divider',{ id:'cust-divider',label:'⎯ Divider', content:`
` }); // SPACER addOnce(bm, 'cust-spacer', { id:'cust-spacer', label:'↕ Spacer', content:`
` }); // MEDIA LEFT addOnce(bm, 'cust-media-left', { id:'cust-media-left', label:'🖼️◀ Text', content:{ type:'default', tagName:'table', attributes:{ role:'presentation', width:'100%', cellpadding:'0', cellspacing:'0' }, style:{ 'font-family':'Arial,sans-serif', 'border-collapse':'collapse', 'margin-bottom':'16px' }, components:` Bild

Überschrift

Beschreibungstext …

Mehr erfahren ` } }); // HERO addOnce(bm, 'cust-hero', { id:'cust-hero', label:'🌄 Hero', content:`
Hero

Titel des Newsletters

Kurzer Untertitel oder Einleitung.

` }); // FOOTER addOnce(bm, 'cust-footer', { id:'cust-footer', label:'⚓ Footer', content:`

Dein Unternehmen GmbH • Musterstraße 1 • 12345 Berlin

Abmelden · Impressum · Datenschutz

` }); log('SUCCESS', `Registrierung abgeschlossen. ${ALL_CUSTOM_BLOCK_IDS.length} Blöcke erstellt.`, '#008000', 'info'); } // 🛑 KRITISCHE EXPORT-KORREKTUR: Exportiere 'register', um den Fehler in bridge-core.js zu beheben window.BridgeBlocksCustom = { IDS: ALL_CUSTOM_BLOCK_IDS, register: register // <--- NEU: Exportiert die Register-Funktion }; // Registriere das Modul als GrapesJS Plugin if (B && B.registerGrapesJSPlugin && typeof register === 'function') { B.registerGrapesJSPlugin('bridge-blocks-custom', register); log('PLUGIN REGISTER', `'bridge-blocks-custom' erfolgreich zur Bridge Plugin Registry hinzugefügt.`, '#008000'); } else { log('CRITICAL ERROR', `BridgeParts oder registerGrapesJSPlugin fehlt! Plugin-Registrierung gescheitert.`, 'red', 'error'); } })();