问题
How can I insert a widget when one of the dropdown menu in Richcombo is clicked? I've read the widget tutorial here and API documentation here
I tried something like this, but it didn't work
CKEDITOR.plugins.add('my_plugin', {
init: function(editor) {
editor.ui.addRichCombo('my_plugin', {
label: 'plugin1',
init: function() {
this.add('FIRST_NAME', 'FIRST NAME', 'Insert FIRST NAME');
},
onclick: function(value) {
editor.focus();
editor.widgets.add('widget1', {
upcast: function( element ) {
// Defines which elements will become widgets.
if ( element.hasClass( 'widget1' ) )
return true;
},
});
editor.setData( '<div class="widget1">foo</div>' );
}
)};
}
});
来源:https://stackoverflow.com/questions/26475998/ckeditor-4-3-widget-richcombo