首页 > 解决方案 > TYPO3:CKEditor 删除了一些 html 标签(例如 strong、h4)

问题描述

当我将 html 内容添加到 CKEditor(源代码模式)然后保存 html 内容时,一些标签被删除 - 例如<strong><h4>.

我正在使用默认的 YAML 配置并添加我自己的配置:

# EXT:my_ext/Configuration/RTE/Default.yaml
imports:
  # Import default RTE config (for example)
  - { resource: "EXT:rte_ckeditor/Configuration/RTE/Processing.yaml" }
  - { resource: "EXT:rte_ckeditor/Configuration/RTE/Editor/Base.yaml" }
  - { resource: "EXT:rte_ckeditor/Configuration/RTE/Full.yaml" }
  # Import the image plugin configuration
  - { resource: "EXT:rte_ckeditor_image/Configuration/RTE/Plugin.yaml" }

editor:
  config:
    # RTE default config removes image plugin - restore it:
    removePlugins: null
    removeButtons: 
      - Anchor
    extraAllowedContent: 'a[onclick]'
    toolbarGroups:
      - { name: basicstyles, groups: [ basicstyles, align, cleanup ] }
      - { name: styles }
    stylesSet:
      - { name: "Rote Schrift", element: "span", attributes: { class: "highlighted red"} }
      - { name: "Button", element: "a", attributes: { class: "btn"} }
      - { name: "Checkliste", element: "ul", attributes: { class: "check-list"} }
    toolbarGroups:
      - { name: links, groups: ['MenuLink', 'Unlink', 'Anchor'] }
  externalPlugins:
      typo3image: { allowedExtensions: "jpg,jpeg,png,gif,svg" }
      typo3link: { resource: "EXT:rte_ckeditor/Resources/Public/JavaScript/Plugins/typo3link.js", route: "rteckeditor_wizard_browse_links" }

processing:
  HTMLparser_db: 
    denyTags: null

此外,我有以下 TS 页面配置(不确定 TYPO3 是否使用它 - 它是旧 RTE 编辑器的设置):

RTE.default.enableWordClean.HTMLparser {
    allowTags = a,b,blockquote,br,div,em,h2,h3,h4,h5,h6,hr,i,img,li,ol,p,span,strike,strong, ...

标签: ckeditortypo3typo3-8.x

解决方案


通过将我的 Custom.yaml 与typo3\sysext\rte_ckeditor\Configuration\RTE\Full.yaml 进行比较,我终于找到了解决方案

为了允许更多标签,我必须在 Yaml 文件的以下部分中添加新标签:

editor:
  config:
    allowTags:
      - link
      - strong
      - h4

processing:
  allowTags:
    - link
    - strong
    - h4

推荐阅读