Triggering style load for equation in ckeditor

5 views
Skip to first unread message

Anish Kumar

unread,
Feb 13, 2018, 2:31:16 AM2/13/18
to MathJax Users
I am using equation editor to build equation for ckeditor by calling an mathjax-node api to get my html output and inserting the html to the ckeditor but on first load the styles for the equation are not loaded but when I edit the equation or open up the equation editor the style tag for the equations is added dynamically to the head. I would like to trigger this addition onload itself instead of loading it only when there is tex code in the input of ckeditor.

Davide Cervone

unread,
Feb 13, 2018, 10:25:39 AM2/13/18
to mathja...@googlegroups.com
Here is a snippet that does what I think you are looking for.  The idea is to force MathJax to process at least one equation (even though it is not actually in the page).

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  "fast-preview": {disabled: true}
});
(function () {
  var div = document.createElement("div");
  div.innerHTML = "\\[\\]";
  MathJax.Hub.Queue(
    ["Typeset",MathJax.Hub,div],
    function () {console.log(document.head.lastChild.innerHTML)}
  );
})();
</script>

Note that the stylesheet is not available immediately, so you need to queue the function that uses it as well as the typesetting.  That way, you won't access the stylesheet until you know it is there.

Davide



On Feb 13, 2018, at 2:31 AM, Anish Kumar <changa...@gmail.com> wrote:

I am using equation editor to build equation for ckeditor by calling an mathjax-node api to get my html output and inserting the html to the ckeditor but on first load the styles for the equation are not loaded but when I edit the equation or open up the equation editor the style tag for the equations is added dynamically to the head. I would like to trigger this addition onload itself instead of loading it only when there is tex code in the input of ckeditor.

--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages