From 71b5ca0374b16351f1f3b64dc222d3d5925622b5 Mon Sep 17 00:00:00 2001 From: Alan Date: Thu, 17 Mar 2022 16:54:13 +0800 Subject: [PATCH] roojs-ui.js roojs-ui-debug.js roojs-bootstrap.js roojs-bootstrap-debug.js roojs-all.js roojs-debug.js --- roojs-all.js | 6 ++-- roojs-bootstrap-debug.js | 61 ++++++++++++++++++++++++++++++++++++++++ roojs-bootstrap.js | 6 ++-- roojs-debug.js | 61 ++++++++++++++++++++++++++++++++++++++++ roojs-ui-debug.js | 61 ++++++++++++++++++++++++++++++++++++++++ roojs-ui.js | 6 ++-- 6 files changed, 195 insertions(+), 6 deletions(-) diff --git a/roojs-all.js b/roojs-all.js index abbc46f69c..8eca39c400 100644 --- a/roojs-all.js +++ b/roojs-all.js @@ -1924,12 +1924,14 @@ 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.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);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; 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);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;}}); +}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(doc){var listpara=doc.getElementsByClassName('MsoListParagraph');while(listpara.length){this.replaceDocBullet(listpara.item(0));}},replaceDocBullet:function(p){var ns=p,A=p.parentNode,B=[];while(ns){if(!ns.className.match(/MsoListParagraph/)){break; +}B.push(ns);ns=ns.nextSibling;}var ul=A.ownerDocument.createElement('ul');B.forEach(function(n){A.removeChild(n);var C=n.getElementsByTagName('span');n.removeChild(C.item(0));});}}); // 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-bootstrap-debug.js b/roojs-bootstrap-debug.js index 98ab829720..9eb90a14b5 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -26458,7 +26458,11 @@ Roo.extend(Roo.htmleditor.FilterTableWidth, Roo.htmleditor.Filter, Roo.htmleditor.FilterWord = function(cfg) { // no need to apply config. + this.replaceDocBullets(cfg.node); + this.walk(cfg.node); + + } Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, @@ -26560,7 +26564,64 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, + }, + + styleToObject: function(node) + { + var styles = node.getAttribute("style").split(";"); + var ret = {}; + Roo.each(styles, function(s) { + if (!s.match(/:/)) { + return; + } + var kv = s.split(":"); + + // what ever is left... we allow. + ret[kv[0]] = kv[1]; + }); + return ret; } + + + replaceDocBullets : function(doc) + { + var listpara = doc.getElementsByClassName('MsoListParagraph'); + while(listpara.length) { + this.replaceDocBullet(listpara.item(0)); + //code + } + }, + + replaceDocBullet : function(p) + { + // gather all the siblings. + var ns = p, + parent = p.parentNode, + items = []; + while (ns) { + if (!ns.className.match(/MsoListParagraph/)) { + break; + } + items.push(ns); + ns = ns.nextSibling; + + } + var ul = parent.ownerDocument.createElement('ul'); // what about number lists... + + items.forEach(function(n) { + parent.removeChild(n); + var spans = n.getElementsByTagName('span'); + n.removeChild(spans.item(0)); // remove the fake bullet. + + }); + + + + + } + + + }); /** * @class Roo.htmleditor.FilterStyleToTag diff --git a/roojs-bootstrap.js b/roojs-bootstrap.js index 23065040d1..03397f15a5 100644 --- a/roojs-bootstrap.js +++ b/roojs-bootstrap.js @@ -1143,12 +1143,14 @@ 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.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);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; 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);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;}}); +}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(doc){var listpara=doc.getElementsByClassName('MsoListParagraph');while(listpara.length){this.replaceDocBullet(listpara.item(0));}},replaceDocBullet:function(p){var ns=p,A=p.parentNode,B=[];while(ns){if(!ns.className.match(/MsoListParagraph/)){break; +}B.push(ns);ns=ns.nextSibling;}var ul=A.ownerDocument.createElement('ul');B.forEach(function(n){A.removeChild(n);var C=n.getElementsByTagName('span');n.removeChild(C.item(0));});}}); // 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 1c84d11894..5154c8b7fc 100644 --- a/roojs-debug.js +++ b/roojs-debug.js @@ -46071,7 +46071,11 @@ Roo.extend(Roo.htmleditor.FilterTableWidth, Roo.htmleditor.Filter, Roo.htmleditor.FilterWord = function(cfg) { // no need to apply config. + this.replaceDocBullets(cfg.node); + this.walk(cfg.node); + + } Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, @@ -46173,7 +46177,64 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, + }, + + styleToObject: function(node) + { + var styles = node.getAttribute("style").split(";"); + var ret = {}; + Roo.each(styles, function(s) { + if (!s.match(/:/)) { + return; + } + var kv = s.split(":"); + + // what ever is left... we allow. + ret[kv[0]] = kv[1]; + }); + return ret; } + + + replaceDocBullets : function(doc) + { + var listpara = doc.getElementsByClassName('MsoListParagraph'); + while(listpara.length) { + this.replaceDocBullet(listpara.item(0)); + //code + } + }, + + replaceDocBullet : function(p) + { + // gather all the siblings. + var ns = p, + parent = p.parentNode, + items = []; + while (ns) { + if (!ns.className.match(/MsoListParagraph/)) { + break; + } + items.push(ns); + ns = ns.nextSibling; + + } + var ul = parent.ownerDocument.createElement('ul'); // what about number lists... + + items.forEach(function(n) { + parent.removeChild(n); + var spans = n.getElementsByTagName('span'); + n.removeChild(spans.item(0)); // remove the fake bullet. + + }); + + + + + } + + + }); /** * @class Roo.htmleditor.FilterStyleToTag diff --git a/roojs-ui-debug.js b/roojs-ui-debug.js index fdf8b123c0..5e6ab22dd2 100644 --- a/roojs-ui-debug.js +++ b/roojs-ui-debug.js @@ -21579,7 +21579,11 @@ Roo.extend(Roo.htmleditor.FilterTableWidth, Roo.htmleditor.Filter, Roo.htmleditor.FilterWord = function(cfg) { // no need to apply config. + this.replaceDocBullets(cfg.node); + this.walk(cfg.node); + + } Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, @@ -21681,7 +21685,64 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, + }, + + styleToObject: function(node) + { + var styles = node.getAttribute("style").split(";"); + var ret = {}; + Roo.each(styles, function(s) { + if (!s.match(/:/)) { + return; + } + var kv = s.split(":"); + + // what ever is left... we allow. + ret[kv[0]] = kv[1]; + }); + return ret; } + + + replaceDocBullets : function(doc) + { + var listpara = doc.getElementsByClassName('MsoListParagraph'); + while(listpara.length) { + this.replaceDocBullet(listpara.item(0)); + //code + } + }, + + replaceDocBullet : function(p) + { + // gather all the siblings. + var ns = p, + parent = p.parentNode, + items = []; + while (ns) { + if (!ns.className.match(/MsoListParagraph/)) { + break; + } + items.push(ns); + ns = ns.nextSibling; + + } + var ul = parent.ownerDocument.createElement('ul'); // what about number lists... + + items.forEach(function(n) { + parent.removeChild(n); + var spans = n.getElementsByTagName('span'); + n.removeChild(spans.item(0)); // remove the fake bullet. + + }); + + + + + } + + + }); /** * @class Roo.htmleditor.FilterStyleToTag diff --git a/roojs-ui.js b/roojs-ui.js index 65113862da..4466af69b6 100644 --- a/roojs-ui.js +++ b/roojs-ui.js @@ -978,12 +978,14 @@ 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.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);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; 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);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;}}); +}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(doc){var listpara=doc.getElementsByClassName('MsoListParagraph');while(listpara.length){this.replaceDocBullet(listpara.item(0));}},replaceDocBullet:function(p){var ns=p,A=p.parentNode,B=[];while(ns){if(!ns.className.match(/MsoListParagraph/)){break; +}B.push(ns);ns=ns.nextSibling;}var ul=A.ownerDocument.createElement('ul');B.forEach(function(n){A.removeChild(n);var C=n.getElementsByTagName('span');n.removeChild(C.item(0));});}}); // 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