* This hook is called when the editor retrieves the semantics of a
* Note: This function should be immutable, so it shouldn't change the
* semantics parameter but return a clone!
* @param library the library that is currently being loaded
* @param semantics the original semantic structure
* @returns the changed semantic structure
const alterLibrarySemanticsHook = (
semantics: ISemanticsEntry[]
): ISemanticsEntry[] => {
// We only change the semantic structure of one library
if (library.machineName === 'H5P.TrueFalse') {
// We create a new array, as the function is supposed to be immutable.
tags: ['strong', 'em', 'sub', 'sup', 'h2', 'h3', 'pre', 'code']
// We return an unchanged structure for all other libraries
* This hook is called when the editor retrieves the language file of a
* library in a specific language.
* Note: This function should be immutable, so it shouldn't change the
* languageFile parameter but return a clone!
* @param library the library that is currently being loaded
* @param languageFile the original language file
* @param language the language for which the entries should be changed
* @returns the changed language file
const alterLibraryLanguageFileHook = (
languageFile: ILanguageFileEntry[],
): ILanguageFileEntry[] => {
// We only change the language file of one library
if (library.machineName === 'H5P.TrueFalse') {
// We create a new array, as the function is supposed to be immutable.
// The language file has the same structure as the semantics file
// but only includes localizable fields.
// We return an unchanged language file for all other libraries