Add setting to open/create files in new pane by default (#241)
* Manifest 1.14.1-beta.1 * 1.14.1-beta.2 manifest * Add setting to open/create files in new pane by default * Fix typo with key labels * Address review comments --------- Co-authored-by: Simon Cambier <simon.cambier@protonmail.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"id": "omnisearch",
|
"id": "omnisearch",
|
||||||
"name": "Omnisearch",
|
"name": "Omnisearch",
|
||||||
"version": "1.14.0",
|
"version": "1.14.1-beta.2",
|
||||||
"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",
|
||||||
|
|||||||
@@ -39,9 +39,24 @@
|
|||||||
let indexingStepDesc = ''
|
let indexingStepDesc = ''
|
||||||
let searching = true
|
let searching = true
|
||||||
let refInput: InputSearch | undefined
|
let refInput: InputSearch | undefined
|
||||||
|
let openInNewPaneKey: string
|
||||||
|
let openInCurrentPaneKey: string
|
||||||
|
let createInNewPaneKey: string
|
||||||
|
let createInCurrentPaneKey: string
|
||||||
|
|
||||||
$: selectedNote = resultNotes[selectedIndex]
|
$: selectedNote = resultNotes[selectedIndex]
|
||||||
$: searchQuery = searchQuery ?? previousQuery
|
$: searchQuery = searchQuery ?? previousQuery
|
||||||
|
$: if (settings.openInNewPane) {
|
||||||
|
openInNewPaneKey = '↵'
|
||||||
|
openInCurrentPaneKey = getCtrlKeyLabel() + ' ↵'
|
||||||
|
createInNewPaneKey = 'shift ↵'
|
||||||
|
createInCurrentPaneKey = 'ctrl shift ↵'
|
||||||
|
} else {
|
||||||
|
openInNewPaneKey = getCtrlKeyLabel() + ' ↵'
|
||||||
|
openInCurrentPaneKey = '↵'
|
||||||
|
createInNewPaneKey = 'ctrl shift ↵'
|
||||||
|
createInCurrentPaneKey = 'shift ↵'
|
||||||
|
}
|
||||||
$: if (searchQuery) {
|
$: if (searchQuery) {
|
||||||
searching = true
|
searching = true
|
||||||
updateResults().then(() => {
|
updateResults().then(() => {
|
||||||
@@ -309,7 +324,7 @@
|
|||||||
<span>to cycle history</span>
|
<span>to cycle history</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="prompt-instruction">
|
<div class="prompt-instruction">
|
||||||
<span class="prompt-instruction-command">↵</span><span>to open</span>
|
<span class="prompt-instruction-command">{openInCurrentPaneKey}</span><span>to open</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="prompt-instruction">
|
<div class="prompt-instruction">
|
||||||
<span class="prompt-instruction-command">tab</span>
|
<span class="prompt-instruction-command">tab</span>
|
||||||
@@ -317,15 +332,15 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="prompt-instruction">
|
<div class="prompt-instruction">
|
||||||
<span class="prompt-instruction-command">{getCtrlKeyLabel()} ↵</span>
|
<span class="prompt-instruction-command">{openInNewPaneKey}</span>
|
||||||
<span>to open in a new pane</span>
|
<span>to open in a new pane</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="prompt-instruction">
|
<div class="prompt-instruction">
|
||||||
<span class="prompt-instruction-command">shift ↵</span>
|
<span class="prompt-instruction-command">{createInCurrentPaneKey}</span>
|
||||||
<span>to create</span>
|
<span>to create</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="prompt-instruction">
|
<div class="prompt-instruction">
|
||||||
<span class="prompt-instruction-command">ctrl shift ↵</span>
|
<span class="prompt-instruction-command">{createInNewPaneKey}</span>
|
||||||
<span>to create in a new pane</span>
|
<span>to create in a new pane</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { App, Modal, TFile } from 'obsidian'
|
import { App, Modal, TFile } from 'obsidian'
|
||||||
|
import type { Modifier } from 'obsidian'
|
||||||
import ModalVault from './ModalVault.svelte'
|
import ModalVault from './ModalVault.svelte'
|
||||||
import ModalInFile from './ModalInFile.svelte'
|
import ModalInFile from './ModalInFile.svelte'
|
||||||
import { eventBus, EventNames, isInputComposition } from '../globals'
|
import { eventBus, EventNames, isInputComposition } from '../globals'
|
||||||
|
import { settings } from '../settings'
|
||||||
|
|
||||||
abstract class OmnisearchModal extends Modal {
|
abstract class OmnisearchModal extends Modal {
|
||||||
protected constructor(app: App) {
|
protected constructor(app: App) {
|
||||||
@@ -61,8 +63,24 @@ abstract class OmnisearchModal extends Modal {
|
|||||||
|
|
||||||
// #endregion Up/Down navigation
|
// #endregion Up/Down navigation
|
||||||
|
|
||||||
|
let openInCurrentPaneKey: Modifier[]
|
||||||
|
let openInNewPaneKey: Modifier[]
|
||||||
|
let createInCurrentPaneKey: Modifier[]
|
||||||
|
let createInNewPaneKey: Modifier[]
|
||||||
|
if (settings.openInNewPane) {
|
||||||
|
openInCurrentPaneKey = ['Mod']
|
||||||
|
openInNewPaneKey = []
|
||||||
|
createInCurrentPaneKey = ['Ctrl', 'Shift']
|
||||||
|
createInNewPaneKey = ['Shift']
|
||||||
|
} else {
|
||||||
|
openInCurrentPaneKey = []
|
||||||
|
openInNewPaneKey = ['Mod']
|
||||||
|
createInCurrentPaneKey = ['Shift']
|
||||||
|
createInNewPaneKey = ['Ctrl', 'Shift']
|
||||||
|
}
|
||||||
|
|
||||||
// Open in new pane
|
// Open in new pane
|
||||||
this.scope.register(['Mod'], 'Enter', e => {
|
this.scope.register(openInNewPaneKey, 'Enter', e => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
eventBus.emit('open-in-new-pane')
|
eventBus.emit('open-in-new-pane')
|
||||||
})
|
})
|
||||||
@@ -74,17 +92,17 @@ abstract class OmnisearchModal extends Modal {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Create a new note
|
// Create a new note
|
||||||
this.scope.register(['Shift'], 'Enter', e => {
|
this.scope.register(createInCurrentPaneKey, 'Enter', e => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
eventBus.emit('create-note')
|
eventBus.emit('create-note')
|
||||||
})
|
})
|
||||||
this.scope.register(['Ctrl', 'Shift'], 'Enter', e => {
|
this.scope.register(createInNewPaneKey, 'Enter', e => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
eventBus.emit('create-note', { newLeaf: true })
|
eventBus.emit('create-note', { newLeaf: true })
|
||||||
})
|
})
|
||||||
|
|
||||||
// Open in current pane
|
// Open in current pane
|
||||||
this.scope.register([], 'Enter', e => {
|
this.scope.register(openInCurrentPaneKey, 'Enter', e => {
|
||||||
if (!isInputComposition()) {
|
if (!isInputComposition()) {
|
||||||
// Check if the user is still typing
|
// Check if the user is still typing
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ export interface OmnisearchSettings extends WeightingSettings {
|
|||||||
simpleSearch: boolean
|
simpleSearch: boolean
|
||||||
highlight: boolean
|
highlight: boolean
|
||||||
splitCamelCase: boolean
|
splitCamelCase: boolean
|
||||||
|
openInNewPane: boolean
|
||||||
verboseLogging: boolean
|
verboseLogging: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,6 +247,18 @@ export class SettingsTab extends PluginSettingTab {
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
|
new Setting(containerEl)
|
||||||
|
.setName('Open in new pane')
|
||||||
|
.setDesc(
|
||||||
|
'Open and create files in a new pane instead of the current pane.'
|
||||||
|
)
|
||||||
|
.addToggle(toggle =>
|
||||||
|
toggle.setValue(settings.openInNewPane).onChange(async v => {
|
||||||
|
settings.openInNewPane = v
|
||||||
|
await saveSettings(this.plugin)
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
//#endregion Behavior
|
//#endregion Behavior
|
||||||
|
|
||||||
//#region User Interface
|
//#region User Interface
|
||||||
@@ -445,6 +458,7 @@ export const DEFAULT_SETTINGS: OmnisearchSettings = {
|
|||||||
PDFIndexing: false,
|
PDFIndexing: false,
|
||||||
imagesIndexing: false,
|
imagesIndexing: false,
|
||||||
splitCamelCase: false,
|
splitCamelCase: false,
|
||||||
|
openInNewPane: false,
|
||||||
|
|
||||||
ribbonIcon: true,
|
ribbonIcon: true,
|
||||||
showExcerpt: true,
|
showExcerpt: true,
|
||||||
|
|||||||
@@ -105,5 +105,7 @@
|
|||||||
"1.13.0-beta.2": "1.0.0",
|
"1.13.0-beta.2": "1.0.0",
|
||||||
"1.13.0": "1.0.0",
|
"1.13.0": "1.0.0",
|
||||||
"1.14.0-beta.1": "1.0.0",
|
"1.14.0-beta.1": "1.0.0",
|
||||||
"1.14.0": "1.0.0"
|
"1.14.0": "1.0.0",
|
||||||
|
"1.14.1-beta.1": "1.0.0",
|
||||||
|
"1.14.1-beta.2": "1.0.0"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user