6

我们正在尝试向 CKeditor 添加一个自定义下拉列表,其中包含我们将查找和替换的预设值列表,对于我来说,我找不到一个简单的方法来做到这一点。查看 TinyMCE 非常简单:

http://www.tinymce.com/tryit/menubutton.php

CKEditor 是否有这样的简单解决方案,我们宁愿不必为了这个功能而将 CKeditor 换成 TinyMCE。我找到了一个名为 PlaceHolder 的插件,但它并不能完全满足我们的要求,老实说,我希望在没有插件的情况下做到这一点,只需像 TinyMCE 那样在初始化时进行配置。

非常感谢您的任何见解。

4

1 回答 1

15

这一切都与editor.ui.addRichComboJSFiddle)有关:

CKEDITOR.replace( 'editor', {
    toolbarGroups: [
        { name: 'mode' },
        { name: 'basicstyles' }
    ],    
    on: {
        pluginsLoaded: function() {
            var editor = this,
                config = editor.config;

            editor.ui.addRichCombo( 'my-combo', {
                label: 'My Dropdown Label',
                title: 'My Dropdown Title',
                toolbar: 'basicstyles,0',

                panel: {               
                    css: [ CKEDITOR.skin.getPath( 'editor' ) ].concat( config.contentsCss ),
                    multiSelect: false,
                    attributes: { 'aria-label': 'My Dropdown Title' }
                },

                init: function() {    
                    this.startGroup( 'My Dropdown Group #1' );
                    this.add( 'foo', 'Foo!' );
                    this.add( 'bar', 'Bar!' );                    

                    this.startGroup( 'My Dropdown Group #2' );
                    this.add( 'ping', 'Ping!' );
                    this.add( 'pong', 'Pong!' );                    

                },

                onClick: function( value ) {
                    editor.focus();
                    editor.fire( 'saveSnapshot' );

                    editor.insertHtml( value );

                    editor.fire( 'saveSnapshot' );
                }
            } );        
        }        
    }
} );
于 2015-04-15T10:15:15.583 回答