DraftJS KaTeX Plugin
This is a plugin for the draft-js-plugins-editor
.
This plugin insert and render LaTeX using KaTeX, modified from TeX example.
- Integrated with Khan/math-input.
Usage
Add MathQuill libs if you want to use MathInput:
Add plugin
; const kaTeXPlugin = ; const InsertButton = kaTeXPlugin;
With MathInput:
;; const kaTeXPlugin = ; const InsertButton = kaTeXPlugin;
There are more examples in the stories/index.js
file.
Configuration options:
Here shown with defaults:
katex // the katex object or a wrapper defining render() and __parse(). doneContent: valid: 'Done' invalid: 'Invalid TeX' MathInput: null // Sett to the MathInput element to use MathInput removeContent: 'Remove' theme: // CSS classes, either you define them or they come from the plugin.css import saveButton: '' removeButton: '' invalidButton: '' buttons: '' // function (string) -> string. translator: null
Loading katex async
If you want to load katex in the background instead of right away, then you can do this by wrapping the katex object that you pass into the plugin:
//file: asyncKatex.jslet katex = nullconst renderQueue = System { if katex return katex renderQueue } // parse is only used by this plugin to check syntax validity. { if katex return katex return null }
Store this in a separate file and and pass it to the plugin config:
; const kaTeXPlugin = ;