2014/10/08

[CKEditor]幾個常用編輯器設置(config.js)

為了方便尋找與使用,特地整理出來,日後還會再增加,目前大致上就這些吧

編輯器字型大小,預設為12px
config.fontSize_defaultLabel = '12px';

編輯器字體,預設字型為Arial
config.font_defaultLabel = 'Arial';

編輯器高度,預設200pixels,不支援百分比(%)
config.height = 500; // 500 pixels.
config.height = '25em'; // CSS length.
config.height = '300px'; // CSS length.

編輯器寬度,預設是空字串
config.width = 850; // 850 pixels wide.
config.width = '75%'; // CSS unit.

編輯器的工具列,下方為預設的工具
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' ] },
    '/',
    { name: 'styles',      items : [ 'Styles','Format','Font','FontSize' ] },
    { name: 'colors',      items : [ 'TextColor','BGColor' ] },
    { name: 'tools',       items : [ 'Maximize', 'ShowBlocks','-','About' ] }
];

編輯器可用字體設定
CKEDITOR.config.font_names =
'Arial/Arial, Helvetica, sans-serif;' +
'Comic Sans MS/Comic Sans MS, cursive;' +
'Courier New/Courier New, Courier, monospace;' +
'Georgia/Georgia, serif;' +
'Lucida Sans Unicode/Lucida Sans Unicode, Lucida Grande, sans-serif;' +
'Tahoma/Tahoma, Geneva, sans-serif;' +
'Times New Roman/Times New Roman, Times, serif;' +
'Trebuchet MS/Trebuchet MS, Helvetica, sans-serif;' +
'Verdana/Verdana, Geneva, sans-serif';

編輯器換行的HTML標籤,預設是<p>
config.enterMode = CKEDITOR.ENTER_P

CKEDITOR.ENTER_P (1) – new <p> paragraphs are created;
CKEDITOR.ENTER_BR (2) – lines are broken with <br> elements;
CKEDITOR.ENTER_DIV (3) – new <div> blocks are created.

參考:
CKEditor 3 JavaScript API Documentation
http://docs.cksource.com/ckeditor_api/index.html

沒有留言:

張貼留言