i have multiple textangular fields in same page common toolbar , have created directive auto insert text in textangular field @ current caret position. problem can insert code when there 1 textangular field. multiple textangular fields, unable find textangular field focussed. here code :
html
<div class="row mrgn20"> <div class="formfld"> <text-angular name="message" ta-target-toolbars="messagetoolbar" ng-model="composeemail.body"></text-angular> <text-angular name="emailsignature" ta-target-toolbars="messagetoolbar" ng-model="composeemailctrl.emailsignature.text"></text-angular> <text-angular-toolbar ta-toolbar="[['uploadattachment','bold','italics', 'ul', 'insertlink', 'fontsize', 'uploadimage', 'fontcolor']]" class="toolbar" name="messagetoolbar"></text-angular-toolbar> </div> <auto-insert-text options="composeemailctrl.autoinserttextoptions" insert-in="message"></auto-insert-text> </div>
js
controller
function ($scope){ $scope.composeemailctrl = {}; $scope.composeemail ={}; $scope.candidate = { name : 'rahul', company : 'test company' } $scope.composeemailctrl.autoinserttextoptions = [{ title: 'candidate fullname', value: scope.candidate.name, key : 'candidate_fullname' }, { title: 'company name', value: scope.candidate.company, key : 'company_name' }]; }
directive
app.directive('autoinserttext', function(textangularmanager) { return { restrict: 'e', template: '<span translate="insert_auto_text"></span> <span ng-repeat="option in options"><button type="button" ng-bind="option.title" ng-click="inserttext($event,option)" unselectable="on"></button></span>', scope: { options: "=", insertin: "@" }, link: function(scope, elem, attr) { var _editorscope = ''; scope.inserttext = function(event, option) { _editorscope = _editorscope || textangularmanager.retrieveeditor(scope.insertin).scope; _editorscope.displayelements.text[0].focus(); _editorscope.wrapselection("inserthtml", option.value, true); } } }; });
the autoinserttext
directive takes insert options , textangular field name in value inserted. want support insertion in multiple textangular fields depending on current caret position.
Comments
Post a Comment