我如何控制 CKEditor API 在何处为 filebrowserBrowseUrl 打开新的 window?

How do I control where CKEditor API opens a new new window for the filebrowserBrowseUrl?

MVC5、CKEditor 自定义文件管理器API

我的界面运行良好,但是当我单击“图像”按钮以 select 要插入的图像时,文件 selection 的新 window 显示在主屏幕上我系统中的监视器(运行 4 个监视器)。因此,如果我使用显示器 3 进行在线编辑,必须转到主显示器以 select 图像有点分散注意力。最好在我当前的 window.

之上打开新的 window

我不知道如何解决这个问题。我无法轻易找到为此的 CKEditor 配置设置,而且我不明白如何在特定位置强制打开或不打开视图。

这是我调用 CKEditor 的设置脚本:

@Section Scripts
<script src="~/scripts/ckeditor/ckeditor.js"></script>
<script>
    CKEDITOR.replace('Model.UserPost.Body', {
        filebrowserBrowseUrl: '/BlogsAndForums/UserPost/ImageDisplay?AnchorPostID=' + @Model.AnchorPostID, //This line routes to the ImageDisplay method and view.  Needs more configuration
        toolbarGroups: [  // Define the toolbar groups as it is a more accessible solution.
            { "name": "basicstyles", "groups": ["basicstyles"] },
            { "name": "links", "groups": ["links"] },
            { "name": "paragraph", "groups": ["list", "blocks"] },
            { "name": "document", "groups": ["mode"] },
            { "name": "insert", "groups": ["insert"] },
            { "name": "styles", "groups": ["styles"] },
            { "name": "about", "groups": ["about"] }
        ],
        removeButtons: 'Underline,Strike,Subscript,Superscript,Anchor,Styles,Specialchar' // Remove the redundant buttons from toolbar groups defined above.
    });
</script>
@Scripts.Render("~/bundles/jqueryval")
End Section

ImageDisplay 方法(参见 filebrowserBrowseUrl: 规范)(1) 显示来自 select 的图像列表。 (2) 单击图像后,它 (3) 关闭并 returns 到 CKEditor。 (4) 填充图像的 URL 之后一切正常。

我遇到的唯一问题是 ImageDisplay 视图在我的显示器上的显示位置。

related question 解释了如何在右侧桌面(监视器)中打开弹出窗口 window。这都是关于设置适当的 window.open() 选项。


现在是困难的部分。从理论上讲,editor.config.fileBrowserWindowFeatures. The reality is that the Popup plugin, which opens popup windows (wrapper for window.open()) is implemented so badly that it overrides any geometry you set in the config 应该是可能的。

It doesn't even return a new window handler for the popup.

所以基本上你无能为力,除了(这是一个非常非常讨厌的 hack):

var org = window.open;
window.open = function() { 
  var args = Array.prototype.slice.call(arguments, arguments); 
  console.log( args ); 
  args[ 2 ] = args[ 2 ].replace( /height=\d+/g, 'height=100' ); 
  return org.apply( window, args); 
}

我在 CKEditor 错误跟踪器上创建了 an issue。希望它能顺利完成插件。