Skip to content

Commit

Permalink
Merge pull request #861 from yaldak/fix644b
Browse files Browse the repository at this point in the history
fix 644: parse whitespace from plaintext
  • Loading branch information
pbassut committed Sep 3, 2015
2 parents 55f2c9a + c6b3730 commit 5c028f5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
10 changes: 10 additions & 0 deletions dist/textAngular.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ See README.md or https://github.com/fraywing/textAngular/wiki for requirements a
Commonjs package manager support (eg componentjs).
*/

/* istanbul ignore next: */
'undefined'!=typeof module&&'undefined'!=typeof exports&&module.exports===exports&&(module.exports='textAngular');

(function(){ // encapsulate all variables so they don't become global vars
Expand Down Expand Up @@ -1516,6 +1517,15 @@ angular.module('textAngular.taBind', ['textAngular.factories', 'textAngular.DOM'
// insert missing parent of li element
text = text.replace(/<li(\s.*)?>.*<\/li(\s.*)?>/i, '<ul>$&</ul>');
}

// parse whitespace from plaintext input, starting with preceding spaces that get stripped on paste
text = text.replace(/^[ |\u00A0]+/gm, function (match) {
var result = '';
for (var i = 0; i < match.length; i++) {
result += '&nbsp;';
}
return result;
}).replace(/\n|\r\n|\r/g, '<br />').replace(/\t/g, '&nbsp;&nbsp;&nbsp;&nbsp;');

if(_pasteHandler) text = _pasteHandler(scope, {$html: text}) || text;

Expand Down
Loading

0 comments on commit 5c028f5

Please sign in to comment.