fix: gate command palette entry behind table detection

Previously the command silently no-oped when run on a non-table
selection. Use editorCheckCallback so the entry is grayed out in the
palette unless the selection contains table-like characters, matching
the existing right-click menu behavior.
This commit is contained in:
Vesa Vänskä 2026-04-26 19:40:04 +03:00
parent 748c7a533f
commit 5d3d9a25c8
No known key found for this signature in database

View file

@ -23,8 +23,11 @@ export default class TableBeautifierPlugin extends Plugin {
this.addCommand({
id: "convert-table-to-markdown",
name: "Convert table to Markdown",
editorCallback: (editor: Editor) => {
convertSelection(editor);
editorCheckCallback: (checking: boolean, editor: Editor) => {
const selection = editor.getSelection();
if (!selection || !looksLikeTable(selection)) return false;
if (!checking) convertSelection(editor);
return true;
},
});