try second span if cant find font in first
authorAlan <alan@roojs.com>
Fri, 13 Jan 2023 08:10:42 +0000 (16:10 +0800)
committerAlan <alan@roojs.com>
Fri, 13 Jan 2023 08:10:42 +0000 (16:10 +0800)
Roo/htmleditor/FilterWord.js
examples/bootstrap/Editor.html
roojs-bootstrap-debug.js
roojs-bootstrap.js

index 61d77eb..f8e695d 100644 (file)
@@ -225,7 +225,8 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
             parent = p.parentNode,
             doc = parent.ownerDocument,
             items = [];
-            
+         
+        //Roo.log("Parsing: " + p.innerText)    ;
         var listtype = 'ul';   
         while (ns) {
             if (ns.nodeType != 1) {
@@ -233,22 +234,33 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
                 continue;
             }
             if (!ns.className.match(/(MsoListParagraph|ql-indent-1)/i)) {
+                //Roo.log("Missing para r q1indent - got:" + ns.className);
                 break;
             }
             var spans = ns.getElementsByTagName('span');
+            
             if (ns.hasAttribute('style') && ns.getAttribute('style').match(/mso-list/)) {
                 items.push(ns);
                 ns = ns.nextSibling;
                 has_list = true;
-                if (spans.length && spans[0].hasAttribute('style')) {
-                    var  style = this.styleToObject(spans[0]);
-                    if (typeof(style['font-family']) != 'undefined' && !style['font-family'].match(/Symbol/)) {
-                        listtype = 'ol';
-                    }
+                if (!spans.length) {
+                    continue;
+                }
+                var ff = spans[0].style.fontFamily;
+                if (!spans[0].hasAttribute('style') && spans.length  > 1 && spans[1].hasAttribute('style')) {
+                    
+                    ff = spans[1].style.fontFamily;
+                }
+                    //var  style = this.styleToObject(spans[0]);
+                //Roo.log("got font family: " + ff);
+                if (typeof(ff) != 'undefined' && !ff.match(/Symbol/)) {
+                    listtype = 'ol';
                 }
                 
                 continue;
             }
+            //Roo.log("no mso-list?");
+            
             var spans = ns.getElementsByTagName('span');
             if (!spans.length) {
                 break;
index 0b1d9ef..f38541f 100644 (file)
@@ -18,8 +18,8 @@
     <!-- bootstrap js.. needs to compile it later.. -->
     <script type="text/javascript" src="../../Roo/HtmlEditorCore.js"></script>
 
-     <script type="text/javascript" src="../../Roo/bootstrap/form/HtmlEditor.js"></script>
-
+    <script type="text/javascript" src="../../Roo/bootstrap/form/HtmlEditor.js"></script>
+    <script type="text/javascript" src="../../Roo/htmleditor/FilterWord.js"></script>
     
     
     <!-- test code -->
index fe00f5c..a4afb8e 100644 (file)
@@ -27204,7 +27204,8 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
             parent = p.parentNode,
             doc = parent.ownerDocument,
             items = [];
-            
+         
+        //Roo.log("Parsing: " + p.innerText)    ;
         var listtype = 'ul';   
         while (ns) {
             if (ns.nodeType != 1) {
@@ -27212,22 +27213,33 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
                 continue;
             }
             if (!ns.className.match(/(MsoListParagraph|ql-indent-1)/i)) {
+                //Roo.log("Missing para r q1indent - got:" + ns.className);
                 break;
             }
             var spans = ns.getElementsByTagName('span');
+            
             if (ns.hasAttribute('style') && ns.getAttribute('style').match(/mso-list/)) {
                 items.push(ns);
                 ns = ns.nextSibling;
                 has_list = true;
-                if (spans.length && spans[0].hasAttribute('style')) {
-                    var  style = this.styleToObject(spans[0]);
-                    if (typeof(style['font-family']) != 'undefined' && !style['font-family'].match(/Symbol/)) {
-                        listtype = 'ol';
-                    }
+                if (!spans.length) {
+                    continue;
+                }
+                var ff = spans[0].style.fontFamily;
+                if (!spans[0].hasAttribute('style') && spans.length  > 1 && spans[1].hasAttribute('style')) {
+                    
+                    ff = spans[1].style.fontFamily;
+                }
+                    //var  style = this.styleToObject(spans[0]);
+                //Roo.log("got font family: " + ff);
+                if (typeof(ff) != 'undefined' && !ff.match(/Symbol/)) {
+                    listtype = 'ol';
                 }
                 
                 continue;
             }
+            //Roo.log("no mso-list?");
+            
             var spans = ns.getElementsByTagName('span');
             if (!spans.length) {
                 break;
index b6fe03d..dbad11c 100644 (file)
@@ -1194,12 +1194,12 @@ for(var i=0;i<B.length;i++){B[i].className="MsoListParagraph";}B=Array.from(A.ge
 i<B.length;i++){B[i].className="MsoListParagraph";}var C=Array.from(A.getElementsByTagName('h2'));for(var i=0;i<C.length;i++){if(C[i].hasAttribute('style')&&C[i].getAttribute('style').match(/mso-list:/)){C[i].className="MsoListParagraph";}}B=Array.from(A.getElementsByClassName('MsoNormal'));
 for(var i=0;i<B.length;i++){if(B[i].hasAttribute('style')&&B[i].getAttribute('style').match(/mso-list:/)){B[i].className="MsoListParagraph";}else{B[i].className="MsoNormalx";}}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=[];var D='ul';while(ns){if(ns.nodeType!=1){ns=ns.nextSibling;continue;}if(!ns.className.match(/(MsoListParagraph|ql-indent-1)/i)){break;}var E=ns.getElementsByTagName('span');if(ns.hasAttribute('style')&&ns.getAttribute('style').match(/mso-list/)){C.push(ns);
-ns=ns.nextSibling;G=true;if(E.length&&E[0].hasAttribute('style')){var F=this.styleToObject(E[0]);if(typeof(F['font-family'])!='undefined'&&!F['font-family'].match(/Symbol/)){D='ol';}}continue;}var E=ns.getElementsByTagName('span');if(!E.length){break;}var G=false;
-for(var i=0;i<E.length;i++){if(E[i].hasAttribute('style')&&E[i].getAttribute('style').match(/mso-list/)){G=true;break;}}if(!G){break;}C.push(ns);ns=ns.nextSibling;}if(!C.length){ns.className="";return;}var ul=A.ownerDocument.createElement(D);A.insertBefore(ul,p);
-var H=0;var I=[ul];var J=false;var K={};max_margins=-1;C.forEach(function(n,L){var M=n.getElementsByTagName('span');if(!M.length){A.removeChild(n);return;}var N=1;var O={};for(var i=0;i<M.length;i++){O=this.styleToObject(M[i]);if(typeof(O['mso-list'])=='undefined'){continue;
-}if(D=='ol'){N=M[i].innerText.replace(/[^0-9]+]/g,'')*1;}M[i].parentNode.removeChild(M[i]);break;}O=this.styleToObject(n);if(typeof(O['mso-list'])=='undefined'){A.removeChild(n);return;}var P=O['margin-left'];if(typeof(K[P])=='undefined'){max_margins++;K[P]=max_margins;
-}nlvl=K[P];if(nlvl>H){var Q=B.createElement(D);if(!J){J=B.createElement('li');I[H].appendChild(J);}J.appendChild(Q);I[nlvl]=Q;}H=nlvl;if(!I[nlvl].hasAttribute("start")&&D=="ol"){I[nlvl].setAttribute("start",N);}var R=I[nlvl].appendChild(B.createElement('li'));
-J=R;R.innerHTML=n.innerHTML;A.removeChild(n);},this);}});
+ns=ns.nextSibling;F=true;if(!E.length){continue;}var ff=E[0].style.fontFamily;if(!E[0].hasAttribute('style')&&E.length>1&&E[1].hasAttribute('style')){ff=E[1].style.fontFamily;}if(typeof(ff)!='undefined'&&!ff.match(/Symbol/)){D='ol';}continue;}var E=ns.getElementsByTagName('span');
+if(!E.length){break;}var F=false;for(var i=0;i<E.length;i++){if(E[i].hasAttribute('style')&&E[i].getAttribute('style').match(/mso-list/)){F=true;break;}}if(!F){break;}C.push(ns);ns=ns.nextSibling;}if(!C.length){ns.className="";return;}var ul=A.ownerDocument.createElement(D);
+A.insertBefore(ul,p);var G=0;var H=[ul];var I=false;var J={};max_margins=-1;C.forEach(function(n,K){var L=n.getElementsByTagName('span');if(!L.length){A.removeChild(n);return;}var M=1;var N={};for(var i=0;i<L.length;i++){N=this.styleToObject(L[i]);if(typeof(N['mso-list'])=='undefined'){continue;
+}if(D=='ol'){M=L[i].innerText.replace(/[^0-9]+]/g,'')*1;}L[i].parentNode.removeChild(L[i]);break;}N=this.styleToObject(n);if(typeof(N['mso-list'])=='undefined'){A.removeChild(n);return;}var O=N['margin-left'];if(typeof(J[O])=='undefined'){max_margins++;J[O]=max_margins;
+}nlvl=J[O];if(nlvl>G){var P=B.createElement(D);if(!I){I=B.createElement('li');H[G].appendChild(I);}I.appendChild(P);H[nlvl]=P;}G=nlvl;if(!H[nlvl].hasAttribute("start")&&D=="ol"){H[nlvl].setAttribute("start",M);}var Q=H[nlvl].appendChild(B.createElement('li'));
+I=Q;Q.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);