diff --git a/src/main.ts b/src/main.ts index 945e709..ed9f125 100644 --- a/src/main.ts +++ b/src/main.ts @@ -223,14 +223,6 @@ export default class LocatorPlugin extends Plugin { return (this.app as any).plugins?.plugins?.['text-extractor']?.api } - /** - * Plugin dependency - Ai Image Analyzer - * @returns - */ - public getAIImageAnalyzer(): AIImageAnalyzerAPI | undefined { - return (this.app as any).plugins?.plugins?.['ai-image-analyzer']?.api - } - private async populateIndex(): Promise { console.time('Indexing total time') indexingStep.set(IndexingStepType.ReadingFiles) diff --git a/src/notes-indexer.ts b/src/notes-indexer.ts index 61e9e5d..76e9ba8 100644 --- a/src/notes-indexer.ts +++ b/src/notes-indexer.ts @@ -1,7 +1,7 @@ import type { TAbstractFile } from 'obsidian' +import type { IndexedDocument } from './globals' import type LocatorPlugin from './main' import { removeAnchors } from './tools/notes' -import type { IndexedDocument } from './globals' import { isFileCanvas, isFileFromDataloom, @@ -44,17 +44,14 @@ export class NotesIndexer { public isContentIndexable(path: string): boolean { const settings = this.plugin.settings const hasTextExtractor = !!this.plugin.getTextExtractor() - const hasAIImageAnalyzer = !!this.plugin.getAIImageAnalyzer() const canIndexPDF = hasTextExtractor && settings.PDFIndexing const canIndexImages = hasTextExtractor && settings.imagesIndexing - const canIndexImagesAI = hasAIImageAnalyzer && settings.aiImageIndexing return ( this.isFilePlaintext(path) || isFileCanvas(path) || isFileFromDataloom(path) || (canIndexPDF && isFilePDF(path)) || - (canIndexImages && isFileImage(path)) || - (canIndexImagesAI && isFileImage(path)) + (canIndexImages && isFileImage(path)) ) } diff --git a/src/repositories/documents-repository.ts b/src/repositories/documents-repository.ts index a5bd5e1..cc96987 100644 --- a/src/repositories/documents-repository.ts +++ b/src/repositories/documents-repository.ts @@ -1,5 +1,8 @@ -import { normalizePath, Notice, TFile } from 'obsidian' +import { normalizePath, TFile } from 'obsidian' +import type { CanvasData } from 'obsidian/canvas' import type { IndexedDocument } from '../globals' +import type LocatorPlugin from '../main' +import { getNonExistingNotes } from '../tools/notes' import { countError, extractHeadingsFromCache, @@ -14,9 +17,6 @@ import { removeDiacritics, stripMarkdownCharacters, } from '../tools/utils' -import type { CanvasData } from 'obsidian/canvas' -import type LocatorPlugin from '../main' -import { getNonExistingNotes } from '../tools/notes' export class DocumentsRepository { /** @@ -96,7 +96,6 @@ export class DocumentsRepository { let content: string | null = null const extractor = this.plugin.getTextExtractor() - const aiImageAnalyzer = this.plugin.getAIImageAnalyzer() // ** Plain text ** // Just read the file content @@ -151,10 +150,8 @@ export class DocumentsRepository { // ** Image ** else if ( isFileImage(path) && - ((this.plugin.settings.imagesIndexing && - extractor?.canFileBeExtracted(path)) || - (this.plugin.settings.aiImageIndexing && - aiImageAnalyzer?.canBeAnalyzed(file))) + (this.plugin.settings.imagesIndexing && + extractor?.canFileBeExtracted(path)) ) { if ( this.plugin.settings.imagesIndexing && @@ -162,13 +159,6 @@ export class DocumentsRepository { ) { content = await extractor.extractText(file) } - - if ( - this.plugin.settings.aiImageIndexing && - aiImageAnalyzer?.canBeAnalyzed(file) - ) { - content = (await aiImageAnalyzer.analyzeImage(file)) + (content ?? '') - } } // ** PDF ** else if ( diff --git a/src/settings/index.ts b/src/settings/index.ts index d8df7ce..d6f1046 100644 --- a/src/settings/index.ts +++ b/src/settings/index.ts @@ -94,7 +94,6 @@ export function getDefaultSettings(app: App): LocatorSettings { PDFIndexing: false, officeIndexing: false, imagesIndexing: false, - aiImageIndexing: false, unsupportedFilesIndexing: 'default', splitCamelCase: false, openInNewPane: false, diff --git a/src/settings/settings-indexing.ts b/src/settings/settings-indexing.ts index dd0bd23..ee7c29f 100644 --- a/src/settings/settings-indexing.ts +++ b/src/settings/settings-indexing.ts @@ -11,7 +11,6 @@ export function injectSettingsIndexing( containerEl: HTMLElement ) { const textExtractor = plugin.getTextExtractor() - const aiImageAnalyzer = plugin.getAIImageAnalyzer() const database = plugin.database const clearCacheDebounced = debounce(async () => { @@ -28,11 +27,6 @@ export function injectSettingsIndexing( ? `👍 You have installed Text Extractor, Locator can use it to index PDFs and images contents.
Text extraction only works on desktop, but the cache can be synchronized with your mobile device.` : `⚠️ Locator requires Text Extractor to index PDFs and images.` - } - ${ - aiImageAnalyzer - ? `
👍 You have installed AI Image Analyzer, Locator can use it to index images contents with ai.` - : `
⚠️ Locator requires AI Image Analyzer to index images with ai.` }`) ) @@ -87,23 +81,6 @@ export function injectSettingsIndexing( ) .setDisabled(!textExtractor) - // AI Images Indexing - const aiIndexImagesDesc = new DocumentFragment() - aiIndexImagesDesc.createSpan({}, span => { - span.innerHTML = `Locator will use AI Image Analyzer to index the content of your images with ai.` - }) - new Setting(containerEl) - .setName(`Images AI indexing ${aiImageAnalyzer ? '' : '⚠️ Disabled'}`) - .setDesc(aiIndexImagesDesc) - .addToggle(toggle => - toggle.setValue(settings.aiImageIndexing).onChange(async v => { - await database.clearCache() - settings.aiImageIndexing = v - await saveSettings(plugin) - }) - ) - .setDisabled(!aiImageAnalyzer) - // Index filenames of unsupported files new Setting(containerEl) .setName('Index paths of unsupported files') @@ -115,7 +92,7 @@ export function injectSettingsIndexing( ) .addDropdown(dropdown => { dropdown - .addOptions({ yes: 'Yes', no: 'No', default: 'Obsidian setting' }) + .addOptions({ yes: 'Yes', no: 'No', default: 'Obsidian default' }) .setValue(settings.unsupportedFilesIndexing) .onChange(async v => { await clearCacheDebounced() diff --git a/src/settings/utils.ts b/src/settings/utils.ts index 20d07ab..6646714 100644 --- a/src/settings/utils.ts +++ b/src/settings/utils.ts @@ -49,9 +49,7 @@ export interface LocatorSettings extends WeightingSettings { imagesIndexing: boolean /** Enable Office documents indexing */ officeIndexing: boolean - /** Enable image ai indexing */ - aiImageIndexing: boolean - + /** Enable indexing of unknown files */ unsupportedFilesIndexing: 'yes' | 'no' | 'default' /** Activate the small 🔍 button on Obsidian's ribbon */