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,9 @@
|
||||
import { App, Modal, TFile } from 'obsidian'
|
||||
import type { Modifier } from 'obsidian'
|
||||
import ModalVault from './ModalVault.svelte'
|
||||
import ModalInFile from './ModalInFile.svelte'
|
||||
import { eventBus, EventNames, isInputComposition } from '../globals'
|
||||
import { settings } from '../settings'
|
||||
|
||||
abstract class OmnisearchModal extends Modal {
|
||||
protected constructor(app: App) {
|
||||
@@ -61,8 +63,24 @@ abstract class OmnisearchModal extends Modal {
|
||||
|
||||
// #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
|
||||
this.scope.register(['Mod'], 'Enter', e => {
|
||||
this.scope.register(openInNewPaneKey, 'Enter', e => {
|
||||
e.preventDefault()
|
||||
eventBus.emit('open-in-new-pane')
|
||||
})
|
||||
@@ -74,17 +92,17 @@ abstract class OmnisearchModal extends Modal {
|
||||
})
|
||||
|
||||
// Create a new note
|
||||
this.scope.register(['Shift'], 'Enter', e => {
|
||||
this.scope.register(createInCurrentPaneKey, 'Enter', e => {
|
||||
e.preventDefault()
|
||||
eventBus.emit('create-note')
|
||||
})
|
||||
this.scope.register(['Ctrl', 'Shift'], 'Enter', e => {
|
||||
this.scope.register(createInNewPaneKey, 'Enter', e => {
|
||||
e.preventDefault()
|
||||
eventBus.emit('create-note', { newLeaf: true })
|
||||
})
|
||||
|
||||
// Open in current pane
|
||||
this.scope.register([], 'Enter', e => {
|
||||
this.scope.register(openInCurrentPaneKey, 'Enter', e => {
|
||||
if (!isInputComposition()) {
|
||||
// Check if the user is still typing
|
||||
e.preventDefault()
|
||||
|
||||
Reference in New Issue
Block a user