aboutsummaryrefslogtreecommitdiff
path: root/ext/js/display/display-anki.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-07-09 17:48:27 -0400
committerGitHub <noreply@github.com>2021-07-09 17:48:27 -0400
commit8c68fa4d9435b562ffe23df92a2b7b620a0ed78e (patch)
tree8c622fe11063b3f9694033f10e47b2ac05badccc /ext/js/display/display-anki.js
parent0d167095479822adf1ed8918e3d1a349b3a53377 (diff)
Anki text furigana parsing and {sentence-furigana} marker (#1814)
* Add support for textFurigana media * Add readingMode parameter * Implement readingMode * Add {sentence-furigana} marker * Fallback to sentence if furigana isn't available * Update test data
Diffstat (limited to 'ext/js/display/display-anki.js')
-rw-r--r--ext/js/display/display-anki.js14
1 files changed, 11 insertions, 3 deletions
diff --git a/ext/js/display/display-anki.js b/ext/js/display/display-anki.js
index 114a9d13..235149ad 100644
--- a/ext/js/display/display-anki.js
+++ b/ext/js/display/display-anki.js
@@ -22,11 +22,11 @@
*/
class DisplayAnki {
- constructor(display) {
+ constructor(display, japaneseUtil) {
this._display = display;
this._ankiFieldTemplates = null;
this._ankiFieldTemplatesDefault = null;
- this._ankiNoteBuilder = new AnkiNoteBuilder();
+ this._ankiNoteBuilder = new AnkiNoteBuilder({japaneseUtil});
this._ankiNoteNotification = null;
this._ankiNoteNotificationEventListeners = null;
this._ankiTagNotification = null;
@@ -44,6 +44,7 @@ class DisplayAnki {
this._duplicateScope = 'collection';
this._screenshotFormat = 'png';
this._screenshotQuality = 100;
+ this._scanLength = 10;
this._noteTags = [];
this._modeOptions = new Map();
this._dictionaryEntryTypeModeMap = new Map([
@@ -141,7 +142,8 @@ class DisplayAnki {
_onOptionsUpdated({options}) {
const {
general: {resultOutputMode, glossaryLayoutMode, compactTags},
- anki: {tags, duplicateScope, suspendNewCards, checkForDuplicates, displayTags, kanji, terms, screenshot: {format, quality}}
+ anki: {tags, duplicateScope, suspendNewCards, checkForDuplicates, displayTags, kanji, terms, screenshot: {format, quality}},
+ scanning: {length: scanLength}
} = options;
this._checkForDuplicates = checkForDuplicates;
@@ -153,6 +155,7 @@ class DisplayAnki {
this._duplicateScope = duplicateScope;
this._screenshotFormat = format;
this._screenshotQuality = quality;
+ this._scanLength = scanLength;
this._noteTags = [...tags];
this._modeOptions.clear();
this._modeOptions.set('kanji', kanji);
@@ -526,6 +529,7 @@ class DisplayAnki {
const contentOrigin = this._display.getContentOrigin();
const details = this._ankiNoteBuilder.getDictionaryEntryDetailsForNote(dictionaryEntry);
const audioDetails = (details.type === 'term' ? this._display.getAnkiNoteMediaAudioDetails(details.term, details.reading) : null);
+ const optionsContext = this._display.getOptionsContext();
const {note, errors, requirements: outputRequirements} = await this._ankiNoteBuilder.createNote({
dictionaryEntry,
@@ -547,6 +551,10 @@ class DisplayAnki {
format: this._screenshotFormat,
quality: this._screenshotQuality,
contentOrigin
+ },
+ textParsing: {
+ optionsContext,
+ scanLength: this._scanLength
}
},
requirements