how can I set writer rules for all elements in ckeditor

a 夏天 提交于 2020-01-07 08:47:13

问题


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?


回答1:


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, { ... } );
}


来源:https://stackoverflow.com/questions/34839629/how-can-i-set-writer-rules-for-all-elements-in-ckeditor

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!