首页 > 解决方案 > TYPO3:我的插件的 ckeditor 配置中标签的数据属性是条纹的

问题描述

我写了一个小插件给ckeditor添加一个按钮,这样用户就可以在编辑器中添加一个tooltip-codesnippet。这很完美。关闭对话框后,代码已正确插入。当我之后保存文本时,我的网站正在重新加载并且我的数据属性消失了。

在我的插件中,我添加了:

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'

我在使用 8.x 版的 TYPO3 上下文中。

我已经尝试将 allowedContent 更改为 extraAllowedContent。但这无济于事。我注意到,我的 yaml-config 通过允许标签 span 或 sup 工作。但不能允许属性。还尝试使用 span[ ] oder span[data- ]。没有成功。

我在这里试过这个: TYPO3: CKEditor strips data-attributes in -Tags

有没有人有同样的问题?

标签: javascriptpluginsckeditortypo3-8.xckeditor4.x

解决方案


解决方法是修改 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"

推荐阅读