2016-05-23 262 views
1

我尝试在TinyMCE中创建一个自定义上下文菜单。TinyMCE 4.X:添加对齐选项到上下文菜单

contextmenu:"cut copy paste | alignment" 

和“对齐”像

tinymce.PluginManager.add('context_menu',function(editor) { 
    editor.addMenuItem('alignment', { 
     text: 'Alignment', 
     menu:[{text: 'Left', icon: 'alignleft', cmd: 'alignleft'}, 
      {text: 'Center', icon: 'aligncenter', cmd: 'aligncenter'}, 
      {text: 'Right', icon: 'alignright', cmd: 'alignright'}, 
      {text: 'Justify', icon: 'alignjustify', cmd: 'alignjustify'}], 
     context:'alignment' 
    }); 
}); 

代码给人以对齐选项的上下文菜单,但是当我的ALIGN单击左/右/辩解似乎没有任何working.The文本不对齐根据命令。我尝试了“cmd”和“格式”选项,但没有任何工作。

回答

1

我从TinyMCE文档中找到了答案。在这里,我们走了,我们只需要用火的execCommand编辑器,而不是CMD一个onclick事件,并命令将

证明左边,中间对齐,证明右边,JustifyFull

onclick: function() { 
       editor.execCommand('JustifyLeft'); 
      } 
相关问题