Skip to content

Commit

Permalink
Fix pjeby#117 - Add command to open or create tag page
Browse files Browse the repository at this point in the history
  • Loading branch information
mvaaltola committed Oct 16, 2023
1 parent 7026bd4 commit e9973cf
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@ export default class TagWrangler extends Plugin {
onElement(document, "contextmenu", ".tag-pane-tag", this.onMenu.bind(this), {capture: true})
);

this.addCommand({
id: "tag-wrangler-tagpage",
name: "Open or create tag page",
editorCallback: (editor, view) => {
const token = editor.getClickableTokenAt(editor.getCursor());
if (token?.type === "tag") {
const tagName = Tag.toTag(token.text).slice(1);
const tagPage = this.tagPage(tagName);
console.log("tagPage: ", tagPage);
tagPage ? this.openTagPage(tagPage, false, false) : this.createTagPage(tagName, false);
}
},
});

this.app.workspace.registerHoverLinkSource(tagHoverMain, {display: 'Tag pane', defaultMod: true});

this.addChild(
Expand Down

0 comments on commit e9973cf

Please sign in to comment.