本文介绍了如何为ckeditor中的所有元素设置编写者规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何为所有元素设置全局值?
how could I set this global for all elements:
CKEDITOR.on('instanceReady', function(ev){
var el = [ "p", "div", "table", "tbody", "tr", "td", "h1", "h2", "h3", "h4", "h5", "h6", "ul", "center" ];
el.forEach(function(v) {
ev.editor.dataProcessor.writer.setRules(v,
{
indent: false,
breakBeforeOpen: true,
breakAfterOpen: false,
breakBeforeClose: false,
breakAfterClose: false
}
);
});
});
将其作为元素数组很无聊吗?有人知道如何解决这个问题吗?
it is boring to make this as array of elements? does anybody know how to fix this?
推荐答案
没有API可以让您为所有元素配置它。但仍然可以结合与像这样:
There's no API which would let you configure it for all elements. But still you can combine CKEDITOR.dtd
with CKEDITOR.tools.extend
like:
var dtd = CKEDITOR.dtd;
for ( var e in CKEDITOR.tools.extend( {},
dtd.$block,
dtd.$listItem,
dtd.$tableContent )
) {
this.setRules( e, { ... } );
}
这篇关于如何为ckeditor中的所有元素设置编写者规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!