在ckeditor中编辑内容时无法读取数学公式

时间:2017-10-04 08:26:36

标签: javascript jquery html ckeditor fckeditor

我在ckeditor中使用数学公式,当我通过textarea插入新内容时,它可以读取数学公式,但是如果我编辑这个内容,它似乎无法像以前一样读取和显示文本公式..

这是我的来源:

<head>
<script type="text/x-mathjax-config">MathJax.Hub.Config({tex2jax: {inlineMath: [['\\(','\\)']]}});</script>     
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script src="https://cdn.ckeditor.com/4.7.3/standard/ckeditor.js">   </script>
</head>

<body>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
    <tr>
        <td valign="top">
            <span >Question Code : <%=id_q%>&nbsp;-&nbsp;<%=valid_types%>&nbsp;(Number presented : <%=make_cnt%>)</span>
        <table border="0">
        <tr>
        <td width="640" height="650">
            <textarea name="ir1" id="ir1" rows="1" cols="10" style="width:580px; height:600px; min-width:400px; min-height:50px; display:none;"></textarea>                     
            <script>
                var ir1 = CKEDITOR.replace('ir1', {                                     
                extraPlugins: 'mathjax,video,font,justify,preview,colorbutton,panelbutton',
                mathJaxLib: 'https://cdn.mathjax.org/mathjax/2.6-latest/MathJax.js?config=TeX-AMS_HTML'
                });
                CKFinder.setupCKEditor(ir1, 'libraries/ckfinder/');
            </script>
        </td>           
    </tr>
</table>   
</body>

当我为内容添加编辑按钮时,这是结果: enter image description here

如何在编辑内容时在ckeditor中显示正确的mathjax?感谢

1 个答案:

答案 0 :(得分:0)

您可以尝试将MathJax脚本移动到头标记的底部,如下所示:

    <head>            
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
        <script src="https://cdn.ckeditor.com/4.7.3/standard/ckeditor.js"></script>
        <script type="text/x-mathjax-config">MathJax.Hub.Config({tex2jax: {inlineMath: [['\\(','\\)']]}});</script>     
    </head>

确保代码可以访问MathJax名称空间。