aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-01-11 23:13:35 -0500
committerGitHub <noreply@github.com>2021-01-11 23:13:35 -0500
commit983e2c79361ad15ada6aae0d153fef9f1b867a93 (patch)
tree1b655b205cdc062f44248b0f0c9ef13d3ca85266 /ext/bg/js
parent5e87a490f78888717c58491959745431580bd64e (diff)
Refactor text scanner options context generation (#1225)
* Refactor how options context is created and updated * Udpate TextScanner/QueryParser to use getSearchContext instead of getOptionsContext
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/query-parser.js15
1 files changed, 10 insertions, 5 deletions
diff --git a/ext/bg/js/query-parser.js b/ext/bg/js/query-parser.js
index a7c00829..fced2bda 100644
--- a/ext/bg/js/query-parser.js
+++ b/ext/bg/js/query-parser.js
@@ -21,9 +21,9 @@
*/
class QueryParser extends EventDispatcher {
- constructor({getOptionsContext, documentUtil}) {
+ constructor({getSearchContext, documentUtil}) {
super();
- this._getOptionsContext = getOptionsContext;
+ this._getSearchContext = getSearchContext;
this._documentUtil = documentUtil;
this._text = '';
this._setTextToken = null;
@@ -34,7 +34,7 @@ class QueryParser extends EventDispatcher {
this._queryParserModeSelect = document.querySelector('#query-parser-mode-select');
this._textScanner = new TextScanner({
node: this._queryParser,
- getOptionsContext,
+ getSearchContext,
documentUtil,
searchTerms: true,
searchKanji: false,
@@ -82,7 +82,7 @@ class QueryParser extends EventDispatcher {
// Private
- _onSearched({type, definitions, sentence, inputInfo, textSource, optionsContext, error}) {
+ _onSearched({type, definitions, sentence, inputInfo, textSource, optionsContext, detail, error}) {
if (error !== null) {
yomichan.logError(error);
return;
@@ -95,7 +95,8 @@ class QueryParser extends EventDispatcher {
sentence,
inputInfo,
textSource,
- optionsContext
+ optionsContext,
+ detail
});
}
@@ -104,6 +105,10 @@ class QueryParser extends EventDispatcher {
this._setSelectedParser(value);
}
+ _getOptionsContext() {
+ return this._getSearchContext().optionsContext;
+ }
+
_refreshSelectedParser() {
if (this._parseResults.length > 0 && !this._getParseResult()) {
const value = this._parseResults[0].id;