fix: blocks render formatted content instead of raw HTML on A4 canvas

This commit is contained in:
root
2026-07-16 08:19:11 +00:00
parent 4e69e9b1b2
commit 9c0d71f7e4

View File

@@ -218,12 +218,19 @@ function addBlockToGrid(block, isNew) {
y: block.y, y: block.y,
w: block.w, w: block.w,
h: block.h, h: block.h,
content: widgetHTML, content: '', // empty — we'll set innerHTML manually below
}); });
// Add type class for color coding // Gridstack uses textContent by default which escapes HTML.
const el = document.querySelector(`[gs-id="${block.blockId}"]`); // Set innerHTML directly on the widget's content element.
if (el) el.classList.add(`block-${block.type}`); 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) { function getBlockPreviewText(block) {