EpicEditor プレビュー iFrame にスクリプト (MathJax など) をロードする方法はありますか? プレビューを正しい Markdown にしてから、JavaScript を実行して MathJax コンテンツをプレビューします。
ありがとう!
EpicEditor プレビュー iFrame にスクリプト (MathJax など) をロードする方法はありますか? プレビューを正しい Markdown にしてから、JavaScript を実行して MathJax コンテンツをプレビューします。
ありがとう!
MathJax スクリプトをプレビューア 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]);');
});
これは、フルスクリーンのライブ編集モードでも機能します。