Adds toolbar and addbar buttons for math formula blocks rendered with KaTeX. Supports inline and display delimiters ($...$, $$...$$, \(...\), \[...\]).
Click Math in the toolbar or addbar to insert a formula, or open an existing math block to edit it. Requires KaTeX loaded on the page (window.katex).
Click Math in the toolbar to insert a formula. Try inline $E=mc^2$ or display $$\\sum_{i=1}^{n} i$$.
$$\\sum_{i=1}^{n} i$$
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css">
<script src="/assets/redactor/redactor.js"></script>
<script src="/assets/redactor/plugins/math/math.js"></script>
const app = Redactor('#entry', {
plugins: ['math']
});
boolean)
falsetrue, adds the button to the context toolbar as well.string)
'math'object[])
[{ left: '$$', right: '$$', display: true }, { left: '$', right: '$', display: false }, ...]{ left, right, display }.string)
Redactor('#entry', {
plugins: ['math'],
math: {
context: false,
classname: 'my-math'
}
});
Formula examples:
$E=mc^2$ or \(E=mc^2\)$$\int_0^1 x^2 dx$$ or \[\int_0^1 x^2 dx\]en: {
math: {
math: 'Math',
label: 'Type an expression (use $$$...$$$ or \\[...\\] for blocks, and $...$ or \\(...\\) for inline formulas)'
}
}
This plugin does not emit events.
Opens the insert form or inserts a formula from form data.
Saves the edited formula on the current math block and re-renders with KaTeX.
Removes the current math block.
app.math.remove();