There are several toolbars in the editor and for each of them you can change the default layout of the buttons.
// default
['add', 'ai-tools', 'html', 'format', 'bold', 'italic', 'deleted', 'moreinline', 'list', 'link', 'image']
// changed
Redactor('#entry', {
buttons: {
toolbar: ['add', 'bold', 'italic', 'deleted', 'moreinline', 'link', 'image']
}
});
// default
['hotkeys']
// changed
Redactor('#entry', {
buttons: {
extrabar: ['undo', 'redo', 'hotkeys']
}
});
// default
['ai-tools', 'format', 'bold', 'italic', 'deleted', 'moreinline', 'link']
// changed
Redactor('#entry', {
buttons: {
context: ['ai-tools', 'bold', 'italic', 'deleted', 'highlight', 'sub', 'sup', link']
}
});
There are several dropdowns in the editor and for each of them you can change the default layout of the buttons.
// default
['ai-tools', 'ai-image', 'text', 'heading', 'image', 'todo', 'list', 'embed', 'table', 'quote', 'pre', 'line', 'layout', 'wrapper']
// changed
Redactor('#entry', {
popups: {
addbar: ['ai-tools', 'ai-image', 'text', 'heading', 'image', 'list']
}
});
// default
['add', 'move-up', 'move-down', 'duplicate', 'trash']
// changed
Redactor('#entry', {
popups: {
control: ['add', 'duplicate', 'trash']
}
});
// default
['text', 'h1', 'h2', 'h3', 'h4', 'quote', 'bulletlist', 'numberedlist', 'todo']
// changed
Redactor('#entry', {
popups: {
format: ['text', 'h1', 'h2', 'h3', 'h4', 'h5']
}
});
// default
['code', 'underline', 'sup', 'sub', 'highlight', 'removeinline']
// changed
Redactor('#entry', {
popups: {
inline: ['code', 'underline', 'removeinline']
}
});
Use the corresponding add setting for each toolbar to add a button to it from the default ones in the editor.
let app = Redactor('#entry', {
toolbar: {
add: {
line: true
}
}
});
Use the API to add a button in the created plugin.
Redactor.add('plugin', 'myplugin', {
start() {
// 1) default button
this.app.toolbar.add('quote');
// 2) custom button
this.app.toolbar.add('mybutton', {
title: 'My Button',
icon: '<svg...>',
command: 'myplugin.toggle'
});
},
toggle(params, button) {
alert('Button Toggle');
}
});
let app = Redactor('#entry', {
plugins: ['myplugin']
});
Use the corresponding hide setting for each toolbar to hide a button from it of the default ones in the editor.
let app = Redactor('#entry', {
toolbar: {
hide: ['deleted']
}
});
Use the API to hide a button from a toolbar in the created plugin.
Redactor.add('plugin', 'myplugin', {
start() {
// remove button from a plugin
this.app.toolbar.remove('list');
}
});
let app = Redactor('#entry', {
plugins: ['myplugin']
});
Use the 'buttons.icons' setting to change the button icons.
let app = Redactor('#entry', {
buttons: {
icons: {
image: '<svg...>',
format: '<svg...>'
}
}
});