IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
|
| 102 | 102 | indentLevel = Math.max( listArray[ baseIndex ].indent, 0 ), |
| 103 | 103 | currentListItem = null, |
| 104 | 104 | orgDir, |
| | 105 | block, |
| 105 | 106 | paragraphName = ( paragraphMode == CKEDITOR.ENTER_P ? 'p' : 'div' ); |
| 106 | 107 | while ( 1 ) |
| 107 | 108 | { |
| … |
… |
|
| 146 | 147 | if ( listNodeNames[ item.grandparent.getName() ] ) |
| 147 | 148 | currentListItem = item.element.clone( false, true ); |
| 148 | 149 | else |
| | 150 | currentListItem = new CKEDITOR.dom.documentFragment( doc ); |
| | 151 | |
| | 152 | // Migrate all children to the new container, |
| | 153 | // apply the proper text direction. |
| | 154 | var dirLoose = item.grandparent.getDirection( 1 ) != orgDir, |
| | 155 | enterBr = paragraphMode == CKEDITOR.ENTER_BR, |
| | 156 | li = item.element, |
| | 157 | className = li.getAttribute( 'class' ), |
| | 158 | style = li.getAttribute( 'style' ); |
| | 159 | |
| | 160 | for ( var i = 0, child, count = item.contents.length; i < count; i++ ) |
| 149 | 161 | { |
| 150 | | // Create completely new blocks here. |
| 151 | | if ( dir || item.element.hasAttributes() || paragraphMode != CKEDITOR.ENTER_BR ) |
| | 162 | child = item.contents[ i ]; |
| | 163 | |
| | 164 | if ( child.type == CKEDITOR.NODE_ELEMENT && child.isBlockBoundary() ) |
| 152 | 165 | { |
| 153 | | currentListItem = doc.createElement( paragraphName ); |
| 154 | | item.element.copyAttributes( currentListItem, { type:1, value:1 } ); |
| | 166 | // Apply direction on content blocks. |
| | 167 | if ( dirLoose && !child.getDirection() ) |
| | 168 | child.setAttribute( 'dir', orgDir ); |
| 155 | 169 | |
| 156 | | // There might be a case where there are no attributes in the element after all |
| 157 | | // (i.e. when "type" or "value" are the only attributes set). In this case, if enterMode = BR, |
| 158 | | // the current item should be a fragment. |
| 159 | | if ( !dir && paragraphMode == CKEDITOR.ENTER_BR && !currentListItem.hasAttributes() ) |
| 160 | | currentListItem = new CKEDITOR.dom.documentFragment( doc ); |
| | 170 | // Merge into child styles. |
| | 171 | style && child.setAttribute( 'style', style + child.getAttribute( 'style' ) || '' ); |
| | 172 | className && child.addClass( className ); |
| 161 | 173 | } |
| 162 | | else |
| 163 | | currentListItem = new CKEDITOR.dom.documentFragment( doc ); |
| 164 | | } |
| | 174 | else if ( dirLoose || !enterBr || style || className ) |
| | 175 | { |
| | 176 | // Establish new block to hold text direction and styles. |
| | 177 | if ( !block ) |
| | 178 | { |
| | 179 | block = doc.createElement( paragraphName ); |
| | 180 | dirLoose && block.setAttribute( 'dir', orgDir ); |
| | 181 | } |
| 165 | 182 | |
| 166 | | if ( currentListItem.type == CKEDITOR.NODE_ELEMENT ) |
| 167 | | { |
| 168 | | if ( item.grandparent.getDirection( 1 ) != orgDir ) |
| 169 | | currentListItem.setAttribute( 'dir', orgDir ); |
| 170 | | } |
| | 183 | // Copy over styles to new block; |
| | 184 | style && block.setAttribute( 'style', style ); |
| | 185 | className && block.setAttribute( 'class', className ); |
| | 186 | |
| | 187 | block.append( child.clone( 1, 1 ) ); |
| | 188 | } |
| 171 | 189 | |
| 172 | | for ( i = 0 ; i < item.contents.length ; i++ ) |
| 173 | | currentListItem.append( item.contents[i].clone( 1, 1 ) ); |
| | 190 | currentListItem.append( block || child.clone( 1, 1 ) ); |
| | 191 | } |
| 174 | 192 | |
| 175 | 193 | if ( currentListItem.type == CKEDITOR.NODE_DOCUMENT_FRAGMENT |
| 176 | 194 | && currentIndex != listArray.length - 1 ) |
| … |
… |
|
| 190 | 208 | } |
| 191 | 209 | } |
| 192 | 210 | |
| 193 | | if ( currentListItem.type == CKEDITOR.NODE_ELEMENT && |
| 194 | | currentListItem.getName() == paragraphName && |
| 195 | | currentListItem.$.firstChild ) |
| 196 | | { |
| 197 | | currentListItem.trim(); |
| 198 | | var firstChild = currentListItem.getFirst(); |
| 199 | | if ( firstChild.type == CKEDITOR.NODE_ELEMENT && firstChild.isBlockBoundary() ) |
| 200 | | { |
| 201 | | var tmp = new CKEDITOR.dom.documentFragment( doc ); |
| 202 | | currentListItem.moveChildren( tmp ); |
| 203 | | currentListItem = tmp; |
| 204 | | } |
| 205 | | } |
| 206 | | |
| 207 | 211 | var currentListItemName = currentListItem.$.nodeName.toLowerCase(); |
| 208 | 212 | if ( !CKEDITOR.env.ie && ( currentListItemName == 'div' || currentListItemName == 'p' ) ) |
| 209 | 213 | currentListItem.appendBogus(); |
| … |
… |
|
| 214 | 218 | else |
| 215 | 219 | return null; |
| 216 | 220 | |
| | 221 | block = null; |
| | 222 | |
| 217 | 223 | if ( listArray.length <= currentIndex || Math.max( listArray[ currentIndex ].indent, 0 ) < indentLevel ) |
| 218 | 224 | break; |
| 219 | 225 | } |
| … |
… |
|
| 378 | 384 | |
| 379 | 385 | listsCreated.push( listNode ); |
| 380 | 386 | |
| 381 | | var contentBlock, listItem; |
| | 387 | var contentBlock, blockDir, listItem; |
| 382 | 388 | |
| 383 | 389 | while ( listContents.length ) |
| 384 | 390 | { |
| 385 | 391 | contentBlock = listContents.shift(); |
| 386 | 392 | listItem = doc.createElement( 'li' ); |
| 387 | 393 | |
| 388 | | // Preserve preformat block and heading structure when converting to list item. (#5335) (#5271) |
| 389 | | if ( contentBlock.is( 'pre' ) || headerTagRegex.test( contentBlock.getName() ) ) |
| | 394 | // Take it off the tree to void bothering |
| | 395 | // the direction change event. |
| | 396 | contentBlock.remove(); |
| | 397 | |
| | 398 | if ( blockDir = contentBlock.getDirection() ) |
| | 399 | { |
| | 400 | contentBlock.removeStyle( 'direction' ); |
| | 401 | contentBlock.removeAttribute( 'dir' ); |
| | 402 | } |
| | 403 | |
| | 404 | // Preserve the block when converting to list item if: |
| | 405 | // 1. In preformat; (#5335) |
| | 406 | // 2. In heading structure; (#5271) |
| | 407 | // 3. Styled or attributed. (#6461) |
| | 408 | if ( contentBlock.is( 'pre' ) |
| | 409 | || headerTagRegex.test( contentBlock.getName() ) |
| | 410 | || contentBlock.hasAttributes() ) |
| 390 | 411 | contentBlock.appendTo( listItem ); |
| 391 | 412 | else |
| 392 | 413 | { |
| 393 | | contentBlock.copyAttributes( listItem ); |
| 394 | | // Remove direction attribute after it was merged into list root. (#7657) |
| 395 | | if ( listDir && contentBlock.getDirection() ) |
| 396 | | { |
| 397 | | listItem.removeStyle( 'direction' ); |
| 398 | | listItem.removeAttribute( 'dir' ); |
| 399 | | } |
| 400 | 414 | contentBlock.moveChildren( listItem ); |
| 401 | 415 | contentBlock.remove(); |
| 402 | 416 | } |
| | 417 | |
| | 418 | // Apply text direction on list item unless it's already applied on root. (#7657) |
| | 419 | if ( blockDir && !listDir ) |
| | 420 | listItem.setAttribute( 'dir', blockDir ); |
| 403 | 421 | |
| 404 | 422 | listItem.appendTo( listNode ); |
| 405 | 423 | } |