电竞比分网-中国电竞赛事及体育赛事平台

分享

CKEditor工具欄自定義配置

CKEditor中的工具欄默認(rèn)顯示所有功能按鈕。出于安全的原因、或者是簡(jiǎn)化的原因,需要對(duì)這個(gè)工具欄進(jìn)行自定義設(shè)置。CKEditor工具欄自定義配置非常簡(jiǎn)單,按下述步驟完成即可(假設(shè)已經(jīng)完成CKEditor的安裝):

編輯ckeditor目錄下的的config.js文件,默認(rèn)的是下面的工具欄代碼(特別說(shuō)明:config.js中沒(méi)有下面的代碼,默認(rèn)就是顯示全部按鈕,但如果對(duì)工具欄進(jìn)行自定義,最好的辦法還是把該代碼全部復(fù)制粘貼,然后再刪除一個(gè)個(gè)不需要的按鈕)

config.toolbar = 'Full';
 
config.toolbar_Full =
[
        { name: 'document', items : [ 'Source','-','Save','NewPage','DocProps','Preview','Print','-','Templates' ] },
        { name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
        { name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','SpellChecker', 'Scayt' ] },
        { name: 'forms', items : [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 
        'HiddenField' ] },
        '/',
        { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] },
        { name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv',
        '-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] },
        { name: 'links', items : [ 'Link','Unlink','Anchor' ] },
        { name: 'insert', items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe' ] },
        '/',
        { name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] },
        { name: 'colors', items : [ 'TextColor','BGColor' ] },
        { name: 'tools', items : [ 'Maximize', 'ShowBlocks','-','About' ] }
];
 
config.toolbar_Basic =
[
        ['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink','-','About']
];
    注意工具按鈕是分組的,一個(gè)name內(nèi)的大括號(hào)就是一個(gè)工具按鈕分組,items后邊是具體的按鈕,我們可以對(duì)這些內(nèi)容進(jìn)行適當(dāng)?shù)膭h除。比如將config.js做成如下的內(nèi)容:
CKEDITOR.editorConfig = function( config )
{
        config.toolbar = 'MyToolbar';
 
        config.toolbar_MyToolbar =
        [
                { name: 'document', items : [ 'Source','NewPage','Preview' ] },
            { name: 'basicstyles', items : [ 'Bold','Italic','Strike','-','RemoveFormat' ] },
            { name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
                { name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','Scayt' ] },
                '/',
                { name: 'styles', items : [ 'Styles','Format' ] },
                { name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote' ] },
            { name: 'insert', items :[ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'
                 ,'Iframe' ] },
                { name: 'links', items : [ 'Link','Unlink','Anchor' ] },
                { name: 'tools', items : [ 'Maximize','-','About' ] }
        ];
};
 
    上代碼創(chuàng)建的CKEditor工具欄就如下圖所示:
wusir <wbr>CKEditor工具欄自定義配置




   工具欄的定義英漢對(duì)照說(shuō)明:

Source = 源碼模式
-
Save = 保存(提交表單)
NewPage = 新建
Preview = 預(yù)覽
- = 分割線
Templates = 模板
Cut = 剪切
Copy = 復(fù)制
Paste = 粘貼
PasteText = 粘貼為無(wú)格式文本
PasteFromWord = 從 MS WORD 粘貼
-
Print = 打印
SpellChecker = 拼寫檢查
Scayt = 即時(shí)拼寫檢查
Undo = 撤銷
Redo = 重做
-
Find = 查找
Replace = 替換
-
SelectAll = 全選
RemoveFormat = 清除格式
Form = 表單
Checkbox = 復(fù)選框
Radio = 單選框
TextField = 單行文本
Textarea = 多行文本
Select = 列表/菜單
Button = 按鈕
ImageButton = 圖片按鈕
HiddenField = 隱藏域
/
Bold = 加粗
Italic = 傾斜
Underline = 下劃線
Strike = 刪除線
-
Subscript = 下標(biāo)
Superscript = 上標(biāo)
NumberedList = 編號(hào)列表
BulletedList = 項(xiàng)目列表
-
Outdent = 減少縮進(jìn)量
Indent = 增加縮進(jìn)量
Blockquote = 塊引用
CreateDiv = 創(chuàng)建DIV容器
JustifyLeft = 左對(duì)齊
JustifyCenter = 居中
JustifyRight = 右對(duì)齊
JustifyBlock = 兩端對(duì)齊
BidiLtr = 文字方向從左到右
BidiRtl = 文字方向從右到左
Link = 插入/編輯超鏈接(上傳文件)
Unlink = 取消超鏈接
Anchor = 插入/編輯錨點(diǎn)鏈接
Image = 圖像(上傳)
Flash = 動(dòng)畫(上傳)
Table = 表格
HorizontalRule = 插入水平線
Smiley = 插入表情
SpecialChar = 插入特殊符號(hào)
PageBreak = 插入分頁(yè)符
/
Styles = 樣式快捷方式
Format = 文本格式
Font = 字體
FontSize = 文字大小
TextColor = 文字顏色
BGColor = 背景顏色
Maximize = 全屏編輯模式
ShowBlocks = 顯示區(qū)塊
-
About = 顯示關(guān)于

   本文參照了CKEditor官網(wǎng)相關(guān)幫助文件,地址為http://docs./CKEditor_3.x/Developers_Guide/Toolbar 

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多