mathjax-editor

Try typing above!

Usage

1. Ensure MathJax is loaded in your application.

2. Add the mje.js file to your application (module coming soon):

<script src="https://cdn.jsdelivr.net/gh/ianlucas/mathjax-editor/dist/mathjax-editor.js?v=3"></script>

3. Use a target element to create the editor:

<input id="target">

<script>
  const editor = mathJaxEditor('#target')
</script>

API

editor.raw()

Get editor current value as a HTMLElement.

editor.get()

Get editor current value as a string.

editor.set(value: String)

Set editor current value.

editor.readonly(value: Boolean)

Define whether the editor is readonly.

editor.left()

Move the cursor to the left.

editor.right()

Move the cursor to the left.

editor.del()

Apply a delete in the current position.

editor.backspace()

Apply a backspace in the current position.

editor.number(n: String|Number)

Insert a number in the current position.

n — number to be inserted, e.q. 1, 2, ...

editor.identifier(c: String)

Insert an identifier in the current position.

c — identifier to be inserted, e.q. α, β, ...

editor.operator(c: String)

Insert an operator in the current position.

c — operator to be inserted, e.q. , , ...

editor.sqrt()

Insert a square root in the current position.

editor.frac()

Insert a fraction in the current position.

editor.root()

Insert a root in the current position.

editor.sup()

Insert a superscript in the current position.

editor.sub()

Insert a subscript in the current position.

editor.subsup()

Insert a superscript and superscript in the current position.

Useful Tables

mje does not include by default all identifiers and operators you can use with it. Here is some useful tables you can use to input identifiers and operators.

Tex Command Operator
+ +
- -
= =
> >
< <
| |
% %
, ,
. .
$ $
( (
) )
[ [
] ]
! !
\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
\rfloor
Tex Command Identifier
\sin sin
\cos cos
\tan tan
\cot cot
\arcsin arcsin
\arccos arccos
\arctan arctan
\arccot arccot
\sinh sinh
\cosh cosh
\tanh tanh
\coth coth
\sec sec
\csc 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
\gimel