Files
ndsolutionswebsite/public/js/editor-bridge.js
Daniel S 0c073983e9
All checks were successful
Production Build & Deploy / build-and-deploy (push) Successful in 1m3s
feat(editor): add section manipulation APIs and interactive sidebar controls
2026-08-09 21:08:35 +02:00

28 lines
835 B
JavaScript

// 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 (<head>)
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();
}
});
})();