oro / html5-purifier
为 WYSIWYG 编辑器添加 HTML5 标签支持
3.1.5
2021-01-28 08:56 UTC
Requires
- oro/platform: 3.1.*
- xemlock/htmlpurifier-html5: 0.1.10
README
此扩展包的目的是在不引入 BC 断裂的情况下添加对 xemlock/htmlpurifier-html5
库的支持。该库为 HTMLPurifier 添加了对 HTML5 标签的支持。扩展包还添加了在三种净化模式之间切换的能力
strict
- 通过白名单过滤 HTML 元素和属性。不允许样式和 iframe 元素。extended
- 与 strict 相同,但允许样式和 iframe 元素。disabled
- 完全禁用 HTML Purifier。
这些模式可以通过 package/html5-purifier/Resources/config/oro/app.yml 中的 html_purifier_mode
配置设置进行切换
如何扩展 Html5Purifier 支持的元素和属性列表
有时可能需要向 Html5Purifier 配置中添加额外的元素或属性。要添加自定义元素,装饰 oro_html5_purifier.html_tag_helper
服务。
services: ... acme.html_tag_helper: decorates: oro_html5_purifier.html_tag_helper parent: oro_html5_purifier.html_tag_helper calls: # map element - ['setElement', ['map', 'Block', 'Flow', 'Common', true]] # map attributes - ['setAttribute', ['map', 'id', 'ID']] - ['setAttribute', ['map', 'name', 'CDATA']]
接下来,将 map
元素和属性添加到您包中的 app.yml
文件中的净化器配置中。
oro_form: wysiwyg: html_allowed_elements: map: attributes: - id - name
现在您可以在所有 WYSIWYG 字段中使用 map
标签及其 id
和 name
属性。