#108 - Removed Vim settings (now always on), and slightly changed the event handling
This commit is contained in:
@@ -32,13 +32,13 @@ abstract class OmnisearchModal extends Modal {
|
|||||||
|
|
||||||
// Ctrl+j/k
|
// Ctrl+j/k
|
||||||
for (const key of [
|
for (const key of [
|
||||||
{ k: 'j', dir: 'down' },
|
{ k: 'J', dir: 'down' },
|
||||||
{ k: 'k', dir: 'up' },
|
{ k: 'K', dir: 'up' },
|
||||||
] as const) {
|
] as const) {
|
||||||
for (const modifier of ['Ctrl', 'Meta'] as const) {
|
for (const modifier of ['Ctrl', 'Mod'] as const) {
|
||||||
this.scope.register([modifier], key.k, e => {
|
this.scope.register([modifier], key.k, e => {
|
||||||
if (settings.CtrlJK && this.app.vault.getConfig('vimMode')) {
|
if (this.app.vault.getConfig('vimMode')) {
|
||||||
e.preventDefault()
|
// e.preventDefault()
|
||||||
eventBus.emit('arrow-' + key.dir)
|
eventBus.emit('arrow-' + key.dir)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -47,13 +47,13 @@ abstract class OmnisearchModal extends Modal {
|
|||||||
|
|
||||||
// Ctrl+n/p
|
// Ctrl+n/p
|
||||||
for (const key of [
|
for (const key of [
|
||||||
{ k: 'n', dir: 'down' },
|
{ k: 'N', dir: 'down' },
|
||||||
{ k: 'p', dir: 'up' },
|
{ k: 'P', dir: 'up' },
|
||||||
] as const) {
|
] as const) {
|
||||||
for (const modifier of ['Ctrl', 'Meta'] as const) {
|
for (const modifier of ['Ctrl', 'Mod'] as const) {
|
||||||
this.scope.register([modifier], key.k, e => {
|
this.scope.register([modifier], key.k, e => {
|
||||||
if (settings.CtrlNP && this.app.vault.getConfig('vimMode')) {
|
if (this.app.vault.getConfig('vimMode')) {
|
||||||
e.preventDefault()
|
// e.preventDefault()
|
||||||
eventBus.emit('arrow-' + key.dir)
|
eventBus.emit('arrow-' + key.dir)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -123,7 +123,7 @@ export class OmnisearchVaultModal extends OmnisearchModal {
|
|||||||
target: this.modalEl,
|
target: this.modalEl,
|
||||||
props: {
|
props: {
|
||||||
modal: this,
|
modal: this,
|
||||||
previousQuery: query
|
previousQuery: query,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -38,10 +38,6 @@ export interface OmnisearchSettings extends WeightingSettings {
|
|||||||
showCreateButton: boolean
|
showCreateButton: boolean
|
||||||
/** Re-execute the last query when opening Omnisearch */
|
/** Re-execute the last query when opening Omnisearch */
|
||||||
showPreviousQueryResults: boolean
|
showPreviousQueryResults: boolean
|
||||||
/** Vim mode shortcuts */
|
|
||||||
CtrlJK: boolean
|
|
||||||
/** Vim mode shortcuts */
|
|
||||||
CtrlNP: boolean
|
|
||||||
/** Key for the welcome message when Obsidian is updated. A message is only shown once. */
|
/** Key for the welcome message when Obsidian is updated. A message is only shown once. */
|
||||||
welcomeMessage: string
|
welcomeMessage: string
|
||||||
/** If a query returns 0 result, try again with more relax conditions */
|
/** If a query returns 0 result, try again with more relax conditions */
|
||||||
@@ -278,36 +274,6 @@ export class SettingsTab extends PluginSettingTab {
|
|||||||
.addSlider(cb => this.weightSlider(cb, 'weightH3'))
|
.addSlider(cb => this.weightSlider(cb, 'weightH3'))
|
||||||
|
|
||||||
// #endregion Results Weighting
|
// #endregion Results Weighting
|
||||||
|
|
||||||
// #region Shortcuts
|
|
||||||
|
|
||||||
new Setting(containerEl).setName('Shortcuts').setHeading()
|
|
||||||
|
|
||||||
const ctrljk = new DocumentFragment()
|
|
||||||
ctrljk.createSpan({}, span => {
|
|
||||||
span.innerHTML =
|
|
||||||
'Use <code>[Ctrl/Cmd]+j/k</code> to navigate up/down in the results, if Vim mode is enabled'
|
|
||||||
})
|
|
||||||
new Setting(containerEl).setName(ctrljk).addToggle(toggle =>
|
|
||||||
toggle.setValue(settings.CtrlJK).onChange(async v => {
|
|
||||||
settings.CtrlJK = v
|
|
||||||
await saveSettings(this.plugin)
|
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
||||||
const ctrlnp = new DocumentFragment()
|
|
||||||
ctrlnp.createSpan({}, span => {
|
|
||||||
span.innerHTML =
|
|
||||||
'Use <code>[Ctrl/Cmd]+j/k</code> to navigate up/down in the results, if Vim mode is enabled'
|
|
||||||
})
|
|
||||||
new Setting(containerEl).setName(ctrlnp).addToggle(toggle =>
|
|
||||||
toggle.setValue(settings.CtrlNP).onChange(async v => {
|
|
||||||
settings.CtrlNP = v
|
|
||||||
await saveSettings(this.plugin)
|
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
||||||
// #endregion Shortcuts
|
|
||||||
}
|
}
|
||||||
|
|
||||||
weightSlider(cb: SliderComponent, key: keyof WeightingSettings): void {
|
weightSlider(cb: SliderComponent, key: keyof WeightingSettings): void {
|
||||||
@@ -349,9 +315,6 @@ export const DEFAULT_SETTINGS: OmnisearchSettings = {
|
|||||||
weightH2: 1.3,
|
weightH2: 1.3,
|
||||||
weightH3: 1.1,
|
weightH3: 1.1,
|
||||||
|
|
||||||
CtrlJK: true,
|
|
||||||
CtrlNP: true,
|
|
||||||
|
|
||||||
// persistCache: false,
|
// persistCache: false,
|
||||||
|
|
||||||
welcomeMessage: '',
|
welcomeMessage: '',
|
||||||
|
|||||||
Reference in New Issue
Block a user