如何禁用 CKEditor 上下文菜单?
有人知道如何禁用 CKEditor 的上下文(右键单击)菜单吗?我希望有一个配置选项,但我找不到。我正在使用 v3.1。谢谢。
Does anybody know how to disable CKEditor's context (right click) menu? I would expect a configuration option, but I can't find one. I am using v3.1. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(12)
可以完全禁用上下文菜单,将此行添加到您的配置文件(通常是 fckconfig.js):
It's possible to completely disable the context menu adding this line to your config file (tipically fckconfig.js):
从版本 3.6.4 开始,此问题中的其他答案不再有效。 查看 bug #9284
需要禁用的三个插件(使用本问题中讨论的方法) ,分别是
contextmenu
、liststyle
和tabletools
。例如,使用配置文件:As of version 3.6.4, the other answers in this question don't work anymore. See bug #9284
The three plugins that need to be disabled (using the means discussed in this question), are
contextmenu
,liststyle
andtabletools
. So for example, using config files:您需要删除
contextmenu
插件。请参阅此处了解 3.1。You need to remove the
contextmenu
plugin. See here for 3.1.Ckeditor
4.7.1
Ckeditor
4.8.0
('elementspath'插件不再需要删除)Ckeditor
4.7.1
Ckeditor
4.8.0
('elementspath' plugin no longer need to remove)还有一个实用的解决方案,通过重写初始化
contextmenu
行为的原型函数:注意:当 CKEDITOR 动态加载其 JS 资源时,您需要将其放在
replace
调用之前。There is still a practical solution, by overriding the prototype function that initializes
contextmenu
behavior:NOTE: when CKEDITOR loads its JS resources dynamically you need to place it right before the
replace
call.您可以在您站点的 F12 控制台窗口中使用以下代码片段来找出您的特定 CKEditor 版本中哪些插件需要
contextmenu
(假设您也有用于$.each
的 jQuery) ):例如:
,然后您可以使用它们来帮助您处理
config.removePlugins
- 在我的例子中:You can find out which plugins require
contextmenu
in your particular build of CKEditor using the following snippet in an F12 console window in your site (assumes you have jQuery also for$.each
):For example:
Which you can then use to help you with your
config.removePlugins
- in my case:我需要禁用以下所有功能才能使其正常工作。
以前我们不需要语言或表大小调整 - 但较新版本的 ckeditor 似乎需要这样做。
我在查看 chrome 上 F12 开发工具的输出时发现了这一点。
I needed to disable all of the following to get this to work.
Previously we did not need language or tableresize - but a newer version of ckeditor seems to require that.
I discovered this in looking at the output in F12 dev tools on chrome.
按住 ctrl 按钮的同时右键单击可绕过上下文菜单并访问拼写检查器等。
Hold down the ctrl button while right clicking to by-pass the context menu and access spell checker etc.
对于 4.2 版本,我将以下内容放在 config.js 文件的末尾
For version 4.2, I put the following at the end of my config.js file
使用 CKEditor 3.6,我可以通过删除上面建议的 contextmenu 插件来禁用上下文菜单。
为此,您必须使用removePlugins 选项配置编辑器。
例如:
也可以从 config.js 文件全局禁用它:
With CKEditor 3.6 I was able to disable context menu by removing the contextmenu plugin as suggested above.
To do this, you have to configure the editor with the removePlugins option.
For instance:
It can also be disabled globally from the config.js file:
不幸的是,从 CKEditor 3.6/4.0 开始,这个功能不再起作用了。
请参阅错误报告:http://dev.ckeditor.com/ticket/9284
Unfortunately since CKEditor 3.6/4.0 this does not work anymore.
See bug report: http://dev.ckeditor.com/ticket/9284
在 CKEditor 4.x 中(我测试了 4.2.2),您必须执行以下两项操作:
CKEDITOR.replace('my_editor', {
删除插件:'上下文菜单'
});
如果
您不禁用它们,所有这三个都将自动需要上下文菜单。
In CKEditor 4.x, (I tested 4.2.2) you must do both:
CKEDITOR.replace('my_editor', {
removePlugins : 'contextmenu'
});
And
All three of those will automatically require contextmenu if you don't disable them.