我尝试将data-attribute保存在span标记中。保存后,它将被删除。我在我的自定义yaml文件中尝试了以下配置。
processing.allowAttributes:
-'span[data]'
processing.allowTags:
-span
editor.config.extraAllowedContent: "*(*)[data-*]"什么都没有用。问题出在哪里?
发布于 2020-04-08 06:39:59
要允许将数据属性从RTE字段保存到数据库,您需要确保:
1) RTE (CKEditor)不会剥离属性。这可以使用extraAllowedContent进行配置。下面是一个示例,说明如何将id属性添加到允许数据属性和类的默认规则中。
editor:
config:
extraAllowedContent:
- "*(*)[data-*]"
- "*[id]"如果您只需要添加数据属性,则不需要上面的配置,可以使用默认配置(来自rte_ckeditor/Configuration/RTE/Editor/Base.yaml),),因为默认情况下允许使用数据属性。
2)然后你需要配置PHP端的东西-数据转换,这发生在数据保存到数据库之前。请参阅手册章节:https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Rte/Transformations/Process.html#transformations-process
下面是一个允许在转换中使用data-abc属性的示例(取自RTE yaml preset) (除了默认允许的属性之外)。
processing:
allowAttributes: [class, id, title, dir, lang, xml:lang, itemscope, itemtype, itemprop, data-abc]因此,在您的情况下,您缺少正确的allowAttributes配置。
https://stackoverflow.com/questions/60849392
复制相似问题