[ckeditor]:如何仅禁止一种css样式
Hy 有没有办法只允许 显示:内联块;和显示:块 是否允许其他显示规则?如果将{display}添加到config.disallowedContent规则中,则不允许使用所有显示样式(还包括显示表、内联和其他样式) Tnx作为答案。不可能使用筛选样式属性值,但会提供一些接口():[ckeditor]:如何仅禁止一种css样式,ckeditor,config,ckeditor4.x,Ckeditor,Config,Ckeditor4.x,Hy 有没有办法只允许 显示:内联块;和显示:块 是否允许其他显示规则?如果将{display}添加到config.disallowedContent规则中,则不允许使用所有显示样式(还包括显示表、内联和其他样式) Tnx作为答案。不可能使用筛选样式属性值,但会提供一些接口(): var filterDisplayProperty = { attributes: { style: function( value, element ) { value
var filterDisplayProperty = {
attributes: {
style: function( value, element ) {
value = CKEDITOR.tools.parseCssText( value, 1 );
if ( value.display in { 'block': 1, 'inline-block': 1 } ) {
delete value.display;
}
// If there's no CSS rules left, discard style attribute.
return CKEDITOR.tools.writeCssText( value ) || false;
}
}
};
CKEDITOR.replace( 'editor', {
toolbar: [ [ 'Source' ], [ 'Undo', 'Redo' ], [ 'Bold', 'Italic', 'Underline' ], [ 'CreateDiv' ] ],
on: {
pluginsLoaded: function() {
// Filter data that comes INTO the editor.
this.dataProcessor.dataFilter.addRules( filterDisplayProperty );
// Filter data that comes OUT of the editor.
this.dataProcessor.htmlFilter.addRules( filterDisplayProperty );
}
}
} );