Merge pull request #474 from siikamiika/fix-custom-anki-templates
fix custom anki templates
This commit is contained in:
commit
6a39b0cd7a
@ -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) => {
|
||||
|
Loading…
Reference in New Issue
Block a user