#58 - index other files than .md
Also, reverted 66e1d2d334 to only make showContext reactive
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
import { eventBus, type ResultNote } from 'src/globals'
|
||||
import { createNote, openNote } from 'src/notes'
|
||||
import { getSuggestions, reindexNotes } from 'src/search'
|
||||
import { getCtrlKeyLabel, loopIndex } from 'src/utils'
|
||||
import { getCtrlKeyLabel, getExtension, loopIndex } from 'src/utils'
|
||||
import { OmnisearchInFileModal, type OmnisearchVaultModal } from 'src/modals'
|
||||
import ResultItemVault from './ResultItemVault.svelte'
|
||||
import { Query } from 'src/query'
|
||||
@@ -20,7 +20,6 @@
|
||||
let resultNotes: ResultNote[] = []
|
||||
let query: Query
|
||||
$: selectedNote = resultNotes[selectedIndex]
|
||||
// $: lastSearch = lastSearches[lastSearchIndex]
|
||||
|
||||
$: if (searchQuery) {
|
||||
updateResults()
|
||||
@@ -94,6 +93,10 @@
|
||||
openNote(note, newPane)
|
||||
}
|
||||
|
||||
async function onClickCreateNote(e: MouseEvent) {
|
||||
await createNoteAndCloseModal()
|
||||
}
|
||||
|
||||
async function createNoteAndCloseModal(opt?: {
|
||||
newLeaf: boolean
|
||||
}): Promise<void> {
|
||||
@@ -123,7 +126,7 @@
|
||||
if (file && active) {
|
||||
link = app.fileManager.generateMarkdownLink(file, active.path)
|
||||
} else {
|
||||
link = `[[${selectedNote.basename}.md]]`
|
||||
link = `[[${selectedNote.basename}.${getExtension(selectedNote.path)}]]`
|
||||
}
|
||||
|
||||
// Inject link
|
||||
@@ -172,8 +175,8 @@
|
||||
value="{searchQuery}"
|
||||
on:input="{e => (searchQuery = e.detail)}"
|
||||
placeholder="Omnisearch - Vault">
|
||||
{#if $settings.showCreateButton}
|
||||
<button on:click="{createNoteAndCloseModal}">Create note</button>
|
||||
{#if settings.showCreateButton}
|
||||
<button on:click="{onClickCreateNote}">Create note</button>
|
||||
{/if}
|
||||
</InputSearch>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { getNoteFromCache } from 'src/notes'
|
||||
import { settings } from 'src/settings'
|
||||
import { settings, showContext } from 'src/settings'
|
||||
import type { ResultNote } from '../globals'
|
||||
import { getMatches } from '../search'
|
||||
import { highlighter, makeExcerpt, stringsToRegex } from '../utils'
|
||||
@@ -13,7 +13,7 @@
|
||||
$: matches = getMatches(note.content, reg)
|
||||
$: cleanedContent = makeExcerpt(note.content, note.matches[0]?.offset ?? -1)
|
||||
$: glyph = getNoteFromCache(note.path)?.doesNotExist
|
||||
$: title = $settings.showShortName ? note.basename : note.path
|
||||
$: title = settings.showShortName ? note.basename : note.path
|
||||
</script>
|
||||
|
||||
<ResultItemContainer id={note.path} {selected} on:mousemove on:click {glyph}>
|
||||
@@ -29,7 +29,7 @@
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if $settings.showContext}
|
||||
{#if $showContext}
|
||||
<div class="omnisearch-result__body">
|
||||
{@html cleanedContent.replace(reg, highlighter)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user