From c875ca728f619c6e6bccbd13ceb90d898c59e53e Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 17 Jan 2021 19:28:42 -0500 Subject: Add support for frontend hotkeys; add scanSelectedText action (#1266) * Add support for frontend hotkeys; add scanSelectedText action * Remove unused global * Remove duplicate hotkey handler script --- ext/bg/data/options-schema.json | 2 +- ext/bg/js/settings/popup-preview-frame-main.js | 6 ++++- ext/bg/js/settings/popup-preview-frame.js | 6 +++-- ext/bg/popup-preview.html | 1 + ext/bg/settings2.html | 5 ++++ ext/fg/js/content-script-main.js | 7 ++++- ext/fg/js/frontend.js | 36 +++++++++++++++++++++++++- ext/manifest.json | 1 + ext/mixed/js/display.js | 3 ++- 9 files changed, 60 insertions(+), 7 deletions(-) (limited to 'ext') diff --git a/ext/bg/data/options-schema.json b/ext/bg/data/options-schema.json index def279cc..a140d3e9 100644 --- a/ext/bg/data/options-schema.json +++ b/ext/bg/data/options-schema.json @@ -1011,7 +1011,7 @@ "type": "array", "items": { "type": "string", - "enum": ["popup", "search"], + "enum": ["popup", "search", "web"], "default": "popup" }, "default": ["popup", "search"] diff --git a/ext/bg/js/settings/popup-preview-frame-main.js b/ext/bg/js/settings/popup-preview-frame-main.js index a639ced7..71454017 100644 --- a/ext/bg/js/settings/popup-preview-frame-main.js +++ b/ext/bg/js/settings/popup-preview-frame-main.js @@ -16,6 +16,7 @@ */ /* global + * HotkeyHandler * PopupFactory * PopupPreviewFrame * api @@ -27,10 +28,13 @@ const {frameId} = await api.frameInformationGet(); + const hotkeyHandler = new HotkeyHandler(); + hotkeyHandler.prepare(); + const popupFactory = new PopupFactory(frameId); popupFactory.prepare(); - const preview = new PopupPreviewFrame(frameId, popupFactory); + const preview = new PopupPreviewFrame(frameId, popupFactory, hotkeyHandler); await preview.prepare(); document.documentElement.dataset.loaded = 'true'; diff --git a/ext/bg/js/settings/popup-preview-frame.js b/ext/bg/js/settings/popup-preview-frame.js index 73d8882a..92b57c7a 100644 --- a/ext/bg/js/settings/popup-preview-frame.js +++ b/ext/bg/js/settings/popup-preview-frame.js @@ -23,9 +23,10 @@ */ class PopupPreviewFrame { - constructor(frameId, popupFactory) { + constructor(frameId, popupFactory, hotkeyHandler) { this._frameId = frameId; this._popupFactory = popupFactory; + this._hotkeyHandler = hotkeyHandler; this._frontend = null; this._apiOptionsGetOld = null; this._popupShown = false; @@ -74,7 +75,8 @@ class PopupPreviewFrame { useProxyPopup: false, pageType: 'web', allowRootFramePopupProxy: false, - childrenSupported: false + childrenSupported: false, + hotkeyHandler: this._hotkeyHandler }); this._frontend.setOptionsContextOverride(this._optionsContext); await this._frontend.prepare(); diff --git a/ext/bg/popup-preview.html b/ext/bg/popup-preview.html index 75386e24..d8855946 100644 --- a/ext/bg/popup-preview.html +++ b/ext/bg/popup-preview.html @@ -45,6 +45,7 @@ + diff --git a/ext/bg/settings2.html b/ext/bg/settings2.html index 0fd3feb0..128bd5ef 100644 --- a/ext/bg/settings2.html +++ b/ext/bg/settings2.html @@ -3014,10 +3014,15 @@ +
Scopes:
+