From 2854bb78b6f88b22d218382dad0c7372543d1c11 Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Tue, 3 Jan 2023 10:25:38 +0100 Subject: [PATCH] Added some labels for Text Extractor --- src/cache-manager.ts | 9 +++++++-- src/main.ts | 8 +++----- src/settings.ts | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/cache-manager.ts b/src/cache-manager.ts index 502ef9d..faa87e0 100644 --- a/src/cache-manager.ts +++ b/src/cache-manager.ts @@ -25,15 +25,20 @@ async function getIndexedDocument(path: string): Promise { let content: string | null = null const extractor = getTextExtractor() + // Plain text if (isFilePlaintext(path)) { content = await app.vault.cachedRead(file) - } else if (extractor) { + } + // Image or PDF, with the text-extractor plugin + else if (extractor) { if (extractor.canFileBeExtracted(path)) { content = await extractor.extractText(file) } else { throw new Error('Invalid file format: ' + file.path) } - } else { + } + // Image or PDF, without the text-extractor plugin + else { if (isFilePDF(path)) { content = await getPdfText(file) } else if (isFileImage(file.path)) { diff --git a/src/main.ts b/src/main.ts index d77ce59..28f10ae 100644 --- a/src/main.ts +++ b/src/main.ts @@ -192,15 +192,13 @@ async function cleanOldCacheFiles() { } function executeFirstLaunchTasks(plugin: Plugin) { - const code = '1.8.0-beta.3' + const code = '1.10.0-beta.1' if (settings.welcomeMessage !== code) { const welcome = new DocumentFragment() welcome.createSpan({}, span => { - span.innerHTML = `Omnisearch has been updated -You can now enable "Images Indexing" to use Optical Character Recognition on your scanned documents -🔎🖼` + span.innerHTML = `🔎 Omnisearch will soon require the Text Extractor plugin to index PDF and images. See Omnisearch settings for more information.` }) - new Notice(welcome, 30000) + new Notice(welcome, 20_000) } settings.welcomeMessage = code diff --git a/src/settings.ts b/src/settings.ts index d503a99..a0a281a 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -8,6 +8,7 @@ import { } from 'obsidian' import { writable } from 'svelte/store' import { database } from './database' +import { getTextExtractor } from './globals' import type OmnisearchPlugin from './main' interface WeightingSettings { @@ -83,6 +84,20 @@ export class SettingsTab extends PluginSettingTab { new Setting(containerEl).setName('Indexing').setHeading() + if (getTextExtractor()) { + new Setting(containerEl).setDesc( + '👍 You have installed Text Extractor, Omnisearch will use it to index PDFs and images.' + ) + } else { + const label = new DocumentFragment() + label.createSpan({}, span => { + span.innerHTML = + `⚠️ Omnisearch will soon require Text Extractor to index PDFs and images. + You can already install it to get a head start.` + }) + new Setting(containerEl).setDesc(label) + } + // PDF Indexing if (!Platform.isMobileApp) { const indexPDFsDesc = new DocumentFragment()