CKEditor中的工具列預設顯示所有功能按鈕。出於安全的原因、或者是簡化的原因,需要對這個工具列進行自訂設定。CKEditor工具列自訂配置非常簡單。
編輯ckeditor目錄下的的config.js檔案,預設的是下面的工具列代碼,
注意工具按鈕是分組的,一個name內的大括弧就是一個工具按鈕分組,items後邊是具體的按鈕,“/”表示工具列換行,“-”表示工具表徵圖之間的中隔線“|”
(特別說明:config.js中沒有下面的代碼,預設就是顯示全部按鈕,但如果對工具列進行自訂,最好的辦法還是把下面的代碼全部複製到config.js,然後再刪除一個個不需要的按鈕)
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']];
下面是經刪除過後的工具條代碼
config.toolbar = 'Full'; config.toolbar_Full = [ {name: 'document',items: ['Source', '-', 'DocProps', 'Preview', 'Print', '-']}, {name: 'clipboard',items: ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo']}, {name: 'editing',items: ['Find', 'Replace', '-', 'SelectAll', '-']}, { 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']}, '/', { name: 'styles',items: ['Styles', 'Format', 'Font', 'FontSize']}, { name: 'colors',items: ['TextColor', 'BGColor']}, { name: 'tools',items: [ 'ShowBlocks', '-']} ]; config.toolbar_Basic = [['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink', '-', 'About']];
工具列的定義英漢對照說明:
Source = 源碼模式
-
Save = 儲存(提交表單)
NewPage = 建立
Preview = 預覽
- = 分割線
Templates = 模板
Cut = 剪下
Copy = 複製
Paste = 粘貼
PasteText = 粘貼為無格式文本
PasteFromWord = 從 MS WORD 粘貼
-
Print = 列印
SpellChecker = 拼字檢查
Scayt = 即時拼字檢查
Undo = 撤銷
Redo = 重做
-
Find = 尋找
Replace = 替換
-
SelectAll = 全選
RemoveFormat = 清除格式
Form = 表單
Checkbox = 複選框
Radio = 單選框
TextField = 單行文本
Textarea = 多行文本
Select = 列表/菜單
Button = 按鈕
ImageButton = 圖片按鈕
HiddenField = 隱藏欄位
/
Bold = 加粗
Italic = 傾斜
Underline = 底線
Strike = 刪除線
-
Subscript = 下標
Superscript = 上標
NumberedList = 編號清單
BulletedList = 項目列表
-
Outdent = 減少縮排量
Indent = 增加縮排量
Blockquote = 區塊引述
CreateDiv = 建立DIV容器
JustifyLeft = 靠左對齊
JustifyCenter = 置中
JustifyRight = 靠右對齊
JustifyBlock = 左右對齊
BidiLtr = 文字方向從左至右
BidiRtl = 文字方向從右至左
Link = 插入/編輯超連結(上傳檔案)
Unlink = 取消超連結
Anchor = 插入/編輯錨點連結
Image = 映像(上傳)
Flash = 動畫(上傳)
Table = 表格
HorizontalRule = 插入水平線
Smiley = 插入表情
SpecialChar = 插入特殊符號
PageBreak = 插入分頁符
/
Styles = 樣式捷徑
Format = 文字格式設定
Font = 字型
FontSize = 文字大小
TextColor = 文字顏色
BGColor = 背景顏色
Maximize = 全屏編輯模式
ShowBlocks = 顯示區塊
-
About = 顯示關於