我写了一个小插件,为ckeditor添加了一个按钮,以便用户可以在编辑器中添加一个工具提示代码片段。这很完美。关闭对话框后,代码已正确插入。当我之后保存文本时,我的网站正在重新加载,并且我的数据属性都消失了。
在我的插件中,我添加了:
CKEDITOR.plugins.add('tooltip', {
lang: [ 'en', 'de'],
init: function (editor) {
editor.addCommand('tooltip', new CKEDITOR.dialogCommand('tooltip', {
allowedContent: 'span[data-hint-content]; sup'
}));
而且还在我使用的yaml-config中添加:
editor:
config:
allowedContent: 'span[data-*](*){*}; sup'
我在TYPO3上下文中使用8.x版。
我已经尝试将allowedContent更改为extraAllowedContent。但这无济于事。我注意到,我的yaml-config通过允许跨度或跨度标记起作用。但是不能允许属性。还尝试使用span [] oder span [data-]。没有成功。
我在这里尝试过:TYPO3: CKEditor strips data-attributes in -Tags
有人遇到同样的问题吗?
解决方案是修改HTMLparser_db的配置。只需将以下代码添加到yaml-config中即可:
processing:
HTMLparser_db:
tags:
span:
allowedAttribs: "class, id, title, dir, lang, xml:lang, itemscope, itemtype, itemprop, data-target, data-toggle, data-hint-content"