From 9c0d71f7e427fa9d1ca2af77415fb3165aaac457 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 16 Jul 2026 08:19:11 +0000 Subject: [PATCH] fix: blocks render formatted content instead of raw HTML on A4 canvas --- static/designer.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/static/designer.js b/static/designer.js index bdf9d26..1034b71 100644 --- a/static/designer.js +++ b/static/designer.js @@ -218,12 +218,19 @@ function addBlockToGrid(block, isNew) { y: block.y, w: block.w, h: block.h, - content: widgetHTML, + content: '', // empty — we'll set innerHTML manually below }); - // Add type class for color coding - const el = document.querySelector(`[gs-id="${block.blockId}"]`); - if (el) el.classList.add(`block-${block.type}`); + // Gridstack uses textContent by default which escapes HTML. + // Set innerHTML directly on the widget's content element. + const el = widget.el || widget; + if (el) { + const contentDiv = el.querySelector('.grid-stack-item-content'); + if (contentDiv) { + contentDiv.innerHTML = widgetHTML; + } + el.classList.add(`block-${block.type}`); + } } function getBlockPreviewText(block) {