diff --git a/docs/dist/v1/chartifact.markdown.umd.js b/docs/dist/v1/chartifact.markdown.umd.js index 666e68d3..01c41a5c 100644 --- a/docs/dist/v1/chartifact.markdown.umd.js +++ b/docs/dist/v1/chartifact.markdown.umd.js @@ -2444,15 +2444,6 @@ ${reconstitutedRules.join("\n\n")} continue; } const spec = specReview.approvedSpec; - const buttons = spec.editable ? `
- - -
` : ""; - container.innerHTML = `
-
- ${buttons} -
`; - const nestedDiv = container.querySelector(".tabulator-nested"); if (!Tabulator && index2 === 0) { errorHandler(new Error("Tabulator not found"), pluginName$3, index2, "init", container); continue; @@ -2476,6 +2467,23 @@ ${reconstitutedRules.join("\n\n")} if (spec.editable && selectableRows) { delete options.selectableRows; } + let buttonsHtml = ""; + if (spec.editable || selectableRows) { + buttonsHtml = '
'; + if (spec.editable) { + buttonsHtml += ''; + buttonsHtml += ''; + } + if (selectableRows) { + buttonsHtml += ''; + } + buttonsHtml += "
"; + } + container.innerHTML = `
+
+ ${buttonsHtml} +
`; + const nestedDiv = container.querySelector(".tabulator-nested"); const table = new Tabulator(nestedDiv, options); const tabulatorInstance = { id: `${pluginName$3}-${index2}`, @@ -2565,6 +2573,9 @@ ${reconstitutedRules.join("\n\n")} }); } table.setColumns(columns); + if (selectableRows && data.length > 0) { + table.selectRow("all"); + } if (tabulatorInstance.listening) { outputData(); } @@ -2591,6 +2602,22 @@ ${reconstitutedRules.join("\n\n")} }; } } + if (selectableRows) { + const invertBtn = container.querySelector(".tabulator-invert-selection"); + if (invertBtn) { + invertBtn.onclick = () => { + const allRows = table.getRows(); + const selectedRows = new Set(table.getSelectedRows()); + allRows.forEach((row) => { + if (selectedRows.has(row)) { + row.deselect(); + } else { + row.select(); + } + }); + }; + } + } return { ...tabulatorInstance, initialSignals, diff --git a/packages/markdown/src/plugins/tabulator.ts b/packages/markdown/src/plugins/tabulator.ts index d01149df..fbfd9796 100644 --- a/packages/markdown/src/plugins/tabulator.ts +++ b/packages/markdown/src/plugins/tabulator.ts @@ -260,19 +260,12 @@ export const tabulatorPlugin: Plugin = { if (selectableRows) { const invertBtn = container.querySelector('.tabulator-invert-selection') as HTMLButtonElement; - if (invertBtn) { invertBtn.onclick = () => { const allRows = table.getRows(); - const selectedRows = table.getSelectedRows(); - - // Create a set of selected row IDs for quick lookup - const selectedRowIds = new Set(selectedRows.map(row => row.getIndex())); - - // Invert selection: select unselected rows, deselect selected rows + const selectedRows = new Set(table.getSelectedRows()); allRows.forEach(row => { - const rowId = row.getIndex(); - if (selectedRowIds.has(rowId)) { + if (selectedRows.has(row)) { row.deselect(); } else { row.select();