Namespace shell

This namespace contains the API related to Shells, an optional API component that provides a richer editing experience than a simple View. New shells are created by calling the create function, which returns a Promise that resolves to the new shell (after loading the shell API if necessary).

Example: Append a new Shell to the page

let shell = await micd.shell.create();
shell.focus();

Index

Type aliases

PaletteButtonTemplate

PaletteButtonTemplate: null | string | [string, string] | CustomPaletteButtonTemplate

An entry describing one button in a row of palette buttons. This can be a single string to assign a primary action, or an array of two strings to assign both primary and secondary actions (activated with Shift). Each string can be a single character to assign an action that inserts that character as a variable or digit, or it can be the name of a command. Not all commands can be used, but all math object commands can. If the entry is a CustomPaletteButtonTemplate object, a custom button will be created that performs its own handling when clicked. Finally, if the entry is null, it will produce a spacer that consumes the same space as a button but does nothing if clicked.

PaletteRowTemplate

Describes a single row in a PaletteTemplate. This can be any of: null to insert a separator row; a single string to insert a row of one button; or an array of 1–6 PaletteButtonTemplates. Rows with either 2 or 4 buttons generally create the best layouts. When enabled, palettes will split each row in two at narrow window widths. In rows with an odd number of buttons, the final entry will be on a line of its own.

Variables

shared

shared: Shell | undefined | null

When the API is loaded in "editor" mode, this will be set to the shared global shell. (If the shared shell is disposed of, this becomes null.) Otherwise it is undefined.

Functions

create

  • Returns a Promise that resolves to a new Shell. The shell will be created asynchronously and appended to the specified element as a new child element.

    Parameters

    • Optional parentElement: HTMLElement

      The element to append the shell's root DOM node to; defaults to document.body.

    • Optional options: NewShellOptions

      Options that affect the shell's features.

    Returns Promise<Shell>

    A Promise that resolves to the new shell.

defaultPanels

  • defaultPanels(): string[][]
  • Returns a new array that describes the default panel configuration used by a shell. The array contains two elements, one for each side panel. Each element is an array of strings, where each string is the name of a built-in palette.

    Returns string[][]

getAddedShells

  • getAddedShells(): Shell[]
  • Returns a new array of all of the shells that are currently on the page.

    see

    View.getAddedViews

    Returns Shell[]

    A (possibly empty) array in which each element is a shell that has been added to the DOM.

getLabelForPalette

  • getLabelForPalette(paletteName: StandardPalette | keyof typeof StandardPalette): string
  • Given the name of a built-in palette, returns a human-friendly label that describes the palette contents.

    Parameters

    Returns string

supportedPalettes

  • Returns a new array in which each element describes one of the available built-in palettes, and for each palette type, which variants are supported.

    Returns PaletteInfo[]

thatContainsElement

  • thatContainsElement(element: Element): Shell | null
  • Returns the shell that contains the specified element, or null if the element is not part of a shell.

    see

    View.thatContainsElement

    Parameters

    • element: Element

      The element (or DOM node) that may be a descendent of a shell.

    Returns Shell | null

    The shell that the element is a descendent of, or null.

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