diff --git a/static/carbone.js b/static/carbone.js index ce11082..fffd7a8 100644 --- a/static/carbone.js +++ b/static/carbone.js @@ -171,8 +171,18 @@ async function previewTemplate(templateId) { } const html = await resp.text(); - // Show the HTML in a modal with an iframe - const body = ''; + // Wrap the LibreOffice HTML in a styled container that adapts to the app theme. + // LibreOffice exports plain HTML with inline styles — we inject a wrapper + // that sets a white page background with padding so it reads like a document, + // regardless of whether the app is in dark or light mode. + const styledHtml = html.replace('', ``); + const body = ''; showModal(body, 'Template Preview', 'large'); toast('Preview generated'); } catch (e) { @@ -311,6 +321,16 @@ function forceSaveOnlyoffice() { } } +// Preview the template from inside the editor — save first, then render +async function previewFromEditor(templateId) { + toast('Saving before preview...'); + // ONLYOFFICE auto-saves on callback, but we force a save notification + // then wait briefly for the callback to hit our backend + await new Promise(r => setTimeout(r, 1500)); + // Now call the existing preview function + await previewTemplate(templateId); +} + // Track whether the editor is cleaning up (disable Edit buttons during this) let editorCleaningUp = false; @@ -380,6 +400,7 @@ async function openOnlyofficeEditor(templateId, templateName) {

Editing: ${templateName}

+
diff --git a/static/index.html b/static/index.html index b7ed968..ce8ae11 100644 --- a/static/index.html +++ b/static/index.html @@ -140,6 +140,6 @@ - + \ No newline at end of file