To perform editing commands on a mathfield, use [[MathfieldElement.executeCommand]] with the commands below.

const mf = document.getElementById('mathfield');
mf.executeCommand('selectAll');
mf.executeCommand('copyToClipboard');

Commands return true if they resulted in a dirty state.

executeCommand

interface Commands {
    addColumnAfter: ((model: Model) => boolean);
    addColumnBefore: ((model: Model) => boolean);
    addRowAfter: ((model: Model) => boolean);
    addRowBefore: ((model: Model) => boolean);
    applyStyle: ((mathfield: Mathfield, style: Style) => boolean);
    commit: ((mathfield: Mathfield) => boolean);
    complete: ((mathfield: Mathfield) => boolean);
    copyToClipboard: ((mathfield: Mathfield) => boolean);
    cutToClipboard: ((mathfield: Mathfield) => boolean);
    deleteAll: ((model: Model) => boolean);
    deleteBackward: ((model: Model) => boolean);
    deleteForward: ((model: Model) => boolean);
    deleteNextWord: ((model: Model) => boolean);
    deletePreviousWord: ((model: Model) => boolean);
    deleteToGroupEnd: ((model: Model) => boolean);
    deleteToGroupStart: ((model: Model) => boolean);
    deleteToMathFieldEnd: ((model: Model) => boolean);
    deleteToMathFieldStart: ((model: Model) => boolean);
    extendSelectionBackward: ((model: Model) => boolean);
    extendSelectionDownward: ((model: Model) => boolean);
    extendSelectionForward: ((model: Model) => boolean);
    extendSelectionUpward: ((model: Model) => boolean);
    extendToGroupEnd: ((model: Model) => boolean);
    extendToGroupStart: ((model: Model) => boolean);
    extendToMathFieldEnd: ((model: Model) => boolean);
    extendToMathFieldStart: ((model: Model) => boolean);
    extendToNextBoundary: ((model: Model) => boolean);
    extendToNextWord: ((model: Model) => boolean);
    extendToPreviousBoundary: ((model: Model) => boolean);
    extendToPreviousWord: ((model: Model) => boolean);
    insert: ((mathfield: Mathfield, s: string, options: InsertOptions) => boolean);
    insertDecimalSeparator: ((mathfield: Mathfield) => boolean);
    insertPrompt: ((mathfield: Mathfield, id?: string, options?: InsertOptions) => boolean);
    moveAfterParent: ((model: Model) => boolean);
    moveBeforeParent: ((model: Model) => boolean);
    moveDown: ((model: Model) => boolean);
    moveToGroupEnd: ((model: Model) => boolean);
    moveToGroupStart: ((model: Model) => boolean);
    moveToMathfieldEnd: ((model: Model) => boolean);
    moveToMathfieldStart: ((model: Model) => boolean);
    moveToNextChar: ((model: Model) => boolean);
    moveToNextGroup: ((model: Model) => boolean);
    moveToNextPlaceholder: ((model: Model) => boolean);
    moveToNextWord: ((model: Model) => boolean);
    moveToOpposite: ((model: Model) => boolean);
    moveToPreviousChar: ((model: Model) => boolean);
    moveToPreviousGroup: ((model: Model) => boolean);
    moveToPreviousPlaceholder: ((model: Model) => boolean);
    moveToPreviousWord: ((model: Model) => boolean);
    moveToSubscript: ((model: Model) => boolean);
    moveToSuperscript: ((model: Model) => boolean);
    moveUp: ((model: Model) => boolean);
    nextSuggestion: ((mathfield: Mathfield) => boolean);
    pasteFromClipboard: ((mathfield: Mathfield) => boolean);
    performWithFeedback: ((mathfield: Mathfield, command: string) => boolean);
    plonk: ((mathfield: Mathfield) => boolean);
    previousSuggestion: ((mathfield: Mathfield) => boolean);
    redo: ((mathfield: Mathfield) => boolean);
    removeColumn: ((model: Model) => boolean);
    removeRow: ((model: Model) => boolean);
    scrollIntoView: ((mathfield: Mathfield) => boolean);
    scrollToEnd: ((mathfield: Mathfield) => boolean);
    scrollToStart: ((mathfield: Mathfield) => boolean);
    selectAll: ((model: Model) => boolean);
    selectGroup: ((model: Model) => boolean);
    setEnvironment: ((model: Model, environment: TabularEnvironment) => boolean);
    speak: ((mathfield: Mathfield, scope: SpeechScope, options: {
        withHighlighting: boolean;
    }) => boolean);
    switchMode: ((mathfield: Mathfield, mode: ParseMode) => boolean);
    toggleContextMenu: ((mathfield: Mathfield) => boolean);
    toggleKeystrokeCaption: ((mathfield: Mathfield) => boolean);
    typedText: ((text: string, options: {
        feedback: boolean;
        focus: boolean;
        simulateKeystroke: boolean;
    }) => boolean);
    undo: ((mathfield: Mathfield) => boolean);
}

Array

