代码之家  ›  专栏  ›  技术社区  ›  Upperstage

如何禁用ckeditor上下文菜单?

  •  19
  • Upperstage  · 技术社区  · 15 年前

    有人知道如何禁用Keckeditor的上下文(右键单击)菜单吗?我希望有一个配置选项,但找不到。我正在使用v3.1。谢谢。

    12 回复  |  直到 6 年前
        1
  •  14
  •   Pekka    15 年前

    你需要移除 contextmenu 插件。见 here 3.1。

        2
  •  36
  •   Alex Turpin    12 年前

    从3.6.4版开始,这个问题的其他答案不再有效。 See bug #9284

    需要禁用的三个插件(使用本问题中讨论的方法)是 contextmenu , liststyle tabletools . 例如,使用配置文件:

    CKEDITOR.editorConfig = function(config) {
        /* Your config options */
        ...
        config.removePlugins = 'contextmenu,liststyle,tabletools';
    };
    
        3
  •  3
  •   rusllonrails    7 年前

    克分子 4.7.1

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

    克分子 4.8.0 ('elementspath'插件不再需要删除)

    CKEDITOR.editorConfig = function (config) {
      config.language = 'en';
      config.toolbar = "mini";
      config.removePlugins = 'contextmenu,liststyle,tabletools,tableselection';
      config.disableNativeSpellChecker = false;
    }
    
        4
  •  2
  •   Tim    10 年前

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

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

    以前,我们不需要语言或表格调整大小——但是更新版本的ckeditor似乎需要这样做。

    我在查看f12 dev tools on chrome中的输出时发现了这一点。

        5
  •  2
  •   I.G. Pascual    10 年前

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

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

    注意:当ckeditor动态加载其JS资源时,需要将其放在 replace 打电话。

        6
  •  1
  •   user1337053    11 年前

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

    CKEDITOR.on('instanceReady', function(ev) {
       ev.editor.editable().addClass('cke_enable_context_menu')
    });
    
        7
  •  1
  •   Duncan Smart    10 年前

    你可以找出哪些插件需要 contextmenu 在您的特定版本的ckeditor中,在站点的f12控制台窗口中使用以下代码段(假设您还具有jquery for $.each ):

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

    例如:

    插件“tabletools”需要table、dialog、contextmenu

    你可以用它来帮助你 config.removePlugins -在我的例子中:

    config.removePlugins = 'tabletools,contextmenu'
    
        8
  •  0
  •   Jonathan Pasquier    12 年前

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

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

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

    CKEDITOR.editorConfig = function(config) {
        /* Your config options */
        ...
        config.removePlugins = 'contextmenu';
    };
    
        9
  •  0
  •   Avatar    12 年前

    不幸的是,由于CKeditor 3.6/4.0,这不再有效。

    见错误报告: http://dev.ckeditor.com/ticket/9284

        10
  •  0
  •   sheldonkreger    11 年前

    在ckeditor 4.x中,(我测试了4.2.2),您必须同时执行以下操作:

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

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

    如果不禁用它们,这三个都将自动需要ContextMenu。

        11
  •  0
  •   Anand Mishra    10 年前

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

    FCKConfig.ContextMenu = [];
    
        12
  •  0
  •   Andy    6 年前

    按住ctrl按钮,同时右键单击以旁路上下文菜单和访问拼写检查器等。