如何禁用 CKEditor 上下文菜单?

发布于 2024-08-21 08:51:33 字数 70 浏览 5 评论 0原文

有人知道如何禁用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(12

独木成林 2024-08-28 08:51:34

可以完全禁用上下文菜单,将此行添加到您的配置文件(通常是 fckconfig.js):

FCKConfig.ContextMenu = [];

It's possible to completely disable the context menu adding this line to your config file (tipically fckconfig.js):

FCKConfig.ContextMenu = [];
○闲身 2024-08-28 08:51:33

从版本 3.6.4 开始,此问题中的其他答案不再有效。 查看 bug #9284

需要禁用的三个插件(使用本问题中讨论的方法) ,分别是 contextmenuliststyletabletools。例如,使用配置文件:

CKEDITOR.editorConfig = function(config) {
    /* Your config options */
    ...
    config.removePlugins = '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 and tabletools. So for example, using config files:

CKEDITOR.editorConfig = function(config) {
    /* Your config options */
    ...
    config.removePlugins = 'contextmenu,liststyle,tabletools';
};
美人骨 2024-08-28 08:51:33

您需要删除 contextmenu 插件。请参阅此处了解 3.1。

You need to remove the contextmenu plugin. See here for 3.1.

过度放纵 2024-08-28 08:51:33

Ckeditor 4.7.1

CKEDITOR.editorConfig = function (config) {
  config.language = 'en';
  config.toolbar = "mini";
  config.removePlugins = 'elementspath,contextmenu,liststyle,tabletools,tableselection';
  config.disableNativeSpellChecker = false;
}

Ckeditor 4.8.0 ('elementspath'插件不再需要删除)

CKEDITOR.editorConfig = function (config) {
  config.language = 'en';
  config.toolbar = "mini";
  config.removePlugins = 'contextmenu,liststyle,tabletools,tableselection';
  config.disableNativeSpellChecker = false;
}

Ckeditor 4.7.1

CKEDITOR.editorConfig = function (config) {
  config.language = 'en';
  config.toolbar = "mini";
  config.removePlugins = 'elementspath,contextmenu,liststyle,tabletools,tableselection';
  config.disableNativeSpellChecker = false;
}

Ckeditor 4.8.0 ('elementspath' plugin no longer need to remove)

CKEDITOR.editorConfig = function (config) {
  config.language = 'en';
  config.toolbar = "mini";
  config.removePlugins = 'contextmenu,liststyle,tabletools,tableselection';
  config.disableNativeSpellChecker = false;
}
月下凄凉 2024-08-28 08:51:33

还有一个实用的解决方案,通过重写初始化 contextmenu 行为的原型函数:

CKEDITOR.dom.element.prototype.disableContextMenu = function () {
    this.on( 'contextmenu', function( event ) {
        // your contextmenu behavior
    });
};

注意:当 CKEDITOR 动态加载其 JS 资源时,您需要将其放在 replace 调用之前。

There is still a practical solution, by overriding the prototype function that initializes contextmenu behavior:

CKEDITOR.dom.element.prototype.disableContextMenu = function () {
    this.on( 'contextmenu', function( event ) {
        // your contextmenu behavior
    });
};

NOTE: when CKEDITOR loads its JS resources dynamically you need to place it right before the replace call.

晚雾 2024-08-28 08:51:33

您可以在您站点的 F12 控制台窗口中使用以下代码片段来找出您的特定 CKEditor 版本中哪些插件需要 contextmenu(假设您也有用于 $.each 的 jQuery) ):

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

例如:

插件“tabletools”需要表格、对话框、上下文菜单

,然后您可以使用它们来帮助您处理 config.removePlugins - 在我的例子中:

config.removePlugins = 'tabletools,contextmenu'

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):

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

For example:

Plugin 'tabletools' requires table,dialog,contextmenu

Which you can then use to help you with your config.removePlugins - in my case:

config.removePlugins = 'tabletools,contextmenu'
锦欢 2024-08-28 08:51:33

我需要禁用以下所有功能才能使其正常工作。

config.removePlugins = 'language,tableresize,liststyle,tabletools,scayt,menubutton,contextmenu';

以前我们不需要语言或表大小调整 - 但较新版本的 ckeditor 似乎需要这样做。

我在查看 chrome 上 F12 开发工具的输出时发现了这一点。

I needed to disable all of the following to get this to work.

config.removePlugins = 'language,tableresize,liststyle,tabletools,scayt,menubutton,contextmenu';

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.

君勿笑 2024-08-28 08:51:33

按住 ctrl 按钮的同时右键单击可绕过上下文菜单并访问拼写检查器等。

Hold down the ctrl button while right clicking to by-pass the context menu and access spell checker etc.

对你再特殊 2024-08-28 08:51:33

对于 4.2 版本,我将以下内容放在 config.js 文件的末尾

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

For version 4.2, I put the following at the end of my config.js file

CKEDITOR.on('instanceReady', function(ev) {
   ev.editor.editable().addClass('cke_enable_context_menu')
});
征棹 2024-08-28 08:51:33

使用 CKEditor 3.6,我可以通过删除上面建议的 contextmenu 插件来禁用上下文菜单。
为此,您必须使用removePlugins 选项配置编辑器。
例如:

CKEDITOR.replace('my_editor', {
    removePlugins : 'contextmenu'
});

也可以从 config.js 文件全局禁用它:

CKEDITOR.editorConfig = function(config) {
    /* Your config options */
    ...
    config.removePlugins = 'contextmenu';
};

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:

CKEDITOR.replace('my_editor', {
    removePlugins : 'contextmenu'
});

It can also be disabled globally from the config.js file:

CKEDITOR.editorConfig = function(config) {
    /* Your config options */
    ...
    config.removePlugins = 'contextmenu';
};
黯然 2024-08-28 08:51:33

不幸的是,从 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

剪不断理还乱 2024-08-28 08:51:33

在 CKEditor 4.x 中(我测试了 4.2.2),您必须执行以下两项操作:

CKEDITOR.replace('my_editor', {
删除插件:'上下文菜单'
});

如果

CKEDITOR.editorConfig = function(config) {
/* Your config options */
...
config.removePlugins = ''liststyle,tabletools,contextmenu'';
};

您不禁用它们,所有这三个都将自动需要上下文菜单。

In CKEditor 4.x, (I tested 4.2.2) you must do both:

CKEDITOR.replace('my_editor', {
removePlugins : 'contextmenu'
});

And

CKEDITOR.editorConfig = function(config) {
/* Your config options */
...
config.removePlugins = ''liststyle,tabletools,contextmenu'';
};

All three of those will automatically require contextmenu if you don't disable them.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文