简体   繁体   English

如何使用 ckeditor 4 类型(链接、图像、闪存)打开不同的对话框

[英]How to open different dialog with ckeditor 4 type (link, image, flash)

I have some troubles when integrated elFinder into my CMS.将 elFinder 集成到我的 CMS 时,我遇到了一些麻烦。 I'm using it with CKEditor 4 as the integrated method with JQuery UI in their guide .我将它与 CKEditor 4 一起使用,作为他们指南中 JQuery UI 的集成方法。 Image upload and image manager is all good but i don't know how to open different dialog for different file type and folder like how can i config elFinder to open a new dialog file manager for flash files and folder for store flash files (different from images folder) when i click "Flash" button in my editor and then "Browse Server".图像上传和图像管理器都很好,但我不知道如何为不同的文件类型和文件夹打开不同的对话框,比如我如何配置 elFinder 为 flash 文件和用于存储 flash 文件的文件夹打开一个新的对话框文件管理器(不同于images 文件夹),当我在编辑器中单击“Flash”按钮,然后单击“浏览服务器”时。 The same as when i click "Link" button and "Browse Server", the dialog should show for diffrent folder that store doc and pdf file.与单击“链接”按钮和“浏览服务器”时相同,对话框应显示存储文档和 pdf 文件的不同文件夹。 I've also try something like this in the main.ckedialog.js i loaded into my page:我也在我加载到我的页面中的 main.ckedialog.js 中尝试了这样的事情:

if ($('#content').length > 0) {
    var editor = CKEDITOR.replace('content', {
        language: 'en',
        filebrowserBrowseUrl: '#',
        //extraPlugins: 'uploadimage,image2',
        extraPlugins: 'uploadimage',
        filebrowserImageBrowseUrl: 'admin/includes/elFinder/php/connector.minimal.php',
        filebrowserImageBrowseLinkUrl: 'admin/includes/elFinder/php/connector.minimal.php',
        filebrowserImageUploadUrl: 'admin/includes/elFinder/php/connector.minimal.php',
        filebrowserFlashUploadUrl: 'admin/includes/elFinder/php/connector.doc.php',
        filebrowserFlashBrowseUrl: 'admin/includes/elFinder/php/connector.doc.php',

        ImageBrowseUrl: 'admin/includes/elFinder/php/connector.minimal.php',
        ImageBrowseLinkUrl: 'admin/includes/elFinder/php/connector.minimal.php',
        ImageUploadUrl: 'admin/includes/elFinder/php/connector.minimal.php',
        FlashUploadUrl: 'admin/includes/elFinder/php/connector.doc.php',
        FlashBrowseUrl: 'admin/includes/elFinder/php/connector.doc.php',
    });
    CKEDITOR.config.height = 500;
    CKEDITOR.config.defaultLanguage = 'en';
    editor.addCommand("mySimpleCommand", { // create named command
        exec: function (edt) {
            alert(edt.getData());
        }
    });
}

Here is the button i want to use to open elFinder dialog for file manager这是我想用来打开文件管理器的 elFinder 对话框的按钮

这是我使用的按钮

Hope someone can help.希望有人可以提供帮助。 Thanks.谢谢。

After can't find anything on google, i found a way to solve my problem using some dirty trick.在谷歌上找不到任何东西后,我找到了一种方法来使用一些肮脏的技巧来解决我的问题。 So i think it's still some official way to do it right.所以我认为这仍然是一些正确的官方方式。 Here is the solution for any one need it:这是任何人需要的解决方案:

  1. Define second variable to php connector using for second dialog (in my case is connector.doc.php) in main.ckedialog.js like this像这样在 main.ckedialog.js 中使用第二个对话框(在我的情况下是 connector.doc.php)将第二个变量定义为 php 连接器

    var elfNode, elfNode1, elfNode2, elfInsrance, dialogName, elfUrl = 'admin/includes/elFinder/php/connector.minimal.php', // Your connector's URL elfUrl1 = 'admin/includes/elFinder/php/connector.doc.php', var elfNode, elfNode1, elfNode2, elfInsrance, dialogName, elfUrl = 'admin/includes/elFinder/php/connector.minimal.php', // 您的连接器的 URL elfUrl1 = 'admin/includes/elFinder/php/connector.doc.php ',

  2. Check for the button at "CKEDITOR.on('dialogDefinition', function (event) {" in main.ckedialog.js find line "if (elfNode) {" and cut it into if else (dialogName) like this检查 main.ckedialog.js 中“CKEDITOR.on('dialogDefinition', function (event) {” 处的按钮找到行“if (elfNode) {” 并将其剪切成 if else (dialogName) 像这样

if (dialogName === 'image') { if (elfNode) { if (elfDirHashMap[dialogName] && elfDirHashMap[dialogName].= elfInsrance.cwd().hash {... elfNode;dialog('open'). } } else if (dialogName == 'link') { if (elfNode1) {... elfNode1;dialog('open'); } } if (dialogName === 'image') { if (elfNode) { if (elfDirHashMap[dialogName] && elfDirHashMap[dialogName].= elfInsrance.cwd().hash {... elfNode;dialog('open'). } } else if (dialogName == 'link') { if (elfNode1) {... elfNode1;dialog('open'); } }

  1. Find line "CKEDITOR.on('instanceReady', function(e) {" in main.ckedialog.js, copy all code in it's function and paste it right after content you copied and then rename "elfNode" within the block you copied and pasted to "elfNode1", change "url: elfUrl," to "url: elfUrl1," also the "onlyMimes" to your needed configures在 main.ckedialog.js 中找到行“CKEDITOR.on('instanceReady', function(e) {”,复制其中的所有代码 function 并将其粘贴在您复制的内容之后,然后在您复制的块中重命名“elfNode”并粘贴到“elfNode1”,将“url:elfUrl”更改为“url:elfUrl1”,并将“onlyMimes”更改为您需要的配置

(Sorry but i still don't know how to use pre tag for my code in stackoverflow editor, sometime it work, sometime it doesn't) (对不起,我仍然不知道如何在stackoverflow编辑器中为我的代码使用pre标签,有时它工作,有时它不工作)

Now it worked.现在它起作用了。 Still looking for better way to do it.仍在寻找更好的方法来做到这一点。 Thanks谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM