JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-4.1_full
[ckeditor.git] / plugins / pastefromword / filter / default.js
index 17cc020..2a1b07c 100644 (file)
@@ -1,11 +1,31 @@
-/*\r
-Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.\r
-For licensing, see LICENSE.html or http://ckeditor.com/license\r
-*/\r
-\r
-(function(){var a=CKEDITOR.htmlParser.fragment.prototype,b=CKEDITOR.htmlParser.element.prototype;a.onlyChild=b.onlyChild=function(){var u=this.children,v=u.length,w=v==1&&u[0];return w||null;};b.removeAnyChildWithName=function(u){var v=this.children,w=[],x;for(var y=0;y<v.length;y++){x=v[y];if(!x.name)continue;if(x.name==u){w.push(x);v.splice(y--,1);}w=w.concat(x.removeAnyChildWithName(u));}return w;};b.getAncestor=function(u){var v=this.parent;while(v&&!(v.name&&v.name.match(u)))v=v.parent;return v;};a.firstChild=b.firstChild=function(u){var v;for(var w=0;w<this.children.length;w++){v=this.children[w];if(u(v))return v;else if(v.name){v=v.firstChild(u);if(v)return v;}}return null;};b.addStyle=function(u,v,w){var A=this;var x,y='';if(typeof v=='string')y+=u+':'+v+';';else{if(typeof u=='object')for(var z in u){if(u.hasOwnProperty(z))y+=z+':'+u[z]+';';}else y+=u;w=v;}if(!A.attributes)A.attributes={};x=A.attributes.style||'';x=(w?[y,x]:[x,y]).join(';');A.attributes.style=x.replace(/^;|;(?=;)/,'');};CKEDITOR.dtd.parentOf=function(u){var v={};for(var w in this){if(w.indexOf('$')==-1&&this[w][u])v[w]=1;}return v;};function c(u){var v=u.children,w,x,y=u.children.length,z,A,B=/list-style-type:(.*?)(?:;|$)/,C=CKEDITOR.plugins.pastefromword.filters.stylesFilter;x=u.attributes;if(B.exec(x.style))return;for(var D=0;D<y;D++){w=v[D];if(w.attributes.value&&Number(w.attributes.value)==D+1)delete w.attributes.value;z=B.exec(w.attributes.style);if(z)if(z[1]==A||!A)A=z[1];else{A=null;break;}}if(A){for(D=0;D<y;D++){x=v[D].attributes;x.style&&(x.style=C([['list-style-type']])(x.style)||'');}u.addStyle('list-style-type',A);}};var d=/^([.\d]*)+(em|ex|px|gd|rem|vw|vh|vm|ch|mm|cm|in|pt|pc|deg|rad|ms|s|hz|khz){1}?/i,e=/^(?:\b0[^\s]*\s*){1,4}$/,f='^m{0,4}(cm|cd|d?c{0,3})(xc|xl|l?x{0,3})(ix|iv|v?i{0,3})$',g=new RegExp(f),h=new RegExp(f.toUpperCase()),i={decimal:/\d+/,'lower-roman':g,'upper-roman':h,'lower-alpha':/^[a-z]+$/,'upper-alpha':/^[A-Z]+$/},j={disc:/[l\u00B7\u2002]/,circle:/[\u006F\u00D8]/,square:/[\u006E\u25C6]/},k={ol:i,ul:j},l=[[1000,'M'],[900,'CM'],[500,'D'],[400,'CD'],[100,'C'],[90,'XC'],[50,'L'],[40,'XL'],[10,'X'],[9,'IX'],[5,'V'],[4,'IV'],[1,'I']],m='ABCDEFGHIJKLMNOPQRSTUVWXYZ';function n(u){u=u.toUpperCase();var v=l.length,w=0;for(var x=0;x<v;++x)for(var y=l[x],z=y[1].length;u.substr(0,z)==y[1];u=u.substr(z))w+=y[0];return w;};function o(u){u=u.toUpperCase();var v=m.length,w=1;for(var x=1;u.length>0;x*=v){w+=m.indexOf(u.charAt(u.length-1))*x;u=u.substr(0,u.length-1);}return w;\r
-};var p=0,q=null,r,s=CKEDITOR.plugins.pastefromword={utils:{createListBulletMarker:function(u,v){var w=new CKEDITOR.htmlParser.element('cke:listbullet');w.attributes={'cke:listsymbol':u[0]};w.add(new CKEDITOR.htmlParser.text(v));return w;},isListBulletIndicator:function(u){var v=u.attributes&&u.attributes.style;if(/mso-list\s*:\s*Ignore/i.test(v))return true;},isContainingOnlySpaces:function(u){var v;return(v=u.onlyChild())&&/^(:?\s|&nbsp;)+$/.test(v.value);},resolveList:function(u){var v=u.attributes,w;if((w=u.removeAnyChildWithName('cke:listbullet'))&&w.length&&(w=w[0])){u.name='cke:li';if(v.style)v.style=s.filters.stylesFilter([['text-indent'],['line-height'],[/^margin(:?-left)?$/,null,function(x){var y=x.split(' ');x=CKEDITOR.tools.convertToPx(y[3]||y[1]||y[0]);if(!p&&q!==null&&x>q)p=x-q;q=x;v['cke:indent']=p&&Math.ceil(x/p)+1||1;}],[/^mso-list$/,null,function(x){x=x.split(' ');var y=Number(x[0].match(/\d+/)),z=Number(x[1].match(/\d+/));if(z==1){y!==r&&(v['cke:reset']=1);r=y;}v['cke:indent']=z;}]])(v.style,u)||'';if(!v['cke:indent']){q=0;v['cke:indent']=1;}CKEDITOR.tools.extend(v,w.attributes);return true;}else r=q=p=null;return false;},getStyleComponents:(function(){var u=CKEDITOR.dom.element.createFromHtml('<div style="position:absolute;left:-9999px;top:-9999px;"></div>',CKEDITOR.document);CKEDITOR.document.getBody().append(u);return function(v,w,x){u.setStyle(v,w);var y={},z=x.length;for(var A=0;A<z;A++)y[x[A]]=u.getStyle(x[A]);return y;};})(),listDtdParents:CKEDITOR.dtd.parentOf('ol')},filters:{flattenList:function(u,v){v=typeof v=='number'?v:1;var w=u.attributes,x;switch(w.type){case 'a':x='lower-alpha';break;case '1':x='decimal';break;}var y=u.children,z;for(var A=0;A<y.length;A++){z=y[A];if(z.name in CKEDITOR.dtd.$listItem){var B=z.attributes,C=z.children,D=C.length,E=C[D-1];if(E.name in CKEDITOR.dtd.$list){u.add(E,A+1);if(!--C.length)y.splice(A--,1);}z.name='cke:li';w.start&&!A&&(B.value=w.start);s.filters.stylesFilter([['tab-stops',null,function(H){var I=H.split(' ')[1].match(d);I&&(q=CKEDITOR.tools.convertToPx(I[0]));}],v==1?['mso-list',null,function(H){H=H.split(' ');var I=Number(H[0].match(/\d+/));I!==r&&(B['cke:reset']=1);r=I;}]:null])(B.style);B['cke:indent']=v;B['cke:listtype']=u.name;B['cke:list-style-type']=x;}else if(z.name in CKEDITOR.dtd.$list){arguments.callee.apply(this,[z,v+1]);y=y.slice(0,A).concat(z.children).concat(y.slice(A+1));u.children=[];for(var F=0,G=y.length;F<G;F++)u.add(y[F]);}}delete u.name;w['cke:list']=1;},assembleList:function(u){var v=u.children,w,x,y,z,A,B,C,D=[],E,F,G,H,I,J;\r
-for(var K=0;K<v.length;K++){w=v[K];if('cke:li'==w.name){w.name='li';x=w;y=x.attributes;G=y['cke:listsymbol'];G=G&&G.match(/^(?:[(]?)([^\s]+?)([.)]?)$/);H=I=J=null;if(y['cke:ignored']){v.splice(K--,1);continue;}y['cke:reset']&&(C=A=B=null);z=Number(y['cke:indent']);if(z!=A)F=E=null;if(!G){H=y['cke:listtype']||'ol';I=y['cke:list-style-type'];}else{if(F&&k[F][E].test(G[1])){H=F;I=E;}else for(var L in k)for(var M in k[L]){if(k[L][M].test(G[1]))if(L=='ol'&&/alpha|roman/.test(M)){var N=/roman/.test(M)?n(G[1]):o(G[1]);if(!J||N<J){J=N;H=L;I=M;}}else{H=L;I=M;break;}}!H&&(H=G[2]?'ol':'ul');}F=H;E=I||(H=='ol'?'decimal':'disc');if(I&&I!=(H=='ol'?'decimal':'disc'))x.addStyle('list-style-type',I);if(H=='ol'&&G){switch(I){case 'decimal':J=Number(G[1]);break;case 'lower-roman':case 'upper-roman':J=n(G[1]);break;case 'lower-alpha':case 'upper-alpha':J=o(G[1]);break;}x.attributes.value=J;}if(!C){D.push(C=new CKEDITOR.htmlParser.element(H));C.add(x);v[K]=C;}else{if(z>A){D.push(C=new CKEDITOR.htmlParser.element(H));C.add(x);B.add(C);}else if(z<A){var O=A-z,P;while(O--&&(P=C.parent))C=P.parent;C.add(x);}else C.add(x);v.splice(K--,1);}B=x;A=z;}else if(C)C=A=B=null;}for(K=0;K<D.length;K++)c(D[K]);C=A=B=r=q=p=null;},falsyFilter:function(u){return false;},stylesFilter:function(u,v){return function(w,x){var y=[];(w||'').replace(/&quot;/g,'"').replace(/\s*([^ :;]+)\s*:\s*([^;]+)\s*(?=;|$)/g,function(A,B,C){B=B.toLowerCase();B=='font-family'&&(C=C.replace(/["']/g,''));var D,E,F,G;for(var H=0;H<u.length;H++){if(u[H]){D=u[H][0];E=u[H][1];F=u[H][2];G=u[H][3];if(B.match(D)&&(!E||C.match(E))){B=G||B;v&&(F=F||C);if(typeof F=='function')F=F(C,x,B);if(F&&F.push)B=F[0],F=F[1];if(typeof F=='string')y.push([B,F]);return;}}}!v&&y.push([B,C]);});for(var z=0;z<y.length;z++)y[z]=y[z].join(':');return y.length?y.join(';')+';':false;};},elementMigrateFilter:function(u,v){return function(w){var x=v?new CKEDITOR.style(u,v)._.definition:u;w.name=x.element;CKEDITOR.tools.extend(w.attributes,CKEDITOR.tools.clone(x.attributes));w.addStyle(CKEDITOR.style.getStyleText(x));};},styleMigrateFilter:function(u,v){var w=this.elementMigrateFilter;return function(x,y){var z=new CKEDITOR.htmlParser.element(null),A={};A[v]=x;w(u,A)(z);z.children=y.children;y.children=[z];};},bogusAttrFilter:function(u,v){if(v.name.indexOf('cke:')==-1)return false;},applyStyleFilter:null},getRules:function(u){var v=CKEDITOR.dtd,w=CKEDITOR.tools.extend({},v.$block,v.$listItem,v.$tableContent),x=u.config,y=this.filters,z=y.falsyFilter,A=y.stylesFilter,B=y.elementMigrateFilter,C=CKEDITOR.tools.bind(this.filters.styleMigrateFilter,this.filters),D=this.utils.createListBulletMarker,E=y.flattenList,F=y.assembleList,G=this.utils.isListBulletIndicator,H=this.utils.isContainingOnlySpaces,I=this.utils.resolveList,J=function(O){O=CKEDITOR.tools.convertToPx(O);\r
-return isNaN(O)?O:O+'px';},K=this.utils.getStyleComponents,L=this.utils.listDtdParents,M=x.pasteFromWordRemoveFontStyles!==false,N=x.pasteFromWordRemoveStyles!==false;return{elementNames:[[/meta|link|script/,'']],root:function(O){O.filterChildren();F(O);},elements:{'^':function(O){var P;if(CKEDITOR.env.gecko&&(P=y.applyStyleFilter))P(O);},$:function(O){var P=O.name||'',Q=O.attributes;if(P in w&&Q.style)Q.style=A([[/^(:?width|height)$/,null,J]])(Q.style)||'';if(P.match(/h\d/)){O.filterChildren();if(I(O))return;B(x['format_'+P])(O);}else if(P in v.$inline){O.filterChildren();if(H(O))delete O.name;}else if(P.indexOf(':')!=-1&&P.indexOf('cke')==-1){O.filterChildren();if(P=='v:imagedata'){var R=O.attributes['o:href'];if(R)O.attributes.src=R;O.name='img';return;}delete O.name;}if(P in L){O.filterChildren();F(O);}},style:function(O){if(CKEDITOR.env.gecko){var P=O.onlyChild().value.match(/\/\* Style Definitions \*\/([\s\S]*?)\/\*/),Q=P&&P[1],R={};if(Q){Q.replace(/[\n\r]/g,'').replace(/(.+?)\{(.+?)\}/g,function(S,T,U){T=T.split(',');var V=T.length,W;for(var X=0;X<V;X++)CKEDITOR.tools.trim(T[X]).replace(/^(\w+)(\.[\w-]+)?$/g,function(Y,Z,aa){Z=Z||'*';aa=aa.substring(1,aa.length);if(aa.match(/MsoNormal/))return;if(!R[Z])R[Z]={};if(aa)R[Z][aa]=U;else R[Z]=U;});});y.applyStyleFilter=function(S){var T=R['*']?'*':S.name,U=S.attributes&&S.attributes['class'],V;if(T in R){V=R[T];if(typeof V=='object')V=V[U];V&&S.addStyle(V,true);}};}}return false;},p:function(O){if(/MsoListParagraph/.exec(O.attributes['class'])){var P=O.firstChild(function(S){return S.type==CKEDITOR.NODE_TEXT&&!H(S.parent);}),Q=P&&P.parent,R=Q&&Q.attributes;R&&!R.style&&(R.style='mso-list: Ignore;');}O.filterChildren();if(I(O))return;if(x.enterMode==CKEDITOR.ENTER_BR){delete O.name;O.add(new CKEDITOR.htmlParser.element('br'));}else B(x['format_'+(x.enterMode==CKEDITOR.ENTER_P?'p':'div')])(O);},div:function(O){var P=O.onlyChild();if(P&&P.name=='table'){var Q=O.attributes;P.attributes=CKEDITOR.tools.extend(P.attributes,Q);Q.style&&P.addStyle(Q.style);var R=new CKEDITOR.htmlParser.element('div');R.addStyle('clear','both');O.add(R);delete O.name;}},td:function(O){if(O.getAncestor('thead'))O.name='th';},ol:E,ul:E,dl:E,font:function(O){if(G(O.parent)){delete O.name;return;}O.filterChildren();var P=O.attributes,Q=P.style,R=O.parent;if('font'==R.name){CKEDITOR.tools.extend(R.attributes,O.attributes);Q&&R.addStyle(Q);delete O.name;}else{Q=Q||'';if(P.color){P.color!='#000000'&&(Q+='color:'+P.color+';');delete P.color;\r
-}if(P.face){Q+='font-family:'+P.face+';';delete P.face;}if(P.size){Q+='font-size:'+(P.size>3?'large':P.size<3?'small':'medium')+';';delete P.size;}O.name='span';O.addStyle(Q);}},span:function(O){if(G(O.parent))return false;O.filterChildren();if(H(O)){delete O.name;return null;}if(G(O)){var P=O.firstChild(function(Y){return Y.value||Y.name=='img';}),Q=P&&(P.value||'l.'),R=Q&&Q.match(/^(?:[(]?)([^\s]+?)([.)]?)$/);if(R){var S=D(R,Q),T=O.getAncestor('span');if(T&&/ mso-hide:\s*all|display:\s*none /.test(T.attributes.style))S.attributes['cke:ignored']=1;return S;}}var U=O.children,V=O.attributes,W=V&&V.style,X=U&&U[0];if(W)V.style=A([['line-height'],[/^font-family$/,null,!M?C(x.font_style,'family'):null],[/^font-size$/,null,!M?C(x.fontSize_style,'size'):null],[/^color$/,null,!M?C(x.colorButton_foreStyle,'color'):null],[/^background-color$/,null,!M?C(x.colorButton_backStyle,'color'):null]])(W,O)||'';return null;},b:B(x.coreStyles_bold),i:B(x.coreStyles_italic),u:B(x.coreStyles_underline),s:B(x.coreStyles_strike),sup:B(x.coreStyles_superscript),sub:B(x.coreStyles_subscript),a:function(O){var P=O.attributes;if(P&&!P.href&&P.name)delete O.name;else if(CKEDITOR.env.webkit&&P.href&&P.href.match(/file:\/\/\/[\S]+#/i))P.href=P.href.replace(/file:\/\/\/[^#]+/i,'');},'cke:listbullet':function(O){if(O.getAncestor(/h\d/)&&!x.pasteFromWordNumberedHeadingToList)delete O.name;}},attributeNames:[[/^onmouse(:?out|over)/,''],[/^onload$/,''],[/(?:v|o):\w+/,''],[/^lang/,'']],attributes:{style:A(N?[[/^list-style-type$/,null],[/^margin$|^margin-(?!bottom|top)/,null,function(O,P,Q){if(P.name in {p:1,div:1}){var R=x.contentsLangDirection=='ltr'?'margin-left':'margin-right';if(Q=='margin')O=K(Q,O,[R])[R];else if(Q!=R)return null;if(O&&!e.test(O))return[R,O];}return null;}],[/^clear$/],[/^border.*|margin.*|vertical-align|float$/,null,function(O,P){if(P.name=='img')return O;}],[/^width|height$/,null,function(O,P){if(P.name in {table:1,td:1,th:1,img:1})return O;}]]:[[/^mso-/],[/-color$/,null,function(O){if(O=='transparent')return false;if(CKEDITOR.env.gecko)return O.replace(/-moz-use-text-color/g,'transparent');}],[/^margin$/,e],['text-indent','0cm'],['page-break-before'],['tab-stops'],['display','none'],M?[/font-?/]:null],N),width:function(O,P){if(P.name in v.$tableContent)return false;},border:function(O,P){if(P.name in v.$tableContent)return false;},'class':z,bgcolor:z,valign:N?z:function(O,P){P.addStyle('vertical-align',O);return false;}},comment:!CKEDITOR.env.ie?function(O,P){var Q=O.match(/<img.*?>/),R=O.match(/^\[if !supportLists\]([\s\S]*?)\[endif\]$/);\r
-if(R){var S=R[1]||Q&&'l.',T=S&&S.match(/>(?:[(]?)([^\s]+?)([.)]?)</);return D(T,S);}if(CKEDITOR.env.gecko&&Q){var U=CKEDITOR.htmlParser.fragment.fromHtml(Q[0]).children[0],V=P.previous,W=V&&V.value.match(/<v:imagedata[^>]*o:href=['"](.*?)['"]/),X=W&&W[1];X&&(U.attributes.src=X);return U;}return false;}:z};}},t=function(){this.dataFilter=new CKEDITOR.htmlParser.filter();};t.prototype={toHtml:function(u){var v=CKEDITOR.htmlParser.fragment.fromHtml(u,false),w=new CKEDITOR.htmlParser.basicWriter();v.writeHtml(w,this.dataFilter);return w.getHtml(true);}};CKEDITOR.cleanWord=function(u,v){if(CKEDITOR.env.gecko)u=u.replace(/(<!--\[if[^<]*?\])-->([\S\s]*?)<!--(\[endif\]-->)/gi,'$1$2$3');var w=new t(),x=w.dataFilter;x.addRules(CKEDITOR.plugins.pastefromword.getRules(v));v.fire('beforeCleanWord',{filter:x});try{u=w.toHtml(u,false);}catch(y){alert(v.lang.pastefromword.error);}u=u.replace(/cke:.*?".*?"/g,'');u=u.replace(/style=""/g,'');u=u.replace(/<span>/g,'');return u;};})();\r
+/*
+ Copyright (c) 2003-2013, 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(),c=z.length,b=0,f=0;f<c;++f)for(var d=z[f],e=d[1].length;a.substr(0,e)==d[1];a=a.substr(e))b+=d[0];return b}function A(a){for(var a=a.toUpperCase(),c=B.length,b=1,f=1;0<a.length;f*=c)b+=B.indexOf(a.charAt(a.length-1))*f,a=a.substr(0,a.length-1);return b}var C=CKEDITOR.htmlParser.fragment.prototype,o=CKEDITOR.htmlParser.element.prototype;C.onlyChild=o.onlyChild=function(){var a=this.children;return 1==a.length&&a[0]||null};o.removeAnyChildWithName=
+function(a){for(var c=this.children,b=[],f,d=0;d<c.length;d++)f=c[d],f.name&&(f.name==a&&(b.push(f),c.splice(d--,1)),b=b.concat(f.removeAnyChildWithName(a)));return b};o.getAncestor=function(a){for(var c=this.parent;c&&(!c.name||!c.name.match(a));)c=c.parent;return c};C.firstChild=o.firstChild=function(a){for(var c,b=0;b<this.children.length;b++)if(c=this.children[b],a(c)||c.name&&(c=c.firstChild(a)))return c;return null};o.addStyle=function(a,c,b){var f="";if("string"==typeof c)f+=a+":"+c+";";else{if("object"==
+typeof a)for(var d in a)a.hasOwnProperty(d)&&(f+=d+":"+a[d]+";");else f+=a;b=c}this.attributes||(this.attributes={});a=this.attributes.style||"";a=(b?[f,a]:[a,f]).join(";");this.attributes.style=a.replace(/^;|;(?=;)/,"")};o.getStyle=function(a){var c=this.attributes.style;if(c)return c=CKEDITOR.tools.parseCssText(c,1),c[a]};CKEDITOR.dtd.parentOf=function(a){var c={},b;for(b in this)-1==b.indexOf("$")&&this[b][a]&&(c[b]=1);return c};var H=/^([.\d]*)+(em|ex|px|gd|rem|vw|vh|vm|ch|mm|cm|in|pt|pc|deg|rad|ms|s|hz|khz){1}?/i,
+D=/^(?:\b0[^\s]*\s*){1,4}$/,x={ol:{decimal:/\d+/,"lower-roman":/^m{0,4}(cm|cd|d?c{0,3})(xc|xl|l?x{0,3})(ix|iv|v?i{0,3})$/,"upper-roman":/^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/,"lower-alpha":/^[a-z]+$/,"upper-alpha":/^[A-Z]+$/},ul:{disc:/[l\u00B7\u2002]/,circle:/[\u006F\u00D8]/,square:/[\u006E\u25C6]/}},z=[[1E3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]],B="ABCDEFGHIJKLMNOPQRSTUVWXYZ",s=0,t=null,w,E=CKEDITOR.plugins.pastefromword=
+{utils:{createListBulletMarker:function(a,c){var b=new CKEDITOR.htmlParser.element("cke:listbullet");b.attributes={"cke:listsymbol":a[0]};b.add(new CKEDITOR.htmlParser.text(c));return b},isListBulletIndicator:function(a){if(/mso-list\s*:\s*Ignore/i.test(a.attributes&&a.attributes.style))return!0},isContainingOnlySpaces:function(a){var c;return(c=a.onlyChild())&&/^(:?\s|&nbsp;)+$/.test(c.value)},resolveList:function(a){var c=a.attributes,b;if((b=a.removeAnyChildWithName("cke:listbullet"))&&b.length&&
+(b=b[0]))return a.name="cke:li",c.style&&(c.style=E.filters.stylesFilter([["text-indent"],["line-height"],[/^margin(:?-left)?$/,null,function(a){a=a.split(" ");a=CKEDITOR.tools.convertToPx(a[3]||a[1]||a[0]);!s&&(null!==t&&a>t)&&(s=a-t);t=a;c["cke:indent"]=s&&Math.ceil(a/s)+1||1}],[/^mso-list$/,null,function(a){var a=a.split(" "),b=Number(a[0].match(/\d+/)),a=Number(a[1].match(/\d+/));1==a&&(b!==w&&(c["cke:reset"]=1),w=b);c["cke:indent"]=a}]])(c.style,a)||""),c["cke:indent"]||(t=0,c["cke:indent"]=
+1),CKEDITOR.tools.extend(c,b.attributes),!0;w=t=s=null;return!1},getStyleComponents:function(){var a=CKEDITOR.dom.element.createFromHtml('<div style="position:absolute;left:-9999px;top:-9999px;"></div>',CKEDITOR.document);CKEDITOR.document.getBody().append(a);return function(c,b,f){a.setStyle(c,b);for(var c={},b=f.length,d=0;d<b;d++)c[f[d]]=a.getStyle(f[d]);return c}}(),listDtdParents:CKEDITOR.dtd.parentOf("ol")},filters:{flattenList:function(a,c){var c="number"==typeof c?c:1,b=a.attributes,f;switch(b.type){case "a":f=
+"lower-alpha";break;case "1":f="decimal"}for(var d=a.children,e,h=0;h<d.length;h++)if(e=d[h],e.name in CKEDITOR.dtd.$listItem){var j=e.attributes,g=e.children,m=g[g.length-1];m.name in CKEDITOR.dtd.$list&&(a.add(m,h+1),--g.length||d.splice(h--,1));e.name="cke:li";b.start&&!h&&(j.value=b.start);E.filters.stylesFilter([["tab-stops",null,function(a){(a=a.split(" ")[1].match(H))&&(t=CKEDITOR.tools.convertToPx(a[0]))}],1==c?["mso-list",null,function(a){a=a.split(" ");a=Number(a[0].match(/\d+/));a!==w&&
+(j["cke:reset"]=1);w=a}]:null])(j.style);j["cke:indent"]=c;j["cke:listtype"]=a.name;j["cke:list-style-type"]=f}else if(e.name in CKEDITOR.dtd.$list){arguments.callee.apply(this,[e,c+1]);d=d.slice(0,h).concat(e.children).concat(d.slice(h+1));a.children=[];e=0;for(g=d.length;e<g;e++)a.add(d[e])}delete a.name;b["cke:list"]=1},assembleList:function(a){for(var c=a.children,b,f,d,e,h,j,a=[],g,m,i,l,k,p,n=0;n<c.length;n++)if(b=c[n],"cke:li"==b.name)if(b.name="li",f=b.attributes,i=(i=f["cke:listsymbol"])&&
+i.match(/^(?:[(]?)([^\s]+?)([.)]?)$/),l=k=p=null,f["cke:ignored"])c.splice(n--,1);else{f["cke:reset"]&&(j=e=h=null);d=Number(f["cke:indent"]);d!=e&&(m=g=null);if(i){if(m&&x[m][g].test(i[1]))l=m,k=g;else for(var q in x)for(var u in x[q])if(x[q][u].test(i[1]))if("ol"==q&&/alpha|roman/.test(u)){if(g=/roman/.test(u)?y(i[1]):A(i[1]),!p||g<p)p=g,l=q,k=u}else{l=q;k=u;break}!l&&(l=i[2]?"ol":"ul")}else l=f["cke:listtype"]||"ol",k=f["cke:list-style-type"];m=l;g=k||("ol"==l?"decimal":"disc");k&&k!=("ol"==l?
+"decimal":"disc")&&b.addStyle("list-style-type",k);if("ol"==l&&i){switch(k){case "decimal":p=Number(i[1]);break;case "lower-roman":case "upper-roman":p=y(i[1]);break;case "lower-alpha":case "upper-alpha":p=A(i[1])}b.attributes.value=p}if(j){if(d>e)a.push(j=new CKEDITOR.htmlParser.element(l)),j.add(b),h.add(j);else{if(d<e){e-=d;for(var r;e--&&(r=j.parent);)j=r.parent}j.add(b)}c.splice(n--,1)}else a.push(j=new CKEDITOR.htmlParser.element(l)),j.add(b),c[n]=j;h=b;e=d}else j&&(j=e=h=null);for(n=0;n<a.length;n++)if(j=
+a[n],q=j.children,g=g=void 0,u=j.children.length,r=g=void 0,c=/list-style-type:(.*?)(?:;|$)/,e=CKEDITOR.plugins.pastefromword.filters.stylesFilter,g=j.attributes,!c.exec(g.style)){for(h=0;h<u;h++)if(g=q[h],g.attributes.value&&Number(g.attributes.value)==h+1&&delete g.attributes.value,g=c.exec(g.attributes.style))if(g[1]==r||!r)r=g[1];else{r=null;break}if(r){for(h=0;h<u;h++)g=q[h].attributes,g.style&&(g.style=e([["list-style-type"]])(g.style)||"");j.addStyle("list-style-type",r)}}w=t=s=null},falsyFilter:function(){return!1},
+stylesFilter:function(a,c){return function(b,f){var d=[];(b||"").replace(/&quot;/g,'"').replace(/\s*([^ :;]+)\s*:\s*([^;]+)\s*(?=;|$)/g,function(b,e,g){e=e.toLowerCase();"font-family"==e&&(g=g.replace(/["']/g,""));for(var m,i,l,k=0;k<a.length;k++)if(a[k]&&(b=a[k][0],m=a[k][1],i=a[k][2],l=a[k][3],e.match(b)&&(!m||g.match(m)))){e=l||e;c&&(i=i||g);"function"==typeof i&&(i=i(g,f,e));i&&i.push&&(e=i[0],i=i[1]);"string"==typeof i&&d.push([e,i]);return}!c&&d.push([e,g])});for(var e=0;e<d.length;e++)d[e]=
+d[e].join(":");return d.length?d.join(";")+";":!1}},elementMigrateFilter:function(a,c){return a?function(b){var f=c?(new CKEDITOR.style(a,c))._.definition:a;b.name=f.element;CKEDITOR.tools.extend(b.attributes,CKEDITOR.tools.clone(f.attributes));b.addStyle(CKEDITOR.style.getStyleText(f))}:function(){}},styleMigrateFilter:function(a,c){var b=this.elementMigrateFilter;return a?function(f,d){var e=new CKEDITOR.htmlParser.element(null),h={};h[c]=f;b(a,h)(e);e.children=d.children;d.children=[e]}:function(){}},
+bogusAttrFilter:function(a,c){if(-1==c.name.indexOf("cke:"))return!1},applyStyleFilter:null},getRules:function(a,c){var b=CKEDITOR.dtd,f=CKEDITOR.tools.extend({},b.$block,b.$listItem,b.$tableContent),d=a.config,e=this.filters,h=e.falsyFilter,j=e.stylesFilter,g=e.elementMigrateFilter,m=CKEDITOR.tools.bind(this.filters.styleMigrateFilter,this.filters),i=this.utils.createListBulletMarker,l=e.flattenList,k=e.assembleList,p=this.utils.isListBulletIndicator,n=this.utils.isContainingOnlySpaces,q=this.utils.resolveList,
+u=function(a){a=CKEDITOR.tools.convertToPx(a);return isNaN(a)?a:a+"px"},r=this.utils.getStyleComponents,t=this.utils.listDtdParents,o=!1!==d.pasteFromWordRemoveFontStyles,s=!1!==d.pasteFromWordRemoveStyles;return{elementNames:[[/meta|link|script/,""]],root:function(a){a.filterChildren(c);k(a)},elements:{"^":function(a){var c;CKEDITOR.env.gecko&&(c=e.applyStyleFilter)&&c(a)},$:function(a){var v=a.name||"",e=a.attributes;v in f&&e.style&&(e.style=j([[/^(:?width|height)$/,null,u]])(e.style)||"");if(v.match(/h\d/)){a.filterChildren(c);
+if(q(a))return;g(d["format_"+v])(a)}else if(v in b.$inline)a.filterChildren(c),n(a)&&delete a.name;else if(-1!=v.indexOf(":")&&-1==v.indexOf("cke")){a.filterChildren(c);if("v:imagedata"==v){if(v=a.attributes["o:href"])a.attributes.src=v;a.name="img";return}delete a.name}v in t&&(a.filterChildren(c),k(a))},style:function(a){if(CKEDITOR.env.gecko){var a=(a=a.onlyChild().value.match(/\/\* Style Definitions \*\/([\s\S]*?)\/\*/))&&a[1],c={};a&&(a.replace(/[\n\r]/g,"").replace(/(.+?)\{(.+?)\}/g,function(a,
+b,F){for(var b=b.split(","),a=b.length,d=0;d<a;d++)CKEDITOR.tools.trim(b[d]).replace(/^(\w+)(\.[\w-]+)?$/g,function(a,b,d){b=b||"*";d=d.substring(1,d.length);d.match(/MsoNormal/)||(c[b]||(c[b]={}),d?c[b][d]=F:c[b]=F)})}),e.applyStyleFilter=function(a){var b=c["*"]?"*":a.name,d=a.attributes&&a.attributes["class"];b in c&&(b=c[b],"object"==typeof b&&(b=b[d]),b&&a.addStyle(b,!0))})}return!1},p:function(a){if(/MsoListParagraph/i.exec(a.attributes["class"])||a.getStyle("mso-list")){var b=a.firstChild(function(a){return a.type==
+CKEDITOR.NODE_TEXT&&!n(a.parent)});(b=b&&b.parent)&&b.addStyle("mso-list","Ignore")}a.filterChildren(c);q(a)||(d.enterMode==CKEDITOR.ENTER_BR?(delete a.name,a.add(new CKEDITOR.htmlParser.element("br"))):g(d["format_"+(d.enterMode==CKEDITOR.ENTER_P?"p":"div")])(a))},div:function(a){var c=a.onlyChild();if(c&&"table"==c.name){var b=a.attributes;c.attributes=CKEDITOR.tools.extend(c.attributes,b);b.style&&c.addStyle(b.style);c=new CKEDITOR.htmlParser.element("div");c.addStyle("clear","both");a.add(c);
+delete a.name}},td:function(a){a.getAncestor("thead")&&(a.name="th")},ol:l,ul:l,dl:l,font:function(a){if(p(a.parent))delete a.name;else{a.filterChildren(c);var b=a.attributes,d=b.style,e=a.parent;"font"==e.name?(CKEDITOR.tools.extend(e.attributes,a.attributes),d&&e.addStyle(d),delete a.name):(d=d||"",b.color&&("#000000"!=b.color&&(d+="color:"+b.color+";"),delete b.color),b.face&&(d+="font-family:"+b.face+";",delete b.face),b.size&&(d+="font-size:"+(3<b.size?"large":3>b.size?"small":"medium")+";",
+delete b.size),a.name="span",a.addStyle(d))}},span:function(a){if(p(a.parent))return!1;a.filterChildren(c);if(n(a))return delete a.name,null;if(p(a)){var b=a.firstChild(function(a){return a.value||"img"==a.name}),e=(b=b&&(b.value||"l."))&&b.match(/^(?:[(]?)([^\s]+?)([.)]?)$/);if(e)return b=i(e,b),(a=a.getAncestor("span"))&&/ mso-hide:\s*all|display:\s*none /.test(a.attributes.style)&&(b.attributes["cke:ignored"]=1),b}if(e=(b=a.attributes)&&b.style)b.style=j([["line-height"],[/^font-family$/,null,
+!o?m(d.font_style,"family"):null],[/^font-size$/,null,!o?m(d.fontSize_style,"size"):null],[/^color$/,null,!o?m(d.colorButton_foreStyle,"color"):null],[/^background-color$/,null,!o?m(d.colorButton_backStyle,"color"):null]])(e,a)||"";b.style||delete b.style;CKEDITOR.tools.isEmpty(b)&&delete a.name;return null},b:g(d.coreStyles_bold),i:g(d.coreStyles_italic),u:g(d.coreStyles_underline),s:g(d.coreStyles_strike),sup:g(d.coreStyles_superscript),sub:g(d.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/)&&!d.pasteFromWordNumberedHeadingToList&&delete a.name}},attributeNames:[[/^onmouse(:?out|over)/,""],[/^onload$/,""],[/(?:v|o):\w+/,""],[/^lang/,""]],attributes:{style:j(s?[[/^list-style-type$/,null],[/^margin$|^margin-(?!bottom|top)/,null,function(a,b,c){if(b.name in{p:1,div:1}){b="ltr"==d.contentsLangDirection?
+"margin-left":"margin-right";if("margin"==c)a=r(c,a,[b])[b];else if(c!=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],s),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":h,bgcolor:h,valign:s?h:function(a,b){b.addStyle("vertical-align",a);return!1}},comment:!CKEDITOR.env.ie?function(a,b){var c=a.match(/<img.*?>/),d=a.match(/^\[if !supportLists\]([\s\S]*?)\[endif\]$/);return d?(d=(c=d[1]||c&&"l.")&&c.match(/>(?:[(]?)([^\s]+?)([.)]?)</),i(d,c)):CKEDITOR.env.gecko&&c?
+(c=CKEDITOR.htmlParser.fragment.fromHtml(c[0]).children[0],(d=(d=(d=b.previous)&&d.value.match(/<v:imagedata[^>]*o:href=['"](.*?)['"]/))&&d[1])&&(c.attributes.src=d),c):!1}:h}}},G=function(){this.dataFilter=new CKEDITOR.htmlParser.filter};G.prototype={toHtml:function(a){var a=CKEDITOR.htmlParser.fragment.fromHtml(a),c=new CKEDITOR.htmlParser.basicWriter;a.writeHtml(c,this.dataFilter);return c.getHtml(!0)}};CKEDITOR.cleanWord=function(a,c){CKEDITOR.env.gecko&&(a=a.replace(/(<\!--\[if[^<]*?\])--\>([\S\s]*?)<\!--(\[endif\]--\>)/gi,
+"$1$2$3"));CKEDITOR.env.webkit&&(a=a.replace(/(class="MsoListParagraph[^>]+><\!--\[if !supportLists\]--\>)([^<]+<span[^<]+<\/span>)(<\!--\[endif\]--\>)/gi,"$1<span>$2</span>$3"));var b=new G,f=b.dataFilter;f.addRules(CKEDITOR.plugins.pastefromword.getRules(c,f));c.fire("beforeCleanWord",{filter:f});try{a=b.toHtml(a)}catch(d){alert(c.lang.pastefromword.error)}a=a.replace(/cke:.*?".*?"/g,"");a=a.replace(/style=""/g,"");return a=a.replace(/<span>/g,"")}})();
\ No newline at end of file