-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(taBind): Textarea basic formatting of html with tabs and newlines
Fixes #307
- Loading branch information
SimeonC
authored and
SimeonC
committed
Jan 21, 2015
1 parent
c4b7bdd
commit f0d3baf
Showing
11 changed files
with
320 additions
and
3 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
var triggerEvent = function(event, element, options){ | ||
var event; | ||
if(angular.element === jQuery){ | ||
event = jQuery.Event(event); | ||
angular.extend(event, options); | ||
element.triggerHandler(event); | ||
}else{ | ||
element.triggerHandler(event, options); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
describe('taBind.$formatters', function () { | ||
'use strict'; | ||
var $rootScope, element; | ||
beforeEach(module('textAngular')); | ||
beforeEach(inject(function(_$rootScope_, $compile){ | ||
$rootScope = _$rootScope_; | ||
$rootScope.html = ''; | ||
element = $compile('<textarea ta-bind ng-model="html"></textarea>')($rootScope); | ||
})); | ||
afterEach(inject(function($document){ | ||
$document.find('body').html(''); | ||
})); | ||
|
||
describe('should format textarea html for readability', function(){ | ||
it('adding newlines after immediate child tags', function(){ | ||
$rootScope.html = '<p>Test Line 1</p><div>Test Line 2</div><span>Test Line 3</span>'; | ||
$rootScope.$digest(); | ||
expect(element.val()).toBe('<p>Test Line 1</p>\n<div>Test Line 2</div>\n<span>Test Line 3</span>'); | ||
}); | ||
it('ignore nested tags', function(){ | ||
$rootScope.html = '<p><b>Test</b> Line 1</p><div>Test <i>Line</i> 2</div><span>Test Line <u>3</u></span>'; | ||
$rootScope.$digest(); | ||
expect(element.val()).toBe('<p><b>Test</b> Line 1</p>\n<div>Test <i>Line</i> 2</div>\n<span>Test Line <u>3</u></span>'); | ||
}); | ||
it('tab out li elements', function(){ | ||
$rootScope.html = '<ul><li>Test Line 1</li><li>Test Line 2</li><li>Test Line 3</li></ul>'; | ||
$rootScope.$digest(); | ||
expect(element.val()).toBe('<ul>\n\t<li>Test Line 1</li>\n\t<li>Test Line 2</li>\n\t<li>Test Line 3</li>\n</ul>'); | ||
}); | ||
it('handle nested lists', function(){ | ||
$rootScope.html = '<ol><li>Test Line 1</li><ul><li>Nested Line 1</li><li>Nested Line 2</li></ul><li>Test Line 3</li></ol>'; | ||
$rootScope.$digest(); | ||
expect(element.val()).toBe('<ol>\n\t<li>Test Line 1</li>\n\t<ul>\n\t\t<li>Nested Line 1</li>\n\t\t<li>Nested Line 2</li>\n\t</ul>\n\t<li>Test Line 3</li>\n</ol>'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters