- if(spanParent || spanBefore || spanAfter) {
- var startSpace = /\s/g.test(this.data.substr(0,1));
- var endSpace = /\s/g.test(this.data.substr(-1)) && this.data.length > 1;
- var trimmed = $.trim(this.data);
- var newText = (startSpace && (spanParent || spanBefore) ? ' ' : '')
- + trimmed
- + (endSpace && (spanParent || spanAfter) ? ' ' : '');
- if(newText !== oldText) {
- this.data = newText;
- var toAdd1, toAdd2;
- var toAdd = [];
- if(!trimmed) {
- toAdd.push(oldText);
- } else {
- if(endSpace) {
- toAdd1 = oldText.match(/\s+$/g)[0];
- if(newText[newText.length - 1] === ' ' && toAdd1[0] === ' ')
- toAdd1 = toAdd1.substr(1);
- toAdd.push(toAdd1);
- }
- if(startSpace) {
- toAdd2 = oldText.match(/^\s+/g)[0];
- if(newText[0] === ' ' && toAdd2[toAdd2.length-1] === ' ')
- toAdd2 = toAdd2.substr(0, toAdd2.length -1);
- toAdd.push(toAdd2);
- }
- }
- addInfo(toAdd);
- }
+ text.transformed = text.trimmed;
+
+ if(hasSpanParent || hasSpanBefore || hasSpanAfter) {
+ var startSpace = /\s/g.test(text.original.substr(0,1)),
+ endSpace = /\s/g.test(text.original.substr(-1)) && text.original.length > 1;
+ text.transformed = (startSpace && (hasSpanParent || hasSpanBefore) ? ' ' : '')
+ + text.trimmed
+ + (endSpace && (hasSpanParent || hasSpanAfter) ? ' ' : '');