Madnx
Madnx

Reputation: 1564

How to set datas with css style with CKEditor?

How can I set datas with CKEditor (4.0) with CSS style ?

$quote = $editor + '<br />'+ 
        '<div class="quote">'+
            '<div class="quote-infos">'+
                '<i class="icon-comment icon-white"></i>'+
                ' <span class="quote-user">'+$user+'</span>,'+
                ' <span class="quote-date">'+$date+'</span> :'+
            '</div>'+
            '<blockquote>'+$div.html()+'</blockquote>'+
        '</div>';   
editorMessage.setData($quote);

In this code, when I send the datas to a POST form, I just have <div><div><i></i><span...

Upvotes: 0

Views: 724

Answers (1)

Joel Peltonen
Joel Peltonen

Reputation: 13402

If you are using the new 4.1 CKEditor, it might be because of the new Advanced Content Filter feature. It nukes tags, attributes and attribute contents from content HTML, see demo. Turn it off by adding config.allowedContent = true to your config. More info on configuration in the API

You can test for this easily in your CKE instance by going to source mode, adding some attributes manually into the content, like <div class="MagicalPonies"><div><i></i><span... Then switch to wysiwyg mode and back to source mode. If your class definition is missing, it's most likely ACF. Also try to add a class like <img alt="X" class="left" src="http://b.cksource.com/a/1/img/sample.jpg" /> and see if that sticks. Standard CKE classes like that aren't removed.

Upvotes: 1

Related Questions