aboutsummaryrefslogtreecommitdiff
path: root/ext/mixed/js/text-scanner.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-11-12 20:32:46 -0500
committerGitHub <noreply@github.com>2020-11-12 20:32:46 -0500
commitf2ad94e54f2a110bf93aebfae33c808c497005be (patch)
tree82580173f795f09e40fbc47f0e8877e24b751160 /ext/mixed/js/text-scanner.js
parent219dfb4917f5b19da19b85ff223de663db561fe7 (diff)
Text scanning options propagation (#1020)
* Update Display.setOptionsContext to update options * Update how options context is updated in Popup * Omit optionsContext for some _showPopupContent calls * Remove extension unload * Disable modifier keys in frontend's options context * Update how text scanner passes modifiers to options context * Update how options context is passed to display * Update how display uses options context
Diffstat (limited to 'ext/mixed/js/text-scanner.js')
-rw-r--r--ext/mixed/js/text-scanner.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/ext/mixed/js/text-scanner.js b/ext/mixed/js/text-scanner.js
index 5ab90de8..66d37c93 100644
--- a/ext/mixed/js/text-scanner.js
+++ b/ext/mixed/js/text-scanner.js
@@ -238,6 +238,14 @@ class TextScanner extends EventDispatcher {
// Private
+ async _getOptionsContextForInput(inputInfo) {
+ const optionsContext = clone(await this._getOptionsContext());
+ const {modifiers, modifierKeys} = inputInfo;
+ optionsContext.modifiers = [...modifiers];
+ optionsContext.modifierKeys = [...modifierKeys];
+ return optionsContext;
+ }
+
async _search(textSource, searchTerms, searchKanji, inputInfo) {
let definitions = null;
let sentence = null;
@@ -251,7 +259,7 @@ class TextScanner extends EventDispatcher {
return;
}
- optionsContext = await this._getOptionsContext();
+ optionsContext = await this._getOptionsContextForInput(inputInfo);
searched = true;
const result = await this._findDefinitions(textSource, searchTerms, searchKanji, optionsContext);
@@ -810,7 +818,6 @@ class TextScanner extends EventDispatcher {
_getMatchingInputGroupFromEvent(type, cause, event) {
const modifiers = DocumentUtil.getActiveModifiersAndButtons(event);
const modifierKeys = DocumentUtil.getActiveModifiers(event);
- this.trigger('activeModifiersChanged', {modifiers, modifierKeys});
return this._getMatchingInputGroup(type, cause, modifiers, modifierKeys);
}