2014-11-14 65 views
1

我試圖從WordPress中的TinyMCE下拉工具欄按鈕中刪除子項目。刪除TinyMCE 4中的子菜單項4

該按鈕是一個插件按鈕(TinyMCE Table Button),它插入一個項目,允許用戶在表格上執行CSS樣式。

TinyMCE plugin generated dropdown

Taulukon ominaisuudet == 表屬性)的菜單項與

editor.addMenuItem('tableprops', { 
    text: 'Table properties', 
    context: 'table', 
    onPostRender: postRender, 
    onclick: dialogs.tableProps 
}); 
創建

工具欄按鈕與

editor.addButton("table", { 
    type: "menubutton", 
    title: "Table", 
    menu: menuItems 
}); 

創建210

editor是TinyMCE的插件構造PARAM:

define("tinymce/tableplugin/Plugin", [ 
    "tinymce/tableplugin/TableGrid", 
    ... 
    "tinymce/PluginManager" 
], function(TableGrid, Quirks, CellSelection, Dialogs, Tools, TreeWalker, Env, PluginManager) { 
    var each = Tools.each; 

    function Plugin(editor) { 
     var clipboardRows, self = this, dialogs = new Dialogs(editor); 

     ... 

的編輯器爲addMenuItem的功能,但我找不到類似removeMenuItem什麼。我也嘗試在編輯器中找到菜單項,以便我可以手動將其刪除,但是系統對於按鈕和菜單的位置有點陰影。

是否有刪除TinyMCE中菜單項的邏輯方法,或者在編輯器生成後,是否必須直接從DOM中刪除它?

回答

3

更新:只要意識到,你正在使用不同的表插件。我想一個簡單的方法是檢查元素/源並獲取該菜單項的元素ID並使用CSS來隱藏它。

<style> 
#mceu_38 {display:none !important;} 
</style> 

下面是我原來的響應,它是爲編輯默認菜單欄


您可以自定義菜單欄在init函數:

tinymce.init({ 
    selector: "textarea", 
    menu : { // this is the complete default configuration 
     file : {title : 'File' , items : 'newdocument'}, 
     edit : {title : 'Edit' , items : 'undo redo | cut copy paste pastetext | selectall'}, 
     insert : {title : 'Insert', items : 'link media | template hr'}, 
     view : {title : 'View' , items : 'visualaid'}, 
     format : {title : 'Format', items : 'bold italic underline strikethrough superscript subscript | formats | removeformat'}, 
     table : {title : 'Table' , items : 'inserttable deletetable | cell row column'}, 
     tools : {title : 'Tools' , items : 'spellchecker code'} 
    },  
    plugins: [ 
     "advlist autolink lists link image charmap print preview anchor", 
     "searchreplace visualblocks code fullscreen", 
     "insertdatetime media table contextmenu paste" 
    ], 
    toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image" 
}); 

只需刪除每個菜單屬性中不需要的項目。

下面是用表格屬性的示例中刪除: http://fiddle.tinymce.com/43eaab

這裏的文檔:http://www.tinymce.com/wiki.php/Configuration:menu

GL。

+0

是的,它是第三方插件,因爲WordPress不包括表格功能。我寧願不直接使用'#id {display:none; }隱藏,因爲ID可能隨機改變。目前,我已經決定在輸出HTML本身時使用PHP'preg_replace'來解析和刪除所有表格屬性。感謝'init'的提示,我會看看我能否從中得到任何東西。 – ojrask 2014-11-17 06:21:04

+0

只是好奇,你使用哪個插件的表功能? – 2014-11-17 15:03:23

+0

在WP回購中,它被稱爲* TinyMCE表格按鈕*,除非我非常錯誤。 – ojrask 2014-11-17 15:07:24