Skip to content

Commit

Permalink
Merge pull request #182 from enkodellc/patch-1
Browse files Browse the repository at this point in the history
Add Indent and Outdent buttons to toolbar.
  • Loading branch information
SimeonC committed May 29, 2014
2 parents dc5ab34 + fd1be7c commit 68b2c8c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 9 deletions.
24 changes: 22 additions & 2 deletions src/textAngularSetup.js
Expand Up @@ -13,7 +13,7 @@ textAngularSetup.value('taOptions', {
toolbar: [
['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'pre', 'quote'],
['bold', 'italics', 'underline', 'ul', 'ol', 'redo', 'undo', 'clear'],
['justifyLeft','justifyCenter','justifyRight'],
['justifyLeft','justifyCenter','justifyRight','indent','outdent'],
['html', 'insertImage', 'insertLink', 'insertVideo']
],
classes: {
Expand Down Expand Up @@ -203,6 +203,26 @@ textAngularSetup.run(['taRegisterTool', '$window', 'taTranslations', 'taSelectio
return result;
}
});
taRegisterTool('indent', {
iconclass: 'fa fa-indent',
tooltiptext: 'Indent',
action: function(){
return this.$editor().wrapSelection("indent", null);
},
activeState: function(){
return this.$editor().queryFormatBlockState('blockquote');
}
});
taRegisterTool('outdent', {
iconclass: 'fa fa-outdent',
tooltiptext: 'Outdent',
action: function(){
return this.$editor().wrapSelection("outdent", null);
},
activeState: function(){
return false;
}
});
taRegisterTool('italics', {
iconclass: 'fa fa-italic',
action: function(){
Expand Down Expand Up @@ -448,4 +468,4 @@ textAngularSetup.run(['taRegisterTool', '$window', 'taTranslations', 'taSelectio
}
}
});
}]);
}]);
12 changes: 11 additions & 1 deletion test/taTools.spec.js
Expand Up @@ -184,6 +184,16 @@ describe('taTools test tool actions', function(){
expect(button.hasClass('active'));
});

it('indent button should function correctly', function(){
button = findAndTriggerButton('indent');
expect(button.hasClass('active'));
});

it('outdent button should function correctly', function(){
button = findAndTriggerButton('outdent');
expect(button.hasClass('active'));
});

it('html button should function correctly', inject(function($timeout){
button = findAndTriggerButton('html');
$timeout.flush();
Expand Down Expand Up @@ -513,4 +523,4 @@ describe('taTools test tool actions', function(){
expect(editorScope.displayElements.text.find('p').find('img').length).toBe(0);
});
});
});
});
8 changes: 4 additions & 4 deletions test/textAngular.spec.js
Expand Up @@ -766,7 +766,7 @@ describe('textAngular', function(){
taOptions.toolbar = [
['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'pre', 'quote', 'testbutton'],
['bold', 'italics', 'underline', 'ul', 'ol', 'redo', 'undo', 'clear'],
['justifyLeft','justifyCenter','justifyRight'],
['justifyLeft','justifyCenter','justifyRight','indent','outdent'],
['html', 'insertImage', 'insertLink', 'unlink']
];
}));
Expand Down Expand Up @@ -1085,12 +1085,12 @@ describe('textAngular', function(){
it('should re-focus on toolbar when swapping directly from editor to editor', inject(function($timeout, textAngularManager){
textAngularManager.retrieveEditor('test1').scope.displayElements.text.triggerHandler('focus');
$rootScope.$digest();
expect(jQuery(toolbar[0]).find('button:not(:disabled)').length).toBe(25);
expect(jQuery(toolbar[0]).find('button:not(:disabled)').length).toBe(27);
textAngularManager.retrieveEditor('test2').scope.displayElements.text.triggerHandler('focus');
$rootScope.$digest();
$timeout.flush();
// expect none to be disabled
expect(jQuery(toolbar[0]).find('button:not(:disabled)').length).toBe(25);
expect(jQuery(toolbar[0]).find('button:not(:disabled)').length).toBe(27);
}));
});
});
});
4 changes: 2 additions & 2 deletions test/textAngularToolbar.spec.js
Expand Up @@ -13,7 +13,7 @@ describe('textAngularToolbar', function(){
taOptions.toolbar = [
['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'pre', 'quote', 'active'],
['bold', 'italics', 'underline', 'ul', 'ol', 'redo', 'undo', 'clear'],
['justifyLeft','justifyCenter','justifyRight'],
['justifyLeft','justifyCenter','justifyRight','indent','outdent'],
['html', 'insertImage', 'insertLink', 'unlink']
];
}));
Expand Down Expand Up @@ -561,4 +561,4 @@ describe('textAngularToolbar', function(){
});
// action is called in correct deferred pattern
});
});
});

0 comments on commit 68b2c8c

Please sign in to comment.