将类应用于ckeditor中的块级元素

Sea*_*ean 1 ckeditor

我似乎无法使用此样式定义应用样式:

var object = {
    type: CKEDITOR.STYLE_BLOCK,
    attributes: {
        'class': 'foo'
    } 
};
Run Code Online (Sandbox Code Playgroud)

var style = new CKEDITOR.style(object);

我在我的配置中将allowContent设置为true.

Com*_*eer 9

CKEditor中的样式定义没有该type属性.CKEditor使用element属性来知道何时以及如何应用样式:

var object = {
    element: 'h1', // This style will be applied to h1 element
    attributes: {
        'class': 'foo'
    } 
};
Run Code Online (Sandbox Code Playgroud)

有关定义样式的更多示例可以在官方指南中找到.