Public API exposed by libreviews.

interface LibreviewsAPI {
    activeRTEs: ActiveRTEs;
    addHelpListeners: ($input: JQuery<HTMLElement>) => void;
    disableRequiredGroup: (groupID: string) => void;
    enableRequiredGroup: (groupID: string) => void;
    getLanguageIDSpan: (lang: string) => JQuery<HTMLSpanElement>;
    msg: (messageKey: string, options?: MessageOptions) => string;
    repaintFocusedHelp: () => void;
    resolveString: (lang: string, strObj?: MLString) => string;
    setupPasswordReveal: () => void;
    trimInput: (this: HTMLInputElement | HTMLTextAreaElement) => void;
    updateContentClickHandlers: () => void;
    urlHasSupportedProtocol: (url: string) => boolean;
    validateURL: (url: string) => boolean;
}

Properties

activeRTEs: ActiveRTEs
addHelpListeners: ($input: JQuery<HTMLElement>) => void

Type declaration

    • ($input: JQuery<HTMLElement>): void
    • Attaches focus/blur listeners and mutation observers to display contextual help for an input field.

      Parameters

      • $input: JQuery<HTMLElement>

        jQuery-wrapped input or textarea element

      Returns void

disableRequiredGroup: (groupID: string) => void

Type declaration

    • (groupID: string): void
    • Disables a group of required field indicators and removes required status.

      Parameters

      • groupID: string

        Data attribute value identifying the required group

      Returns void

enableRequiredGroup: (groupID: string) => void

Type declaration

    • (groupID: string): void
    • Enables a group of required field indicators and marks inputs as required.

      Parameters

      • groupID: string

        Data attribute value identifying the required group

      Returns void

getLanguageIDSpan: (lang: string) => JQuery<HTMLSpanElement>

Type declaration

    • (lang: string): JQuery<HTMLSpanElement>
    • Creates a styled language identifier badge for a given language code.

      Parameters

      • lang: string

        ISO language code

      Returns JQuery<HTMLSpanElement>

      jQuery element containing the language badge

msg: (messageKey: string, options?: MessageOptions) => string

Type declaration

    • (messageKey: string, options?: MessageOptions): string
    • Retrieves a localized message from the global config by key, with optional parameter substitution.

      Parameters

      • messageKey: string

        Key for the message in the global config.messages object

      • Optionaloptions: MessageOptions

        Optional parameters for interpolation and access keys

      Returns string

      The formatted message string, or ?messageKey? if not found

repaintFocusedHelp: () => void

Type declaration

    • (): void
    • Repaints the help text for the currently focused input element. Used to adjust positioning after DOM mutations.

      Returns void

resolveString: (lang: string, strObj?: MLString) => string

Type declaration

    • (lang: string, strObj?: MLString): string
    • Resolves a multi-language string to a single language, preferring the specified language but falling back to English, then any available language.

      Parameters

      • lang: string

        Preferred language code

      • OptionalstrObj: MLString

        Multi-language string object

      Returns string

      Resolved string or undefined if object is empty

setupPasswordReveal: () => void

Type declaration

    • (): void
    • Adds password reveal toggle functionality to password inputs.

      Returns void

trimInput: (this: HTMLInputElement | HTMLTextAreaElement) => void

Type declaration

    • (this: HTMLInputElement | HTMLTextAreaElement): void
    • Trims whitespace from the value of an input or textarea element. Intended as a jQuery event handler bound with this context.

      Parameters

      • this: HTMLInputElement | HTMLTextAreaElement

      Returns void

updateContentClickHandlers: () => void

Type declaration

    • (): void
    • Re-attaches click handlers for content warning toggles.

      Returns void

urlHasSupportedProtocol: (url: string) => boolean

Type declaration

    • (url: string): boolean
    • Checks if a URL begins with a supported protocol (http, https, or ftp).

      Parameters

      • url: string

        URL string to check

      Returns boolean

      True if the URL has a supported protocol

validateURL: (url: string) => boolean

Type declaration

    • (url: string): boolean
    • Validates a URL using a comprehensive regex pattern.

      Parameters

      • url: string

        URL string to validate

      Returns boolean

      True if the URL is valid