Added some labels for Text Extractor
This commit is contained in:
@@ -25,15 +25,20 @@ async function getIndexedDocument(path: string): Promise<IndexedDocument> {
|
|||||||
let content: string | null = null
|
let content: string | null = null
|
||||||
|
|
||||||
const extractor = getTextExtractor()
|
const extractor = getTextExtractor()
|
||||||
|
// Plain text
|
||||||
if (isFilePlaintext(path)) {
|
if (isFilePlaintext(path)) {
|
||||||
content = await app.vault.cachedRead(file)
|
content = await app.vault.cachedRead(file)
|
||||||
} else if (extractor) {
|
}
|
||||||
|
// Image or PDF, with the text-extractor plugin
|
||||||
|
else if (extractor) {
|
||||||
if (extractor.canFileBeExtracted(path)) {
|
if (extractor.canFileBeExtracted(path)) {
|
||||||
content = await extractor.extractText(file)
|
content = await extractor.extractText(file)
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Invalid file format: ' + file.path)
|
throw new Error('Invalid file format: ' + file.path)
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
// Image or PDF, without the text-extractor plugin
|
||||||
|
else {
|
||||||
if (isFilePDF(path)) {
|
if (isFilePDF(path)) {
|
||||||
content = await getPdfText(file)
|
content = await getPdfText(file)
|
||||||
} else if (isFileImage(file.path)) {
|
} else if (isFileImage(file.path)) {
|
||||||
|
|||||||
@@ -192,15 +192,13 @@ async function cleanOldCacheFiles() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function executeFirstLaunchTasks(plugin: Plugin) {
|
function executeFirstLaunchTasks(plugin: Plugin) {
|
||||||
const code = '1.8.0-beta.3'
|
const code = '1.10.0-beta.1'
|
||||||
if (settings.welcomeMessage !== code) {
|
if (settings.welcomeMessage !== code) {
|
||||||
const welcome = new DocumentFragment()
|
const welcome = new DocumentFragment()
|
||||||
welcome.createSpan({}, span => {
|
welcome.createSpan({}, span => {
|
||||||
span.innerHTML = `<strong>Omnisearch has been updated</strong>
|
span.innerHTML = `🔎 Omnisearch will soon require the <strong>Text Extractor</strong> plugin to index PDF and images. See Omnisearch settings for more information.`
|
||||||
You can now enable "Images Indexing" to use Optical Character Recognition on your scanned documents
|
|
||||||
🔎🖼`
|
|
||||||
})
|
})
|
||||||
new Notice(welcome, 30000)
|
new Notice(welcome, 20_000)
|
||||||
}
|
}
|
||||||
settings.welcomeMessage = code
|
settings.welcomeMessage = code
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
} from 'obsidian'
|
} from 'obsidian'
|
||||||
import { writable } from 'svelte/store'
|
import { writable } from 'svelte/store'
|
||||||
import { database } from './database'
|
import { database } from './database'
|
||||||
|
import { getTextExtractor } from './globals'
|
||||||
import type OmnisearchPlugin from './main'
|
import type OmnisearchPlugin from './main'
|
||||||
|
|
||||||
interface WeightingSettings {
|
interface WeightingSettings {
|
||||||
@@ -83,6 +84,20 @@ export class SettingsTab extends PluginSettingTab {
|
|||||||
|
|
||||||
new Setting(containerEl).setName('Indexing').setHeading()
|
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 <a href="https://github.com/scambier/obsidian-text-extractor">Text Extractor</a> to index PDFs and images.
|
||||||
|
You can already install it to get a head start.`
|
||||||
|
})
|
||||||
|
new Setting(containerEl).setDesc(label)
|
||||||
|
}
|
||||||
|
|
||||||
// PDF Indexing
|
// PDF Indexing
|
||||||
if (!Platform.isMobileApp) {
|
if (!Platform.isMobileApp) {
|
||||||
const indexPDFsDesc = new DocumentFragment()
|
const indexPDFsDesc = new DocumentFragment()
|
||||||
|
|||||||
Reference in New Issue
Block a user