模态对话框中的CKEditor和elFinder

Mar*_*hal 1 javascript modal-dialog ckeditor elfinder

我需要将elFinder集成到CKEditor.我跟着这个:

https://github.com/Studio-42/elFinder/wiki/Integration-with-CKEditor

它正在工作,但打开弹出窗口的图像选择不是很好,所以我想在模态对话框中打开elFinder.

对于"模态集成",我遵循这个主题:http: //bxuulgygd9.tal.ki/20110728/integration-with-ckeditor-759177/

那里的最后一篇文章部分有效.它真的打开了模态中的elfinder.但是:当我想在CKFinder中将图像URL插入URL字段时,我必须知道它的确切ID.也不填写图像分辨率并带来一些其他问题.最好的解决方案是运行在"普通弹出"集成中调用的函数,它处理所有事情:

window.opener.CKEDITOR.tools.callFunction(funcNum, file);
Run Code Online (Sandbox Code Playgroud)

但是在"弹出集成"中,funcNum回调被注册,在模态集成中它不是那么我无法调用它.你有任何提示在模态窗口中运行elfinder(或任何其他图像管理器 - 它会是相同的)吗?我很绝望.

Mar*_*hal 5

我自己解决了.此代码是几个教程的组合,允许在模态窗口中完全集成elFinder.也许有人会认为它很有用.

    CKEDITOR.on('dialogDefinition', function(event) {
    var editor = event.editor;
    var dialogDefinition = event.data.definition;
    console.log(event.editor);
    var dialogName = event.data.name;

    var tabCount = dialogDefinition.contents.length;
    for (var i = 0; i < tabCount; i++) {
        var browseButton = dialogDefinition.contents[i].get('browse');

        if (browseButton !== null) {
            browseButton.hidden = false;
            browseButton.onClick = function(dialog, i) {
                editor._.filebrowserSe = this;
                jQuery('<div \>').dialog({modal: true, width: "80%", title: "Insert image", zIndex: 99999,
                    create: function(event, ui) {
                        jQuery(this).elfinder({
                            resizable: false,
                            url: "/path/to/connector.php",
                            getFileCallback: function(url) {
                                CKEDITOR.tools.callFunction(editor._.filebrowserFn, url);
                                jQuery('a.ui-dialog-titlebar-close[role="button"]').click()
                            }
                        }).elfinder('instance')
                    }
                })
            }
        }
    }
});
Run Code Online (Sandbox Code Playgroud)