Use MathjaxEditing.js (or mj.js)