// public/js/editor-bridge.js (function () { // Bridge nur im Preview-Modus aktivieren const urlParams = new URLSearchParams(window.location.search); if (urlParams.get('preview') !== 'draft') return; console.log('[N&D Editor Bridge] Active on preview canvas'); window.addEventListener('message', (event) => { const { type, payload } = event.data || {}; if (type === 'THEME_UPDATE') { // Injiziert CSS-Variablen live in den DOM () const root = document.documentElement; if (payload.colors) { Object.entries(payload.colors).forEach(([key, val]) => { root.style.setProperty(`--${key}`, val as string); }); } } if (type === 'RELOAD_CANVAS') { // Sanfter Reload des Iframes bei Strukturänderungen window.location.reload(); } }); })();