mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-13 04:28:41 -09:00
add command handler to uncatch keyboard event if search is closed
This commit is contained in:
parent
d046d6cf99
commit
73e45f51f0
3 changed files with 19 additions and 7 deletions
|
|
@ -145,13 +145,19 @@ export function onSearch(uid?: string) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function closeSearch(uid?: string) {
|
export function closeSearch(uid?: string, keyEvent?: any) {
|
||||||
return (dispatch: HyperDispatch, getState: () => HyperState) => {
|
return (dispatch: HyperDispatch, getState: () => HyperState) => {
|
||||||
const targetUid = uid || getState().sessions.activeUid!;
|
const targetUid = uid || getState().sessions.activeUid!;
|
||||||
dispatch({
|
if (getState().sessions.sessions[targetUid]?.search) {
|
||||||
type: SESSION_SEARCH_CLOSE,
|
dispatch({
|
||||||
uid: targetUid
|
type: SESSION_SEARCH_CLOSE,
|
||||||
});
|
uid: targetUid
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if (keyEvent) {
|
||||||
|
keyEvent.catched = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -325,7 +325,7 @@ export function execCommand(command: string, fn: (...args: any[]) => void, e: an
|
||||||
command,
|
command,
|
||||||
effect() {
|
effect() {
|
||||||
if (fn) {
|
if (fn) {
|
||||||
fn(e);
|
fn(e, dispatch);
|
||||||
} else {
|
} else {
|
||||||
rpc.emit('command', command);
|
rpc.emit('command', command);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,15 @@
|
||||||
import {remote} from 'electron';
|
import {remote} from 'electron';
|
||||||
|
import {HyperDispatch} from './hyper';
|
||||||
|
import {closeSearch} from './actions/sessions';
|
||||||
// TODO: Should be updates to new async API https://medium.com/@nornagon/electrons-remote-module-considered-harmful-70d69500f31
|
// TODO: Should be updates to new async API https://medium.com/@nornagon/electrons-remote-module-considered-harmful-70d69500f31
|
||||||
|
|
||||||
const {getDecoratedKeymaps} = remote.require('./plugins');
|
const {getDecoratedKeymaps} = remote.require('./plugins');
|
||||||
|
|
||||||
let commands: Record<string, (...args: any[]) => void> = {};
|
let commands: Record<string, (event: any, dispatch: HyperDispatch) => void> = {
|
||||||
|
'editor:search-close': (e, dispatch) => {
|
||||||
|
dispatch(closeSearch(undefined, e));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const getRegisteredKeys = () => {
|
export const getRegisteredKeys = () => {
|
||||||
const keymaps = getDecoratedKeymaps();
|
const keymaps = getDecoratedKeymaps();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue