X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=plugins%2Fpastefromword%2Ffilter%2Fdefault.js;h=12d01b5edad4901533dcdcf42a4b74e018d381da;hb=4625dba05116026713fee9008dd93306be0d1553;hp=280e5598515f324f0e972e5113d56a326aedde71;hpb=941b0a9ba4e673e292510d80a5a86806994b8ea6;p=ckeditor.git diff --git a/plugins/pastefromword/filter/default.js b/plugins/pastefromword/filter/default.js index 280e559..12d01b5 100644 --- a/plugins/pastefromword/filter/default.js +++ b/plugins/pastefromword/filter/default.js @@ -1,10 +1,30 @@ -/* -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=n-f;j['cke:margin']=f=n;}]])(j.style,h)||'';var l=k.attributes,m=l.style; -h.addStyle(m);CKEDITOR.tools.extend(j,l);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':D.size<3?'small':'medium')+';';delete D.size;}C.name='span';C.addStyle(E);}},span:function(C){if(!CKEDITOR.env.gecko&&u(C.parent))return false;C.filterChildren();if(v(C)){delete C.name;return null;}if(!CKEDITOR.env.gecko&&u(C)){var D=C.firstChild(function(K){return K.value||K.name=='img';}),E=D&&(D.value||'l.'),F=E.match(/^([^\s]+?)([.)]?)$/);return r(F,E);}var G=C.children,H=C.attributes,I=H&&H.style,J=G&&G[0];if(I)H.style=n([['line-height'],[/^font-family$/,null,!A?p(k.font_style,'family'):null],[/^font-size$/,null,!A?p(k.fontSize_style,'size'):null],[/^color$/,null,!A?p(k.colorButton_foreStyle,'color'):null],[/^background-color$/,null,!A?p(k.colorButton_backStyle,'color'):null]])(I,C)||'';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(C){var D=C.attributes;if(D&&!D.href&&D.name)delete C.name;},'cke:listbullet':function(C){if(C.getAncestor(/h\d/)&&!k.pasteFromWordNumberedHeadingToList)delete C.name;}},attributeNames:[[/^onmouse(:?out|over)/,''],[/^onload$/,''],[/(?:v|o):\w+/,''],[/^lang/,'']],attributes:{style:n(B?[[/^margin$|^margin-(?!bottom|top)/,null,function(C,D,E){if(D.name in {p:1,div:1}){var F=k.contentsLangDirection=='ltr'?'margin-left':'margin-right';if(E=='margin')C=y(E,C,[F])[F];else if(E!=F)return null;if(C&&!d.test(C))return[F,C];}return null;}],[/^clear$/],[/^border.*|margin.*|vertical-align|float$/,null,function(C,D){if(D.name=='img')return C;}],[/^width|height$/,null,function(C,D){if(D.name in {table:1,td:1,th:1,img:1})return C; -}]]:[[/^mso-/],[/-color$/,null,function(C){if(C=='transparent')return false;if(CKEDITOR.env.gecko)return C.replace(/-moz-use-text-color/g,'transparent');}],[/^margin$/,d],['text-indent','0cm'],['page-break-before'],['tab-stops'],['display','none'],A?[/font-?/]:null],B),width:function(C,D){if(D.name in i.$tableContent)return false;},border:function(C,D){if(D.name in i.$tableContent)return false;},'class':m,bgcolor:m,valign:B?m:function(C,D){D.addStyle('vertical-align',C);return false;}},comment:!CKEDITOR.env.ie?function(C,D){var E=C.match(//),F=C.match(/^\[if !supportLists\]([\s\S]*?)\[endif\]$/);if(F){var G=F[1]||E&&'l.',H=G&&G.match(/>([^\s]+?)([.)]?)]*o:href=['"](.*?)['"]/),L=K&&K[1];L&&(I.attributes.src=L);return I;}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;};})(); +/* + Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved. + For licensing, see LICENSE.html or http://ckeditor.com/license +*/ +(function(){function y(a){for(var a=a.toUpperCase(),b=z.length,d=0,c=0;cp)&&(u=a-p);p=a;b["cke:indent"]=u&&Math.ceil(a/u)+1||1}],[/^mso-list$/,null,function(a){var a=a.split(" "),d=Number(a[0].match(/\d+/)),a=Number(a[1].match(/\d+/));1==a&&(d!==v&&(b["cke:reset"]=1),v=d);b["cke:indent"]=a}]])(b.style,a)||""),b["cke:indent"]||(p=0,b["cke:indent"]=1),CKEDITOR.tools.extend(b,d.attributes),!0;v=p=u=null;return!1},getStyleComponents:function(){var a=CKEDITOR.dom.element.createFromHtml('
', +CKEDITOR.document);CKEDITOR.document.getBody().append(a);return function(b,d,c){a.setStyle(b,d);for(var b={},d=c.length,e=0;ef)a.push(g=new CKEDITOR.htmlParser.element(m)),g.add(d),h.add(g);else{if(eb.size?"small":"medium")+";",delete b.size),a.name="span",a.addStyle(c))}},span:function(a){if(m(a.parent))return!1;a.filterChildren();if(k(a))return delete a.name,null;if(m(a)){var b=a.firstChild(function(a){return a.value||"img"==a.name}), +d=(b=b&&(b.value||"l."))&&b.match(/^(?:[(]?)([^\s]+?)([.)]?)$/);if(d)return b=i(d,b),(a=a.getAncestor("span"))&&/ mso-hide:\s*all|display:\s*none /.test(a.attributes.style)&&(b.attributes["cke:ignored"]=1),b}if(d=(b=a.attributes)&&b.style)b.style=f([["line-height"],[/^font-family$/,null,!o?g(c.font_style,"family"):null],[/^font-size$/,null,!o?g(c.fontSize_style,"size"):null],[/^color$/,null,!o?g(c.colorButton_foreStyle,"color"):null],[/^background-color$/,null,!o?g(c.colorButton_backStyle,"color"): +null]])(d,a)||"";return null},b:h(c.coreStyles_bold),i:h(c.coreStyles_italic),u:h(c.coreStyles_underline),s:h(c.coreStyles_strike),sup:h(c.coreStyles_superscript),sub:h(c.coreStyles_subscript),a:function(a){var b=a.attributes;b&&!b.href&&b.name?delete a.name:CKEDITOR.env.webkit&&(b.href&&b.href.match(/file:\/\/\/[\S]+#/i))&&(b.href=b.href.replace(/file:\/\/\/[^#]+/i,""))},"cke:listbullet":function(a){a.getAncestor(/h\d/)&&!c.pasteFromWordNumberedHeadingToList&&delete a.name}},attributeNames:[[/^onmouse(:?out|over)/, +""],[/^onload$/,""],[/(?:v|o):\w+/,""],[/^lang/,""]],attributes:{style:f(p?[[/^list-style-type$/,null],[/^margin$|^margin-(?!bottom|top)/,null,function(a,b,d){if(b.name in{p:1,div:1}){b="ltr"==c.contentsLangDirection?"margin-left":"margin-right";if("margin"==d)a=s(d,a,[b])[b];else if(d!=b)return null;if(a&&!D.test(a))return[b,a]}return null}],[/^clear$/],[/^border.*|margin.*|vertical-align|float$/,null,function(a,b){if("img"==b.name)return a}],[/^width|height$/,null,function(a,b){if(b.name in{table:1, +td:1,th:1,img:1})return a}]]:[[/^mso-/],[/-color$/,null,function(a){if("transparent"==a)return!1;if(CKEDITOR.env.gecko)return a.replace(/-moz-use-text-color/g,"transparent")}],[/^margin$/,D],["text-indent","0cm"],["page-break-before"],["tab-stops"],["display","none"],o?[/font-?/]:null],p),width:function(a,c){if(c.name in b.$tableContent)return!1},border:function(a,c){if(c.name in b.$tableContent)return!1},"class":a,bgcolor:a,valign:p?a:function(a,b){b.addStyle("vertical-align",a);return!1}},comment:!CKEDITOR.env.ie? +function(a,b){var c=a.match(//),d=a.match(/^\[if !supportLists\]([\s\S]*?)\[endif\]$/);return d?(d=(c=d[1]||c&&"l.")&&c.match(/>(?:[(]?)([^\s]+?)([.)]?)]*o:href=['"](.*?)['"]/))&&d[1])&&(c.attributes.src=d),c):!1}:a}}},F=function(){this.dataFilter=new CKEDITOR.htmlParser.filter};F.prototype={toHtml:function(a){var a=CKEDITOR.htmlParser.fragment.fromHtml(a), +b=new CKEDITOR.htmlParser.basicWriter;a.writeHtml(b,this.dataFilter);return b.getHtml(!0)}};CKEDITOR.cleanWord=function(a,b){CKEDITOR.env.gecko&&(a=a.replace(/(<\!--\[if[^<]*?\])--\>([\S\s]*?)<\!--(\[endif\]--\>)/gi,"$1$2$3"));var d=new F,c=d.dataFilter;c.addRules(CKEDITOR.plugins.pastefromword.getRules(b));b.fire("beforeCleanWord",{filter:c});try{a=d.toHtml(a)}catch(e){alert(b.lang.pastefromword.error)}a=a.replace(/cke:.*?".*?"/g,"");a=a.replace(/style=""/g,"");return a=a.replace(//g,"")}})(); \ No newline at end of file