Adding color to textAngular is an easy way to make colorpicker close when clicked in textAngular editor? - SOLVED

A fair number asked about adding a font and background to textAngular. I am pleased with my decision, so I decided to share this. I have a final question: is there an easy way to close the colorpicker when the editor is clicked? without changing the textAngular code that I wanted to avoid?

In this solution, I use angular-bootstrap-colorpicker, so I also added as a dependency to my application: [... 'colorpicker.module', 'textAngular', ...].

Following https://github.com/fraywing/textAngular/wiki/Customising-The-Toolbar I have my application configuration section:

$provide.decorator('taOptions', ['taRegisterTool', '$delegate', function(taRegisterTool, taOptions){ // $delegate is the taOptions we are decorating // register the tool with textAngular taRegisterTool('backgroundColor', { display: "<button colorpicker class='btn btn-default ng-scope' title='Background Color' type='button' colorpicker-close-on-select colorpicker-position='bottom' ng-model='backgroundColor' style='background-color: {{backgroundColor}}'><i class='fa fa-paint-brush'></i></button>", action: function (deferred) { var self = this; this.$editor().wrapSelection('backgroundColor', this.backgroundColor); if (typeof self.listener == 'undefined') { self.listener = self.$watch('backgroundColor', function (newValue) { self.$editor().wrapSelection('backColor', newValue); }); } self.$on('colorpicker-selected', function () { deferred.resolve(); }); self.$on('colorpicker-closed', function () { deferred.resolve(); }); return; } }); taOptions.toolbar[1].unshift('backgroundColor'); taRegisterTool('fontColor', { display: "<button colorpicker type='button' class='btn btn-default ng-scope' title='Font Color' colorpicker-close-on-select colorpicker-position='bottom' ng-model='fontColor' style='color: {{fontColor}}'><i class='fa fa-font '></i></button>", action: function (deferred) { var self = this; if (typeof self.listener == 'undefined') { self.listener = self.$watch('fontColor', function (newValue) { self.$editor().wrapSelection('foreColor', newValue); }); } self.$on('colorpicker-selected', function () { deferred.resolve(); }); self.$on('colorpicker-closed', function () { deferred.resolve(); }); return false; } }); taOptions.toolbar[1].unshift('fontColor'); taOptions.setup.textEditorSetup=function($element) { $element.attr('ui-codemirror', ''); }; return taOptions; }]); }) 

where "ui-codemirror" is not related to adding color to textAngular, only part of my code.

I hope this is useful to others, as I mentioned above, I only want me to be able to get the colorpicker to close when I click on the editor ...

Here is the image of the received addition to the user interface.

picture of the toolbar with the added color for font and background

+8
angularjs user-interface
source share

No one has answered this question yet.

See related questions:

177
Clicking a button on the form will refresh the page.
3
AngularJS: What is the correct way to close the dropdown / popover element on an external mouse click?
one
AngularJS ng-click changes color to two tds in ng-repeat
one
looking for a "corner way" to close an open menu when you click on a page
0
AngularJS ng-click change color in ng-repeat
0
AngularJS - Closing a bootstrap when a button is pressed from the inside
0
Is there a way to set the angular-bootstrap-colorpicker color pointer to some color code value?
0
Dropdown diagonal js Summernote does not close when external editor is clicked
0
Bootstrap popover causes a weird bug when combined with the textAngular editor
-one
easy cocoa control to display rich text

All Articles