あなたがリンクしている質問は、それをかなり要約しています。まず、何をやることはあなたのページにプレビュー<div>
を追加している、何かのように:
<div id="tiny-mce-preview"></div>
(あなたはこの質問がjQuery
タグが付いているので、私はあなたがTinyMCEをjQueryのパッケージを使用していると仮定するつもりです)TinyMCE初期化の中で、onKeyPress
イベントに関数を追加して、TinyMCEコンテンツをプレビュー<div>
にコピーします。だから、完全な初期化は次のようなもののようになります。
var theEditor = $('textarea').tinymce({
script_url: 'path/to/your/tinymce/tiny_mce.js',
height: "400",
width: "600",
//
// ... whatever other options you may have ...
//
// Capture the onKeyPress event and do something with TinyMCE's content
setup: function (theEditor) {
// "theEditor" refers to the current TinyMCE instance
theEditor.onKeyPress.add(function() {
// Get the current editor's content
var content = theEditor.getContent();
// Find our "preview" div
// Set it's content to be the same as the editor's
document.getElementById("tiny-mce-preview").innerHTML = content;
})
}
});
キーはTinyMCEのインスタンス内で押されたときはいつでも、プレビューdiv
のコンテンツは、TinyMCEのインスタンスのものに設定されます。
tinymceにはプレビューボタンがありますか?私の場合、それは「フォントサイズ」の矢印のすぐ下に表示されます。そのアイコンは、拡大鏡が付いた空白のページに似ています(私は先進的なテーマを使用しています) –
私が望むのは、完全に別のdivをプレビューすることです –