2013-07-11 32 views
1

我已經解決了我的部分幾乎添加一個按鈕。如何添加一個新的按鈕在tinymce

setup : function(ed) { 
    // Add a custom button 
    ed.addButton('Information', { 
     title : 'Viktig Information', 
     image : '../img/page_white_text.png', 
     onclick : function() { 
      // Add you own code to execute something on click 
      ed.focus(); 
      ed.selection.setContent('Text here'); 
    } 
    }); 
} 

但現在我想知道如何讓這個工作像他們大膽的按鈕和東西?所以,當我按大膽的文字變得粗體..

我想與我的按鈕相同,當我按我的按鈕,我想div出現。任何人都知道我能做到這一點?!

+0

你是用tinymce 3還是4? – Thariama

+0

Iam使用版本3 – Tommy

+0

+1好問題 – Thariama

回答

0

這是執行一件容易的事。 只需在編輯器初始化函數中添加這樣的內容即可。 也看到這個page of moxycode了。

tinyMCE.init({ 
    ... 
    theme_advanced_buttons1: 'bold,italic,..' 

    setup: function(ed) { 

     ed.onInit.add(function(ed) { 
     // Scroll runter 
     ed.addCommand('my_own_command', function() { 
      alert('my_own_command called!'); 
     }); 
     }); 

     // Register example button 
     ed.addButton('example', { 
     title: 'example.desc', 
     // make sure the image exists 
     image: '../jscripts/tiny_mce/plugins/example/img/example.gif', 
     onclick: function() { 
      ed.windowManager.alert('Hello world!!'); 
      // execute my_own_command 
      ed.execCommand('my_own_command'); 
     } 
     }); 
    }, // end setup 
    ... 
}); 
+0

這部分我已經解決,但我希望它像粗體文本,所以它增加了文字 Tommy

+0

看到我更新的帖子 – Thariama

+0

我怎樣才能使自己的命令?像大膽? – Tommy

相關問題