【问题标题】:CKEditor: Allow span tag inside paragraphCKEditor:允许段落内的跨度标签
【发布时间】:2018-08-22 09:28:06
【问题描述】:

如果我输入以下 html 并将其保存到 CKEditor,所有 span 标签都会被删除。

 <p class="animate" data-animate="fadeIn"><span>Maschinenlager</span> <span>Schwergutlager</span> <span>Frei- vs. Festplatzprinzip</span></p>

我找到了 following solution on stackoverflow 来适应我的需要,但它不起作用。

 editor:
   config:
    extraAllowedContent: "*(*)[data-*];span;p span"  

我使用了 EXT 的默认配置并将其包含在我自己的中。

 imports:
- { resource: "EXT:rte_ckeditor/Configuration/RTE/Processing.yaml" }
- { resource: "EXT:rte_ckeditor/Configuration/RTE/Editor/Base.yaml" }
- { resource: "EXT:rte_ckeditor/Configuration/RTE/Editor/Plugins.yaml" }

默认配置允许使用标签。

  processing:
    allowTags:
      - a
      - abbr
      - acronym
      - address
      - article
      - big
      - blockquote
      - br
      - caption
      - cite
      - code
      - col
      - colgroup
      - dd
      - del
      - dfn
      - dl
      - div
      - dt
      - em
      - footer
      - header
      - h1
      - h2
      - h3
      - h4
      - h5
      - h6
      - hr
      - i
      - img
      - ins
      - kbd
      - label
      - li
      - nav
      - ol
      - p
      - pre
      - q
      - samp
      - section
      - small
      - span
      - strong
      - style
      - sub
      - sup
      - table
      - thead
      - tbody
      - tfoot
      - td
      - th
      - tr
      - tt
      - ul
      - var

如何存档?

【问题讨论】:

    标签: ckeditor typo3 typo3-8.7.x


    【解决方案1】:

    也许您的配置中不允许使用 span 标签?然后像这样添加它:

    # Allow additional tags
    processing:
      allowTags:
        - s
        - span
        - iframe
        - i
    

    编辑:似乎有必要将跨度添加到 extraAllowedContent:

    editor:
      config:
        extraAllowedContent:
          - span
    

    更重要的是,防止空标签被剥离:

    processing:
      HTMLparser_db:
        tags:
          span:
            rmTagIfNoAttrib: false
    

    【讨论】:

    • 这对我不起作用。我的配置中有这个,请参阅编辑后的问题。
    • 更新了我的答案,因为这些天我遇到了同样的问题。
    • rmTagIfNoAttrib: false 是重要的部分。感谢您的帮助 ;-)
    猜你喜欢
    • 2013-04-24
    • 2018-07-15
    • 2014-07-26
    • 1970-01-01
    • 2011-02-24
    • 1970-01-01
    • 2016-05-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多