
      (() => {
        const preview = document.getElementById('preview');
        window.addEventListener('message', (event) => {
          if (event.source !== window.parent || event.data?.type !== 'lvonce-html-preview') return;
          if (typeof event.data.html === 'string') preview.srcdoc = event.data.html;
        });
        window.parent.postMessage({ type: 'lvonce-html-preview-ready' }, '*');
      })();
    
