以下为我实现的步骤:
一、
首先说明下,要想把ckeditor里的分页符源码改为得简单些,是在是太难了,可能是我对js不熟悉吧,所以就自己添加插件按钮来插入分页符:
1.
在ckeditor的plugins目录新建文件夹nextpage,在nextpage下新建文件:plugin.js 内容如下:
(function(){
var a= {
exec:function(editor)
{
editor.insertHtml("[[page]]");
}
},
b="nextpage";
CKEDITOR.plugins.add(b,{
init:function(editor){
editor.addCommand(b,a);
editor.ui.addButton("nextpage",{
label:"nextpage",
icon: this.path + "nextpage.gif",
command:b
});
}
});
})();
还要在文件夹nextpage下,添加一个图标nextpage.gif大小差不多是16*16的
2.
在toolbar中加一项nextpage,并在配置中声明添加扩展插件 config.extraPlugins = ‘nextpage’; 有两种方法实现,方法一是直接在config.js中添加;方法二:在引用CKEditor的地方加配置参
数,我是用方法一配置的:
CKEDITOR.editorConfig = function( config )
{
config.font_names = '宋体/宋体;黑体/黑体;仿宋/仿宋_GB2312;楷体/楷体_GB2312;隶书/隶书;幼圆/幼圆;雅黑/雅黑;'+ config.font_names ;
config.language = 'zh-cn';
config.skin = 'v2';
config.width = 650;
config.height = 300;
config.removePlugins = 'elementspath';
config.extraPlugins = "nextpage";//新建插件
config.toolbar=
[
['Source','unlink','-','Save','unlink','Preview','-','Templates'],
['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print','SpellChecker','Scayt'],
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
'/',
['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
['Link','Unlink','Anchor'],
['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar',
'PageBreak','nextpage,
//我的按钮
'/',
['Styles','Format','Font','FontSize'],
['TextColor','BGColor'],
['Maximize','ShowBlocks','-','About','-']
">;
};
这样就在ckeditor编辑器里添加了一个nextpage按钮插件,在文章需要分页的地方按下这个按钮,就会在文章中添加一个[[page]]代码。要看到效果,需要把网站的历史浏览记录多清空,刷新几次就可以看到有一个新按钮了。