【问题标题】:CKEditor Configuration, why it remove id in span attribute?CKEditor 配置,为什么要删除 span 属性中的 id?
【发布时间】:2017-02-07 12:19:22
【问题描述】:

我的 ckeditor 有这样的配置:config.allowedContent = true

如果我将此代码插入我的编辑器:

<div class="col-xs-12">
 <input type="text" name="LastName" class="form-control" id="LastName">
        <div class="help-block animated fadeInDown">
        <span id="errLastNameMsg"></span>
       </div>
    </div>

this is a simple id <span id="errLastNameMsg"></span> with span content.

After Ckeditor compile it is.
 <div class="col-xs-12"><input class="form-control" id="LastName" 
    name="LastName" type="text" /> 
    <div class="help-block animated fadeInDown">&nbsp;</div>
    </div>


It Strip <span id="errLastNameMsg"></span> with &nbsp;

thanks in advance for your's solution.

【问题讨论】:

  • 试试config.extraAllowedContent = '*[id]';。禁用所有过滤器不是一个好主意
  • private CkeditorConfig = { allowedContent: true, extraAllowedContent:'*[id]', protectedSource:/]*>/g } 我也用过,但可以对我没有帮助。
  • 尝试添加一个  进入 span ,我认为 span 被删除了,因为它是空的

标签: javascript html drupal ckeditor


【解决方案1】:

CKEditor 有一个选项可以在为空时忽略元素:CKEDITOR.dtd.$removeEmpty

默认情况下,空的 span 元素会被移除。

使用它来允许空的 span 元素:

CKEDITOR.dtd.$removeEmpty.span = 0;

【讨论】:

    猜你喜欢
    • 2013-08-23
    • 2015-05-16
    • 1970-01-01
    • 1970-01-01
    • 2011-04-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多