1.下载ckeditor的行距插件包(https://files.cnblogs.com/files/ysfng/ckeditor-lineheight.zip);
2.解压到ckeditor/plugins目录下;3.在/include/ckeditor/plugins/dedepage文件夹下,打开plugin.js文件在最后面添加:requires : [ 'lineheight' ],添加完之后的代码如下:
// Register a plugin named "dedepage".
(function()
{
CKEDITOR.plugins.add( 'dedepage',
{
init : function( editor )
{
// Register the command.
editor.addCommand( 'dedepage',{
exec : function( editor )
{
// Create the element that represents a print break.
// alert('dedepageCmd!');
editor.insertHtml("#p#副标题#e#");
}
});
// alert('dedepage!');
// Register the toolbar button.
editor.ui.addButton( 'MyPage',
{
label : '插入分页符',
command : 'dedepage',
icon: 'images/dedepage.gif'
});
// alert(editor.name);
},
requires : [ 'fakeobjects' ],
requires : [ 'lineheight' ]
});
})();
4.修改/include/ckeditor/ckeditor.inc.php文件,在$toolbar['Basic'] 的最后一行添加元素array( 'lineheight'),修改后代码如下:
$toolbar['Basic'] = array(
array( 'Source','-','Templates'),
array( 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Print'),
array( 'Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'),
array( 'ShowBlocks'),array('Image','Flash','Addon'),array('Maximize'),'/',
array( 'Bold','Italic','Underline','Strike','-'),
array( 'NumberedList','BulletedList','-','Outdent','Indent','Blockquote'),
array( 'JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'),
array( 'Table','HorizontalRule','Smiley','SpecialChar'),
array( 'Link','Unlink','Anchor'),'/',
array( 'Styles','Format','Font','FontSize'),
array( 'TextColor', 'BGColor', 'MyPage','MultiPic'),
array( 'lineheight')
);
添加行距至此就已经完成了,若还是没有添加成功,则需要对\ckeditor\config.js文件进行修改,即添加行距插件:
config.extraPlugins += (config.extraPlugins ?',lineheight' :'lineheight');
这样就可以实现添加行距按钮的功能了!