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) {