From 48377717df34ac2a2f30dece0223c040854418dd Mon Sep 17 00:00:00 2001 From: Alan Date: Fri, 13 Jan 2023 16:10:42 +0800 Subject: [PATCH] try second span if cant find font in first --- Roo/htmleditor/FilterWord.js | 24 ++++++++++++++++++------ examples/bootstrap/Editor.html | 4 ++-- roojs-bootstrap-debug.js | 24 ++++++++++++++++++------ roojs-bootstrap.js | 12 ++++++------ 4 files changed, 44 insertions(+), 20 deletions(-) diff --git a/Roo/htmleditor/FilterWord.js b/Roo/htmleditor/FilterWord.js index 61d77eb84c..f8e695d124 100644 --- a/Roo/htmleditor/FilterWord.js +++ b/Roo/htmleditor/FilterWord.js @@ -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; diff --git a/examples/bootstrap/Editor.html b/examples/bootstrap/Editor.html index 0b1d9ef48e..f38541f45a 100644 --- a/examples/bootstrap/Editor.html +++ b/examples/bootstrap/Editor.html @@ -18,8 +18,8 @@ - - + + diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index fe00f5c123..a4afb8e9e5 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -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; diff --git a/roojs-bootstrap.js b/roojs-bootstrap.js index b6fe03da0f..dbad11c1fc 100644 --- a/roojs-bootstrap.js +++ b/roojs-bootstrap.js @@ -1194,12 +1194,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