hide console on <Esc> and <C-{>

This commit is contained in:
Shin'ya Ueoka 2018-03-04 18:32:24 +09:00
parent 37410b874f
commit 90b83d7b7b
6 changed files with 18 additions and 2 deletions

View file

@ -73,6 +73,10 @@ const exec = (operation, tab) => {
return browser.tabs.sendMessage(tab.id, {
type: messages.CONSOLE_SHOW_FIND
});
case operations.CANCEL:
return browser.tabs.sendMessage(tab.id, {
type: messages.CONSOLE_HIDE,
});
default:
return Promise.resolve();
}

View file

@ -1,10 +1,17 @@
import actions from 'content/actions';
import * as keyUtils from 'shared/utils/keys';
import operations from 'shared/operations';
const reservedKeymaps = {
'<Esc>': { type: operations.CANCEL },
'<C-[>': { type: operations.CANCEL },
};
const set = (value) => {
let entries = [];
if (value.keymaps) {
entries = Object.entries(value.keymaps).map((entry) => {
let keymaps = Object.assign({}, value.keymaps, reservedKeymaps);
entries = Object.entries(keymaps).map((entry) => {
return [
keyUtils.fromMapKeys(entry[0]),
entry[1],

View file

@ -32,6 +32,7 @@ export default {
CONSOLE_SHOW_ERROR: 'console.show.error',
CONSOLE_SHOW_INFO: 'console.show.info',
CONSOLE_SHOW_FIND: 'console.show.find',
CONSOLE_HIDE: 'console.hide',
FOLLOW_START: 'follow.start',
FOLLOW_REQUEST_COUNT_TARGETS: 'follow.request.count.targets',

View file

@ -1,4 +1,7 @@
export default {
// Hide console, or cancel some user actions
CANCEL: 'cancel',
// Addons
ADDON_ENABLE: 'addon.enable',
ADDON_DISABLE: 'addon.disable',