给Z-blog的FCKeditor加上代码高亮插件

因为要写点代码在日志里面,光是文本显示感觉不爽,一直想找个高亮显示的插件.找到了dp.SyntaxHighlighter.弄了很久都没弄好,先是在模版里改,显示效果不是很好,而且一旦换了模版后还是要再改一次.所以就想法从编辑器着手.网上搜索之后,发现很多好的办法,无奈人笨,选了个简单的. 让FCKEditor与dp.syntaxhighlighter完美结合

下载插件,然后解压,放置在你的FCK里的plugins目录,或者其他自定义的plugin目录。
1、修改你的config文件,在ToolbarSet里加上'HighLighter'。

// Set toolbar.
FCKConfig.ToolbarSets["custom"] = [
['HighLighter','Placeholder','DocProps','-','Save','NewPage','Preview','-','Templates'],
['Cut','Copy','Paste','PasteText','PasteWord','-','Print','SpellCheck'],
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
['Form','Checkbox','Radio','TextField','Textarea','Select','Button','ImageButton','HiddenField'],
'/',
['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],
['OrderedList','UnorderedList','-','Outdent','Indent'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
['Link','Unlink','Anchor'],
['Image','Flash','Table','Rule','Smiley','SpecialChar'],
'/',
['Style','FontFormat','FontName','FontSize'],
['TextColor','BGColor'],
['FitWindow']
] ;        

2、根据你指定的plugin目录,注册plugin

// Change the default plugin path.
FCKConfig.PluginsPath = FCKConfig.BasePath.substr(0, FCKConfig.BasePath.length - 7) + 'editor/customPlugins' ;
//注意这里,就是调用syntaxhighlighter插件的地方
FCKConfig.Plugins.Add( 'highlighter' , 'en') ;  

当然实现的方法不只一种,在无忧论坛上也有比较好的解决方法http://bbs.5u.hk/viewthread.php?tid=3308用的是insertCode

Published by 阿飞 on
Tags: z-blog, fckeditor

暂无评论