Skip to content

Commit 8c22cbf

Browse files
committed
fix: disable delete row on table header
1 parent cb0cfd0 commit 8c22cbf

5 files changed

Lines changed: 45 additions & 34 deletions

src/blazor-markdown-editor.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,12 @@ function addRowBeforeIfAllowed(state, dispatch) {
407407
return addRowBefore(state, dispatch);
408408
}
409409

410+
function deleteRowIfAllowed(state, dispatch) {
411+
const tableContext = getActiveTableContext(state);
412+
if (tableContext?.rowIndex === 0) return false;
413+
return deleteRow(state, dispatch);
414+
}
415+
410416
// ── Inline Markdown Input Rules ──
411417
const inlineMarkdownRules = inputRules({ rules: [
412418
// **bold**
@@ -493,7 +499,7 @@ function tableToolbarPlugin() {
493499
return el;
494500
}
495501
const cmds = { addColumnBefore, addColumnAfter, deleteColumn,
496-
addRowBefore: addRowBeforeIfAllowed, addRowAfter, deleteRow, deleteTable };
502+
addRowBefore: addRowBeforeIfAllowed, addRowAfter, deleteRow: deleteRowIfAllowed, deleteTable };
497503

498504
function updateButtonStates(state) {
499505
if (!toolbarEl) return;

wwwroot/blazor-markdown-editor.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32046,6 +32046,11 @@
3204632046
if (tableContext?.rowIndex === 0) return false;
3204732047
return addRowBefore(state, dispatch);
3204832048
}
32049+
function deleteRowIfAllowed(state, dispatch) {
32050+
const tableContext = getActiveTableContext(state);
32051+
if (tableContext?.rowIndex === 0) return false;
32052+
return deleteRow(state, dispatch);
32053+
}
3204932054
var inlineMarkdownRules = inputRules({ rules: [
3205032055
// **bold**
3205132056
new InputRule(/\*\*([^\s*](?:[^*]*[^\s*])?)\*\*$/, (state, match2, start, end) => {
@@ -32122,7 +32127,7 @@
3212232127
deleteColumn,
3212332128
addRowBefore: addRowBeforeIfAllowed,
3212432129
addRowAfter,
32125-
deleteRow,
32130+
deleteRow: deleteRowIfAllowed,
3212632131
deleteTable
3212732132
};
3212832133
function updateButtonStates(state) {

wwwroot/blazor-markdown-editor.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)