[英]ckeditor 4 jQuery Adapter, How to add a custom button?
code 0: 代码0:
$editor.ckeditor(function () {
var editor = this;
editor.ui.add('MyButton', CKEDITOR.UI_BUTTON, {
label: 'My Button',
command: 'test'
});
}, {toolbar: [['MyButton']]});
code 1: 代码1:
var editor = CKEDITOR.replace('editor', {toolbar: [['MyButton']]});
editor.ui.add('MyButton', CKEDITOR.UI_BUTTON, {
label: 'My Button',
command: 'test'
});
[code 1] is OK, normal to show at toolbar, but [code 0] is not work, how to use jQuery Adapter to add custom button?? [代码1]可以,可以正常显示在工具栏上,但是[代码0]不起作用,如何使用jQuery Adapter添加自定义按钮?
updated [code 0]: 更新了[代码0]:
$editor.ckeditor(function () {
var editor = this;
editor.on('pluginsLoaded', function(event) {
editor.ui.add('MyButton', CKEDITOR.UI_BUTTON, {
label: 'My Button',
command: 'test'
});
});
},
{
customConfig: '/ckeditor-config.js'
});
Use pluginsLoaded
event ( jsFiddle ): 使用
pluginsLoaded
事件( jsFiddle ):
$( 'textarea' ).ckeditor( {
on: {
pluginsLoaded: function() {
this.ui.add('MyButton', CKEDITOR.UI_BUTTON, {
label: 'My Button',
command: 'test'
} );
console.log( this.name + ' plugins ready!' );
}
},
toolbar: [['MyButton']]
},
function( textarea ) {
console.log( this.name + ' instance ready!' );
} );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.