Skip to content

Commit

Permalink
Fixed #60
Browse files Browse the repository at this point in the history
  • Loading branch information
scambier committed Jul 14, 2022
1 parent 7ea07e1 commit 19cc972
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
removeFromIndex,
} from './search'
import { OmnisearchInFileModal, OmnisearchVaultModal } from './modals'
import { loadSettings, SettingsTab } from './settings'
import { loadSettings, settings, SettingsTab } from './settings'
import { eventBus } from './globals'
import { registerAPI } from '@vanakat/plugin-api'
import api from './api'
Expand All @@ -33,6 +33,10 @@ export default class OmnisearchPlugin extends Plugin {

_registerAPI(this)

if (settings.ribbonIcon) {
this.addRibbonButton()
}

this.addSettingTab(new SettingsTab(this))
eventBus.disable('vault')
eventBus.disable('infile')
Expand Down Expand Up @@ -85,4 +89,10 @@ export default class OmnisearchPlugin extends Plugin {
}

onunload(): void {}

addRibbonButton(): void {
this.addRibbonIcon('search', 'Omnisearch', evt => {
new OmnisearchVaultModal(app).open()
})
}
}
16 changes: 16 additions & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface OmnisearchSettings extends WeightingSettings {
respectExcluded: boolean
ignoreDiacritics: boolean
showIndexingNotices: boolean
ribbonIcon: boolean
showShortName: boolean
CtrlJK: boolean
CtrlNP: boolean
Expand Down Expand Up @@ -93,6 +94,20 @@ export class SettingsTab extends PluginSettingTab {

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
new Setting(containerEl)
.setName('Show indexing notices')
Expand Down Expand Up @@ -189,6 +204,7 @@ export const DEFAULT_SETTINGS: OmnisearchSettings = {

showIndexingNotices: false,
showShortName: false,
ribbonIcon: true,

weightBasename: 2,
weightH1: 1.5,
Expand Down

0 comments on commit 19cc972

Please sign in to comment.