Namespace ui

Auxiliary user interface elements, including dialogs and menus. This is a lightweight toolkit intended primarily for the API's own internal needs. It provides a number of conveniences, including pre-built option dialogs and easy extension of the default context menu. However, using it is entirely optional.

Index

Type aliases

ButtonTemplate

All possible templates for buttons that can appear in a dialog.

WidgetTemplate

All possible dialog widget types.

Functions

changeTheme

  • Changes the interface theme. The supplied theme options do not need to be complete; any missing properties will use their standard default values. For example, the following call would switch to the "dark" version of the built-in theme: micd.ui.changeTheme({ sBaseTheme: "dark" }).

    Parameters

    • Optional theme: ThemeOptions | null

      The options for the new theme. Missing options will be filled in with defaults automatically.

    Returns void

createHelpTable

  • Returns a Promise that resolves to an HTMLTableElement for a help table describing available commands and their keyboard shortcuts. An optional template can be used to customize the table contents, such as adding help for custom commands.

    Parameters

    • Optional template: HelpTableTemplate | null

      An optional template that allows customization and extension of the generated table.

    Returns Promise<HTMLTableElement>

    A Promise that resolves to the table, or null if a callback was supplied.

createImageOptionsDialog

createLatexOptionsDialog

createMmlOptionsDialog

getPageRect

  • getPageRect(element: Element): object
  • Returns the bounding rectangle of an element relative to the top left corner of the document. That is, the coordinate system is the same as that used by the pageX and pageY properties of input events.

    Parameters

    • element: Element

      The element to get the bounds of.

    Returns object

    The page-relative bounding rectangle.

    • height: number
    • width: number
    • x: number
    • x2: number
    • y: number
    • y2: number

provideErrorFeedback

  • provideErrorFeedback(): void
  • Provides feedback to the user that a minor error occurred, such as playing a soft "error beep" sound. The exact form(s) of the feedback is determined by the sErrorFeedback theme setting. The effect will be the same as that produced when the user attempts a low-level inapplicable action, such as moving the caret past the end of the document.

    Returns void

showDialog

  • Displays a basic dialog box based on the contents of a template.

    Note that the dialog box API is meant primarily to meet the needs of the editor itself. It may not be suited to all of your use cases and is not intended to be a complete replacement for a general user interface framework.

    Parameters

    • template: DialogTemplate

      The template that defines the structure and logic for the desired dialog.

    Returns Promise<DialogTemplate>

    A Promise that resolves to the template once the dialog is closed.

showMenu

  • Displays a basic popup menu based on a template. Only one popup menu can be visible at a time. If a menu is already showing when this is called, it will be cancelled automatically.

    throws

    ReferenceError If the template is null.

    Parameters

    • template: MenuTemplate

      The template that defines the structure and logic for the desired dialog.

    Returns void

showToast

  • showToast(message: string): void
  • Briefly displays a feedback message at the bottom of the window. The display time is calculated automatically based on the message length. Clicking a toast dismisses it prematurely. At most one toast is shown at a time; if this is called when a toast is already showing, the new toast will be added to a queue to be shown later.

    Parameters

    • message: string

      The text of a message to display.

    Returns void

toHtml

  • toHtml(math: string): Promise<HTMLElement>
  • Returns a Promise that resolves to the root of a tree of HTMLElements that provide a graphic representation of some math content. The content is described by a string using one of three formats: the string value of a Clip, the name of a command that inserts math, or a string of MathML. Note that this is intended mainly to support the construction of user interface elements and might not be suited to more general math display applications.

    throws

    ReferenceError If the supplied math content is null.

    Parameters

    • math: string

      A string containing a clip, a command name, or MathML.

    Returns Promise<HTMLElement>

    A Promise that resolves to the root of a tree of HTMLElements that will display the math, or null if a callback was supplied.

This API is still under development and is subject to change. Copyright © Math I Can Do Solutions Incorporated and/or its licensors.