添加收藏
 系统管理
 联系方式

  汉南在线网页设计JavaScript脚本

让FCKEditor与dp.syntaxhighlighter完美结合
作  者:匿名
关键字:JavaScript



FCKeditor毫无疑问已经是WEB编辑器的龙头老大,功能强,使用广,为广大程序员所喜欢。
dp.syntaxhighlighter是完全用javascript编写,用来实现语法高亮的工具。以其方便易用,功能强大,赢了广大开发的青睐。
很多人都很喜欢WORDPRESS的语法亮亮,可以以WORDPRESS的语法高亮插件是赢得如此之多程序员喜欢的重要理由。
如果我们能够把syntaxhighlighter开发成为FCKeditor的语法高亮显示插件,那么对于FCKeditor来说,无疑是如虎添翼。而对于syntaxhighlighter来说,更是多了一个展现自己的更大舞台。
事实上,国内早已经有人这么做了,比如JAVAEYE的论坛,就是把syntaxhighlighter做为FCKeditor的插件来实现语法高亮显示。其他好像也有人做了,不过除了JAVAEYE没有人真正展示过效果。
所谓插件,我的理解是应该完全融合在主程序中,除了在主程序内做必要的配置之外,不需要在主程序外的任何其他地方专门对插件做某些修改。而大概分析了一下javaeye的做法,并没有把syntaxhighlighter做为FCKeditor的完全独立插件来做,还需要依赖于手工在页面中单独添加syntaxhighlighter的CSS。
想把syntaxhighlighter做成FCKeditor的插件的想法由来已久。这周经过仔细研究,终于成功完成了一大步。第一时间推出了,让大家一起感觉FCKeditor与syntaxhighlighter双剑合壁的简单方便与巨大威力。
具体的开发需要熟悉开发FCKeditor插件,了解syntaxhighlighter的用法。在这里就不多说了,有兴趣的可以自己研究一下。
这里只简单的讲一下使用方法。
******
第一种情况:
点击这里FCKeditor_with_syntaxhighlighter.rar结合了syntaxhighlighter的FCKeditor,并带有示例页面。
解压到适应目录后,修改sample.html页面里的sBasePath变量。
  1. <script type="text/javascript">    
  2.     //注意这里,根据实际环境修改  
  3.         var sBasePath = "http://localhost/my_works/FCKeditor_with_syntaxhighlighter/FCKeditor/";    
  4.         var oFCKeditor = new FCKeditor( 'FCKeditor1' ) ;    
  5.          oFCKeditor.BasePath = sBasePath ;    
  6.         // Set the custom configurations file path (in this way the original file is mantained).    
  7.          oFCKeditor.Config['CustomConfigurationsPath'] = sBasePath + 'custom.config.js' ;    
  8.         // Let's use a custom toolbar for this sample.    
  9.          oFCKeditor.ToolbarSet    = 'custom' ;    
  10.          oFCKeditor.Value         = '' ;    
  11.          oFCKeditor.Create() ;    
  12. /script>   
点击图标,立即感受二者威力。
******
第二种情况:
点击这里highlighter.rarsyntaxhighlighter插件。
解压以后,放置在你的FCK里的plugins目录,或者其他自定义的plugin目录。
1、修改你的config文件,在ToolbarSet里加上'HighLighter'。
  1. // Set toolbar.  
  2. FCKConfig.ToolbarSets["custom"] = [  
  3.      ['HighLighter','Placeholder','DocProps','-','Save','NewPage','Preview','-','Templates'],  
  4.      ['Cut','Copy','Paste','PasteText','PasteWord','-','Print','SpellCheck'],  
  5.      ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],  
  6.      ['Form','Checkbox','Radio','TextField','Textarea','Select','Button','ImageButton','HiddenField'],  
  7.     '/',  
  8.      ['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],  
  9.      ['OrderedList','UnorderedList','-','Outdent','Indent'],  
  10.      ['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],  
  11.      ['Link','Unlink','Anchor'],  
  12.      ['Image','Flash','Table','Rule','Smiley','SpecialChar'],  
  13.     '/',  
  14.      ['Style','FontFormat','FontName','FontSize'],  
  15.      ['TextColor','BGColor'],  
  16.      ['FitWindow']  
  17. ] ;  
2、根据你指定的plugin目录,注册plugin
  1. // Change the default plugin path.  
  2. FCKConfig.PluginsPath = FCKConfig.BasePath.substr(0, FCKConfig.BasePath.length - 7) + 'editor/customPlugins' ;  
  3. //注意这里,就是调用syntaxhighlighter插件的地方  
  4. FCKConfig.Plugins.Add( 'highlighter' , 'en') ;  


(FCKeditor版本:2.3.2,syntaxhighlighter版本:1.5.1)
FCKEditor的插件开发,最好的参考地方还是官方wiki:http://wiki.fckeditor.net/
dp.syntaxhighlighter的官方下载在这里:http://code.google.com/p/syntaxhighlighter/


来源:网络
阅读:9
日期:2008-4-1

【 双击滚屏 】 【 推荐朋友 】 【 收藏 】 【 打印 】 【 关闭 】 【 字体: 】 
上一篇:“openWYSIWYG 在线编辑器插件”免费下载
下一篇:asp删除非空目录的例子

  >> 相关文章
 
  ·向上滚动代码,不间断
  ·[原创]javascript截取文本框内容
  ·javascrpt 退出灰色
  ·showModalDialog子窗口怎样向父窗口传参数
  ·javascript技巧参考(转载)
  ·javactript关闭窗体 刷新父窗体
  ·使用Javascript评估用户输入密码的强度
  ·JS中将字符串转为XML并读取对象值实例

许愿墙 | 祝福 | 汉南在线总站 | 免费电影 | BT电影下载 | 娱乐新闻网站 | 东莞信息网 | 流行购商城

授权使用:汉南在线 http://hnzx.hzwz.net/
经营许可证:陕ICP备05000109号 Powered by:汉南在线
Copyright (c) 2002-2007 汉南在线. All Rights Reserved .