@@ -31,6 +31,11 @@
|
|||||||
color: var(--text-muted);
|
color: var(--text-muted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.omnisearch-result__extension {
|
||||||
|
font-size: 0.7rem;
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
.omnisearch-result__counter {
|
.omnisearch-result__counter {
|
||||||
font-size: 0.7rem;
|
font-size: 0.7rem;
|
||||||
color: var(--text-muted);
|
color: var(--text-muted);
|
||||||
|
|||||||
@@ -2,9 +2,12 @@
|
|||||||
import { settings, showExcerpt } from 'src/settings'
|
import { settings, showExcerpt } from 'src/settings'
|
||||||
import type { ResultNote } from '../globals'
|
import type { ResultNote } from '../globals'
|
||||||
import {
|
import {
|
||||||
|
getExtension,
|
||||||
highlighter,
|
highlighter,
|
||||||
|
isFileCanvas,
|
||||||
isFileImage,
|
isFileImage,
|
||||||
isFilePDF,
|
isFilePDF,
|
||||||
|
isFilePlaintext,
|
||||||
makeExcerpt,
|
makeExcerpt,
|
||||||
pathWithoutFilename,
|
pathWithoutFilename,
|
||||||
removeDiacritics,
|
removeDiacritics,
|
||||||
@@ -20,8 +23,8 @@
|
|||||||
let imagePath: string | null = null
|
let imagePath: string | null = null
|
||||||
let title = ''
|
let title = ''
|
||||||
let notePath = ''
|
let notePath = ''
|
||||||
let folderPathIcon
|
let elFolderPathIcon: HTMLElement
|
||||||
let filePathIcon
|
let elFilePathIcon: HTMLElement
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
imagePath = null
|
imagePath = null
|
||||||
@@ -45,13 +48,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Icons
|
// Icons
|
||||||
if (folderPathIcon) {
|
if (elFolderPathIcon) {
|
||||||
setIcon(folderPathIcon, 'folder-open')
|
setIcon(elFolderPathIcon, 'folder-open')
|
||||||
}
|
}
|
||||||
if (filePathIcon) {
|
if (elFilePathIcon) {
|
||||||
if (isFileImage(note.path)) setIcon(filePathIcon, 'file-image')
|
if (isFileImage(note.path)) setIcon(elFilePathIcon, 'image')
|
||||||
else if (isFilePDF(note.path)) setIcon(filePathIcon, 'file-line-chart')
|
else if (isFilePDF(note.path)) setIcon(elFilePathIcon, 'file-text')
|
||||||
else setIcon(filePathIcon, 'file-text')
|
else if (isFileCanvas(note.path)) setIcon(elFilePathIcon, 'layout-dashboard')
|
||||||
|
else setIcon(elFilePathIcon, 'file')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -65,8 +69,10 @@
|
|||||||
<div>
|
<div>
|
||||||
<div class="omnisearch-result__title-container">
|
<div class="omnisearch-result__title-container">
|
||||||
<span class="omnisearch-result__title">
|
<span class="omnisearch-result__title">
|
||||||
<!-- <span bind:this="{filePathIcon}"></span>-->
|
<span bind:this="{elFilePathIcon}"></span>
|
||||||
<span>{@html title.replace(reg, highlighter)}</span>
|
<span>{@html title.replace(reg, highlighter)}</span>
|
||||||
|
<span class="omnisearch-result__extension"
|
||||||
|
>.{getExtension(note.path)}</span>
|
||||||
|
|
||||||
<!-- Counter -->
|
<!-- Counter -->
|
||||||
{#if note.matches.length > 0}
|
{#if note.matches.length > 0}
|
||||||
@@ -80,10 +86,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Folder path -->
|
<!-- Folder path -->
|
||||||
|
{#if notePath}
|
||||||
<div class="omnisearch-result__folder-path">
|
<div class="omnisearch-result__folder-path">
|
||||||
<span bind:this="{folderPathIcon}"></span>
|
<span bind:this="{elFolderPathIcon}"></span>
|
||||||
<span>{notePath}</span>
|
<span>{notePath}</span>
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<div style="display: flex; flex-direction: row;">
|
<div style="display: flex; flex-direction: row;">
|
||||||
{#if $showExcerpt}
|
{#if $showExcerpt}
|
||||||
|
|||||||
@@ -255,13 +255,12 @@ export function isFileIndexable(path: string): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function isFileImage(path: string): boolean {
|
export function isFileImage(path: string): boolean {
|
||||||
return (
|
const ext = getExtension(path)
|
||||||
path.endsWith('.png') || path.endsWith('.jpg') || path.endsWith('.jpeg')
|
return (ext === 'png' || ext === 'jpg' || ext === 'jpeg')
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isFilePDF(path: string): boolean {
|
export function isFilePDF(path: string): boolean {
|
||||||
return path.endsWith('.pdf')
|
return getExtension(path) === 'pdf'
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isFilePlaintext(path: string): boolean {
|
export function isFilePlaintext(path: string): boolean {
|
||||||
|
|||||||
Reference in New Issue
Block a user