本文使用的版本是3.0.83版,下载后只需要syntaxhighlighter文件夹下的“scripts”和“styles”文件夹内的文件,在代码语法着色高亮显示的页面引用“styles/shCore.css”样式文件,“scripts/shCore.js”JS文件,因为每一种代码语言都要引用各自的JS文件,为了降低HTTP请求,把所有代码语言的JS文件内容都放到一个“scripts/sh
<link rel="stylesheet" ty
PE="text/css"
href="/syntaxhighlighter/styles/shCo
redefault.css" />
<script language="javascript" type="text/javascript" src="/syntaxhighlighter/scripts/shCore.js"></script>
<script language="javascript" type="text/javascript" src="/syntaxhighlighter/scripts/shBrushSeaYee.js"></script>
CKEDITOR.plugins.add('insertcode',
{
init: function(editor)
{
//plugin code goes here
VAR pluginN
ame = 'Insertcode';
CKEDITOR.dia
LOG.add(pluginName, this.path + 'insertcode.js');
editor.
config.flv_path = editor.config.flv_path || (this.path);
editor.addCommand(pluginName, new CKEDITOR.dialogCommand(pluginName));
editor.ui.addButton('Insertcode',
{
label: '插入代码',
command: pluginName,
icon: this.path + 'insertcode.gif'
});
}
});
CKEDITOR.dialog.add('Insertcode', function(editor){
var escape = function(value){return value;};
return{
title: '插入代码',
resizable: CKEDITOR.DIALOG_RESIZE_BOTH,
minWidth: 720,
minH
eight: 520,
contents: [{
id: 'cb',
name: 'cb',
label: 'cb',
title: 'cb',
elements: [{
type: 'select',
label: 'Language',
id: 'lang',
required: true,
'default': '
csharp',
items: [['ActionScript3', 'as3'], ['Bash/shell', 'bash'], ['Col
DFusion', '
CF'], ['C
#', 'csharp'], ['C++', 'cpp'], ['CSS', 'css'], ['Delphi', 'delphi'], ['Diff', 'diff'], ['Groovy', 'groovy'], ['JavaScript', 'js'], ['Java', 'java'], ['JavaFX', 'jfx'], ['Perl', 'perl'], ['PHP', 'php'], ['Pl
ain Text', 'plain'], ['PowerShell', 'ps'], ['Python', 'py'], ['R
uby', 'rails'], ['Scala', 'scala'], ['
SQL', 'sql'], ['
Visual Basic', '
vb'], ['
XML', 'x
ML']]
}, {
type: 'textarea',
style: 'width:718px;height:450px',
label: 'Code',
id: 'code',
rows: 31,
'default': ''
}]
}],
onOk: function(){
code = this.getValueOf('cb', 'code');
lang = this.getValueOf('cb', 'lang');
html = '' + escape(code) + '';
editor.insertHtml("<
PRe class=\"brush:" + lang + ";\">" + html + "</pre>");
},
onLoad: function(){}
};
});
要在CKEditor工具栏添加按钮就在此配置文件中添加上“,Insertcode”,依然要注意区分大小写字母。至此就大功造成了。