Fixed layout, removed agressive highlighter and some console.logs

This commit is contained in:
Simon Cambier
2022-04-18 18:35:08 +02:00
parent a9e087bff7
commit 47b30b5c62
6 changed files with 30 additions and 32 deletions

View File

@@ -24,3 +24,6 @@
color: var(--text-muted); color: var(--text-muted);
} }
.omnisearch-highlight {
}

View File

@@ -15,8 +15,8 @@ $: {
groupedOffsets = groups.map((group) => groupedOffsets = groups.map((group) =>
Math.round((group.first()!.offset + group.last()!.offset) / 2) Math.round((group.first()!.offset + group.last()!.offset) / 2)
) )
console.log(groups) // console.log(groups)
console.log(groupedOffsets) // console.log(groupedOffsets)
} }
} }

View File

@@ -3,15 +3,7 @@ import CmpInput from "./CmpInput.svelte"
import CmpNoteResult from "./CmpNoteResult.svelte" import CmpNoteResult from "./CmpNoteResult.svelte"
import type { ResultNote } from "./globals" import type { ResultNote } from "./globals"
import { openNote } from "./notes" import { openNote } from "./notes"
import { import { modal, plugin, resultNotes, searchQuery, selectedNote } from "./stores"
modal,
plugin,
resultNotes,
searchQuery,
selectedNote,
} from "./stores"
async function createOrOpenNote(item: ResultNote): Promise<void> { async function createOrOpenNote(item: ResultNote): Promise<void> {
try { try {
@@ -60,23 +52,23 @@ function onInputShiftEnter(event: CustomEvent<ResultNote>): void {
<CmpNoteResult selected={result === $selectedNote} note={result} /> <CmpNoteResult selected={result === $selectedNote} note={result} />
{/each} {/each}
</div> </div>
<div class="prompt-instructions"> </div>
<div class="prompt-instruction"> <div class="prompt-instructions">
<span class="prompt-instruction-command">↑↓</span><span>to navigate</span> <div class="prompt-instruction">
</div> <span class="prompt-instruction-command">↑↓</span><span>to navigate</span>
<div class="prompt-instruction"> </div>
<span class="prompt-instruction-command"></span><span>to open</span> <div class="prompt-instruction">
</div> <span class="prompt-instruction-command"></span><span>to open</span>
<div class="prompt-instruction"> </div>
<span class="prompt-instruction-command">ctrl ↵</span> <div class="prompt-instruction">
<span>to open in a new pane</span> <span class="prompt-instruction-command">ctrl ↵</span>
</div> <span>to open in a new pane</span>
<div class="prompt-instruction"> </div>
<span class="prompt-instruction-command">shift ↵</span> <div class="prompt-instruction">
<span>to create</span> <span class="prompt-instruction-command">shift ↵</span>
</div> <span>to create</span>
<div class="prompt-instruction"> </div>
<span class="prompt-instruction-command">esc</span><span>to dismiss</span> <div class="prompt-instruction">
</div> <span class="prompt-instruction-command">esc</span><span>to dismiss</span>
</div> </div>
</div> </div>

View File

@@ -6,6 +6,8 @@ export const regexYaml = /^---\s*\n(.*?)\n?^---\s?/ms
export const excerptBefore = 100 export const excerptBefore = 100
export const excerptAfter = 180 export const excerptAfter = 180
export const highlightClass = 'suggestion-highlight omnisearch-highlight'
export type SearchNote = { export type SearchNote = {
path: string path: string
basename: string basename: string

View File

@@ -91,8 +91,8 @@ function subscribeToQuery(): void {
? getSuggestions(q, { singleFile: get(singleFileSearch) }) ? getSuggestions(q, { singleFile: get(singleFileSearch) })
: getSuggestions(q) : getSuggestions(q)
console.log('Search results') // console.log('Search results')
console.log(results) // console.log(results)
// Save the results in the store // Save the results in the store
resultNotes.set(results) resultNotes.set(results)

View File

@@ -1,5 +1,6 @@
import type { CachedMetadata } from 'obsidian' import type { CachedMetadata } from 'obsidian'
import { import {
highlightClass,
isSearchMatch, isSearchMatch,
regexLineSplit, regexLineSplit,
regexYaml, regexYaml,
@@ -7,7 +8,7 @@ import {
import type { SearchMatch } from './globals' import type { SearchMatch } from './globals'
export function highlighter(str: string): string { export function highlighter(str: string): string {
return '<span class="search-result-file-matched-text">' + str + '</span>' return `<span class="${highlightClass}">${str}</span>`
} }
export function escapeHTML(html: string): string { export function escapeHTML(html: string): string {