Fix #7284 - more issues with bullet point detection
authorAlan <alan@roojs.com>
Wed, 29 Jun 2022 02:52:49 +0000 (10:52 +0800)
committerAlan <alan@roojs.com>
Wed, 29 Jun 2022 02:52:49 +0000 (10:52 +0800)
Roo/htmleditor/FilterWord.js
roojs-all.js
roojs-bootstrap-debug.js
roojs-bootstrap.js
roojs-debug.js
roojs-ui-debug.js
roojs-ui.js

index d3d6cc4..a9fad68 100644 (file)
@@ -139,12 +139,11 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
         });
         return ret;
     },
-    
-    
+     
     replaceDocBullets : function(doc)
     {
         // this is a bit odd - but it appears some indents use ql-indent-1
-         //Roo.log(doc.innerHTML);
+        //Roo.log(doc.innerHTML);
         
         var listpara = doc.getElementsByClassName('MsoListParagraphCxSpFirst');
         for( var i = 0; i < listpara.length; i ++) {
@@ -153,11 +152,18 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
         // this is a bit hacky - we had one word document where h2 had a miso-list attribute.
         var htwo = doc.getElementsByTagName('h2');
         for( var i = 0; i < htwo.length; i ++) {
-            if (htwo.item(i).getAttribute('style').match(/mso-list:/)) {
+            if (htwo.item(i).hasAttribute('style') && htwo.item(i).getAttribute('style').match(/mso-list:/)) {
                 htwo.item(i).className = "MsoListParagraph";
             }
         }
-        
+        listpara = doc.getElementsByClassName('MsoNormal');
+        while(listpara.length) {
+            if (listpara.item(0).hasAttribute('style') && listpara.item(0).getAttribute('style').match(/mso-list:/)) {
+                listpara.item(0).className = "MsoListParagraph";
+            } else {
+                listpara.item(0).className = "MsoNormalx";
+            }
+        }
         listpara = doc.getElementsByClassName('ql-indent-1');
         while(listpara.length) {
             this.replaceDocBullet(listpara.item(0));
@@ -189,6 +195,12 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
             if (!ns.className.match(/(MsoListParagraph|ql-indent-1)/i)) {
                 break;
             }
+            if (ns.getAttribute('style').match(/mso-list/)) {
+                items.push(ns);
+                ns = ns.nextSibling;
+                has_list = true;
+                continue;
+            }
             var spans = ns.getElementsByTagName('span');
             if (!spans.length) {
                 break;
@@ -203,10 +215,10 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
             if (!has_list) {
                 break;
             }
-            
-            
             items.push(ns);
             ns = ns.nextSibling;
+            
+            
         }
         if (!items.length) {
             ns.className = "";
@@ -219,7 +231,9 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
         var stack = [ ul ];
         var last_li = false;
         
-         
+        var margin_to_depth = {};
+        max_margins = -1;
+        
         items.forEach(function(n, ipos) {
             //Roo.log("got innertHMLT=" + n.innerHTML);
             
@@ -250,15 +264,18 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
             style = this.styleToObject(n); // mo-list is from the parent node.
             if (typeof(style['mso-list']) == 'undefined') {
                 //Roo.log("parent is missing level");
-                
-                 
+                  
                 parent.removeChild(n);
                  
                 return;
             }
             
-            var nlvl =   (style['mso-list'].split(' ')[1].replace(/level/,'') *1) - 1  ;
-            
+            var margin = style['margin-left'];
+            if (typeof(margin_to_depth[margin]) == 'undefined') {
+                max_margins++;
+                margin_to_depth[margin] = max_margins;
+            }
+            nlvl = margin_to_depth[margin] ;
              
             if (nlvl > lvl) {
                 //new indent
index 9688489..9608c7f 100644 (file)
@@ -1931,12 +1931,13 @@ A.removeChild(cn);A.parentNode.insertBefore(cn,A);if(cn.nodeType==1){this.replac
 }C.push(F);});A.className=C.length?C.join(' '):'';if(!C.length){A.removeAttribute("class");}}if(A.hasAttribute("lang")){A.removeAttribute("lang");}if(A.hasAttribute("style")){var D=A.getAttribute("style").split(";");var E=[];Roo.each(D,function(s){if(!s.match(/:/)){return;
 }var kv=s.split(":");if(kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)){return;}E.push(s);});A.setAttribute("style",E.length?E.join(';'):'');if(!E.length){A.removeAttribute('style');}}return true;},styleToObject:function(A){var B=(A.getAttribute("style")||'').split(";");
 var C={};Roo.each(B,function(s){if(!s.match(/:/)){return;}var kv=s.split(":");C[kv[0].trim()]=kv[1];});return C;},replaceDocBullets:function(A){var B=A.getElementsByClassName('MsoListParagraphCxSpFirst');for(var i=0;i<B.length;i++){B.item(i).className="MsoListParagraph";
-}var C=A.getElementsByTagName('h2');for(var i=0;i<C.length;i++){if(C.item(i).getAttribute('style').match(/mso-list:/)){C.item(i).className="MsoListParagraph";}}B=A.getElementsByClassName('ql-indent-1');while(B.length){this.replaceDocBullet(B.item(0));}B=A.getElementsByClassName('MsoListParagraph');
-while(B.length){this.replaceDocBullet(B.item(0));}},replaceDocBullet:function(p){var ns=p,A=p.parentNode,B=A.ownerDocument,C=[];while(ns){if(ns.nodeType!=1){ns=ns.nextSibling;continue;}if(!ns.className.match(/(MsoListParagraph|ql-indent-1)/i)){break;}var D=ns.getElementsByTagName('span');
-if(!D.length){break;}var E=false;for(var i=0;i<D.length;i++){if(D[i].getAttribute('style').match(/mso-list/)){E=true;break;}}if(!E){break;}C.push(ns);ns=ns.nextSibling;}if(!C.length){ns.className="";return;}var ul=A.ownerDocument.createElement('ul');A.insertBefore(ul,p);
-var F=0;var G=[ul];var H=false;C.forEach(function(n,I){var J=n.getElementsByTagName('span');if(!J.length){A.removeChild(n);return;}var K={};for(var i=0;i<J.length;i++){K=this.styleToObject(J[i]);if(typeof(K['mso-list'])=='undefined'){continue;}J[i].parentNode.removeChild(J[i]);
-break;}K=this.styleToObject(n);if(typeof(K['mso-list'])=='undefined'){A.removeChild(n);return;}var L=(K['mso-list'].split(' ')[1].replace(/level/,'')*1)-1;if(L>F){var M=B.createElement('ul');if(!H){H=B.createElement('li');G[F].appendChild(H);}H.appendChild(M);
-G[L]=M;}F=L;var N=G[L].appendChild(B.createElement('li'));H=N;N.innerHTML=n.innerHTML;A.removeChild(n);},this);}});
+}var C=A.getElementsByTagName('h2');for(var i=0;i<C.length;i++){if(C.item(i).hasAttribute('style')&&C.item(i).getAttribute('style').match(/mso-list:/)){C.item(i).className="MsoListParagraph";}}B=A.getElementsByClassName('MsoNormal');while(B.length){if(B.item(0).hasAttribute('style')&&B.item(0).getAttribute('style').match(/mso-list:/)){B.item(0).className="MsoListParagraph";
+}else{B.item(0).className="MsoNormalx";}}B=A.getElementsByClassName('ql-indent-1');while(B.length){this.replaceDocBullet(B.item(0));}B=A.getElementsByClassName('MsoListParagraph');while(B.length){this.replaceDocBullet(B.item(0));}},replaceDocBullet:function(p){var ns=p,A=p.parentNode,B=A.ownerDocument,C=[];
+while(ns){if(ns.nodeType!=1){ns=ns.nextSibling;continue;}if(!ns.className.match(/(MsoListParagraph|ql-indent-1)/i)){break;}if(ns.getAttribute('style').match(/mso-list/)){C.push(ns);ns=ns.nextSibling;E=true;continue;}var D=ns.getElementsByTagName('span');if(!D.length){break;
+}var E=false;for(var i=0;i<D.length;i++){if(D[i].getAttribute('style').match(/mso-list/)){E=true;break;}}if(!E){break;}C.push(ns);ns=ns.nextSibling;}if(!C.length){ns.className="";return;}var ul=A.ownerDocument.createElement('ul');A.insertBefore(ul,p);var F=0;
+var G=[ul];var H=false;var I={};max_margins=-1;C.forEach(function(n,J){var K=n.getElementsByTagName('span');if(!K.length){A.removeChild(n);return;}var L={};for(var i=0;i<K.length;i++){L=this.styleToObject(K[i]);if(typeof(L['mso-list'])=='undefined'){continue;
+}K[i].parentNode.removeChild(K[i]);break;}L=this.styleToObject(n);if(typeof(L['mso-list'])=='undefined'){A.removeChild(n);return;}var M=L['margin-left'];if(typeof(I[M])=='undefined'){max_margins++;I[M]=max_margins;}nlvl=I[M];if(nlvl>F){var N=B.createElement('ul');
+if(!H){H=B.createElement('li');G[F].appendChild(H);}H.appendChild(N);G[nlvl]=N;}F=nlvl;var O=G[nlvl].appendChild(B.createElement('li'));H=O;O.innerHTML=n.innerHTML;A.removeChild(n);},this);}});
 // Roo/htmleditor/FilterStyleToTag.js
 Roo.htmleditor.FilterStyleToTag=function(A){this.tags={B:['fontWeight','bold'],I:['fontStyle','italic'],SUP:['verticalAlign','super'],SUB:['verticalAlign','sub']};Roo.apply(this,A);this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterStyleToTag,Roo.htmleditor.Filter,{tag:true,tags:false,replaceTag:function(A){if(A.getAttribute("style")===null){return true;
 }var B=[];for(var k in this.tags){if(A.style[this.tags[k][0]]==this.tags[k][1]){B.push(k);A.style.removeProperty(this.tags[k][0]);}}if(!B.length){return true;}var cn=Array.from(A.childNodes);var nn=A;Roo.each(B,function(t){var nc=A.ownerDocument.createElement(t);
index 2f3c656..d46f596 100644 (file)
@@ -26592,12 +26592,11 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
         });
         return ret;
     },
-    
-    
+     
     replaceDocBullets : function(doc)
     {
         // this is a bit odd - but it appears some indents use ql-indent-1
-         //Roo.log(doc.innerHTML);
+        //Roo.log(doc.innerHTML);
         
         var listpara = doc.getElementsByClassName('MsoListParagraphCxSpFirst');
         for( var i = 0; i < listpara.length; i ++) {
@@ -26606,11 +26605,18 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
         // this is a bit hacky - we had one word document where h2 had a miso-list attribute.
         var htwo = doc.getElementsByTagName('h2');
         for( var i = 0; i < htwo.length; i ++) {
-            if (htwo.item(i).getAttribute('style').match(/mso-list:/)) {
+            if (htwo.item(i).hasAttribute('style') && htwo.item(i).getAttribute('style').match(/mso-list:/)) {
                 htwo.item(i).className = "MsoListParagraph";
             }
         }
-        
+        listpara = doc.getElementsByClassName('MsoNormal');
+        while(listpara.length) {
+            if (listpara.item(0).hasAttribute('style') && listpara.item(0).getAttribute('style').match(/mso-list:/)) {
+                listpara.item(0).className = "MsoListParagraph";
+            } else {
+                listpara.item(0).className = "MsoNormalx";
+            }
+        }
         listpara = doc.getElementsByClassName('ql-indent-1');
         while(listpara.length) {
             this.replaceDocBullet(listpara.item(0));
@@ -26642,6 +26648,12 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
             if (!ns.className.match(/(MsoListParagraph|ql-indent-1)/i)) {
                 break;
             }
+            if (ns.getAttribute('style').match(/mso-list/)) {
+                items.push(ns);
+                ns = ns.nextSibling;
+                has_list = true;
+                continue;
+            }
             var spans = ns.getElementsByTagName('span');
             if (!spans.length) {
                 break;
@@ -26656,10 +26668,10 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
             if (!has_list) {
                 break;
             }
-            
-            
             items.push(ns);
             ns = ns.nextSibling;
+            
+            
         }
         if (!items.length) {
             ns.className = "";
@@ -26672,7 +26684,9 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
         var stack = [ ul ];
         var last_li = false;
         
-         
+        var margin_to_depth = {};
+        max_margins = -1;
+        
         items.forEach(function(n, ipos) {
             //Roo.log("got innertHMLT=" + n.innerHTML);
             
@@ -26703,15 +26717,18 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
             style = this.styleToObject(n); // mo-list is from the parent node.
             if (typeof(style['mso-list']) == 'undefined') {
                 //Roo.log("parent is missing level");
-                
-                 
+                  
                 parent.removeChild(n);
                  
                 return;
             }
             
-            var nlvl =   (style['mso-list'].split(' ')[1].replace(/level/,'') *1) - 1  ;
-            
+            var margin = style['margin-left'];
+            if (typeof(margin_to_depth[margin]) == 'undefined') {
+                max_margins++;
+                margin_to_depth[margin] = max_margins;
+            }
+            nlvl = margin_to_depth[margin] ;
              
             if (nlvl > lvl) {
                 //new indent
index 692ae87..379f958 100644 (file)
@@ -1150,12 +1150,13 @@ A.removeChild(cn);A.parentNode.insertBefore(cn,A);if(cn.nodeType==1){this.replac
 }C.push(F);});A.className=C.length?C.join(' '):'';if(!C.length){A.removeAttribute("class");}}if(A.hasAttribute("lang")){A.removeAttribute("lang");}if(A.hasAttribute("style")){var D=A.getAttribute("style").split(";");var E=[];Roo.each(D,function(s){if(!s.match(/:/)){return;
 }var kv=s.split(":");if(kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)){return;}E.push(s);});A.setAttribute("style",E.length?E.join(';'):'');if(!E.length){A.removeAttribute('style');}}return true;},styleToObject:function(A){var B=(A.getAttribute("style")||'').split(";");
 var C={};Roo.each(B,function(s){if(!s.match(/:/)){return;}var kv=s.split(":");C[kv[0].trim()]=kv[1];});return C;},replaceDocBullets:function(A){var B=A.getElementsByClassName('MsoListParagraphCxSpFirst');for(var i=0;i<B.length;i++){B.item(i).className="MsoListParagraph";
-}var C=A.getElementsByTagName('h2');for(var i=0;i<C.length;i++){if(C.item(i).getAttribute('style').match(/mso-list:/)){C.item(i).className="MsoListParagraph";}}B=A.getElementsByClassName('ql-indent-1');while(B.length){this.replaceDocBullet(B.item(0));}B=A.getElementsByClassName('MsoListParagraph');
-while(B.length){this.replaceDocBullet(B.item(0));}},replaceDocBullet:function(p){var ns=p,A=p.parentNode,B=A.ownerDocument,C=[];while(ns){if(ns.nodeType!=1){ns=ns.nextSibling;continue;}if(!ns.className.match(/(MsoListParagraph|ql-indent-1)/i)){break;}var D=ns.getElementsByTagName('span');
-if(!D.length){break;}var E=false;for(var i=0;i<D.length;i++){if(D[i].getAttribute('style').match(/mso-list/)){E=true;break;}}if(!E){break;}C.push(ns);ns=ns.nextSibling;}if(!C.length){ns.className="";return;}var ul=A.ownerDocument.createElement('ul');A.insertBefore(ul,p);
-var F=0;var G=[ul];var H=false;C.forEach(function(n,I){var J=n.getElementsByTagName('span');if(!J.length){A.removeChild(n);return;}var K={};for(var i=0;i<J.length;i++){K=this.styleToObject(J[i]);if(typeof(K['mso-list'])=='undefined'){continue;}J[i].parentNode.removeChild(J[i]);
-break;}K=this.styleToObject(n);if(typeof(K['mso-list'])=='undefined'){A.removeChild(n);return;}var L=(K['mso-list'].split(' ')[1].replace(/level/,'')*1)-1;if(L>F){var M=B.createElement('ul');if(!H){H=B.createElement('li');G[F].appendChild(H);}H.appendChild(M);
-G[L]=M;}F=L;var N=G[L].appendChild(B.createElement('li'));H=N;N.innerHTML=n.innerHTML;A.removeChild(n);},this);}});
+}var C=A.getElementsByTagName('h2');for(var i=0;i<C.length;i++){if(C.item(i).hasAttribute('style')&&C.item(i).getAttribute('style').match(/mso-list:/)){C.item(i).className="MsoListParagraph";}}B=A.getElementsByClassName('MsoNormal');while(B.length){if(B.item(0).hasAttribute('style')&&B.item(0).getAttribute('style').match(/mso-list:/)){B.item(0).className="MsoListParagraph";
+}else{B.item(0).className="MsoNormalx";}}B=A.getElementsByClassName('ql-indent-1');while(B.length){this.replaceDocBullet(B.item(0));}B=A.getElementsByClassName('MsoListParagraph');while(B.length){this.replaceDocBullet(B.item(0));}},replaceDocBullet:function(p){var ns=p,A=p.parentNode,B=A.ownerDocument,C=[];
+while(ns){if(ns.nodeType!=1){ns=ns.nextSibling;continue;}if(!ns.className.match(/(MsoListParagraph|ql-indent-1)/i)){break;}if(ns.getAttribute('style').match(/mso-list/)){C.push(ns);ns=ns.nextSibling;E=true;continue;}var D=ns.getElementsByTagName('span');if(!D.length){break;
+}var E=false;for(var i=0;i<D.length;i++){if(D[i].getAttribute('style').match(/mso-list/)){E=true;break;}}if(!E){break;}C.push(ns);ns=ns.nextSibling;}if(!C.length){ns.className="";return;}var ul=A.ownerDocument.createElement('ul');A.insertBefore(ul,p);var F=0;
+var G=[ul];var H=false;var I={};max_margins=-1;C.forEach(function(n,J){var K=n.getElementsByTagName('span');if(!K.length){A.removeChild(n);return;}var L={};for(var i=0;i<K.length;i++){L=this.styleToObject(K[i]);if(typeof(L['mso-list'])=='undefined'){continue;
+}K[i].parentNode.removeChild(K[i]);break;}L=this.styleToObject(n);if(typeof(L['mso-list'])=='undefined'){A.removeChild(n);return;}var M=L['margin-left'];if(typeof(I[M])=='undefined'){max_margins++;I[M]=max_margins;}nlvl=I[M];if(nlvl>F){var N=B.createElement('ul');
+if(!H){H=B.createElement('li');G[F].appendChild(H);}H.appendChild(N);G[nlvl]=N;}F=nlvl;var O=G[nlvl].appendChild(B.createElement('li'));H=O;O.innerHTML=n.innerHTML;A.removeChild(n);},this);}});
 // Roo/htmleditor/FilterStyleToTag.js
 Roo.htmleditor.FilterStyleToTag=function(A){this.tags={B:['fontWeight','bold'],I:['fontStyle','italic'],SUP:['verticalAlign','super'],SUB:['verticalAlign','sub']};Roo.apply(this,A);this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterStyleToTag,Roo.htmleditor.Filter,{tag:true,tags:false,replaceTag:function(A){if(A.getAttribute("style")===null){return true;
 }var B=[];for(var k in this.tags){if(A.style[this.tags[k][0]]==this.tags[k][1]){B.push(k);A.style.removeProperty(this.tags[k][0]);}}if(!B.length){return true;}var cn=Array.from(A.childNodes);var nn=A;Roo.each(B,function(t){var nc=A.ownerDocument.createElement(t);
index 1c1d336..bbbe6a8 100644 (file)
@@ -46206,12 +46206,11 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
         });
         return ret;
     },
-    
-    
+     
     replaceDocBullets : function(doc)
     {
         // this is a bit odd - but it appears some indents use ql-indent-1
-         //Roo.log(doc.innerHTML);
+        //Roo.log(doc.innerHTML);
         
         var listpara = doc.getElementsByClassName('MsoListParagraphCxSpFirst');
         for( var i = 0; i < listpara.length; i ++) {
@@ -46220,11 +46219,18 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
         // this is a bit hacky - we had one word document where h2 had a miso-list attribute.
         var htwo = doc.getElementsByTagName('h2');
         for( var i = 0; i < htwo.length; i ++) {
-            if (htwo.item(i).getAttribute('style').match(/mso-list:/)) {
+            if (htwo.item(i).hasAttribute('style') && htwo.item(i).getAttribute('style').match(/mso-list:/)) {
                 htwo.item(i).className = "MsoListParagraph";
             }
         }
-        
+        listpara = doc.getElementsByClassName('MsoNormal');
+        while(listpara.length) {
+            if (listpara.item(0).hasAttribute('style') && listpara.item(0).getAttribute('style').match(/mso-list:/)) {
+                listpara.item(0).className = "MsoListParagraph";
+            } else {
+                listpara.item(0).className = "MsoNormalx";
+            }
+        }
         listpara = doc.getElementsByClassName('ql-indent-1');
         while(listpara.length) {
             this.replaceDocBullet(listpara.item(0));
@@ -46256,6 +46262,12 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
             if (!ns.className.match(/(MsoListParagraph|ql-indent-1)/i)) {
                 break;
             }
+            if (ns.getAttribute('style').match(/mso-list/)) {
+                items.push(ns);
+                ns = ns.nextSibling;
+                has_list = true;
+                continue;
+            }
             var spans = ns.getElementsByTagName('span');
             if (!spans.length) {
                 break;
@@ -46270,10 +46282,10 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
             if (!has_list) {
                 break;
             }
-            
-            
             items.push(ns);
             ns = ns.nextSibling;
+            
+            
         }
         if (!items.length) {
             ns.className = "";
@@ -46286,7 +46298,9 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
         var stack = [ ul ];
         var last_li = false;
         
-         
+        var margin_to_depth = {};
+        max_margins = -1;
+        
         items.forEach(function(n, ipos) {
             //Roo.log("got innertHMLT=" + n.innerHTML);
             
@@ -46317,15 +46331,18 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
             style = this.styleToObject(n); // mo-list is from the parent node.
             if (typeof(style['mso-list']) == 'undefined') {
                 //Roo.log("parent is missing level");
-                
-                 
+                  
                 parent.removeChild(n);
                  
                 return;
             }
             
-            var nlvl =   (style['mso-list'].split(' ')[1].replace(/level/,'') *1) - 1  ;
-            
+            var margin = style['margin-left'];
+            if (typeof(margin_to_depth[margin]) == 'undefined') {
+                max_margins++;
+                margin_to_depth[margin] = max_margins;
+            }
+            nlvl = margin_to_depth[margin] ;
              
             if (nlvl > lvl) {
                 //new indent
index 17bdaa9..27bb052 100644 (file)
@@ -21714,12 +21714,11 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
         });
         return ret;
     },
-    
-    
+     
     replaceDocBullets : function(doc)
     {
         // this is a bit odd - but it appears some indents use ql-indent-1
-         //Roo.log(doc.innerHTML);
+        //Roo.log(doc.innerHTML);
         
         var listpara = doc.getElementsByClassName('MsoListParagraphCxSpFirst');
         for( var i = 0; i < listpara.length; i ++) {
@@ -21728,11 +21727,18 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
         // this is a bit hacky - we had one word document where h2 had a miso-list attribute.
         var htwo = doc.getElementsByTagName('h2');
         for( var i = 0; i < htwo.length; i ++) {
-            if (htwo.item(i).getAttribute('style').match(/mso-list:/)) {
+            if (htwo.item(i).hasAttribute('style') && htwo.item(i).getAttribute('style').match(/mso-list:/)) {
                 htwo.item(i).className = "MsoListParagraph";
             }
         }
-        
+        listpara = doc.getElementsByClassName('MsoNormal');
+        while(listpara.length) {
+            if (listpara.item(0).hasAttribute('style') && listpara.item(0).getAttribute('style').match(/mso-list:/)) {
+                listpara.item(0).className = "MsoListParagraph";
+            } else {
+                listpara.item(0).className = "MsoNormalx";
+            }
+        }
         listpara = doc.getElementsByClassName('ql-indent-1');
         while(listpara.length) {
             this.replaceDocBullet(listpara.item(0));
@@ -21764,6 +21770,12 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
             if (!ns.className.match(/(MsoListParagraph|ql-indent-1)/i)) {
                 break;
             }
+            if (ns.getAttribute('style').match(/mso-list/)) {
+                items.push(ns);
+                ns = ns.nextSibling;
+                has_list = true;
+                continue;
+            }
             var spans = ns.getElementsByTagName('span');
             if (!spans.length) {
                 break;
@@ -21778,10 +21790,10 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
             if (!has_list) {
                 break;
             }
-            
-            
             items.push(ns);
             ns = ns.nextSibling;
+            
+            
         }
         if (!items.length) {
             ns.className = "";
@@ -21794,7 +21806,9 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
         var stack = [ ul ];
         var last_li = false;
         
-         
+        var margin_to_depth = {};
+        max_margins = -1;
+        
         items.forEach(function(n, ipos) {
             //Roo.log("got innertHMLT=" + n.innerHTML);
             
@@ -21825,15 +21839,18 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
             style = this.styleToObject(n); // mo-list is from the parent node.
             if (typeof(style['mso-list']) == 'undefined') {
                 //Roo.log("parent is missing level");
-                
-                 
+                  
                 parent.removeChild(n);
                  
                 return;
             }
             
-            var nlvl =   (style['mso-list'].split(' ')[1].replace(/level/,'') *1) - 1  ;
-            
+            var margin = style['margin-left'];
+            if (typeof(margin_to_depth[margin]) == 'undefined') {
+                max_margins++;
+                margin_to_depth[margin] = max_margins;
+            }
+            nlvl = margin_to_depth[margin] ;
              
             if (nlvl > lvl) {
                 //new indent
index 1cd3858..6880d15 100644 (file)
@@ -985,12 +985,13 @@ A.removeChild(cn);A.parentNode.insertBefore(cn,A);if(cn.nodeType==1){this.replac
 }C.push(F);});A.className=C.length?C.join(' '):'';if(!C.length){A.removeAttribute("class");}}if(A.hasAttribute("lang")){A.removeAttribute("lang");}if(A.hasAttribute("style")){var D=A.getAttribute("style").split(";");var E=[];Roo.each(D,function(s){if(!s.match(/:/)){return;
 }var kv=s.split(":");if(kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)){return;}E.push(s);});A.setAttribute("style",E.length?E.join(';'):'');if(!E.length){A.removeAttribute('style');}}return true;},styleToObject:function(A){var B=(A.getAttribute("style")||'').split(";");
 var C={};Roo.each(B,function(s){if(!s.match(/:/)){return;}var kv=s.split(":");C[kv[0].trim()]=kv[1];});return C;},replaceDocBullets:function(A){var B=A.getElementsByClassName('MsoListParagraphCxSpFirst');for(var i=0;i<B.length;i++){B.item(i).className="MsoListParagraph";
-}var C=A.getElementsByTagName('h2');for(var i=0;i<C.length;i++){if(C.item(i).getAttribute('style').match(/mso-list:/)){C.item(i).className="MsoListParagraph";}}B=A.getElementsByClassName('ql-indent-1');while(B.length){this.replaceDocBullet(B.item(0));}B=A.getElementsByClassName('MsoListParagraph');
-while(B.length){this.replaceDocBullet(B.item(0));}},replaceDocBullet:function(p){var ns=p,A=p.parentNode,B=A.ownerDocument,C=[];while(ns){if(ns.nodeType!=1){ns=ns.nextSibling;continue;}if(!ns.className.match(/(MsoListParagraph|ql-indent-1)/i)){break;}var D=ns.getElementsByTagName('span');
-if(!D.length){break;}var E=false;for(var i=0;i<D.length;i++){if(D[i].getAttribute('style').match(/mso-list/)){E=true;break;}}if(!E){break;}C.push(ns);ns=ns.nextSibling;}if(!C.length){ns.className="";return;}var ul=A.ownerDocument.createElement('ul');A.insertBefore(ul,p);
-var F=0;var G=[ul];var H=false;C.forEach(function(n,I){var J=n.getElementsByTagName('span');if(!J.length){A.removeChild(n);return;}var K={};for(var i=0;i<J.length;i++){K=this.styleToObject(J[i]);if(typeof(K['mso-list'])=='undefined'){continue;}J[i].parentNode.removeChild(J[i]);
-break;}K=this.styleToObject(n);if(typeof(K['mso-list'])=='undefined'){A.removeChild(n);return;}var L=(K['mso-list'].split(' ')[1].replace(/level/,'')*1)-1;if(L>F){var M=B.createElement('ul');if(!H){H=B.createElement('li');G[F].appendChild(H);}H.appendChild(M);
-G[L]=M;}F=L;var N=G[L].appendChild(B.createElement('li'));H=N;N.innerHTML=n.innerHTML;A.removeChild(n);},this);}});
+}var C=A.getElementsByTagName('h2');for(var i=0;i<C.length;i++){if(C.item(i).hasAttribute('style')&&C.item(i).getAttribute('style').match(/mso-list:/)){C.item(i).className="MsoListParagraph";}}B=A.getElementsByClassName('MsoNormal');while(B.length){if(B.item(0).hasAttribute('style')&&B.item(0).getAttribute('style').match(/mso-list:/)){B.item(0).className="MsoListParagraph";
+}else{B.item(0).className="MsoNormalx";}}B=A.getElementsByClassName('ql-indent-1');while(B.length){this.replaceDocBullet(B.item(0));}B=A.getElementsByClassName('MsoListParagraph');while(B.length){this.replaceDocBullet(B.item(0));}},replaceDocBullet:function(p){var ns=p,A=p.parentNode,B=A.ownerDocument,C=[];
+while(ns){if(ns.nodeType!=1){ns=ns.nextSibling;continue;}if(!ns.className.match(/(MsoListParagraph|ql-indent-1)/i)){break;}if(ns.getAttribute('style').match(/mso-list/)){C.push(ns);ns=ns.nextSibling;E=true;continue;}var D=ns.getElementsByTagName('span');if(!D.length){break;
+}var E=false;for(var i=0;i<D.length;i++){if(D[i].getAttribute('style').match(/mso-list/)){E=true;break;}}if(!E){break;}C.push(ns);ns=ns.nextSibling;}if(!C.length){ns.className="";return;}var ul=A.ownerDocument.createElement('ul');A.insertBefore(ul,p);var F=0;
+var G=[ul];var H=false;var I={};max_margins=-1;C.forEach(function(n,J){var K=n.getElementsByTagName('span');if(!K.length){A.removeChild(n);return;}var L={};for(var i=0;i<K.length;i++){L=this.styleToObject(K[i]);if(typeof(L['mso-list'])=='undefined'){continue;
+}K[i].parentNode.removeChild(K[i]);break;}L=this.styleToObject(n);if(typeof(L['mso-list'])=='undefined'){A.removeChild(n);return;}var M=L['margin-left'];if(typeof(I[M])=='undefined'){max_margins++;I[M]=max_margins;}nlvl=I[M];if(nlvl>F){var N=B.createElement('ul');
+if(!H){H=B.createElement('li');G[F].appendChild(H);}H.appendChild(N);G[nlvl]=N;}F=nlvl;var O=G[nlvl].appendChild(B.createElement('li'));H=O;O.innerHTML=n.innerHTML;A.removeChild(n);},this);}});
 // Roo/htmleditor/FilterStyleToTag.js
 Roo.htmleditor.FilterStyleToTag=function(A){this.tags={B:['fontWeight','bold'],I:['fontStyle','italic'],SUP:['verticalAlign','super'],SUB:['verticalAlign','sub']};Roo.apply(this,A);this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterStyleToTag,Roo.htmleditor.Filter,{tag:true,tags:false,replaceTag:function(A){if(A.getAttribute("style")===null){return true;
 }var B=[];for(var k in this.tags){if(A.style[this.tags[k][0]]==this.tags[k][1]){B.push(k);A.style.removeProperty(this.tags[k][0]);}}if(!B.length){return true;}var cn=Array.from(A.childNodes);var nn=A;Roo.each(B,function(t){var nc=A.ownerDocument.createElement(t);