diff options
| author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2024-02-01 10:00:59 -0500 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-01 15:00:59 +0000 | 
| commit | dfd42bad0b46845ad88d1fdc5fa82b4f03bab0f3 (patch) | |
| tree | 04686b943b84b33b8927238be17e4bc0dda7eb62 /ext/js/data/anki-note-builder.js | |
| parent | 2356223942a21d1683ac38eed8e7b9485f453d87 (diff) | |
Application refactor (#591)
* Rename Yomitan class to Application, change initialization style
* Rename file
* Update init
* Update config
* Remove dead code
Diffstat (limited to 'ext/js/data/anki-note-builder.js')
| -rw-r--r-- | ext/js/data/anki-note-builder.js | 10 | 
1 files changed, 6 insertions, 4 deletions
| diff --git a/ext/js/data/anki-note-builder.js b/ext/js/data/anki-note-builder.js index 5bb943c2..a6e1aafc 100644 --- a/ext/js/data/anki-note-builder.js +++ b/ext/js/data/anki-note-builder.js @@ -19,15 +19,17 @@  import {ExtensionError} from '../core/extension-error.js';  import {deferPromise} from '../core/utilities.js';  import {convertHiraganaToKatakana, convertKatakanaToHiragana} from '../language/japanese.js'; -import {yomitan} from '../yomitan.js';  import {cloneFieldMarkerPattern, getRootDeckName} from './anki-util.js';  export class AnkiNoteBuilder {      /**       * Initiate an instance of AnkiNoteBuilder. +     * @param {import('anki-note-builder').MinimalApi} api       * @param {import('../templates/template-renderer-proxy.js').TemplateRendererProxy|import('../templates/sandbox/template-renderer.js').TemplateRenderer} templateRenderer       */ -    constructor(templateRenderer) { +    constructor(api, templateRenderer) { +        /** @type {import('anki-note-builder').MinimalApi} */ +        this._api = api;          /** @type {RegExp} */          this._markerPattern = cloneFieldMarkerPattern(true);          /** @type {import('../templates/template-renderer-proxy.js').TemplateRendererProxy|import('../templates/sandbox/template-renderer.js').TemplateRenderer} */ @@ -431,7 +433,7 @@ export class AnkiNoteBuilder {          // Inject media          const selectionText = injectSelectionText ? this._getSelectionText() : null; -        const injectedMedia = await yomitan.api.injectAnkiNoteMedia( +        const injectedMedia = await this._api.injectAnkiNoteMedia(              timestamp,              dictionaryEntryDetails,              audioDetails, @@ -483,7 +485,7 @@ export class AnkiNoteBuilder {      async _getTextFurigana(entries, optionsContext, scanLength) {          const results = [];          for (const {text, readingMode} of entries) { -            const parseResults = await yomitan.api.parseText(text, optionsContext, scanLength, true, false); +            const parseResults = await this._api.parseText(text, optionsContext, scanLength, true, false);              let data = null;              for (const {source, content} of parseResults) {                  if (source !== 'scanning-parser') { continue; } |