源码网,源码论坛,源码之家,商业源码,游戏源码下载,discuz插件,棋牌源码下载,精品源码论坛

 找回密码
 立即注册
查看: 729|回复: 17

[网页编辑器] FCKeditor 和 SyntaxHighlighter 代码高亮插件的整合

[复制链接]

7万

主题

861

回帖

32万

积分

论坛元老

Rank: 8Rank: 8

积分
329525
发表于 2010-4-25 20:29:20 | 显示全部楼层 |阅读模式
FCKeditor 和 SyntaxHighlighter 代码高亮插件的整合方法,里面有下载,可以根据需要结合自己的fckeditor版本。
        
        
            
Introduction(简介)
This is a dialog-based plugin to handle formatting of source code for FCKeditor 2.5.x. It WON'T work with the new CKEditor (yet).(CKEditor 是FCKEditor 的升级版,不过,SyntaxHighlighter 还不能在 CKEditor 中实现代码高亮) It makes use of the SyntaxHighlighter 2.0.x javascript library available to download from Alex Gorbatchev's project page (the older version 1.5.1 version is available from Google Code).
The plugin primiarily edits a tag with some custom attributes. Its mainly aimed at users editing blogs or content management systems where there is a requirement to format programming languages on a website that is being edited using FCKEditor.
The plugin will not format the code in FCKEditor - the SyntaxHighlighter javascript library dynamically generates a lot of formatted HTML at runtime, which would cause problems in FCKEditor.
Skip straight to the good bits
Can't be bothered reading all this? View the online demo or download the plugin and go play with it yourself.
So what do I get then?
Correctly installed, the plugin is in the form of a tabbed dialogue box that looks like this:(插件安装好以后的效果)

