From 074a96fcfff5c090d85abe2099b207e794ca106f Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Thu, 20 Jun 2024 18:34:54 +0200 Subject: [PATCH] Show "dashboard" icon for excalidraw files --- src/cache-manager.ts | 4 ++-- src/components/ResultItemVault.svelte | 17 ++++++++++++----- src/notes-indexer.ts | 6 +++--- src/tools/utils.ts | 6 +++++- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/cache-manager.ts b/src/cache-manager.ts index 6b8ebaf..8b94e9e 100644 --- a/src/cache-manager.ts +++ b/src/cache-manager.ts @@ -5,7 +5,7 @@ import { getAliasesFromMetadata, getTagsFromMetadata, isFileCanvas, - isFileFromDataloomPlugin, + isFileFromDataloom, isFileImage, isFileOffice, isFilePDF, @@ -135,7 +135,7 @@ export class CacheManager { } // ** Dataloom plugin ** - else if (isFileFromDataloomPlugin(path)) { + else if (isFileFromDataloom(path)) { try { const data = JSON.parse(await app.vault.cachedRead(file)) // data is a json object, we recursively iterate the keys diff --git a/src/components/ResultItemVault.svelte b/src/components/ResultItemVault.svelte index d5a6387..22f9ea6 100644 --- a/src/components/ResultItemVault.svelte +++ b/src/components/ResultItemVault.svelte @@ -3,7 +3,7 @@ import type { ResultNote } from '../globals' import { getExtension, - isFileCanvas, + isFileCanvas, isFileExcalidraw, isFileImage, isFilePDF, pathWithoutFilename, @@ -44,11 +44,18 @@ setIcon(elFolderPathIcon, 'folder-open') } if (elFilePathIcon) { - if (isFileImage(note.path)) setIcon(elFilePathIcon, 'image') - else if (isFilePDF(note.path)) setIcon(elFilePathIcon, 'file-text') - else if (isFileCanvas(note.path)) + if (isFileImage(note.path)) { + setIcon(elFilePathIcon, 'image') + } + else if (isFilePDF(note.path)) { + setIcon(elFilePathIcon, 'file-text') + } + else if (isFileCanvas(note.path) || isFileExcalidraw(note.path)) { setIcon(elFilePathIcon, 'layout-dashboard') - else setIcon(elFilePathIcon, 'file') + } + else { + setIcon(elFilePathIcon, 'file') + } } } diff --git a/src/notes-indexer.ts b/src/notes-indexer.ts index 89f51f7..c5e56f6 100644 --- a/src/notes-indexer.ts +++ b/src/notes-indexer.ts @@ -4,7 +4,7 @@ import { removeAnchors } from './tools/notes' import type { IndexedDocument } from './globals' import { isFileCanvas, - isFileFromDataloomPlugin, + isFileFromDataloom, isFileImage, isFilePDF, logDebug, @@ -49,7 +49,7 @@ export class NotesIndexer { return ( this.isFilePlaintext(path) || isFileCanvas(path) || - isFileFromDataloomPlugin(path) || + isFileFromDataloom(path) || (canIndexPDF && isFilePDF(path)) || (canIndexImages && isFileImage(path)) ) @@ -60,7 +60,7 @@ export class NotesIndexer { this.canIndexUnsupportedFiles() || this.isFilePlaintext(path) || isFileCanvas(path) || - isFileFromDataloomPlugin(path) + isFileFromDataloom(path) ) } diff --git a/src/tools/utils.ts b/src/tools/utils.ts index 664d1de..1c32558 100644 --- a/src/tools/utils.ts +++ b/src/tools/utils.ts @@ -152,7 +152,11 @@ export function isFileCanvas(path: string): boolean { return path.endsWith('.canvas') } -export function isFileFromDataloomPlugin(path: string): boolean { +export function isFileExcalidraw(path: string): boolean { + return path.endsWith('.excalidraw') +} + +export function isFileFromDataloom(path: string): boolean { return path.endsWith('.loom') }