CKEditor删除<span>带有类的自定义



我的网站上有一个表格,管理员可以在其中编辑注册表上显示的合同。 表格中很少有动态字段 在注册表格的第一页上有名字,正在注册的人的姓氏。我想得到他的名字,并用合同中规定的template_field_name代替。这是我正在尝试做的事情的示例

<p>contactor: <span class="template_name">template_name</span></p>

稍后,当页面在注册表单上呈现时,我将查找template_name类,并将文本替换为 jQuery 从注册表第一页的"名字"和"姓氏"字段中获得的值。 但是当管理员稍后进行一些更改以收缩它时,只需消除带有类名的 span 标记

<p>contactor:template_name</p>

并按上述方式输出template_name。我对这个问题感到厌倦,并多次尝试解决这个问题。

任何帮助将不胜感激。

可能是您在 CKEditor 的高级内容过滤 (ACF( 中的问题。

尝试设置配置选项以允许所有内容:

config.allowedContent = true;

看看它是否适合你。如果是,请将config.allowedContent替换为:

config.extraAllowedContent = 'span(template_name)';

这将允许类template_name span 标记。

有关ACF的更多信息,请点击此处 - https://docs.ckeditor.com/ckeditor4/docs/#!/guide/dev_acf

要添加允许的乘法类,您可以指定它们,以逗号分隔:

config.extraAllowedContent = 'span(template_name,another_class,one_more_class)';

或者,您可以允许每个类使用 span 标记,如下所示:

config.extraAllowedContent = 'span(*)';

如果字段由不同的标签表示 - 您需要用空格分隔它们

config.extraAllowedContent = 'span(template_name) p(another_template_name)';

最新更新