diff --git a/.eslintrc.json b/.eslintrc.json
index 9d47b369..fbbe9925 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -114,7 +114,8 @@
"ext/js/display/structured-content-generator.js",
"ext/js/dom/css-style-applier.js",
"ext/js/language/dictionary-data-util.js",
- "ext/js/templates/template-renderer.js"
+ "ext/js/templates/template-renderer.js",
+ "ext/js/templates/template-renderer-media-provider.js"
],
"env": {
"webextensions": false
@@ -128,7 +129,8 @@
"ext/js/display/structured-content-generator.js",
"ext/js/dom/css-style-applier.js",
"ext/js/language/dictionary-data-util.js",
- "ext/js/templates/template-renderer.js"
+ "ext/js/templates/template-renderer.js",
+ "ext/js/templates/template-renderer-media-provider.js"
],
"globals": {
"serializeError": "readonly",
@@ -159,7 +161,8 @@
"ext/js/display/structured-content-generator.js",
"ext/js/dom/css-style-applier.js",
"ext/js/language/dictionary-data-util.js",
- "ext/js/templates/template-renderer.js"
+ "ext/js/templates/template-renderer.js",
+ "ext/js/templates/template-renderer-media-provider.js"
],
"globals": {
"yomichan": "readonly"
diff --git a/dev/translator-vm.js b/dev/translator-vm.js
index 7eab47b8..d628608a 100644
--- a/dev/translator-vm.js
+++ b/dev/translator-vm.js
@@ -120,7 +120,7 @@ class TranslatorVM extends DatabaseVM {
query: 'query',
fullQuery: 'fullQuery'
},
- injectedMedia: null
+ media: {}
};
return this._ankiNoteDataCreator.create(marker, data);
}
diff --git a/ext/data/templates/anki-field-templates-upgrade-v13.handlebars b/ext/data/templates/anki-field-templates-upgrade-v13.handlebars
index 04cc855a..ebf9069e 100644
--- a/ext/data/templates/anki-field-templates-upgrade-v13.handlebars
+++ b/ext/data/templates/anki-field-templates-upgrade-v13.handlebars
@@ -15,3 +15,37 @@
{{=======}}
{{#each glossary}}
{{#formatGlossary ../dictionary}}{{{.}}}{{/formatGlossary}}{{/each}}
{{>>>>>>>}}
+
+{{<<<<<<<}}
+ {{~#if definition.audioFileName~}}
+ [sound:{{definition.audioFileName}}]
+ {{~/if~}}
+{{=======}}
+ {{~#if (hasMedia "audio")~}}
+ [sound:{{#getMedia "audio" format="fileName"}}{{/getMedia}}]
+ {{~/if~}}
+{{>>>>>>>}}
+
+{{<<<<<<<}}
+
+{{=======}}
+ {{~#if (hasMedia "screenshot")~}}
+
+ {{~/if~}}
+{{>>>>>>>}}
+
+{{<<<<<<<}}
+ {{~#if definition.clipboardImageFileName~}}
+
+ {{~/if~}}
+{{=======}}
+ {{~#if (hasMedia "clipboardImage")~}}
+
+ {{~/if~}}
+{{>>>>>>>}}
+
+{{<<<<<<<}}
+{{~#if definition.clipboardText~}}{{definition.clipboardText}}{{~/if~}}
+{{=======}}
+{{~#if (hasMedia "clipboardText")}}{{#getMedia "clipboardText" format="text"}}{{/getMedia}}{{/if~}}
+{{>>>>>>>}}
diff --git a/ext/data/templates/default-anki-field-templates.handlebars b/ext/data/templates/default-anki-field-templates.handlebars
index 67547732..62da796d 100644
--- a/ext/data/templates/default-anki-field-templates.handlebars
+++ b/ext/data/templates/default-anki-field-templates.handlebars
@@ -31,8 +31,8 @@
{{/inline}}
{{#*inline "audio"}}
- {{~#if definition.audioFileName~}}
- [sound:{{definition.audioFileName}}]
+ {{~#if (hasMedia "audio")~}}
+ [sound:{{#getMedia "audio" format="fileName"}}{{/getMedia}}]
{{~/if~}}
{{/inline}}
@@ -173,7 +173,9 @@
{{/inline}}
{{#*inline "screenshot"}}
-
+ {{~#if (hasMedia "screenshot")~}}
+
+ {{~/if~}}
{{/inline}}
{{#*inline "document-title"}}
@@ -291,13 +293,13 @@
{{! End Pitch Accents }}
{{#*inline "clipboard-image"}}
- {{~#if definition.clipboardImageFileName~}}
-
+ {{~#if (hasMedia "clipboardImage")~}}
+
{{~/if~}}
{{/inline}}
{{#*inline "clipboard-text"}}
- {{~#if definition.clipboardText~}}{{definition.clipboardText}}{{~/if~}}
+ {{~#if (hasMedia "clipboardText")}}{{#getMedia "clipboardText" format="text"}}{{/getMedia}}{{/if~}}
{{/inline}}
{{#*inline "conjugation"}}
diff --git a/ext/js/data/anki-note-builder.js b/ext/js/data/anki-note-builder.js
index 6077eec1..c69d6741 100644
--- a/ext/js/data/anki-note-builder.js
+++ b/ext/js/data/anki-note-builder.js
@@ -37,12 +37,13 @@ class AnkiNoteBuilder {
modelName,
fields,
tags=[],
- injectedMedia=null,
+ requirements=[],
checkForDuplicates=true,
duplicateScope='collection',
resultOutputMode='split',
glossaryLayoutMode='default',
- compactTags=false
+ compactTags=false,
+ mediaOptions=null
}) {
let duplicateScopeDeckName = null;
let duplicateScopeCheckChildren = false;
@@ -52,7 +53,19 @@ class AnkiNoteBuilder {
duplicateScopeCheckChildren = true;
}
- const commonData = this._createData(dictionaryEntry, mode, context, resultOutputMode, glossaryLayoutMode, compactTags, injectedMedia);
+ const allErrors = [];
+ let media;
+ if (requirements.length > 0 && mediaOptions !== null) {
+ let errors;
+ ({media, errors} = await this._injectMedia(dictionaryEntry, requirements, mediaOptions));
+ for (const error of errors) {
+ allErrors.push(deserializeError(error));
+ }
+ } else {
+ media = {};
+ }
+
+ const commonData = this._createData(dictionaryEntry, mode, context, resultOutputMode, glossaryLayoutMode, compactTags, media);
const formattedFieldValuePromises = [];
for (const [, fieldValue] of fields) {
const formattedFieldValuePromise = this._formatField(fieldValue, commonData, template);
@@ -60,15 +73,14 @@ class AnkiNoteBuilder {
}
const formattedFieldValues = await Promise.all(formattedFieldValuePromises);
- const errors = [];
const uniqueRequirements = new Map();
const noteFields = {};
for (let i = 0, ii = fields.length; i < ii; ++i) {
const fieldName = fields[i][0];
- const {value, errors: fieldErrors, requirements} = formattedFieldValues[i];
+ const {value, errors: fieldErrors, requirements: fieldRequirements} = formattedFieldValues[i];
noteFields[fieldName] = value;
- errors.push(...fieldErrors);
- for (const requirement of requirements) {
+ allErrors.push(...fieldErrors);
+ for (const requirement of fieldRequirements) {
const key = JSON.stringify(requirement);
if (uniqueRequirements.has(key)) { continue; }
uniqueRequirements.set(key, requirement);
@@ -89,7 +101,7 @@ class AnkiNoteBuilder {
}
}
};
- return {note, errors, requirements: [...uniqueRequirements.values()]};
+ return {note, errors: allErrors, requirements: [...uniqueRequirements.values()]};
}
async getRenderingData({
@@ -99,16 +111,42 @@ class AnkiNoteBuilder {
resultOutputMode='split',
glossaryLayoutMode='default',
compactTags=false,
- injectedMedia=null,
marker=null
}) {
- const commonData = this._createData(dictionaryEntry, mode, context, resultOutputMode, glossaryLayoutMode, compactTags, injectedMedia);
+ const commonData = this._createData(dictionaryEntry, mode, context, resultOutputMode, glossaryLayoutMode, compactTags, {});
return await this._templateRenderer.getModifiedData({marker, commonData}, 'ankiNote');
}
+ getDictionaryEntryDetailsForNote(dictionaryEntry) {
+ const {type} = dictionaryEntry;
+ if (type === 'kanji') {
+ const {character} = dictionaryEntry;
+ return {type, character};
+ }
+
+ const {headwords} = dictionaryEntry;
+ let bestIndex = -1;
+ for (let i = 0, ii = headwords.length; i < ii; ++i) {
+ const {term, reading, sources} = headwords[i];
+ for (const {deinflectedText} of sources) {
+ if (term === deinflectedText) {
+ bestIndex = i;
+ i = ii;
+ break;
+ } else if (reading === deinflectedText && bestIndex < 0) {
+ bestIndex = i;
+ break;
+ }
+ }
+ }
+
+ const {term, reading} = headwords[Math.max(0, bestIndex)];
+ return {type, term, reading};
+ }
+
// Private
- _createData(dictionaryEntry, mode, context, resultOutputMode, glossaryLayoutMode, compactTags, injectedMedia) {
+ _createData(dictionaryEntry, mode, context, resultOutputMode, glossaryLayoutMode, compactTags, media) {
return {
dictionaryEntry,
mode,
@@ -116,7 +154,7 @@ class AnkiNoteBuilder {
resultOutputMode,
glossaryLayoutMode,
compactTags,
- injectedMedia
+ media
};
}
@@ -236,4 +274,68 @@ class AnkiNoteBuilder {
}
}
}
+
+ async _injectMedia(dictionaryEntry, requirements, mediaOptions) {
+ const timestamp = Date.now();
+
+ // Parse requirements
+ let injectAudio = false;
+ let injectScreenshot = false;
+ let injectClipboardImage = false;
+ let injectClipboardText = false;
+ const injectDictionaryMedia = [];
+ for (const requirement of requirements) {
+ const {type} = requirement;
+ switch (type) {
+ case 'audio': injectAudio = true; break;
+ case 'screenshot': injectScreenshot = true; break;
+ case 'clipboardImage': injectClipboardImage = true; break;
+ case 'clipboardText': injectClipboardText = true; break;
+ case 'dictionaryMedia': injectDictionaryMedia.push(requirement); break;
+ }
+ }
+
+ // Generate request data
+ const dictionaryEntryDetails = this.getDictionaryEntryDetailsForNote(dictionaryEntry);
+ let audioDetails = null;
+ let screenshotDetails = null;
+ const clipboardDetails = {image: injectClipboardImage, text: injectClipboardText};
+ if (injectAudio && dictionaryEntryDetails.type !== 'kanji') {
+ const audioOptions = mediaOptions.audio;
+ if (typeof audioOptions === 'object' && audioOptions !== null) {
+ const {sources, preferredAudioIndex} = audioOptions;
+ audioDetails = {sources, preferredAudioIndex};
+ }
+ }
+ if (injectScreenshot) {
+ const screenshotOptions = mediaOptions.screenshot;
+ if (typeof screenshotOptions === 'object' && screenshotOptions !== null) {
+ const {format, quality, contentOrigin: {tabId, frameId}} = screenshotOptions;
+ if (typeof tabId === 'number' && typeof frameId === 'number') {
+ screenshotDetails = {tabId, frameId, format, quality};
+ }
+ }
+ }
+
+ // Inject media
+ // TODO : injectDictionaryMedia
+ const {result: {audioFileName, screenshotFileName, clipboardImageFileName, clipboardText}, errors} = await yomichan.api.injectAnkiNoteMedia(
+ timestamp,
+ dictionaryEntryDetails,
+ audioDetails,
+ screenshotDetails,
+ clipboardDetails
+ );
+
+ // Format results
+ const dictionaryMedia = {}; // TODO
+ const media = {
+ audio: (typeof audioFileName === 'string' ? {fileName: audioFileName} : null),
+ screenshot: (typeof screenshotFileName === 'string' ? {fileName: screenshotFileName} : null),
+ clipboardImage: (typeof clipboardImageFileName === 'string' ? {fileName: clipboardImageFileName} : null),
+ clipboardText: (typeof clipboardText === 'string' ? {text: clipboardText} : null),
+ dictionaryMedia
+ };
+ return {media, errors};
+ }
}
diff --git a/ext/js/data/anki-note-data-creator.js b/ext/js/data/anki-note-data-creator.js
index 6a6bfd36..3622e837 100644
--- a/ext/js/data/anki-note-data-creator.js
+++ b/ext/js/data/anki-note-data-creator.js
@@ -44,15 +44,16 @@ class AnkiNoteDataCreator {
glossaryLayoutMode,
compactTags,
context,
- injectedMedia=null
+ media
}) {
const self = this;
- const definition = this.createCachedValue(this._getDefinition.bind(this, dictionaryEntry, injectedMedia, context, resultOutputMode));
+ const definition = this.createCachedValue(this._getDefinition.bind(this, dictionaryEntry, context, resultOutputMode));
const uniqueExpressions = this.createCachedValue(this._getUniqueExpressions.bind(this, dictionaryEntry));
const uniqueReadings = this.createCachedValue(this._getUniqueReadings.bind(this, dictionaryEntry));
const context2 = this.createCachedValue(this._getPublicContext.bind(this, context));
const pitches = this.createCachedValue(this._getPitches.bind(this, dictionaryEntry));
const pitchCount = this.createCachedValue(this._getPitchCount.bind(this, pitches));
+ if (typeof media !== 'object' || media === null || Array.isArray(media)) { media = {}; }
const result = {
marker,
get definition() { return self.getCachedValue(definition); },
@@ -68,7 +69,8 @@ class AnkiNoteDataCreator {
get uniqueReadings() { return self.getCachedValue(uniqueReadings); },
get pitches() { return self.getCachedValue(pitches); },
get pitchCount() { return self.getCachedValue(pitchCount); },
- get context() { return self.getCachedValue(context2); }
+ get context() { return self.getCachedValue(context2); },
+ media
};
Object.defineProperty(result, 'dictionaryEntry', {
configurable: false,
@@ -178,29 +180,22 @@ class AnkiNoteDataCreator {
return pitches.reduce((i, v) => i + v.pitches.length, 0);
}
- _getDefinition(dictionaryEntry, injectedMedia, context, resultOutputMode) {
+ _getDefinition(dictionaryEntry, context, resultOutputMode) {
switch (dictionaryEntry.type) {
case 'term':
- return this._getTermDefinition(dictionaryEntry, injectedMedia, context, resultOutputMode);
+ return this._getTermDefinition(dictionaryEntry, context, resultOutputMode);
case 'kanji':
- return this._getKanjiDefinition(dictionaryEntry, injectedMedia, context);
+ return this._getKanjiDefinition(dictionaryEntry, context);
default:
return {};
}
}
- _getKanjiDefinition(dictionaryEntry, injectedMedia, context) {
+ _getKanjiDefinition(dictionaryEntry, context) {
const self = this;
const {character, dictionary, onyomi, kunyomi, definitions} = dictionaryEntry;
- const {
- screenshotFileName=null,
- clipboardImageFileName=null,
- clipboardText=null,
- audioFileName=null
- } = this._asObject(injectedMedia);
-
let {url} = this._asObject(context);
if (typeof url !== 'string') { url = ''; }
@@ -219,10 +214,6 @@ class AnkiNoteDataCreator {
get tags() { return self.getCachedValue(tags); },
get stats() { return self.getCachedValue(stats); },
get frequencies() { return self.getCachedValue(frequencies); },
- screenshotFileName,
- clipboardImageFileName,
- clipboardText,
- audioFileName,
url,
get cloze() { return self.getCachedValue(cloze); }
};
@@ -265,7 +256,7 @@ class AnkiNoteDataCreator {
return results;
}
- _getTermDefinition(dictionaryEntry, injectedMedia, context, resultOutputMode) {
+ _getTermDefinition(dictionaryEntry, context, resultOutputMode) {
const self = this;
let type = 'term';
@@ -276,13 +267,6 @@ class AnkiNoteDataCreator {
const {inflections, score, dictionaryIndex, dictionaryPriority, sourceTermExactMatchCount, definitions} = dictionaryEntry;
- const {
- screenshotFileName=null,
- clipboardImageFileName=null,
- clipboardText=null,
- audioFileName=null
- } = this._asObject(injectedMedia);
-
let {url} = this._asObject(context);
if (typeof url !== 'string') { url = ''; }
@@ -331,10 +315,6 @@ class AnkiNoteDataCreator {
get frequencies() { return self.getCachedValue(frequencies); },
get pitches() { return self.getCachedValue(pitches); },
sourceTermExactMatchCount,
- screenshotFileName,
- clipboardImageFileName,
- clipboardText,
- audioFileName,
url,
get cloze() { return self.getCachedValue(cloze); },
get furiganaSegments() { return self.getCachedValue(furiganaSegments); }
diff --git a/ext/js/display/display-anki.js b/ext/js/display/display-anki.js
index b9fbb2bc..f5456ebb 100644
--- a/ext/js/display/display-anki.js
+++ b/ext/js/display/display-anki.js
@@ -100,7 +100,6 @@ class DisplayAnki {
resultOutputMode: this.resultOutputMode,
glossaryLayoutMode: this._glossaryLayoutMode,
compactTags: this._compactTags,
- injectedMedia: null,
marker: 'test'
});
} catch (e) {
@@ -119,7 +118,7 @@ class DisplayAnki {
let errors;
let requirements;
try {
- ({note: note, errors, requirements} = await this._createNote(dictionaryEntry, mode, false, []));
+ ({note: note, errors, requirements} = await this._createNote(dictionaryEntry, mode, []));
} catch (e) {
errors = [e];
}
@@ -237,33 +236,6 @@ class DisplayAnki {
};
}
- _getDictionaryEntryDetailsForNote(dictionaryEntry) {
- const {type} = dictionaryEntry;
- if (type === 'kanji') {
- const {character} = dictionaryEntry;
- return {type, character};
- }
-
- const {headwords} = dictionaryEntry;
- let bestIndex = -1;
- for (let i = 0, ii = headwords.length; i < ii; ++i) {
- const {term, reading, sources} = headwords[i];
- for (const {deinflectedText} of sources) {
- if (term === deinflectedText) {
- bestIndex = i;
- i = ii;
- break;
- } else if (reading === deinflectedText && bestIndex < 0) {
- bestIndex = i;
- break;
- }
- }
- }
-
- const {term, reading} = headwords[Math.max(0, bestIndex)];
- return {type, term, reading};
- }
-
async _updateDictionaryEntryDetails() {
const {dictionaryEntries} = this._display;
const token = {};
@@ -390,7 +362,7 @@ class DisplayAnki {
const progressIndicatorVisible = this._display.progressIndicatorVisible;
const overrideToken = progressIndicatorVisible.setOverride(true);
try {
- const {note, errors, requirements: outputRequirements} = await this._createNote(dictionaryEntry, mode, true, requirements);
+ const {note, errors, requirements: outputRequirements} = await this._createNote(dictionaryEntry, mode, requirements);
allErrors.push(...errors);
if (outputRequirements.length > 0) {
@@ -494,7 +466,7 @@ class DisplayAnki {
const modes = this._dictionaryEntryTypeModeMap.get(type);
if (typeof modes === 'undefined') { continue; }
for (const mode of modes) {
- const notePromise = this._createNote(dictionaryEntry, mode, false, []);
+ const notePromise = this._createNote(dictionaryEntry, mode, []);
notePromises.push(notePromise);
noteTargets.push({index: i, mode});
}
@@ -544,25 +516,18 @@ class DisplayAnki {
return results;
}
- async _createNote(dictionaryEntry, mode, injectMedia, _requirements) {
+ async _createNote(dictionaryEntry, mode, requirements) {
const context = this._noteContext;
const modeOptions = this._modeOptions.get(mode);
if (typeof modeOptions === 'undefined') { throw new Error(`Unsupported note type: ${mode}`); }
const template = this._ankiFieldTemplates;
const {deck: deckName, model: modelName} = modeOptions;
const fields = Object.entries(modeOptions.fields);
+ const contentOrigin = this._display.getContentOrigin();
+ const details = this._ankiNoteBuilder.getDictionaryEntryDetailsForNote(dictionaryEntry);
+ const audioDetails = (details.type === 'term' ? this._display.getAnkiNoteMediaAudioDetails(details.term, details.reading) : null);
- const errors = [];
- let injectedMedia = null;
- if (injectMedia) {
- let errors2;
- ({result: injectedMedia, errors: errors2} = await this._injectAnkiNoteMedia(dictionaryEntry, fields));
- for (const error of errors2) {
- errors.push(deserializeError(error));
- }
- }
-
- const {note, errors: createNoteErrors, requirements: outputRequirements} = await this._ankiNoteBuilder.createNote({
+ const {note, errors, requirements: outputRequirements} = await this._ankiNoteBuilder.createNote({
dictionaryEntry,
mode,
context,
@@ -576,45 +541,19 @@ class DisplayAnki {
resultOutputMode: this.resultOutputMode,
glossaryLayoutMode: this._glossaryLayoutMode,
compactTags: this._compactTags,
- injectedMedia,
- errors
+ mediaOptions: {
+ audio: audioDetails,
+ screenshot: {
+ format: this._screenshotFormat,
+ quality: this._screenshotQuality,
+ contentOrigin
+ }
+ },
+ requirements
});
- errors.push(...createNoteErrors);
return {note, errors, requirements: outputRequirements};
}
- async _injectAnkiNoteMedia(dictionaryEntry, fields) {
- const timestamp = Date.now();
-
- const dictionaryEntryDetails = this._getDictionaryEntryDetailsForNote(dictionaryEntry);
-
- const audioDetails = (
- dictionaryEntryDetails.type !== 'kanji' && AnkiUtil.fieldsObjectContainsMarker(fields, 'audio') ?
- this._display.getAnkiNoteMediaAudioDetails(dictionaryEntryDetails.term, dictionaryEntryDetails.reading) :
- null
- );
-
- const {tabId, frameId} = this._display.getContentOrigin();
- const screenshotDetails = (
- AnkiUtil.fieldsObjectContainsMarker(fields, 'screenshot') && typeof tabId === 'number' ?
- {tabId, frameId, format: this._screenshotFormat, quality: this._screenshotQuality} :
- null
- );
-
- const clipboardDetails = {
- image: AnkiUtil.fieldsObjectContainsMarker(fields, 'clipboard-image'),
- text: AnkiUtil.fieldsObjectContainsMarker(fields, 'clipboard-text')
- };
-
- return await yomichan.api.injectAnkiNoteMedia(
- timestamp,
- dictionaryEntryDetails,
- audioDetails,
- screenshotDetails,
- clipboardDetails
- );
- }
-
_getModes(isTerms) {
return isTerms ? ['term-kanji', 'term-kana'] : ['kanji'];
}
diff --git a/ext/js/templates/template-renderer-media-provider.js b/ext/js/templates/template-renderer-media-provider.js
new file mode 100644
index 00000000..db4a6d18
--- /dev/null
+++ b/ext/js/templates/template-renderer-media-provider.js
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2021 Yomichan Authors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+class TemplateRendererMediaProvider {
+ constructor() {
+ this._requirements = null;
+ }
+
+ get requirements() {
+ return this._requirements;
+ }
+
+ set requirements(value) {
+ this._requirements = value;
+ }
+
+ hasMedia(root, args, namedArgs) {
+ const {media} = root;
+ const data = this._getMediaData(media, args, namedArgs);
+ return (data !== null);
+ }
+
+ getMedia(root, args, namedArgs) {
+ const {media} = root;
+ const data = this._getMediaData(media, args, namedArgs);
+ if (data !== null) {
+ const {format} = namedArgs;
+ const result = this._getFormattedValue(data, format);
+ if (typeof result === 'string') { return result; }
+ }
+ const defaultValue = namedArgs.default;
+ return typeof defaultValue !== 'undefined' ? defaultValue : '';
+ }
+
+ // Private
+
+ _addRequirement(value) {
+ if (this._requirements === null) { return; }
+ this._requirements.push(value);
+ }
+
+ _getFormattedValue(data, format) {
+ switch (format) {
+ case 'fileName':
+ {
+ const {fileName} = data;
+ if (typeof fileName === 'string') { return fileName; }
+ }
+ break;
+ case 'text':
+ {
+ const {text} = data;
+ if (typeof text === 'string') { return text; }
+ }
+ break;
+ }
+ return null;
+ }
+
+ _getMediaData(media, args, namedArgs) {
+ const type = args[0];
+ switch (type) {
+ case 'audio': return this._getSimpleMediaData(media, 'audio');
+ case 'screenshot': return this._getSimpleMediaData(media, 'screenshot');
+ case 'clipboardImage': return this._getSimpleMediaData(media, 'clipboardImage');
+ case 'clipboardText': return this._getSimpleMediaData(media, 'clipboardText');
+ case 'dictionaryMedia': return this._getDictionaryMedia(media, args[1], namedArgs);
+ default: return null;
+ }
+ }
+
+ _getSimpleMediaData(media, type) {
+ const result = media[type];
+ if (typeof result === 'object' && result !== null) { return result; }
+ this._addRequirement({type});
+ return null;
+ }
+
+ _getDictionaryMedia(media, path, namedArgs) {
+ const {dictionaryMedia} = media;
+ const {dictionary} = namedArgs;
+ if (
+ typeof dictionaryMedia !== 'undefined' &&
+ typeof dictionary === 'string' &&
+ Object.prototype.hasOwnProperty.call(dictionaryMedia, dictionary)
+ ) {
+ const dictionaryMedia2 = dictionaryMedia[dictionary];
+ if (Object.prototype.hasOwnProperty.call(dictionaryMedia2, path)) {
+ const result = dictionaryMedia2[path];
+ if (typeof result === 'object' && result !== null) {
+ return result;
+ }
+ }
+ }
+ this._addRequirement({
+ type: 'dictionaryMedia',
+ dictionary,
+ path
+ });
+ return null;
+ }
+}
diff --git a/ext/js/templates/template-renderer.js b/ext/js/templates/template-renderer.js
index f9fbdeb5..02471c97 100644
--- a/ext/js/templates/template-renderer.js
+++ b/ext/js/templates/template-renderer.js
@@ -19,12 +19,14 @@
* DictionaryDataUtil
* Handlebars
* StructuredContentGenerator
+ * TemplateRendererMediaProvider
*/
class TemplateRenderer {
constructor(japaneseUtil, cssStyleApplier) {
this._japaneseUtil = japaneseUtil;
this._cssStyleApplier = cssStyleApplier;
+ this._mediaProvider = new TemplateRendererMediaProvider();
this._cache = new Map();
this._cacheMaxSize = 5;
this._helpersRegistered = false;
@@ -94,6 +96,7 @@ class TemplateRenderer {
try {
this._stateStack = [new Map()];
this._requirements = requirements;
+ this._mediaProvider.requirements = requirements;
this._cleanupCallbacks = cleanupCallbacks;
const result = instance(data).trim();
return {result, requirements};
@@ -101,6 +104,7 @@ class TemplateRenderer {
for (const callback of cleanupCallbacks) { callback(); }
this._stateStack = null;
this._requirements = null;
+ this._mediaProvider.requirements = null;
this._cleanupCallbacks = null;
}
}
@@ -162,7 +166,9 @@ class TemplateRenderer {
['join', this._join.bind(this)],
['concat', this._concat.bind(this)],
['pitchCategories', this._pitchCategories.bind(this)],
- ['formatGlossary', this._formatGlossary.bind(this)]
+ ['formatGlossary', this._formatGlossary.bind(this)],
+ ['hasMedia', this._hasMedia.bind(this)],
+ ['getMedia', this._getMedia.bind(this)]
];
for (const [name, helper] of helpers) {
@@ -563,33 +569,13 @@ class TemplateRenderer {
parentNode.replaceChild(fragment, textNode);
}
- _getDictionaryMedia(data, dictionary, path) {
- const {media} = data;
- if (typeof media === 'object' && media !== null && Object.prototype.hasOwnProperty.call(media, 'dictionaryMedia')) {
- const {dictionaryMedia} = media;
- if (typeof dictionaryMedia === 'object' && dictionaryMedia !== null && Object.prototype.hasOwnProperty.call(dictionaryMedia, dictionary)) {
- const dictionaryMedia2 = dictionaryMedia[dictionary];
- if (Object.prototype.hasOwnProperty.call(dictionaryMedia2, path)) {
- return dictionaryMedia2[path];
- }
- }
- }
- return null;
- }
-
_createStructuredContentGenerator(data) {
const mediaLoader = {
loadMedia: async (path, dictionary, onLoad, onUnload) => {
- const imageUrl = this._getDictionaryMedia(data, dictionary, path);
+ const imageUrl = this._mediaProvider.getMedia(data, ['dictionaryMedia', path], {dictionary, format: 'fileName', default: null});
if (imageUrl !== null) {
onLoad(imageUrl);
this._cleanupCallbacks.push(() => onUnload(true));
- } else {
- this._requirements.push({
- type: 'dictionaryMedia',
- dictionary,
- path
- });
}
}
};
@@ -619,4 +605,16 @@ class TemplateRenderer {
const node = structuredContentGenerator.createStructuredContent(content.content, dictionary);
return node !== null ? this._getHtml(node) : '';
}
+
+ _hasMedia(context, ...args) {
+ const ii = args.length - 1;
+ const options = args[ii];
+ return this._mediaProvider.hasMedia(options.data.root, args.slice(0, ii), options.hash);
+ }
+
+ _getMedia(context, ...args) {
+ const ii = args.length - 1;
+ const options = args[ii];
+ return this._mediaProvider.getMedia(options.data.root, args.slice(0, ii), options.hash);
+ }
}
diff --git a/ext/template-renderer.html b/ext/template-renderer.html
index f01b5b9a..a3812b37 100644
--- a/ext/template-renderer.html
+++ b/ext/template-renderer.html
@@ -24,6 +24,7 @@
+
diff --git a/test/data/anki-note-builder-test-results.json b/test/data/anki-note-builder-test-results.json
index c8357cb3..7a895dcb 100644
--- a/test/data/anki-note-builder-test-results.json
+++ b/test/data/anki-note-builder-test-results.json
@@ -14,7 +14,7 @@
"glossary": "- utsu meaning 1
- utsu meaning 2
- utsu meaning 3
- utsu meaning 4
- utsu meaning 5
",
"kunyomi": "う.つ, う.ち-, ぶ.つ",
"onyomi": "ダ, ダアス",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打cloze-suffix",
"stroke-count": "Stroke count: Unknown",
@@ -38,7 +38,7 @@
"glossary": "- komu meaning 1
- komu meaning 2
- komu meaning 3
- komu meaning 4
- komu meaning 5
",
"kunyomi": "-こ.む, こ.む, こ.み, -こ.み, こ.める",
"onyomi": "",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix込cloze-suffix",
"stroke-count": "Stroke count: Unknown",
@@ -76,7 +76,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "だ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打cloze-suffix",
"tags": "n",
@@ -104,7 +104,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "ダース",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打cloze-suffix",
"tags": "abbr, n",
@@ -137,7 +137,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "うつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打つcloze-suffix",
"tags": "vt",
@@ -165,7 +165,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "ぶつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打つcloze-suffix",
"tags": "vt",
@@ -193,7 +193,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "うつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打つcloze-suffix",
"tags": "vt",
@@ -221,7 +221,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "ぶつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打つcloze-suffix",
"tags": "vt",
@@ -249,7 +249,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "だ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打cloze-suffix",
"tags": "n",
@@ -277,7 +277,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "ダース",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打cloze-suffix",
"tags": "abbr, n",
@@ -310,7 +310,7 @@
"pitch-accent-graphs": "
",
"pitch-accent-positions": "- [0]
- [3]
",
"reading": "うちこむ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打ち込むcloze-suffix",
"tags": "vt",
@@ -338,7 +338,7 @@
"pitch-accent-graphs": "
",
"pitch-accent-positions": "- [0]
- [3]
",
"reading": "ぶちこむ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打ち込むcloze-suffix",
"tags": "vt",
@@ -366,7 +366,7 @@
"pitch-accent-graphs": "
",
"pitch-accent-positions": "- [0]
- [3]
",
"reading": "うちこむ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打ち込むcloze-suffix",
"tags": "vt",
@@ -394,7 +394,7 @@
"pitch-accent-graphs": "
",
"pitch-accent-positions": "- [0]
- [3]
",
"reading": "ぶちこむ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打ち込むcloze-suffix",
"tags": "vt",
@@ -422,7 +422,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "うつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打ちcloze-suffix",
"tags": "vt",
@@ -450,7 +450,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "ぶつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打ちcloze-suffix",
"tags": "vt",
@@ -478,7 +478,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "うつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打ちcloze-suffix",
"tags": "vt",
@@ -506,7 +506,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "ぶつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打ちcloze-suffix",
"tags": "vt",
@@ -534,7 +534,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "だ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打cloze-suffix",
"tags": "n",
@@ -562,7 +562,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "ダース",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打cloze-suffix",
"tags": "abbr, n",
@@ -595,7 +595,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "がぞう",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix画像cloze-suffix",
"tags": "n",
@@ -628,7 +628,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "だ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefixだcloze-suffix",
"tags": "n",
@@ -661,7 +661,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "ダース",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefixダースcloze-suffix",
"tags": "abbr, n",
@@ -694,7 +694,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "うつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefixうつcloze-suffix",
"tags": "vt",
@@ -722,7 +722,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "うつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefixうつcloze-suffix",
"tags": "vt",
@@ -755,7 +755,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "ぶつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefixぶつcloze-suffix",
"tags": "vt",
@@ -783,7 +783,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "ぶつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefixぶつcloze-suffix",
"tags": "vt",
@@ -816,7 +816,7 @@
"pitch-accent-graphs": "
",
"pitch-accent-positions": "- [0]
- [3]
",
"reading": "うちこむ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefixうちこむcloze-suffix",
"tags": "vt",
@@ -844,7 +844,7 @@
"pitch-accent-graphs": "
",
"pitch-accent-positions": "- [0]
- [3]
",
"reading": "うちこむ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefixうちこむcloze-suffix",
"tags": "vt",
@@ -872,7 +872,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "うつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefixうちcloze-suffix",
"tags": "vt",
@@ -900,7 +900,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "うつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefixうちcloze-suffix",
"tags": "vt",
@@ -933,7 +933,7 @@
"pitch-accent-graphs": "
",
"pitch-accent-positions": "- [0]
- [3]
",
"reading": "ぶちこむ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefixぶちこむcloze-suffix",
"tags": "vt",
@@ -961,7 +961,7 @@
"pitch-accent-graphs": "
",
"pitch-accent-positions": "- [0]
- [3]
",
"reading": "ぶちこむ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefixぶちこむcloze-suffix",
"tags": "vt",
@@ -989,7 +989,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "ぶつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefixぶちcloze-suffix",
"tags": "vt",
@@ -1017,7 +1017,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "ぶつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefixぶちcloze-suffix",
"tags": "vt",
@@ -1050,7 +1050,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "がぞう",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefixがぞうcloze-suffix",
"tags": "n",
@@ -1095,7 +1095,7 @@
"pitch-accent-graphs": "
",
"pitch-accent-positions": "- [0]
- [3]
",
"reading": "うちこむ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打ち込むcloze-suffix",
"tags": "vt",
@@ -1123,7 +1123,7 @@
"pitch-accent-graphs": "
",
"pitch-accent-positions": "- [0]
- [3]
",
"reading": "ぶちこむ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打ち込むcloze-suffix",
"tags": "vt",
@@ -1151,7 +1151,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "うつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打ちcloze-suffix",
"tags": "vt",
@@ -1179,7 +1179,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "ぶつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打ちcloze-suffix",
"tags": "vt",
@@ -1207,7 +1207,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "だ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打cloze-suffix",
"tags": "n",
@@ -1235,7 +1235,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "ダース",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打cloze-suffix",
"tags": "abbr, n",
@@ -1268,7 +1268,7 @@
"pitch-accent-graphs": "- (うちこむ only)
- (うちこむ only)
- (ぶちこむ only)
- (ぶちこむ only)
",
"pitch-accent-positions": "- (うちこむ only) [0]
- (うちこむ only) [3]
- (ぶちこむ only) [0]
- (ぶちこむ only) [3]
",
"reading": "うちこむ、ぶちこむ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打ち込むcloze-suffix",
"tags": "vt",
@@ -1296,7 +1296,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "うつ、ぶつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打ちcloze-suffix",
"tags": "vt",
@@ -1324,7 +1324,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "だ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打cloze-suffix",
"tags": "n",
@@ -1352,7 +1352,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "ダース",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打cloze-suffix",
"tags": "abbr, n",
@@ -1385,7 +1385,7 @@
"pitch-accent-graphs": "
",
"pitch-accent-positions": "- [0]
- [3]
",
"reading": "うちこむ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打ち込んでいませんでしたcloze-suffix",
"tags": "vt",
@@ -1413,7 +1413,7 @@
"pitch-accent-graphs": "
",
"pitch-accent-positions": "- [0]
- [3]
",
"reading": "ぶちこむ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打ち込んでいませんでしたcloze-suffix",
"tags": "vt",
@@ -1441,7 +1441,7 @@
"pitch-accent-graphs": "
",
"pitch-accent-positions": "- [0]
- [3]
",
"reading": "うちこむ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打ち込んでいませんでしたcloze-suffix",
"tags": "vt",
@@ -1469,7 +1469,7 @@
"pitch-accent-graphs": "
",
"pitch-accent-positions": "- [0]
- [3]
",
"reading": "ぶちこむ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打ち込んでいませんでしたcloze-suffix",
"tags": "vt",
@@ -1497,7 +1497,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "うつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打ちcloze-suffix",
"tags": "vt",
@@ -1525,7 +1525,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "ぶつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打ちcloze-suffix",
"tags": "vt",
@@ -1553,7 +1553,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "うつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打ちcloze-suffix",
"tags": "vt",
@@ -1581,7 +1581,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "ぶつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打ちcloze-suffix",
"tags": "vt",
@@ -1609,7 +1609,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "だ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打cloze-suffix",
"tags": "n",
@@ -1637,7 +1637,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "ダース",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打cloze-suffix",
"tags": "abbr, n",
@@ -1670,7 +1670,7 @@
"pitch-accent-graphs": "
",
"pitch-accent-positions": "- [0]
- [3]
",
"reading": "うちこむ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打(う)ち込(こ)むcloze-suffix",
"tags": "vt",
@@ -1698,7 +1698,7 @@
"pitch-accent-graphs": "
",
"pitch-accent-positions": "- [0]
- [3]
",
"reading": "ぶちこむ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打(う)ち込(こ)むcloze-suffix",
"tags": "vt",
@@ -1726,7 +1726,7 @@
"pitch-accent-graphs": "
",
"pitch-accent-positions": "- [0]
- [3]
",
"reading": "うちこむ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打(う)ち込(こ)むcloze-suffix",
"tags": "vt",
@@ -1754,7 +1754,7 @@
"pitch-accent-graphs": "
",
"pitch-accent-positions": "- [0]
- [3]
",
"reading": "ぶちこむ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打(う)ち込(こ)むcloze-suffix",
"tags": "vt",
@@ -1782,7 +1782,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "うつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打(う)ちcloze-suffix",
"tags": "vt",
@@ -1810,7 +1810,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "ぶつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打(う)ちcloze-suffix",
"tags": "vt",
@@ -1838,7 +1838,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "うつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打(う)ちcloze-suffix",
"tags": "vt",
@@ -1866,7 +1866,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "ぶつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打(う)ちcloze-suffix",
"tags": "vt",
@@ -1894,7 +1894,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "だ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打cloze-suffix",
"tags": "n",
@@ -1922,7 +1922,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "ダース",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix打cloze-suffix",
"tags": "abbr, n",
@@ -1955,7 +1955,7 @@
"pitch-accent-graphs": "
",
"pitch-accent-positions": "- [0]
- [3]
",
"reading": "うちこむ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix(打)(ち)(込)(む)cloze-suffix",
"tags": "vt",
@@ -1983,7 +1983,7 @@
"pitch-accent-graphs": "
",
"pitch-accent-positions": "- [0]
- [3]
",
"reading": "ぶちこむ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix(打)(ち)(込)(む)cloze-suffix",
"tags": "vt",
@@ -2011,7 +2011,7 @@
"pitch-accent-graphs": "
",
"pitch-accent-positions": "- [0]
- [3]
",
"reading": "うちこむ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix(打)(ち)(込)(む)cloze-suffix",
"tags": "vt",
@@ -2039,7 +2039,7 @@
"pitch-accent-graphs": "
",
"pitch-accent-positions": "- [0]
- [3]
",
"reading": "ぶちこむ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix(打)(ち)(込)(む)cloze-suffix",
"tags": "vt",
@@ -2067,7 +2067,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "うつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix(打)(ち)cloze-suffix",
"tags": "vt",
@@ -2095,7 +2095,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "ぶつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix(打)(ち)cloze-suffix",
"tags": "vt",
@@ -2123,7 +2123,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "うつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix(打)(ち)cloze-suffix",
"tags": "vt",
@@ -2151,7 +2151,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "ぶつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix(打)(ち)cloze-suffix",
"tags": "vt",
@@ -2179,7 +2179,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "だ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix(打)cloze-suffix",
"tags": "n",
@@ -2207,7 +2207,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "ダース",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefix(打)cloze-suffix",
"tags": "abbr, n",
@@ -2240,7 +2240,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "よむ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefixtestcloze-suffix",
"tags": "vt",
@@ -2273,7 +2273,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "つよみ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefixつtestcloze-suffix",
"tags": "n",
@@ -2306,7 +2306,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "よむ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefixtestましたcloze-suffix",
"tags": "vt",
@@ -2339,7 +2339,7 @@
"pitch-accent-graphs": "- (うちこむ only)
- (うちこむ only)
- (ぶちこむ only)
- (ぶちこむ only)
",
"pitch-accent-positions": "- (うちこむ only) [0]
- (うちこむ only) [3]
- (ぶちこむ only) [0]
- (ぶちこむ only) [3]
",
"reading": "うちこむ、ぶちこむ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefixうちこむcloze-suffix",
"tags": "vt",
@@ -2367,7 +2367,7 @@
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"reading": "うつ、ぶつ",
- "screenshot": "",
+ "screenshot": "",
"search-query": "fullQuery",
"sentence": "cloze-prefixうちcloze-suffix",
"tags": "vt",
diff --git a/test/data/translator-test-results-note-data1.json b/test/data/translator-test-results-note-data1.json
index 07e7d86f..0b54b0ec 100644
--- a/test/data/translator-test-results-note-data1.json
+++ b/test/data/translator-test-results-note-data1.json
@@ -111,10 +111,6 @@
"frequency": 1
}
],
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -141,7 +137,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
}
]
},
@@ -256,10 +253,6 @@
"frequency": 2
}
],
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -286,7 +279,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
}
]
},
@@ -432,10 +426,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -472,7 +462,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -618,10 +609,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -658,7 +645,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
}
]
},
@@ -822,10 +810,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -866,7 +850,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -1025,10 +1010,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -1069,7 +1050,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -1228,10 +1210,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -1272,7 +1250,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -1431,10 +1410,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -1475,7 +1450,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -1612,10 +1588,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -1652,7 +1624,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -1798,10 +1771,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -1838,7 +1807,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
}
]
},
@@ -2054,10 +2024,6 @@
}
],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -2132,7 +2098,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -2343,10 +2310,6 @@
}
],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -2421,7 +2384,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -2632,10 +2596,6 @@
}
],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -2710,7 +2670,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -2921,10 +2882,6 @@
}
],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -2999,7 +2956,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -3160,10 +3118,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -3204,7 +3158,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -3365,10 +3320,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -3409,7 +3360,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -3570,10 +3522,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -3614,7 +3562,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -3775,10 +3724,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -3819,7 +3764,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -3956,10 +3902,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -3996,7 +3938,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -4142,10 +4085,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -4182,7 +4121,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
}
]
},
@@ -4297,10 +4237,6 @@
"frequencies": [],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -4337,7 +4273,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
}
]
},
@@ -4479,10 +4416,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 0,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -4519,7 +4452,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
}
]
},
@@ -4670,10 +4604,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 0,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -4710,7 +4640,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
}
]
},
@@ -4874,10 +4805,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 0,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -4918,7 +4845,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -5077,10 +5005,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 0,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -5121,7 +5045,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
}
]
},
@@ -5285,10 +5210,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 0,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -5329,7 +5250,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -5488,10 +5410,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 0,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -5532,7 +5450,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
}
]
},
@@ -5748,10 +5667,6 @@
}
],
"sourceTermExactMatchCount": 0,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -5826,7 +5741,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -6037,10 +5953,6 @@
}
],
"sourceTermExactMatchCount": 0,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -6115,7 +6027,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -6276,10 +6189,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 0,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -6320,7 +6229,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -6481,10 +6391,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 0,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -6525,7 +6431,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
}
]
},
@@ -6741,10 +6648,6 @@
}
],
"sourceTermExactMatchCount": 0,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -6819,7 +6722,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -7030,10 +6934,6 @@
}
],
"sourceTermExactMatchCount": 0,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -7108,7 +7008,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -7269,10 +7170,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 0,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -7313,7 +7210,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -7474,10 +7372,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 0,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -7518,7 +7412,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
}
]
},
@@ -7633,10 +7528,6 @@
"frequencies": [],
"pitches": [],
"sourceTermExactMatchCount": 0,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -7673,7 +7564,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
}
]
},
@@ -7942,10 +7834,6 @@
}
],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -8002,7 +7890,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -8254,10 +8143,6 @@
}
],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -8314,7 +8199,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -8516,10 +8402,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -8550,7 +8432,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -8752,10 +8635,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -8786,7 +8665,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -8927,10 +8807,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -8961,7 +8837,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -9111,10 +8988,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -9145,7 +9018,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
}
]
},
@@ -9581,10 +9455,6 @@
}
],
"sourceTermExactMatchCount": 2,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -9670,7 +9540,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -10000,10 +9871,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 2,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -10035,7 +9902,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -10169,10 +10037,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -10203,7 +10067,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -10346,10 +10211,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -10380,7 +10241,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
}
]
},
@@ -10600,10 +10462,6 @@
}
],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -10678,7 +10536,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -10893,10 +10752,6 @@
}
],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -10971,7 +10826,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -11186,10 +11042,6 @@
}
],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -11264,7 +11116,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -11479,10 +11332,6 @@
}
],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -11557,7 +11406,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -11718,10 +11568,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -11762,7 +11608,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -11923,10 +11770,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -11967,7 +11810,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -12128,10 +11972,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -12172,7 +12012,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -12333,10 +12174,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -12377,7 +12214,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -12514,10 +12352,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -12554,7 +12388,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -12700,10 +12535,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -12740,7 +12571,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
}
]
},
@@ -12956,10 +12788,6 @@
}
],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -13034,7 +12862,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -13245,10 +13074,6 @@
}
],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -13323,7 +13148,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -13534,10 +13360,6 @@
}
],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -13612,7 +13434,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -13823,10 +13646,6 @@
}
],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -13901,7 +13720,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -14062,10 +13882,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -14106,7 +13922,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -14267,10 +14084,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -14311,7 +14124,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -14472,10 +14286,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -14516,7 +14326,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -14677,10 +14488,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -14721,7 +14528,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -14858,10 +14666,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -14898,7 +14702,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -15044,10 +14849,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -15084,7 +14885,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
}
]
},
@@ -15300,10 +15102,6 @@
}
],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -15378,7 +15176,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -15589,10 +15388,6 @@
}
],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -15667,7 +15462,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -15878,10 +15674,6 @@
}
],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -15956,7 +15748,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -16167,10 +15960,6 @@
}
],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -16245,7 +16034,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -16406,10 +16196,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -16450,7 +16236,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -16611,10 +16398,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -16655,7 +16438,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -16816,10 +16600,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -16860,7 +16640,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -17021,10 +16802,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -17065,7 +16842,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -17202,10 +16980,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -17242,7 +17016,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -17388,10 +17163,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 1,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -17428,7 +17199,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
}
]
},
@@ -17539,10 +17311,6 @@
"frequencies": [],
"pitches": [],
"sourceTermExactMatchCount": 0,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -17583,7 +17351,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
}
]
},
@@ -17692,10 +17461,6 @@
"frequencies": [],
"pitches": [],
"sourceTermExactMatchCount": 0,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -17736,7 +17501,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
}
]
},
@@ -17847,10 +17613,6 @@
"frequencies": [],
"pitches": [],
"sourceTermExactMatchCount": 0,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -17891,7 +17653,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
}
]
},
@@ -18327,10 +18090,6 @@
}
],
"sourceTermExactMatchCount": 0,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -18416,7 +18175,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
},
{
"marker": "{marker}",
@@ -18746,10 +18506,6 @@
],
"pitches": [],
"sourceTermExactMatchCount": 0,
- "screenshotFileName": null,
- "clipboardImageFileName": null,
- "clipboardText": null,
- "audioFileName": null,
"url": "url:",
"cloze": {
"sentence": "",
@@ -18781,7 +18537,8 @@
"document": {
"title": "title"
}
- }
+ },
+ "media": {}
}
]
}
diff --git a/test/test-anki-note-builder.js b/test/test-anki-note-builder.js
index 97489aa8..607388fc 100644
--- a/test/test-anki-note-builder.js
+++ b/test/test-anki-note-builder.js
@@ -46,6 +46,7 @@ async function createVM() {
'js/dom/css-style-applier.js',
'js/display/structured-content-generator.js',
'js/templates/template-renderer.js',
+ 'js/templates/template-renderer-media-provider.js',
'lib/handlebars.min.js'
]);
@@ -228,7 +229,6 @@ async function getRenderResults(dictionaryEntries, type, mode, template, AnkiNot
modelName: 'modelName',
fields,
tags: ['yomichan'],
- injectedMedia: null,
checkForDuplicates: true,
duplicateScope: 'collection',
resultOutputMode: mode,
diff --git a/test/test-options-util.js b/test/test-options-util.js
index 986ba040..b942c66f 100644
--- a/test/test-options-util.js
+++ b/test/test-options-util.js
@@ -952,6 +952,54 @@ async function testFieldTemplatesUpdate(extDir) {
{{~else~}}
{{#each glossary}}- {{#formatGlossary ../dictionary}}{{{.}}}{{/formatGlossary}}
{{/each}}
{{~/if~}}`.trimStart()
+ },
+ // hasMedia/getMedia update
+ {
+ oldVersion: 12,
+ newVersion: 13,
+ old: `
+{{#*inline "audio"}}
+ {{~#if definition.audioFileName~}}
+ [sound:{{definition.audioFileName}}]
+ {{~/if~}}
+{{/inline}}
+
+{{#*inline "screenshot"}}
+
+{{/inline}}
+
+{{#*inline "clipboard-image"}}
+ {{~#if definition.clipboardImageFileName~}}
+
+ {{~/if~}}
+{{/inline}}
+
+{{#*inline "clipboard-text"}}
+ {{~#if definition.clipboardText~}}{{definition.clipboardText}}{{~/if~}}
+{{/inline}}`.trimStart(),
+
+ expected: `
+{{#*inline "audio"}}
+ {{~#if (hasMedia "audio")~}}
+ [sound:{{#getMedia "audio" format="fileName"}}{{/getMedia}}]
+ {{~/if~}}
+{{/inline}}
+
+{{#*inline "screenshot"}}
+ {{~#if (hasMedia "screenshot")~}}
+
+ {{~/if~}}
+{{/inline}}
+
+{{#*inline "clipboard-image"}}
+ {{~#if (hasMedia "clipboardImage")~}}
+
+ {{~/if~}}
+{{/inline}}
+
+{{#*inline "clipboard-text"}}
+ {{~#if (hasMedia "clipboardText")}}{{#getMedia "clipboardText" format="text"}}{{/getMedia}}{{/if~}}
+{{/inline}}`.trimStart()
}
];