aboutsummaryrefslogtreecommitdiff
path: root/ext/js/templates/sandbox/anki-template-renderer.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/templates/sandbox/anki-template-renderer.js')
-rw-r--r--ext/js/templates/sandbox/anki-template-renderer.js15
1 files changed, 5 insertions, 10 deletions
diff --git a/ext/js/templates/sandbox/anki-template-renderer.js b/ext/js/templates/sandbox/anki-template-renderer.js
index 67ea0d81..c75f92d3 100644
--- a/ext/js/templates/sandbox/anki-template-renderer.js
+++ b/ext/js/templates/sandbox/anki-template-renderer.js
@@ -17,6 +17,7 @@
/* global
* AnkiNoteDataCreator
+ * AnkiTemplateRendererContentManager
* CssStyleApplier
* DictionaryDataUtil
* Handlebars
@@ -534,16 +535,10 @@ class AnkiTemplateRenderer {
}
_createStructuredContentGenerator(data) {
- const mediaLoader = {
- loadMedia: async (path, dictionary, onLoad, onUnload) => {
- const imageUrl = this._mediaProvider.getMedia(data, ['dictionaryMedia', path], {dictionary, format: 'fileName', default: null});
- if (imageUrl !== null) {
- onLoad(imageUrl);
- this._cleanupCallbacks.push(() => onUnload(true));
- }
- }
- };
- return new StructuredContentGenerator(mediaLoader, document);
+ const contentManager = new AnkiTemplateRendererContentManager(this._mediaProvider, data);
+ const instance = new StructuredContentGenerator(contentManager, document);
+ this._cleanupCallbacks.push(() => contentManager.unloadAll());
+ return instance;
}
_formatGlossary(context, dictionary, options) {