How to disable CKEditor context menu?

前端 未结 12 1418
梦毁少年i
梦毁少年i 2020-12-09 03:34

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.

相关标签:
12条回答
  • 2020-12-09 04:21

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

    FCKConfig.ContextMenu = [];
    
    0 讨论(0)
  • 2020-12-09 04:22

    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';
    };
    
    0 讨论(0)
  • 2020-12-09 04:22

    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.

    0 讨论(0)
  • 2020-12-09 04:27

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

    0 讨论(0)
  • 2020-12-09 04:27

    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.

    0 讨论(0)
  • 2020-12-09 04:28

    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;
    }
    
    0 讨论(0)
提交回复
热议问题