Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.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 Epiceditor与MathJax配对_Javascript_Mathjax_Epiceditor - Fatal编程技术网

Javascript Epiceditor与MathJax配对

Javascript Epiceditor与MathJax配对,javascript,mathjax,epiceditor,Javascript,Mathjax,Epiceditor,是否仍然可以将脚本(如MathJax)加载到EpicEditor预览iFrame中?我希望我的预览是正确的标记,然后运行javascript预览MathJax内容 谢谢 似乎应该手动将MathJax脚本注入previewer iframe。大概是这样的: var editor = new EpicEditor(opts).load(); previewer = editor.getElement('previewer'); var mathjax = previewer.createEleme

是否仍然可以将脚本(如MathJax)加载到EpicEditor预览iFrame中?我希望我的预览是正确的标记,然后运行javascript预览MathJax内容


谢谢

似乎应该手动将MathJax脚本注入previewer iframe。大概是这样的:

var editor = new EpicEditor(opts).load();

previewer = editor.getElement('previewer');
var mathjax = previewer.createElement('script');
mathjax.type = 'text/javascript';
mathjax.src = 'http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML';
previewer.body.appendChild(mathjax);

var config = previewer.createElement('script');
config.type = 'text/x-mathjax-config';
config.text = "MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$']], displayMath: [['$$','$$']], processEscapes: true}});";
previewer.body.appendChild(config);
然后,可以在预览事件上渲染方程式:

editor.on('preview', function() {
    editor.getElement('previewerIframe').contentWindow.eval(
        'MathJax.Hub.Queue(["Typeset",MathJax.Hub]);');
});

这也适用于全屏实时编辑模式。

如果采用这种方法,是否有一种机制可以在内容更改高度后调整预览iframe的大小?回流方法根据容器调整iframe的大小,这是不好的。未来的注意:cdn.mathjax.org即将结束,请查看迁移提示(或者为将来的读者更新您的帖子)。