允许在ckeditor中的span和p标签上的twitterbootstrap类属性

时间:2013-05-04 13:17:14

标签: twitter-bootstrap ckeditor

对于我的cms我想用bootstrap-styles编辑内容。当我在ckeditor中编辑源代码并添加类属性时,它会被切换到wysiwyg-mode而被剥离。

<p class="lead">bla</p>   =>   <p>bla</p> 
从文档

我找不到一种方法来允许带有任何p-tags值的类属性。

我的配置非常默认:

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 个答案:

答案 0 :(得分: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