From 5e20d2d4c06f3b903975ec0a90550d5d9cca8779 Mon Sep 17 00:00:00 2001 From: Alan Date: Thu, 14 Apr 2022 11:26:09 +0800 Subject: [PATCH] try and use xml serializer to correctly ouput text --- Roo/htmleditor/TidyWriter.js | 6 +- docs/src/Roo_htmleditor_FilterWord.js.html | 66 ++++++++++++++++------ docs/src/Roo_htmleditor_TidyWriter.js.html | 6 +- roojs-all.js | 10 ++-- roojs-bootstrap-debug.js | 52 +++++++++++++---- roojs-bootstrap.js | 13 +++-- roojs-debug.js | 6 +- roojs-ui-debug.js | 6 +- roojs-ui.js | 10 ++-- 9 files changed, 122 insertions(+), 53 deletions(-) diff --git a/Roo/htmleditor/TidyWriter.js b/Roo/htmleditor/TidyWriter.js index 9db08abc72..34a6b34c08 100644 --- a/Roo/htmleditor/TidyWriter.js +++ b/Roo/htmleditor/TidyWriter.js @@ -186,12 +186,14 @@ Roo.htmleditor.TidyWriter.prototype = { * @param {String} text String to write out. * @param {Boolean} raw Optional raw state if true the contents wont get encoded. */ - text: function(text, node) + text: function(in_text, node) { // if not in whitespace critical - if (text.length < 1) { + if (in_text.length < 1) { return; } + var text = new XMLSerializer().serializeToString(document.createTextNode(in_text)); // escape it properly? + if (this.in_pre) { this.html[this.html.length] = text; return; diff --git a/docs/src/Roo_htmleditor_FilterWord.js.html b/docs/src/Roo_htmleditor_FilterWord.js.html index 068de8ada7..39c0cf9e51 100644 --- a/docs/src/Roo_htmleditor_FilterWord.js.html +++ b/docs/src/Roo_htmleditor_FilterWord.js.html @@ -14,10 +14,10 @@ // no need to apply config. this.replaceDocBullets(cfg.node); - this.walk(cfg.node); + // this.walk(cfg.node); -} +} Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, { @@ -125,7 +125,7 @@ styleToObject: function(node) { - var styles = node.getAttribute("style").split(";"); + var styles = (node.getAttribute("style") || '').split(";"); var ret = {}; Roo.each(styles, function(s) { if (!s.match(/:/)) { @@ -142,11 +142,17 @@ replaceDocBullets : function(doc) { + // this is a bit odd - but it appears some indents use ql-indent-1 + + var listpara = doc.getElementsByClassName('ql-indent-1'); + while(listpara.length) { + this.replaceDocBullet(listpara.item(0)); + } + var listpara = doc.getElementsByClassName('MsoListParagraph'); while(listpara.length) { this.replaceDocBullet(listpara.item(0)); - //code - } + } }, replaceDocBullet : function(p) @@ -161,7 +167,7 @@ ns = ns.nextSibling; continue; } - if (!ns.className.match(/MsoListParagraph/i)) { + if (!ns.className.match(/(MsoListParagraph|ql-indent-1)/i)) { break; } items.push(ns); @@ -174,17 +180,37 @@ var stack = [ ul ]; var last_li = false; items.forEach(function(n) { - parent.removeChild(n); + //Roo.log("got innertHMLT=" + n.innerHTML); + var spans = n.getElementsByTagName('span'); - if (!spans.length || !n.isEqualNode(spans.item(0).parentNode)) { + if (!spans.length) { + //Roo.log("No spans found"); + + parent.removeChild(n); return; // skip it... } - var style = this.styleToObject(n); + + + var style = {}; + for(var i = 0; i < spans.length; i++) { + + style = this.styleToObject(spans[i]); + if (typeof(style['mso-list']) == 'undefined') { + continue; + } + + spans[i].parentNode.removeChild(spans[i]); // remove the fake bullet. + break; + } + //Roo.log("NOW GOT innertHMLT=" + n.innerHTML); + style = this.styleToObject(n); // mo-list is from the parent node. if (typeof(style['mso-list']) == 'undefined') { - return; // skip it. - } - n.removeChild(spans.item(0)); // remove the fake bullet. + //Roo.log("parent is missing level"); + parent.removeChild(n); + return; + } + var nlvl = (style['mso-list'].split(' ')[1].replace(/level/,'') *1) - 1; if (nlvl > lvl) { //new indent @@ -196,15 +222,19 @@ var nli = stack[nlvl].appendChild(doc.createElement('li')); last_li = nli; + nli.innerHTML = n.innerHTML; + //Roo.log("innerHTML = " + n.innerHTML); + parent.removeChild(n); + // copy children of p into nli - while(n.firstChild) { - var fc = n.firstChild; - n.removeChild(fc); - nli.appendChild(fc); - } + /*while(n.firstChild) { + var fc = n.firstChild; + n.removeChild(fc); + nli.appendChild(fc); + }*/ - },this); + },this); diff --git a/docs/src/Roo_htmleditor_TidyWriter.js.html b/docs/src/Roo_htmleditor_TidyWriter.js.html index 3dd67335ea..16d42bb90b 100644 --- a/docs/src/Roo_htmleditor_TidyWriter.js.html +++ b/docs/src/Roo_htmleditor_TidyWriter.js.html @@ -186,12 +186,14 @@ * @param {String} text String to write out. * @param {Boolean} raw Optional raw state if true the contents wont get encoded. */ - text: function(text, node) + text: function(in_text, node) { // if not in whitespace critical - if (text.length < 1) { + if (in_text.length < 1) { return; } + var text = new XMLSerializer().serializeToString(document.createTextNode(in_text)); // escape it properly? + if (this.in_pre) { this.html[this.html.length] = text; return; diff --git a/roojs-all.js b/roojs-all.js index bca7579563..f37c11fde6 100644 --- a/roojs-all.js +++ b/roojs-all.js @@ -1957,11 +1957,11 @@ var G=this.in_inline||Roo.htmleditor.TidyWriter.inline_elements.indexOf(A)>-1;va }var K=this.indentstr;if(!this.in_pre){if(G){if(A=='BR'){this.addLine();}else if(this.lastElementEndsWS()){this.addLine();}else{K='';}}else{this.addLine();}}else{K='';}this.html.push(K+'<',A.toLowerCase());if(B){for(i=0,l=B.length;i';}var L=A=='BR'?false:this.in_inline;if(!L&&!this.in_pre){this.addLine();}return;}this.html[this.html.length]='>';this.pushState({indentstr:H?'':(this.indentstr+this.indent),in_pre:H,in_inline:G} );if(!G&&!H){this.addLine();}},lastElementEndsWS:function(){var A=this.html.length>0?this.html[this.html.length-1]:false;if(A===false){return true;}return A.match(/\s+$/);},end:function(A){var B;this.popState();var C='';var D=this.in_inline||Roo.htmleditor.TidyWriter.inline_elements.indexOf(A)>-1; -if(!this.in_pre&&!D){this.addLine();C=this.indentstr;}this.html.push(C+'');this.last_inline=D;},text:function(A,B){if(A.length<1){return;}if(this.in_pre){this.html[this.html.length]=A;return;}if(this.in_inline){A=A.replace(/\s+/g,' '); -if(A!=' '){A=A.replace(/\s+/,' ');if(B.nextSibling&&B.nextSibling.nodeType==1&&B.nextSibling.nodeName=='BR'){A=A.replace(/\s+$/g,'');}if(B.previousSibling&&B.previousSibling.nodeType==1&&B.previousSibling.nodeName=='BR'){A=this.indentstr+A.replace(/^\s+/g,''); -}if(A.match(/\n/)){A=A.replace(/(?![^\n]{1,64}$)([^\n]{1,64})\s/g,'$1\n'+this.indentstr);A=A.replace(/\n\s+$/,'');}}this.html[this.html.length]=A;return;}var C=this.indentstr;A=A.replace(/\s+/g," ");if(B.previousSibling&&B.previousSibling.nodeType==1&&Roo.htmleditor.TidyWriter.inline_elements.indexOf(B.previousSibling.nodeName)>-1){C=''; -}else{this.addLine();A=A.replace(/^\s+/,'');}if(B.nextSibling&&B.nextSibling.nodeType==1&&Roo.htmleditor.TidyWriter.inline_elements.indexOf(B.nextSibling.nodeName)>-1){}else{A=A.replace(/\s+$/,'');}if(A.length<1){return;}if(!A.match(/\n/)){this.html.push(C+A); -return;}A=this.indentstr+A.replace(/(?![^\n]{1,64}$)([^\n]{1,64})\s/g,'$1\n'+this.indentstr);A=A.replace(/\s+$/,'');this.html.push(A);},cdata:function(A){this.html.push('');},comment:function(A){this.html.push('');},pi:function(A,B){B?this.html.push(''):this.html.push(''); +if(!this.in_pre&&!D){this.addLine();C=this.indentstr;}this.html.push(C+'');this.last_inline=D;},text:function(A,B){if(A.length<1){return;}var C=new XMLSerializer().serializeToString(document.createTextNode(A));if(this.in_pre){this.html[this.html.length]=C; +return;}if(this.in_inline){C=C.replace(/\s+/g,' ');if(C!=' '){C=C.replace(/\s+/,' ');if(B.nextSibling&&B.nextSibling.nodeType==1&&B.nextSibling.nodeName=='BR'){C=C.replace(/\s+$/g,'');}if(B.previousSibling&&B.previousSibling.nodeType==1&&B.previousSibling.nodeName=='BR'){C=this.indentstr+C.replace(/^\s+/g,''); +}if(C.match(/\n/)){C=C.replace(/(?![^\n]{1,64}$)([^\n]{1,64})\s/g,'$1\n'+this.indentstr);C=C.replace(/\n\s+$/,'');}}this.html[this.html.length]=C;return;}var D=this.indentstr;C=C.replace(/\s+/g," ");if(B.previousSibling&&B.previousSibling.nodeType==1&&Roo.htmleditor.TidyWriter.inline_elements.indexOf(B.previousSibling.nodeName)>-1){D=''; +}else{this.addLine();C=C.replace(/^\s+/,'');}if(B.nextSibling&&B.nextSibling.nodeType==1&&Roo.htmleditor.TidyWriter.inline_elements.indexOf(B.nextSibling.nodeName)>-1){}else{C=C.replace(/\s+$/,'');}if(C.length<1){return;}if(!C.match(/\n/)){this.html.push(D+C); +return;}C=this.indentstr+C.replace(/(?![^\n]{1,64}$)([^\n]{1,64})\s/g,'$1\n'+this.indentstr);C=C.replace(/\s+$/,'');this.html.push(C);},cdata:function(A){this.html.push('');},comment:function(A){this.html.push('');},pi:function(A,B){B?this.html.push(''):this.html.push(''); this.indent!=''&&this.html.push('\n');},doctype:function(A){this.html.push('',this.indent!=''?'\n':'');},reset:function(){this.html.length=0;this.state=[];this.pushState({indentstr:'',in_pre:false,in_inline:false})},getContent:function(){return this.html.join('').replace(/\n$/,''); },pushState:function(A){this.state.push(A);Roo.apply(this,A);},popState:function(){if(this.state.length<1){return;}var A={in_pre:false,indentstr:''};this.state.pop();if(this.state.length>0){A=this.state[this.state.length-1];}Roo.apply(this,A);},addLine:function(){if(this.html.length<1){return; }var A=this.html[this.html.length-1];if(A.length>0&&'\n'!==A){this.html.push('\n');}}};Roo.htmleditor.TidyWriter.inline_elements=['SPAN','STRONG','B','EM','I','FONT','STRIKE','U','VAR','CITE','DFN','CODE','MARK','Q','SUP','SUB','SAMP','A'];Roo.htmleditor.TidyWriter.shortend_elements=['AREA','BASE','BASEFONT','BR','COL','FRAME','HR','IMG','INPUT','ISINDEX','LINK','','META','PARAM','EMBED','SOURCE','WBR','TRACK']; diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index d417f6c182..7f9c067782 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -26460,7 +26460,7 @@ Roo.htmleditor.FilterWord = function(cfg) // no need to apply config. this.replaceDocBullets(cfg.node); - this.walk(cfg.node); + // this.walk(cfg.node); } @@ -26571,7 +26571,7 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, styleToObject: function(node) { - var styles = node.getAttribute("style").split(";"); + var styles = (node.getAttribute("style") || '').split(";"); var ret = {}; Roo.each(styles, function(s) { if (!s.match(/:/)) { @@ -26588,10 +26588,16 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, replaceDocBullets : function(doc) { + // this is a bit odd - but it appears some indents use ql-indent-1 + + var listpara = doc.getElementsByClassName('ql-indent-1'); + while(listpara.length) { + this.replaceDocBullet(listpara.item(0)); + } + var listpara = doc.getElementsByClassName('MsoListParagraph'); while(listpara.length) { this.replaceDocBullet(listpara.item(0)); - //code } }, @@ -26607,7 +26613,7 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, ns = ns.nextSibling; continue; } - if (!ns.className.match(/MsoListParagraph/i)) { + if (!ns.className.match(/(MsoListParagraph|ql-indent-1)/i)) { break; } items.push(ns); @@ -26620,17 +26626,37 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, var stack = [ ul ]; var last_li = false; items.forEach(function(n) { - parent.removeChild(n); + //Roo.log("got innertHMLT=" + n.innerHTML); + var spans = n.getElementsByTagName('span'); - if (!spans.length || !n.isEqualNode(spans.item(0).parentNode)) { + if (!spans.length) { + //Roo.log("No spans found"); + + parent.removeChild(n); return; // skip it... } + + - var style = this.styleToObject(n); + var style = {}; + for(var i = 0; i < spans.length; i++) { + + style = this.styleToObject(spans[i]); + if (typeof(style['mso-list']) == 'undefined') { + continue; + } + + spans[i].parentNode.removeChild(spans[i]); // remove the fake bullet. + break; + } + //Roo.log("NOW GOT innertHMLT=" + n.innerHTML); + style = this.styleToObject(n); // mo-list is from the parent node. if (typeof(style['mso-list']) == 'undefined') { - return; // skip it. + //Roo.log("parent is missing level"); + parent.removeChild(n); + return; } - n.removeChild(spans.item(0)); // remove the fake bullet. + var nlvl = (style['mso-list'].split(' ')[1].replace(/level/,'') *1) - 1; if (nlvl > lvl) { //new indent @@ -26642,12 +26668,16 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, var nli = stack[nlvl].appendChild(doc.createElement('li')); last_li = nli; + nli.innerHTML = n.innerHTML; + //Roo.log("innerHTML = " + n.innerHTML); + parent.removeChild(n); + // copy children of p into nli - while(n.firstChild) { + /*while(n.firstChild) { var fc = n.firstChild; n.removeChild(fc); nli.appendChild(fc); - } + }*/ },this); diff --git a/roojs-bootstrap.js b/roojs-bootstrap.js index d7469b1ca5..ba272eca15 100644 --- a/roojs-bootstrap.js +++ b/roojs-bootstrap.js @@ -1143,16 +1143,17 @@ Roo.htmleditor.FilterTableWidth=function(A){this.tag=['TABLE','TD','TR','TH','TH }if(A.hasAttribute("style")){var B=A.getAttribute("style").split(";");var C=[];Roo.each(B,function(s){if(!s.match(/:/)){return;}var kv=s.split(":");if(kv[0].match(/^\s*(width|min-width)\s*$/)){return;}C.push(s);});A.setAttribute("style",C.length?C.join(';'):''); if(!C.length){A.removeAttribute('style');}}return true;}}); // Roo/htmleditor/FilterWord.js -Roo.htmleditor.FilterWord=function(A){this.replaceDocBullets(A.node);this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterWord,Roo.htmleditor.Filter,{tag:true,replaceTag:function(A){if(A.nodeName=='SPAN'&&!A.hasAttributes()&&A.childNodes.length==1&&A.firstChild.nodeName=="#text"){var B=A.firstChild; +Roo.htmleditor.FilterWord=function(A){this.replaceDocBullets(A.node);};Roo.extend(Roo.htmleditor.FilterWord,Roo.htmleditor.Filter,{tag:true,replaceTag:function(A){if(A.nodeName=='SPAN'&&!A.hasAttributes()&&A.childNodes.length==1&&A.firstChild.nodeName=="#text"){var B=A.firstChild; A.removeChild(B);if(A.getAttribute('lang')!='zh-CN'){A.parentNode.insertBefore(A.ownerDocument.createTextNode(" "),A);}A.parentNode.insertBefore(B,A);if(A.getAttribute('lang')!='zh-CN'){A.parentNode.insertBefore(A.ownerDocument.createTextNode(" "),A);}A.parentNode.removeChild(A); return false;}if(A.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)){A.parentNode.removeChild(A);return false;}if(A.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|v:|font)/)){while(A.childNodes.length){var cn=A.childNodes[0]; A.removeChild(cn);A.parentNode.insertBefore(cn,A);if(cn.nodeType==1){this.replaceTag(cn);}}A.parentNode.removeChild(A);return false;}if(A.className.length){var cn=A.className.split(/\W+/);var C=[];Roo.each(cn,function(F){if(F.match(/Mso[a-zA-Z]+/)){return; }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]]=kv[1];});return C;},replaceDocBullets:function(A){var 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/i)){break;}C.push(ns);ns=ns.nextSibling;}var ul=A.ownerDocument.createElement('ul');A.insertBefore(ul,p);var D=0;var E=[ul];var F=false;C.forEach(function(n){A.removeChild(n); -var G=n.getElementsByTagName('span');if(!G.length||!n.isEqualNode(G.item(0).parentNode)){return;}var H=this.styleToObject(n);if(typeof(H['mso-list'])=='undefined'){return;}n.removeChild(G.item(0));var I=(H['mso-list'].split(' ')[1].replace(/level/,'')*1)-1; -if(I>D){var J=B.createElement('ul');F.appendChild(J);E[I]=J;}D=I;var K=E[I].appendChild(B.createElement('li'));F=K;while(n.firstChild){var fc=n.firstChild;n.removeChild(fc);K.appendChild(fc);}},this);}}); +}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]]=kv[1];});return C;},replaceDocBullets:function(A){var B=A.getElementsByClassName('ql-indent-1');while(B.length){this.replaceDocBullet(B.item(0));}var 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;}C.push(ns); +ns=ns.nextSibling;}var ul=A.ownerDocument.createElement('ul');A.insertBefore(ul,p);var D=0;var E=[ul];var F=false;C.forEach(function(n){var G=n.getElementsByTagName('span');if(!G.length){A.removeChild(n);return;}var H={};for(var i=0;iD){var J=B.createElement('ul'); +F.appendChild(J);E[I]=J;}D=I;var K=E[I].appendChild(B.createElement('li'));F=K;K.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 3a57b8d57a..047cba8461 100644 --- a/roojs-debug.js +++ b/roojs-debug.js @@ -46790,12 +46790,14 @@ Roo.htmleditor.TidyWriter.prototype = { * @param {String} text String to write out. * @param {Boolean} raw Optional raw state if true the contents wont get encoded. */ - text: function(text, node) + text: function(in_text, node) { // if not in whitespace critical - if (text.length < 1) { + if (in_text.length < 1) { return; } + var text = new XMLSerializer().serializeToString(document.createTextNode(in_text)); // escape it properly? + if (this.in_pre) { this.html[this.html.length] = text; return; diff --git a/roojs-ui-debug.js b/roojs-ui-debug.js index ead11143ef..27ca272f86 100644 --- a/roojs-ui-debug.js +++ b/roojs-ui-debug.js @@ -22298,12 +22298,14 @@ Roo.htmleditor.TidyWriter.prototype = { * @param {String} text String to write out. * @param {Boolean} raw Optional raw state if true the contents wont get encoded. */ - text: function(text, node) + text: function(in_text, node) { // if not in whitespace critical - if (text.length < 1) { + if (in_text.length < 1) { return; } + var text = new XMLSerializer().serializeToString(document.createTextNode(in_text)); // escape it properly? + if (this.in_pre) { this.html[this.html.length] = text; return; diff --git a/roojs-ui.js b/roojs-ui.js index 7605603234..d4cb311184 100644 --- a/roojs-ui.js +++ b/roojs-ui.js @@ -1011,11 +1011,11 @@ var G=this.in_inline||Roo.htmleditor.TidyWriter.inline_elements.indexOf(A)>-1;va }var K=this.indentstr;if(!this.in_pre){if(G){if(A=='BR'){this.addLine();}else if(this.lastElementEndsWS()){this.addLine();}else{K='';}}else{this.addLine();}}else{K='';}this.html.push(K+'<',A.toLowerCase());if(B){for(i=0,l=B.length;i';}var L=A=='BR'?false:this.in_inline;if(!L&&!this.in_pre){this.addLine();}return;}this.html[this.html.length]='>';this.pushState({indentstr:H?'':(this.indentstr+this.indent),in_pre:H,in_inline:G} );if(!G&&!H){this.addLine();}},lastElementEndsWS:function(){var A=this.html.length>0?this.html[this.html.length-1]:false;if(A===false){return true;}return A.match(/\s+$/);},end:function(A){var B;this.popState();var C='';var D=this.in_inline||Roo.htmleditor.TidyWriter.inline_elements.indexOf(A)>-1; -if(!this.in_pre&&!D){this.addLine();C=this.indentstr;}this.html.push(C+'');this.last_inline=D;},text:function(A,B){if(A.length<1){return;}if(this.in_pre){this.html[this.html.length]=A;return;}if(this.in_inline){A=A.replace(/\s+/g,' '); -if(A!=' '){A=A.replace(/\s+/,' ');if(B.nextSibling&&B.nextSibling.nodeType==1&&B.nextSibling.nodeName=='BR'){A=A.replace(/\s+$/g,'');}if(B.previousSibling&&B.previousSibling.nodeType==1&&B.previousSibling.nodeName=='BR'){A=this.indentstr+A.replace(/^\s+/g,''); -}if(A.match(/\n/)){A=A.replace(/(?![^\n]{1,64}$)([^\n]{1,64})\s/g,'$1\n'+this.indentstr);A=A.replace(/\n\s+$/,'');}}this.html[this.html.length]=A;return;}var C=this.indentstr;A=A.replace(/\s+/g," ");if(B.previousSibling&&B.previousSibling.nodeType==1&&Roo.htmleditor.TidyWriter.inline_elements.indexOf(B.previousSibling.nodeName)>-1){C=''; -}else{this.addLine();A=A.replace(/^\s+/,'');}if(B.nextSibling&&B.nextSibling.nodeType==1&&Roo.htmleditor.TidyWriter.inline_elements.indexOf(B.nextSibling.nodeName)>-1){}else{A=A.replace(/\s+$/,'');}if(A.length<1){return;}if(!A.match(/\n/)){this.html.push(C+A); -return;}A=this.indentstr+A.replace(/(?![^\n]{1,64}$)([^\n]{1,64})\s/g,'$1\n'+this.indentstr);A=A.replace(/\s+$/,'');this.html.push(A);},cdata:function(A){this.html.push('');},comment:function(A){this.html.push('');},pi:function(A,B){B?this.html.push(''):this.html.push(''); +if(!this.in_pre&&!D){this.addLine();C=this.indentstr;}this.html.push(C+'');this.last_inline=D;},text:function(A,B){if(A.length<1){return;}var C=new XMLSerializer().serializeToString(document.createTextNode(A));if(this.in_pre){this.html[this.html.length]=C; +return;}if(this.in_inline){C=C.replace(/\s+/g,' ');if(C!=' '){C=C.replace(/\s+/,' ');if(B.nextSibling&&B.nextSibling.nodeType==1&&B.nextSibling.nodeName=='BR'){C=C.replace(/\s+$/g,'');}if(B.previousSibling&&B.previousSibling.nodeType==1&&B.previousSibling.nodeName=='BR'){C=this.indentstr+C.replace(/^\s+/g,''); +}if(C.match(/\n/)){C=C.replace(/(?![^\n]{1,64}$)([^\n]{1,64})\s/g,'$1\n'+this.indentstr);C=C.replace(/\n\s+$/,'');}}this.html[this.html.length]=C;return;}var D=this.indentstr;C=C.replace(/\s+/g," ");if(B.previousSibling&&B.previousSibling.nodeType==1&&Roo.htmleditor.TidyWriter.inline_elements.indexOf(B.previousSibling.nodeName)>-1){D=''; +}else{this.addLine();C=C.replace(/^\s+/,'');}if(B.nextSibling&&B.nextSibling.nodeType==1&&Roo.htmleditor.TidyWriter.inline_elements.indexOf(B.nextSibling.nodeName)>-1){}else{C=C.replace(/\s+$/,'');}if(C.length<1){return;}if(!C.match(/\n/)){this.html.push(D+C); +return;}C=this.indentstr+C.replace(/(?![^\n]{1,64}$)([^\n]{1,64})\s/g,'$1\n'+this.indentstr);C=C.replace(/\s+$/,'');this.html.push(C);},cdata:function(A){this.html.push('');},comment:function(A){this.html.push('');},pi:function(A,B){B?this.html.push(''):this.html.push(''); this.indent!=''&&this.html.push('\n');},doctype:function(A){this.html.push('',this.indent!=''?'\n':'');},reset:function(){this.html.length=0;this.state=[];this.pushState({indentstr:'',in_pre:false,in_inline:false})},getContent:function(){return this.html.join('').replace(/\n$/,''); },pushState:function(A){this.state.push(A);Roo.apply(this,A);},popState:function(){if(this.state.length<1){return;}var A={in_pre:false,indentstr:''};this.state.pop();if(this.state.length>0){A=this.state[this.state.length-1];}Roo.apply(this,A);},addLine:function(){if(this.html.length<1){return; }var A=this.html[this.html.length-1];if(A.length>0&&'\n'!==A){this.html.push('\n');}}};Roo.htmleditor.TidyWriter.inline_elements=['SPAN','STRONG','B','EM','I','FONT','STRIKE','U','VAR','CITE','DFN','CODE','MARK','Q','SUP','SUB','SAMP','A'];Roo.htmleditor.TidyWriter.shortend_elements=['AREA','BASE','BASEFONT','BR','COL','FRAME','HR','IMG','INPUT','ISINDEX','LINK','','META','PARAM','EMBED','SOURCE','WBR','TRACK']; -- 2.39.2