Documentation

Context

add

Arguments
name String
button Object

Adds a button to the context bar. The context bar appears when the context setting is enabled and text is selected.

RedactorX.add('plugin', 'myplugin', {
    start: function() {
        this.app.context.add('mybutton', {
            title: 'My Button',
            icon: '<i class="fa fa-file-alt"></i>',
            command: 'myplugin.toggle'
        });
    },
    toggle: function(params, button) {
        // do something
    }
});

In this example, Font Awesome is used for the button icon. You can add your own HTML and SVG icon.

Now call the editor with the plugin created:

RedactorX('#entry', {
    plugins: ['myplugin']
});

The button should appear in the context bar when you select text. The button click will call the plugin's toggle method.

See more about the parameters of the buttons.