ntiedt
ntiedt

Reputation: 183

CKEditor: Allow span tag inside paragraph

If I enter and save the following html to CKEditor all span tags gets removed.

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

I found the following solution on stackoverflow adapt it for my needs but it doesn´t work.

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

I used the default config from EXT an include it in my own.

 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" }

Tags are allowed from default config.

  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

How can i archive this?

Upvotes: 2

Views: 3896

Answers (1)

Paul Beck
Paul Beck

Reputation: 2683

Maybe the span tag is not allowed in your configuration? Then add it like this:

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

EDIT: It seems to be necessary you add the span to extraAllowedContent:

editor:
  config:
    extraAllowedContent:
      - span

And much more important, to prevent empty tags to become stripped away:

processing:
  HTMLparser_db:
    tags:
      span:
        rmTagIfNoAttrib: false

Upvotes: 4

Related Questions