summaryrefslogtreecommitdiff
path: root/ext/bg/js/backend.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js/backend.js')
-rw-r--r--ext/bg/js/backend.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js
index ca03f94d..1a874dc8 100644
--- a/ext/bg/js/backend.js
+++ b/ext/bg/js/backend.js
@@ -321,6 +321,7 @@ class Backend {
async _onApiDefinitionAdd({definition, mode, context, optionsContext}) {
const options = await this.getOptions(optionsContext);
+ const templates = Backend._getTemplates(options);
if (mode !== 'kanji') {
await audioInject(
@@ -339,19 +340,20 @@ class Backend {
);
}
- const note = await dictNoteFormat(definition, mode, options);
+ const note = await dictNoteFormat(definition, mode, options, templates);
return this.anki.addNote(note);
}
async _onApiDefinitionsAddable({definitions, modes, optionsContext}) {
const options = await this.getOptions(optionsContext);
+ const templates = Backend._getTemplates(options);
const states = [];
try {
const notes = [];
for (const definition of definitions) {
for (const mode of modes) {
- const note = await dictNoteFormat(definition, mode, options);
+ const note = await dictNoteFormat(definition, mode, options, templates);
notes.push(note);
}
}
@@ -672,6 +674,11 @@ class Backend {
return 'chrome';
}
}
+
+ static _getTemplates(options) {
+ const templates = options.anki.fieldTemplates;
+ return typeof templates === 'string' ? templates : profileOptionsGetDefaultFieldTemplates();
+ }
}
Backend._messageHandlers = new Map([