mirror of
https://github.com/dilantha/link-formatter.git
synced 2026-07-22 11:30:23 +00:00
Wrapping command with editorCheckCallback
This commit is contained in:
parent
c5b86106a7
commit
4897f577de
3 changed files with 8 additions and 7 deletions
11
main.ts
11
main.ts
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "link-formatter",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"description": "",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
|
|||
Loading…
Reference in a new issue