Fork me on GitHub

EditableMathlist

EditableMathlist

new EditableMathlist(config: Object, announce: function)

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 the perform() function of a MathField object. They will be dispatched to an instance of MathEditableList as necessary. Note that the selector name does not include the underbar.

For example:

   mf.perform('selectAll');
config Object
announce function

A callback invoked when there is some spoken feedback available.

Properties
root Array.<MathAtom>

The root element of the math expression.

path Array.<Object>

The path to the element that is the anchor for the selection.

extent number

Number of atoms in the selection. 0 if the selection is collapsed.

config Object
suppressSelectionChangeNotifications boolean

If true, the handlers for notification change won't be called. @todo This is an inelegant solution to deal with iterating the expression, which has the side effect of temporarily changing the path. We should have an iterator that doesn't change the path instead.

Source

Methods

_addCell()

Internal primitive to add a column/row in a matrix

Source

_deleteAtoms()

Delete sibling atoms

Source

addColumnAfter_()

Source

addColumnBefore_()

Source

addRowAfter_()

Source

addRowBefore_()

Source

ancestor(ancestor: number)MathAtomprivate

ancestor number

distance from self to ancestor.

  • ancestor = 0: self
  • ancestor = 1: parent
  • ancestor = 2: grand-parent
  • etc...

MathAtom   
Source

anchor()private

The atom where the selection starts. When the selection is extended the anchor remains fixed. The anchor could be either before or after the focus.

Source

applyStyle()

Source

commandOffsets() → Objectprivate

Return a {start:, end:} for the offsets of the command around the insertion point, or null.

  • start is the first atom which is of type command
  • end is after the last atom of type command
Object   
Source

commitCommandStringBeforeInsertionPoint() → stringprivate

string   
Source

contains(atom: MathAtom) → booleanprivate

atom MathAtom
boolean   

True if atom is within the selection range

Source

decorateCommandStringAroundInsertionPoint(value: boolean)private

value boolean

If true, decorate the command string around the insertion point with an error indicator (red dotted underline). If false, remove it.

Source

delete()

Delete multiple characters

Source

delete_(dir: number)

dir number

If the selection is not collapsed, and dir is negative, delete backwards, starting with the anchor atom. That is, delete(-1) will delete only the anchor atom. If dir = 0, delete only if the selection is not collapsed

Source

deleteAll_()

Delete everything in the field

Source

deleteNextChar_()

Source

deleteNextWord_()

Source

deletePreviousChar_()

Source

deletePreviousWord_()

Source

deleteToGroupEnd_()

Source

deleteToGroupStart_()

Source

deleteToMathFieldEnd_()

Source

endOffset()private

Offset of the first atom not included in the selection i.e. max value of siblings.length
endOffset - startOffset = extent

Source

extend(dist: number)private

Change the range of the selection

dist number

The change (positive or negative) to the extent of the selection. The anchor point does not move.

Source

extendDown_()

If the selection is in a numerator, the selection will be extended to include the denominator.

Source

extendToGroupEnd_()

Source

extendToGroupStart_()

Source

extendToMathFieldEnd_()

Extend the selection to the end of the math field.

Source

extendToMathFieldStart_()

Source

extendToNextBoundary_()

Extend the selection until the next boundary is reached. A boundary is defined by an atom of a different type (mbin, mord, etc...) than the current focus. For example, in "1234+x=y", if the focus is between "1" and "2", invoking extendToNextBoundary_ would extend the selection to "234".

Source

extendToNextChar_()

Source

extendToNextWord_()

Source

extendToPreviousBoundary_()

Extend the selection until the previous boundary is reached. A boundary is defined by an atom of a different type (mbin, mord, etc...) than the current focus. For example, in "1+23456", if the focus is between "5" and "6", invoking extendToPreviousBoundary would extend the selection to "2345".

Source

extendToPreviousChar_()

Source

extendToPreviousWord_()

Source

extendUp_()

If the selection is in a denominator, the selection will be extended to include the numerator.

Source

extractCharactersBeforeInsertionPoint(count: number) → stringprivate

count number

  • The number of atoms back we should return. Note that since an atom can map to multiple characters, the length of the string may be greater than this argument. It could also be smaller.

string   
Source

extractCommandStringAroundInsertionPoint() → stringprivate

string   
Source

extractContents() → Array.<MathAtom>private

Array.<MathAtom>   

The currently selected atoms, or null if the selection is collapsed

Source

extractContentsOrdInGroupBeforeInsertionPoint() → stringprivate

string   
Source

filter(cb: function, dir: number) → Array.<MathAtom>private

Iterate over each atom in the expression, starting with the focus.

Return an array of all the paths for which the callback predicate returned true.

cb function

A predicate being passed a path and the atom at this path. Return true to include the designated atom in the result.

