aboutsummaryrefslogtreecommitdiff
path: root/ext/js/data
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/data')
-rw-r--r--ext/js/data/anki-note-builder.js12
-rw-r--r--ext/js/data/anki-note-data-creator.js2
-rw-r--r--ext/js/data/options-util.js8
3 files changed, 15 insertions, 7 deletions
diff --git a/ext/js/data/anki-note-builder.js b/ext/js/data/anki-note-builder.js
index 13e83aaf..85a68265 100644
--- a/ext/js/data/anki-note-builder.js
+++ b/ext/js/data/anki-note-builder.js
@@ -29,7 +29,7 @@ class AnkiNoteBuilder {
}
async createNote({
- definition,
+ dictionaryEntry,
mode,
context,
template,
@@ -53,7 +53,7 @@ class AnkiNoteBuilder {
duplicateScopeCheckChildren = true;
}
- const commonData = this._createData(definition, mode, context, resultOutputMode, glossaryLayoutMode, compactTags, injectedMedia);
+ const commonData = this._createData(dictionaryEntry, mode, context, resultOutputMode, glossaryLayoutMode, compactTags, injectedMedia);
const formattedFieldValuePromises = [];
for (const [, fieldValue] of fields) {
const formattedFieldValuePromise = this._formatField(fieldValue, commonData, template, errors);
@@ -85,7 +85,7 @@ class AnkiNoteBuilder {
}
async getRenderingData({
- definition,
+ dictionaryEntry,
mode,
context,
resultOutputMode='split',
@@ -94,15 +94,15 @@ class AnkiNoteBuilder {
injectedMedia=null,
marker=null
}) {
- const commonData = this._createData(definition, mode, context, resultOutputMode, glossaryLayoutMode, compactTags, injectedMedia);
+ const commonData = this._createData(dictionaryEntry, mode, context, resultOutputMode, glossaryLayoutMode, compactTags, injectedMedia);
return await this._templateRenderer.getModifiedData({marker, commonData}, 'ankiNote');
}
// Private
- _createData(definition, mode, context, resultOutputMode, glossaryLayoutMode, compactTags, injectedMedia) {
+ _createData(dictionaryEntry, mode, context, resultOutputMode, glossaryLayoutMode, compactTags, injectedMedia) {
return {
- definition,
+ dictionaryEntry,
mode,
context,
resultOutputMode,
diff --git a/ext/js/data/anki-note-data-creator.js b/ext/js/data/anki-note-data-creator.js
index e7abaa21..1c32c4b4 100644
--- a/ext/js/data/anki-note-data-creator.js
+++ b/ext/js/data/anki-note-data-creator.js
@@ -38,7 +38,7 @@ class AnkiNoteDataCreator {
* @returns An object used for rendering Anki templates.
*/
create(marker, {
- definition: dictionaryEntry,
+ dictionaryEntry,
resultOutputMode,
mode,
glossaryLayoutMode,
diff --git a/ext/js/data/options-util.js b/ext/js/data/options-util.js
index 857ef630..42f9a38f 100644
--- a/ext/js/data/options-util.js
+++ b/ext/js/data/options-util.js
@@ -791,12 +791,20 @@ class OptionsUtil {
_updateVersion11(options) {
// Version 11 changes:
// Changed dictionaries to an array.
+ // Changed audio.customSourceUrl's {expression} marker to {term}.
+ const customSourceUrlPattern = /\{expression\}/g;
for (const profile of options.profiles) {
const dictionariesNew = [];
for (const [name, {priority, enabled, allowSecondarySearches, definitionsCollapsible}] of Object.entries(profile.options.dictionaries)) {
dictionariesNew.push({name, priority, enabled, allowSecondarySearches, definitionsCollapsible});
}
profile.options.dictionaries = dictionariesNew;
+
+ let {customSourceUrl} = profile.options.audio;
+ if (typeof customSourceUrl === 'string') {
+ customSourceUrl = customSourceUrl.replace(customSourceUrlPattern, '{term}');
+ }
+ profile.options.audio.customSourceUrl = customSourceUrl;
}
return options;
}