Redactor / Documentation / API

Button

get #

Accessing toolbar button element by key.

var button = this.button.get('bold');

add #

Adds button at the end of toolbar. Returns button element.

var button = this.button.add('my-button', 'My Button');

addFirst #

Adds button at the beginning of toolbar. Returns button element.

var button = this.button.addFirst('my-button', 'My Button');

addAfter #

Adds button after specified button. Returns button element.

var button = this.button.addAfter('bold', 'my-button', 'My Button');

addBefore #

Adds button before specified button. Return button element.

var button = this.button.addBefore('bold', 'my-button', 'My Button');

addCallback #

Applies callback to added button.

var button = this.button.add('my-button', 'My Button');
this.button.addCallback(button, function()
{
    // your code
});

addDropdown #

Adds dropdown to a button.

var button = this.button.add('my-button', 'My Button');

var dropdown = {
    item1: { title: 'Item 1', func: function() { // your code } },
    item2: { title: 'Item 2', func: function() { // your code } }
};

this.button.addDropdown(button, dropdown);

remove #

Removes specified button from toolbar.

this.button.remove('my-button');

set #

Change button title.

this.button.set('image', 'Upload image');

setIcon #

Set icon as a toolbar button.

this.button.setIcon('image', '<i class="fa fa-cog"></i>');

all #

This method returns an array of all toolbar buttons.

	var buttons = this.button.all();

disableAll #

Using this method, all toolbar buttons can be disabled at once. A specific button can be passed as an argument and this button will be excluded from disabling.

	this.button.disableAll();	

enableAll #

This method removes disabled status from all toolbar buttons.
this.button.enableAll();

getButtons #

Returns a set of elements of all buttonsd in toolbar.

var buttons = this.button.getButtons();

getButtonsKeys #

Returns buttons' keys array.

var keys = this.button.getButtonsKeys();