summaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2020-04-24 00:38:29 +0300
committerGitHub <noreply@github.com>2020-04-24 00:38:29 +0300
commit6a39b0cd7a5f3145300fe48942b55122734ae0a5 (patch)
tree3c267bf35f55e2e508798bf3e2d30937fb5fed45 /ext/bg
parent1fea8a3a10a0548da9f29552a6c97a89311fb8ed (diff)
parent6cd86e203ac243b7cde09df46920319dfb2b56b4 (diff)
Merge pull request #474 from siikamiika/fix-custom-anki-templates
fix custom anki templates
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/js/backend.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js
index 8a19203f..6b696f2c 100644
--- a/ext/bg/js/backend.js
+++ b/ext/bg/js/backend.js
@@ -496,7 +496,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') {
const {customSourceUrl} = options.audio;
@@ -522,7 +522,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 {
@@ -945,6 +945,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) => {