GetmeUK / ContentTools

A JS library for building WYSIWYG editors for HTML content.
http://getcontenttools.com
MIT License
3.95k stars 395 forks source link

Maths and chemical equations #462

Closed imsiddharth closed 6 years ago

imsiddharth commented 6 years ago

Hi Anthony, the content tool is awesome. I was looking for maths and chemical equation to add in content editor

screen shot 2017-12-18 at 3 14 41 pm screen shot 2017-12-18 at 3 14 47 pm

i was not able to find the documentation for it. if you can guide me through it that would be helpfull.

Thanks, Siddharth

anthonyjb commented 6 years ago

Hi @imsiddharth - thank you for the kind words!

I've not used equations with ContentTools before (or with HTML before) so I wasn't initially sure what to suggest. I've now had a play with a couple of libraries and as an initially suggestion before perhaps we integrate something fully I'd recommend looking at https://www.mathjax.org/

The library is easy to install and provides a way to convert a HTML shorthand (e.g \(ax^2 + bx + c = 0\)) to visual equation (as per your example).

As there's no integration with ContentTools (as of yet) what you'd need to do is use the MathJAX library on the public version of your pages (by including the script), but not use it in the editing environment (otherwise you'll end up storing the non-editable versions of the equations in your pages or database).

Longer term I'd like to look at maybe adding an extension so that the equations convert from/to and the HTML shorthand and visual equations when the editor is started and stopped.

Hope that helps - Ant