From 21836ca07301c4cbdeb900107ec2c1f85d6e06b5 Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Mon, 4 Jul 2022 11:52:09 +0200 Subject: [PATCH] Add a quick "Navigate: Home" command with Alt-h keyboard shortcut --- packages/plugs/core/core.plug.yaml | 19 +++++++++++++++---- packages/plugs/core/navigate.ts | 4 ++++ packages/web/hooks/command.ts | 2 +- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/packages/plugs/core/core.plug.yaml b/packages/plugs/core/core.plug.yaml index 61bb128..35fe568 100644 --- a/packages/plugs/core/core.plug.yaml +++ b/packages/plugs/core/core.plug.yaml @@ -36,6 +36,12 @@ functions: reindexSpace: path: "./page.ts:reindexSpace" env: server + + deletePage: + path: "./page.ts:deletePage" + command: + name: "Page: Delete" + # Backlinks indexLinks: path: "./page.ts:indexLinks" events: @@ -44,20 +50,19 @@ functions: path: ./page.ts:linkQueryProvider events: - query:link - deletePage: - path: "./page.ts:deletePage" - command: - name: "Page: Delete" renamePage: path: "./page.ts:renamePage" command: name: "Page: Rename" mac: Cmd-Alt-r key: Ctrl-Alt-r + pageComplete: path: "./page.ts:pageComplete" events: - page:complete + + # Navigation linkNavigate: path: "./navigate.ts:linkNavigate" command: @@ -68,6 +73,12 @@ functions: path: "./navigate.ts:clickNavigate" events: - page:click + navigateHome: + path: "./navigate.ts:navigateCommand" + command: + name: "Navigate: Home" + key: "Alt-h" + page: "index" # Hashtags indexTags: diff --git a/packages/plugs/core/navigate.ts b/packages/plugs/core/navigate.ts index b39da31..9e52f7c 100644 --- a/packages/plugs/core/navigate.ts +++ b/packages/plugs/core/navigate.ts @@ -47,3 +47,7 @@ export async function clickNavigate(event: ClickEvent) { let newNode = nodeAtPos(mdTree, event.pos); await actionClickOrActionEnter(newNode); } + +export async function navigateCommand(cmdDef: any) { + await navigateTo(cmdDef.page); +} diff --git a/packages/web/hooks/command.ts b/packages/web/hooks/command.ts index 718649c..a3f5301 100644 --- a/packages/web/hooks/command.ts +++ b/packages/web/hooks/command.ts @@ -44,7 +44,7 @@ export class CommandHook this.editorCommands.set(cmd.name, { command: cmd, run: () => { - return plug.invoke(name, []); + return plug.invoke(name, [cmd]); }, }); }