Skip to content

Commit cb0cfd0

Browse files
committed
release: 2026.3.1
1 parent 7a96be7 commit cb0cfd0

11 files changed

Lines changed: 111 additions & 20 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Use the slash command menu or type markdown syntax and have it automatically con
5656
- `window.blazorMarkdownEditor.focus(...)`
5757
- `window.blazorMarkdownEditor.destroy(...)`
5858

59-
Versioning uses a calendar schema: `YYYY.MINOR.PATCH` (current: `2026.2.2`).
59+
Versioning uses a calendar schema: `YYYY.MINOR.PATCH` (current: `2026.3.1`).
6060

6161
## Third-Party
6262
* markdown-it 14.1.0

docs/jsinterop-packaging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Build output includes license headers automatically.
2525
This project uses calendar versioning:
2626

2727
- Format: `YYYY.MINOR.PATCH`
28-
- Current: `2026.2.2`
28+
- Current: `2026.3.1`
2929

3030
## Blazor / MudBlazor consumption
3131

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "blazor-markdown-editor",
3-
"version": "2026.2.2",
3+
"version": "2026.3.1",
44
"private": true,
55
"type": "module",
66
"scripts": {

src/blazor-markdown-editor.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@
8080
.link-toolbar button:hover {
8181
background: #f0f0ff;
8282
}
83+
.table-toolbar button:disabled,
84+
.link-toolbar button:disabled {
85+
opacity: 0.45;
86+
cursor: not-allowed;
87+
}
88+
.table-toolbar button:disabled:hover,
89+
.link-toolbar button:disabled:hover {
90+
background: none;
91+
}
8392
.table-toolbar .sep {
8493
width: 1px;
8594
background: #e0e0e0;

src/blazor-markdown-editor.js

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,35 @@ function compactLineBreak(state, dispatch) {
378378
return true;
379379
}
380380

381+
function getActiveTableContext(state) {
382+
const { $head } = state.selection;
383+
let tableDepth = -1;
384+
let rowDepth = -1;
385+
386+
for (let d = $head.depth; d > 0; d--) {
387+
const name = $head.node(d).type.name;
388+
if (rowDepth < 0 && name === "table_row") rowDepth = d;
389+
if (name === "table") {
390+
tableDepth = d;
391+
break;
392+
}
393+
}
394+
395+
if (tableDepth < 0 || rowDepth < 0) return null;
396+
397+
return {
398+
tableDepth,
399+
rowDepth,
400+
rowIndex: $head.index(tableDepth),
401+
};
402+
}
403+
404+
function addRowBeforeIfAllowed(state, dispatch) {
405+
const tableContext = getActiveTableContext(state);
406+
if (tableContext?.rowIndex === 0) return false;
407+
return addRowBefore(state, dispatch);
408+
}
409+
381410
// ── Inline Markdown Input Rules ──
382411
const inlineMarkdownRules = inputRules({ rules: [
383412
// **bold**
@@ -464,7 +493,16 @@ function tableToolbarPlugin() {
464493
return el;
465494
}
466495
const cmds = { addColumnBefore, addColumnAfter, deleteColumn,
467-
addRowBefore, addRowAfter, deleteRow, deleteTable };
496+
addRowBefore: addRowBeforeIfAllowed, addRowAfter, deleteRow, deleteTable };
497+
498+
function updateButtonStates(state) {
499+
if (!toolbarEl) return;
500+
501+
toolbarEl.querySelectorAll("button[data-cmd]").forEach((btn) => {
502+
const cmd = cmds[btn.dataset.cmd];
503+
btn.disabled = cmd ? !cmd(state) : true;
504+
});
505+
}
468506

469507
function positionForSelection(view) {
470508
if (!view.hasFocus()) { hideToolbar(); return; }
@@ -482,6 +520,7 @@ function tableToolbarPlugin() {
482520

483521
if (!inTbl || !tblDom) { hideToolbar(); return; }
484522

523+
updateButtonStates(view.state);
485524
const r = tblDom.getBoundingClientRect();
486525
toolbarEl.style.display = "flex";
487526
toolbarEl.style.left = r.left + "px";
@@ -494,6 +533,7 @@ function tableToolbarPlugin() {
494533
toolbarEl.addEventListener("mousedown", e => {
495534
e.preventDefault();
496535
const btn = e.target.closest("button[data-cmd]");
536+
if (btn?.disabled) return;
497537
if (btn) { const c = cmds[btn.dataset.cmd]; if (c) c(editorView.state, editorView.dispatch); }
498538
});
499539

wwwroot/blazor-markdown-editor.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@
8383
.link-toolbar button:hover {
8484
background: #f0f0ff;
8585
}
86+
.table-toolbar button:disabled,
87+
.link-toolbar button:disabled {
88+
opacity: 0.45;
89+
cursor: not-allowed;
90+
}
91+
.table-toolbar button:disabled:hover,
92+
.link-toolbar button:disabled:hover {
93+
background: none;
94+
}
8695
.table-toolbar .sep {
8796
width: 1px;
8897
background: #e0e0e0;

wwwroot/blazor-markdown-editor.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32022,6 +32022,30 @@
3202232022
if (dispatch) dispatch(state.tr.replaceSelectionWith(schema2.nodes.hard_break.create()).scrollIntoView());
3202332023
return true;
3202432024
}
32025+
function getActiveTableContext(state) {
32026+
const { $head } = state.selection;
32027+
let tableDepth = -1;
32028+
let rowDepth = -1;
32029+
for (let d = $head.depth; d > 0; d--) {
32030+
const name = $head.node(d).type.name;
32031+
if (rowDepth < 0 && name === "table_row") rowDepth = d;
32032+
if (name === "table") {
32033+
tableDepth = d;
32034+
break;
32035+
}
32036+
}
32037+
if (tableDepth < 0 || rowDepth < 0) return null;
32038+
return {
32039+
tableDepth,
32040+
rowDepth,
32041+
rowIndex: $head.index(tableDepth)
32042+
};
32043+
}
32044+
function addRowBeforeIfAllowed(state, dispatch) {
32045+
const tableContext = getActiveTableContext(state);
32046+
if (tableContext?.rowIndex === 0) return false;
32047+
return addRowBefore(state, dispatch);
32048+
}
3202532049
var inlineMarkdownRules = inputRules({ rules: [
3202632050
// **bold**
3202732051
new InputRule(/\*\*([^\s*](?:[^*]*[^\s*])?)\*\*$/, (state, match2, start, end) => {
@@ -32096,11 +32120,18 @@
3209632120
addColumnBefore,
3209732121
addColumnAfter,
3209832122
deleteColumn,
32099-
addRowBefore,
32123+
addRowBefore: addRowBeforeIfAllowed,
3210032124
addRowAfter,
3210132125
deleteRow,
3210232126
deleteTable
3210332127
};
32128+
function updateButtonStates(state) {
32129+
if (!toolbarEl) return;
32130+
toolbarEl.querySelectorAll("button[data-cmd]").forEach((btn) => {
32131+
const cmd = cmds[btn.dataset.cmd];
32132+
btn.disabled = cmd ? !cmd(state) : true;
32133+
});
32134+
}
3210432135
function positionForSelection(view) {
3210532136
if (!view.hasFocus()) {
3210632137
hideToolbar();
@@ -32120,6 +32151,7 @@
3212032151
hideToolbar();
3212132152
return;
3212232153
}
32154+
updateButtonStates(view.state);
3212332155
const r = tblDom.getBoundingClientRect();
3212432156
toolbarEl.style.display = "flex";
3212532157
toolbarEl.style.left = r.left + "px";
@@ -32131,6 +32163,7 @@
3213132163
toolbarEl.addEventListener("mousedown", (e) => {
3213232164
e.preventDefault();
3213332165
const btn = e.target.closest("button[data-cmd]");
32166+
if (btn?.disabled) return;
3213432167
if (btn) {
3213532168
const c = cmds[btn.dataset.cmd];
3213632169
if (c) c(editorView.state, editorView.dispatch);

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.

wwwroot/blazor-markdown-editor.min.js

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

0 commit comments

Comments
 (0)