Highlighting rework, should help with #304
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
<script lang="ts">
|
||||
import {
|
||||
makeExcerpt,
|
||||
highlightText,
|
||||
} from 'src/tools/text-processing'
|
||||
import { makeExcerpt, highlightText } from 'src/tools/text-processing'
|
||||
import type { ResultNote } from '../globals'
|
||||
import ResultItemContainer from './ResultItemContainer.svelte'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
@@ -13,10 +10,7 @@
|
||||
export let selected = false
|
||||
|
||||
$: cleanedContent = makeExcerpt(note?.content ?? '', offset)
|
||||
$: matchesExcerpt = cloneDeep(note.matches).map(m => {
|
||||
m.offset = m.offset - cleanedContent.offset
|
||||
return m
|
||||
})
|
||||
$: matchesExcerpt = cloneDeep(note.matches)
|
||||
</script>
|
||||
|
||||
<ResultItemContainer
|
||||
@@ -26,6 +20,6 @@
|
||||
on:click
|
||||
on:auxclick>
|
||||
<div class="omnisearch-result__body">
|
||||
{@html highlightText(cleanedContent.content, matchesExcerpt)}
|
||||
{@html highlightText(cleanedContent, matchesExcerpt)}
|
||||
</div>
|
||||
</ResultItemContainer>
|
||||
|
||||
@@ -40,10 +40,6 @@
|
||||
$: reg = stringsToRegex(note.foundWords)
|
||||
$: matchesTitle = getMatches(title, reg)
|
||||
$: matchesNotePath = getMatches(notePath, reg)
|
||||
$: matchesExcerpt = cloneDeep(note.matches).map(m => {
|
||||
m.offset = m.offset - cleanedContent.offset
|
||||
return m
|
||||
})
|
||||
$: cleanedContent = makeExcerpt(note.content, note.matches[0]?.offset ?? -1)
|
||||
$: glyph = false //cacheManager.getLiveDocument(note.path)?.doesNotExist
|
||||
$: {
|
||||
@@ -102,7 +98,7 @@
|
||||
<div style="display: flex; flex-direction: row;">
|
||||
{#if $showExcerpt}
|
||||
<div class="omnisearch-result__body">
|
||||
{@html highlightText(cleanedContent.content, matchesExcerpt)}
|
||||
{@html highlightText(cleanedContent, note.matches)}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user