From 033b515c313074785a53f256cf1d15791c6f58ca Mon Sep 17 00:00:00 2001 From: Alan Date: Fri, 13 Jan 2023 16:11:55 +0800 Subject: [PATCH] try second span if cant find font in first --- docs/src/Roo_htmleditor_FilterWord.js.html | 22 +++++++++++++++----- roojs-all.js | 12 +++++------ roojs-debug.js | 24 ++++++++++++++++------ roojs-ui-debug.js | 24 ++++++++++++++++------ roojs-ui.js | 12 +++++------ 5 files changed, 65 insertions(+), 29 deletions(-) diff --git a/docs/src/Roo_htmleditor_FilterWord.js.html b/docs/src/Roo_htmleditor_FilterWord.js.html index 70bc7c9d8b..bc4414698b 100644 --- a/docs/src/Roo_htmleditor_FilterWord.js.html +++ b/docs/src/Roo_htmleditor_FilterWord.js.html @@ -226,6 +226,7 @@ doc = parent.ownerDocument, items = []; + //Roo.log("Parsing: " + p.innerText) ; var listtype = 'ul'; while (ns) { if (ns.nodeType != 1) { @@ -233,22 +234,33 @@ 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; diff --git a/roojs-all.js b/roojs-all.js index a800828577..8d18e03a4d 100644 --- a/roojs-all.js +++ b/roojs-all.js @@ -1939,12 +1939,12 @@ for(var i=0;iH){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;iG){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); diff --git a/roojs-debug.js b/roojs-debug.js index b98d488887..75b2070a88 100644 --- a/roojs-debug.js +++ b/roojs-debug.js @@ -46368,7 +46368,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) { @@ -46376,22 +46377,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; diff --git a/roojs-ui-debug.js b/roojs-ui-debug.js index 41d2be3a4a..55c765320b 100644 --- a/roojs-ui-debug.js +++ b/roojs-ui-debug.js @@ -21869,7 +21869,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) { @@ -21877,22 +21878,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; diff --git a/roojs-ui.js b/roojs-ui.js index fbabd87648..b24d21446a 100644 --- a/roojs-ui.js +++ b/roojs-ui.js @@ -992,12 +992,12 @@ for(var i=0;iH){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;iG){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); -- 2.39.2