Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Define new command, my example is based on <a href="https://github.com/xing/wysihtml5/blob/master/src/commands/foreColor.js" rel="noreferrer">ForeColor</a>:</p> <pre><code>(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); </code></pre> <p>usage:</p> <p>HTML:</p> <pre><code>&lt;div id="uxToolbar"&gt; &lt;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"&gt; My class &lt;/button&gt; &lt;/div&gt; </code></pre> <p>so as you can see value is from two parts: <code>element:class</code></p> <p><a href="http://jsfiddle.net/oceog/nkkek/" rel="noreferrer">DEMO</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload