All checks were successful
Production Build & Deploy / build-and-deploy (push) Successful in 1m3s
28 lines
835 B
JavaScript
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();
|
|
}
|
|
});
|
|
})();
|