gpt4 book ai didi

javascript - ckeditor 4 jQuery 适配器,如何添加自定义按钮?

转载 作者:行者123 更新时间:2023-11-28 19:25:33 25 4
gpt4 key购买 nike

代码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 Adapter添加自定义按钮?

<小时/><小时/>

更新了[代码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事件(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!' );
} );

关于javascript - ckeditor 4 jQuery 适配器,如何添加自定义按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27961325/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com