mirror of
https://github.com/vesan/obsidian-table-beautifier.git
synced 2026-07-22 06:53:19 +00:00
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:
parent
748c7a533f
commit
5d3d9a25c8
1 changed files with 5 additions and 2 deletions
|
|
@ -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;
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue