1
votes

Im trying to limit the html editing behavior of CKEditor when switching between source and wysiwyg mode. Currently when I switch from source to wysiwyg the editor removes any attributes added to <span> tags. It does not repeat this behavior with any other tags.

I've set CKEDITOR.config.allowedContent = true; , as well as registered allowedContent: 'span[*]', in a custom plugin. The allowedContent setting prevented the editor from removing the tag entirely, but attributes are still stripped away. The entirety of the code I'm trying to perserve is below.

Thanks!

    <div class="float_right_caption_drop" style="width: 243px">
    <span style="width: 233px;">
    <img class="float_img" src="/images/fox.jpg" width="233" border="0" alt="" />
    <br />Fox Caption</span></div>
1

1 Answers

3
votes

That's because style and class attributes are not handled by Advanced Content Filter as other attributes - they have their specific format in Allowed Content Rules. You can find a detailed description of ACRs in Allowed Content Rules guide. But in short - to allow all attributes, styles and classes you need to set:

allowedContent: 'span[*]{*}(*)'

PS. If you set allowedContent = true correctly, then your spans wouldn't be filtered at all.