the configuration values for the editor; note that the editor can also change these values and save them!
the storage object for libraries
the storage object for content
the storage object for temporary files
a function that is called to retrieve translations of keys in a certain language; the keys use the i18next format (e.g. namespace:key). See the ITranslationFunction documentation for more details.
creates url strings for files, can be used to customize the paths in an implementation application
Optional
options: IH5PEditorOptionsmore options to customize the behavior of the editor; see IH5PEditorOptions documentation for more details
Optional
contentUserDataStorage: IContentUserDataStorageProtected
cachethe cache is used to store key - value pairs that must be accessed often; values stored in it must be accessible by ALL instances of the editor (across machines)
the configuration values for the editor; note that the editor can also change these values and save them!
the storage object for content
Optional
contentthe storage object for libraries
the storage object for temporary files
Generates cache buster strings that are used by the JavaScript client in the browser when generating URLs of core JavaScript files (only rarely used).
If you want to customize cache busting, you can override this generator. The default generator creates strings like '?version=1.24.0', which are simply added to the URL.
Deletes a piece of content and all files dependent on it.
the piece of content to delete
the user who wants to delete it
Creates a .h5p-package for the specified content file and pipes it to the stream. Throws H5pErrors if something goes wrong. The contents of the stream should be disregarded then.
IMPORTANT: This method's returned promise will resolve BEFORE piping to the writeable has been finished. If you outputStream is directly piped to a download that's not an issue, but if you do something else with this stream, you have to wait for the piping to finish by subscribing to the 'finish' event of the stream!
The contentId for which the package should be created.
The writable that the package is written to (e.g. the response stream fo Express)
Returns all the data needed to editor or display content
the content id
Optional
user: IUser(optional) the user who wants to access the content; if undefined, access will be granted
all relevant information for the content (you can send it back to the GET request for content)
Returns a readable for a file that was uploaded for a content object. The requested content file can be a temporary file uploaded for unsaved content or a file in permanent content storage.
the content id (undefined if retrieved for unsaved content)
the file to get (without 'content/' prefix!)
the user who wants to retrieve the file
Optional
rangeStart: number(optional) the position in bytes at which the stream should start
Optional
rangeEnd: number(optional) the position in bytes at which the stream should end
a readable of the content file
Downloads a .h5p file from the content hub. Then "uploads" the file as if the user uploaded the file manually.
the content hub id; this is a id of the external service and not related to local contentId
the user who is using the content hub; relevant for temporary file access rights
the content information extracted from the package.
Returns the content type cache for a specific user. This includes all available content types for the user (some might be restricted) and what the user can do with them (update, install from Hub).
Optional
language: stringReturns detailed information about an installed library.
Returns a readable stream of a library file's contents. Throws an exception if the file does not exist.
library
the relative path inside the library
a readable stream of the file's contents
Gets a rough overview of information about the requested libraries.
Optional
language: string(optional) if set, the system will try to localize the title of the library (the namespace 'library-metadata' must be loaded in the i18n system)
Installs a content type from the H5P Hub.
The name of the content type to install (e.g. H5P.Test) Note that this is not a full ubername!
a list of installed libraries if successful. Will throw errors if something goes wrong.
Retrieves the installed languages for libraries
A list of libraries for which the language files should be retrieved. In this list the names of the libraries don't use hyphens to separate machine name and version.
the language code to get the files for
The strings of the language files
Renders the content. This means that a frame in which the editor is displayed is generated and returned. You can override the default frame by calling setRenderer(...).
the language to use; defaults to English
the user who uses the editor
the rendered frame that you can include in your website. Normally a string, but can be anything you want it to be if you override the renderer.
Stores an uploaded file in temporary storage.
the id of the piece of content the file is attached to; Set to null/undefined if the content hasn't been saved before.
the semantic structure of the field the file is attached to.
information about the uploaded file; either data or tempFilePath must be used!
information about the uploaded file
Stores new content or updates existing content. Copies over files from temporary storage if necessary.
the contentId of existing content (undefined or previously unsaved content)
the content parameters (=content.json)
the content metadata (~h5p.json)
the ubername with whitespace as separator (no hyphen!)
the user who wants to save the piece of content
the existing contentId or the newly assigned one
Stores new content or updates existing content. Copies over files from temporary storage if necessary.
the contentId of existing content (undefined or previously unsaved content)
the content parameters (=content.json)
the content metadata (~h5p.json)
the ubername with whitespace as separator (no hyphen!)
the user who wants to save the piece of content
the existing contentId or the newly assigned one and the metatdata
By setting custom copyright semantics, you can customize what licenses are displayed when editing metadata of files.
NOTE: It is unclear if copyrightSemantics is deprecated in the H5P client. Use setMetadataSemantics instead, which certainly works.
NOTE: The semantic structure is localized before delivered to the H5P client. If you change it, you must either make sure there is a appropriate language file loaded in your translation library (and set one in the first place).
a semantic structure similar to the one used in semantics.json of regular H5P libraries. See https://h5p.org/semantics for more documentation. However, you can only add one entry (which can be nested). See the file assets/defaultCopyrightSemantics.json for the default version which you can build on.
the H5PEditor object that you can use to chain method calls
By setting custom metadata semantics, you can customize what licenses are displayed when editing metadata of content object and files.
NOTE: It is only trivial to change the license offered as a a selection to the editors. All other semantic entries CANNOT be changed, as the form displayed in the editor is hard-coded in h5peditor-metadata.js in the client. You'll have to replace this file with a custom implementation if you want to change more metadata.
NOTE: The semantic structure is localized before delivered to the H5P client. If you change it, you must either make sure there is a appropriate language file loaded in your translation library (and set one in the first place).
a semantic structure similar to the one used in semantics.json of regular H5P libraries. See https://h5p.org/semantics for more documentation. See the file assets/defaultMetadataSemantics.json for the default version which you can build on
the H5PEditor object that you can use to chain method calls
By setting a custom renderer you can change the way the editor produces HTML output
the H5PEditor object that you can use to chain method calls
Adds the contents of a package to the system: Installs required libraries (if the user has the permissions for this), adds files to temporary storage and returns the actual content information for the editor to process. Throws errors if something goes wrong.
the raw data of the h5p package as a buffer or the path of the file in the local filesystem
Optional
user: IUserthe user who is uploading the package; optional if onlyInstallLibraries is set to true
Optional
options: { onlyInstallLibraries?: boolean }(optional) further options:
the content information extracted from the package. The metadata and parameters property will be undefined if onlyInstallLibraries was set to true.
the cache is used to store key - value pairs that must be accessed often; values stored in it must be accessible by ALL instances of the editor (across machines)