Fork me on GitHub


This module contains the definition of a data structure representing a list of math atoms that can be edited. It is an in-memory representation of a mathematical expression whose elements, math atoms, can be removed, inserted or re-arranged. In addition, the data structure keeps track of a selection, which can be either an insertion point — the selection is then said to be collapsed — or a range of atoms.

See EditableMathlist


arrayCell(atom: MathAtom | MathAtom[], colrow: any)inner

Return the array cell corresponding to colrow or null (for example in a sparse array)

atom : MathAtom | MathAtom[]
colrow : any

arrayCellCount(atom: MathAtom)inner

Total numbers of cells (include sparse cells) in the array.

atom : MathAtom

arrayColRow(atom: MathAtom, index: number)inner

Convert an array index (scalar) to an array row/col.

atom : MathAtom
index : number

arrayIndex(atom: MathAtom, rowCol: object): numberinner

Convert am array row/col into an array index.

atom : MathAtom
rowCol : object
: number   

atomContains(atom: MathAtom, target: MathAtom): booleanprivateinner

atom : MathAtom
target : MathAtom
: boolean   

True if atom is the target, or if one of the children of atom contains the target

getString(atom: MathAtom)inner

Return a 'string' version of the atom. This is used when matching auto-inline replacements for example, so we make a best attempt at getting a string version of the atom. Some atom types are effectively 'hard' barriers in the string because they're not obvious to translate to a string. We don't want them to be transparent, so we map them to '\ufffd' (REPLACEMENT CHARACTER).

For example, '-\sqrt{2}=' should not trigger a replacement of '-='

atom : MathAtom