forked from textAngular/textAngular
-
Notifications
You must be signed in to change notification settings - Fork 12
Setting Defaults
SimeonC edited this page Feb 18, 2014
·
6 revisions
To set global defaults that affect all of your text-angular instances we recommend using an angular decorator. See below for an example:
angular.module("textAngularTest", ['textAngular'])
.config(function($provide){
// this demonstrates how to register a new tool and add it to the default toolbar
$provide.decorator('taOptions', ['$delegate', function(taOptions){
// $delegate is the taOptions we are decorating
// here we change taOptions to be the default of taOptions for example
taOptions = {toolbar: [
['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'pre', 'quote'],
['bold', 'italics', 'underline', 'ul', 'ol', 'redo', 'undo', 'clear'],
['justifyLeft','justifyCenter','justifyRight'],
['html', 'insertImage', 'insertLink', 'unlink']
],
classes: {
focussed: "focussed",
toolbar: "btn-toolbar",
toolbarGroup: "btn-group",
toolbarButton: "btn btn-default",
toolbarButtonActive: "active",
disabled: "disabled",
textEditor: 'form-control',
htmlEditor: 'form-control'
}};
return taOptions; // whatever you return will be the taOptions
}]);
// this demonstrates changing the classes of the icons for the tools for font-awesome v3.x
$provide.decorator('taTools', ['$delegate', function(taTools){
taTools.bold.iconclass = 'icon-bold';
taTools.italics.iconclass = 'icon-italic';
taTools.underline.iconclass = 'icon-underline';
taTools.ul.iconclass = 'icon-list-ul';
taTools.ol.iconclass = 'icon-list-ol';
taTools.undo.iconclass = 'icon-undo';
taTools.redo.iconclass = 'icon-repeat';
taTools.justifyLeft.iconclass = 'icon-align-left';
taTools.justifyRight.iconclass = 'icon-align-right';
taTools.justifyCenter.iconclass = 'icon-align-center';
taTools.clear.iconclass = 'icon-ban-circle';
taTools.insertLink.iconclass = 'icon-link';
taTools.unlink.iconclass = 'icon-link red';
taTools.insertImage.iconclass = 'icon-picture';
// there is no quote icon in old font-awesome so we change to text as follows
delete taTools.quote.iconclass;
taTools.quote.buttontext = 'quote';
return taTools;
}]);
});