我正在尝试在 CK 编辑器中添加一个新的格式或样式选项,该选项插入一个带有类的块引用。
我添加了几种自定义格式和样式并且没有问题,但是当尝试创建一个元素设置为块引用的元素时,它不起作用。
格式下拉菜单会显示该选项,但该选项不起作用。样式下拉菜单甚至不显示该选项。
我的 javascript 在下面,这是一个 JS Fiddle 来演示:
CKEDITOR.replace('editor1', {
format_section: {
name: 'Section',
element: 'section'
},
format_blockquote: {
name: 'Blockquote',
element: 'blockquote',
attributes: {
class: 'test-class1'
}
},
format_tags: 'p;section;blockquote',
stylesSet: 'custom_styles'
});
CKEDITOR.stylesSet.add('custom_styles', [
// Block-level styles
{
name: 'Red Title',
element: 'h3',
styles: {
'color': 'Red'
},
attributes: {
'class': 'test'
}
},
{
name: 'Bquote',
element: 'blockquote',
styles: {
'color': 'Red'
},
attributes: {
'class': 'test'
}
},
// Inline styles
{
name: 'Marker: Yellow',
element: 'span',
styles: {
'background-color': 'Yellow'
},
attributes: {
'class': 'test'
}
},
{
name: 'Bquote inline',
element: 'blockquote',
styles: {
'background-color': 'Yellow'
},
attributes: {
'class': 'test'
}
}
]);
注意:我已经启用了默认报价按钮,我们将其用于我们的默认报价样式。