diff --git a/blocks/table/table.js b/blocks/table/table.js index eb88936..9988ba3 100644 --- a/blocks/table/table.js +++ b/blocks/table/table.js @@ -29,7 +29,7 @@ function extractColSpans(block) { return []; } - const cols = firstCol.nextElementSibling.textContent.split(','); + const cols = firstCol.nextElementSibling.textContent.split(';').map((row) => row.split(',')); firstRow.remove(); return cols; } @@ -111,11 +111,12 @@ export default async function decorate(block) { const head = rows.shift(); if (!head) return; + const spans = colSpans.shift() || []; const cells = [...head.querySelectorAll(':scope > div')]; const thead = html` - ${cells.map((cell, i) => `${cell.innerHTML}`).join('\n')} + ${cells.map((cell, i) => `${cell.innerHTML}`).join('\n')}
`.firstElementChild; @@ -128,10 +129,12 @@ export default async function decorate(block) { table.appendChild(tbody); rows.forEach((row) => { + const spans = colSpans.shift() || []; const cells = [...row.querySelectorAll(':scope > div')]; + const tr = html` - ${cells.map((cell) => ``).join('\n')} + ${cells.map((cell, i) => `${cell.innerHTML}`).join('\n')}
${cell.innerHTML}
`.firstElementChild.firstElementChild; tbody.appendChild(tr);