for ( var i = 0; i < children.length; i++ )\r
{\r
child = children[ i ];\r
- if( !child.name )\r
+ if ( !child.name )\r
continue;\r
\r
if ( child.name == tagName )\r
child = child.firstChild( evaluator );\r
if ( child )\r
return child;\r
- else\r
- continue;\r
}\r
}\r
\r
return null;\r
};\r
\r
- // Adding a (set) of styles to the element's attributes.\r
+ // Adding a (set) of styles to the element's 'style' attributes.\r
elementPrototype.addStyle = function( name, value, isPrepend )\r
{\r
var styleText, addingStyleText = '';\r
// style literal.\r
if ( typeof name == 'object' )\r
{\r
- for( var style in name )\r
+ for ( var style in name )\r
{\r
- if( name.hasOwnProperty( style ) )\r
+ if ( name.hasOwnProperty( style ) )\r
addingStyleText += style + ':' + name[ style ] + ';';\r
}\r
}\r
isPrepend = value;\r
}\r
\r
- if( !this.attributes )\r
+ if ( !this.attributes )\r
this.attributes = {};\r
\r
styleText = this.attributes.style || '';\r
return result;\r
};\r
\r
- 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
- var emptyMarginRegex = /^(?:\b0[^\s]*\s*){1,4}$/;\r
+ 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
+ var emptyMarginRegex = /^(?:\b0[^\s]*\s*){1,4}$/; // e.g. 0px 0pt 0px\r
\r
var listBaseIndent = 0,\r
previousListItemMargin;\r
}\r
else\r
{\r
- if ( /[l\u00B7\u2002]/.test( bulletStyle[ 1 ] ) ) //l·•\r
+ if ( /[l\u00B7\u2002]/.test( bulletStyle[ 1 ] ) )\r
bulletStyle = 'disc';\r
- else if ( /[\u006F\u00D8]/.test( bulletStyle[ 1 ] ) ) //oØ\r
+ else if ( /[\u006F\u00D8]/.test( bulletStyle[ 1 ] ) )\r
bulletStyle = 'circle';\r
- else if ( /[\u006E\u25C6]/.test( bulletStyle[ 1 ] ) ) //n◆\r
+ else if ( /[\u006E\u25C6]/.test( bulletStyle[ 1 ] ) )\r
bulletStyle = 'square';\r
else\r
bulletStyle = 'disc';\r
isListBulletIndicator : function( element )\r
{\r
var styleText = element.attributes && element.attributes.style;\r
- if( /mso-list\s*:\s*Ignore/i.test( styleText ) )\r
+ if ( /mso-list\s*:\s*Ignore/i.test( styleText ) )\r
return true;\r
},\r
\r
resolveList : function( element )\r
{\r
// <cke:listbullet> indicate a list item.\r
- var children = element.children,\r
- attrs = element.attributes,\r
+ var attrs = element.attributes,\r
listMarker;\r
\r
if ( ( listMarker = element.removeAnyChildWithName( 'cke:listbullet' ) )\r
{\r
// Be able to deal with component/short-hand form style.\r
var values = margin.split( ' ' );\r
- margin = values[ 3 ] || values[ 1 ] || values [ 0 ];\r
+ margin = CKEDITOR.plugins.pastefromword.utils.convertToPx( values[ 3 ] || values[ 1 ] || values [ 0 ] );\r
margin = parseInt( margin, 10 );\r
\r
// Figure out the indent unit by looking at the first increament.\r
\r
return function( cssLength )\r
{\r
- if( cssLengthRelativeUnit.test( cssLength ) )\r
+ if ( cssLengthRelativeUnit.test( cssLength ) )\r
{\r
calculator.setStyle( 'width', cssLength );\r
return calculator.$.clientWidth + 'px';\r
child = children[ i ];\r
var attributes = child.attributes;\r
\r
- if( child.name in CKEDITOR.dtd.$listItem )\r
+ if ( child.name in CKEDITOR.dtd.$listItem )\r
{\r
var listItemChildren = child.children,\r
count = listItemChildren.length,\r
last = listItemChildren[ count - 1 ];\r
\r
// Move out nested list.\r
- if( last.name in CKEDITOR.dtd.$list )\r
+ if ( last.name in CKEDITOR.dtd.$list )\r
{\r
children.splice( i + 1, 0, last );\r
last.parent = element;\r
{\r
// There might be a negative gap between two list levels. (#4944)\r
var diff = indent - listItemIndent,\r
- parent = list.parent;\r
- while( diff-- && parent )\r
+ parent;\r
+ while ( diff-- && ( parent = list.parent ) )\r
list = parent.parent;\r
\r
list.add( listItem );\r
valuePattern,\r
newValue,\r
newName;\r
- for( var i = 0 ; i < styles.length; i++ )\r
+ for ( var i = 0 ; i < styles.length; i++ )\r
{\r
- if( styles[ i ] )\r
+ if ( styles[ i ] )\r
{\r
namePattern = styles[ i ][ 0 ];\r
valuePattern = styles[ i ][ 1 ];\r
name = newName || name;\r
whitelist && ( newValue = newValue || value );\r
\r
- if( typeof newValue == 'function' )\r
+ if ( typeof newValue == 'function' )\r
newValue = newValue( value, element, name );\r
\r
// Return an couple indicate both name and value\r
// changed.\r
- if( newValue && newValue.push )\r
+ if ( newValue && newValue.push )\r
name = newValue[ 0 ], newValue = newValue[ 1 ];\r
\r
- if( typeof newValue == 'string' )\r
+ if ( typeof newValue == 'string' )\r
rules.push( [ name, newValue ] );\r
return;\r
}\r
*/\r
bogusAttrFilter : function( value, element )\r
{\r
- if( element.name.indexOf( 'cke:' ) == -1 )\r
+ if ( element.name.indexOf( 'cke:' ) == -1 )\r
return false;\r
},\r
\r
stylesFilter = filters.stylesFilter,\r
elementMigrateFilter = filters.elementMigrateFilter,\r
styleMigrateFilter = CKEDITOR.tools.bind( this.filters.styleMigrateFilter, this.filters ),\r
- bogusAttrFilter = filters.bogusAttrFilter,\r
createListBulletMarker = this.utils.createListBulletMarker,\r
flattenList = filters.flattenList,\r
assembleList = filters.assembleList,\r
{\r
element.filterChildren();\r
// Is the heading actually a list item?\r
- if( resolveListItem( element ) )\r
+ if ( resolveListItem( element ) )\r
return;\r
\r
// Adapt heading styles to editor's convention.\r
className = className.substring( 1, className.length );\r
\r
// Reject MS-Word Normal styles.\r
- if( className.match( /MsoNormal/ ) )\r
+ if ( className.match( /MsoNormal/ ) )\r
return;\r
\r
- if( !rules[ tagName ] )\r
+ if ( !rules[ tagName ] )\r
rules[ tagName ] = {};\r
- if( className )\r
+ if ( className )\r
rules[ tagName ][ className ] = styleBlock;\r
else\r
rules[ tagName ] = styleBlock;\r
var name = rules[ '*' ] ? '*' : element.name,\r
className = element.attributes && element.attributes[ 'class' ],\r
style;\r
- if( name in rules )\r
+ if ( name in rules )\r
{\r
style = rules[ name ];\r
- if( typeof style == 'object' )\r
+ if ( typeof style == 'object' )\r
style = style[ className ];\r
// Maintain style rules priorities.\r
style && element.addStyle( style, true );\r
{\r
element.filterChildren();\r
\r
- var attrs = element.attributes,\r
- parent = element.parent,\r
- children = element.children;\r
-\r
// Is the paragraph actually a list item?\r
if ( resolveListItem( element ) )\r
return;\r
// table cells inherit as text-align styles, which is wrong.\r
// Instead we use a clear-float div after the table to properly achieve the same layout.\r
var singleChild = element.onlyChild();\r
- if( singleChild && singleChild.name == 'table' )\r
+ if ( singleChild && singleChild.name == 'table' )\r
{\r
var attrs = element.attributes;\r
singleChild.attributes = CKEDITOR.tools.extend( singleChild.attributes, attrs );\r
element.attributes );\r
styleText && parent.addStyle( styleText );\r
delete element.name;\r
- return;\r
}\r
// Convert the merged into a span with all attributes preserved.\r
else\r
'a' : function( element )\r
{\r
var attrs = element.attributes;\r
- if( attrs && !attrs.href && attrs.name )\r
+ if ( attrs && !attrs.href && attrs.name )\r
delete element.name;\r
},\r
'cke:listbullet' : function( element )\r
[ ( /^border.*|margin.*|vertical-align|float$/ ), null,\r
function( value, element )\r
{\r
- if( element.name == 'img' )\r
+ if ( element.name == 'img' )\r
return value;\r
} ],\r
\r
[ (/^width|height$/ ), null,\r
function( value, element )\r
{\r
- if( element.name in { table : 1, td : 1, th : 1, img : 1 } )\r
+ if ( element.name in { table : 1, td : 1, th : 1, img : 1 } )\r
return value;\r
} ]\r
] :\r
// Fixing color values.\r
[ ( /-color$/ ), null, function( value )\r
{\r
- if( value == 'transparent' )\r
+ if ( value == 'transparent' )\r
return false;\r
- if( CKEDITOR.env.gecko )\r
+ if ( CKEDITOR.env.gecko )\r
return value.replace( /-moz-use-text-color/g, 'transparent' );\r
} ],\r
// Remove empty margin values, e.g. 0.00001pt 0em 0pt\r
// Prefer width styles over 'width' attributes.\r
'width' : function( value, element )\r
{\r
- if( element.name in dtd.$tableContent )\r
+ if ( element.name in dtd.$tableContent )\r
return false;\r
},\r
// Prefer border styles over table 'border' attributes.\r
'border' : function( value, element )\r
{\r
- if( element.name in dtd.$tableContent )\r
+ if ( element.name in dtd.$tableContent )\r
return false;\r
},\r
\r
}\r
\r
// Reveal the <img> element in conditional comments for Firefox.\r
- if( CKEDITOR.env.gecko && imageInfo )\r
+ if ( CKEDITOR.env.gecko && imageInfo )\r
{\r
var img = CKEDITOR.htmlParser.fragment.fromHtml( imageInfo[ 0 ] ).children[ 0 ],\r
previousComment = node.previous,\r
// Firefox will be confused by those downlevel-revealed IE conditional\r
// comments, fixing them first( convert it to upperlevel-revealed one ).\r
// e.g. <![if !vml]>...<![endif]>\r
- if( CKEDITOR.env.gecko )\r
+ if ( CKEDITOR.env.gecko )\r
data = data.replace( /(<!--\[if[^<]*?\])-->([\S\s]*?)<!--(\[endif\]-->)/gi, '$1$2$3' );\r
\r
var dataProcessor = new pasteProcessor(),\r
})();\r
\r
/**\r
- * Whether the ignore all font-related format styles, including:\r
- * - font size;\r
- * - font family;\r
- * - font fore/background color;\r
+ * Whether to ignore all font related formatting styles, including:\r
+ * <ul> <li>font size;</li>\r
+ * <li>font family;</li>\r
+ * <li>font foreground/background color.</li></ul>\r
* @name CKEDITOR.config.pasteFromWordRemoveFontStyles\r
+ * @since 3.1\r
* @type Boolean\r
* @default true\r
* @example\r
*/\r
\r
/**\r
- * Whether transform MS-Word Outline Numbered Heading into html list.\r
+ * Whether to transform MS Word outline numbered headings into lists.\r
* @name CKEDITOR.config.pasteFromWordNumberedHeadingToList\r
+ * @since 3.1\r
* @type Boolean\r
* @default false\r
* @example\r
*/\r
\r
/**\r
- * Whether remove element styles that can't be managed with editor, note that this\r
- * this doesn't handle the font-specific styles, which depends on\r
- * how {@link CKEDITOR.config.pasteFromWordRemoveFontStyles} is configured.\r
+ * Whether to remove element styles that can't be managed with the editor. Note\r
+ * that this doesn't handle the font specific styles, which depends on the\r
+ * {@link CKEDITOR.config.pasteFromWordRemoveFontStyles} setting instead.\r
* @name CKEDITOR.config.pasteFromWordRemoveStyles\r
+ * @since 3.1\r
* @type Boolean\r
* @default true\r
* @example\r