Jquery plugins tinyMCE iframe中的JQuery SyntaxHighLighter插件

Jquery plugins tinyMCE iframe中的JQuery SyntaxHighLighter插件,jquery-plugins,tinymce,syntaxhighlighter,Jquery Plugins,Tinymce,Syntaxhighlighter,我发现一个关于SyntaxHighlighter的问题 但是,我说的是jquery插件,而不是 我想强调tinyMCE中的源代码 我添加以下按钮: ed.addButton('srccd', { title: 'Source Code', image: 'sourcecode.png', onclick: function() {

我发现一个关于SyntaxHighlighter的问题

但是,我说的是jquery插件,而不是

我想强调tinyMCE中的源代码 我添加以下按钮:

ed.addButton('srccd', {
                     title: 'Source Code',
                     image: 'sourcecode.png',
                     onclick: function() {
                         ed.focus();       
                         var newSRCjq='<pre id="s1" class="highlight">'+ ed.selection.getContent() + '</pre>';
                         ed.selection.setContent(newSRCjq);


                           $.SyntaxHighlighter.init({})

                     }
                 });
我没有达到预期的结果

注意:我不会忘记在一天后为上面的插件导入所需的JS和CSS: 让我们介绍一下my,它是一个基于以下内容的编译器:

如何使用

而不是:

$('pre').snippet('java',{box:"1-2"});
添加本地或会话参数:

$('pre').snippetcache('local','java',{box:"1-2"});
==>这意味着您有
前置元素。当您运行上面的代码段时,我的插件将使用
jquerysyntaxhighlighter
编译代码,然后保存呈现的代码。因此,如果另一个
pre
具有与先前编译的
pre
相同的代码(内部文本),编译器将从其缓存中检索呈现的代码

但是,当您刷新页面时,缓存将被删除。如果想要有状态编译器,请使用会话参数值而不是本地参数

$('pre').snippetcache('session','java',{box:"1-2"});
看见 这是一个非常有用的插件,在iframe中作为tinyMCE。事实上,试试这个:

    ed.addButton('srccd', {
                         title: 'Source Code',
                         image: 'sourcecode.png',
                         onclick: function() {
                             ed.focus();   
                                //You should have an ID which is generated automatically     
                             var newSRCjq='<pre id="s1" class="highlight">'+ ed.selection.getContent() + '</pre>';
                             ed.selection.setContent(newSRCjq);

                       // iframe selected is the frame of TinyMCE  

                   $('iframe').contents.find('pre#s1').snippetcache('local','java',{box:"1-2"});




                 }
             });
ed.addButton('srccd'{
标题:“源代码”,
图片:“sourcecode.png”,
onclick:function(){
ed.focus();
//您应该有一个自动生成的ID
var newSRCjq=''+ed.selection.getContent()+'';
ed.selection.setContent(newSRCjq);
//iframe selected是TinyMCE的框架
$('iframe').contents.find('pre#s1').snippetcache('local','java',{box:'1-2});
}
});
    ed.addButton('srccd', {
                         title: 'Source Code',
                         image: 'sourcecode.png',
                         onclick: function() {
                             ed.focus();   
                                //You should have an ID which is generated automatically     
                             var newSRCjq='<pre id="s1" class="highlight">'+ ed.selection.getContent() + '</pre>';
                             ed.selection.setContent(newSRCjq);

                       // iframe selected is the frame of TinyMCE  

                   $('iframe').contents.find('pre#s1').snippetcache('local','java',{box:"1-2"});




                 }
             });