FileBrowser回调,而不是用CKEditor 4.5弹出

FileBrowser callback instead of popup with CKEditor 4.5

本文关键字:CKEditor 弹出 回调 FileBrowser      更新时间:2023-09-26

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

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

如果没有,是否有一个"更新的补丁"可以再次添加,或者有人能给我指一下我可以自己添加的位置吗?

按下"浏览服务器"按钮时,您不必修补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>