【问题标题】:FileBrowser callback instead of popup with CKEditor 4.5FileBrowser 回调而不是 CKEditor 4.5 的弹出窗口
【发布时间】:2015-07-04 08:12:16
【问题描述】:

我在我的 ASP.NET MVC 5 应用程序中使用 CKEditor,但我仍在使用 4.0.2 版本,因为我通过使用来自 AlexW 的补丁来使用 fileBrowserCallback 配置(另请参阅 here)。但是这个补丁不兼容任何更新的版本。

现在有了 CKEditor 4.5 的新版本,我终于想升级,因为它们有一些很棒的新功能(如拖放/复制和粘贴上传),但我不想回到“弹出文件浏览器” .
我在文档和 API 中搜索了所有新的文件浏览器插件/选项,但我仍然找不到这样的选项。
我错过了启用此功能的配置选项还是仍然不可能?

如果没有,是否有一个“更新的补丁”可以再次添加它,或者有人可以指出我可以自己添加它的位置吗?

【问题讨论】:

    标签: javascript jquery asp.net file-upload ckeditor


    【解决方案1】:

    您不必修补 CKEditor 以在按下浏览服务器按钮时调用您的自定义回调。检查以下更改图像对话框的示例代码:

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <title>Browse server - custom callback</title>
        <script src="http://cdn.ckeditor.com/4.5.1/standard/ckeditor.js"></script>
    </head>
    <body>
        <form action="sample_posteddata.php" method="post">
            <textarea cols="80" id="editor1" name="editor1" rows="10">
    
            </textarea>
            <script>
    
                CKEDITOR.on( 'dialogDefinition', function( ev ) {
                    // Take the dialog name and its definition from the event data.
                    var dialogName = ev.data.name;
                    var dialogDefinition = ev.data.definition;
    
                    // Check if the definition is from the dialog we're
                    // interested on (the "Image" dialog).
                    if ( dialogName == 'image' ) {
                        // Get a reference to the "Image Properties" tab.
                        var infoTab = dialogDefinition.getContents( 'info' );
    
                        // Get a reference to the "Browse Server" button.
                        var browse = infoTab.get( 'browse' );
                        // Instruct filebrowser plugin to skip hooking into this button.
                        browse[ 'filebrowser' ] = false;
                        // The "Browse Server" button is hidden by default.
                        browse[ 'hidden' ] = false;
                        // Add our own callback.
                        browse[ 'onClick' ] = function() {
                            var url = prompt( 'Type some URL' );
                            this.getDialog().getContentElement( 'info', 'txtUrl' ).setValue( url );
                        };
                    }
                } );
    
                CKEDITOR.replace( 'editor1' );
    
            </script>
        </form>
    </body>
    </html>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-23
      • 1970-01-01
      • 1970-01-01
      • 2019-03-18
      • 1970-01-01
      • 2020-05-31
      相关资源
      最近更新 更多