Jump to content

[SOLVED] ckeditor mathjax plugin


procnewie
 Share

Recommended Posts

I'm really not able to get this working!

 

I downloaded the plugin and dependences here: https://ckeditor.com/cke4/addon/mathjax

The first time with latest version, than i tried 4.10 version which should be the version in processwire at the moment.

 

I edited the field Body and turned on all the plugins, plus i added the Mathjax to the toolbar.

I have also 'config.mathJaxLib = '//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-AMS_HTML';', in config.js.

And i added the script to show formula on pages.

 

The fact is that i get the the botton on the toolbar, i get formulas viewed on pages but in the editor they don't show up.

It's blank in editor when i insert a formula. Also in the formula windows i don't get the preview.

It's really not working the editing part, is able to insert it as an object, but is not able to reproduce in the editor.

Link to comment
Share on other sites

Hi and welcome,

 

3 hours ago, procnewie said:

The fact is that i get the the botton on the toolbar, i get formulas viewed on pages but in the editor they don't show up.

It's blank in editor when i insert a formula. Also in the formula windows i don't get the preview.

You likely have an issue with document encoding (while pasting the url in the config.js file), you can check it in the Network tab of your browser developer tool, 404 error happen for sure, try recopying from here or write the url by hand :

config.mathJaxLib = '//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-AMS_HTML';

 

Error diff from your previous "pasted" line :

1066848209_Capturedecran2018-12-30a12_29_47.thumb.png.b40e90edb2c4e81011855478573297c9.png

 

Result:

49455003_Capturedecran2018-12-30a12_37_21.png.25b2a52b3b99d27074a811e52b9890b1.png

Link to comment
Share on other sites

Nevermind. Thank you anyway since you pointed me in the right direction.

Opening the console and loading the page showed me an error saying that mathjax was missing the configuration.

So i went again to configuration file and i discovered that if some-config.js exist, options in config.js are ignored...
So i moved the conf from config.js to config-body.js and now is working.

Is really really slow thought.

Link to comment
Share on other sites

1 minute ago, procnewie said:

Is really really slow thought.

Then download it from the cdn server and load the file locally.

 

1 minute ago, procnewie said:

options in config.js are ignored...

Nah, you had a typo in your url ?

Link to comment
Share on other sites

On Chrome it's fast.

On Firefox console i get a lot of errors related to a missing  header CORS “Access-Control-Allow-Origin” .

I guess that will slow down a bit things since there a lot of related to http://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/fonts/HTML-CSS/TeX/otf/MathJax*.otf

Even if i'm not really sure where those links come from... They are not in my sources anywhere...

Link to comment
Share on other sites

I'm sorry that i can not edit my previous posts.

The firefox issue is documented in mathjax. I need to set something in my web server to solve it.

I really don't like to use a cdn, but including a local versionl seems more than just the simple javascript file.

 

About the AdminOnSteroids, i'm not sure i would load such a thing only to get mathjax.

Link to comment
Share on other sites

To use it locally it's simple.

  • Download and install Mathjax lib

Download Mathjax from Github and extract the following file and folders from the downloaded archive into the CKEditor Mathjax plugin dir : 

601347929_Capturedecran2018-12-30a15_13_52.png.639d0b5daa19ebfb6978552ffafdb7e6.png  Left panel =  CKEditor mathjax plugin dir  /  Right panel = Mathjax downloaded folder

 

  • Modify your config.js (or config-body.js)

before :

config.mathJaxLib = '//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-AMS_HTML';

after :

config.mathJaxLib = ProcessWire.config.urls.root + 'site/modules/InputfieldCKEditor/plugins/mathjax/MathJax.js?config=TeX-AMS_CHTML';

 

Note :  on the config line, the config get value (?config=TeX-AMS_CHTML) need to be the name of one config file existing under the mathjax/config dir.

 

Refresh your page and voila.

 

  • Like 2
Link to comment
Share on other sites

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...