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