diff options
Diffstat (limited to 'ext/js')
-rw-r--r-- | ext/js/data/anki-note-builder.js | 16 | ||||
-rw-r--r-- | ext/js/templates/template-renderer-media-provider.js | 16 |
2 files changed, 20 insertions, 12 deletions
diff --git a/ext/js/data/anki-note-builder.js b/ext/js/data/anki-note-builder.js index 02aa7969..621816d4 100644 --- a/ext/js/data/anki-note-builder.js +++ b/ext/js/data/anki-note-builder.js @@ -362,14 +362,14 @@ class AnkiNoteBuilder { (dictionaryMedia[dictionary]) : (dictionaryMedia[dictionary] = {}) ); - dictionaryMedia2[path] = {fileName}; + dictionaryMedia2[path] = {value: fileName}; } 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), - selectionText: (typeof selectionText === 'string' ? {text: selectionText} : null), + audio: (typeof audioFileName === 'string' ? {value: audioFileName} : null), + screenshot: (typeof screenshotFileName === 'string' ? {value: screenshotFileName} : null), + clipboardImage: (typeof clipboardImageFileName === 'string' ? {value: clipboardImageFileName} : null), + clipboardText: (typeof clipboardText === 'string' ? {value: clipboardText} : null), + selectionText: (typeof selectionText === 'string' ? {value: selectionText} : null), textFurigana, dictionaryMedia }; @@ -391,8 +391,8 @@ class AnkiNoteBuilder { break; } if (data !== null) { - const html = this._createFuriganaHtml(data, readingMode); - results.push({text, readingMode, details: {html}}); + const value = this._createFuriganaHtml(data, readingMode); + results.push({text, readingMode, details: {value}}); } } return results; diff --git a/ext/js/templates/template-renderer-media-provider.js b/ext/js/templates/template-renderer-media-provider.js index 604b5331..114d3387 100644 --- a/ext/js/templates/template-renderer-media-provider.js +++ b/ext/js/templates/template-renderer-media-provider.js @@ -15,6 +15,10 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ +/* global + * Handlebars + */ + class TemplateRendererMediaProvider { constructor() { this._requirements = null; @@ -38,8 +42,7 @@ class TemplateRendererMediaProvider { const {media} = root; const data = this._getMediaData(media, args, namedArgs); if (data !== null) { - const {format} = namedArgs; - const result = this._getFormattedValue(data, format); + const result = this._getFormattedValue(data, namedArgs); if (typeof result === 'string') { return result; } } const defaultValue = namedArgs.default; @@ -53,8 +56,13 @@ class TemplateRendererMediaProvider { this._requirements.push(value); } - _getFormattedValue(data, format) { - return Object.prototype.hasOwnProperty.call(data, format) ? data[format] : null; + _getFormattedValue(data, namedArgs) { + let {value} = data; + const {escape=true} = namedArgs; + if (escape) { + value = Handlebars.Utils.escapeExpression(value); + } + return value; } _getMediaData(media, args, namedArgs) { |