Typo3 9 RTE CK_Editor 4保存后范围内的数据属性删除

问题描述 投票:0回答:1

我试图将数据属性保存在span标记内。保存后将其删除。我在自定义yaml文件中尝试了以下配置。

processing.allowAttributes: 
 -'span[data]'
processing.allowTags:
 -span
editor.config.extraAllowedContent: "*(*)[data-*]"

没有任何帮助。问题出在哪里?

add custom-data-attribute rte
1个回答
0
投票

为了允许将数据属性从RTE字段保存到db,您需要确保:

1)RTE(CKEditor)不会剥离属性。可以使用extraAllowedContent进行配置。下面是一个示例,如何在允许数据属性和类的默认规则之外另外允许id属性。

editor:
  config:
    extraAllowedContent:
      - "*(*)[data-*]"
      - "*[id]"

如果只需要添加数据属性,则不需要上面的配置,并且可以中继默认配置(来自rte_ckeditor / Configuration / RTE / Editor / Base.yaml),因为默认情况下允许使用数据属性。] >

2),那么您需要配置PHP方面的内容-数据转换发生在将数据保存到db之前。参见手册章节:https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Rte/Transformations/Process.html#transformations-process

下面是一个示例(取自RTE yaml预设),允许在转换中允许data-abc属性(除了默认情况下允许的属性。)>

processing:
  allowAttributes: [class, id, title, dir, lang, xml:lang, itemscope, itemtype, itemprop, data-abc]

因此,您缺少适当的allowAttributes配置。

© www.soinside.com 2019 - 2024. All rights reserved.