问题
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