From: Alan Knowles Date: Thu, 26 Sep 2019 02:12:53 +0000 (+0800) Subject: Roo/HtmlEditorCore.js X-Git-Url: http://git.roojs.org/?p=roojs1;a=commitdiff_plain;h=6bd78f040092e70ac77ca9ee7c3e01fa5ef5c5df Roo/HtmlEditorCore.js roojs-ui.js roojs-ui-debug.js roojs-all.js roojs-debug.js --- diff --git a/Roo/HtmlEditorCore.js b/Roo/HtmlEditorCore.js index 16aef64d3f..a55695281e 100644 --- a/Roo/HtmlEditorCore.js +++ b/Roo/HtmlEditorCore.js @@ -1043,9 +1043,9 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { if (!node.attributes || !node.attributes.length) { - if (lcname == 'span' && - node.childNodes.length == 1 && - node.childNodes[0].nodeName.toLowerCase() == 'span' + if (lcname == 'span' //&& + //node.childNodes.length == 1 && + //node.childNodes[0].nodeName.toLowerCase() == 'span' ) { remove_keep_children = true; } diff --git a/roojs-all.js b/roojs-all.js index 662dc5f851..5ac377bf0b 100644 --- a/roojs-all.js +++ b/roojs-all.js @@ -1808,8 +1808,8 @@ var B=this.createRange(A);try{var p=B.commonAncestorContainer;while(p.nodeType== var D=ss==1;var E=ee==-1;if(D&&E){return 0;}if(!D&&E){return 1;}if(D&&!E){return 2;}return 3;},cleanUpPaste:function(){Roo.log('cleanuppaste');this.cleanUpChildren(this.doc.body);var A=this.cleanWordChars(this.doc.body.innerHTML);if(A!=this.doc.body.innerHTML){this.doc.body.innerHTML=A; }},cleanWordChars:function(A){var he=Roo.HtmlEditorCore;var B=A;Roo.each(he.swapCodes,function(sw){var C=new RegExp("\\u"+sw[0].toString(16),"g");B=B.replace(C,sw[1]);});return B;},cleanUpChildren:function(n){if(!n.childNodes.length){return;}for(var i=n.childNodes.length-1; i>-1;i--){this.cleanUpChild(n.childNodes[i]);}},cleanUpChild:function(A){var ed=this;if(A.nodeName=="#text"){return;}if(A.nodeName=="#comment"){A.parentNode.removeChild(A);return;}var B=A.tagName.toLowerCase();if(this.black.indexOf(B)>-1&&this.clearUp){A.parentNode.removeChild(A); -return;}var C=Roo.HtmlEditorCore.remove.indexOf(A.tagName.toLowerCase())>-1;if(!A.attributes||!A.attributes.length){if(B=='span'&&A.childNodes.length==1&&A.childNodes[0].nodeName.toLowerCase()=='span'){C=true;}}if(C){this.cleanUpChildren(A);while(A.childNodes.length){var cn=A.childNodes[0]; -A.removeChild(cn);A.parentNode.insertBefore(cn,A);}A.parentNode.removeChild(A);return;}if(!A.attributes||!A.attributes.length){this.cleanUpChildren(A);return;}function cleanAttr(n,v){if(v.match(/^\./)||v.match(/^\//)){return;}if(v.match(/^(http|https):\/\//)||v.match(/^mailto:/)||v.match(/^ftp:/)){return; +return;}var C=Roo.HtmlEditorCore.remove.indexOf(A.tagName.toLowerCase())>-1;if(!A.attributes||!A.attributes.length){if(B=='span'){C=true;}}if(C){this.cleanUpChildren(A);while(A.childNodes.length){var cn=A.childNodes[0];A.removeChild(cn);A.parentNode.insertBefore(cn,A); +}A.parentNode.removeChild(A);return;}if(!A.attributes||!A.attributes.length){this.cleanUpChildren(A);return;}function cleanAttr(n,v){if(v.match(/^\./)||v.match(/^\//)){return;}if(v.match(/^(http|https):\/\//)||v.match(/^mailto:/)||v.match(/^ftp:/)){return; }if(v.match(/^#/)){return;}A.removeAttribute(n);}var D=this.cwhite;var E=this.cblack;function cleanStyle(n,v){if(v.match(/expression/)){A.removeAttribute(n);return;}var F=v.split(/;/);var G=[];Roo.each(F,function(p){p=p.replace(/^\s+/g,'').replace(/\s+$/g,''); if(!p.length){return true;}var l=p.split(':').shift().replace(/\s+/g,'');l=l.replace(/^\s+/g,'').replace(/\s+$/g,'');if(D.length&&E.indexOf(l)>-1){return true;}if(D.length&&D.indexOf(l)<0){return true;}G.push(p);return true;});if(G.length){A.setAttribute(n,G.join(';')); }else{A.removeAttribute(n);}}for(var i=A.attributes.length-1;i>-1;i--){var a=A.attributes[i];if(a.name.toLowerCase().substr(0,2)=='on'){A.removeAttribute(a.name);continue;}if(Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase())>-1){A.removeAttribute(a.name); diff --git a/roojs-debug.js b/roojs-debug.js index beb4a3559f..7d4d119562 100644 --- a/roojs-debug.js +++ b/roojs-debug.js @@ -43956,9 +43956,9 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { if (!node.attributes || !node.attributes.length) { - if (lcname == 'span' && - node.childNodes.length == 1 && - node.childNodes[0].nodeName.toLowerCase() == 'span' + if (lcname == 'span' //&& + //node.childNodes.length == 1 && + //node.childNodes[0].nodeName.toLowerCase() == 'span' ) { remove_keep_children = true; } diff --git a/roojs-ui-debug.js b/roojs-ui-debug.js index 9880095617..9a7b8b6f68 100644 --- a/roojs-ui-debug.js +++ b/roojs-ui-debug.js @@ -21505,9 +21505,9 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { if (!node.attributes || !node.attributes.length) { - if (lcname == 'span' && - node.childNodes.length == 1 && - node.childNodes[0].nodeName.toLowerCase() == 'span' + if (lcname == 'span' //&& + //node.childNodes.length == 1 && + //node.childNodes[0].nodeName.toLowerCase() == 'span' ) { remove_keep_children = true; } diff --git a/roojs-ui.js b/roojs-ui.js index c985226826..3712cbc65d 100644 --- a/roojs-ui.js +++ b/roojs-ui.js @@ -939,8 +939,8 @@ var B=this.createRange(A);try{var p=B.commonAncestorContainer;while(p.nodeType== var D=ss==1;var E=ee==-1;if(D&&E){return 0;}if(!D&&E){return 1;}if(D&&!E){return 2;}return 3;},cleanUpPaste:function(){Roo.log('cleanuppaste');this.cleanUpChildren(this.doc.body);var A=this.cleanWordChars(this.doc.body.innerHTML);if(A!=this.doc.body.innerHTML){this.doc.body.innerHTML=A; }},cleanWordChars:function(A){var he=Roo.HtmlEditorCore;var B=A;Roo.each(he.swapCodes,function(sw){var C=new RegExp("\\u"+sw[0].toString(16),"g");B=B.replace(C,sw[1]);});return B;},cleanUpChildren:function(n){if(!n.childNodes.length){return;}for(var i=n.childNodes.length-1; i>-1;i--){this.cleanUpChild(n.childNodes[i]);}},cleanUpChild:function(A){var ed=this;if(A.nodeName=="#text"){return;}if(A.nodeName=="#comment"){A.parentNode.removeChild(A);return;}var B=A.tagName.toLowerCase();if(this.black.indexOf(B)>-1&&this.clearUp){A.parentNode.removeChild(A); -return;}var C=Roo.HtmlEditorCore.remove.indexOf(A.tagName.toLowerCase())>-1;if(!A.attributes||!A.attributes.length){if(B=='span'&&A.childNodes.length==1&&A.childNodes[0].nodeName.toLowerCase()=='span'){C=true;}}if(C){this.cleanUpChildren(A);while(A.childNodes.length){var cn=A.childNodes[0]; -A.removeChild(cn);A.parentNode.insertBefore(cn,A);}A.parentNode.removeChild(A);return;}if(!A.attributes||!A.attributes.length){this.cleanUpChildren(A);return;}function cleanAttr(n,v){if(v.match(/^\./)||v.match(/^\//)){return;}if(v.match(/^(http|https):\/\//)||v.match(/^mailto:/)||v.match(/^ftp:/)){return; +return;}var C=Roo.HtmlEditorCore.remove.indexOf(A.tagName.toLowerCase())>-1;if(!A.attributes||!A.attributes.length){if(B=='span'){C=true;}}if(C){this.cleanUpChildren(A);while(A.childNodes.length){var cn=A.childNodes[0];A.removeChild(cn);A.parentNode.insertBefore(cn,A); +}A.parentNode.removeChild(A);return;}if(!A.attributes||!A.attributes.length){this.cleanUpChildren(A);return;}function cleanAttr(n,v){if(v.match(/^\./)||v.match(/^\//)){return;}if(v.match(/^(http|https):\/\//)||v.match(/^mailto:/)||v.match(/^ftp:/)){return; }if(v.match(/^#/)){return;}A.removeAttribute(n);}var D=this.cwhite;var E=this.cblack;function cleanStyle(n,v){if(v.match(/expression/)){A.removeAttribute(n);return;}var F=v.split(/;/);var G=[];Roo.each(F,function(p){p=p.replace(/^\s+/g,'').replace(/\s+$/g,''); if(!p.length){return true;}var l=p.split(':').shift().replace(/\s+/g,'');l=l.replace(/^\s+/g,'').replace(/\s+$/g,'');if(D.length&&E.indexOf(l)>-1){return true;}if(D.length&&D.indexOf(l)<0){return true;}G.push(p);return true;});if(G.length){A.setAttribute(n,G.join(';')); }else{A.removeAttribute(n);}}for(var i=A.attributes.length-1;i>-1;i--){var a=A.attributes[i];if(a.name.toLowerCase().substr(0,2)=='on'){A.removeAttribute(a.name);continue;}if(Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase())>-1){A.removeAttribute(a.name);