Sean
Sean

Reputation: 789

Applying classes to block level elements in ckeditor

I cannot seem to apply styles using this style definition:

var object = {
    type: CKEDITOR.STYLE_BLOCK,
    attributes: {
        'class': 'foo'
    } 
};

var style = new CKEDITOR.style(object);

I have allowedContent set to true in my configs.

Upvotes: 1

Views: 172

Answers (1)

Comandeer
Comandeer

Reputation: 360

Styles definitions in CKEditor don't have the type property. CKEditor uses element property to know when and how to apply the style:

var object = {
    element: 'h1', // This style will be applied to h1 element
    attributes: {
        'class': 'foo'
    } 
};

More examples on defining styles can be found in official guide.

Upvotes: 8

Related Questions