Hello!
Actually it's very easy to add multiple sections at once, as you can see from the default configuration of the [jquery.wikiEditor.js](https://phabricator.wikimedia.org/diffusion/EWED/browse/master/modules/jquery.wikiEditor.toolbar.config.js).
In the other hand, it's not efficient to edit multiple sections at once because you need to fires the `addToToolbar` method one time per each edited group and, if you have multiple groups, doing so can raise graphical bugs (e.g. the textarea with the first lines covered by the toolbar, I think because of the too many `resize` triggers called in unpredictable order of execution).
== Actual examples ==
The syntax for adding multiple sections at once is the following (aka multiple section syntax):
```
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'sections': {
'strangeSection1': {
'type': 'toolbar',
'label': 'Strange section 1',
},
'strangeSection2': {
'type': 'toolbar',
'label': 'Strange section 2',
// etc.
}
// and so on for new sections
}
} );
```
Note that you can't use the above syntax to update existing section>groups (e.g. you can't use the above syntax to add buttons in existing groups). If you do this, you will duplicate each edited section/group.
The syntax for editing a single existing section>group is the following e.g. adding a button in the existing `advanced` > `insert` (aka single section syntax):
```
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
section: 'advanced',
group: 'insert',
tools: {
toolName: {
label: 'Click here to add a plus',
type: 'button',
oouiIcon: 'add',
action: {
type: 'encapsulate',
options: {
peri: '+',
}
}
},
}
} );
```
== The proposal ==
We can apply one of these:
1. Set as default the "preserve existing" logic into the multiple section syntax. This allow every user to declare their buttons in existing sections in a very compressed way. It also allow improve consistence when multiple scripts are personalizing the toolbar, allowing them to simply don't care about «is this section already existing or I have to create it?».
2. or we can add an optional flag into the multiple section syntax as e.g. `preserveExisting: true` that, when specified, avoid to duplicate an existing section/group. In my opinion this is not a good solution because we do not have the above gains.
3. or something else