Skip to content

Commit

Permalink
Wrapping command with editorCheckCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
dilantha committed Dec 10, 2024
1 parent c5b8610 commit 4897f57
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "link-formatter",
"version": "1.0.2",
"version": "1.0.3",
"description": "",
"main": "main.js",
"scripts": {
Expand Down

0 comments on commit 4897f57

Please sign in to comment.