X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=plugins%2Fpastefromword%2Ffilter%2Fdefault.js;h=b699ccb830182f4e8c4e5ef67fbd31d80086869f;hp=07df5c464c9db580463fa85be9e7ac481dfd583d;hb=039a051ccf3901311661022a30afd60fc38130c9;hpb=c9fdde67e6384bd5a66adc2b3bba5c4ce9db56c7 diff --git a/plugins/pastefromword/filter/default.js b/plugins/pastefromword/filter/default.js index 07df5c4..b699ccb 100644 --- a/plugins/pastefromword/filter/default.js +++ b/plugins/pastefromword/filter/default.js @@ -3,8 +3,8 @@ Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ -(function(){var a=CKEDITOR.htmlParser.fragment.prototype,b=CKEDITOR.htmlParser.element.prototype;a.onlyChild=b.onlyChild=function(){var h=this.children,i=h.length,j=i==1&&h[0];return j||null;};b.removeAnyChildWithName=function(h){var i=this.children,j=[],k;for(var l=0;lf)e=m-f;i['cke:margin']=f=m;}]])(i.style,h)||'';var k=j.attributes,l=k.style;h.addStyle(l); -CKEDITOR.tools.extend(i,k);return true;}return false;},convertToPx:(function(){var h=CKEDITOR.dom.element.createFromHtml('
',CKEDITOR.document);CKEDITOR.document.getBody().append(h);return function(i){if(c.test(i)){h.setStyle('width',i);return h.$.clientWidth+'px';}return i;};})(),getStyleComponents:(function(){var h=CKEDITOR.dom.element.createFromHtml('
',CKEDITOR.document);CKEDITOR.document.getBody().append(h);return function(i,j,k){h.setStyle(i,j);var l={},m=k.length;for(var n=0;nr){p=new CKEDITOR.htmlParser.element(m);p.add(k);o.add(p);}else if(n3?'large':C.size<3?'small':'medium')+';';delete C.size;}B.name='span';B.addStyle(D);}},span:function(B){if(!CKEDITOR.env.gecko&&t(B.parent))return false;B.filterChildren();if(u(B)){delete B.name;return null;}if(!CKEDITOR.env.gecko&&t(B)){var C=B.firstChild(function(J){return J.value||J.name=='img';}),D=C&&(C.value||'l.'),E=D.match(/^([^\s]+?)([.)]?)$/);return q(E,D);}var F=B.children,G=B.attributes,H=G&&G.style,I=F&&F[0];if(H)G.style=n([['line-height'],[/^font-family$/,null,!z?p(k.font_style,'family'):null],[/^font-size$/,null,!z?p(k.fontSize_style,'size'):null],[/^color$/,null,!z?p(k.colorButton_foreStyle,'color'):null],[/^background-color$/,null,!z?p(k.colorButton_backStyle,'color'):null]])(H,B)||'';return null;},b:o(k.coreStyles_bold),i:o(k.coreStyles_italic),u:o(k.coreStyles_underline),s:o(k.coreStyles_strike),sup:o(k.coreStyles_superscript),sub:o(k.coreStyles_subscript),a:function(B){var C=B.attributes;if(C&&!C.href&&C.name)delete B.name;},'cke:listbullet':function(B){if(B.getAncestor(/h\d/)&&!k.pasteFromWordNumberedHeadingToList)delete B.name;}},attributeNames:[[/^onmouse(:?out|over)/,''],[/^onload$/,''],[/(?:v|o):\w+/,''],[/^lang/,'']],attributes:{style:n(A?[[/^margin$|^margin-(?!bottom|top)/,null,function(B,C,D){if(C.name in {p:1,div:1}){var E=k.contentsLangDirection=='ltr'?'margin-left':'margin-right';if(D=='margin')B=x(D,B,[E])[E];else if(D!=E)return null;if(B&&!d.test(B))return[E,B];}return null;}],[/^clear$/],[/^border.*|margin.*|vertical-align|float$/,null,function(B,C){if(C.name=='img')return B;}],[/^width|height$/,null,function(B,C){if(C.name in {table:1,td:1,th:1,img:1})return B;}]]:[[/^mso-/],[/-color$/,null,function(B){if(B=='transparent')return false; -if(CKEDITOR.env.gecko)return B.replace(/-moz-use-text-color/g,'transparent');}],[/^margin$/,d],['text-indent','0cm'],['page-break-before'],['tab-stops'],['display','none'],z?[/font-?/]:null],A),width:function(B,C){if(C.name in i.$tableContent)return false;},border:function(B,C){if(C.name in i.$tableContent)return false;},'class':m,bgcolor:m,valign:A?m:function(B,C){C.addStyle('vertical-align',B);return false;}},comment:!CKEDITOR.env.ie?function(B,C){var D=B.match(//),E=B.match(/^\[if !supportLists\]([\s\S]*?)\[endif\]$/);if(E){var F=E[1]||D&&'l.',G=F&&F.match(/>([^\s]+?)([.)]?)]*o:href=['"](.*?)['"]/),K=J&&J[1];K&&(H.attributes.src=K);return H;}return false;}:m};}};var g=function(){this.dataFilter=new CKEDITOR.htmlParser.filter();};g.prototype={toHtml:function(h){var i=CKEDITOR.htmlParser.fragment.fromHtml(h,false),j=new CKEDITOR.htmlParser.basicWriter();i.writeHtml(j,this.dataFilter);return j.getHtml(true);}};CKEDITOR.cleanWord=function(h,i){if(CKEDITOR.env.gecko)h=h.replace(/(([\S\s]*?))/gi,'$1$2$3');var j=new g(),k=j.dataFilter;k.addRules(CKEDITOR.plugins.pastefromword.getRules(i));i.fire('beforeCleanWord',{filter:k});try{h=j.toHtml(h,false);}catch(l){alert(i.lang.pastefromword.error);}h=h.replace(/cke:.*?".*?"/g,'');h=h.replace(/style=""/g,'');h=h.replace(//g,'');return h;};})(); +(function(){var a=CKEDITOR.htmlParser.fragment.prototype,b=CKEDITOR.htmlParser.element.prototype;a.onlyChild=b.onlyChild=function(){var h=this.children,i=h.length,j=i==1&&h[0];return j||null;};b.removeAnyChildWithName=function(h){var i=this.children,j=[],k;for(var l=0;lf)e=m-f;i['cke:margin']=f=m;}]])(i.style,h)||''; +var k=j.attributes,l=k.style;h.addStyle(l);CKEDITOR.tools.extend(i,k);return true;}return false;},convertToPx:(function(){var h=CKEDITOR.dom.element.createFromHtml('
',CKEDITOR.document);CKEDITOR.document.getBody().append(h);return function(i){if(c.test(i)){h.setStyle('width',i);return h.$.clientWidth+'px';}return i;};})(),getStyleComponents:(function(){var h=CKEDITOR.dom.element.createFromHtml('
',CKEDITOR.document);CKEDITOR.document.getBody().append(h);return function(i,j,k){h.setStyle(i,j);var l={},m=k.length;for(var n=0;nr){p=new CKEDITOR.htmlParser.element(m);p.add(k);o.add(p);}else if(n3?'large':C.size<3?'small':'medium')+';';delete C.size;}B.name='span';B.addStyle(D);}},span:function(B){if(!CKEDITOR.env.gecko&&t(B.parent))return false;B.filterChildren();if(u(B)){delete B.name;return null;}if(!CKEDITOR.env.gecko&&t(B)){var C=B.firstChild(function(J){return J.value||J.name=='img';}),D=C&&(C.value||'l.'),E=D.match(/^([^\s]+?)([.)]?)$/);return q(E,D);}var F=B.children,G=B.attributes,H=G&&G.style,I=F&&F[0];if(H)G.style=n([['line-height'],[/^font-family$/,null,!z?p(k.font_style,'family'):null],[/^font-size$/,null,!z?p(k.fontSize_style,'size'):null],[/^color$/,null,!z?p(k.colorButton_foreStyle,'color'):null],[/^background-color$/,null,!z?p(k.colorButton_backStyle,'color'):null]])(H,B)||'';return null;},b:o(k.coreStyles_bold),i:o(k.coreStyles_italic),u:o(k.coreStyles_underline),s:o(k.coreStyles_strike),sup:o(k.coreStyles_superscript),sub:o(k.coreStyles_subscript),a:function(B){var C=B.attributes;if(C&&!C.href&&C.name)delete B.name;},'cke:listbullet':function(B){if(B.getAncestor(/h\d/)&&!k.pasteFromWordNumberedHeadingToList)delete B.name;}},attributeNames:[[/^onmouse(:?out|over)/,''],[/^onload$/,''],[/(?:v|o):\w+/,''],[/^lang/,'']],attributes:{style:n(A?[[/^margin$|^margin-(?!bottom|top)/,null,function(B,C,D){if(C.name in {p:1,div:1}){var E=k.contentsLangDirection=='ltr'?'margin-left':'margin-right';if(D=='margin')B=x(D,B,[E])[E];else if(D!=E)return null;if(B&&!d.test(B))return[E,B];}return null;}],[/^clear$/],[/^border.*|margin.*|vertical-align|float$/,null,function(B,C){if(C.name=='img')return B;}],[/^width|height$/,null,function(B,C){if(C.name in {table:1,td:1,th:1,img:1})return B; +}]]:[[/^mso-/],[/-color$/,null,function(B){if(B=='transparent')return false;if(CKEDITOR.env.gecko)return B.replace(/-moz-use-text-color/g,'transparent');}],[/^margin$/,d],['text-indent','0cm'],['page-break-before'],['tab-stops'],['display','none'],z?[/font-?/]:null],A),width:function(B,C){if(C.name in i.$tableContent)return false;},border:function(B,C){if(C.name in i.$tableContent)return false;},'class':m,bgcolor:m,valign:A?m:function(B,C){C.addStyle('vertical-align',B);return false;}},comment:!CKEDITOR.env.ie?function(B,C){var D=B.match(//),E=B.match(/^\[if !supportLists\]([\s\S]*?)\[endif\]$/);if(E){var F=E[1]||D&&'l.',G=F&&F.match(/>([^\s]+?)([.)]?)]*o:href=['"](.*?)['"]/),K=J&&J[1];K&&(H.attributes.src=K);return H;}return false;}:m};}};var g=function(){this.dataFilter=new CKEDITOR.htmlParser.filter();};g.prototype={toHtml:function(h){var i=CKEDITOR.htmlParser.fragment.fromHtml(h,false),j=new CKEDITOR.htmlParser.basicWriter();i.writeHtml(j,this.dataFilter);return j.getHtml(true);}};CKEDITOR.cleanWord=function(h,i){if(CKEDITOR.env.gecko)h=h.replace(/(([\S\s]*?))/gi,'$1$2$3');var j=new g(),k=j.dataFilter;k.addRules(CKEDITOR.plugins.pastefromword.getRules(i));i.fire('beforeCleanWord',{filter:k});try{h=j.toHtml(h,false);}catch(l){alert(i.lang.pastefromword.error);}h=h.replace(/cke:.*?".*?"/g,'');h=h.replace(/style=""/g,'');h=h.replace(//g,'');return h;};})();