X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fpastefromword%2Ffilter%2Fdefault.js;h=83b8ec813ebd953816a14b6cd66c839862dea0a1;hb=refs%2Ftags%2Fv3.6.6;hp=dce3649ab778a1a2c2d38014908a1c04dc4d050b;hpb=4e90e78dc97789709ee7404359a5517540c27553;p=ckeditor.git
diff --git a/_source/plugins/pastefromword/filter/default.js b/_source/plugins/pastefromword/filter/default.js
index dce3649..83b8ec8 100644
--- a/_source/plugins/pastefromword/filter/default.js
+++ b/_source/plugins/pastefromword/filter/default.js
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
+Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
@@ -261,8 +261,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
// Deal with component/short-hand form.
var values = margin.split( ' ' );
- margin = plugin.utils.convertToPx( values[ 3 ] || values[ 1 ] || values [ 0 ] );
- margin = parseInt( margin, 10 );
+ margin = CKEDITOR.tools.convertToPx( values[ 3 ] || values[ 1 ] || values [ 0 ] );
// Figure out the indent unit by checking the first time of incrementation.
if ( !listBaseIndent && previousListItemMargin !== null && margin > previousListItemMargin )
@@ -279,8 +278,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
var listId = Number( val[ 0 ].match( /\d+/ ) ),
indent = Number( val[ 1 ].match( /\d+/ ) );
- listId !== previousListId && ( attrs[ 'cke:reset' ] = 1 );
- previousListId = listId;
+ if ( indent == 1 )
+ {
+ listId !== previousListId && ( attrs[ 'cke:reset' ] = 1 );
+ previousListId = listId;
+ }
attrs[ 'cke:indent' ] = indent;
} ]
] )( attrs.style, element ) || '';
@@ -307,27 +309,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
return false;
},
- // Convert various length units to 'px' in ignorance of DPI.
- convertToPx : ( function ()
- {
- var calculator = CKEDITOR.dom.element.createFromHtml(
- '
', CKEDITOR.document );
- CKEDITOR.document.getBody().append( calculator );
-
- return function( cssLength )
- {
- if ( cssLengthRelativeUnit.test( cssLength ) )
- {
- calculator.setStyle( 'width', cssLength );
- return calculator.$.clientWidth + 'px';
- }
-
- return cssLength;
- };
- } )(),
-
// Providing a shorthand style then retrieve one or more style component values.
getStyleComponents : ( function()
{
@@ -357,20 +338,12 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
// E.g. - level1
- level2
=>
// level1
// level2
- flattenList : function( element )
+ flattenList : function( element, level )
{
- var attrs = element.attributes,
- parent = element.parent;
-
- var listStyleType,
- indentLevel = 1;
+ level = typeof level == 'number' ? level : 1;
- // Resolve how many level nested.
- while ( parent )
- {
- parent.attributes && parent.attributes[ 'cke:list' ] && indentLevel++;
- parent = parent.parent;
- }
+ var attrs = element.attributes,
+ listStyleType;
// All list items are of the same type.
switch ( attrs.type )
@@ -378,6 +351,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
case 'a' :
listStyleType = 'lower-alpha';
break;
+ case '1' :
+ listStyleType = 'decimal';
+ break;
// TODO: Support more list style type from MS-Word.
}
@@ -387,23 +363,22 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
for ( var i = 0; i < children.length; i++ )
{
child = children[ i ];
- var attributes = child.attributes;
if ( child.name in CKEDITOR.dtd.$listItem )
{
- var listItemChildren = child.children,
+ var attributes = child.attributes,
+ listItemChildren = child.children,
count = listItemChildren.length,
last = listItemChildren[ count - 1 ];
// Move out nested list.
if ( last.name in CKEDITOR.dtd.$list )
{
- children.splice( i + 1, 0, last );
- last.parent = element;
+ element.add( last, i + 1 );
// Remove the parent list item if it's just a holder.
if ( !--listItemChildren.length )
- children.splice( i, 1 );
+ children.splice( i--, 1 );
}
child.name = 'cke:li';
@@ -413,24 +388,34 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
plugin.filters.stylesFilter(
[
- [ 'tab-stops', null, function( val )
+ [ 'tab-stops', null, function( val )
{
var margin = val.split( ' ' )[ 1 ].match( cssLengthRelativeUnit );
- margin && ( previousListItemMargin = parseInt( plugin.utils.convertToPx( margin[ 0 ] ), 10 ) );
+ margin && ( previousListItemMargin = CKEDITOR.tools.convertToPx( margin[ 0 ] ) );
} ],
- [ 'mso-list', null, function( val )
+ ( level == 1 ? [ 'mso-list', null, function( val )
{
val = val.split( ' ' );
var listId = Number( val[ 0 ].match( /\d+/ ) );
listId !== previousListId && ( attributes[ 'cke:reset' ] = 1 );
previousListId = listId;
- } ]
+ } ] : null )
] )( attributes.style );
- attributes[ 'cke:indent' ] = indentLevel;
+ attributes[ 'cke:indent' ] = level;
attributes[ 'cke:listtype' ] = element.name;
attributes[ 'cke:list-style-type' ] = listStyleType;
}
+ // Flatten sub list.
+ else if ( child.name in CKEDITOR.dtd.$list )
+ {
+ // Absorb sub list children.
+ arguments.callee.apply( this, [ child, level + 1 ] );
+ children = children.slice( 0, i ).concat( child.children ).concat( children.slice( i + 1 ) );
+ element.children = [];
+ for ( var j = 0, num = children.length; j < num ; j++ )
+ element.add( children[ j ] );
+ }
}
delete element.name;
@@ -771,7 +756,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
isListBulletIndicator = this.utils.isListBulletIndicator,
containsNothingButSpaces = this.utils.isContainingOnlySpaces,
resolveListItem = this.utils.resolveList,
- convertToPx = this.utils.convertToPx,
+ convertToPx = function( value )
+ {
+ value = CKEDITOR.tools.convertToPx( value );
+ return isNaN( value ) ? value : value + 'px';
+ },
getStyleComponents = this.utils.getStyleComponents,
listDtdParents = this.utils.listDtdParents,
removeFontStyles = config.pasteFromWordRemoveFontStyles !== false,
@@ -1120,6 +1109,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
var attrs = element.attributes;
if ( attrs && !attrs.href && attrs.name )
delete element.name;
+ else if ( CKEDITOR.env.webkit && attrs.href && attrs.href.match( /file:\/\/\/[\S]+#/i ) )
+ attrs.href = attrs.href.replace( /file:\/\/\/[^#]+/i,'' );
},
'cke:listbullet' : function( element )
{