Fork me on GitHub

MathField

MathField

new MathField(element: Element, config: Object)

Note

  • Method names that begin with $ are public.
  • Method names that begin with an underbar _ are private and meant to be used only by the implementation of the class.
  • Method names that end with an underbar _ are selectors. They can be invoked by calling the perform() function of a MathField object. Note that the selector name does not include the underbar.

For example:

   mf.perform('selectAll');
element Element
config Object

See MathLive.makeMathField() for details

Properties
element Element

The DOM element this mathfield is attached to.

config Object

A key/value/pair object that includes options customizing the behavior of the mathfield

id string

A unique ID identifying this mathfield

keystrokeCaptionVisible boolean

True if the keystroke caption panel is visible

virtualKeyboardVisible boolean
inlineShortcutBuffer string

The last few keystrokes, to look out for inline shortcuts

inlineShortcutStates Array.<object>

The saved state for each of the past keystrokes

Source

Methods

$el() → Element

Return the DOM element associated with this mathfield.

Element   
Source

$insert(s: string)

This function can be invoked as a selector with perform() or called explicitly. It will insert the specified block of text at the current selection point, according to the insertion mode specified. After the insertion, the selection will be set according to the selectionMode.

s string

The text to be inserted

options.selectionMode string

Describes where the selection will be after the insertion:

  • 'placeholder': the selection will be the first available placeholder in the item that has been inserted) (default)
  • 'after': the selection will be an insertion point after the item that has been inserted),
  • 'before': the selection will be an insertion point before the item that has been inserted) or 'item' (the item that was inserted will be selected).

options.format string

The format of the string s:

  • 'auto': the string is interpreted as a latex fragment or command) (default)
  • 'latex': the string is interpreted strictly as a latex fragment

options.focus boolean

If true, the mathfield will be focused

options.feedback boolean

If true, provide audio and haptic feedback

Source

$keystroke(keys: string, evt: Event) → boolean

keys string

A string representation of a key combination. For example 'Alt-KeyU'. See https://www.w3.org/TR/2012/WD-DOM-Level-3-Events-20120614/#fixed-virtual-key-codes

evt Event
boolean   
Source

$latex(text: string, options: Object) → string

If text is not empty, sets the content of the mathfield to the text interpreted as a LaTeX expression. If text is empty (or omitted), return the content of the mahtfield as a LaTeX expression.

text string
options Object
options.suppressContentChangeNotifications boolean

If true, the handlers for the contentWillChange and contentDidChange notifications will not be invoked. Default false.

string   
Source

$perform(command: string,Array.<string>)

command string | Array.<string>

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

Source

$revertToOriginalContent()

Revert this math field to its original content. After this method has been called, no other methods can be called on the MathField object. To turn the element back into a MathField, call MathLive.makeMathField() on the element again to get a new math field object.

Source

$selectedText(formatopt: string) → string

Return a textual representation of the selection in the mathfield.

format string optional = 'latex'

One of

  • 'latex'
  • 'latex-expanded' : all macros are recursively expanded to their definition
  • 'spoken'
  • 'mathML'

string   
Source

$selectionAtStart() → boolean

Return true if the selection starts at the beginning of the selection group.

boolean   
Source

$selectionDepth() → number

Return the depth of the selection group. If the selection is at the root level, returns 0. If the selection is a portion of the numerator of a fraction which is at the root level, return 1. Note that in that case, the numerator would be the "selection group".

number   
Source

$selectionIsCollapsed() → boolean

Return true if the length of the selection is 0, that is, if it is a single insertion point.

boolean   
Source

$setConfig(config: Object)

config Object

See MathLive.makeMathField() for details

Source

$text(formatopt: string) → string

Return a textual representation of the mathfield.

format string optional = 'latex'

One of

  • 'latex'
  • 'latex-expanded' : all macros are recursively expanded to their definition
  • 'spoken'
  • 'mathML'

string   
Source

$typedText(text: string)

Simulate a user typing the keys indicated by text.

text string

A sequence of one or more characters.

Source

_getCaretPosition()private

Return the (x,y) client coordinates of the caret

Source

_onKeystroke(keystroke: string, evt: Event)private

keystroke string
evt Event

optional, an Event corresponding to the keystroke

Source

complete_()private

Completes an operation in progress, for example when in command mode, interpret the command

Source

enterCommandMode_()private

Source

render()private

Lay-out the math field and generate the DOM.

This is usually done automatically, but if the font-size, or other geometric attributes are modified, outside of MathLive, this function may need to be called explicitly.

Source

selectionAtEnd() → boolean

Return true if the selection extends to the end of the selection group.

boolean   
Source

speakAll_()

Source

speakAllWithSynchronizedHighlighting_()

Source

speakGroup_()

Source

speakLeftSibling_()

Source

speakParent_()

Source

speakRightSibling_()

Source

speakSelection_()

Source

speakSelectionWithSynchronizedHighlighting_()

Source