JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.4.2
[ckeditor.git] / _source / plugins / pastefromword / filter / default.js
1 /*\r
2 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
3 For licensing, see LICENSE.html or http://ckeditor.com/license\r
4 */\r
5 \r
6 (function()\r
7 {\r
8         var fragmentPrototype = CKEDITOR.htmlParser.fragment.prototype,\r
9                 elementPrototype = CKEDITOR.htmlParser.element.prototype;\r
10 \r
11         fragmentPrototype.onlyChild = elementPrototype.onlyChild = function()\r
12         {\r
13                 var children = this.children,\r
14                         count = children.length,\r
15                         firstChild = ( count == 1 ) && children[ 0 ];\r
16                 return firstChild || null;\r
17         };\r
18 \r
19         elementPrototype.removeAnyChildWithName = function( tagName )\r
20         {\r
21                 var children = this.children,\r
22                         childs = [],\r
23                         child;\r
24 \r
25                 for ( var i = 0; i < children.length; i++ )\r
26                 {\r
27                         child = children[ i ];\r
28                         if ( !child.name )\r
29                                 continue;\r
30 \r
31                         if ( child.name == tagName )\r
32                         {\r
33                                 childs.push( child );\r
34                                 children.splice( i--, 1 );\r
35                         }\r
36                         childs = childs.concat( child.removeAnyChildWithName( tagName ) );\r
37                 }\r
38                 return childs;\r
39         };\r
40 \r
41         elementPrototype.getAncestor = function( tagNameRegex )\r
42         {\r
43                 var parent = this.parent;\r
44                 while ( parent && !( parent.name && parent.name.match( tagNameRegex ) ) )\r
45                         parent = parent.parent;\r
46                 return parent;\r
47         };\r
48 \r
49         fragmentPrototype.firstChild = elementPrototype.firstChild = function( evaluator )\r
50         {\r
51                 var child;\r
52 \r
53                 for ( var i = 0 ; i < this.children.length ; i++ )\r
54                 {\r
55                         child = this.children[ i ];\r
56                         if ( evaluator( child ) )\r
57                                 return child;\r
58                         else if ( child.name )\r
59                         {\r
60                                 child = child.firstChild( evaluator );\r
61                                 if ( child )\r
62                                         return child;\r
63                         }\r
64                 }\r
65 \r
66                 return null;\r
67         };\r
68 \r
69         // Adding a (set) of styles to the element's 'style' attributes.\r
70         elementPrototype.addStyle = function( name, value, isPrepend )\r
71         {\r
72                 var styleText, addingStyleText = '';\r
73                 // name/value pair.\r
74                 if ( typeof value == 'string' )\r
75                         addingStyleText += name + ':' + value + ';';\r
76                 else\r
77                 {\r
78                         // style literal.\r
79                         if ( typeof name == 'object' )\r
80                         {\r
81                                 for ( var style in name )\r
82                                 {\r
83                                         if ( name.hasOwnProperty( style ) )\r
84                                                 addingStyleText += style + ':' + name[ style ] + ';';\r
85                                 }\r
86                         }\r
87                         // raw style text form.\r
88                         else\r
89                                 addingStyleText += name;\r
90 \r
91                         isPrepend = value;\r
92                 }\r
93 \r
94                 if ( !this.attributes )\r
95                         this.attributes = {};\r
96 \r
97                 styleText = this.attributes.style || '';\r
98 \r
99                 styleText = ( isPrepend ?\r
100                               [ addingStyleText, styleText ]\r
101                                           : [ styleText, addingStyleText ] ).join( ';' );\r
102 \r
103                 this.attributes.style = styleText.replace( /^;|;(?=;)/, '' );\r
104         };\r
105 \r
106         /**\r
107          * Return the DTD-valid parent tag names of the specified one.\r
108          * @param tagName\r
109          */\r
110         CKEDITOR.dtd.parentOf = function( tagName )\r
111         {\r
112                 var result = {};\r
113                 for ( var tag in this )\r
114                 {\r
115                         if ( tag.indexOf( '$' ) == -1 && this[ tag ][ tagName ] )\r
116                                 result[ tag ] = 1;\r
117                 }\r
118                 return result;\r
119         };\r
120 \r
121         var cssLengthRelativeUnit = /^([.\d]*)+(em|ex|px|gd|rem|vw|vh|vm|ch|mm|cm|in|pt|pc|deg|rad|ms|s|hz|khz){1}?/i;\r
122         var emptyMarginRegex = /^(?:\b0[^\s]*\s*){1,4}$/;               // e.g. 0px 0pt 0px\r
123 \r
124         var listBaseIndent = 0,\r
125                  previousListItemMargin;\r
126 \r
127         CKEDITOR.plugins.pastefromword =\r
128         {\r
129                 utils :\r
130                 {\r
131                         // Create a <cke:listbullet> which indicate an list item type.\r
132                         createListBulletMarker : function ( bulletStyle, bulletText )\r
133                         {\r
134                                 var marker = new CKEDITOR.htmlParser.element( 'cke:listbullet' ),\r
135                                         listType;\r
136 \r
137                                 // TODO: Support more list style type from MS-Word.\r
138                                 if ( !bulletStyle )\r
139                                 {\r
140                                         bulletStyle = 'decimal';\r
141                                         listType = 'ol';\r
142                                 }\r
143                                 else if ( bulletStyle[ 2 ] )\r
144                                 {\r
145                                         if ( !isNaN( bulletStyle[ 1 ] ) )\r
146                                                 bulletStyle = 'decimal';\r
147                                         // No way to distinguish between Roman numerals and Alphas,\r
148                                         // detect them as a whole.\r
149                                         else if ( /^[a-z]+$/.test( bulletStyle[ 1 ] ) )\r
150                                                 bulletStyle = 'lower-alpha';\r
151                                         else if ( /^[A-Z]+$/.test( bulletStyle[ 1 ] ) )\r
152                                                 bulletStyle = 'upper-alpha';\r
153                                         // Simply use decimal for the rest forms of unrepresentable\r
154                                         // numerals, e.g. Chinese...\r
155                                         else\r
156                                                 bulletStyle = 'decimal';\r
157 \r
158                                         listType = 'ol';\r
159                                 }\r
160                                 else\r
161                                 {\r
162                                         if ( /[l\u00B7\u2002]/.test( bulletStyle[ 1 ] ) )\r
163                                                 bulletStyle = 'disc';\r
164                                         else if ( /[\u006F\u00D8]/.test( bulletStyle[ 1 ] ) )\r
165                                                 bulletStyle = 'circle';\r
166                                         else if ( /[\u006E\u25C6]/.test( bulletStyle[ 1 ] ) )\r
167                                                 bulletStyle = 'square';\r
168                                         else\r
169                                                 bulletStyle = 'disc';\r
170 \r
171                                         listType = 'ul';\r
172                                 }\r
173 \r
174                                 // Represent list type as CSS style.\r
175                                 marker.attributes =\r
176                                 {\r
177                                         'cke:listtype' : listType,\r
178                                         'style' : 'list-style-type:' + bulletStyle + ';'\r
179                                 };\r
180                                 marker.add( new CKEDITOR.htmlParser.text( bulletText ) );\r
181                                 return marker;\r
182                         },\r
183 \r
184                         isListBulletIndicator : function( element )\r
185                         {\r
186                                 var styleText = element.attributes && element.attributes.style;\r
187                                 if ( /mso-list\s*:\s*Ignore/i.test( styleText ) )\r
188                                         return true;\r
189                         },\r
190 \r
191                         isContainingOnlySpaces : function( element )\r
192                         {\r
193                                 var text;\r
194                                 return ( ( text = element.onlyChild() )\r
195                                             && ( /^(:?\s|&nbsp;)+$/ ).test( text.value ) );\r
196                         },\r
197 \r
198                         resolveList : function( element )\r
199                         {\r
200                                 // <cke:listbullet> indicate a list item.\r
201                                 var attrs = element.attributes,\r
202                                         listMarker;\r
203 \r
204                                 if ( ( listMarker = element.removeAnyChildWithName( 'cke:listbullet' ) )\r
205                                           && listMarker.length\r
206                                           && ( listMarker = listMarker[ 0 ] ) )\r
207                                 {\r
208                                         element.name = 'cke:li';\r
209 \r
210                                         if ( attrs.style )\r
211                                         {\r
212                                                 attrs.style = CKEDITOR.plugins.pastefromword.filters.stylesFilter(\r
213                                                                 [\r
214                                                                         // Text-indent is not representing list item level any more.\r
215                                                                         [ 'text-indent' ],\r
216                                                                         [ 'line-height' ],\r
217                                                                         // Resolve indent level from 'margin-left' value.\r
218                                                                         [ ( /^margin(:?-left)?$/ ), null, function( margin )\r
219                                                                         {\r
220                                                                                 // Be able to deal with component/short-hand form style.\r
221                                                                                 var values = margin.split( ' ' );\r
222                                                                                 margin = CKEDITOR.plugins.pastefromword.utils.convertToPx( values[ 3 ] || values[ 1 ] || values [ 0 ] );\r
223                                                                                 margin = parseInt( margin, 10 );\r
224 \r
225                                                                                 // Figure out the indent unit by looking at the first increament.\r
226                                                                                 if ( !listBaseIndent && previousListItemMargin && margin > previousListItemMargin )\r
227                                                                                         listBaseIndent = margin - previousListItemMargin;\r
228 \r
229                                                                                 attrs[ 'cke:margin' ] = previousListItemMargin = margin;\r
230                                                                         } ]\r
231                                                         ] )( attrs.style, element ) || '' ;\r
232                                         }\r
233 \r
234                                         // Inherit list-type-style from bullet.\r
235                                         var listBulletAttrs = listMarker.attributes,\r
236                                                 listBulletStyle = listBulletAttrs.style;\r
237 \r
238                                         element.addStyle( listBulletStyle );\r
239                                         CKEDITOR.tools.extend( attrs, listBulletAttrs );\r
240                                         return true;\r
241                                 }\r
242 \r
243                                 return false;\r
244                         },\r
245 \r
246                         // Convert various length units to 'px' in ignorance of DPI.\r
247                         convertToPx : ( function ()\r
248                         {\r
249                                 var calculator = CKEDITOR.dom.element.createFromHtml(\r
250                                                                 '<div style="position:absolute;left:-9999px;' +\r
251                                                                 'top:-9999px;margin:0px;padding:0px;border:0px;"' +\r
252                                                                 '></div>', CKEDITOR.document );\r
253                                 CKEDITOR.document.getBody().append( calculator );\r
254 \r
255                                 return function( cssLength )\r
256                                 {\r
257                                         if ( cssLengthRelativeUnit.test( cssLength ) )\r
258                                         {\r
259                                                 calculator.setStyle( 'width', cssLength );\r
260                                                 return calculator.$.clientWidth + 'px';\r
261                                         }\r
262 \r
263                                         return cssLength;\r
264                                 };\r
265                         } )(),\r
266 \r
267                         // Providing a shorthand style then retrieve one or more style component values.\r
268                         getStyleComponents : ( function()\r
269                         {\r
270                                 var calculator = CKEDITOR.dom.element.createFromHtml(\r
271                                                                 '<div style="position:absolute;left:-9999px;top:-9999px;"></div>',\r
272                                                                 CKEDITOR.document );\r
273                                 CKEDITOR.document.getBody().append( calculator );\r
274 \r
275                                 return function( name, styleValue, fetchList )\r
276                                 {\r
277                                         calculator.setStyle( name, styleValue );\r
278                                         var styles = {},\r
279                                                 count = fetchList.length;\r
280                                         for ( var i = 0; i < count; i++ )\r
281                                                 styles[ fetchList[ i ] ]  = calculator.getStyle( fetchList[ i ] );\r
282 \r
283                                         return styles;\r
284                                 };\r
285                         } )(),\r
286 \r
287                         listDtdParents : CKEDITOR.dtd.parentOf( 'ol' )\r
288                 },\r
289 \r
290                 filters :\r
291                 {\r
292                                 // Transform a normal list into flat list items only presentation.\r
293                                 // E.g. <ul><li>level1<ol><li>level2</li></ol></li> =>\r
294                                 // <cke:li cke:listtype="ul" cke:indent="1">level1</cke:li>\r
295                                 // <cke:li cke:listtype="ol" cke:indent="2">level2</cke:li>\r
296                                 flattenList : function( element )\r
297                                 {\r
298                                         var     attrs = element.attributes,\r
299                                                 parent = element.parent;\r
300 \r
301                                         var listStyleType,\r
302                                                 indentLevel = 1;\r
303 \r
304                                         // Resolve how many level nested.\r
305                                         while ( parent )\r
306                                         {\r
307                                                 parent.attributes && parent.attributes[ 'cke:list'] && indentLevel++;\r
308                                                 parent = parent.parent;\r
309                                         }\r
310 \r
311                                         // All list items are of the same type.\r
312                                         switch ( attrs.type )\r
313                                         {\r
314                                                 case 'a' :\r
315                                                         listStyleType = 'lower-alpha';\r
316                                                         break;\r
317                                                 // TODO: Support more list style type from MS-Word.\r
318                                         }\r
319 \r
320                                         var children = element.children,\r
321                                                 child;\r
322 \r
323                                         for ( var i = 0; i < children.length; i++ )\r
324                                         {\r
325                                                 child = children[ i ];\r
326                                                 var attributes = child.attributes;\r
327 \r
328                                                 if ( child.name in CKEDITOR.dtd.$listItem )\r
329                                                 {\r
330                                                         var listItemChildren = child.children,\r
331                                                                 count = listItemChildren.length,\r
332                                                                 last = listItemChildren[ count - 1 ];\r
333 \r
334                                                         // Move out nested list.\r
335                                                         if ( last.name in CKEDITOR.dtd.$list )\r
336                                                         {\r
337                                                                 children.splice( i + 1, 0, last );\r
338                                                                 last.parent = element;\r
339 \r
340                                                                 // Remove the parent list item if it's just a holder.\r
341                                                                 if ( !--listItemChildren.length )\r
342                                                                         children.splice( i, 1 );\r
343                                                         }\r
344 \r
345                                                         child.name = 'cke:li';\r
346                                                         attributes[ 'cke:indent' ] = indentLevel;\r
347                                                         previousListItemMargin = 0;\r
348                                                         attributes[ 'cke:listtype' ] = element.name;\r
349                                                         listStyleType && child.addStyle( 'list-style-type', listStyleType, true );\r
350                                                 }\r
351                                         }\r
352 \r
353                                         delete element.name;\r
354 \r
355                                         // We're loosing tag name here, signalize this element as a list.\r
356                                         attrs[ 'cke:list' ] = 1;\r
357                                 },\r
358 \r
359                                 /**\r
360                                  *  Try to collect all list items among the children and establish one\r
361                                  *  or more HTML list structures for them.\r
362                                  * @param element\r
363                                  */\r
364                                 assembleList : function( element )\r
365                                 {\r
366                                         var children = element.children, child,\r
367                                                         listItem,   // The current processing cke:li element.\r
368                                                         listItemAttrs,\r
369                                                         listType,   // Determine the root type of the list.\r
370                                                         listItemIndent, // Indent level of current list item.\r
371                                                         lastListItem, // The previous one just been added to the list.\r
372                                                         list, parentList, // Current staging list and it's parent list if any.\r
373                                                         indent;\r
374 \r
375                                         for ( var i = 0; i < children.length; i++ )\r
376                                         {\r
377                                                 child = children[ i ];\r
378 \r
379                                                 if ( 'cke:li' == child.name )\r
380                                                 {\r
381                                                         child.name = 'li';\r
382                                                         listItem = child;\r
383                                                         listItemAttrs = listItem.attributes;\r
384                                                         listType = listItem.attributes[ 'cke:listtype' ];\r
385 \r
386                                                         // List item indent level might come from a real list indentation or\r
387                                                         // been resolved from a pseudo list item's margin value, even get\r
388                                                         // no indentation at all.\r
389                                                         listItemIndent = parseInt( listItemAttrs[ 'cke:indent' ], 10 )\r
390                                                                                                         || listBaseIndent && ( Math.ceil( listItemAttrs[ 'cke:margin' ] / listBaseIndent ) )\r
391                                                                                                         || 1;\r
392 \r
393                                                         // Ignore the 'list-style-type' attribute if it's matched with\r
394                                                         // the list root element's default style type.\r
395                                                         listItemAttrs.style && ( listItemAttrs.style =\r
396                                                                 CKEDITOR.plugins.pastefromword.filters.stylesFilter(\r
397                                                                         [\r
398                                                                                 [ 'list-style-type', listType == 'ol' ? 'decimal' : 'disc' ]\r
399                                                                         ] )( listItemAttrs.style )\r
400                                                                         || '' );\r
401 \r
402                                                         if ( !list )\r
403                                                         {\r
404                                                                 list = new CKEDITOR.htmlParser.element( listType );\r
405                                                                 list.add( listItem );\r
406                                                                 children[ i ] = list;\r
407                                                         }\r
408                                                         else\r
409                                                         {\r
410                                                                 if ( listItemIndent > indent )\r
411                                                                 {\r
412                                                                         list = new CKEDITOR.htmlParser.element( listType );\r
413                                                                         list.add( listItem );\r
414                                                                         lastListItem.add( list );\r
415                                                                 }\r
416                                                                 else if ( listItemIndent < indent )\r
417                                                                 {\r
418                                                                         // There might be a negative gap between two list levels. (#4944)\r
419                                                                         var diff = indent - listItemIndent,\r
420                                                                                 parent;\r
421                                                                         while ( diff-- && ( parent = list.parent ) )\r
422                                                                                 list = parent.parent;\r
423 \r
424                                                                         list.add( listItem );\r
425                                                                 }\r
426                                                                 else\r
427                                                                         list.add( listItem );\r
428 \r
429                                                                 children.splice( i--, 1 );\r
430                                                         }\r
431 \r
432                                                         lastListItem = listItem;\r
433                                                         indent = listItemIndent;\r
434                                                 }\r
435                                                 else\r
436                                                         list = null;\r
437                                         }\r
438 \r
439                                         listBaseIndent = 0;\r
440                                 },\r
441 \r
442                                 /**\r
443                                  * A simple filter which always rejecting.\r
444                                  */\r
445                                 falsyFilter : function( value )\r
446                                 {\r
447                                         return false;\r
448                                 },\r
449 \r
450                                 /**\r
451                                  * A filter dedicated on the 'style' attribute filtering, e.g. dropping/replacing style properties.\r
452                                  * @param styles {Array} in form of [ styleNameRegexp, styleValueRegexp,\r
453                                  *  newStyleValue/newStyleGenerator, newStyleName ] where only the first\r
454                                  *  parameter is mandatory.\r
455                                  * @param whitelist {Boolean} Whether the {@param styles} will be considered as a white-list.\r
456                                  */\r
457                                 stylesFilter : function( styles, whitelist )\r
458                                 {\r
459                                         return function( styleText, element )\r
460                                         {\r
461                                                  var rules = [];\r
462                                                 // html-encoded quote might be introduced by 'font-family'\r
463                                                 // from MS-Word which confused the following regexp. e.g.\r
464                                                 //'font-family: &quot;Lucida, Console&quot;'\r
465                                                  styleText\r
466                                                         .replace( /&quot;/g, '"' )\r
467                                                         .replace( /\s*([^ :;]+)\s*:\s*([^;]+)\s*(?=;|$)/g,\r
468                                                                  function( match, name, value )\r
469                                                                  {\r
470                                                                          name = name.toLowerCase();\r
471                                                                          name == 'font-family' && ( value = value.replace( /["']/g, '' ) );\r
472 \r
473                                                                          var namePattern,\r
474                                                                                  valuePattern,\r
475                                                                                  newValue,\r
476                                                                                  newName;\r
477                                                                          for ( var i = 0 ; i < styles.length; i++ )\r
478                                                                          {\r
479                                                                                 if ( styles[ i ] )\r
480                                                                                 {\r
481                                                                                         namePattern = styles[ i ][ 0 ];\r
482                                                                                         valuePattern = styles[ i ][ 1 ];\r
483                                                                                         newValue = styles[ i ][ 2 ];\r
484                                                                                         newName = styles[ i ][ 3 ];\r
485 \r
486                                                                                         if ( name.match( namePattern )\r
487                                                                                                  && ( !valuePattern || value.match( valuePattern ) ) )\r
488                                                                                         {\r
489                                                                                                 name = newName || name;\r
490                                                                                                 whitelist && ( newValue = newValue || value );\r
491 \r
492                                                                                                 if ( typeof newValue == 'function' )\r
493                                                                                                         newValue = newValue( value, element, name );\r
494 \r
495                                                                                                 // Return an couple indicate both name and value\r
496                                                                                                 // changed.\r
497                                                                                                 if ( newValue && newValue.push )\r
498                                                                                                         name = newValue[ 0 ], newValue = newValue[ 1 ];\r
499 \r
500                                                                                                 if ( typeof newValue == 'string' )\r
501                                                                                                         rules.push( [ name, newValue ] );\r
502                                                                                                 return;\r
503                                                                                         }\r
504                                                                                 }\r
505                                                                          }\r
506 \r
507                                                                          !whitelist && rules.push( [ name, value ] );\r
508 \r
509                                                                  });\r
510 \r
511                                                 for ( var i = 0 ; i < rules.length ; i++ )\r
512                                                          rules[ i ] = rules[ i ].join( ':' );\r
513                                                 return rules.length ?\r
514                                                          ( rules.join( ';' ) + ';' ) : false;\r
515                                          };\r
516                                 },\r
517 \r
518                                 /**\r
519                                  * Migrate the element by decorate styles on it.\r
520                                  * @param styleDefiniton\r
521                                  * @param variables\r
522                                  */\r
523                                 elementMigrateFilter : function ( styleDefiniton, variables )\r
524                                 {\r
525                                         return function( element )\r
526                                                 {\r
527                                                         var styleDef =\r
528                                                                         variables ?\r
529                                                                                 new CKEDITOR.style( styleDefiniton, variables )._.definition\r
530                                                                                 : styleDefiniton;\r
531                                                         element.name = styleDef.element;\r
532                                                         CKEDITOR.tools.extend( element.attributes, CKEDITOR.tools.clone( styleDef.attributes ) );\r
533                                                         element.addStyle( CKEDITOR.style.getStyleText( styleDef ) );\r
534                                                 };\r
535                                 },\r
536 \r
537                                 /**\r
538                                  * Migrate styles by creating a new nested stylish element.\r
539                                  * @param styleDefinition\r
540                                  */\r
541                                 styleMigrateFilter : function( styleDefinition, variableName )\r
542                                 {\r
543 \r
544                                         var elementMigrateFilter = this.elementMigrateFilter;\r
545                                         return function( value, element )\r
546                                         {\r
547                                                 // Build an stylish element first.\r
548                                                 var styleElement = new CKEDITOR.htmlParser.element( null ),\r
549                                                         variables = {};\r
550 \r
551                                                 variables[ variableName ] = value;\r
552                                                 elementMigrateFilter( styleDefinition, variables )( styleElement );\r
553                                                 // Place the new element inside the existing span.\r
554                                                 styleElement.children = element.children;\r
555                                                 element.children = [ styleElement ];\r
556                                         };\r
557                                 },\r
558 \r
559                                 /**\r
560                                  * A filter which remove cke-namespaced-attribute on\r
561                                  * all none-cke-namespaced elements.\r
562                                  * @param value\r
563                                  * @param element\r
564                                  */\r
565                                 bogusAttrFilter : function( value, element )\r
566                                 {\r
567                                         if ( element.name.indexOf( 'cke:' ) == -1 )\r
568                                                 return false;\r
569                                 },\r
570 \r
571                                 /**\r
572                                  * A filter which will be used to apply inline css style according the stylesheet\r
573                                  * definition rules, is generated lazily when filtering.\r
574                                  */\r
575                                 applyStyleFilter : null\r
576 \r
577                         },\r
578 \r
579                 getRules : function( editor )\r
580                 {\r
581                         var dtd = CKEDITOR.dtd,\r
582                                 blockLike = CKEDITOR.tools.extend( {}, dtd.$block, dtd.$listItem, dtd.$tableContent ),\r
583                                 config = editor.config,\r
584                                 filters = this.filters,\r
585                                 falsyFilter = filters.falsyFilter,\r
586                                 stylesFilter = filters.stylesFilter,\r
587                                 elementMigrateFilter = filters.elementMigrateFilter,\r
588                                 styleMigrateFilter = CKEDITOR.tools.bind( this.filters.styleMigrateFilter, this.filters ),\r
589                                 createListBulletMarker = this.utils.createListBulletMarker,\r
590                                 flattenList = filters.flattenList,\r
591                                 assembleList = filters.assembleList,\r
592                                 isListBulletIndicator = this.utils.isListBulletIndicator,\r
593                                 containsNothingButSpaces = this.utils.isContainingOnlySpaces,\r
594                                 resolveListItem = this.utils.resolveList,\r
595                                 convertToPx = this.utils.convertToPx,\r
596                                 getStyleComponents = this.utils.getStyleComponents,\r
597                                 listDtdParents = this.utils.listDtdParents,\r
598                                 removeFontStyles = config.pasteFromWordRemoveFontStyles !== false,\r
599                                 removeStyles = config.pasteFromWordRemoveStyles !== false;\r
600 \r
601                         return {\r
602 \r
603                                 elementNames :\r
604                                 [\r
605                                         // Remove script, meta and link elements.\r
606                                         [ ( /meta|link|script/ ), '' ]\r
607                                 ],\r
608 \r
609                                 root : function( element )\r
610                                 {\r
611                                         element.filterChildren();\r
612                                         assembleList( element );\r
613                                 },\r
614 \r
615                                 elements :\r
616                                 {\r
617                                         '^' : function( element )\r
618                                         {\r
619                                                 // Transform CSS style declaration to inline style.\r
620                                                 var applyStyleFilter;\r
621                                                 if ( CKEDITOR.env.gecko && ( applyStyleFilter = filters.applyStyleFilter ) )\r
622                                                         applyStyleFilter( element );\r
623                                         },\r
624 \r
625                                         $ : function( element )\r
626                                         {\r
627                                                 var tagName = element.name || '',\r
628                                                         attrs = element.attributes;\r
629 \r
630                                                 // Convert length unit of width/height on blocks to\r
631                                                 // a more editor-friendly way (px).\r
632                                                 if ( tagName in blockLike\r
633                                                         && attrs.style )\r
634                                                 {\r
635                                                         attrs.style = stylesFilter(\r
636                                                                                 [ [ ( /^(:?width|height)$/ ), null, convertToPx ] ] )( attrs.style ) || '';\r
637                                                 }\r
638 \r
639                                                 // Processing headings.\r
640                                                 if ( tagName.match( /h\d/ ) )\r
641                                                 {\r
642                                                         element.filterChildren();\r
643                                                         // Is the heading actually a list item?\r
644                                                         if ( resolveListItem( element ) )\r
645                                                                 return;\r
646 \r
647                                                         // Adapt heading styles to editor's convention.\r
648                                                         elementMigrateFilter( config[ 'format_' + tagName ] )( element );\r
649                                                 }\r
650                                                 // Remove inline elements which contain only empty spaces.\r
651                                                 else if ( tagName in dtd.$inline )\r
652                                                 {\r
653                                                         element.filterChildren();\r
654                                                         if ( containsNothingButSpaces( element ) )\r
655                                                                 delete element.name;\r
656                                                 }\r
657                                                 // Remove element with ms-office namespace,\r
658                                                 // with it's content preserved, e.g. 'o:p'.\r
659                                                 else if ( tagName.indexOf( ':' ) != -1\r
660                                                                  && tagName.indexOf( 'cke' ) == -1 )\r
661                                                 {\r
662                                                         element.filterChildren();\r
663 \r
664                                                         // Restore image real link from vml.\r
665                                                         if ( tagName == 'v:imagedata' )\r
666                                                         {\r
667                                                                 var href = element.attributes[ 'o:href' ];\r
668                                                                 if ( href )\r
669                                                                         element.attributes.src = href;\r
670                                                                 element.name = 'img';\r
671                                                                 return;\r
672                                                         }\r
673                                                         delete element.name;\r
674                                                 }\r
675 \r
676                                                 // Assembling list items into a whole list.\r
677                                                 if ( tagName in listDtdParents )\r
678                                                 {\r
679                                                         element.filterChildren();\r
680                                                         assembleList( element );\r
681                                                 }\r
682                                         },\r
683 \r
684                                         // We'll drop any style sheet, but Firefox conclude\r
685                                         // certain styles in a single style element, which are\r
686                                         // required to be changed into inline ones.\r
687                                         'style' : function( element )\r
688                                         {\r
689                                                 if ( CKEDITOR.env.gecko )\r
690                                                 {\r
691                                                         // Grab only the style definition section.\r
692                                                         var styleDefSection = element.onlyChild().value.match( /\/\* Style Definitions \*\/([\s\S]*?)\/\*/ ),\r
693                                                                 styleDefText = styleDefSection && styleDefSection[ 1 ],\r
694                                                                 rules = {}; // Storing the parsed result.\r
695 \r
696                                                         if ( styleDefText )\r
697                                                         {\r
698                                                                 styleDefText\r
699                                                                         // Remove line-breaks.\r
700                                                                         .replace(/[\n\r]/g,'')\r
701                                                                         // Extract selectors and style properties.\r
702                                                                         .replace( /(.+?)\{(.+?)\}/g,\r
703                                                                                 function( rule, selectors, styleBlock )\r
704                                                                                 {\r
705                                                                                         selectors = selectors.split( ',' );\r
706                                                                                         var length = selectors.length, selector;\r
707                                                                                         for ( var i = 0; i < length; i++ )\r
708                                                                                         {\r
709                                                                                                 // Assume MS-Word mostly generate only simple\r
710                                                                                                 // selector( [Type selector][Class selector]).\r
711                                                                                                 CKEDITOR.tools.trim( selectors[ i ] )\r
712                                                                                                                           .replace( /^(\w+)(\.[\w-]+)?$/g,\r
713                                                                                                 function( match, tagName, className )\r
714                                                                                                 {\r
715                                                                                                         tagName = tagName || '*';\r
716                                                                                                         className = className.substring( 1, className.length );\r
717 \r
718                                                                                                         // Reject MS-Word Normal styles.\r
719                                                                                                         if ( className.match( /MsoNormal/ ) )\r
720                                                                                                                 return;\r
721 \r
722                                                                                                         if ( !rules[ tagName ] )\r
723                                                                                                                 rules[ tagName ] = {};\r
724                                                                                                         if ( className )\r
725                                                                                                                 rules[ tagName ][ className ] = styleBlock;\r
726                                                                                                         else\r
727                                                                                                                 rules[ tagName ] = styleBlock;\r
728                                                                                                 } );\r
729                                                                                         }\r
730                                                                                 });\r
731 \r
732                                                                 filters.applyStyleFilter = function( element )\r
733                                                                 {\r
734                                                                         var name = rules[ '*' ] ? '*' : element.name,\r
735                                                                                 className = element.attributes && element.attributes[ 'class' ],\r
736                                                                                 style;\r
737                                                                         if ( name in rules )\r
738                                                                         {\r
739                                                                                 style = rules[ name ];\r
740                                                                                 if ( typeof style == 'object' )\r
741                                                                                         style = style[ className ];\r
742                                                                                 // Maintain style rules priorities.\r
743                                                                                 style && element.addStyle( style, true );\r
744                                                                         }\r
745                                                                 };\r
746                                                         }\r
747                                                 }\r
748                                                 return false;\r
749                                         },\r
750 \r
751                                         'p' : function( element )\r
752                                         {\r
753                                                 element.filterChildren();\r
754 \r
755                                                 // Is the paragraph actually a list item?\r
756                                                 if ( resolveListItem( element ) )\r
757                                                         return;\r
758 \r
759                                                 // Adapt paragraph formatting to editor's convention\r
760                                                 // according to enter-mode.\r
761                                                 if ( config.enterMode == CKEDITOR.ENTER_BR )\r
762                                                 {\r
763                                                         // We suffer from attribute/style lost in this situation.\r
764                                                         delete element.name;\r
765                                                         element.add( new CKEDITOR.htmlParser.element( 'br' ) );\r
766                                                 }\r
767                                                 else\r
768                                                         elementMigrateFilter( config[ 'format_' + ( config.enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' ) ] )( element );\r
769                                         },\r
770 \r
771                                         'div' : function( element )\r
772                                         {\r
773                                                 // Aligned table with no text surrounded is represented by a wrapper div, from which\r
774                                                 // table cells inherit as text-align styles, which is wrong.\r
775                                                 // Instead we use a clear-float div after the table to properly achieve the same layout.\r
776                                                 var singleChild = element.onlyChild();\r
777                                                 if ( singleChild && singleChild.name == 'table' )\r
778                                                 {\r
779                                                         var attrs = element.attributes;\r
780                                                         singleChild.attributes = CKEDITOR.tools.extend( singleChild.attributes, attrs );\r
781                                                         attrs.style && singleChild.addStyle( attrs.style );\r
782 \r
783                                                         var clearFloatDiv = new CKEDITOR.htmlParser.element( 'div' );\r
784                                                         clearFloatDiv.addStyle( 'clear' ,'both' );\r
785                                                         element.add( clearFloatDiv );\r
786                                                         delete element.name;\r
787                                                 }\r
788                                         },\r
789 \r
790                                         'td' : function ( element )\r
791                                         {\r
792                                                 // 'td' in 'thead' is actually <th>.\r
793                                                 if ( element.getAncestor( 'thead') )\r
794                                                         element.name = 'th';\r
795                                         },\r
796 \r
797                                         // MS-Word sometimes present list as a mixing of normal list\r
798                                         // and pseudo-list, normalize the previous ones into pseudo form.\r
799                                         'ol' : flattenList,\r
800                                         'ul' : flattenList,\r
801                                         'dl' : flattenList,\r
802 \r
803                                         'font' : function( element )\r
804                                         {\r
805                                                 // IE/Safari: drop the font tag if it comes from list bullet text.\r
806                                                 if ( !CKEDITOR.env.gecko && isListBulletIndicator( element.parent ) )\r
807                                                 {\r
808                                                         delete element.name;\r
809                                                         return;\r
810                                                 }\r
811 \r
812                                                 element.filterChildren();\r
813 \r
814                                                 var attrs = element.attributes,\r
815                                                         styleText = attrs.style,\r
816                                                         parent = element.parent;\r
817 \r
818                                                 if ( 'font' == parent.name )     // Merge nested <font> tags.\r
819                                                 {\r
820                                                         CKEDITOR.tools.extend( parent.attributes,\r
821                                                                         element.attributes );\r
822                                                         styleText && parent.addStyle( styleText );\r
823                                                         delete element.name;\r
824                                                 }\r
825                                                 // Convert the merged into a span with all attributes preserved.\r
826                                                 else\r
827                                                 {\r
828                                                         styleText = styleText || '';\r
829                                                         // IE's having those deprecated attributes, normalize them.\r
830                                                         if ( attrs.color )\r
831                                                         {\r
832                                                                 attrs.color != '#000000' && ( styleText += 'color:' + attrs.color + ';' );\r
833                                                                 delete attrs.color;\r
834                                                         }\r
835                                                         if ( attrs.face )\r
836                                                         {\r
837                                                                 styleText += 'font-family:' + attrs.face + ';';\r
838                                                                 delete attrs.face;\r
839                                                         }\r
840                                                         // TODO: Mapping size in ranges of xx-small,\r
841                                                         // x-small, small, medium, large, x-large, xx-large.\r
842                                                         if ( attrs.size )\r
843                                                         {\r
844                                                                 styleText += 'font-size:' +\r
845                                                                              ( attrs.size > 3 ? 'large'\r
846                                                                                              : ( attrs.size < 3 ? 'small' : 'medium' ) ) + ';';\r
847                                                                 delete attrs.size;\r
848                                                         }\r
849 \r
850                                                         element.name = 'span';\r
851                                                         element.addStyle( styleText );\r
852                                                 }\r
853                                         },\r
854 \r
855                                         'span' : function( element )\r
856                                         {\r
857                                                 // IE/Safari: remove the span if it comes from list bullet text.\r
858                                                 if ( !CKEDITOR.env.gecko && isListBulletIndicator( element.parent ) )\r
859                                                         return false;\r
860 \r
861                                                 element.filterChildren();\r
862                                                 if ( containsNothingButSpaces( element ) )\r
863                                                 {\r
864                                                         delete element.name;\r
865                                                         return null;\r
866                                                 }\r
867 \r
868                                                 // For IE/Safari: List item bullet type is supposed to be indicated by\r
869                                                 // the text of a span with style 'mso-list : Ignore' or an image.\r
870                                                 if ( !CKEDITOR.env.gecko && isListBulletIndicator( element ) )\r
871                                                 {\r
872                                                         var listSymbolNode = element.firstChild( function( node )\r
873                                                         {\r
874                                                                 return node.value || node.name == 'img';\r
875                                                         });\r
876 \r
877                                                         var listSymbol =  listSymbolNode && ( listSymbolNode.value || 'l.' ),\r
878                                                                 listType = listSymbol.match( /^([^\s]+?)([.)]?)$/ );\r
879                                                         return createListBulletMarker( listType, listSymbol );\r
880                                                 }\r
881 \r
882                                                 // Update the src attribute of image element with href.\r
883                                                 var children = element.children,\r
884                                                         attrs = element.attributes,\r
885                                                         styleText = attrs && attrs.style,\r
886                                                         firstChild = children && children[ 0 ];\r
887 \r
888                                                 // Assume MS-Word mostly carry font related styles on <span>,\r
889                                                 // adapting them to editor's convention.\r
890                                                 if ( styleText )\r
891                                                 {\r
892                                                         attrs.style = stylesFilter(\r
893                                                                         [\r
894                                                                                 // Drop 'inline-height' style which make lines overlapping.\r
895                                                                                 [ 'line-height' ],\r
896                                                                                 [ ( /^font-family$/ ), null, !removeFontStyles ? styleMigrateFilter( config[ 'font_style' ], 'family' ) : null ] ,\r
897                                                                                 [ ( /^font-size$/ ), null, !removeFontStyles ? styleMigrateFilter( config[ 'fontSize_style' ], 'size' ) : null ] ,\r
898                                                                                 [ ( /^color$/ ), null, !removeFontStyles ? styleMigrateFilter( config[ 'colorButton_foreStyle' ], 'color' ) : null ] ,\r
899                                                                                 [ ( /^background-color$/ ), null, !removeFontStyles ? styleMigrateFilter( config[ 'colorButton_backStyle' ], 'color' ) : null ]\r
900                                                                         ] )( styleText, element ) || '';\r
901                                                 }\r
902 \r
903                                                 return null;\r
904                                         },\r
905 \r
906                                         // Migrate basic style formats to editor configured ones.\r
907                                         'b' : elementMigrateFilter( config[ 'coreStyles_bold' ] ),\r
908                                         'i' : elementMigrateFilter( config[ 'coreStyles_italic' ] ),\r
909                                         'u' : elementMigrateFilter( config[ 'coreStyles_underline' ] ),\r
910                                         's' : elementMigrateFilter( config[ 'coreStyles_strike' ] ),\r
911                                         'sup' : elementMigrateFilter( config[ 'coreStyles_superscript' ] ),\r
912                                         'sub' : elementMigrateFilter( config[ 'coreStyles_subscript' ] ),\r
913                                         // Editor doesn't support anchor with content currently (#3582),\r
914                                         // drop such anchors with content preserved.\r
915                                         'a' : function( element )\r
916                                         {\r
917                                                 var attrs = element.attributes;\r
918                                                 if ( attrs && !attrs.href && attrs.name )\r
919                                                         delete element.name;\r
920                                         },\r
921                                         'cke:listbullet' : function( element )\r
922                                         {\r
923                                                 if ( element.getAncestor( /h\d/ ) && !config.pasteFromWordNumberedHeadingToList )\r
924                                                         delete element.name;\r
925                                                 }\r
926                                 },\r
927 \r
928                                 attributeNames :\r
929                                 [\r
930                                         // Remove onmouseover and onmouseout events (from MS Word comments effect)\r
931                                         [ ( /^onmouse(:?out|over)/ ), '' ],\r
932                                         // Onload on image element.\r
933                                         [ ( /^onload$/ ), '' ],\r
934                                         // Remove office and vml attribute from elements.\r
935                                         [ ( /(?:v|o):\w+/ ), '' ],\r
936                                         // Remove lang/language attributes.\r
937                                         [ ( /^lang/ ), '' ]\r
938                                 ],\r
939 \r
940                                 attributes :\r
941                                 {\r
942                                         'style' : stylesFilter(\r
943                                         removeStyles ?\r
944                                         // Provide a white-list of styles that we preserve, those should\r
945                                         // be the ones that could later be altered with editor tools.\r
946                                         [\r
947                                                 // Preserve margin-left/right which used as default indent style in the editor.\r
948                                                 [ ( /^margin$|^margin-(?!bottom|top)/ ), null, function( value, element, name )\r
949                                                         {\r
950                                                                 if ( element.name in { p : 1, div : 1 } )\r
951                                                                 {\r
952                                                                         var indentStyleName = config.contentsLangDirection == 'ltr' ?\r
953                                                                                         'margin-left' : 'margin-right';\r
954 \r
955                                                                         // Extract component value from 'margin' shorthand.\r
956                                                                         if ( name == 'margin' )\r
957                                                                         {\r
958                                                                                 value = getStyleComponents( name, value,\r
959                                                                                                 [ indentStyleName ] )[ indentStyleName ];\r
960                                                                         }\r
961                                                                         else if ( name != indentStyleName )\r
962                                                                                 return null;\r
963 \r
964                                                                         if ( value && !emptyMarginRegex.test( value ) )\r
965                                                                                 return [ indentStyleName, value ];\r
966                                                                 }\r
967 \r
968                                                                 return null;\r
969                                                         } ],\r
970 \r
971                                                 // Preserve clear float style.\r
972                                                 [ ( /^clear$/ ) ],\r
973 \r
974                                                 [ ( /^border.*|margin.*|vertical-align|float$/ ), null,\r
975                                                         function( value, element )\r
976                                                         {\r
977                                                                 if ( element.name == 'img' )\r
978                                                                         return value;\r
979                                                         } ],\r
980 \r
981                                                 [ (/^width|height$/ ), null,\r
982                                                         function( value, element )\r
983                                                         {\r
984                                                                 if ( element.name in { table : 1, td : 1, th : 1, img : 1 } )\r
985                                                                         return value;\r
986                                                         } ]\r
987                                         ] :\r
988                                         // Otherwise provide a black-list of styles that we remove.\r
989                                         [\r
990                                                 [ ( /^mso-/ ) ],\r
991                                                 // Fixing color values.\r
992                                                 [ ( /-color$/ ), null, function( value )\r
993                                                 {\r
994                                                         if ( value == 'transparent' )\r
995                                                                 return false;\r
996                                                         if ( CKEDITOR.env.gecko )\r
997                                                                 return value.replace( /-moz-use-text-color/g, 'transparent' );\r
998                                                 } ],\r
999                                                 // Remove empty margin values, e.g. 0.00001pt 0em 0pt\r
1000                                                 [ ( /^margin$/ ), emptyMarginRegex ],\r
1001                                                 [ 'text-indent', '0cm' ],\r
1002                                                 [ 'page-break-before' ],\r
1003                                                 [ 'tab-stops' ],\r
1004                                                 [ 'display', 'none' ],\r
1005                                                 removeFontStyles ? [ ( /font-?/ ) ] : null\r
1006                                         ], removeStyles ),\r
1007 \r
1008                                         // Prefer width styles over 'width' attributes.\r
1009                                         'width' : function( value, element )\r
1010                                         {\r
1011                                                 if ( element.name in dtd.$tableContent )\r
1012                                                         return false;\r
1013                                         },\r
1014                                         // Prefer border styles over table 'border' attributes.\r
1015                                         'border' : function( value, element )\r
1016                                         {\r
1017                                                 if ( element.name in dtd.$tableContent )\r
1018                                                         return false;\r
1019                                         },\r
1020 \r
1021                                         // Only Firefox carry style sheet from MS-Word, which\r
1022                                         // will be applied by us manually. For other browsers\r
1023                                         // the css className is useless.\r
1024                                         'class' : falsyFilter,\r
1025 \r
1026                                         // MS-Word always generate 'background-color' along with 'bgcolor',\r
1027                                         // simply drop the deprecated attributes.\r
1028                                         'bgcolor' : falsyFilter,\r
1029 \r
1030                                         // Deprecate 'valign' attribute in favor of 'vertical-align'.\r
1031                                         'valign' : removeStyles ? falsyFilter : function( value, element )\r
1032                                         {\r
1033                                                 element.addStyle( 'vertical-align', value );\r
1034                                                 return false;\r
1035                                         }\r
1036                                 },\r
1037 \r
1038                                 // Fore none-IE, some useful data might be buried under these IE-conditional\r
1039                                 // comments where RegExp were the right approach to dig them out where usual approach\r
1040                                 // is transform it into a fake element node which hold the desired data.\r
1041                                 comment :\r
1042                                         !CKEDITOR.env.ie ?\r
1043                                                 function( value, node )\r
1044                                                 {\r
1045                                                         var imageInfo = value.match( /<img.*?>/ ),\r
1046                                                                 listInfo = value.match( /^\[if !supportLists\]([\s\S]*?)\[endif\]$/ );\r
1047 \r
1048                                                         // Seek for list bullet indicator.\r
1049                                                         if ( listInfo )\r
1050                                                         {\r
1051                                                                 // Bullet symbol could be either text or an image.\r
1052                                                                 var listSymbol = listInfo[ 1 ] || ( imageInfo && 'l.' ),\r
1053                                                                         listType = listSymbol && listSymbol.match( />([^\s]+?)([.)]?)</ );\r
1054                                                                 return createListBulletMarker( listType, listSymbol );\r
1055                                                         }\r
1056 \r
1057                                                         // Reveal the <img> element in conditional comments for Firefox.\r
1058                                                         if ( CKEDITOR.env.gecko && imageInfo )\r
1059                                                         {\r
1060                                                                 var img = CKEDITOR.htmlParser.fragment.fromHtml( imageInfo[ 0 ] ).children[ 0 ],\r
1061                                                                         previousComment = node.previous,\r
1062                                                                         // Try to dig the real image link from vml markup from previous comment text.\r
1063                                                                         imgSrcInfo = previousComment && previousComment.value.match( /<v:imagedata[^>]*o:href=['"](.*?)['"]/ ),\r
1064                                                                         imgSrc = imgSrcInfo && imgSrcInfo[ 1 ];\r
1065 \r
1066                                                                 // Is there a real 'src' url to be used?\r
1067                                                                 imgSrc && ( img.attributes.src = imgSrc );\r
1068                                                                 return img;\r
1069                                                         }\r
1070 \r
1071                                                         return false;\r
1072                                                 }\r
1073                                         : falsyFilter\r
1074                         };\r
1075                 }\r
1076         };\r
1077 \r
1078         // The paste processor here is just a reduced copy of html data processor.\r
1079         var pasteProcessor = function()\r
1080         {\r
1081                 this.dataFilter = new CKEDITOR.htmlParser.filter();\r
1082         };\r
1083 \r
1084         pasteProcessor.prototype =\r
1085         {\r
1086                 toHtml : function( data )\r
1087                 {\r
1088                         var fragment = CKEDITOR.htmlParser.fragment.fromHtml( data, false ),\r
1089                                 writer = new CKEDITOR.htmlParser.basicWriter();\r
1090 \r
1091                         fragment.writeHtml( writer, this.dataFilter );\r
1092                         return writer.getHtml( true );\r
1093                 }\r
1094         };\r
1095 \r
1096         CKEDITOR.cleanWord = function( data, editor )\r
1097         {\r
1098                 // Firefox will be confused by those downlevel-revealed IE conditional\r
1099                 // comments, fixing them first( convert it to upperlevel-revealed one ).\r
1100                 // e.g. <![if !vml]>...<![endif]>\r
1101                 if ( CKEDITOR.env.gecko )\r
1102                         data = data.replace( /(<!--\[if[^<]*?\])-->([\S\s]*?)<!--(\[endif\]-->)/gi, '$1$2$3' );\r
1103 \r
1104                 var dataProcessor = new pasteProcessor(),\r
1105                         dataFilter = dataProcessor.dataFilter;\r
1106 \r
1107                 // These rules will have higher priorities than default ones.\r
1108                 dataFilter.addRules( CKEDITOR.plugins.pastefromword.getRules( editor ) );\r
1109 \r
1110                 // Allow extending data filter rules.\r
1111                 editor.fire( 'beforeCleanWord', { filter : dataFilter } );\r
1112 \r
1113                 try\r
1114                 {\r
1115                         data = dataProcessor.toHtml( data, false );\r
1116                 }\r
1117                 catch ( e )\r
1118                 {\r
1119                         alert( editor.lang.pastefromword.error );\r
1120                 }\r
1121 \r
1122                 /* Below post processing those things that are unable to delivered by filter rules. */\r
1123 \r
1124                 // Remove 'cke' namespaced attribute used in filter rules as marker.\r
1125                 data = data.replace( /cke:.*?".*?"/g, '' );\r
1126 \r
1127                 // Remove empty style attribute.\r
1128                 data = data.replace( /style=""/g, '' );\r
1129 \r
1130                 // Remove the dummy spans ( having no inline style ).\r
1131                 data = data.replace( /<span>/g, '' );\r
1132 \r
1133                 return data;\r
1134         };\r
1135 })();\r
1136 \r
1137 /**\r
1138  * Whether to ignore all font related formatting styles, including:\r
1139  * <ul> <li>font size;</li>\r
1140  *              <li>font family;</li>\r
1141  *              <li>font foreground/background color.</li></ul>\r
1142  * @name CKEDITOR.config.pasteFromWordRemoveFontStyles\r
1143  * @since 3.1\r
1144  * @type Boolean\r
1145  * @default true\r
1146  * @example\r
1147  * config.pasteFromWordRemoveFontStyles = false;\r
1148  */\r
1149 \r
1150 /**\r
1151  * Whether to transform MS Word outline numbered headings into lists.\r
1152  * @name CKEDITOR.config.pasteFromWordNumberedHeadingToList\r
1153  * @since 3.1\r
1154  * @type Boolean\r
1155  * @default false\r
1156  * @example\r
1157  * config.pasteFromWordNumberedHeadingToList = true;\r
1158  */\r
1159 \r
1160 /**\r
1161  * Whether to remove element styles that can't be managed with the editor. Note\r
1162  * that this doesn't handle the font specific styles, which depends on the\r
1163  * {@link CKEDITOR.config.pasteFromWordRemoveFontStyles} setting instead.\r
1164  * @name CKEDITOR.config.pasteFromWordRemoveStyles\r
1165  * @since 3.1\r
1166  * @type Boolean\r
1167  * @default true\r
1168  * @example\r
1169  * config.pasteFromWordRemoveStyles = false;\r
1170  */\r