0

对于我的 cms,我想使用引导样式编辑内容。当我在 ckeditor 中编辑源代码并添加类属性时,它会通过切换到所见即所得模式而被剥离。

<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 
4

1 回答 1

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)';

在此处阅读有关高级内容过滤器的更多信息:高级内容过滤器指南

于 2013-05-05T18:36:38.267 回答