转:dedecms自带ckeditor编辑添加行间距按钮

1.下载ckeditor的行距插件包(https://files-cdn.cnblogs.com/files/fudanchencds/ckeditor-lineheight.zip);

2.解压到ckeditor/plugins目录下;
3.在/include/ckeditor/plugins/dedepage文件夹下,打开plugin.js文件在最后面添加:requires : [ 'lineheight' ],添加完之后的代码如下:

 1 // Register a plugin named "dedepage".
 2 (function()
 3 {
 4     CKEDITOR.plugins.add( 'dedepage',
 5     {
 6         init : function( editor )
 7         {
 8             // Register the command.
 9             editor.addCommand( 'dedepage',{
10                 exec : function( editor )
11                 {
12                     // Create the element that represents a print break.
13                     // alert('dedepageCmd!');
14                     editor.insertHtml("#p#副标题#e#");
15                 }
16             });
17             // alert('dedepage!');
18             // Register the toolbar button.
19             editor.ui.addButton( 'MyPage',
20             {
21                 label : '插入分页符',
22                 command : 'dedepage',
23                 icon: 'images/dedepage.gif'
24             });
25             // alert(editor.name);
26         },
27         requires : [ 'fakeobjects' ],
28  requires : [ 'lineheight' ]
29     });
30 })();

4.修改/include/ckeditor/ckeditor.inc.php文件,在$toolbar['Basic'] 的最后一行添加元素array( 'lineheight'),修改后代码如下:

 1 $toolbar['Basic'] = array(
 2             array( 'Source','-','Templates'),
 3             array( 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Print'),
 4             array( 'Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'),
 5             array( 'ShowBlocks'),array('Image','Flash','Addon'),array('Maximize'),'/',
 6             array( 'Bold','Italic','Underline','Strike','-'),
 7             array( 'NumberedList','BulletedList','-','Outdent','Indent','Blockquote'),
 8             array( 'JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'),
 9             array( 'Table','HorizontalRule','Smiley','SpecialChar'),
10             array( 'Link','Unlink','Anchor'),'/',
11             array( 'Styles','Format','Font','FontSize'),
12             array( 'TextColor', 'BGColor', 'MyPage','MultiPic'),
13             array( 'lineheight')
14         );

添加行距至此就已经完成了,若还是没有添加成功,则需要对\ckeditor\config.js文件进行修改,即添加行距插件:

1 config.extraPlugins += (config.extraPlugins ?',lineheight' :'lineheight');

这样就可以实现添加行距按钮的功能了!

 

 

转载自:https://blog.csdn.net/sunshine_csj/article/details/80578368

你可能感兴趣的:(转:dedecms自带ckeditor编辑添加行间距按钮)