ckeditor - 浏览服务器按钮调用函数不弹出怎么办?
我为 ckeditor 创建了一个文件浏览器..在弹出窗口中打开它非常混乱..
我如何绑定浏览服务器上的单击事件,而不是以模式等方式启动文件浏览器。
基本上看看类似的东西
config.filebrowserClick = function(){
// do stuff here that happens when the button gets clicked
}
ive created a file browser for ckeditor.. having it open in a pop-up is messy in the extreme..
how can i tie into the click event on the browse server to rather launch the file browser in a modal etc.
basically looking at something like
config.filebrowserClick = function(){
// do stuff here that happens when the button gets clicked
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
@1I111I1 的答案对我来说非常有用,但缺点是它在所有实例中都会有相同的行为。
如果您需要每个实例进行特殊配置(例如每个实例的根目录可能有不同的默认路径),那么这种方式并不容易。
此外,文件管理器会更好地知道您是否想要图像或文件,因为它们需要不同的查看方法(例如用于图像选择的缩略图模式)。
因此,我对其进行了编辑,以便它可以根据浏览模式(图像/链接)为每个实例触发自定义事件。
现在,您可以分别在每个实例中注册适当的事件,然后使用提供的回调返回选定的值:
另请注意,在这之前,您应该使用弹出窗口模式所需的配置激活浏览按钮,那么此解决方法将覆盖 onClick 操作,并且不会打开弹出窗口,而是触发相应的事件
The answer by @1I111I1 was very useful for me, but the downside is that it would have the same behavior among all instances.
If you need special configuration per instance (for example each instance might have a different default path for its root directory), that would not be easy this way.
Also, a file manager would better know whether you want an image or a file because they would require a different view method (like thumbnail mode for image select).
So, I have edited it so that it would fire custom events for each instance based on the browse mode (image/link).
Now you can register for the appropriate event in each instance individually and then use the provided callback to return the selected value:
Also note that before all of this, you should activate the browse button with the configuration that is required for pop-up window mode, then this workaround will override the onClick action and instead of opening pop-ups it will fire the appropriate event
100%可能,而且其他人也在这么做。您可以看到此功能在 Mailchimp.com 上的 OP 请求中起作用,
“Matt Ball”已编辑问题并回答说这是不可能的,但他似乎不熟悉 CKEditor 和 CKFinder,而是认为 OP 想要使用浏览器的“浏览文件” - 但这显然不是OP正在寻找的。
OP 有一个文件浏览器,例如在弹出窗口中运行的 CKFinder。他希望将文件浏览器作为模式窗口调用,而不是作为弹出窗口调用。
我也在研究如何做到这一点,我怀疑它将涉及编辑 _source/plugins/image 下的文件并修改子浏览器(这是如何调用 CKFinder 的技术术语)以代替作为模式加载。这里的第一个问题是违反封装性,因为模式窗口的 Jquery 代码不属于 CKEditor 内...
It 100% is possible, and other people are doing it. You can see this feature working as the OP requests on Mailchimp.com
"Matt Ball" has edited the question and replied that it is not possible, but he seemingly is not familiar with CKEditor and CKFinder, and is instead thinking that the OP is wanting to use the browser's "browse file" - but that is clearly not what the OP is looking for.
The OP has a file browser such as CKFinder running within a popup window. Instead of invoking as a popup he would like to invoke the file browser as a modal window.
I am also looking at how to do this, and I suspect it will involve editing the files under _source/plugins/image and modifying the Child Browser (that's the technical term for how CKFinder is invoked) to instead load as a modal. The number one problem here is the violation of encapsulation, as Jquery code for modal windows does not belong within CKEditor...
我最近不得不做一些非常类似的事情,并决定自己解决。完成后,我给自己做了一个记录,以便回来发布解决方案。那是 3 个月前的事了,但这里是我所做的一个简化版本,它基本上是使用 ckeditor 的 browserServer 函数(也包含在下面)中的修改代码来覆盖 onClick 函数。
这是我从 ckeditor 文档中获得的 browserServer 函数,可以在这里找到 - http://docs .ckeditor.com/source/plugin33.html。
我希望这有帮助。抱歉我没有早点回答。
(注意:我使用的是 ckeditor 4.4.7,但我认为其他版本应该类似)
I had to do something very similar recently and decided to figure it out on my own. Once I did, I made myself a note to come back and post the solution. That was 3 months ago, but here is a simplified version of what I did, which was basically overriding the onClick function with modified code from ckeditor's browseServer function (included below as well).
Here is the browseServer function I got from the ckeditor docs, which can be found here - http://docs.ckeditor.com/source/plugin33.html.
I hope this helps. Sorry I didn't answer sooner.
(Note: I'm using ckeditor 4.4.7, but I assume it should be similar for other versions)
如果我明白你想做什么,那是不可能的。出于安全原因,浏览器中的 JavaScript 被沙箱化,因此它无法访问本地文件系统。
If I understand what you're trying to do, it's not possible. For security reasons, JavaScript in the browser is sandboxed so that it has no access to the local filesystem.