CkEditor,如何添加额外的菜单项在右键单击? [英] CkEditor, How to add additional menu item in right click?

查看:1655
本文介绍了CkEditor,如何添加额外的菜单项在右键单击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在CKeditor中,当我们右键单击图像时,会出现四个菜单项。

  cut 
copy
paste
图片属性

我想再添加两个菜单项,

  test1 
test2 - > test1将是一个菜单,test2将有两个子菜单。test1将是一个菜单,test2将有两个子菜单。



也请指导我如何添加操作到这个新的菜单项。例如,点击test1应该在右侧绘制边框。点击subtest2将添加图像阴影等。



除此之外。我想在div和桌子上点击clik时做类似的操作。



请帮助我。这是迫切的。我已经找到上下文菜单插件,但我需要知道如何使用这个?



感谢您的帮助

解决方案

我也遇到了这个问题。由于CKEditor的坏文档,我终于通过尝试不同的方式整个下午。
这段代码在我的网站上工作得很好 - Drupal 6& CKEditor 4。

  //假设我已经有3个命令
// insertTick,insertTickxxx和insertTickxxxandxxx

if(editor.addMenuItems){
//第一,添加菜单组
//提示:命名与插件相同。 (我不知道这个)
editor.addMenuGroup('tick',3);

//第二,使用addMenuItems添加项目
editor.addMenuItems({
// 2.1再次添加组,并给它getItems,返回所有子项目
tick:
{
label:'Insert Tick',
group:'tick',
order:21,
getItems:function $ b return {
tick_insertTick:CKEDITOR.TRISTATE_OFF,
tick_insertQuestionMark:CKEDITOR.TRISTATE_OFF,
tick_insertTickandQuestion:CKEDITOR.TRISTATE_OFF
};
}
}

// 2.2现在将子项添加到组中
tick_insertTick:
{
标签:'插入一个标记',
组: tick',
command:'insertTick',
order:22
},

tick_insertQuestionMark:
{
label:'Insert Question Mark',
group:'tick',
command:'insertQuestionMark',
order:23
},

tick_insertTickandQuestion:
{
label:'insert Tick and Question',
group:'tick',
command:'insertTickandQuestion',
order:24
}
});
}

//第三,添加Listener,并返回菜单组
if(editor.contextMenu){
editor.contextMenu.addListener(function(element,选择){
return {
tick:CKEDITOR.TRISTATE_OFF
};
});
}

,这将显示为



插入记号 - >插入记号



--------------插入问号



--------------插入勾号和问号


In CKeditor, when we right click on image, there are four menu items that appear.

cut
copy
paste
image properties

I would like to add two more menu items,

test1
test2 -> subtest2
         subtest3 

test1 will be one menu and test2 will have two sub menus.

also please guide me how can I add action to this new menu item. For example, click on test1 should draw a border on right side. clicking on subtest2 will add image shadow and so on.

in addition to this. I would like to do similar when we right clik on div and table.

Please help me. This is urgent. I have found context menu plugins but I need to know how can I use this?

Thanks for your help

解决方案

I met this problem, too. Thanks to the bad documentation of CKEditor, I finally make it by trying different ways the whole afternoon. This code works well on my site -- Drupal 6 & CKEditor 4.

// Assume I already Have 3 commands
// insertTick, insertTickxxx, and insertTickxxxandxxx

if (editor.addMenuItems) {
  // 1st, add a Menu Group
  // tip: name it the same as your plugin. (I'm not sure about this)
  editor.addMenuGroup('tick', 3);

  // 2nd, use addMenuItems to add items
  editor.addMenuItems({
      // 2.1 add the group again, and give it getItems, return all the child items
      tick :
      {
        label : 'Insert Tick',
        group : 'tick',
        order : 21,
        getItems : function() {
          return {
            tick_insertTick : CKEDITOR.TRISTATE_OFF,
            tick_insertQuestionMark : CKEDITOR.TRISTATE_OFF,
            tick_insertTickandQuestion : CKEDITOR.TRISTATE_OFF
          };
        }
      },

      // 2.2 Now add the child items to the group.
      tick_insertTick :
      {
        label : 'Insert a tick',
        group : 'tick',
        command : 'insertTick',
        order : 22
      },

      tick_insertQuestionMark :
      {
        label : 'Insert Question Mark',
        group : 'tick',
        command : 'insertQuestionMark',
        order : 23
      },

      tick_insertTickandQuestion :
      {
        label : 'insert Tick and Question',
        group : 'tick',
        command : 'insertTickandQuestion',
        order : 24
      }
  });
}

// 3rd, add Listener, and return the Menu Group
if (editor.contextMenu) {
  editor.contextMenu.addListener(function(element, selection) {
    return {
      tick : CKEDITOR.TRISTATE_OFF
    };
  });
}

and this will show like

Insert Tick -> Insert a tick

-------------- Insert a Question Mark

-------------- Insert a tick and question mark

这篇关于CkEditor,如何添加额外的菜单项在右键单击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