MathJax Editor Star

Getting Started

First, you will need to add MathJax to your page, then add MathJax Editor file or install it via npm:

npm install mathjax-editor

MathJax Editor was tested on Chrome, Firefox and Internet Explorer 9 with babel-polyfill.

Usage

Put a <textarea> where the editor should be placed, like this:

<textarea id="myEditor"></textarea>

Then, instantiate the editor:

const editor = new MathJaxEditor('#myEditor')

Styling the Editor

To style the display, just use the .mathjax-editor-display selector. To style the caret, use the .mathjax-editor-caret selector.

The API

new MathJaxEditor(selectors[, options])


editor.backspaceRemove()

Perform a "backspace" deletion in the editor.


editor.deleteRemove()

Perform a "delete" deletion in the editor.


editor.destroy()

Remove the editor element and event listeners.


editor.focus()

Focus the editor.


editor.getValue()

Get the editor value as a <math> HTML Element.


editor.insertNumber(n)

Insert a number in the editor.


editor.insertIdentifier(i)

Insert an identifier in the editor.


editor.insertOperator(o)

Insert an operator in the editor.


editor.insertFraction()

Insert a fraction in the editor.


editor.insertSqrt()

Insert a square root in the editor.


editor.insertRoot()

Insert a nth root in the editor.


editor.insertSuperscript()

Insert a superscript in the editor.


editor.insertSubscript()

Insert a subscript in the editor.


editor.insertNewline()

Insert a newline in the editor.


editor.moveCursorLeft()

Move the cursor to the left.


editor.moveCursorRight()

Move the cursor to the right.


editor.on(type, listener)

Listen to an editor event. Currently available: update, focus and blur.


editor.setValue($value)

Set the value of the editor.


editor.toString()

Get the value of the editor as MathML string.


editor.toTex()

Get the value of the editor as a Tex string. (Pretty experimental, but should work.)

Identifier List

Besides alphabetical characters, these identifiers are also usable: \sin, \cos, \tan, \cot, \arcsin, \arccos, \arctan, \arccot, \sinh, \cosh, \tanh, \coth, \sec, \csc, \alpha, \beta, \gamma, \Gamma, \delta, \Delta, \epsilon, \varepsilon, \zeta, \eta, \theta, \vartheta, \Theta, \iota, \kappa, \Lambda, \lambda, \mu, \nu, \xi, \Xi, \pi, \Pi, \rho, \varrho, \sigma, \Sigma, \tau, \upsilon, \Upsilon, \phi, \varphi, \Phi, \chi, \psi, \Psi, \omega, \Omega, \partial, \eth, \hbar, \imath, \jmath, \ell, \Re, \Im, \wp, \nabla, \infty, \aleph, \beth, and \gimel.

Operators List

These are the allowed operators: +, -, =, <, >, |, %, ,, ., $, (, ), [, ], !, \leq, \geq, \ll, \gg, \subset, \supset, \subseteq, \supseteq, \nsubseteq, \nsupseteq, \sqsubset, \sqsupset, \sqsubseteq, \sqsupseteq, \preceq, \succeq, \doteq, \equiv, \approx, \cong, \simeq, \sim, \propto, \neq, \parallel, \asymp, \vdash, \in, \smile, \models, \perp, \prec, \sphericalangle, \nparallel, \bowtie, \dashv, \ni, \frown, \notin, \mid, \succ, \measuredangle, \pm, \div, \times, \cdot, \mp, \ast, \star, \dagger, \ddagger, \cap, \cup, \uplus, \sqcap, \sqcup, \vee, \wedge, \diamond, \bigtriangleup, \bigtriangledown, \triangleleft, \triangleright, \bigcirc, \bullet, \wr, \oplus, \ominus, \otimes, \odot, \circ, \setminus, \amalg, \exists, \nexists, \forall, \neg, \land, \lor, \rightarrow, \leftarrow, \mapsto, \implies, \Rightarrow, \leftrightarrow, \iff, \Leftrightarrow, \top, \bot, \emptyset, \varnothing, \{, \uparrow, \downarrow, \|, \}, \Uparrow, \Downarrow, /, \angle, \lceil, \lfloor, \backslash, \rangle, \rceil, and \rfloor.