MultiFormat BBcodes

Quite often, websites are used BB codes that have multiple spellings. Often, this BB Code for quote. Usually he has such options insert:

[quote]text[/quote]
[quote=Author]text[/text]

The second option is usually inserted when you press the "Insert quote".

In WysiBB designed to handle such BB codes. Suppose that in the first case, HTML code looks like this:

<div class="quote">text</div>

And in the second, as follows:

<div class="quote"><cite>Author wrote:</cite>text</div>

Then to implement this BB code is necessary to make such a configuration:

<script>
$(document).ready(function() {
 var wbbOpt = {
  allButtons: {
    quote: {
      transform: {
        '<div class="quote">{SELTEXT}</div>':'[quote]{SELTEXT}[/quote]',
        '<div class="quote"><cite>{AUTHOR} wrote:</cite>{SELTEXT}</div>':'[quote={AUTHOR}]{SELTEXT}[/quote]'
      }
    }
  }
 }
 $("#editor").wysibb(wbbOpt);
});
</script>
.....
<textarea id="editor"></textaera>

Here we describe how you want to make the transformation from HTML to BB code. {AUTHOR} variable was taken for clarity, you can use any name that contains no spaces.

Respectively for inserting quotes when you click "Quote" on the site, you need to add by clicking the API call function execCommand

<button id="button">Insert quote</button>
...
<script>
$(document).ready(function() {
  $("#button").click(function() {
     $('#editor').execCommand('quote',{author: 'WysiBB',seltext:'This is a quote text'});
  });
})
</script>


The result of the configuration: