Access to the Dom of the toolbar element.
let $toolbar = this.app.toolbar.getElement();
let $nodes = $toolbar.find('a');
Arguments:
String
Disables all button on the toolbar.
this.app.toolbar.disable();
Disables the specified button.
this.app.toolbar.disable('mybutton');
Arguments:
String
Enables all button on the toolbar.
this.app.toolbar.enable();
Enables the specified button if it was disabled.
this.app.toolbar.enable('mybutton');
Arguments:
String
Sets the toggle state to the button.
this.app.toolbar.setToggled('mybutton');
Arguments:
String
Removes the toggle state from the button.
this.app.toolbar.unsetToggled('mybutton');
Arguments:
String
Sets the active state to the button.
this.app.toolbar.setActive('mybutton');
Arguments:
String
Removes the active state from the button.
this.app.toolbar.unsetActive('mybutton');
Arguments:
String
Object
Adds a button to the toolbar.
Redactor.add('plugin', 'myplugin', {
start() {
this.app.toolbar.add('mybutton', {
title: 'My Button',
icon: '<svg...>',
command: 'myplugin.toggle'
});
},
toggle(args) {
// 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:
Redactor('#entry', {
plugins: ['myplugin']
});
The button should appear on the toolbar when you click on any block and when it pressed, will call the plugin's toggle
method.
See more about the parameters of the buttons.
Checks if the toolbar is sticked.
let is = this.app.toolbar.isSticky();