#39 - Fixed keypress events not correctly prevented
This commit is contained in:
@@ -13,14 +13,6 @@ onMount(async () => {
|
|||||||
elInput.select()
|
elInput.select()
|
||||||
})
|
})
|
||||||
|
|
||||||
function onKeydown(e: KeyboardEvent) {
|
|
||||||
switch (e.key) {
|
|
||||||
case "ArrowUp":
|
|
||||||
case "ArrowDown":
|
|
||||||
e.preventDefault()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const debouncedOnInput = debounce(() => {
|
const debouncedOnInput = debounce(() => {
|
||||||
dispatch("input", value)
|
dispatch("input", value)
|
||||||
}, 100)
|
}, 100)
|
||||||
@@ -30,7 +22,6 @@ const debouncedOnInput = debounce(() => {
|
|||||||
bind:value
|
bind:value
|
||||||
bind:this={elInput}
|
bind:this={elInput}
|
||||||
on:input={debouncedOnInput}
|
on:input={debouncedOnInput}
|
||||||
on:keydown={onKeydown}
|
|
||||||
type="text"
|
type="text"
|
||||||
class="prompt-input"
|
class="prompt-input"
|
||||||
placeholder="Type to search through your notes"
|
placeholder="Type to search through your notes"
|
||||||
|
|||||||
@@ -17,25 +17,32 @@ 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.scope.register([], 'ArrowDown', () => {
|
this.scope.register([], 'ArrowDown', e => {
|
||||||
|
e.preventDefault()
|
||||||
eventBus.emit('arrow-down')
|
eventBus.emit('arrow-down')
|
||||||
})
|
})
|
||||||
this.scope.register([], 'ArrowUp', () => {
|
this.scope.register([], 'ArrowUp', e => {
|
||||||
|
e.preventDefault()
|
||||||
eventBus.emit('arrow-up')
|
eventBus.emit('arrow-up')
|
||||||
})
|
})
|
||||||
this.scope.register(['Ctrl'], 'Enter', () => {
|
this.scope.register(['Ctrl'], 'Enter', e => {
|
||||||
|
e.preventDefault()
|
||||||
eventBus.emit('ctrl-enter') // Open in new pane
|
eventBus.emit('ctrl-enter') // Open in new pane
|
||||||
})
|
})
|
||||||
this.scope.register(['Meta'], 'Enter', () => {
|
this.scope.register(['Meta'], 'Enter', e => {
|
||||||
|
e.preventDefault()
|
||||||
eventBus.emit('ctrl-enter') // Open in new pane (but on Mac)
|
eventBus.emit('ctrl-enter') // Open in new pane (but on Mac)
|
||||||
})
|
})
|
||||||
this.scope.register(['Alt'], 'Enter', () => {
|
this.scope.register(['Alt'], 'Enter', e => {
|
||||||
|
e.preventDefault()
|
||||||
eventBus.emit('alt-enter') // Open the InFile modal
|
eventBus.emit('alt-enter') // Open the InFile modal
|
||||||
})
|
})
|
||||||
this.scope.register(['Shift'], 'Enter', () => {
|
this.scope.register(['Shift'], 'Enter', e => {
|
||||||
|
e.preventDefault()
|
||||||
eventBus.emit('shift-enter') // Create a new note
|
eventBus.emit('shift-enter') // Create a new note
|
||||||
})
|
})
|
||||||
this.scope.register([], 'Enter', () => {
|
this.scope.register([], 'Enter', e => {
|
||||||
|
e.preventDefault()
|
||||||
eventBus.emit('enter') // Open in current pane
|
eventBus.emit('enter') // Open in current pane
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,7 @@ import {
|
|||||||
type SearchMatch,
|
type SearchMatch,
|
||||||
} from './globals'
|
} from './globals'
|
||||||
import {
|
import {
|
||||||
escapeRegex,
|
|
||||||
extractHeadingsFromCache,
|
extractHeadingsFromCache,
|
||||||
splitQuotes,
|
|
||||||
stringsToRegex,
|
stringsToRegex,
|
||||||
stripMarkdownCharacters,
|
stripMarkdownCharacters,
|
||||||
wait,
|
wait,
|
||||||
|
|||||||
Reference in New Issue
Block a user