在版本4.4.6中禁用ckeditor上下文菜单 [英] Disable ckeditor context menu in version 4.4.6

查看:86
本文介绍了在版本4.4.6中禁用ckeditor上下文菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Rails4项目中使用ckeditor。我已经尝试了ckeditor gem和ckeditor_rails gem来提供ckeditor库。

I am using ckeditor in a Rails4 project. I have tried both the ckeditor gem and the ckeditor_rails gem to provide the ckeditor libraries.

这里有很多人希望删除ckeditor上下文菜单,以便本机可以显示浏览器上下文菜单。

There are multiple posts here by people wanting to remove the ckeditor context menu so that the native browser context menu can be displayed.

通常是为了使浏览器可以使用拼写检查器,而不是使用ckeditor付费/广告的拼写检查器。

This is usually to enable the browser spellchecker to be used rather than the ckeditor paid / advertised spellchecker.

how-to-remove-contextmenu-in -ckeditor-4-3

ckeditor-3-6-3-enable-browser-spellcheck-and-disable-contextmenu

how-to-disable-ckeditor-context-menu / 20229730#20229730

第三个链接代表最多,但没有一个被普遍接受。
通常,答复是通过将以下内容放在ckeditor config.js中来删除contextmenu插件

The third link has the most replies but none of them are universally accepted. Generally the reply is to remove the contextmenu plugin by placing the following in the ckeditor config.js

config.removePlugins = 'contextmenu';

也有人建议contextmenu依赖于其他插件,不同的人会添加许多其他插件

There is also the suggestion that contextmenu is a dependency on other plugins and different people add a multitude of other plugins to be removed as well.

一个有用的帖子建议在控制台中运行以下代码以建立依赖关系。

One helpful post suggests running the following code in the console to establish the dependencies.

$.each(CKEDITOR.plugins, function(k, v){ 
    v.requires && console.log("Plugin '" + k + "' requires: " + v.requires) 
})

建议tabletools和liststyle插件依赖于contextmenu。因此,我们最终得到

This seems to work well and suggests that tabletools and liststyle plugin is dependent on contextmenu. So we end up with

config.removePlugins = 'liststyle,tabletools,contextmenu';

不幸的是,这不会禁用我正在使用的ckeditor版本中的上下文菜单(4.4.6通过在config.js中添加alert(CKEDITOR.version)建立。

Unfortunately this does not disable the context menu in the version of ckeditor that I am using (4.4.6 established by adding alert(CKEDITOR.version) in the config.js)

最后,建议在config.js中使用以下代码

Finally there is a suggestion to use the following code in config.js

CKEDITOR.on('instanceReady', function(ev) {
   ev.editor.editable().addClass('cke_enable_context_menu')
});

对于如何禁用上下文菜单没有任何建议,但是无论如何都会使对我来说没什么区别。

There is no suggestion as to how this is meant to disable the context menu but in any case it makes no difference for me.

对我来说,这是一个亮点,因为ckeditor上下文菜单隐藏了浏览器的拼写建议,并且其中包含的剪切和粘贴选项实际上并不起作用,而仅仅是

For me this is a showstopper as the ckeditor context menu hides the browser spelling suggestions and the cut and paste options it contains do not actually work but just bring up the browser dialog.


您的浏览器安全设置不允许编辑器
自动执行复制操作。请使用(Ctrl / Cmd + C)的
键盘。

Your browser security settings don't permit the editor to automatically execute copying operations. Please use the keyboard for that (Ctrl/Cmd+C).

在所有其他方面,ckeditor似乎确实是

In all other aspects ckeditor does seem to be the best functioning editor out there.

推荐答案

在我的Drupal 7环境中,从CDN加载ckeditor,当前版本为4.11.4 。
在许多失败的替代方法之后,唯一对我有用的东西:

In my Drupal 7 environment, loading ckeditor from the CDN, current version is 4.11.4. The only thing that worked for me after many failed alternatives:

config.removePlugins = 'liststyle,tableselection,tabletools,tableresize,contextmenu';

为了方便起见,我将其放在模块配置设置->高级->自定义JavaScript配置中,但是以我的经验,可以在模块文件夹中的ckeditor.config.js文件中获得相同的结果。
(更新模块时,它很可能会被意外覆盖。...您也可以通过选中在主题中使用config.js文件的选项,然后在上面添加一行来实现此目的文件。)

For convenience, I put this in the module configuration settings -> Advanced -> Custom JavaScript configuration, but in my experience the same result can be achieved in the ckeditor.config.js file in the module folder. (It's just more likely to get accidentally overwritten there, when updating the module. ... you could also do it by checking the option to use the config.js file in your theme and then adding the line above to that file.)

这篇关于在版本4.4.6中禁用ckeditor上下文菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