TYPO3: Data-attributes of tags in ckeditor configuration of my plugin are striped

陌路散爱 提交于 2019-12-13 03:10:14

问题


I wrote a small plugin to add a button to ckeditor, so that the user can add a tooltip-codesnippet into the editor. This works perfect. After closing the dialog the code is correctly inserted. When I save afterward the text my site is reloading and my data-attributes are gone.

In my plugin I added:

CKEDITOR.plugins.add('tooltip', {
        lang: [ 'en', 'de'],
        init: function (editor) {
            editor.addCommand('tooltip', new CKEDITOR.dialogCommand('tooltip', {
        allowedContent: 'span[data-hint-content]; sup'
            }));

And also in my used yaml-config I added:

editor:
  config:
    allowedContent: 'span[data-*](*){*}; sup'

I'm in a TYPO3 context with Version 8.x.

I already tried to change allowedContent to extraAllowedContent. But this doesn't help. I noticed, that my yaml-config is working by allowing the tags span or sup. But cannot allow the attributes. Also tried to use span[] oder span[data-]. No success.

I eather tried this here: TYPO3: CKEditor strips data-attributes in -Tags

Does anybody had equal problems?


回答1:


The solution is to modify the config of the HTMLparser_db. Just add the following code to the 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"


来源:https://stackoverflow.com/questions/58624514/typo3-data-attributes-of-tags-in-ckeditor-configuration-of-my-plugin-are-stripe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!