diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/bg/js/anki-note-builder.js | 7 | ||||
-rw-r--r-- | ext/bg/js/backend.js | 7 |
2 files changed, 9 insertions, 5 deletions
diff --git a/ext/bg/js/anki-note-builder.js b/ext/bg/js/anki-note-builder.js index 0e17783b..1ccec20c 100644 --- a/ext/bg/js/anki-note-builder.js +++ b/ext/bg/js/anki-note-builder.js @@ -17,7 +17,8 @@ */ class AnkiNoteBuilder { - constructor({renderTemplate}) { + constructor({audioSystem, renderTemplate}) { + this._audioSystem = audioSystem; this._renderTemplate = renderTemplate; } @@ -84,14 +85,14 @@ class AnkiNoteBuilder { }); } - async injectAudio(definition, fields, sources, audioSystem, optionsContext) { + async injectAudio(definition, fields, sources, optionsContext) { if (!this._containsMarker(fields, 'audio')) { return; } try { const expressions = definition.expressions; const audioSourceDefinition = Array.isArray(expressions) ? expressions[0] : definition; - const {uri} = await audioSystem.getDefinitionAudio(audioSourceDefinition, sources, {tts: false, optionsContext}); + const {uri} = await this.audioSystem.getDefinitionAudio(audioSourceDefinition, sources, {tts: false, optionsContext}); const filename = this._createInjectedAudioFileName(audioSourceDefinition); if (filename !== null) { definition.audio = {url: uri, filename}; diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 9e02cced..1fa7ede1 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -51,12 +51,16 @@ class Backend { this.anki = new AnkiNull(); this.mecab = new Mecab(); this.clipboardMonitor = new ClipboardMonitor({getClipboard: this._onApiClipboardGet.bind(this)}); - this.ankiNoteBuilder = new AnkiNoteBuilder({renderTemplate: this._renderTemplate.bind(this)}); this.options = null; this.optionsSchema = null; this.defaultAnkiFieldTemplates = null; this.audioSystem = new AudioSystem({getAudioUri: this._getAudioUri.bind(this)}); this.audioUriBuilder = new AudioUriBuilder(); + this.ankiNoteBuilder = new AnkiNoteBuilder({ + audioSystem: this.audioSystem, + renderTemplate: this._renderTemplate.bind(this) + }); + this.optionsContext = { depth: 0, url: window.location.href @@ -464,7 +468,6 @@ class Backend { definition, options.anki.terms.fields, options.audio.sources, - this.audioSystem, optionsContext ); } |