Ticket #7131: 7131.patch
File 7131.patch, 4.4 KB (added by , 13 years ago) |
---|
-
_source/plugins/pastefromword/filter/default.js
124 124 lowerRomanLiteralRegex = new RegExp( romanLiternalPattern ), 125 125 upperRomanLiteralRegex = new RegExp( romanLiternalPattern.toUpperCase() ); 126 126 127 var orderedPatterns = { 'decimal' : /\d+/, 'lower-roman': lowerRomanLiteralRegex, 'upper-roman': upperRomanLiteralRegex, 'lower-alpha' : /^[a-z]+$/, 'upper-alpha': /^[A-Z]+$/ }, 128 unorderedPatterns = { 'disc' : /[l\u00B7\u2002]/, 'circle' : /[\u006F\u00D8]/,'square' : /[\u006E\u25C6]/}, 129 listMarkerPatterns = { 'ol' : orderedPatterns, 'ul' : unorderedPatterns }; 130 127 131 var listBaseIndent = 0, 128 previousListItemMargin; 132 previousListItemMargin, 133 previousListType, 134 previousListStyleType; 129 135 130 136 CKEDITOR.plugins.pastefromword = 131 137 { … … 135 141 createListBulletMarker : function ( bulletStyle, bulletText ) 136 142 { 137 143 var marker = new CKEDITOR.htmlParser.element( 'cke:listbullet' ), 138 listType; 144 listType, 145 listStyleType; 139 146 140 147 // TODO: Support more list style type from MS-Word. 141 148 if ( !bulletStyle ) 142 149 { 143 bulletStyle = 'decimal';144 150 listType = 'ol'; 151 listStyleType = 'decimal'; 145 152 } 146 else if ( bulletStyle[ 2 ] ) 147 { 148 if ( !isNaN( bulletStyle[ 1 ] ) ) 149 bulletStyle = 'decimal'; 150 else if ( lowerRomanLiteralRegex.test( bulletStyle[ 1 ] ) ) 151 bulletStyle = 'lower-roman'; 152 else if ( upperRomanLiteralRegex.test( bulletStyle[ 1 ] ) ) 153 bulletStyle = 'upper-roman'; 154 else if ( /^[a-z]+$/.test( bulletStyle[ 1 ] ) ) 155 bulletStyle = 'lower-alpha'; 156 else if ( /^[A-Z]+$/.test( bulletStyle[ 1 ] ) ) 157 bulletStyle = 'upper-alpha'; 158 // Simply use decimal for the rest forms of unrepresentable 159 // numerals, e.g. Chinese... 160 else 161 bulletStyle = 'decimal'; 162 163 listType = 'ol'; 164 } 165 else 166 { 167 if ( /[l\u00B7\u2002]/.test( bulletStyle[ 1 ] ) ) 168 bulletStyle = 'disc'; 169 else if ( /[\u006F\u00D8]/.test( bulletStyle[ 1 ] ) ) 170 bulletStyle = 'circle'; 171 else if ( /[\u006E\u25C6]/.test( bulletStyle[ 1 ] ) ) 172 bulletStyle = 'square'; 173 else 174 bulletStyle = 'disc'; 153 else 154 { 155 // Probably share the same list style type with previous list item, 156 // give it priority to avoid ambiguous between C(Alpha) and C.(Roman). 157 if ( previousListType && listMarkerPatterns[ previousListType ] [ previousListStyleType ].test( bulletStyle[ 1 ] ) ) 158 { 159 listType = previousListType; 160 listStyleType = previousListStyleType; 161 } 162 else 163 { 164 for ( var type in listMarkerPatterns ) 165 { 166 for ( var style in listMarkerPatterns[ type ] ) 167 { 168 if ( listMarkerPatterns[ type ][ style ].test( bulletStyle[ 1 ] ) ) 169 { 170 listType = type; 171 listStyleType = style; 172 break; 173 } 174 } 175 } 176 } 175 177 176 listType = 'ul'; 178 179 // Simply use decimal/disc for the rest forms of unrepresentable 180 // numerals, e.g. Chinese..., but as long as there a second part 181 // included, it has a bigger chance of being a order list ;) 182 !listType && ( listType = bulletStyle[ 2 ] ? 'ol' : 'ul' ); 177 183 } 178 184 185 // Record for next. 186 previousListType = listType; 187 previousListStyleType = listStyleType || ( listType == 'ol' ? 'decimal' : 'disc' ); 188 179 189 // Represent list type as CSS style. 180 marker.attributes = 181 { 182 'cke:listtype' : listType, 183 'style' : 'list-style-type:' + bulletStyle + ';' 184 }; 190 marker.attributes = { 'cke:listtype' : listType }; 191 listStyleType && ( marker.attributes[ 'style' ] = 'list-style-type:' + listStyleType + ';' ) 185 192 marker.add( new CKEDITOR.htmlParser.text( bulletText ) ); 186 193 return marker; 187 194 }, … … 949 956 // Provide a white-list of styles that we preserve, those should 950 957 // be the ones that could later be altered with editor tools. 951 958 [ 959 // Leave list-style-type 960 [ /^list-style-type$/, null ], 961 952 962 // Preserve margin-left/right which used as default indent style in the editor. 953 963 [ ( /^margin$|^margin-(?!bottom|top)/ ), null, function( value, element, name ) 954 964 {