CKEditor 4.3 Widget Richcombo

风格不统一 提交于 2019-12-23 04:46:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!