summaryrefslogtreecommitdiff
path: root/ext/js/templates
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/templates')
-rw-r--r--ext/js/templates/template-renderer-media-provider.js34
1 files changed, 19 insertions, 15 deletions
diff --git a/ext/js/templates/template-renderer-media-provider.js b/ext/js/templates/template-renderer-media-provider.js
index 4fd40c67..604b5331 100644
--- a/ext/js/templates/template-renderer-media-provider.js
+++ b/ext/js/templates/template-renderer-media-provider.js
@@ -54,21 +54,7 @@ class TemplateRendererMediaProvider {
}
_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;
+ return Object.prototype.hasOwnProperty.call(data, format) ? data[format] : null;
}
_getMediaData(media, args, namedArgs) {
@@ -79,6 +65,7 @@ class TemplateRendererMediaProvider {
case 'clipboardImage': return this._getSimpleMediaData(media, 'clipboardImage');
case 'clipboardText': return this._getSimpleMediaData(media, 'clipboardText');
case 'selectionText': return this._getSimpleMediaData(media, 'selectionText');
+ case 'textFurigana': return this._getTextFurigana(media, args[1], namedArgs);
case 'dictionaryMedia': return this._getDictionaryMedia(media, args[1], namedArgs);
default: return null;
}
@@ -114,4 +101,21 @@ class TemplateRendererMediaProvider {
});
return null;
}
+
+ _getTextFurigana(media, text, namedArgs) {
+ const {readingMode=null} = namedArgs;
+ const {textFurigana} = media;
+ if (Array.isArray(textFurigana)) {
+ for (const entry of textFurigana) {
+ if (entry.text !== text || entry.readingMode !== readingMode) { continue; }
+ return entry.details;
+ }
+ }
+ this._addRequirement({
+ type: 'textFurigana',
+ text,
+ readingMode
+ });
+ return null;
+ }
}