ckeditor 4 jQuery 适配器,如何添加自定义按钮?
ckeditor 4 jQuery Adapter, How to add a custom button?
代码 0:
$editor.ckeditor(function () {
var editor = this;
editor.ui.add('MyButton', CKEDITOR.UI_BUTTON, {
label: 'My Button',
command: 'test'
});
}, {toolbar: [['MyButton']]});
代码 1:
var editor = CKEDITOR.replace('editor', {toolbar: [['MyButton']]});
editor.ui.add('MyButton', CKEDITOR.UI_BUTTON, {
label: 'My Button',
command: 'test'
});
[code 1]可以,在工具栏正常显示,但是[code 0]不行,如何使用jQuery适配器添加自定义按钮?
已更新 [代码 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'
});
使用pluginsLoaded
event (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!' );
} );
代码 0:
$editor.ckeditor(function () {
var editor = this;
editor.ui.add('MyButton', CKEDITOR.UI_BUTTON, {
label: 'My Button',
command: 'test'
});
}, {toolbar: [['MyButton']]});
代码 1:
var editor = CKEDITOR.replace('editor', {toolbar: [['MyButton']]});
editor.ui.add('MyButton', CKEDITOR.UI_BUTTON, {
label: 'My Button',
command: 'test'
});
[code 1]可以,在工具栏正常显示,但是[code 0]不行,如何使用jQuery适配器添加自定义按钮?
已更新 [代码 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'
});
使用pluginsLoaded
event (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!' );
} );