From 13241dd38de916bc2d47b36f483a60dcde3452a3 Mon Sep 17 00:00:00 2001 From: Alan Date: Thu, 7 Jul 2022 10:32:35 +0800 Subject: [PATCH] Fix #7300 - namespace cleaning on word --- Roo/HtmlEditorCore.js | 12 ++++++- Roo/htmleditor/FilterKeepChildren.js | 22 ++++++++++--- docs/src/Roo_HtmlEditorCore.js.html | 12 ++++++- .../Roo_htmleditor_FilterKeepChildren.js.html | 22 ++++++++++--- examples/form/htmledit.html | 1 + roojs-all.js | 10 +++--- roojs-bootstrap-debug.js | 33 +++++++++++++++---- roojs-bootstrap.js | 10 +++--- roojs-debug.js | 33 +++++++++++++++---- roojs-ui-debug.js | 33 +++++++++++++++---- roojs-ui.js | 10 +++--- 11 files changed, 153 insertions(+), 45 deletions(-) diff --git a/Roo/HtmlEditorCore.js b/Roo/HtmlEditorCore.js index 1da95fe14b..c995778ce8 100644 --- a/Roo/HtmlEditorCore.js +++ b/Roo/HtmlEditorCore.js @@ -595,7 +595,7 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { .map(function(g) { return g.toDataURL(); }) .filter(function(g) { return g != 'about:blank'; }); - + //Roo.log(html); html = this.cleanWordChars(html); var d = (new DOMParser().parseFromString(html, 'text/html')).body; @@ -613,7 +613,17 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { return false; } + + if (images.length > 0) { + // replace all v:imagedata - with img. + var ar = Array.from(d.getElementsByTagName('v:imagedata')) + Roo.each(ar, function(node) { + node.parentNode.insertBefore(d.ownerDocument.createElement('img'), node ); + node.parentNode.removeChild(node); + }); + + Roo.each(d.getElementsByTagName('img'), function(img, i) { img.setAttribute('src', images[i]); }); diff --git a/Roo/htmleditor/FilterKeepChildren.js b/Roo/htmleditor/FilterKeepChildren.js index de742375e7..b504d0ebe9 100644 --- a/Roo/htmleditor/FilterKeepChildren.js +++ b/Roo/htmleditor/FilterKeepChildren.js @@ -12,25 +12,36 @@ Roo.htmleditor.FilterKeepChildren = function(cfg) if (this.tag === false) { return; // dont walk.. (you can use this to use this just to do a child removal on a single tag ) } + // hacky? + if ((typeof(this.tag) == 'object' && this.tag.indexOf(":") > -1)) { + this.cleanNamespace = true; + } + this.walk(cfg.node); } Roo.extend(Roo.htmleditor.FilterKeepChildren, Roo.htmleditor.FilterBlack, { - + cleanNamespace : false, // should really be an option, rather than using ':' inside of this tag. replaceTag : function(node) { // walk children... - //Roo.log(node); + //Roo.log(node.tagName); var ar = Array.from(node.childNodes); //remove first.. + for (var i = 0; i < ar.length; i++) { - if (ar[i].nodeType == 1) { + var e = ar[i]; + if (e.nodeType == 1) { if ( - (typeof(this.tag) == 'object' && this.tag.indexOf(ar[i].tagName) > -1) + (typeof(this.tag) == 'object' && this.tag.indexOf(e.tagName) > -1) || // array and it matches - (typeof(this.tag) == 'string' && this.tag == ar[i].tagName) + (typeof(this.tag) == 'string' && this.tag == e.tagName) + || + (e.tagName.indexOf(":") > -1 && typeof(this.tag) == 'object' && this.tag.indexOf(":") > -1) + || + (e.tagName.indexOf(":") > -1 && typeof(this.tag) == 'string' && this.tag == ":") ) { this.replaceTag(ar[i]); // child is blacklisted as well... continue; @@ -48,6 +59,7 @@ Roo.extend(Roo.htmleditor.FilterKeepChildren, Roo.htmleditor.FilterBlack, } } + //Roo.log("REMOVE:" + node.tagName); node.parentNode.removeChild(node); return false; // don't walk children diff --git a/docs/src/Roo_HtmlEditorCore.js.html b/docs/src/Roo_HtmlEditorCore.js.html index 8dc5d15fe3..f55106649b 100644 --- a/docs/src/Roo_HtmlEditorCore.js.html +++ b/docs/src/Roo_HtmlEditorCore.js.html @@ -595,7 +595,7 @@ .map(function(g) { return g.toDataURL(); }) .filter(function(g) { return g != 'about:blank'; }); - + //Roo.log(html); html = this.cleanWordChars(html); var d = (new DOMParser().parseFromString(html, 'text/html')).body; @@ -613,7 +613,17 @@ return false; } + + if (images.length > 0) { + // replace all v:imagedata - with img. + var ar = Array.from(d.getElementsByTagName('v:imagedata')) + Roo.each(ar, function(node) { + node.parentNode.insertBefore(d.ownerDocument.createElement('img'), node ); + node.parentNode.removeChild(node); + }); + + Roo.each(d.getElementsByTagName('img'), function(img, i) { img.setAttribute('src', images[i]); }); diff --git a/docs/src/Roo_htmleditor_FilterKeepChildren.js.html b/docs/src/Roo_htmleditor_FilterKeepChildren.js.html index 0a166a6c7c..feaae49481 100644 --- a/docs/src/Roo_htmleditor_FilterKeepChildren.js.html +++ b/docs/src/Roo_htmleditor_FilterKeepChildren.js.html @@ -12,25 +12,36 @@ if (this.tag === false) { return; // dont walk.. (you can use this to use this just to do a child removal on a single tag ) } + // hacky? + if ((typeof(this.tag) == 'object' && this.tag.indexOf(":") > -1)) { + this.cleanNamespace = true; + } + this.walk(cfg.node); } Roo.extend(Roo.htmleditor.FilterKeepChildren, Roo.htmleditor.FilterBlack, { - + cleanNamespace : false, // should really be an option, rather than using ':' inside of this tag. replaceTag : function(node) { // walk children... - //Roo.log(node); + //Roo.log(node.tagName); var ar = Array.from(node.childNodes); //remove first.. + for (var i = 0; i < ar.length; i++) { - if (ar[i].nodeType == 1) { + var e = ar[i]; + if (e.nodeType == 1) { if ( - (typeof(this.tag) == 'object' && this.tag.indexOf(ar[i].tagName) > -1) + (typeof(this.tag) == 'object' && this.tag.indexOf(e.tagName) > -1) || // array and it matches - (typeof(this.tag) == 'string' && this.tag == ar[i].tagName) + (typeof(this.tag) == 'string' && this.tag == e.tagName) + || + (e.tagName.indexOf(":") > -1 && typeof(this.tag) == 'object' && this.tag.indexOf(":") > -1) + || + (e.tagName.indexOf(":") > -1 && typeof(this.tag) == 'string' && this.tag == ":") ) { this.replaceTag(ar[i]); // child is blacklisted as well... continue; @@ -48,6 +59,7 @@ } } + //Roo.log("REMOVE:" + node.tagName); node.parentNode.removeChild(node); return false; // don't walk children diff --git a/examples/form/htmledit.html b/examples/form/htmledit.html index 6e7c3de242..d6ed481271 100644 --- a/examples/form/htmledit.html +++ b/examples/form/htmledit.html @@ -77,6 +77,7 @@ + diff --git a/roojs-all.js b/roojs-all.js index 4681811e9e..54064f1582 100644 --- a/roojs-all.js +++ b/roojs-all.js @@ -1910,9 +1910,9 @@ Roo.htmleditor.FilterBlack=function(A){Roo.apply(this,A);this.walk(A.node);};Roo // Roo/htmleditor/FilterComment.js Roo.htmleditor.FilterComment=function(A){this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterComment,Roo.htmleditor.Filter,{replaceComment:function(n){n.parentNode.removeChild(n);}}); // Roo/htmleditor/FilterKeepChildren.js -Roo.htmleditor.FilterKeepChildren=function(A){Roo.apply(this,A);if(this.tag===false){return;}this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterKeepChildren,Roo.htmleditor.FilterBlack,{replaceTag:function(A){var ar=Array.from(A.childNodes);for(var i=0;i-1)||(typeof(this.tag)=='string'&&this.tag==ar[i].tagName)){this.replaceTag(ar[i]);continue;}}}ar=Array.from(A.childNodes);for(var i=0;i-1)){this.cleanNamespace=true;}this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterKeepChildren,Roo.htmleditor.FilterBlack,{cleanNamespace:false,replaceTag:function(A){var ar=Array.from(A.childNodes); +for(var i=0;i-1)||(typeof(this.tag)=='string'&&this.tag==e.tagName)||(e.tagName.indexOf(":")>-1&&typeof(this.tag)=='object'&&this.tag.indexOf(":")>-1)||(e.tagName.indexOf(":")>-1&&typeof(this.tag)=='string'&&this.tag==":")){this.replaceTag(ar[i]); +continue;}}}ar=Array.from(A.childNodes);for(var i=0;i0){var A=(window.createObjectURL&&window)||(window.URL&&URL.revokeObjectURL&&URL)||(window.webkitURL&&webkitURL);var B=A.createObjectURL(cd.files[0]); this.insertAtCursor('');return false;}if(cd.types.indexOf('text/html')<0){return false;}var C=[];var D=cd.getData('text/html');if(cd.types.indexOf('text/rtf')>-1){var E=new Roo.rtf.Parser(cd.getData('text/rtf'));C=E.doc?E.doc.getElementsByType('pict'):[]; }C=C.filter(function(g){return !g.path.match(/^rtf\/(head|pgdsctbl|listtable|footerf)/);}).map(function(g){return g.toDataURL();}).filter(function(g){return g!='about:blank';});D=this.cleanWordChars(D);var d=(new DOMParser().parseFromString(D,'text/html')).body; -var sn=this.getParentElement();if(d.getElementsByTagName('table').length&&sn&&sn.closest('table')){e.preventDefault();this.insertAtCursor("You can not nest tables");return false;}if(C.length>0){Roo.each(d.getElementsByTagName('img'),function(F,i){F.setAttribute('src',C[i]); -});}if(this.autoClean){new Roo.htmleditor.FilterWord({node:d});new Roo.htmleditor.FilterStyleToTag({node:d});new Roo.htmleditor.FilterAttributes({node:d,attrib_white:['href','src','name','align','colspan','rowspan','data-display','data-width'],attrib_clean:['href','src']} +var sn=this.getParentElement();if(d.getElementsByTagName('table').length&&sn&&sn.closest('table')){e.preventDefault();this.insertAtCursor("You can not nest tables");return false;}if(C.length>0){Roo.each(d.getElementsByTagName('v:imagedata'),function(F){F.parentNode.insertBefore(F,document.createElement('img')); +F.parentNode.removeChild(F);});Roo.each(d.getElementsByTagName('img'),function(F,i){F.setAttribute('src',C[i]);});}if(this.autoClean){new Roo.htmleditor.FilterWord({node:d});new Roo.htmleditor.FilterStyleToTag({node:d});new Roo.htmleditor.FilterAttributes({node:d,attrib_white:['href','src','name','align','colspan','rowspan','data-display','data-width'],attrib_clean:['href','src']} );new Roo.htmleditor.FilterBlack({node:d,tag:this.black});new Roo.htmleditor.FilterKeepChildren({node:d,tag:['FONT',':']});new Roo.htmleditor.FilterParagraph({node:d});new Roo.htmleditor.FilterSpan({node:d});new Roo.htmleditor.FilterLongBr({node:d});new Roo.htmleditor.FilterComment({node:d} );}if(this.enableBlocks){Array.from(d.getElementsByTagName('img')).forEach(function(F){if(F.closest('figure')){return;}var G=new Roo.htmleditor.BlockFigure({image_src:F.src});G.updateElement(F);});}this.insertAtCursor(d.innerHTML.replace(/ /g,' '));if(this.enableBlocks){Roo.htmleditor.Block.initAll(this.doc.body); }e.preventDefault();return false;},onDestroy:function(){if(this.rendered){}},onFirstFocus:function(){this.assignDocWin();this.undoManager=new Roo.lib.UndoManager(100,(this.doc.body||this.doc.documentElement));this.activated=true;if(Roo.isGecko){this.win.focus(); diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index a5e171cc46..a554029283 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -26285,25 +26285,36 @@ Roo.htmleditor.FilterKeepChildren = function(cfg) if (this.tag === false) { return; // dont walk.. (you can use this to use this just to do a child removal on a single tag ) } + // hacky? + if ((typeof(this.tag) == 'object' && this.tag.indexOf(":") > -1)) { + this.cleanNamespace = true; + } + this.walk(cfg.node); } Roo.extend(Roo.htmleditor.FilterKeepChildren, Roo.htmleditor.FilterBlack, { - + cleanNamespace : false, // should really be an option, rather than using ':' inside of this tag. replaceTag : function(node) { // walk children... - //Roo.log(node); + //Roo.log(node.tagName); var ar = Array.from(node.childNodes); //remove first.. + for (var i = 0; i < ar.length; i++) { - if (ar[i].nodeType == 1) { + var e = ar[i]; + if (e.nodeType == 1) { if ( - (typeof(this.tag) == 'object' && this.tag.indexOf(ar[i].tagName) > -1) + (typeof(this.tag) == 'object' && this.tag.indexOf(e.tagName) > -1) || // array and it matches - (typeof(this.tag) == 'string' && this.tag == ar[i].tagName) + (typeof(this.tag) == 'string' && this.tag == e.tagName) + || + (e.tagName.indexOf(":") > -1 && typeof(this.tag) == 'object' && this.tag.indexOf(":") > -1) + || + (e.tagName.indexOf(":") > -1 && typeof(this.tag) == 'string' && this.tag == ":") ) { this.replaceTag(ar[i]); // child is blacklisted as well... continue; @@ -26321,6 +26332,7 @@ Roo.extend(Roo.htmleditor.FilterKeepChildren, Roo.htmleditor.FilterBlack, } } + //Roo.log("REMOVE:" + node.tagName); node.parentNode.removeChild(node); return false; // don't walk children @@ -29485,7 +29497,7 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { .map(function(g) { return g.toDataURL(); }) .filter(function(g) { return g != 'about:blank'; }); - + //Roo.log(html); html = this.cleanWordChars(html); var d = (new DOMParser().parseFromString(html, 'text/html')).body; @@ -29503,7 +29515,16 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { return false; } + + if (images.length > 0) { + // replace all v:imagedata - with img. + Roo.each(d.getElementsByTagName('v:imagedata'), function(node) { + node.parentNode.insertBefore(node, document.createElement('img')); + node.parentNode.removeChild(node); + }); + + Roo.each(d.getElementsByTagName('img'), function(img, i) { img.setAttribute('src', images[i]); }); diff --git a/roojs-bootstrap.js b/roojs-bootstrap.js index 4e42197289..14f03c737b 100644 --- a/roojs-bootstrap.js +++ b/roojs-bootstrap.js @@ -1129,9 +1129,9 @@ Roo.htmleditor.FilterBlack=function(A){Roo.apply(this,A);this.walk(A.node);};Roo // Roo/htmleditor/FilterComment.js Roo.htmleditor.FilterComment=function(A){this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterComment,Roo.htmleditor.Filter,{replaceComment:function(n){n.parentNode.removeChild(n);}}); // Roo/htmleditor/FilterKeepChildren.js -Roo.htmleditor.FilterKeepChildren=function(A){Roo.apply(this,A);if(this.tag===false){return;}this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterKeepChildren,Roo.htmleditor.FilterBlack,{replaceTag:function(A){var ar=Array.from(A.childNodes);for(var i=0;i-1)||(typeof(this.tag)=='string'&&this.tag==ar[i].tagName)){this.replaceTag(ar[i]);continue;}}}ar=Array.from(A.childNodes);for(var i=0;i-1)){this.cleanNamespace=true;}this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterKeepChildren,Roo.htmleditor.FilterBlack,{cleanNamespace:false,replaceTag:function(A){var ar=Array.from(A.childNodes); +for(var i=0;i-1)||(typeof(this.tag)=='string'&&this.tag==e.tagName)||(e.tagName.indexOf(":")>-1&&typeof(this.tag)=='object'&&this.tag.indexOf(":")>-1)||(e.tagName.indexOf(":")>-1&&typeof(this.tag)=='string'&&this.tag==":")){this.replaceTag(ar[i]); +continue;}}}ar=Array.from(A.childNodes);for(var i=0;i0){var A=(window.createObjectURL&&window)||(window.URL&&URL.revokeObjectURL&&URL)||(window.webkitURL&&webkitURL);var B=A.createObjectURL(cd.files[0]); this.insertAtCursor('');return false;}if(cd.types.indexOf('text/html')<0){return false;}var C=[];var D=cd.getData('text/html');if(cd.types.indexOf('text/rtf')>-1){var E=new Roo.rtf.Parser(cd.getData('text/rtf'));C=E.doc?E.doc.getElementsByType('pict'):[]; }C=C.filter(function(g){return !g.path.match(/^rtf\/(head|pgdsctbl|listtable|footerf)/);}).map(function(g){return g.toDataURL();}).filter(function(g){return g!='about:blank';});D=this.cleanWordChars(D);var d=(new DOMParser().parseFromString(D,'text/html')).body; -var sn=this.getParentElement();if(d.getElementsByTagName('table').length&&sn&&sn.closest('table')){e.preventDefault();this.insertAtCursor("You can not nest tables");return false;}if(C.length>0){Roo.each(d.getElementsByTagName('img'),function(F,i){F.setAttribute('src',C[i]); -});}if(this.autoClean){new Roo.htmleditor.FilterWord({node:d});new Roo.htmleditor.FilterStyleToTag({node:d});new Roo.htmleditor.FilterAttributes({node:d,attrib_white:['href','src','name','align','colspan','rowspan','data-display','data-width'],attrib_clean:['href','src']} +var sn=this.getParentElement();if(d.getElementsByTagName('table').length&&sn&&sn.closest('table')){e.preventDefault();this.insertAtCursor("You can not nest tables");return false;}if(C.length>0){Roo.each(d.getElementsByTagName('v:imagedata'),function(F){F.parentNode.insertBefore(F,document.createElement('img')); +F.parentNode.removeChild(F);});Roo.each(d.getElementsByTagName('img'),function(F,i){F.setAttribute('src',C[i]);});}if(this.autoClean){new Roo.htmleditor.FilterWord({node:d});new Roo.htmleditor.FilterStyleToTag({node:d});new Roo.htmleditor.FilterAttributes({node:d,attrib_white:['href','src','name','align','colspan','rowspan','data-display','data-width'],attrib_clean:['href','src']} );new Roo.htmleditor.FilterBlack({node:d,tag:this.black});new Roo.htmleditor.FilterKeepChildren({node:d,tag:['FONT',':']});new Roo.htmleditor.FilterParagraph({node:d});new Roo.htmleditor.FilterSpan({node:d});new Roo.htmleditor.FilterLongBr({node:d});new Roo.htmleditor.FilterComment({node:d} );}if(this.enableBlocks){Array.from(d.getElementsByTagName('img')).forEach(function(F){if(F.closest('figure')){return;}var G=new Roo.htmleditor.BlockFigure({image_src:F.src});G.updateElement(F);});}this.insertAtCursor(d.innerHTML.replace(/ /g,' '));if(this.enableBlocks){Roo.htmleditor.Block.initAll(this.doc.body); }e.preventDefault();return false;},onDestroy:function(){if(this.rendered){}},onFirstFocus:function(){this.assignDocWin();this.undoManager=new Roo.lib.UndoManager(100,(this.doc.body||this.doc.documentElement));this.activated=true;if(Roo.isGecko){this.win.focus(); diff --git a/roojs-debug.js b/roojs-debug.js index 85f8dfca24..03ae7ba25b 100644 --- a/roojs-debug.js +++ b/roojs-debug.js @@ -45899,25 +45899,36 @@ Roo.htmleditor.FilterKeepChildren = function(cfg) if (this.tag === false) { return; // dont walk.. (you can use this to use this just to do a child removal on a single tag ) } + // hacky? + if ((typeof(this.tag) == 'object' && this.tag.indexOf(":") > -1)) { + this.cleanNamespace = true; + } + this.walk(cfg.node); } Roo.extend(Roo.htmleditor.FilterKeepChildren, Roo.htmleditor.FilterBlack, { - + cleanNamespace : false, // should really be an option, rather than using ':' inside of this tag. replaceTag : function(node) { // walk children... - //Roo.log(node); + //Roo.log(node.tagName); var ar = Array.from(node.childNodes); //remove first.. + for (var i = 0; i < ar.length; i++) { - if (ar[i].nodeType == 1) { + var e = ar[i]; + if (e.nodeType == 1) { if ( - (typeof(this.tag) == 'object' && this.tag.indexOf(ar[i].tagName) > -1) + (typeof(this.tag) == 'object' && this.tag.indexOf(e.tagName) > -1) || // array and it matches - (typeof(this.tag) == 'string' && this.tag == ar[i].tagName) + (typeof(this.tag) == 'string' && this.tag == e.tagName) + || + (e.tagName.indexOf(":") > -1 && typeof(this.tag) == 'object' && this.tag.indexOf(":") > -1) + || + (e.tagName.indexOf(":") > -1 && typeof(this.tag) == 'string' && this.tag == ":") ) { this.replaceTag(ar[i]); // child is blacklisted as well... continue; @@ -45935,6 +45946,7 @@ Roo.extend(Roo.htmleditor.FilterKeepChildren, Roo.htmleditor.FilterBlack, } } + //Roo.log("REMOVE:" + node.tagName); node.parentNode.removeChild(node); return false; // don't walk children @@ -50366,7 +50378,7 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { .map(function(g) { return g.toDataURL(); }) .filter(function(g) { return g != 'about:blank'; }); - + //Roo.log(html); html = this.cleanWordChars(html); var d = (new DOMParser().parseFromString(html, 'text/html')).body; @@ -50384,7 +50396,16 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { return false; } + + if (images.length > 0) { + // replace all v:imagedata - with img. + Roo.each(d.getElementsByTagName('v:imagedata'), function(node) { + node.parentNode.insertBefore(node, document.createElement('img')); + node.parentNode.removeChild(node); + }); + + Roo.each(d.getElementsByTagName('img'), function(img, i) { img.setAttribute('src', images[i]); }); diff --git a/roojs-ui-debug.js b/roojs-ui-debug.js index 22d5aeb0d4..321112a93e 100644 --- a/roojs-ui-debug.js +++ b/roojs-ui-debug.js @@ -21407,25 +21407,36 @@ Roo.htmleditor.FilterKeepChildren = function(cfg) if (this.tag === false) { return; // dont walk.. (you can use this to use this just to do a child removal on a single tag ) } + // hacky? + if ((typeof(this.tag) == 'object' && this.tag.indexOf(":") > -1)) { + this.cleanNamespace = true; + } + this.walk(cfg.node); } Roo.extend(Roo.htmleditor.FilterKeepChildren, Roo.htmleditor.FilterBlack, { - + cleanNamespace : false, // should really be an option, rather than using ':' inside of this tag. replaceTag : function(node) { // walk children... - //Roo.log(node); + //Roo.log(node.tagName); var ar = Array.from(node.childNodes); //remove first.. + for (var i = 0; i < ar.length; i++) { - if (ar[i].nodeType == 1) { + var e = ar[i]; + if (e.nodeType == 1) { if ( - (typeof(this.tag) == 'object' && this.tag.indexOf(ar[i].tagName) > -1) + (typeof(this.tag) == 'object' && this.tag.indexOf(e.tagName) > -1) || // array and it matches - (typeof(this.tag) == 'string' && this.tag == ar[i].tagName) + (typeof(this.tag) == 'string' && this.tag == e.tagName) + || + (e.tagName.indexOf(":") > -1 && typeof(this.tag) == 'object' && this.tag.indexOf(":") > -1) + || + (e.tagName.indexOf(":") > -1 && typeof(this.tag) == 'string' && this.tag == ":") ) { this.replaceTag(ar[i]); // child is blacklisted as well... continue; @@ -21443,6 +21454,7 @@ Roo.extend(Roo.htmleditor.FilterKeepChildren, Roo.htmleditor.FilterBlack, } } + //Roo.log("REMOVE:" + node.tagName); node.parentNode.removeChild(node); return false; // don't walk children @@ -25874,7 +25886,7 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { .map(function(g) { return g.toDataURL(); }) .filter(function(g) { return g != 'about:blank'; }); - + //Roo.log(html); html = this.cleanWordChars(html); var d = (new DOMParser().parseFromString(html, 'text/html')).body; @@ -25892,7 +25904,16 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { return false; } + + if (images.length > 0) { + // replace all v:imagedata - with img. + Roo.each(d.getElementsByTagName('v:imagedata'), function(node) { + node.parentNode.insertBefore(node, document.createElement('img')); + node.parentNode.removeChild(node); + }); + + Roo.each(d.getElementsByTagName('img'), function(img, i) { img.setAttribute('src', images[i]); }); diff --git a/roojs-ui.js b/roojs-ui.js index fd99407aa6..4179c869cd 100644 --- a/roojs-ui.js +++ b/roojs-ui.js @@ -964,9 +964,9 @@ Roo.htmleditor.FilterBlack=function(A){Roo.apply(this,A);this.walk(A.node);};Roo // Roo/htmleditor/FilterComment.js Roo.htmleditor.FilterComment=function(A){this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterComment,Roo.htmleditor.Filter,{replaceComment:function(n){n.parentNode.removeChild(n);}}); // Roo/htmleditor/FilterKeepChildren.js -Roo.htmleditor.FilterKeepChildren=function(A){Roo.apply(this,A);if(this.tag===false){return;}this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterKeepChildren,Roo.htmleditor.FilterBlack,{replaceTag:function(A){var ar=Array.from(A.childNodes);for(var i=0;i-1)||(typeof(this.tag)=='string'&&this.tag==ar[i].tagName)){this.replaceTag(ar[i]);continue;}}}ar=Array.from(A.childNodes);for(var i=0;i-1)){this.cleanNamespace=true;}this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterKeepChildren,Roo.htmleditor.FilterBlack,{cleanNamespace:false,replaceTag:function(A){var ar=Array.from(A.childNodes); +for(var i=0;i-1)||(typeof(this.tag)=='string'&&this.tag==e.tagName)||(e.tagName.indexOf(":")>-1&&typeof(this.tag)=='object'&&this.tag.indexOf(":")>-1)||(e.tagName.indexOf(":")>-1&&typeof(this.tag)=='string'&&this.tag==":")){this.replaceTag(ar[i]); +continue;}}}ar=Array.from(A.childNodes);for(var i=0;i0){var A=(window.createObjectURL&&window)||(window.URL&&URL.revokeObjectURL&&URL)||(window.webkitURL&&webkitURL);var B=A.createObjectURL(cd.files[0]); this.insertAtCursor('');return false;}if(cd.types.indexOf('text/html')<0){return false;}var C=[];var D=cd.getData('text/html');if(cd.types.indexOf('text/rtf')>-1){var E=new Roo.rtf.Parser(cd.getData('text/rtf'));C=E.doc?E.doc.getElementsByType('pict'):[]; }C=C.filter(function(g){return !g.path.match(/^rtf\/(head|pgdsctbl|listtable|footerf)/);}).map(function(g){return g.toDataURL();}).filter(function(g){return g!='about:blank';});D=this.cleanWordChars(D);var d=(new DOMParser().parseFromString(D,'text/html')).body; -var sn=this.getParentElement();if(d.getElementsByTagName('table').length&&sn&&sn.closest('table')){e.preventDefault();this.insertAtCursor("You can not nest tables");return false;}if(C.length>0){Roo.each(d.getElementsByTagName('img'),function(F,i){F.setAttribute('src',C[i]); -});}if(this.autoClean){new Roo.htmleditor.FilterWord({node:d});new Roo.htmleditor.FilterStyleToTag({node:d});new Roo.htmleditor.FilterAttributes({node:d,attrib_white:['href','src','name','align','colspan','rowspan','data-display','data-width'],attrib_clean:['href','src']} +var sn=this.getParentElement();if(d.getElementsByTagName('table').length&&sn&&sn.closest('table')){e.preventDefault();this.insertAtCursor("You can not nest tables");return false;}if(C.length>0){Roo.each(d.getElementsByTagName('v:imagedata'),function(F){F.parentNode.insertBefore(F,document.createElement('img')); +F.parentNode.removeChild(F);});Roo.each(d.getElementsByTagName('img'),function(F,i){F.setAttribute('src',C[i]);});}if(this.autoClean){new Roo.htmleditor.FilterWord({node:d});new Roo.htmleditor.FilterStyleToTag({node:d});new Roo.htmleditor.FilterAttributes({node:d,attrib_white:['href','src','name','align','colspan','rowspan','data-display','data-width'],attrib_clean:['href','src']} );new Roo.htmleditor.FilterBlack({node:d,tag:this.black});new Roo.htmleditor.FilterKeepChildren({node:d,tag:['FONT',':']});new Roo.htmleditor.FilterParagraph({node:d});new Roo.htmleditor.FilterSpan({node:d});new Roo.htmleditor.FilterLongBr({node:d});new Roo.htmleditor.FilterComment({node:d} );}if(this.enableBlocks){Array.from(d.getElementsByTagName('img')).forEach(function(F){if(F.closest('figure')){return;}var G=new Roo.htmleditor.BlockFigure({image_src:F.src});G.updateElement(F);});}this.insertAtCursor(d.innerHTML.replace(/ /g,' '));if(this.enableBlocks){Roo.htmleditor.Block.initAll(this.doc.body); }e.preventDefault();return false;},onDestroy:function(){if(this.rendered){}},onFirstFocus:function(){this.assignDocWin();this.undoManager=new Roo.lib.UndoManager(100,(this.doc.body||this.doc.documentElement));this.activated=true;if(Roo.isGecko){this.win.focus(); -- 2.39.2