summaryrefslogtreecommitdiff
path: root/ext/js/display/display-anki.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-09-27 19:07:28 -0400
committerGitHub <noreply@github.com>2021-09-27 19:07:28 -0400
commitb0f6c41f5dc7f498f2948f846dd273bcb1bc1f0b (patch)
tree09f17dd0c6d549528d680c6f982efeb55610858d /ext/js/display/display-anki.js
parentb784e5b11a596a456eb8879d394fde64bc63aaef (diff)
Search query offset value (#1968)
* Add type property to TextSource* classes * Use type property rather than instanceof * Expose a sentence offset value * Use offset added to URL * Improve fallback sentence for Anki note context
Diffstat (limited to 'ext/js/display/display-anki.js')
-rw-r--r--ext/js/display/display-anki.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/ext/js/display/display-anki.js b/ext/js/display/display-anki.js
index d17a2f0f..216e3108 100644
--- a/ext/js/display/display-anki.js
+++ b/ext/js/display/display-anki.js
@@ -216,8 +216,8 @@ class DisplayAnki {
if (typeof url !== 'string') {
url = window.location.href;
}
- const {query, fullQuery} = this._display;
- sentence = this._getValidSentenceData(sentence, query);
+ const {query, fullQuery, queryOffset} = this._display;
+ sentence = this._getValidSentenceData(sentence, fullQuery, queryOffset);
return {
url,
sentence,
@@ -565,11 +565,11 @@ class DisplayAnki {
return isTerms ? ['term-kanji', 'term-kana'] : ['kanji'];
}
- _getValidSentenceData(sentence, fallback) {
+ _getValidSentenceData(sentence, fallback, fallbackOffset) {
let {text, offset} = (isObject(sentence) ? sentence : {});
if (typeof text !== 'string') {
text = fallback;
- offset = 0;
+ offset = fallbackOffset;
} else {
if (typeof offset !== 'number') { offset = 0; }
}