OKこの方法を試して、あなたはそれがライブだ編集可能領域内でコンテンツを交換するときエディタとページが同期しなくなります。
厳密なシナリオではこれを簡単に試すことはできませんが、次のコードでは、どのように進化し、どのような改訂が必要なのかを教えていただければ、私はそれをうれしく更新します。簡単な質問の
var editor = ContentTools.EditorApp.get();
// Add a flag to the editor that indicates when the tex version of the content
// has loaded.
editor.texLoaded = false;
// Capture the start event against the editor, the first time around we load
// the tex version of our content, the second time around we intialize the
// editor as normal.
editor.addEventListener('start', function(ev) {
// Has the Tex content been loaded, if so do nothing we're ready to start
// editing.
if (this.texLoaded) {
return;
}
// If the Tex content hasn't been loaded then cancel the start event
ev.preventDefault();
// Load the Tex content
$.ajax({
url: "/get-tex?..."
}).done(function (response) {
// From the response update the contents of the editable region
$('.contentArea')[0].innerHTML = response.data.content;
// Flag that the tex version of the content is now in place
this.texLoaded = true;
// Start the editor
editor.start();
});
});
カップル:あなたは地域の内容を置き換えるしようとすると、CTエディタがアクティブです(例えば、あなたが編集していますか)?挿入する前に、またはエディタを再度初期化しようとする前に、MathJaxによってフォーマットされたコンテンツを挿入していますか? –
@AnthonyBlackshaw MathJaxがレンダリングされると、TeXがMathMLに変換されます。私はMathMLマークアップを編集するのではなく、TeX(要素のinnerHTML内の$ x^2 + 7 $のように)を編集したいと思います。 私は次のことをしようとしています。エディタが起動したら、MathMLマークアップを削除してTeXマークアップに戻すために、ページコンテンツをページにリロードしてから、そのコンテンツの編集を開始します。したがって、私はエディタが起動するときにコンテンツを置き換えようとしています(これをeditor._ignitionの 'start'イベントにバインドしています)。私は助けに感謝します。 –
こんにちは@グランサンダーズ - 私はあなたが新しいので参照してください。回答が問題を解決したと感じる場合は、緑色のチェックマークをクリックして「受け入れ済み」とマークしてください。これはまだ答えがない年上のSOに焦点を当てるのに役立ちます。 –