JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.4.3
[ckeditor.git] / _source / plugins / pastefromword / filter / default.js
index b042a33..13ff5bc 100644 (file)
@@ -60,15 +60,13 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                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
@@ -120,8 +118,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                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
+       var romanLiternalPattern = '^m{0,4}(cm|cd|d?c{0,3})(xc|xl|l?x{0,3})(ix|iv|v?i{0,3})$',\r
+               lowerRomanLiteralRegex = new RegExp( romanLiternalPattern ),\r
+               upperRomanLiteralRegex = new RegExp( romanLiternalPattern.toUpperCase() );\r
 \r
        var listBaseIndent = 0,\r
                 previousListItemMargin;\r
@@ -146,8 +147,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                {\r
                                        if ( !isNaN( bulletStyle[ 1 ] ) )\r
                                                bulletStyle = 'decimal';\r
-                                       // No way to distinguish between Roman numerals and Alphas,\r
-                                       // detect them as a whole.\r
+                                       else if ( lowerRomanLiteralRegex.test( bulletStyle[ 1 ] ) )\r
+                                               bulletStyle = 'lower-roman';\r
+                                       else if ( upperRomanLiteralRegex.test( bulletStyle[ 1 ] ) )\r
+                                               bulletStyle = 'upper-roman';\r
                                        else if ( /^[a-z]+$/.test( bulletStyle[ 1 ] ) )\r
                                                bulletStyle = 'lower-alpha';\r
                                        else if ( /^[A-Z]+$/.test( bulletStyle[ 1 ] ) )\r
@@ -161,11 +164,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                }\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
@@ -200,8 +203,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        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
@@ -222,7 +224,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                        {\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
@@ -589,7 +591,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                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
@@ -756,10 +757,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                        {\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
@@ -829,7 +826,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                        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