Version history:(版本历史)
Huge thanks goes to Sergey Gurevich who wrote the updated code for the FCKEditor plugin to handle the latest version of the SyntaxHighlighter code and submitted useful bug fixes.
[U]
  • v2.1.0 [23 May 2009]
    - Plugin version information now being displayed
    - Line highlighting feature added
    Download | Demo
      
  • v2.0.1 [22 March 2009]
    Minor bug fix where semi-colons were sometimes positioned in the wrong place when no advanced options were selected
    Download
      
  • v2.0 [2 March 2009]
    Latest version supporting SyntaxHighlighter 2.0.x
      
  • v1.0.2 [2 March 2009]
    Bug fixes, final release supporting the older SyntaxHighlighter 1.5.1
    Note the instructions below are for the newer version of the library and makes references to syntaxhighlight2 a lot, this version uses syntaxhighlight. The documentation in the download will be more accurate.
    Download.| Demo
      
  • v1.0.1 [10 Feb 2009].
      
  • v1.0 [30 Nov 2008]. First version. [/U]
    Known bugs:
    Occasionally the dialogue box does not pickup the  element to be edited in Firefox. It only seems to happen when a user clicks inside the  tag with the mouse but doesn't actually move or interact with the cursor.
    Fixed in version 1.0.2 - Thanks to Sergey Gurevich
    Installation(安装配置过程)
    1. Copying the files(拷贝文件)
    Extract the contents of the zip in your plugins directory, so it ends up like this:(基本的目录结构如下)

    Note: Version 2 of the plugin must be extracted to a directory named 'syntaxhighlighter2'. The older plugin for the earlier version of the library must go in a folder named 'syntaxhighlighter'. The file fckplugin.js references this directory when the plugin initialises.(注意这里的命名)
    2. Adding it to FCKeditor(将它添加到 FCKeditor)
    Now add in your fckconfig.js or custom js configuration file the following line (remember its javascript we are dealing with so everything is case sensitive!):
    1.FCKConfig.Plugins.Add( 'syntaxhighlight2', 'en') ;
    3. Adding it to the toolbarset
    Add the button 'SyntaxHighLight2' button to your toolbarset:
    1.FCKConfig.ToolbarSets["Basic"] = [
    2.['Bold','Italic','-','OrderedList','UnorderedList','-','Link','Unlink', '-','SyntaxHighLight2','-','About']
    3.] ;
    4. Configure the plugin
    The plugin will work 'out of the box', but you can configure a default language using the SyntaxHighlight2LangDefault parameter:
    1.FCKConfig.SyntaxHighlight2LangDefault = 'csharp' ;
    The full list of languages and corresponding codes are:
    [U]
  •   
    [U]
  • c++ - C++
  • csharp - C#
  • css - CSS
  • delphi - Delphi
  • java - Java
  • jscript - Java Script
  • php - PHP
  • python - Python
  • ruby - Ruby
  • sql - SQL
  • vb - VB.NET
  • xhtml - XML/HTML [/U][/U]
    In FCKEditor blocks aren't really formatted by default. I suggest editing your fck_editorarea.css (or equivalant if you are using a custom CSS file) to something that highlights code blocks better. eg:
    01.pre
    02.{
    03.    background-color: #fff;
    04.    font-family: "Consolas" , "Courier New" ,Courier,mono,serif;
    05.    font-size: 12px;
    06.    color: blue;
    07.    padding: 5px;
    08.    border: 1px dashed blue;
    09.}
    Configuring SyntaxHighlighter.
    You must have SyntaxHighlighter installed and working to display properly formatted code. FCKEditor does not need it, but for code to be properly formatted on your website you must have it configurated correctly. For SyntaxHighlighter2 Alex Gorbatchev's site has loads of excellent information (he wrote it after all!), for the old version 1.5.1 library, the project wiki here is a good resouce, or this blog post might also be useful.
    5. Use it
    Now clear your browser cache (this stage is important!) and reload the editor, the new button

    should be ready to use.
    6. Future updates
    There's some additional functionality I might add at a later date:
    [U]
  • Preview tab using the SyntaxHighlighter library
  • More configuration options, eg, available languages, path to SyntaxHighlighter files
  • Dynamically adding a formatting style to the editor by default [/U]
    7. And finally...
    Thanks goes to Alex Gorbatchev for creating Syntax Highlighter!.
    脚本之家打包下载地址:
    /201004/yuanma/FCKEditor-syntaxhighlight.rar
  • 回复

    使用道具 举报

    0

    主题

    2万

    回帖

    0

    积分

    中级会员

    Rank: 3Rank: 3

    积分
    0
    发表于 2023-8-22 07:09:28 | 显示全部楼层
    老衲笑纳了
    回复 支持 反对

    使用道具 举报

    1

    主题

    2万

    回帖

    319

    积分

    中级会员

    Rank: 3Rank: 3

    积分
    319
    发表于 2023-8-24 12:29:59 | 显示全部楼层
    看看看看
    回复 支持 反对

    使用道具 举报

    12

    主题

    2万

    回帖

    431

    积分

    中级会员

    Rank: 3Rank: 3

    积分
    431
    发表于 2023-10-18 08:09:32 | 显示全部楼层
    我要金豆金豆金豆
    回复 支持 反对

    使用道具 举报

    3

    主题

    2万

    回帖

    172

    积分

    注册会员

    Rank: 2

    积分
    172
    发表于 2023-10-28 00:16:12 | 显示全部楼层
    借款金额看了就立刻
    回复 支持 反对

    使用道具 举报

    4

    主题

    2万

    回帖

    303

    积分

    中级会员

    Rank: 3Rank: 3

    积分
    303
    发表于 2024-1-21 17:28:52 | 显示全部楼层
    8888888888888888
    回复 支持 反对

    使用道具 举报

    0

    主题

    2万

    回帖

    0

    积分

    中级会员

    Rank: 3Rank: 3

    积分
    0
    发表于 2024-4-26 22:34:48 | 显示全部楼层
    建军节建军节建军节建军节
    回复 支持 反对

    使用道具 举报

    3

    主题

    2万

    回帖

    50

    积分

    注册会员

    Rank: 2

    积分
    50
    发表于 2024-6-22 11:58:37 | 显示全部楼层
    论坛有你更精彩!
    回复 支持 反对

    使用道具 举报

    2

    主题

    2万

    回帖

    381

    积分

    中级会员

    Rank: 3Rank: 3

    积分
    381
    发表于 2024-9-7 13:55:22 | 显示全部楼层
    看看看咋么
    回复 支持 反对

    使用道具 举报

    0

    主题

    2万

    回帖

    0

    积分

    中级会员

    Rank: 3Rank: 3

    积分
    0
    发表于 2024-9-8 18:18:46 | 显示全部楼层
    谢谢分享,先下来用用
    回复 支持 反对

    使用道具 举报

    高级模式
    B Color Image Link Quote Code Smilies

    本版积分规则

    手机版|小黑屋|网站地图|源码论坛 ( 海外版 )

    GMT+8, 2024-11-22 17:53 , Processed in 0.276577 second(s), 26 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表