我正在创建一个简单的插件,将Richcombo
添加到工具栏中,当点击下拉菜单中的某个选项时,该工具栏将插入小部件。
以下是代码:
CKEDITOR.plugins.add( 'myPlugin', {
init : function( editor )
{
editor.widgets.add( 'widget1' );
editor.ui.addRichCombo( 'richcombo1', {...} );
}
});
在chrome > inspect element> console
下,
它说:Uncaught TypeError: Cannot read property 'add' of undefined
我使用的是版本4.4.5
请帮助,没有人回复CKEditor的论坛。
答案 0 :(得分:2)
您需要widget插件。否则editor.widgets
对象不存在,因此出错。
CKEDITOR.plugins.add( 'myPlugin', {
// Load the widget plugin.
requires: 'widget',
init : function( editor )
{
editor.widgets.add( 'widget1', {
// Your widget definition...
} );
}
} );
有关详情,请参阅有关creating simple widget的教程。