Text Extractor requirement
This commit is contained in:
@@ -105,11 +105,11 @@ export default class OmnisearchPlugin extends Plugin {
|
||||
}
|
||||
|
||||
executeFirstLaunchTasks(): void {
|
||||
const code = '1.10.0-beta.1'
|
||||
const code = '1.10.1'
|
||||
if (settings.welcomeMessage !== code) {
|
||||
const welcome = new DocumentFragment()
|
||||
welcome.createSpan({}, span => {
|
||||
span.innerHTML = `🔎 Omnisearch will soon require the <strong>Text Extractor</strong> plugin to index PDF and images. See Omnisearch settings for more information.`
|
||||
span.innerHTML = `🔎 Omnisearch now requires the <strong>Text Extractor</strong> plugin to index PDF and images. See Omnisearch settings for more information.`
|
||||
})
|
||||
new Notice(welcome, 20_000)
|
||||
}
|
||||
|
||||
@@ -86,53 +86,50 @@ export class SettingsTab extends PluginSettingTab {
|
||||
|
||||
new Setting(containerEl).setName('Indexing').setHeading()
|
||||
|
||||
const textExtractDesc = new DocumentFragment()
|
||||
if (getTextExtractor()) {
|
||||
const desc = new DocumentFragment()
|
||||
desc.createSpan({}, span => {
|
||||
textExtractDesc.createSpan({}, span => {
|
||||
span.innerHTML = `👍 You have installed <a href="https://github.com/scambier/obsidian-text-extractor">Text Extractor</a>, Omnisearch will use it to index PDFs and images.
|
||||
<br />Text extraction only works on desktop, but the cache can be synchronized with your mobile device.`
|
||||
})
|
||||
new Setting(containerEl).setDesc(desc)
|
||||
} 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.`
|
||||
textExtractDesc.createSpan({}, span => {
|
||||
span.innerHTML = `⚠️ Omnisearch requires <a href="https://github.com/scambier/obsidian-text-extractor">Text Extractor</a> to index PDFs and images.`
|
||||
})
|
||||
new Setting(containerEl).setDesc(label)
|
||||
}
|
||||
new Setting(containerEl).setDesc(textExtractDesc)
|
||||
|
||||
// PDF Indexing
|
||||
if (!Platform.isMobileApp || getTextExtractor()) {
|
||||
const indexPDFsDesc = new DocumentFragment()
|
||||
indexPDFsDesc.createSpan({}, span => {
|
||||
span.innerHTML = `Include PDFs in search results - Will soon depend on Text Extractor.`
|
||||
})
|
||||
new Setting(containerEl)
|
||||
.setName(`PDFs Indexing`)
|
||||
.setDesc(indexPDFsDesc)
|
||||
.addToggle(toggle =>
|
||||
toggle.setValue(settings.PDFIndexing).onChange(async v => {
|
||||
settings.PDFIndexing = v
|
||||
await saveSettings(this.plugin)
|
||||
})
|
||||
)
|
||||
const indexPDFsDesc = new DocumentFragment()
|
||||
indexPDFsDesc.createSpan({}, span => {
|
||||
span.innerHTML = `Include PDFs in search results`
|
||||
})
|
||||
new Setting(containerEl)
|
||||
.setName(`PDFs Indexing ${getTextExtractor() ? '' : '⚠️ Disabled'}`)
|
||||
.setDesc(indexPDFsDesc)
|
||||
.addToggle(toggle =>
|
||||
toggle.setValue(settings.PDFIndexing).onChange(async v => {
|
||||
settings.PDFIndexing = v
|
||||
await saveSettings(this.plugin)
|
||||
})
|
||||
)
|
||||
.setDisabled(!getTextExtractor())
|
||||
|
||||
// Images Indexing
|
||||
const indexImagesDesc = new DocumentFragment()
|
||||
indexImagesDesc.createSpan({}, span => {
|
||||
span.innerHTML = `Include images in search results - Will soon depend on Text Extractor.`
|
||||
})
|
||||
new Setting(containerEl)
|
||||
.setName(`Images Indexing`)
|
||||
.setDesc(indexImagesDesc)
|
||||
.addToggle(toggle =>
|
||||
toggle.setValue(settings.imagesIndexing).onChange(async v => {
|
||||
settings.imagesIndexing = v
|
||||
await saveSettings(this.plugin)
|
||||
})
|
||||
)
|
||||
}
|
||||
// Images Indexing
|
||||
const indexImagesDesc = new DocumentFragment()
|
||||
indexImagesDesc.createSpan({}, span => {
|
||||
span.innerHTML = `Include images in search results`
|
||||
})
|
||||
new Setting(containerEl)
|
||||
.setName(`Images Indexing ${getTextExtractor() ? '' : '⚠️ Disabled'}`)
|
||||
.setDesc(indexImagesDesc)
|
||||
.addToggle(toggle =>
|
||||
toggle.setValue(settings.imagesIndexing).onChange(async v => {
|
||||
settings.imagesIndexing = v
|
||||
await saveSettings(this.plugin)
|
||||
})
|
||||
)
|
||||
.setDisabled(!getTextExtractor())
|
||||
|
||||
// Additional files to index
|
||||
const indexedFileTypesDesc = new DocumentFragment()
|
||||
|
||||
@@ -5,16 +5,17 @@ import {
|
||||
parseFrontMatterAliases,
|
||||
Platform,
|
||||
} from 'obsidian'
|
||||
import { getTextExtractor, type SearchMatch } from '../globals'
|
||||
import {
|
||||
excerptAfter,
|
||||
excerptBefore,
|
||||
getChsSegmenter,
|
||||
getTextExtractor,
|
||||
highlightClass,
|
||||
isSearchMatch,
|
||||
regexLineSplit,
|
||||
regexStripQuotes,
|
||||
regexYaml,
|
||||
type SearchMatch,
|
||||
} from '../globals'
|
||||
import { settings } from '../settings'
|
||||
import { type BinaryLike, createHash } from 'crypto'
|
||||
@@ -236,8 +237,8 @@ export function getCtrlKeyLabel(): 'ctrl' | '⌘' {
|
||||
}
|
||||
|
||||
export function isFileIndexable(path: string): boolean {
|
||||
const canIndexPDF = (!Platform.isMobileApp || !!getTextExtractor()) && settings.PDFIndexing
|
||||
const canIndexImages = (!Platform.isMobileApp || !!getTextExtractor()) && settings.imagesIndexing
|
||||
const canIndexPDF = !!getTextExtractor() && settings.PDFIndexing
|
||||
const canIndexImages = !!getTextExtractor() && settings.imagesIndexing
|
||||
return (
|
||||
isFilePlaintext(path) ||
|
||||
isFileCanvas(path) ||
|
||||
|
||||
Reference in New Issue
Block a user