Interface MathfieldInternal

interface Mathfield {
    applyStyle(style: Style, options?: ApplyStyleOptions): void;
    blur?(): void;
    executeCommand(command: Selector | [Selector, ...any[]]): boolean;
    focus?(): void;
    getCaretPoint?(): null | {
        x: number;
        y: number;
    };
    getPrompts(filter?: {
        correctness?: "undefined" | "correct" | "incorrect";
        id?: string;
        locked?: boolean;
    }): string[];
    getPromptValue(placeholderId: string, format?: OutputFormat): string;
    getValue(format?: OutputFormat): string;
    getValue(start: number, end: number, format?: OutputFormat): string;
    getValue(range: Selection | Range, format?: OutputFormat): string;
    getValue(arg1?:
        | number
        | Selection
        | Range
        | OutputFormat, arg2?: number | OutputFormat, arg3?: OutputFormat): string;
    hasFocus(): boolean;
    insert(s: string, options?: InsertOptions): boolean;
    select(): void;
    setCaretPoint(x: number, y: number): boolean;
    setValue(latex?: string, options?: InsertOptions): void;
}

Implemented by

Methods

  • Update the style (color, bold, italic, etc...) of the selection or sets the style to be applied to future input.

    If there is no selection and no range is specified, the style will apply to the next character typed.

    If a range is specified, the style is applied to the range, otherwise, if there is a selection, the style is applied to the selection.

    If the operation is "toggle" and the range already has this style, remove it. If the range has the style partially applied (i.e. only some sections), remove it from those sections, and apply it to the entire range.

    If the operation is "set", the style is applied to the range, whether it already has the style or not.

    The default operation is "set".

    Parameters

    Returns void

  • Returns void

  • Execute a [[Commands|command]] defined by a selector.

    mfe.executeCommand('add-column-after');
    mfe.executeCommand(['switch-mode', 'math']);

    Parameters

    • command: Selector | [Selector, ...any[]]

      A selector, or an array whose first element is a selector, and whose subsequent elements are arguments to the selector.

      Selectors can be passed either in camelCase or kebab-case.

      // Both calls do the same thing
      mfe.executeCommand('selectAll');
      mfe.executeCommand('select-all');

    Returns boolean

  • Returns void

  • The bottom location of the caret (insertion point) in viewport coordinates.

    See also [[setCaretPoint]]

    Returns null | {
        x: number;
        y: number;
    }

  • Parameters

    • Optionalfilter: {
          correctness?: "undefined" | "correct" | "incorrect";
          id?: string;
          locked?: boolean;
      }
      • Optionalcorrectness?: "undefined" | "correct" | "incorrect"
      • Optionalid?: string
      • Optionallocked?: boolean

    Returns string[]

  • Return the content of the \placeholder{} command with the placeholderId

    Parameters

    Returns string

  • Return a textual representation of the content of the mathfield.

    Parameters

    • Optionalformat: OutputFormat

      The format of the result. If using math-json the Compute Engine library must be loaded, for example with:

      import "https://unpkg.com/@cortex-js/compute-engine?module";
      

      Default: "latex"

    Returns string

  • Return the value of the mathfield from start to end

    Parameters

    Returns string

  • Return the value of the mathfield in range

    Parameters

    Returns string

  • Internal

    Parameters

    Returns string

  • Return true if the mathfield is currently focused (responds to keyboard input).

    Returns boolean

  • Insert a block of text at the current insertion point.

    This method can be called explicitly or invoked as a selector with executeCommand("insert").

    After the insertion, the selection will be set according to the options.selectionMode.

    Parameters

    Returns boolean

  • Returns void

  • Parameters

    • x: number
    • y: number

    Returns boolean

  • Set the content of the mathfield to the text interpreted as a LaTeX expression.

    Parameters

    Returns void