Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/374.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何从TinyMCE的fMath编辑器插件获取MathML/Latex代码?_Javascript_Jquery_Math_Tinymce_Tinymce 4 - Fatal编程技术网

Javascript 如何从TinyMCE的fMath编辑器插件获取MathML/Latex代码?

Javascript 如何从TinyMCE的fMath编辑器插件获取MathML/Latex代码?,javascript,jquery,math,tinymce,tinymce-4,Javascript,Jquery,Math,Tinymce,Tinymce 4,我需要使用TinyMCE编辑器,但我也需要能够编辑数学方程和公式。我在TinyMCE安装中添加了FMath编辑器插件 是的,它可以工作,我可以添加方程,但方程是由包含blob:httpurl的src生成的img标记生成的,这意味着图像存在于浏览器内存中,一旦浏览器关闭就会被删除 是的,有两个技巧如何使用AJAX处理blob img标记,但问题是,我希望能够将编辑的文本和数学公式保存到数据库中 我认为最好的方法是将方程的MathML/Latex表示保存在数据库中。障碍是,FMath编辑器的文档很差

我需要使用TinyMCE编辑器,但我也需要能够编辑数学方程和公式。我在TinyMCE安装中添加了FMath编辑器插件

是的,它可以工作,我可以添加方程,但方程是由包含blob:httpurl的src生成的img标记生成的,这意味着图像存在于浏览器内存中,一旦浏览器关闭就会被删除

是的,有两个技巧如何使用AJAX处理blob img标记,但问题是,我希望能够将编辑的文本和数学公式保存到数据库中

我认为最好的方法是将方程的MathML/Latex表示保存在数据库中。障碍是,FMath编辑器的文档很差,所以我不知道如何获得生成的MathML/Latex代码

那么我该怎么做呢,是否有一些FMath函数,getMathML代码等等


通过TinyMCE访问插件API时遇到了问题?

如果要在TinyMCE插件文件夹中检查plugin.min.js中的FMath,它只会在TinyMCE创建的iframe中加载一个html页面yeditor.html。此html页面包含如下getter函数:

<script type="text/javascript">

    var e1 = $("#editor1").mathEditor({ width: 1000, height: 400 }),
        mathml = null;

    e1.mathEditor("setSaveCallback", clientSaveMethod);

    function clientSaveMethod(){
        // get info from editor ex: get image
        console.dir(e1.mathEditor("getMathML", "UNICODE", "true"));
    }

    function getMathML(){
        return e1.mathEditor("getMathML", "UNICODE", "true");
    }

    function getBlobOrUrl(returnFunc){
        return e1.mathEditor("getBlobOrUrl", returnFunc, "UNICODE", "true");
    }

    function setMathML(mathml){
        e1.mathEditor("setMathML", mathml);
    }

    function getImage(){
        return e1.mathEditor("getImage","png");
    }

    function getMathMLToLoad(){
        return null;
    }

    // autoload used in tinyMCE editor - do not delete
    if (window.parent !== null && window.parent.getMathMLToLoad !== null) {
        mathml = window.parent.getMathMLToLoad();

        if (mathml !== null) {
            e1.mathEditor("setMathML", mathml);
        }
    }
</script>

因此getMathML以xml格式返回原始MathML。getImage返回生成图像的blob地址/数据。您还可以使用setMathML设置FMath编辑器以加载您的特定公式。

我已经开发了自定义插件解决方案,请查看:

它使用MathJax呈现字体。它是免费的,并且有麻省理工学院的许可证

看看我的其他插件,您可能有兴趣使用数学函数生成一些图表或图形