Fixed #84
This commit is contained in:
@@ -18,6 +18,7 @@ import ModalContainer from "./ModalContainer.svelte"
|
|||||||
import { OmnisearchInFileModal, OmnisearchVaultModal } from "src/modals"
|
import { OmnisearchInFileModal, OmnisearchVaultModal } from "src/modals"
|
||||||
import ResultItemInFile from "./ResultItemInFile.svelte"
|
import ResultItemInFile from "./ResultItemInFile.svelte"
|
||||||
import { Query } from "src/query"
|
import { Query } from "src/query"
|
||||||
|
import { openNote } from "src/notes";
|
||||||
|
|
||||||
export let modal: OmnisearchInFileModal
|
export let modal: OmnisearchInFileModal
|
||||||
export let parent: OmnisearchVaultModal | null = null
|
export let parent: OmnisearchVaultModal | null = null
|
||||||
@@ -106,13 +107,15 @@ async function scrollIntoView(): Promise<void> {
|
|||||||
elem?.scrollIntoView({ behavior: "auto", block: "nearest" })
|
elem?.scrollIntoView({ behavior: "auto", block: "nearest" })
|
||||||
}
|
}
|
||||||
|
|
||||||
async function openSelection(evt: MouseEvent): Promise<void> {
|
async function openSelection(evt?: MouseEvent | KeyboardEvent): Promise<void> {
|
||||||
// TODO: clean me, merge with notes.openNote()
|
|
||||||
if (note) {
|
if (note) {
|
||||||
modal.close()
|
modal.close()
|
||||||
if (parent) parent.close()
|
if (parent) parent.close()
|
||||||
|
|
||||||
await app.workspace.openLinkText(note.path, "", evt.ctrlKey)
|
// Open (or switch focus to) the note
|
||||||
|
await openNote(note, evt?.ctrlKey)
|
||||||
|
|
||||||
|
// Move cursor to the match
|
||||||
const view = app.workspace.getActiveViewOfType(MarkdownView)
|
const view = app.workspace.getActiveViewOfType(MarkdownView)
|
||||||
if (!view) {
|
if (!view) {
|
||||||
throw new Error("OmniSearch - No active MarkdownView")
|
throw new Error("OmniSearch - No active MarkdownView")
|
||||||
|
|||||||
@@ -53,14 +53,13 @@ async function updateResults() {
|
|||||||
scrollIntoView()
|
scrollIntoView()
|
||||||
}
|
}
|
||||||
|
|
||||||
function onClick(evt: MouseEvent) {
|
function onClick(evt?: MouseEvent | KeyboardEvent) {
|
||||||
if (!selectedNote) return
|
if (!selectedNote) return
|
||||||
openNote(selectedNote, evt.ctrlKey) // Keep ctrl pressed to open in a new pane
|
openNote(selectedNote, evt?.ctrlKey) // Keep ctrl pressed to open in a new pane
|
||||||
modal.close()
|
modal.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
function openNoteAndCloseModal(): void {
|
function openNoteAndCloseModal(): void {
|
||||||
// console.log(event.detail)
|
|
||||||
if (!selectedNote) return
|
if (!selectedNote) return
|
||||||
openNote(selectedNote)
|
openNote(selectedNote)
|
||||||
modal.close()
|
modal.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user