2016-05-23 86 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'); 
      } 
相關問題