1

我几乎已经解决了添加按钮的问题。

    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 出现。任何人都知道我该怎么做?!

4

2 回答 2

0

初始化 TinyMCE 时,您可以指定哪些按钮位于哪一行。

这是一些文档

http://www.tinymce.com/wiki.php/Configuration3x:theme_advanced_buttons_1_n

于 2013-07-11T20:46:16.110 回答
0

这是一项容易执行的任务。只需将这样的内容添加到您的编辑器初始化函数中即可。也请参阅此页面的 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
    ...
}); 
于 2013-07-12T09:29:03.233 回答