aboutsummaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-01-17 19:28:42 -0500
committerGitHub <noreply@github.com>2021-01-17 19:28:42 -0500
commitc875ca728f619c6e6bccbd13ceb90d898c59e53e (patch)
treeedcf6862bd5d33eefea6c1a2af867b16d1040081 /ext/bg
parentde5d3ec3ad608893a9db75229296094f85c200c3 (diff)
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
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/data/options-schema.json2
-rw-r--r--ext/bg/js/settings/popup-preview-frame-main.js6
-rw-r--r--ext/bg/js/settings/popup-preview-frame.js6
-rw-r--r--ext/bg/popup-preview.html1
-rw-r--r--ext/bg/settings2.html5
5 files changed, 16 insertions, 4 deletions
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 @@
<script src="/mixed/js/text-scanner.js"></script>
<script src="/mixed/js/document-util.js"></script>
+<script src="/mixed/js/hotkey-handler.js"></script>
<script src="/fg/js/dom-text-scanner.js"></script>
<script src="/fg/js/popup.js"></script>
<script src="/fg/js/text-source-range.js"></script>
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 @@
<option value="viewNote" data-scopes="popup search">View note</option>
<option value="playAudio" data-scopes="popup search">Play audio</option>
<option value="copyHostSelection" data-scopes="popup search">Copy selection</option>
+ <option value="scanSelectedText" data-scopes="web">Scan selected text</option>
</select>
<div class="hotkey-list-item-flex-row">
<div class="hotkey-list-item-flex-row-label">Scopes:</div>
<div class="hotkey-list-item-flex-row">
+ <label class="hotkey-scope-checkbox-container" data-scope="web">
+ <label class="checkbox"><input type="checkbox" class="hotkey-scope-checkbox" data-scope="web"><span class="checkbox-body"><span class="checkbox-fill"></span><span class="checkbox-border"></span><span class="checkbox-check"></span></span></label>
+ <span>Web</span>
+ </label>
<label class="hotkey-scope-checkbox-container" data-scope="popup">
<label class="checkbox"><input type="checkbox" class="hotkey-scope-checkbox" data-scope="popup"><span class="checkbox-body"><span class="checkbox-fill"></span><span class="checkbox-border"></span><span class="checkbox-check"></span></span></label>
<span>Popup</span>