diff --git a/src/js/h5p-standalone.class.js b/src/js/h5p-standalone.class.js index 425196ad..bcb5bfdb 100644 --- a/src/js/h5p-standalone.class.js +++ b/src/js/h5p-standalone.class.js @@ -64,7 +64,7 @@ export default class H5PStandalone { contentOptions.exportUrl = urlPath(options.downloadUrl); } - if (options.metadata) { + if (options.metadata) { // exposing content['id'].metadata key to allow overrides contentOptions.metadata = options.metadata; } @@ -173,6 +173,7 @@ export default class H5PStandalone { scripts: scripts, displayOptions: contentOptions.displayOptions, contentUrl: this.contentUrl, + metadata: {} }; for (const key in contentOptions) { @@ -181,6 +182,13 @@ export default class H5PStandalone { } } + // add missing content metadata from h5p.json + for (const key in this.h5p) { + if (H5PIntegration.contents[`cid-${this.id}`]?.['metadata']?.[key] === undefined) { + H5PIntegration.contents[`cid-${this.id}`]['metadata'][key] = this.h5p[key] + } + } + if (!generalIntegrationOptions.preventH5PInit) { H5P.init(); } @@ -325,13 +333,6 @@ export default class H5PStandalone { Array.prototype.push.apply(scripts, JSDependencies[dependencyName]); }); - if (this.mainLibrary.preloadedCss) { - Array.prototype.push.apply(styles, this.mainLibrary.preloadedCss.map(style => `${this.librariesPath}/${this.mainLibraryPath}/${style.path}`)); - } - if (this.mainLibrary.preloadedJs) { - Array.prototype.push.apply(scripts, this.mainLibrary.preloadedJs.map(script => `${this.librariesPath}/${this.mainLibraryPath}/${script.path}`)); - } - // Append custom styles and scripts at the end to override original values styles = styles.concat(customOptions.customCss); scripts = scripts.concat(customOptions.customJs);