diff options
| author | siikamiika <siikamiika@users.noreply.github.com> | 2020-04-23 19:58:31 +0300 | 
|---|---|---|
| committer | siikamiika <siikamiika@users.noreply.github.com> | 2020-04-24 00:46:18 +0300 | 
| commit | db0eff6ecaf175253ca7111bc1b5309d42a5fec3 (patch) | |
| tree | d046b74fd35698709576042af608e27f8ce3f2b9 /ext/bg/js/backend.js | |
| parent | 281023095a9fb7f7aca1df8dc0e3f902e78dc16b (diff) | |
fix custom anki templates
Diffstat (limited to 'ext/bg/js/backend.js')
| -rw-r--r-- | ext/bg/js/backend.js | 9 | 
1 files changed, 7 insertions, 2 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 1fa7ede1..7060dc9e 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -461,7 +461,7 @@ class Backend {      async _onApiDefinitionAdd({definition, mode, context, details, optionsContext}) {          const options = this.getOptions(optionsContext); -        const templates = this.defaultAnkiFieldTemplates; +        const templates = this._getTemplates(options);          if (mode !== 'kanji') {              await this.ankiNoteBuilder.injectAudio( @@ -487,7 +487,7 @@ class Backend {      async _onApiDefinitionsAddable({definitions, modes, context, optionsContext}) {          const options = this.getOptions(optionsContext); -        const templates = this.defaultAnkiFieldTemplates; +        const templates = this._getTemplates(options);          const states = [];          try { @@ -809,6 +809,11 @@ class Backend {          return handlebarsRenderDynamic(template, data);      } +    _getTemplates(options) { +        const templates = options.anki.fieldTemplates; +        return typeof templates === 'string' ? templates : this.defaultAnkiFieldTemplates; +    } +      static _getTabUrl(tab) {          return new Promise((resolve) => {              chrome.tabs.sendMessage(tab.id, {action: 'getUrl'}, {frameId: 0}, (response) => {  |