addColumnAfter: ((model: Model) => boolean)
addColumnBefore: ((model: Model) => boolean)
addRowAfter: ((model: Model) => boolean)
addRowBefore: ((model: Model) => boolean)
removeColumn: ((model: Model) => boolean)
removeRow: ((model: Model) => boolean)
setEnvironment: ((model: Model, environment: TabularEnvironment) => boolean)

Auto-complete

complete: ((mathfield: Mathfield) => boolean)
nextSuggestion: ((mathfield: Mathfield) => boolean)
previousSuggestion: ((mathfield: Mathfield) => boolean)

Clipboard

copyToClipboard: ((mathfield: Mathfield) => boolean)
cutToClipboard: ((mathfield: Mathfield) => boolean)
pasteFromClipboard: ((mathfield: Mathfield) => boolean)

Deleting

deleteAll: ((model: Model) => boolean)
deleteBackward: ((model: Model) => boolean)
deleteForward: ((model: Model) => boolean)
deleteNextWord: ((model: Model) => boolean)
deletePreviousWord: ((model: Model) => boolean)
deleteToGroupEnd: ((model: Model) => boolean)
deleteToGroupStart: ((model: Model) => boolean)
deleteToMathFieldEnd: ((model: Model) => boolean)
deleteToMathFieldStart: ((model: Model) => boolean)

Other

applyStyle: ((mathfield: Mathfield, style: Style) => boolean)
commit: ((mathfield: Mathfield) => boolean)
insert: ((mathfield: Mathfield, s: string, options: InsertOptions) => boolean)
insertDecimalSeparator: ((mathfield: Mathfield) => boolean)
performWithFeedback: ((mathfield: Mathfield, command: string) => boolean)

Perform a command and include interactive feedback such as sound and haptic feedback. This is useful to simulate user interaction, for example for commands from the virtual keyboard

plonk: ((mathfield: Mathfield) => boolean)
speak: ((mathfield: Mathfield, scope: SpeechScope, options: {
    withHighlighting: boolean;
}) => boolean)

Type declaration

    • (mathfield, scope, options): boolean
    • Parameters

      • mathfield: Mathfield
      • scope: SpeechScope

        How much of the formula should be spoken:

        all the entire formula
        selection the selection portion of the formula
        left the element to the left of the selection
        right the element to the right of the selection
        group the group (numerator, root, etc..) the selection is in
        parent the parent of the selection
      • options: {
            withHighlighting: boolean;
        }
        • withHighlighting: boolean

          In addition to speaking the requested portion of the formula, visually highlight it as it is read (read aloud functionality)

      Returns boolean

switchMode: ((mathfield: Mathfield, mode: ParseMode) => boolean)
toggleContextMenu: ((mathfield: Mathfield) => boolean)
toggleKeystrokeCaption: ((mathfield: Mathfield) => boolean)
typedText: ((text: string, options: {
    feedback: boolean;
    focus: boolean;
    simulateKeystroke: boolean;
}) => boolean)

Prompt

insertPrompt: ((mathfield: Mathfield, id?: string, options?: InsertOptions) => boolean)

Scrolling

scrollIntoView: ((mathfield: Mathfield) => boolean)
scrollToEnd: ((mathfield: Mathfield) => boolean)
scrollToStart: ((mathfield: Mathfield) => boolean)

Selection

extendSelectionBackward: ((model: Model) => boolean)
extendSelectionDownward: ((model: Model) => boolean)
extendSelectionForward: ((model: Model) => boolean)
extendSelectionUpward: ((model: Model) => boolean)
extendToGroupEnd: ((model: Model) => boolean)
extendToGroupStart: ((model: Model) => boolean)
extendToMathFieldEnd: ((model: Model) => boolean)
extendToMathFieldStart: ((model: Model) => boolean)
extendToNextBoundary: ((model: Model) => boolean)
extendToNextWord: ((model: Model) => boolean)
extendToPreviousBoundary: ((model: Model) => boolean)
extendToPreviousWord: ((model: Model) => boolean)
moveAfterParent: ((model: Model) => boolean)
moveBeforeParent: ((model: Model) => boolean)
moveDown: ((model: Model) => boolean)
moveToGroupEnd: ((model: Model) => boolean)
moveToGroupStart: ((model: Model) => boolean)
moveToMathfieldEnd: ((model: Model) => boolean)
moveToMathfieldStart: ((model: Model) => boolean)
moveToNextChar: ((model: Model) => boolean)
moveToNextGroup: ((model: Model) => boolean)
moveToNextPlaceholder: ((model: Model) => boolean)
moveToNextWord: ((model: Model) => boolean)
moveToOpposite: ((model: Model) => boolean)
moveToPreviousChar: ((model: Model) => boolean)
moveToPreviousGroup: ((model: Model) => boolean)
moveToPreviousPlaceholder: ((model: Model) => boolean)
moveToPreviousWord: ((model: Model) => boolean)
moveToSubscript: ((model: Model) => boolean)
moveToSuperscript: ((model: Model) => boolean)
moveUp: ((model: Model) => boolean)
selectAll: ((model: Model) => boolean)
selectGroup: ((model: Model) => boolean)

Undo/Redo

redo: ((mathfield: Mathfield) => boolean)
undo: ((mathfield: Mathfield) => boolean)