Skip to content

Commit

Permalink
Changed back checkCallback to callback for now since it doesn't allow…
Browse files Browse the repository at this point in the history
… for the setting to appear in command palette.
  • Loading branch information
agathauy committed Nov 18, 2020
1 parent d8a232c commit 86a4d8b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
21 changes: 14 additions & 7 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ export default class WikilinksToMdlinks extends Plugin {
this.addCommand({
id: "toggle-wiki-md-links",
name: "Toggle selected wikilink to markdown link and vice versa",
checkCallback: () => {
const currentView = this.app.workspace.getActiveLeafOfViewType(MarkdownView)
if ((currentView == null) || (currentView.getMode() !== 'source')) {
return
}
// checkCallback: () => {
// Figuring out why checkCallback doesn't allow the setting to appear in Command Palette
// const currentView = this.app.workspace.getActiveLeafOfViewType(MarkdownView)

// if ((currentView == null) || (currentView.getMode() !== 'source')) {
// return
// }

return this.toggleLink()
},
// return this.toggleLink()
// },
callback: () => this.toggleLink(),
hotkeys: [{
modifiers: ["Mod", "Shift"],
key: "="
Expand All @@ -33,6 +36,10 @@ export default class WikilinksToMdlinks extends Plugin {
const currentView = this.app.workspace.getActiveLeafOfViewType(MarkdownView)
const editor = currentView.sourceMode.cmEditor

if ((currentView == null) || (currentView.getMode() !== 'source')) {
return
}

const cursor = editor.getCursor()
const line = editor.getDoc().getLine(cursor.line);

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": "wikilinks-to-mdlinks-obsidian",
"name": "Wikilinks to MDLinks",
"version": "0.0.7",
"version": "0.0.8",
"minAppVersion": "0.9.12",
"description": "A plugin that converts wikilinks to markdown links and vice versa",
"author": "Agatha Uy",
Expand Down

0 comments on commit 86a4d8b

Please sign in to comment.