This method is a lot easier than the old one!
Using Rangy, I can get the position of the cursor in screen co-ordinates, which allows me to position a MathJax preview of the TeX you're typing directly above it.
For example, click somewhere in the following: $\frac{x}{2}$
This whole area is just a contenteditable
div.