CKEditor关闭对话框

9

我想在自定义插件中调用CKEditor对话框框的close函数。就像在“表情符号”插件中点击笑脸时发生的那样,但是我不知道如何在自己的插件中实现相同的功能。 感谢回复!

我已经找到了解决方案。 在我的插件中,我需要从“CKEDITOR.dialog.add”的“onLoad”部分调用close函数。所以,我需要这样做:

CKEDITOR.dialog.add( 'plugin_name', function( editor ){
    onLoad: function( event ){
        [...some code...]
        event.sender.hide();
    }
}
2个回答

23

CKEDITOR.dialog.getCurrent().hide()


4
我建议您采用与CKEditor Dialog插件内部相同的方式进行操作。请参见plugin.js中第535行。

通过点击按钮或触发取消事件,您可以确保插件正确处理。

示例代码:

// If there's a Cancel button, click it, else just fire the cancel event and hide the dialog.
        button = CKEDITOR.dialog.getCurrent().getButton( 'cancel' );
        if ( button )
            CKEDITOR.tools.setTimeout( button.click, 0, button );
        else {
            if ( CKEDITOR.dialog.getCurrent().fire( 'cancel', { hide : true } ).hide !== false )
            CKEDITOR.dialog.getCurrent().hide();
        }

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接