You can do it like this:
tinymce.init({
selector: "textarea",
toolbar: "customFormat",
setup: function(editor) {
editor.addButton('customFormat', {
text: 'My custom formatting',
icon: false,
onclick: function() {
// Add the custom formatting
editor.formatter.toggle('custom_caption');
}
});
}
});
update
Have a look at this fiddle
I gues this is what you want. With this fiddle you can select some text, hit the My Custom Formatting
button, and the text will be surrounded with a <span class="caption">
.