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:
11
src/main.ts
11
src/main.ts
@@ -28,6 +28,7 @@ import { CacheManager } from './cache-manager'
|
||||
import { logDebug } from './tools/utils'
|
||||
import { NotesIndexer } from './notes-indexer'
|
||||
import { TextProcessor } from './tools/text-processing'
|
||||
import { EmbedsRepository } from './repositories/embeds-repository'
|
||||
|
||||
export default class OmnisearchPlugin extends Plugin {
|
||||
// FIXME: fix the type
|
||||
@@ -42,6 +43,8 @@ export default class OmnisearchPlugin extends Plugin {
|
||||
public readonly textProcessor = new TextProcessor(this)
|
||||
public readonly searchEngine = new SearchEngine(this)
|
||||
|
||||
public readonly embedsRepository = new EmbedsRepository(this)
|
||||
|
||||
private ribbonButton?: HTMLElement
|
||||
private refreshIndexCallback?: () => void
|
||||
|
||||
@@ -109,6 +112,7 @@ export default class OmnisearchPlugin extends Plugin {
|
||||
if (this.notesIndexer.isFileIndexable(file.path)) {
|
||||
logDebug('Indexing new file', file.path)
|
||||
searchEngine.addFromPaths([file.path])
|
||||
this.embedsRepository.refreshEmbeds(file.path)
|
||||
}
|
||||
})
|
||||
)
|
||||
@@ -117,6 +121,7 @@ export default class OmnisearchPlugin extends Plugin {
|
||||
logDebug('Removing file', file.path)
|
||||
this.cacheManager.removeFromLiveCache(file.path)
|
||||
searchEngine.removeFromPaths([file.path])
|
||||
this.embedsRepository.refreshEmbeds(file.path)
|
||||
})
|
||||
)
|
||||
this.registerEvent(
|
||||
@@ -124,6 +129,7 @@ export default class OmnisearchPlugin extends Plugin {
|
||||
if (this.notesIndexer.isFileIndexable(file.path)) {
|
||||
this.notesIndexer.flagNoteForReindex(file)
|
||||
}
|
||||
this.embedsRepository.refreshEmbeds(file.path)
|
||||
})
|
||||
)
|
||||
this.registerEvent(
|
||||
@@ -240,7 +246,7 @@ export default class OmnisearchPlugin extends Plugin {
|
||||
}
|
||||
}
|
||||
|
||||
const diff = searchEngine.getDiff(
|
||||
const diff = searchEngine.getDocumentsToReindex(
|
||||
files.map(f => ({ path: f.path, mtime: f.stat.mtime }))
|
||||
)
|
||||
|
||||
@@ -281,7 +287,8 @@ export default class OmnisearchPlugin extends Plugin {
|
||||
}
|
||||
|
||||
// Write the cache
|
||||
await searchEngine.writeToCache()
|
||||
await this.database.writeMinisearchCache()
|
||||
await this.embedsRepository.writeToCache()
|
||||
|
||||
// Re-enable settings.caching
|
||||
if (cacheEnabled) {
|
||||
|
||||
Reference in New Issue
Block a user