Add button

First, to add button to the toolbar from the additional set you can use the buttonsAdd option, like this:


$R('#content', {
    buttonsAdd: ['underline', 'line', 'undo']
});

// the full additional set of buttons, that is:
'line', 'redo', 'undo', 'underline', 'ol', 'ul', 'indent', 'outdent', 'sup', 'sub'

The second way is to create a plugin. See the demo and its code.


Code

<!--element -->
<textarea id="content"></textarea>

<!-- plugin code -->
<script>
(function($R)
{
    $R.add('plugin', 'mybutton', {
        translations: {
            en: {
                "mybutton": "My Button"
            }
        },
        init: function(app)
        {
            this.app = app;
            this.lang = app.lang;
            this.toolbar = app.toolbar;
        },
        start: function()
        {
            // create the button data
            var buttonData = {
                title: this.lang.get('mybutton'),
                api: 'plugin.mybutton.toggle'
            };

            // create the button
            var $button = this.toolbar.addButton('mybutton', buttonData);
        },
        toggle: function()
        {
            alert('My Button is toggled!');
        }
    });
})(Redactor);
</script>

<!-- call -->
<script>
$R('#content', { plugins: ['mybutton'] });
</script>