dir number

+1 to iterate forward, -1 to iterate backward.

Array.<MathAtom>   

The atoms for which the predicate is true

Source

insert(s: string, options: Object)

s string
options Object
options.insertionMode string

  • 'replaceSelection' (default)
    • 'replaceAll'
    • 'insertBefore'
    • 'insertAfter'

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.placeholder string

The placeholder string, if necessary

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.smartFence string

If true, promote plain fences, e.g. (, as \left...\right or \mleft...\mright

Source

insertFirstAtom()private

If necessary, insert a first atom in the sibling list. If there's already a first atom, do nothing. The first atom is used as a 'placeholder' to hold the blinking caret when the caret is positioned at the very beginning of the mathlist.

Source

isCollapsed() → boolean

boolean   

True if the selection is an insertion point.

Source

jump()private

Move to the next/previous expression boundary

Source

leap() → booleanprivate

Move to the next/previous placeholder or empty child list.

boolean   

False if no placeholder found and did not move

Source

moveAfterParent_()

Source

moveBeforeParent_()

Source

moveDown_()

Source

moveToGroupEnd_()

Source

moveToGroupStart_()

Source

moveToMathFieldEnd_()

Source

moveToMathFieldStart_()

Source

moveToNextChar_()

Source

moveToNextPlaceholder_()

Source

moveToNextWord_()

Source

moveToOpposite_() → boolean

If cursor is currently in:

  • superscript: move to subscript, creating it if necessary
  • subscript: move to superscript, creating it if necessary
  • numerator: move to denominator
  • denominator: move to numerator
  • otherwise: do nothing and return false
boolean   

True if the move was possible. False is there is no opposite to move to, in which case the cursors is left unchanged.

Source

moveToPreviousChar_()

Source

moveToPreviousPlaceholder_()

Source

moveToPreviousWord_()

Source

moveToSubscript_()

Switch the cursor to the subscript and select it. If there is no subscript yet, create one.

Source

moveToSuperscript_()

Switch the cursor to the superscript and select it. If there is no subscript yet, create one.

Source

moveUp_()

Source

next()private

Move the anchor to the next permissible atom

Source

selectAll_()

Select all the atoms in the math field.

Source

selectGroup_()

Select all the atoms in the current group, that is all the siblings. When the selection is in a numerator, the group is the numerator. When the selection is a superscript or subscript, the group is the supsub.

Source

setExtent(extent: number)private

extent number
Source

setRange(from: Array.<string>, to: Array.<string>) → booleanprivate

Extend the selection between from and to nodes

from Array.<string>
to Array.<string>
boolean   

true if the range was actually changed

Source

setSelection(offset: number, extentopt: number,string, relation: string) → booleanprivate

offset number

  • >0: index of the child in the group where the selection will start from
  • <0: index counting from the end of the group

extent number | string optional = 0

Number of items in the selection:

  • 0: collapsed selection, single insertion point
  • >0: selection extending after the offset
  • <0: selection extending before the offset
  • 'end': selection extending to the end of the group
  • 'start': selection extending to the beginning of the group

relation string

e.g. 'body', 'superscript', etc...

boolean   

False if the relation is invalid (no such children)

Source

sibling()MathAtomprivate

Sibling, relative to anchor sibling(0) = start of selection sibling(-1) = sibling immediately left of start offset

MathAtom   
Source

siblings() → Array.<MathAtom>private

Array.<MathAtom>   

array of children of the parent

Source

skip(dir: number, options: Object)private

Move the selection focus to the next/previous point of interest. A point of interest is an atom of a different type (mbin, mord, etc...) than the current focus. If extend is true, the selection will be extended. Otherwise, it is collapsed, then moved.

dir number

+1 to skip forward, -1 to skip back

options Object
Source

speakAll_()

Source

speakAllWithSynchronizedHighlighting_()

Source

speakGroup_()

Source

speakLeftSibling_()

Source

speakParent_()

Source

speakRightSibling_()

Source

speakSelection_()

Source

speakSelectionWithSynchronizedHighlighting_()

Source

startOffset()private

Offset of the first atom included in the selection i.e. =1 => selection starts with and includes first atom With expression _x=_ and atoms :

  • 0:
  • 1: _x_
  • 2: _=_

  • if caret is before _x_: start = 0, end = 0

  • if caret is after _x_: start = 1, end = 1
  • if _x_ is selected: start = 1, end = 2
  • if _x=_ is selected: start = 1, end = 3
Source

toString() → stringprivate

Return a string representation of the selection.

string   
Source
To Do:
  • This is a bad name for this function, since it doesn't return a representation of the content, which one might expect...

transpose_()

Swap the characters to either side of the insertion point and advances the insertion point past both of them. Does nothing to a selected range of text.

Source