Merge branch 'master' into feature/ocr

This commit is contained in:
Simon Cambier
2022-10-31 11:27:35 +01:00
6 changed files with 43 additions and 33 deletions

View File

@@ -1,7 +1,7 @@
{ {
"id": "omnisearch", "id": "omnisearch",
"name": "Omnisearch", "name": "Omnisearch",
"version": "1.7.8", "version": "1.7.10",
"minAppVersion": "1.0.0", "minAppVersion": "1.0.0",
"description": "A search engine that just works", "description": "A search engine that just works",
"author": "Simon Cambier", "author": "Simon Cambier",

View File

@@ -1,7 +1,7 @@
{ {
"id": "omnisearch", "id": "omnisearch",
"name": "Omnisearch", "name": "Omnisearch",
"version": "1.7.8", "version": "1.7.10",
"minAppVersion": "1.0.0", "minAppVersion": "1.0.0",
"description": "A search engine that just works", "description": "A search engine that just works",
"author": "Simon Cambier", "author": "Simon Cambier",

View File

@@ -1,6 +1,6 @@
{ {
"name": "scambier.obsidian-search", "name": "scambier.obsidian-search",
"version": "1.7.8", "version": "1.7.10",
"description": "A search engine for Obsidian", "description": "A search engine for Obsidian",
"main": "dist/main.js", "main": "dist/main.js",
"scripts": { "scripts": {

View File

@@ -48,8 +48,8 @@ export const minisearchOptions: Options<IndexedDocument> = {
} }
export class SearchEngine { export class SearchEngine {
private static engine: SearchEngine private static engine?: SearchEngine
private static tmpEngine: SearchEngine private static tmpEngine?: SearchEngine
public static isIndexing = writable(true) public static isIndexing = writable(true)
/** /**
@@ -92,12 +92,12 @@ export class SearchEngine {
* Loads the freshest indexed data into the main instance. * Loads the freshest indexed data into the main instance.
*/ */
public static loadTmpDataIntoMain(): void { public static loadTmpDataIntoMain(): void {
const tmpData = this.tmpEngine.minisearch.toJSON() const tmpData = this.getTmpEngine().minisearch.toJSON()
this.engine.minisearch = MiniSearch.loadJS(tmpData, minisearchOptions) this.getEngine().minisearch = MiniSearch.loadJS(tmpData, minisearchOptions)
} }
public static clearTmp(): void { public static clearTmp(): void {
this.tmpEngine.minisearch = new MiniSearch(minisearchOptions) this.getTmpEngine().minisearch = new MiniSearch(minisearchOptions)
} }
private minisearch: MiniSearch private minisearch: MiniSearch

View File

@@ -134,7 +134,7 @@ export class SettingsTab extends PluginSettingTab {
new Setting(containerEl) new Setting(containerEl)
.setName('Retry queries that return zero result') .setName('Retry queries that return zero result')
.setDesc( .setDesc(
`When a query returns zero result, Omnisearch will try again (but harder). Enabling this may incur some freezes.` `When a query returns zero result, Omnisearch will try again (but harder). Disabling this can improve search reactivity.`
) )
.addToggle(toggle => .addToggle(toggle =>
toggle.setValue(settings.retryWhenZeroResult).onChange(async v => { toggle.setValue(settings.retryWhenZeroResult).onChange(async v => {
@@ -143,27 +143,29 @@ export class SettingsTab extends PluginSettingTab {
}) })
) )
// PDF Indexing // PDF Indexing - disabled on iOS
const indexPDFsDesc = new DocumentFragment() if (!Platform.isIosApp) {
indexPDFsDesc.createSpan({}, span => { const indexPDFsDesc = new DocumentFragment()
span.innerHTML = `Omnisearch will include PDFs in search results. indexPDFsDesc.createSpan({}, span => {
<ul> span.innerHTML = `Omnisearch will include PDFs in search results.
<li>⚠️ Depending on their size, PDFs can take anywhere from a few seconds to 2 minutes to be processed.</li> <ul>
<li>⚠️ Texts extracted from PDFs may contain errors such as missing spaces, or spaces in the middle of words.</li> <li>⚠️ Depending on their size, PDFs can take anywhere from a few seconds to 2 minutes to be processed.</li>
<li>⚠️ Some PDFs can't be processed correctly and will return an empty text.</li> <li>⚠️ Texts extracted from PDFs may contain errors such as missing spaces, or spaces in the middle of words.</li>
<li>This feature is currently a work-in-progress, please report issues that you might experience.</li> <li>⚠️ Some PDFs can't be processed correctly and will return an empty text.</li>
</ul> <li>This feature is currently a work-in-progress, please report issues that you might experience.</li>
<strong style="color: var(--text-accent)">Needs a restart to fully take effect.</strong>` </ul>
}) <strong style="color: var(--text-accent)">Needs a restart to fully take effect.</strong>`
new Setting(containerEl) })
.setName('BETA - PDF Indexing') new Setting(containerEl)
.setDesc(indexPDFsDesc) .setName('BETA - PDF Indexing')
.addToggle(toggle => .setDesc(indexPDFsDesc)
toggle.setValue(settings.PDFIndexing).onChange(async v => { .addToggle(toggle =>
settings.PDFIndexing = v toggle.setValue(settings.PDFIndexing).onChange(async v => {
await saveSettings(this.plugin) settings.PDFIndexing = v
}) await saveSettings(this.plugin)
) })
)
}
// #endregion Behavior // #endregion Behavior
// #region User Interface // #region User Interface
@@ -308,7 +310,7 @@ export const DEFAULT_SETTINGS: OmnisearchSettings = {
showExcerpt: true, showExcerpt: true,
showCreateButton: false, showCreateButton: false,
showPreviousQueryResults: true, showPreviousQueryResults: true,
retryWhenZeroResult: false, retryWhenZeroResult: true,
weightBasename: 2, weightBasename: 2,
weightH1: 1.5, weightH1: 1.5,
@@ -324,6 +326,12 @@ export let settings = Object.assign({}, DEFAULT_SETTINGS) as OmnisearchSettings
export async function loadSettings(plugin: Plugin): Promise<void> { export async function loadSettings(plugin: Plugin): Promise<void> {
settings = Object.assign({}, DEFAULT_SETTINGS, await plugin.loadData()) settings = Object.assign({}, DEFAULT_SETTINGS, await plugin.loadData())
// Make sure that PDF indexing is disabled on iOS
if (Platform.isIosApp) {
settings.PDFIndexing = false
}
showExcerpt.set(settings.showExcerpt) showExcerpt.set(settings.showExcerpt)
} }

View File

@@ -66,5 +66,7 @@
"1.7.5": "1.0.0", "1.7.5": "1.0.0",
"1.7.6": "1.0.0", "1.7.6": "1.0.0",
"1.7.7": "1.0.0", "1.7.7": "1.0.0",
"1.7.8": "1.0.0" "1.7.8": "1.0.0",
"1.7.9": "1.0.0",
"1.7.10": "1.0.0"
} }