Skip to content

Commit 5ff572f

Browse files
SimeonCSimeonC
SimeonC
authored and
SimeonC
committedOct 23, 2014
fix(taBind): Fixes paste lists, more lenient stripping of spans.
1 parent 9fe51ab commit 5ff572f

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed
 

‎src/textAngular.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/*!
2-
textAngular
1+
/*
2+
@license textAngular
33
Author : Austin Anderson
44
License : 2013 MIT
55
Version 1.3.0-pre8
@@ -1183,7 +1183,7 @@ See README.md or https://github.com/fraywing/textAngular/wiki for requirements a
11831183
for(var i = 0; i <= dom[0].childNodes.length; i++){
11841184
if(!dom[0].childNodes[i] || dom[0].childNodes[i].nodeName === "#text" || dom[0].childNodes[i].tagName.toLowerCase() !== "p") continue;
11851185
var el = angular.element(dom[0].childNodes[i]);
1186-
var _listMatch = (el.attr('class') || '').match(/MsoList(Bullet|Number|Paragraph)(|CxSp(First|Middle|Last))/i);
1186+
var _listMatch = (el.attr('class') || '').match(/MsoList(Bullet|Number|Paragraph)(CxSp(First|Middle|Last)|)/i);
11871187

11881188
if(_listMatch){
11891189
if(el[0].childNodes.length < 2 || el[0].childNodes[1].childNodes.length < 1){
@@ -1194,7 +1194,7 @@ See README.md or https://github.com/fraywing/textAngular/wiki for requirements a
11941194
var _indentMatch = (el.attr('style') || '').match(/margin-left:([\-\.0-9]*)pt/i);
11951195
var indent = parseFloat((_indentMatch)?_indentMatch[1]:0);
11961196

1197-
if (!_listMatch[2] || _listMatch[2].toLowerCase() === "first" || (_list.lastIndent === null && _list.element === null) || (_list.isUl !== isUl && _list.lastIndent === indent)) {
1197+
if (!_listMatch[3] || _listMatch[3].toLowerCase() === "first" || (_list.lastIndent === null) || (_list.isUl !== isUl && _list.lastIndent === indent)) {
11981198
_list.isUl = isUl;
11991199
_list.element = angular.element(isUl ? "<ul>" : "<ol>");
12001200
el.after(_list.element);
@@ -1226,7 +1226,10 @@ See README.md or https://github.com/fraywing/textAngular/wiki for requirements a
12261226
node.remove();
12271227
};
12281228

1229-
angular.forEach(dom.find('span'), _unwrapElement);
1229+
angular.forEach(dom.find('span'), function(node){
1230+
node.removeAttribute('lang');
1231+
if(node.attributes.length <= 0) _unwrapElement(node);
1232+
});
12301233
angular.forEach(dom.find('font'), _unwrapElement);
12311234
text = dom.html();
12321235
}

‎src/textAngularSetup.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
textAngular
2+
@license textAngular
33
Author : Austin Anderson
44
License : 2013 MIT
55
Version 1.3.0-pre8

‎test/taBind/taBind.wordPaste.spec.js

+11
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,17 @@ describe('taBind.wordPaste', function () {
103103
$rootScope.$digest();
104104
expect(pasted).toBe('<ul><li>Test1</li><li>Test1</li></ul>');
105105
}));
106+
107+
it('subsequent list', inject(function($timeout, taSelection){
108+
element.triggerHandler('paste', {clipboardData: {types: ['text/html'], getData: function(){
109+
return '<p class="MsoListParagraphCxSpFirst" style="text-indent:-18.0pt;mso-list:l1 level1 lfo1"><!--[if !supportLists]--><span lang="EN-US" style="font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family:Symbol"><span style="mso-list:Ignore">·<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span><!--[endif]--><span lang="EN-US">no vidisse partiendocomplectitur has. </span></p><p class="MsoListParagraphCxSpLast" style="text-indent:-18.0pt;mso-list:l1 level1 lfo1"><!--[if !supportLists]--><span lang="EN-US" style="font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family:Symbol"><span style="mso-list:Ignore">·<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span><!--[endif]--><span lang="EN-US">Te sit iusto viris tibique, nevoluptaria philosophia cum, cum ad vivendum mediocritatem. </span></p><p style="text-indent:18.0pt"><span lang="EN-US"></span></p><p style="text-indent:18.0pt"><span lang="EN-US">Alii mazimsoleat ne sed, dicta putant ad qui. </span></p><p class="MsoListParagraphCxSpFirst" style="margin-left:18.0pt;mso-add-space:auto;text-indent:-18.0pt;mso-list:l0 level1 lfo2"><!--[if !supportLists]--><span lang="EN-US" style="mso-fareast-font-family:Cambria;mso-fareast-theme-font:minor-latin;mso-bidi-font-family:Cambria;mso-bidi-theme-font:minor-latin"><span style="mso-list:Ignore">1.<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span><!--[endif]--><span lang="EN-US">Has accusam scriptorem cu, </span></p><p class="MsoListParagraphCxSpLast" style="margin-left:39.6pt;mso-add-space:auto;text-indent:-21.6pt;mso-list:l0 level2 lfo2"><!--[if !supportLists]--><span lang="EN-US" style="mso-fareast-font-family:Cambria;mso-fareast-theme-font:minor-latin;mso-bidi-font-family:Cambria;mso-bidi-theme-font:minor-latin"><span style="mso-list:Ignore">1.1.<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp; </span></span></span><!--[endif]--><span lang="EN-US">aliquam complectitur vim ne.</span></p>';// jshint ignore:line
110+
}}});
111+
$timeout.flush();
112+
$rootScope.$digest();
113+
expect(pasted).toBe('<ul><li>no vidisse partiendocomplectitur has. </li><li>Te sit iusto viris tibique, nevoluptaria philosophia cum, cum ad vivendum mediocritatem. </li></ul><p></p><p>Alii mazimsoleat ne sed, dicta putant ad qui. </p><ol><li>Has accusam scriptorem cu, <ol><li>aliquam complectitur vim ne.</li></ol></li></ol>');
114+
}));
115+
116+
106117
// indents - ul > ul, ul > ol, ol > ol, ol > ul
107118

108119
it('ul > ul nested list', inject(function($timeout, taSelection){

0 commit comments

Comments
 (0)