【问题标题】:CKEditor error creating dialogCKEditor 错误创建对话框
【发布时间】:2017-10-09 20:39:10
【问题描述】:

我有以下测试脚本:

    var field = {id: "html1"};
    var editor = CKEDITOR.replace(field.id);
    var dialogObj = new CKEDITOR.dialog(editor, 'smiley');

我收到以下错误:Uncaught TypeError: Cannot read property 'dir' of undefined 在 CKEDITOR.dialog (ckeditor.js:573) 在 testCKE.html:24

我使用的是完整版 4.6.2(2017 年 1 月 12 日)

dir 似乎是 editor.lang 的一个元素 我尝试设置 config.language 和 config.defaultLanguage

我用jquery和不用jquery都试过了,没区别

编辑器可以正常打开并且可以正常工作。 我做错了什么?

更新:找到答案,见下文。如果有更好的方法,仍然很感兴趣。

【问题讨论】:

    标签: javascript ckeditor


    【解决方案1】:

    我让对话框使用基于示例/旧/对话框文件的代码工作,缩减版本:

    var field = {id: "html1"};
    CKEDITOR.on( 'instanceCreated', function( ev ){
        var editor = ev.editor;
    
        // Listen for the "pluginsLoaded" event, so we are sure that the
        // "dialog" plugin has been loaded and we are able to do our
        // customizations.
        editor.on( 'pluginsLoaded', function() {
    
            // If our custom dialog has not been registered, do that now.
            if ( !CKEDITOR.dialog.exists( 'myDialog' ) ) {
    
                CKEDITOR.dialog.add( 'myDialog', function(){
                    return  {title: 'My Dialog',
                        minWidth: 400,
                        minHeight: 200,
                        contents:[
                            {
                                id: 'tabA',
                                label: 'TabA',
                                title: 'TabA',
                                elements: [
                                    {
                                        id: 'button1',
                                        type: 'button',
                                        label: 'Button Field'
                                    }
                                ]
                            }
                        ]
                    };
                } );
            }
    
            // Register the command used to open the dialog.
            editor.addCommand( 'myDialogCmd', new CKEDITOR.dialogCommand( 'myDialog' ) );
    
            // Add the a custom toolbar buttons, which fires the above
            // command..
            editor.ui.add( 'MyButton', CKEDITOR.UI_BUTTON, {
                label: 'My Dialog',
                command: 'myDialogCmd'
            });
        });
    });
    
    var editor = CKEDITOR.replace(field.id);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-26
      • 2014-11-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-26
      • 2013-12-16
      • 2011-05-28
      • 2013-02-27
      相关资源
      最近更新 更多