new MathField(element: Element, config: Object)
Note
- 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 theperform()function of aMathFieldobject. 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
Methods
_onKeystroke(keystroke: string, evt: Event)private
keystroke
string
evt
Event
optional, an Event corresponding to the keystroke
complete_()private
Completes an operation in progress, for example when in command mode, interpret the command
enterCommandMode_()private
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
keystroke(keys: string, evt: Event)
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
latex(text: string) → 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
perform(command: string,Array.<string>)
command
string
|
Array.<string>
A selector and its parameters
render()private
Call render() to re-layout the field and generate the updated 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.
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.
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'
selectionAtEnd() → boolean
Return true if the selection extends to the end of the selection group.
selectionAtStart() → boolean
Return true if the selection starts at the beginning of the selection group.
selectionDepth() → integer
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".
selectionIsCollapsed() → boolean
Return true if the length of the selection is 0, that is, if it is a single insertion point.
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'or'mathML'.
typedText(text: string)
Simulate a user typing the keys indicated by text.
text
string
A sequence of one or more characters.
