H5P NodeJS Library
    Preparing search index...

    The options that can be passed to the constructor of H5PEditor

    interface IH5PEditorOptions {
        customization?: {
            alterLibraryFiles?: (
                library: ILibraryName,
                scripts: string[],
                styles: string[],
            ) => { scripts: string[]; styles: string[] };
            alterLibraryLanguageFile?: (
                library: ILibraryName,
                languageFile: ILanguageFileEntry[],
                language: string,
            ) => ILanguageFileEntry[];
            alterLibrarySemantics?: (
                library: ILibraryName,
                semantics: ISemanticsEntry[],
            ) => ISemanticsEntry[];
            global?: { scripts?: string[]; styles?: string[] };
        };
        enableHubLocalization?: boolean;
        enableLibraryNameLocalization?: boolean;
        fileSanitizers?: IFileSanitizer[];
        getLocalIdOverride?: () => string;
        hooks?: {
            contentWasCreated?: (
                contentId: string,
                metadata: IContentMetadata,
                parameters: any,
                user: IUser,
            ) => Promise<void>;
            contentWasDeleted?: (contentId: string, user: IUser) => Promise<void>;
            contentWasUpdated?: (
                contentId: string,
                metadata: IContentMetadata,
                parameters: any,
                user: IUser,
            ) => Promise<void>;
        };
        lockProvider?: ILockProvider;
        malwareScanners?: IFileMalwareScanner[];
        permissionSystem?: IPermissionSystem;
    }
    Index

    Properties

    customization?: {
        alterLibraryFiles?: (
            library: ILibraryName,
            scripts: string[],
            styles: string[],
        ) => { scripts: string[]; styles: string[] };
        alterLibraryLanguageFile?: (
            library: ILibraryName,
            languageFile: ILanguageFileEntry[],
            language: string,
        ) => ILanguageFileEntry[];
        alterLibrarySemantics?: (
            library: ILibraryName,
            semantics: ISemanticsEntry[],
        ) => ISemanticsEntry[];
        global?: { scripts?: string[]; styles?: string[] };
    }

    Enables customization of looks and behavior See the documentation page on customization for more details.

    Type declaration

    • OptionalalterLibraryFiles?: (
          library: ILibraryName,
          scripts: string[],
          styles: string[],
      ) => { scripts: string[]; styles: string[] }

      This hook is called when the editor creates the list of files that are loaded when displaying the editor for a library. Note: This function should be immutable, so it shouldn't change the scripts and styles parameters but create new arrays!

    • OptionalalterLibraryLanguageFile?: (
          library: ILibraryName,
          languageFile: ILanguageFileEntry[],
          language: string,
      ) => ILanguageFileEntry[]

      This hook is called when the editor retrieves the language file of a library in a specific language. You can change the language file in the hook, e.g. by adding or removing entries. Note: This function should be immutable, so it shouldn't change the languageFile parameter but return a clone! Note: If you change the semantic structure of a library, you must also change the language files by using the this hook!

    • OptionalalterLibrarySemantics?: (library: ILibraryName, semantics: ISemanticsEntry[]) => ISemanticsEntry[]

      This hook is called when the editor retrieves the semantics of a library. You can change the semantics in the hook, e.g. by adding or removing entries. Note: This function should be immutable, so it shouldn't change the semantics parameter but return a clone! Note: If you change the semantic structure of a library, you must also change its language files by using the alterLibraryLanguageFile hook!

    • Optionalglobal?: { scripts?: string[]; styles?: string[] }

      Lists of JavaScript and CSS files that should always be appended to the list of core editor files.

    enableHubLocalization?: boolean

    If true, the system will localize the information about content types displayed in the H5P Hub. It will use the translationCallback that is passed to H5PEditor for this by getting translations from the namespace 'hub'. It will try to localize these language strings: hub:H5P_Example.description hub:H5P_Example.summary hub:H5P_Example.keywords.key_word1 hub:H5P_Example.keywords.key_word2 hub:H5P_Example.keywords. ... Note that "H5P_Example" is a transformed version of the machineName of the content type main library, in which . is replaced by _. In the key words whitespaces are replaced by _.

    enableLibraryNameLocalization?: boolean

    If true, the system will localize library titles. It will use the translationCallback that is passed to H5PEditor for this by getting translations from the namespace 'library-metadata'. It will try to localize these language strings: hub:H5P_Example.title Note that "H5P_Example" is a transformed version of the machineName of the content type main library, in which . is replaced by _. In the key words whitespaces are replaced by _.

    fileSanitizers?: IFileSanitizer[]

    A list of file sanitizers that are executed for content files in order of the array when a file or package is uploaded.

    getLocalIdOverride?: () => string

    Allows you to inject custom machine ids. This id is sent to the H5P.org Hub server when registering to get a UUID for the local instance or when refreshing the list of available content types.

    By default the server gets an ID for the local machine by calling node-machine-id, so you don't have to use the override. There are cases in which calling node-machine-id might not work, so you can use the override.

    hooks?: {
        contentWasCreated?: (
            contentId: string,
            metadata: IContentMetadata,
            parameters: any,
            user: IUser,
        ) => Promise<void>;
        contentWasDeleted?: (contentId: string, user: IUser) => Promise<void>;
        contentWasUpdated?: (
            contentId: string,
            metadata: IContentMetadata,
            parameters: any,
            user: IUser,
        ) => Promise<void>;
    }

    Hooks allow you to react to things happening in the library.

    lockProvider?: ILockProvider

    A lock provider to use. By default, the library uses a single-process lock. You must pass in a distributed lock implementation if the library is used in a multi-process or cluster environment.

    malwareScanners?: IFileMalwareScanner[]

    A list of file malware scanners that are executed for content files in order of the array when a file or package is uploaded.

    permissionSystem?: IPermissionSystem