From b718f8e5cb99bf7e62ab8855770209870ad2b142 Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Sat, 25 Jun 2022 12:01:49 +0200 Subject: [PATCH] Tab to switch contexts, alt+enter to inject a link --- src/components/ModalInFile.svelte | 18 +++++-- src/components/ModalVault.svelte | 86 ++++++++++++++++++++++++------- src/event-bus.ts | 7 +-- src/main.ts | 5 +- src/modals.ts | 7 ++- src/suggestions.ts | 52 ------------------- src/utils.ts | 2 +- 7 files changed, 94 insertions(+), 83 deletions(-) delete mode 100644 src/suggestions.ts diff --git a/src/components/ModalInFile.svelte b/src/components/ModalInFile.svelte index 3e3dbc8..a7167d5 100644 --- a/src/components/ModalInFile.svelte +++ b/src/components/ModalInFile.svelte @@ -15,7 +15,7 @@ import { onDestroy, onMount, tick } from "svelte" import { MarkdownView } from "obsidian" import { getSuggestions } from "src/search" import ModalContainer from "./ModalContainer.svelte" -import type { OmnisearchInFileModal, OmnisearchVaultModal } from "src/modals" +import { OmnisearchInFileModal, OmnisearchVaultModal } from "src/modals" import ResultItemInFile from "./ResultItemInFile.svelte" import { Query } from "src/query" @@ -33,15 +33,16 @@ onMount(() => { if (lastSearch && !searchQuery) { searchQuery = lastSearch } - eventBus.disable("vault") + eventBus.enable("infile") eventBus.on("infile", "enter", openSelection) eventBus.on("infile", "arrow-up", () => moveIndex(-1)) eventBus.on("infile", "arrow-down", () => moveIndex(1)) + eventBus.on("infile", "tab", switchToVaultModal) }) onDestroy(() => { - eventBus.enable("vault") + eventBus.disable("infile") }) $: (async () => { @@ -127,6 +128,11 @@ async function openSelection(): Promise { }) } } + +function switchToVaultModal(): void { + new OmnisearchVaultModal(app).open() + modal.close() +} @@ -155,12 +161,16 @@ async function openSelection(): Promise {
to open
+
+ + to switch to Vault Search +
esc {#if !!parent} to go back to Vault Search {:else} - to dismiss + to close {/if}
diff --git a/src/components/ModalVault.svelte b/src/components/ModalVault.svelte index 7293596..9efb444 100644 --- a/src/components/ModalVault.svelte +++ b/src/components/ModalVault.svelte @@ -3,8 +3,8 @@ let lastSearch = ""