我已经添加了
- { name: "Data Test", element: "p", attributes: { 'data-test': "test" } }
到我的Yaml配置。我可以在编辑器代码中选择数据属性(并查看正确)。但是在保存内容后,TYPO3还将从代码中删除data-tesst =“ test”。
我该如何解决?感谢帮助!马丁
按钮: 链接: relAttribute:已 启用:true targetSelector: 禁用:false 属性: 类: allowedClasses:'按钮,button_hell' 标题: readOnly:错误 导入: -{资源:“ EXT:rte_ckeditor / Configuration / RTE / Processing.yaml”} -{资源:“ EXT:rte_ckeditor / Configuration / RTE / Editor / Base.yaml”} -{资源:“ EXT:rte_ckeditor / Configuration / RTE / Editor / Plugins.yaml”} 编辑器: config: #编辑器的css定义 contentCss:“ EXT:mw_theme / Resources / Public / Css / rte.css” #可以是“默认”,但是可以在此处定义自定义stylesSet,这最适合TYPO3 format_tags:“ p; h1; h2; h3; h4; h5; h6; pre; address” stylesSet: #自定义块级样式 -{名称:“ Button”,元素:“ a”,属性:{'class':“ button”}} -{名称:“ Test”,元素:“ p”,属性:{'data-test':“ test” }} 工具栏: -['格式','样式'] -['粗体,'斜体','下划线','Blockquote','下标','上标'] -['JustifyLeft','JustifyCenter', 'JustifyRight','JustifyBlock','HorizontalRule'] -['NumberedList','BulletedList'] -['Link','Unlink','Anchor','Table','SpecialChar','CodeSnippet','Youtube'] -['剪切','复制','粘贴','PasteText','PasteFromWord'] 剪切”,“复制”,“粘贴”,“ PasteText”,“ PasteFromWord”] -['撤消','重做','RemoveFormat','ShowBlocks'] -['源','最大化','关于' ] removePlugins: -图像 额外插件: -对齐 justifyClasses: -文本左 -文本中心 -文本右 -文本对齐 允许标签 处理: allowTags: -dl -dt -dd
ts页:
RTE { default { preset = mw_theme } }`
为了允许将数据属性从RTE字段保存到db,您需要确保:
1)RTE(CKEditor)不会剥离属性。这可以使用extraAllowedContent进行配置。下面是一个示例,该示例如何在允许数据属性和类的默认规则之外另外允许id属性。
editor:
config:
extraAllowedContent:
- "*(*)[data-*]"
- "*[id]"
如果只需要添加数据属性,则不需要上面的配置,并且可以中继默认配置(来自rte_ckeditor / Configuration / RTE / Editor / Base.yaml),因为默认情况下,数据属性是允许的。
要测试此配置部分,请转到RTE,单击“查看源代码”按钮,再切换回并再次切换,以查看该属性是否消失。如果仍然存在,则意味着您的RTE配置允许它。
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]
因此,在您的情况下,您缺少转换部分上的正确配置。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句