#107 - updated WIP layout
This commit is contained in:
@@ -4,10 +4,30 @@
|
|||||||
.omnisearch-result {
|
.omnisearch-result {
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.omnisearch-result__title-container {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
column-gap: 5px;
|
||||||
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.omnisearch-result__title {
|
.omnisearch-result__title {
|
||||||
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
|
gap: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.omnisearch-result__folder-path {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
|
gap: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.omnisearch-result__counter {
|
.omnisearch-result__counter {
|
||||||
@@ -27,12 +47,20 @@
|
|||||||
color: var(--text-muted);
|
color: var(--text-muted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.omnisearch-result__image-container {
|
||||||
|
flex-basis: 20%;
|
||||||
|
text-align: right
|
||||||
|
}
|
||||||
|
|
||||||
.omnisearch-highlight {
|
.omnisearch-highlight {
|
||||||
}
|
}
|
||||||
|
|
||||||
.omnisearch-default-highlight {
|
.omnisearch-default-highlight {
|
||||||
color: var(--text-normal);
|
text-decoration: underline;
|
||||||
background-color: var(--text-highlight-bg);
|
text-decoration-color: var(--text-highlight-bg);
|
||||||
|
text-decoration-thickness: 3px;
|
||||||
|
text-underline-offset: -1px;
|
||||||
|
text-decoration-skip-ink: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.omnisearch-input-container {
|
.omnisearch-input-container {
|
||||||
|
|||||||
@@ -4,17 +4,24 @@
|
|||||||
import {
|
import {
|
||||||
highlighter,
|
highlighter,
|
||||||
isFileImage,
|
isFileImage,
|
||||||
|
isFilePDF,
|
||||||
makeExcerpt,
|
makeExcerpt,
|
||||||
|
pathWithoutFilename,
|
||||||
removeDiacritics,
|
removeDiacritics,
|
||||||
stringsToRegex,
|
stringsToRegex,
|
||||||
} from '../tools/utils'
|
} from '../tools/utils'
|
||||||
import ResultItemContainer from './ResultItemContainer.svelte'
|
import ResultItemContainer from './ResultItemContainer.svelte'
|
||||||
|
import { onMount } from 'svelte'
|
||||||
|
import { setIcon } from 'obsidian'
|
||||||
|
|
||||||
export let selected = false
|
export let selected = false
|
||||||
export let note: ResultNote
|
export let note: ResultNote
|
||||||
|
|
||||||
let imagePath: string | null = null
|
let imagePath: string | null = null
|
||||||
let title = ''
|
let title = ''
|
||||||
|
let notePath = ''
|
||||||
|
let folderPathIcon
|
||||||
|
let filePathIcon
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
imagePath = null
|
imagePath = null
|
||||||
@@ -31,10 +38,21 @@
|
|||||||
$: cleanedContent = makeExcerpt(note.content, note.matches[0]?.offset ?? -1)
|
$: cleanedContent = makeExcerpt(note.content, note.matches[0]?.offset ?? -1)
|
||||||
$: glyph = false //cacheManager.getLiveDocument(note.path)?.doesNotExist
|
$: glyph = false //cacheManager.getLiveDocument(note.path)?.doesNotExist
|
||||||
$: {
|
$: {
|
||||||
title = settings.showShortName ? note.basename : note.path
|
title = note.basename
|
||||||
|
notePath = pathWithoutFilename(note.path)
|
||||||
if (settings.ignoreDiacritics) {
|
if (settings.ignoreDiacritics) {
|
||||||
title = removeDiacritics(title)
|
title = removeDiacritics(title)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Icons
|
||||||
|
if (folderPathIcon) {
|
||||||
|
setIcon(folderPathIcon, 'folder-open')
|
||||||
|
}
|
||||||
|
if (filePathIcon) {
|
||||||
|
if (isFileImage(note.path)) setIcon(filePathIcon, 'file-image')
|
||||||
|
else if (isFilePDF(note.path)) setIcon(filePathIcon, 'file-line-chart')
|
||||||
|
else setIcon(filePathIcon, 'file-text')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -44,31 +62,42 @@
|
|||||||
on:click
|
on:click
|
||||||
on:mousemove
|
on:mousemove
|
||||||
selected="{selected}">
|
selected="{selected}">
|
||||||
<div style="display:flex">
|
<div style="flex-grow: 1;">
|
||||||
<div>
|
<div class="omnisearch-result__title-container">
|
||||||
<div>
|
|
||||||
<span class="omnisearch-result__title">
|
<span class="omnisearch-result__title">
|
||||||
{@html title.replace(reg, highlighter)}
|
<!-- <span bind:this="{filePathIcon}"></span>-->
|
||||||
|
<span>{@html title.replace(reg, highlighter)}</span>
|
||||||
|
|
||||||
|
<!-- Counter -->
|
||||||
|
<!--{#if note.matches.length > 0}-->
|
||||||
|
<!-- <span class="omnisearch-result__counter">-->
|
||||||
|
<!-- {note.matches.length} {note.matches.length > 1-->
|
||||||
|
<!-- ? 'matches'-->
|
||||||
|
<!-- : 'match'}-->
|
||||||
|
<!-- </span>-->
|
||||||
|
<!--{/if}-->
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
{#if note.matches.length > 0}
|
<!-- Folder path -->
|
||||||
<span class="omnisearch-result__counter">
|
<div class="omnisearch-result__folder-path">
|
||||||
{note.matches.length} {note.matches.length > 1
|
<span bind:this="{folderPathIcon}"></span>
|
||||||
? 'matches'
|
<span>{notePath}</span>
|
||||||
: 'match'}
|
</div>
|
||||||
</span>
|
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div style="display: flex; flex-direction: row;">
|
||||||
{#if $showExcerpt}
|
{#if $showExcerpt}
|
||||||
<div class="omnisearch-result__body">
|
<div class="omnisearch-result__body">
|
||||||
{@html cleanedContent.replace(reg, highlighter)}
|
{@html cleanedContent.replace(reg, highlighter)}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
|
||||||
|
|
||||||
|
<!-- Image -->
|
||||||
{#if imagePath}
|
{#if imagePath}
|
||||||
|
<div class="omnisearch-result__image-container">
|
||||||
<img style="width: 100px" src="{imagePath}" alt="" />
|
<img style="width: 100px" src="{imagePath}" alt="" />
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</ResultItemContainer>
|
</ResultItemContainer>
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ export interface OmnisearchSettings extends WeightingSettings {
|
|||||||
imagesIndexing: boolean
|
imagesIndexing: boolean
|
||||||
/** Activate the small 🔍 button on Obsidian's ribbon */
|
/** Activate the small 🔍 button on Obsidian's ribbon */
|
||||||
ribbonIcon: boolean
|
ribbonIcon: boolean
|
||||||
/** Display short filenames in search results, instead of the full path */
|
|
||||||
showShortName: boolean
|
|
||||||
/** Display the small contextual excerpt in search results */
|
/** Display the small contextual excerpt in search results */
|
||||||
showExcerpt: boolean
|
showExcerpt: boolean
|
||||||
/** Render line returns with <br> in excerpts */
|
/** Render line returns with <br> in excerpts */
|
||||||
@@ -295,19 +293,6 @@ export class SettingsTab extends PluginSettingTab {
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
// Display note names without the full path
|
|
||||||
new Setting(containerEl)
|
|
||||||
.setName('Hide full path in results list')
|
|
||||||
.setDesc(
|
|
||||||
'In the search results, only show the note name, without the full path.'
|
|
||||||
)
|
|
||||||
.addToggle(toggle =>
|
|
||||||
toggle.setValue(settings.showShortName).onChange(async v => {
|
|
||||||
settings.showShortName = v
|
|
||||||
await saveSettings(this.plugin)
|
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
||||||
// Highlight results
|
// Highlight results
|
||||||
new Setting(containerEl)
|
new Setting(containerEl)
|
||||||
.setName('Highlight matching words in results')
|
.setName('Highlight matching words in results')
|
||||||
@@ -390,7 +375,6 @@ export const DEFAULT_SETTINGS: OmnisearchSettings = {
|
|||||||
PDFIndexing: false,
|
PDFIndexing: false,
|
||||||
imagesIndexing: false,
|
imagesIndexing: false,
|
||||||
|
|
||||||
showShortName: false,
|
|
||||||
ribbonIcon: true,
|
ribbonIcon: true,
|
||||||
showExcerpt: true,
|
showExcerpt: true,
|
||||||
renderLineReturnInExcerpts: true,
|
renderLineReturnInExcerpts: true,
|
||||||
|
|||||||
@@ -43,6 +43,12 @@ export function removeFrontMatter(text: string): string {
|
|||||||
return text.replace(regexYaml, '')
|
return text.replace(regexYaml, '')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function pathWithoutFilename(path: string): string {
|
||||||
|
const split = path.split('/')
|
||||||
|
split.pop()
|
||||||
|
return split.join('/')
|
||||||
|
}
|
||||||
|
|
||||||
export function wait(ms: number): Promise<void> {
|
export function wait(ms: number): Promise<void> {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
setTimeout(resolve, ms)
|
setTimeout(resolve, ms)
|
||||||
|
|||||||
Reference in New Issue
Block a user