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