From 7cce3b9aebb6da75fb0ba0bfe15459aa47bbee00 Mon Sep 17 00:00:00 2001 From: Kuuuube <61125188+Kuuuube@users.noreply.github.com> Date: Sat, 22 Jun 2024 00:40:59 -0400 Subject: Support dictionaryStylesMap in anki-deck-generator-controller and anki-templates-controller (#1112) * Support dictionaryStylesMap in bulk anki card generation * Move getDictionaryStylesMap to anki-note-builder * Support dictionaryStylesMap in anki-templates-controller * Strip newline to prevent tsv breaking * Allow dictionaryStylesMap to be omitted in createNote --------- Signed-off-by: Kuuuube <61125188+Kuuuube@users.noreply.github.com> --- ext/js/display/display-anki.js | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'ext/js/display/display-anki.js') diff --git a/ext/js/display/display-anki.js b/ext/js/display/display-anki.js index 68a6654c..fc242549 100644 --- a/ext/js/display/display-anki.js +++ b/ext/js/display/display-anki.js @@ -149,7 +149,7 @@ export class DisplayAnki { glossaryLayoutMode: this._glossaryLayoutMode, compactTags: this._compactTags, marker: 'test', - dictionaryStylesMap: this._getDictionaryStylesMap(), + dictionaryStylesMap: this._ankiNoteBuilder.getDictionaryStylesMap(this._dictionaries), }); } catch (e) { ankiNoteDataException = e; @@ -813,7 +813,7 @@ export class DisplayAnki { const details = this._ankiNoteBuilder.getDictionaryEntryDetailsForNote(dictionaryEntry); const audioDetails = this._getAnkiNoteMediaAudioDetails(details); const optionsContext = this._display.getOptionsContext(); - const dictionaryStylesMap = this._getDictionaryStylesMap(); + const dictionaryStylesMap = this._ankiNoteBuilder.getDictionaryStylesMap(this._dictionaries); const {note, errors, requirements: outputRequirements} = await this._ankiNoteBuilder.createNote({ dictionaryEntry, @@ -847,20 +847,6 @@ export class DisplayAnki { return {note, errors, requirements: outputRequirements}; } - /** - * @returns {Map} - */ - _getDictionaryStylesMap() { - const styleMap = new Map(); - for (const dictionary of this._dictionaries) { - const {name, styles} = dictionary; - if (typeof styles === 'string') { - styleMap.set(name, styles); - } - } - return styleMap; - } - /** * @param {boolean} isTerms * @returns {import('display-anki').CreateMode[]} -- cgit v1.2.3