我试图在债权人4中覆盖默认对齐左/右/中心,这样他们就可以将整个文本证明为左/右/中心,而不是分别对齐每一行。我已将下面的代码添加到creditor.config.js中,一切正常,但我无法在ckeditor中更新/刷新新值。看起来像setData()会更新ckeditor值,但它在循环中执行,尝试将其包装在setTimout()中,但这并没有改变任何东西。尝试更新元素,setValue,setHtml ...
CKEDITOR.on('instanceReady', function (ev) {
ev.editor.on('selectionChange', function () {
var text = ev.editor.getData();
text = text.replace(new RegExp('(class="rtecenter")|(class="rteleft") |(class="rteright")','g'),'');
text = '<div class="rteleft">'+text+'</div>';
// ev.editor.setData(text);
// ev.editor.element.setValue(text);
// ev.editor.element.setHtml(text);
});
});
答案 0 :(得分:0)
是的,谢谢! 最终工作,很简单...... 即这是如何在CKEditor 4中覆盖'justifycenter'命令:
CKEDITOR.on('instanceReady',function(ev){
var editor = ev.editor;
var overridecmd_justifycenter = new CKEDITOR.command(editor, {
exec: function(editor){
var ps = editor.document.$.getElementsByTagName("p");
for (var i=0; i < ps.length; i++){
if(ps[i].className.indexOf("rtecenter") < 0) {
ps[i].className = "rtecenter";
}
}
}
});
// Replace default button commands with overrides
ev.editor.commands.justifycenter.exec = overridecmd_justifycenter.exec;
});