2013-05-04 81 views
0

我的cms我想用bootstrap-styles編輯內容。當我編輯ckeditor中的源代碼並添加類屬性時,它會通過切換到wysiwyg模式而被剝離。允許twitterbootstrap class-attributes在ckeditor中的span和p標籤

<p class="lead">bla</p> => <p>bla</p> 

從文檔我無法找到一種方法來允許具有任何值的類屬性p標籤。

我的配置非常默認:

CKEDITOR.editorConfig = (config) -> 
    config.language = 'de' 
    config.contentsCss = '/assets/front/application.css' 
    config.format_div = { element : 'div', attributes : {'data-no-turbolink' : 'true'}} 

    config.toolbar_Pure = [ 
    { 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: 'tools',  items: [ 'Maximize', 'ShowBlocks','-','About' ] } 
    '/', 
    { 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: 'styles',  items: [ 'Styles','Format','Font','FontSize' ] }, 
    { name: 'colors',  items: [ 'TextColor','BGColor' ] }, 
    { name: 'insert',  items: [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak' ] }, 
    ] 
    config.toolbar = 'Pure' 
    true 

回答

1

您需要添加所有或選定類允許的內容。

// Allow all classes for all allowed elements. 
config.extraAllowedContent = '*(*)'; 

// Or allow class1 and class2 for listed block elements and class3 for listed inline ones. 
config.extraAllowedContent = 'p,h1,h2,h3(class1,class2); img,strong,em(class3)'; 

瞭解更多關於高級內容在這裏過濾:Advanced Content Filter guide

+0

我可以添加樣式屬性的span-tags。如果我在stlye屬性中添加行高,它會被剝離。我在哪裏配置CSS樣式規則? – toy 2013-05-07 10:41:40

+0

請參閱[允許的內容規則指南](http://docs.ckeditor.com/#!/guide/dev_allowed_content_rules)。 – Reinmar 2013-05-07 10:51:40