feat(#245): in results list, show where an image/pdf is embedded
* Add an index of embeds for reference in results * Notes embedding images are now shown in results * Updated dependencies * Correctly referencing all embeds * Updated docs * Basic embedded feature ok
This commit is contained in:
+9
-9
@@ -1,12 +1,11 @@
|
||||
import Dexie from 'dexie'
|
||||
import type MiniSearch from 'minisearch'
|
||||
import type { AsPlainObject } from 'minisearch'
|
||||
import type { DocumentRef } from './globals'
|
||||
import { Notice } from 'obsidian'
|
||||
import type OmnisearchPlugin from './main'
|
||||
|
||||
export class Database extends Dexie {
|
||||
public static readonly dbVersion = 8
|
||||
public static readonly dbVersion = 9
|
||||
searchHistory!: Dexie.Table<{ id?: number; query: string }, number>
|
||||
minisearch!: Dexie.Table<
|
||||
{
|
||||
@@ -16,6 +15,7 @@ export class Database extends Dexie {
|
||||
},
|
||||
string
|
||||
>
|
||||
embeds!: Dexie.Table<{ embedded: string; references: string[] }, string>
|
||||
|
||||
constructor(private plugin: OmnisearchPlugin) {
|
||||
super(Database.getDbName(plugin.app.appId))
|
||||
@@ -23,6 +23,7 @@ export class Database extends Dexie {
|
||||
this.version(Database.dbVersion).stores({
|
||||
searchHistory: '++id',
|
||||
minisearch: 'date',
|
||||
embeds: 'embedded',
|
||||
})
|
||||
}
|
||||
|
||||
@@ -49,17 +50,15 @@ export class Database extends Dexie {
|
||||
}
|
||||
}
|
||||
|
||||
public async writeMinisearchCache(
|
||||
minisearch: MiniSearch,
|
||||
indexed: Map<string, number>
|
||||
): Promise<void> {
|
||||
const paths = Array.from(indexed).map(([k, v]) => ({ path: k, mtime: v }))
|
||||
public async writeMinisearchCache(): Promise<void> {
|
||||
const minisearchJson = this.plugin.searchEngine.getSerializedMiniSearch()
|
||||
const paths = this.plugin.searchEngine.getSerializedIndexedDocuments()
|
||||
const database = this.plugin.database
|
||||
await database.minisearch.clear()
|
||||
await database.minisearch.add({
|
||||
date: new Date().toISOString(),
|
||||
paths,
|
||||
data: minisearch.toJSON(),
|
||||
data: minisearchJson,
|
||||
})
|
||||
console.log('Omnisearch - Search cache written')
|
||||
}
|
||||
@@ -85,7 +84,8 @@ export class Database extends Dexie {
|
||||
}
|
||||
|
||||
public async clearCache() {
|
||||
new Notice('Omnisearch - Cache cleared. Please restart Obsidian.')
|
||||
await this.minisearch.clear()
|
||||
await this.embeds.clear()
|
||||
new Notice('Omnisearch - Cache cleared. Please restart Obsidian.')
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user