summaryrefslogtreecommitdiff
path: root/ext/bg/js/search-query-parser.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js/search-query-parser.js')
-rw-r--r--ext/bg/js/search-query-parser.js21
1 files changed, 11 insertions, 10 deletions
diff --git a/ext/bg/js/search-query-parser.js b/ext/bg/js/search-query-parser.js
index e1e37d1c..86524b66 100644
--- a/ext/bg/js/search-query-parser.js
+++ b/ext/bg/js/search-query-parser.js
@@ -18,9 +18,7 @@
/* global
* QueryParserGenerator
* TextScanner
- * apiModifySettings
- * apiTermsFind
- * apiTextParse
+ * api
* docSentenceExtract
*/
@@ -44,6 +42,7 @@ class QueryParser {
async prepare() {
await this._queryParserGenerator.prepare();
+ this._textScanner.prepare();
this._queryParser.addEventListener('click', this._onClick.bind(this));
}
@@ -59,7 +58,7 @@ class QueryParser {
this._setPreview(text);
- this._parseResults = await apiTextParse(text, this._getOptionsContext());
+ this._parseResults = await api.textParse(text, this._getOptionsContext());
this._refreshSelectedParser();
this._renderParserSelect();
@@ -77,15 +76,17 @@ class QueryParser {
async _search(textSource, cause) {
if (textSource === null) { return null; }
- const searchText = this._textScanner.getTextSourceContent(textSource, this._options.scanning.length);
+ const {length: scanLength, layoutAwareScan} = this._options.scanning;
+ const searchText = this._textScanner.getTextSourceContent(textSource, scanLength, layoutAwareScan);
if (searchText.length === 0) { return null; }
- const {definitions, length} = await apiTermsFind(searchText, {}, this._getOptionsContext());
+ const {definitions, length} = await api.termsFind(searchText, {}, this._getOptionsContext());
if (definitions.length === 0) { return null; }
- const sentence = docSentenceExtract(textSource, this._options.anki.sentenceExt);
+ const sentenceExtent = this._options.anki.sentenceExt;
+ const sentence = docSentenceExtract(textSource, sentenceExtent, layoutAwareScan);
- textSource.setEndOffset(length);
+ textSource.setEndOffset(length, layoutAwareScan);
this._setContent('terms', {definitions, context: {
focus: false,
@@ -99,7 +100,7 @@ class QueryParser {
_onParserChange(e) {
const value = e.target.value;
- apiModifySettings([{
+ api.modifySettings([{
action: 'set',
path: 'parsing.selectedParser',
value,
@@ -112,7 +113,7 @@ class QueryParser {
if (this._parseResults.length > 0) {
if (!this._getParseResult()) {
const value = this._parseResults[0].id;
- apiModifySettings([{
+ api.modifySettings([{
action: 'set',
path: 'parsing.selectedParser',
value,