PR fixes for obsidian-releases
https://github.com/obsidianmd/obsidian-releases/pull/920#issuecomment-1110183606
This commit is contained in:
12
src/main.ts
12
src/main.ts
@@ -1,4 +1,4 @@
|
|||||||
import { MarkdownView, Plugin, TFile } from 'obsidian'
|
import { Plugin, TFile } from 'obsidian'
|
||||||
import {
|
import {
|
||||||
addToIndex,
|
addToIndex,
|
||||||
initGlobalSearchIndex,
|
initGlobalSearchIndex,
|
||||||
@@ -21,16 +21,8 @@ export default class OmnisearchPlugin extends Plugin {
|
|||||||
this.addCommand({
|
this.addCommand({
|
||||||
id: 'show-modal-infile',
|
id: 'show-modal-infile',
|
||||||
name: 'In-file search',
|
name: 'In-file search',
|
||||||
checkCallback: (checking: boolean) => {
|
editorCallback: (_editor, view) => {
|
||||||
// Can only be shown when a note is active
|
|
||||||
const view = app.workspace.getActiveViewOfType(MarkdownView)
|
|
||||||
if (view) {
|
|
||||||
if (!checking) {
|
|
||||||
new OmnisearchInFileModal(app, view.file).open()
|
new OmnisearchInFileModal(app, view.file).open()
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -17,37 +17,27 @@ abstract class OmnisearchModal extends Modal {
|
|||||||
this.modalEl.tabIndex = -1
|
this.modalEl.tabIndex = -1
|
||||||
|
|
||||||
// Setup events that can be listened through the event bus
|
// Setup events that can be listened through the event bus
|
||||||
this.modalEl.onkeydown = ev => {
|
this.scope.register([], 'ArrowDown', () => {
|
||||||
switch (ev.key) {
|
|
||||||
case 'ArrowDown':
|
|
||||||
ev.preventDefault()
|
|
||||||
eventBus.emit('arrow-down')
|
eventBus.emit('arrow-down')
|
||||||
break
|
})
|
||||||
case 'ArrowUp':
|
this.scope.register([], 'ArrowUp', () => {
|
||||||
ev.preventDefault()
|
|
||||||
eventBus.emit('arrow-up')
|
eventBus.emit('arrow-up')
|
||||||
break
|
})
|
||||||
case 'Enter':
|
this.scope.register(['Ctrl'], 'Enter', () => {
|
||||||
ev.preventDefault()
|
eventBus.emit('ctrl-enter') // Open in new pane
|
||||||
if (ev.ctrlKey || ev.metaKey) {
|
})
|
||||||
// Open in a new pane
|
this.scope.register(['Meta'], 'Enter', () => {
|
||||||
eventBus.emit('ctrl-enter')
|
eventBus.emit('ctrl-enter') // Open in new pane (but on Mac)
|
||||||
}
|
})
|
||||||
else if (ev.shiftKey) {
|
this.scope.register(['Alt'], 'Enter', () => {
|
||||||
// Create a new note
|
eventBus.emit('alt-enter') // Open the InFile modal
|
||||||
eventBus.emit('shift-enter')
|
})
|
||||||
}
|
this.scope.register(['Shift'], 'Enter', () => {
|
||||||
else if (ev.altKey) {
|
eventBus.emit('shift-enter') // Create a new note
|
||||||
// Expand in-note results
|
})
|
||||||
eventBus.emit('alt-enter')
|
this.scope.register([], 'Enter', () => {
|
||||||
}
|
eventBus.emit('enter') // Open in current pane
|
||||||
else {
|
})
|
||||||
// Open in current pane
|
|
||||||
eventBus.emit('enter')
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user