'+e+""))}n.selection.moveToBookmark(a)}function o(){return function(){var e=this;t.on("nodeChange",function(){var o=null;try{var n=t.selection.getNode();"PRE"==n.nodeName&&(o=$.trim($(n).attr("class").split(":")[1]))}catch(r){}e.value(o)})}}var n=t;t.addButton("leanote_code",function(){var t=["CSS:css","C/C++:cpp","C#:c#","Javascript:javascript","Java:java","PHP:php","Python:python","Shell:shell","Delphi:delphi","Golang:golang","Erlang:erlang","Groovy:groovy","ActionScript:actionScript"],n=[];for(var r in t){var a=t[r].split(":");n.push({text:a[0],value:a[1]})}return{type:"listbox",text:"代码语言",tooltip:"ctrl+shift+c 切换代码",values:n,fixedWidth:!0,onselect:function(t){t.control.settings.value&&e(t.control.settings.value)},onPostRender:o(n)}}),n.addCommand("toggleCode",function(){var t,e=n.selection.getNode(),o=n.selection.getContent(),r=n.selection.getBookmark();try{t=$.trim($(o).text())}catch(a){}t||(t=$.trim(o)),t?"PRE"==e.nodeName?$(e).replaceWith("
"+$(e).html()+"
"):n.insertContent(""+t+""):$(e).replaceWith("PRE"==e.nodeName?"
"+$(e).html().replace(/\n/g,"
")+"
"+$(e).html()+""),n.selection.moveToBookmark(r)}),n.addShortcut("ctrl+shift+c","","toggleCode"),n.addShortcut("command+shift+c","","toggleCode")}); \ No newline at end of file +tinymce.PluginManager.requireLangPack("leanote_code"),tinymce.PluginManager.add("leanote_code",function(e){function t(e){var t,o=n.selection.getNode(),a=n.selection.getContent(),r=n.selection.getBookmark();if("PRE"==o.nodeName)$(o).attr("class","brush:"+e);else{if("BODY"==o.nodeName)return;try{t=$(a).text()}catch(c){}t?n.insertContent('
'+t+""):(t=$(o).text(),$(o).replaceWith('
'+t+""))}n.selection.moveToBookmark(r)}function o(){return function(){var t=this;e.on("nodeChange",function(){var o=null;try{var n=e.selection.getNode();"PRE"==n.nodeName&&(o=$.trim($(n).attr("class").split(":")[1]))}catch(a){}t.value(o)})}}var n=e;e.addButton("leanote_code",function(){var e=["CSS:css","C/C++:cpp","C#:c#","Javascript:javascript","Java:java","PHP:php","Python:python","Shell:shell","Delphi:delphi","Golang:golang","Erlang:erlang","Groovy:groovy","ActionScript:actionScript"],n=[];for(var a in e){var r=e[a].split(":");n.push({text:r[0],value:r[1]})}return{type:"listbox",text:"codeLang",tooltip:"toggleCode",values:n,fixedWidth:!0,onselect:function(e){e.control.settings.value&&t(e.control.settings.value)},onPostRender:o(n)}}),n.addCommand("toggleCode",function(){var e,t=n.selection.getNode(),o=n.selection.getContent(),a=n.selection.getBookmark();try{e=$.trim($(o).text())}catch(r){}e||(e=$.trim(o)),e?"PRE"==t.nodeName?$(t).replaceWith("
"+$(t).html()+"
"):n.insertContent(""+e+""):$(t).replaceWith("PRE"==t.nodeName?"
"+$(t).html().replace(/\n/g,"
")+"
"+$(t).html()+""),n.selection.moveToBookmark(a)}),n.addShortcut("ctrl+shift+c","","toggleCode"),n.addShortcut("command+shift+c","","toggleCode")}); \ No newline at end of file