diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-09-08 11:01:08 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-08 11:01:08 -0400 |
commit | f7093b4c1abf73363e65dba54a098b76d0f2ba50 (patch) | |
tree | c54fc65cb559d21450a1c2a3596ec222e40fc9ba /ext/bg/js/backend.js | |
parent | 36fc5abae543840484b3d8f7abff85f57de66ada (diff) |
Anki note clipboard marker (#780)
* Update fields reference
* Add support for adding clipboard images to anki notes
* Add handlebars templates
* Add markers
* Add markers to readme
Diffstat (limited to 'ext/bg/js/backend.js')
-rw-r--r-- | ext/bg/js/backend.js | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 047044df..e9f3fbec 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -60,7 +60,8 @@ class Backend { this._ankiNoteBuilder = new AnkiNoteBuilder({ anki: this._anki, audioSystem: this._audioSystem, - renderTemplate: this._renderTemplate.bind(this) + renderTemplate: this._renderTemplate.bind(this), + getClipboardImage: this._onApiClipboardImageGet.bind(this) }); this._templateRenderer = new TemplateRenderer(); @@ -444,21 +445,28 @@ class Backend { async _onApiDefinitionAdd({definition, mode, context, details, optionsContext}) { const options = this.getOptions(optionsContext); const templates = this._getTemplates(options); + const fields = ( + mode === 'kanji' ? + options.anki.kanji.fields : + options.anki.terms.fields + ); if (mode !== 'kanji') { const {customSourceUrl} = options.audio; await this._ankiNoteBuilder.injectAudio( definition, - options.anki.terms.fields, + fields, options.audio.sources, customSourceUrl ); } + await this._ankiNoteBuilder.injectClipboardImage(definition, fields); + if (details && details.screenshot) { await this._ankiNoteBuilder.injectScreenshot( definition, - options.anki.terms.fields, + fields, details.screenshot ); } |