I'm using Textangular 1.4.6 and Angular 1.4.7. I need to add a drop down to the toolbar, so i wrote this code:
$provide.decorator('taOptions', [
'taRegisterTool',
'$delegate',
function (taRegisterTool, taOptions) {
// $delegate is the taOptions we are decorating
// register the tool with textAngular
taRegisterTool('parameterscombo', {
display: '<button class="btn" type="button" data-animation="am-fade" bs-dropdown="content" aria-haspopup="true" aria-expanded="false">Select parameter</button>',
content: [
{
text: 1,
click: 'action(item)'
},
{
text: 2,
click: 'action(item)'
},
{
text: 3,
click: 'action(item)'
},
{
text: 4,
click: 'action(item)'
}
],
action: function (item) {
if (item.text) {
this.$editor().wrapSelection('insertHtml', item.text + '***');
}
}
});
// add the button to the default toolbar definition
taOptions.toolbar[1].push('parameterscombo');
return taOptions;
}
]);
The dropdown is shown and I'm able to choose a value and insert it to the textarea. The problem is that the first time I choose a value, it's inserted in the correct place (where the cursor is), but the second time onward , it always puts the value in the beginning of the text.
Here's a plunkr: http://plnkr.co/edit/UZQk3jQ5xEpMJdNLonBO?p=preview