Wrapping command with editorCheckCallback

This commit is contained in:
Dilantha Nanayakkara 2024-12-10 23:05:43 +11:00
parent c5b86106a7
commit 4897f577de
3 changed files with 8 additions and 7 deletions

11
main.ts
View file

@ -6,12 +6,13 @@ export default class LinkFormatterPlugin extends Plugin {
this.addCommand({
id: 'link-formatter',
name: 'Format links to unordered list',
editorCallback: (editor: Editor, view: MarkdownView) => {
if (editor.somethingSelected()) {
const selectedText = editor.getSelection();
const formattedText = formatLinkList(selectedText);
editor.replaceSelection(formattedText);
editorCheckCallback: (checking: boolean, editor: Editor, view: MarkdownView) => {
if (checking) {
return !!editor.somethingSelected();
}
const selectedText = editor.getSelection();
const formattedText = formatLinkList(selectedText);
editor.replaceSelection(formattedText);
}
});
}

View file

@ -1,7 +1,7 @@
{
"id": "link-formatter",
"name": "Link Formatter",
"version": "1.0.2",
"version": "1.0.3",
"minAppVersion": "0.15.0",
"description": "Formats a block of links into a clean markdown list",
"author": "Dilantha Nanayakkara",

View file

@ -1,6 +1,6 @@
{
"name": "link-formatter",
"version": "1.0.2",
"version": "1.0.3",
"description": "",
"main": "main.js",
"scripts": {