dedecms自带CKEditor编辑添加行间距按钮

来源:互联网 发布:直播系统源码 编辑:程序博客网 时间:2024/05/01 07:27
由于dedecms将ckeditor做了集成,和一般的只针对于ckeditor对config.js修改不同,以后是我在dedecms 5.7版本上添加行间距按钮的方法:
1、下载ckeditor的行距插件包 ;
2.解压到ckeditor/plugins目录下;
3、由于dedecms 5.7自己集成了一个dedepage插件,用来添加ckeditor自定义插件,在/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'] 的最后一行添加元素Code,修改后代码如下:

$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')
        );

至此OK!

ps,简单的自定义行距功能

1.修改该功能的语言,在lineheight(就是行距插件的目录)/lang目录下添加相应的语言包,修改plugin.js文件115行为相应的语言。

2.更改行距的功能按钮,修改plugin.js文件139行。

0 0
原创粉丝点击