Update extension shortcuts (#1246)
* Update commands * Add command to open the popup window
This commit is contained in:
parent
8766744aa4
commit
f7c3b0010c
@ -86,17 +86,26 @@
|
||||
"clipboardRead"
|
||||
],
|
||||
"commands": {
|
||||
"toggle": {
|
||||
"toggleTextScanning": {
|
||||
"suggested_key": {
|
||||
"default": "Alt+Delete"
|
||||
},
|
||||
"description": "Toggle text scanning"
|
||||
"description": "Toggle text scanning on/off"
|
||||
},
|
||||
"search": {
|
||||
"openHelpPage": {
|
||||
"description": "Open the help page"
|
||||
},
|
||||
"openSettingsPage": {
|
||||
"description": "Open the settings page"
|
||||
},
|
||||
"openSearchPage": {
|
||||
"suggested_key": {
|
||||
"default": "Alt+Insert"
|
||||
},
|
||||
"description": "Open search window"
|
||||
"description": "Open the search page"
|
||||
},
|
||||
"openPopupWindow": {
|
||||
"description": "Open the popup window"
|
||||
}
|
||||
},
|
||||
"web_accessible_resources": [
|
||||
|
@ -131,10 +131,11 @@ class Backend {
|
||||
]);
|
||||
|
||||
this._commandHandlers = new Map([
|
||||
['search', this._onCommandSearch.bind(this)],
|
||||
['help', this._onCommandHelp.bind(this)],
|
||||
['options', this._onCommandOptions.bind(this)],
|
||||
['toggle', this._onCommandToggle.bind(this)]
|
||||
['toggleTextScanning', this._onCommandToggleTextScanning.bind(this)],
|
||||
['openHelpPage', this._onCommandOpenHelpPage.bind(this)],
|
||||
['openSettingsPage', this._onCommandOpenSettingsPage.bind(this)],
|
||||
['openSearchPage', this._onCommandOpenSearchPage.bind(this)],
|
||||
['openPopupWindow', this._onCommandOpenPopupWindow.bind(this)]
|
||||
]);
|
||||
}
|
||||
|
||||
@ -727,7 +728,7 @@ class Backend {
|
||||
|
||||
// Command handlers
|
||||
|
||||
async _onCommandSearch(params) {
|
||||
async _onCommandOpenSearchPage(params) {
|
||||
const {mode='existingOrNewTab', query} = params || {};
|
||||
|
||||
const baseUrl = chrome.runtime.getURL('/bg/search.html');
|
||||
@ -773,22 +774,26 @@ class Backend {
|
||||
}
|
||||
}
|
||||
|
||||
async _onCommandHelp() {
|
||||
async _onCommandOpenHelpPage() {
|
||||
await this._openInfoPage();
|
||||
}
|
||||
|
||||
async _onCommandOptions(params) {
|
||||
async _onCommandOpenSettingsPage(params) {
|
||||
const {mode='existingOrNewTab'} = params || {};
|
||||
await this._openSettingsPage(mode);
|
||||
}
|
||||
|
||||
async _onCommandToggle() {
|
||||
async _onCommandToggleTextScanning() {
|
||||
const source = 'popup';
|
||||
const options = this.getOptions({current: true});
|
||||
options.general.enable = !options.general.enable;
|
||||
await this._saveOptions(source);
|
||||
}
|
||||
|
||||
async _onCommandOpenPopupWindow() {
|
||||
await this._onApiGetOrCreateSearchPopup({focus: true});
|
||||
}
|
||||
|
||||
// Utilities
|
||||
|
||||
_getOrCreateSearchPopup() {
|
||||
|
@ -29,14 +29,14 @@ class DisplayController {
|
||||
|
||||
this._showExtensionInfo(manifest);
|
||||
this._setupEnvironment();
|
||||
this._setupButtonEvents('.action-open-search', 'search', chrome.runtime.getURL('/bg/search.html'));
|
||||
this._setupButtonEvents('.action-open-help', 'help', chrome.runtime.getURL('/bg/info.html'));
|
||||
this._setupButtonEvents('.action-open-search', 'openSearchPage', chrome.runtime.getURL('/bg/search.html'));
|
||||
this._setupButtonEvents('.action-open-help', 'openHelpPage', chrome.runtime.getURL('/bg/info.html'));
|
||||
|
||||
const optionsFull = await api.optionsGetFull();
|
||||
this._optionsFull = optionsFull;
|
||||
|
||||
const optionsPageUrl = optionsFull.global.useSettingsV2 ? '/bg/settings2.html' : manifest.options_ui.page;
|
||||
this._setupButtonEvents('.action-open-options', 'options', chrome.runtime.getURL(optionsPageUrl));
|
||||
this._setupButtonEvents('.action-open-options', 'openSettingsPage', chrome.runtime.getURL(optionsPageUrl));
|
||||
|
||||
const {profiles, profileCurrent} = optionsFull;
|
||||
const primaryProfile = (profileCurrent >= 0 && profileCurrent < profiles.length) ? profiles[profileCurrent] : null;
|
||||
@ -92,7 +92,7 @@ class DisplayController {
|
||||
|
||||
_setupOptions({options}) {
|
||||
const extensionEnabled = options.general.enable;
|
||||
const onToggleChanged = () => api.commandExec('toggle');
|
||||
const onToggleChanged = () => api.commandExec('toggleTextScanning');
|
||||
for (const toggle of document.querySelectorAll('#enable-search,#enable-search2')) {
|
||||
toggle.checked = extensionEnabled;
|
||||
toggle.addEventListener('change', onToggleChanged, false);
|
||||
|
@ -85,17 +85,26 @@
|
||||
"clipboardRead"
|
||||
],
|
||||
"commands": {
|
||||
"toggle": {
|
||||
"toggleTextScanning": {
|
||||
"suggested_key": {
|
||||
"default": "Alt+Delete"
|
||||
},
|
||||
"description": "Toggle text scanning"
|
||||
"description": "Toggle text scanning on/off"
|
||||
},
|
||||
"search": {
|
||||
"openHelpPage": {
|
||||
"description": "Open the help page"
|
||||
},
|
||||
"openSettingsPage": {
|
||||
"description": "Open the settings page"
|
||||
},
|
||||
"openSearchPage": {
|
||||
"suggested_key": {
|
||||
"default": "Alt+Insert"
|
||||
},
|
||||
"description": "Open search window"
|
||||
"description": "Open the search page"
|
||||
},
|
||||
"openPopupWindow": {
|
||||
"description": "Open the popup window"
|
||||
}
|
||||
},
|
||||
"web_accessible_resources": [
|
||||
|
Loading…
Reference in New Issue
Block a user