Define new command, my example is based on ForeColor:
(function(wysihtml5) {
wysihtml5.commands.setClass = {
exec: function(composer, command, element_class) {
element_class=element_class.split(/:/);
element=element_class[0];
newclass=element_class[1];
var REG_EXP = new RegExp(newclass,'g');
//register custom class
wysihtml5ParserRules['classes'][newclass]=1;
return wysihtml5.commands.formatInline.exec(composer, command, element, newclass, REG_EXP);
},
state: function(composer, command, element_class) {
element_class=element_class.split(/:/);
element=element_class[0];
newclass=element_class[1];
var REG_EXP = new RegExp(newclass,'g');
return wysihtml5.commands.formatInline.state(composer, command, element, newclass, REG_EXP);
}
};
})(wysihtml5);
usage:
HTML:
<div id="uxToolbar">
<button data-wysihtml5-command="setClass" data-wysihtml5-command-value="span:my-wysihtml5-custom-class" type="button" title="View HTML" tabindex="-1" class="btn btn-mini">
My class
</button>
</div>
so as you can see value is from two parts: element:class
DEMO