Squashed commit of the following:
commit 603b9bbde4c6efc90c81032e4e765c64d3075e75 Author: Simon Cambier <simon.cambier@protonmail.com> Date: Tue Oct 11 21:47:03 2022 +0200 Basic PDF indexing ok commit 200331bb5c5111493af1e1f6ef8cd4bbfbdbfd4f Author: Simon Cambier <simon.cambier@protonmail.com> Date: Tue Oct 11 20:56:44 2022 +0200 Tweaks and comments commit 434b9662d40c5fea9d8b28d43828b11916db8c94 Author: Simon Cambier <simon.cambier@ores.be> Date: Tue Oct 11 16:22:55 2022 +0200 Refactoring notes & minisearch cache commit 7253c676c8ed161782ba8e33f0c4c162880925ad Author: Simon Cambier <simon.cambier@protonmail.com> Date: Tue Oct 11 09:50:33 2022 +0200 wip commit 77736e6ef6f28ccfddb64fb768732927d43bbd77 Author: Simon Cambier <simon.cambier@protonmail.com> Date: Mon Oct 10 20:49:02 2022 +0200 Small rewrites & deps updates commit 59845fdb89eb6a3ad3f3f9ad75b39e7a3e604c45 Author: Simon Cambier <simon.cambier@protonmail.com> Date: Mon Oct 10 12:22:11 2022 +0200 wasm + worker ok commit 1cf3b506e56147586cd0ebcc003642c5230e04cc Author: Simon Cambier <simon.cambier@protonmail.com> Date: Sun Oct 2 20:04:49 2022 +0200 no disk access, of course commit eb3dd9dd4f616a479a53e10856f6c96c6725e911 Author: Simon Cambier <simon.cambier@protonmail.com> Date: Sun Oct 2 19:08:48 2022 +0200 Rollup build ok commit 54f2b7e615456c0e1b1504691689d1ba2c72d9e8 Author: Simon Cambier <simon.cambier@protonmail.com> Date: Sun Oct 2 16:03:31 2022 +0200 Rollup build + wasm PoC
This commit is contained in:
@@ -13,13 +13,13 @@
|
||||
import { loopIndex } from 'src/utils'
|
||||
import { onDestroy, onMount, tick } from 'svelte'
|
||||
import { MarkdownView } from 'obsidian'
|
||||
import { getSuggestions } from 'src/search'
|
||||
import * as Search from 'src/search'
|
||||
import ModalContainer from './ModalContainer.svelte'
|
||||
import { OmnisearchInFileModal, OmnisearchVaultModal } from 'src/modals'
|
||||
import ResultItemInFile from './ResultItemInFile.svelte'
|
||||
import { Query } from 'src/query'
|
||||
import { openNote } from 'src/notes'
|
||||
import {saveSearchHistory} from "../search-history";
|
||||
import { saveSearchHistory } from '../search-history'
|
||||
|
||||
export let modal: OmnisearchInFileModal
|
||||
export let parent: OmnisearchVaultModal | null = null
|
||||
@@ -50,7 +50,7 @@
|
||||
$: (async () => {
|
||||
if (searchQuery) {
|
||||
query = new Query(searchQuery)
|
||||
note = (await getSuggestions(query, { singleFilePath }))[0] ?? null
|
||||
note = (await Search.getSuggestions(query, { singleFilePath }))[0] ?? null
|
||||
lastSearch = searchQuery
|
||||
}
|
||||
selectedIndex = 0
|
||||
@@ -143,20 +143,20 @@
|
||||
</script>
|
||||
|
||||
<InputSearch
|
||||
value={searchQuery}
|
||||
on:input={e => (searchQuery = e.detail)}
|
||||
value="{searchQuery}"
|
||||
on:input="{e => (searchQuery = e.detail)}"
|
||||
placeholder="Omnisearch - File" />
|
||||
|
||||
<ModalContainer>
|
||||
{#if groupedOffsets.length && note}
|
||||
{#each groupedOffsets as offset, i}
|
||||
<ResultItemInFile
|
||||
{offset}
|
||||
{note}
|
||||
index={i}
|
||||
selected={i === selectedIndex}
|
||||
on:mousemove={_e => (selectedIndex = i)}
|
||||
on:click={openSelection} />
|
||||
offset="{offset}"
|
||||
note="{note}"
|
||||
index="{i}"
|
||||
selected="{i === selectedIndex}"
|
||||
on:mousemove="{_e => (selectedIndex = i)}"
|
||||
on:click="{openSelection}" />
|
||||
{/each}
|
||||
{:else}
|
||||
<div style="text-align: center;">
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
import ModalContainer from './ModalContainer.svelte'
|
||||
import { eventBus, type ResultNote } from 'src/globals'
|
||||
import { createNote, openNote } from 'src/notes'
|
||||
import { getSuggestions } from 'src/search'
|
||||
import * as Search from 'src/search'
|
||||
import { getCtrlKeyLabel, getExtension, loopIndex } from 'src/utils'
|
||||
import { OmnisearchInFileModal, type OmnisearchVaultModal } from 'src/modals'
|
||||
import ResultItemVault from './ResultItemVault.svelte'
|
||||
import { Query } from 'src/query'
|
||||
import { saveSearchHistory, searchHistory } from 'src/search-history'
|
||||
import { settings } from '../settings'
|
||||
import { refreshIndex } from '../notes-index'
|
||||
import * as NotesIndex from '../notes-index'
|
||||
|
||||
export let modal: OmnisearchVaultModal
|
||||
let selectedIndex = 0
|
||||
@@ -29,7 +29,7 @@
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
await refreshIndex()
|
||||
await NotesIndex.refreshIndex()
|
||||
searchQuery = searchHistory[historySearchIndex]
|
||||
eventBus.enable('vault')
|
||||
eventBus.on('vault', 'enter', openNoteAndCloseModal)
|
||||
@@ -63,7 +63,7 @@
|
||||
|
||||
async function updateResults() {
|
||||
query = new Query(searchQuery)
|
||||
resultNotes = (await getSuggestions(query)).sort(
|
||||
resultNotes = (await Search.getSuggestions(query)).sort(
|
||||
(a, b) => b.score - a.score
|
||||
)
|
||||
selectedIndex = 0
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<script lang="ts">
|
||||
import { getNoteFromCache } from 'src/notes'
|
||||
import { cacheManager } from 'src/cache-manager'
|
||||
import { settings, showExcerpt } from 'src/settings'
|
||||
import type { ResultNote } from '../globals'
|
||||
import { getMatches } from '../search'
|
||||
import * as Search from '../search'
|
||||
import { highlighter, makeExcerpt, stringsToRegex } from '../utils'
|
||||
import ResultItemContainer from './ResultItemContainer.svelte'
|
||||
|
||||
@@ -10,13 +10,18 @@
|
||||
export let note: ResultNote
|
||||
|
||||
$: reg = stringsToRegex(note.foundWords)
|
||||
$: matches = getMatches(note.content, reg)
|
||||
$: matches = Search.getMatches(note.content, reg)
|
||||
$: cleanedContent = makeExcerpt(note.content, note.matches[0]?.offset ?? -1)
|
||||
$: glyph = getNoteFromCache(note.path)?.doesNotExist
|
||||
$: glyph = cacheManager.getNoteFromCache(note.path)?.doesNotExist
|
||||
$: title = settings.showShortName ? note.basename : note.path
|
||||
</script>
|
||||
|
||||
<ResultItemContainer id={note.path} {selected} on:mousemove on:click {glyph}>
|
||||
<ResultItemContainer
|
||||
id="{note.path}"
|
||||
selected="{selected}"
|
||||
on:mousemove
|
||||
on:click
|
||||
glyph="{glyph}">
|
||||
<div>
|
||||
<span class="omnisearch-result__title">
|
||||
{@html title.replace(reg, highlighter)}
|
||||
|
||||
Reference in New Issue
Block a user