Remove the Context Menu in TinyMCE

2020-02-13 07:50发布

问题:

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.

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

回答1:

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

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

becomes

 plugins : "inlinepopups,insertdatetime,fullscreen",


回答2:

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

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


回答3:

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

It works for me, the contextmenu no longer appears.



回答4:

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

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:

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