diff --git a/src/cache-manager.ts b/src/cache-manager.ts index 9a96fbc..867977c 100644 --- a/src/cache-manager.ts +++ b/src/cache-manager.ts @@ -13,6 +13,7 @@ import { isFileFromDataloomPlugin, isFileImage, isFilePDF, + isFileOffice, isFilePlaintext, isFilenameIndexable, logDebug, @@ -106,6 +107,15 @@ async function getAndMapIndexedDocument( content = await extractor.extractText(file) } + // ** Office document ** + else if ( + isFileOffice(path) && + settings.officeIndexing && + extractor?.canFileBeExtracted(path) + ) { + content = await extractor.extractText(file) + } + // ** Unsupported files ** else if (isFilenameIndexable(path)) { content = file.path diff --git a/src/settings.ts b/src/settings.ts index 1d3946c..30514fc 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -37,6 +37,9 @@ export interface OmnisearchSettings extends WeightingSettings { PDFIndexing: boolean /** Enable Images indexing */ imagesIndexing: boolean + /** Enable Office documents indexing */ + officeIndexing: boolean + /** Enable indexing of unknown files */ unsupportedFilesIndexing: 'yes' | 'no' | 'default' /** Activate the small 🔍 button on Obsidian's ribbon */ @@ -158,11 +161,30 @@ export class SettingsTab extends PluginSettingTab { ) .setDisabled(!getTextExtractor()) + // Office Documents Indexing + const indexOfficesDesc = new DocumentFragment() + indexOfficesDesc.createSpan({}, span => { + span.innerHTML = `Omnisearch will use Text Extractor to index the content of your office documents (currently
.docxand
.xlsx)` + }) + new Setting(containerEl) + .setName( + `Documents content indexing ${getTextExtractor() ? '' : '⚠️ Disabled'}` + ) + .setDesc(indexOfficesDesc) + .addToggle(toggle => + toggle.setValue(settings.officeIndexing).onChange(async v => { + await database.clearCache() + settings.officeIndexing = v + await saveSettings(this.plugin) + }) + ) + .setDisabled(!getTextExtractor()) + // Index filenames of unsupported files const indexUnsupportedDesc = new DocumentFragment() indexUnsupportedDesc.createSpan({}, span => { span.innerHTML = ` - Omnisearch can index filenames of "unsupported" files, such as e.g.
.mp4,
.xlsx, + Omnisearch can index filenames of "unsupported" files, such as e.g.
.mp4or non-extracted PDFs & images.
md files, Omnisearch can also index other PLAINTEXT files.txt org csv".