async/await
and optional chaining. These features are supported by all cutting-edge modern browsers as of December 2020. Use a transpiler if you have to support older browsers.loadContentCallback
(and saveContentCallback for the editor) attribute from your JavaScript code.loadContentCallback
that you must set as a property of the DOM element (see above for examples). The components won't work without the callback.loadContentCallback
is setcontent-id
is setcontent-id
and it will discard the old content and display the new one. You can also safely remove the component from the DOM.content-id
to the string new
. Caution: If the newly created content is saved later, then its contentId
will be undefined
in saveContententCallback
, not new
!save()
method:saveContentCallback
(see below) with all the data needed to save the content.loadContentCallback
to a function that retrieves the necessary data from the backend. It returns a promise of data that follows the structure of IPlayerModel in types.ts in @lumieducation/h5p-server. If there is an error, the callback should throw an error object with the error message in the message
property.H5PPlayer.render(...)
:contentId
can be undefined
if the editor is used to create new contentcontentId
is defined.H5PEditor.saveOrUpdateContentReturnMetaData(...)
and then return the result to the client, which returns the result as the return value of saveContentCallback
.contentId
can be undefined
, if the user is creating new content.dispatchEvent
method of the component. You can listen to them by adding an event listener with addEventListener
.contentId
in event.detail.contentId
. Note: The event is emitted by H5P at a point when all the scripts but possibly not all resources (images etc.) might be loaded. You should only use the event as an indication of initialization state.statement
in event.detail.statement
,context
in event.detail.context
, and event
in event.detail.event
.contentId
in event.detail.contentId
and an ubername of the main content type in event.detail.ubername
.contentId
can be found in event.detail.contentId
and the content metadata in event.detail.metadata
.save()
method instead of subscribing to this event.event.detail.message
.save()
method in a try {...} catch {...}
block instead of subscribing to this event.initialized
event was fired. Important: This object is only partially typed and there are more properties and methods on it!initialized
event was fired. Important: This object is only partially typed and there are more properties and methods on it!