Fixed #60
This commit is contained in:
12
src/main.ts
12
src/main.ts
@@ -6,7 +6,7 @@ import {
|
|||||||
removeFromIndex,
|
removeFromIndex,
|
||||||
} from './search'
|
} from './search'
|
||||||
import { OmnisearchInFileModal, OmnisearchVaultModal } from './modals'
|
import { OmnisearchInFileModal, OmnisearchVaultModal } from './modals'
|
||||||
import { loadSettings, SettingsTab } from './settings'
|
import { loadSettings, settings, SettingsTab } from './settings'
|
||||||
import { eventBus } from './globals'
|
import { eventBus } from './globals'
|
||||||
import { registerAPI } from '@vanakat/plugin-api'
|
import { registerAPI } from '@vanakat/plugin-api'
|
||||||
import api from './api'
|
import api from './api'
|
||||||
@@ -33,6 +33,10 @@ export default class OmnisearchPlugin extends Plugin {
|
|||||||
|
|
||||||
_registerAPI(this)
|
_registerAPI(this)
|
||||||
|
|
||||||
|
if (settings.ribbonIcon) {
|
||||||
|
this.addRibbonButton()
|
||||||
|
}
|
||||||
|
|
||||||
this.addSettingTab(new SettingsTab(this))
|
this.addSettingTab(new SettingsTab(this))
|
||||||
eventBus.disable('vault')
|
eventBus.disable('vault')
|
||||||
eventBus.disable('infile')
|
eventBus.disable('infile')
|
||||||
@@ -85,4 +89,10 @@ export default class OmnisearchPlugin extends Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onunload(): void {}
|
onunload(): void {}
|
||||||
|
|
||||||
|
addRibbonButton(): void {
|
||||||
|
this.addRibbonIcon('search', 'Omnisearch', evt => {
|
||||||
|
new OmnisearchVaultModal(app).open()
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ export interface OmnisearchSettings extends WeightingSettings {
|
|||||||
respectExcluded: boolean
|
respectExcluded: boolean
|
||||||
ignoreDiacritics: boolean
|
ignoreDiacritics: boolean
|
||||||
showIndexingNotices: boolean
|
showIndexingNotices: boolean
|
||||||
|
ribbonIcon: boolean
|
||||||
showShortName: boolean
|
showShortName: boolean
|
||||||
CtrlJK: boolean
|
CtrlJK: boolean
|
||||||
CtrlNP: boolean
|
CtrlNP: boolean
|
||||||
@@ -93,6 +94,20 @@ export class SettingsTab extends PluginSettingTab {
|
|||||||
|
|
||||||
new Setting(containerEl).setName('User Interface').setHeading()
|
new Setting(containerEl).setName('User Interface').setHeading()
|
||||||
|
|
||||||
|
// Show Ribbon Icon
|
||||||
|
new Setting(containerEl)
|
||||||
|
.setName('Show ribbon button')
|
||||||
|
.setDesc('Add a button on the sidebar to open the Vault search modal. Needs a restart to remove the button.')
|
||||||
|
.addToggle(toggle =>
|
||||||
|
toggle.setValue(settings.ribbonIcon).onChange(async v => {
|
||||||
|
settings.ribbonIcon = v
|
||||||
|
await saveSettings(this.plugin)
|
||||||
|
if (v) {
|
||||||
|
this.plugin.addRibbonButton()
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
// Show notices
|
// Show notices
|
||||||
new Setting(containerEl)
|
new Setting(containerEl)
|
||||||
.setName('Show indexing notices')
|
.setName('Show indexing notices')
|
||||||
@@ -189,6 +204,7 @@ export const DEFAULT_SETTINGS: OmnisearchSettings = {
|
|||||||
|
|
||||||
showIndexingNotices: false,
|
showIndexingNotices: false,
|
||||||
showShortName: false,
|
showShortName: false,
|
||||||
|
ribbonIcon: true,
|
||||||
|
|
||||||
weightBasename: 2,
|
weightBasename: 2,
|
||||||
weightH1: 1.5,
|
weightH1: 1.5,
|
||||||
|
|||||||
Reference in New Issue
Block a user