1. 程式人生 > >dedecms自帶ckeditor編輯新增行間距按鈕

dedecms自帶ckeditor編輯新增行間距按鈕

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

這樣就可以實現新增行距按鈕的功能了!