javascript 删除 TinyMCE 中的上下文菜单

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9509082/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 06:55:29  来源:igfitidea点击:

Remove the Context Menu in TinyMCE

javascripttinymce

提问by Chris Schuld

TinyMCE has a built-in contextmenu which activates when you right-click in the content editor area. I need to remove this menu due to the copy/cut/paste in the menu. It for an application specific reason and less of a technical reason.

TinyMCE 有一个内置的上下文菜单,当您右键单击内容编辑器区域时会激活该菜单。由于菜单中的复制/剪切/粘贴,我需要删除此菜单。它出于特定于应用程序的原因而不是技术原因。

enter image description here

在此处输入图片说明

I have attempted to remove the contextmenu plugin as well as attempt to catch the contextmenu event and trap it without luck.

我试图删除 contextmenu 插件以及尝试捕获 contextmenu 事件并在没有运气的情况下捕获它。

回答by Thariama

The easy solution is to remove the contextmenu plugin in your tinymce init:

简单的解决方案是删除 tinymce init 中的 contextmenu 插件:

 plugins : "inlinepopups,insertdatetime,fullscreen,contextmenu",

becomes

变成

 plugins : "inlinepopups,insertdatetime,fullscreen",

回答by Anton Kostiuchkov

In version 5, context menu is built in the core. This has helped me:

在第 5 版中,上下文菜单内置于核心中。这对我有帮助:

tinymce.init({
    ...
    contextmenu: false,
    ...
});

回答by Dr.Molle

Try to remove the complete script in plugins/contextmenu/editor.plugin.js(It's only 1 line so it's sufficient to put 2 slashes at the start).

尝试删除plugins/contextmenu/editor.plugin.js中的完整脚本(它只有 1 行,因此在开头放置 2 个斜杠就足够了)。

It works for me, the contextmenu no longer appears.

它对我有用,上下文菜单不再出现。

回答by SkarXa

Commenting this line in /plugins/contextmenu/editor_plugin.jsworked for me:

评论这一行/plugins/contextmenu/editor_plugin.js对我有用:

f.addSeparator();f.add({title:"advanced.image_desc",icon:"image",cmd:h.plugins.advimage?"mceAdvImage":"mceImage",ui:true});

If for any reason you use the non-minified js, comment this:

如果出于任何原因您使用非缩小的 js,请对此发表评论:

m.addSeparator();
m.add({title : 'advanced.image_desc', icon : 'image', cmd : ed.plugins.advimage ? 'mceAdvImage' : 'mceImage', ui : true});