IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
161 | 161 | { |
162 | 162 | iterator = ranges[ i ].createIterator(); |
163 | 163 | iterator.enlargeBr = enterMode != CKEDITOR.ENTER_BR; |
| 164 | iterator.enforceRealBlocks = 1; |
164 | 165 | |
165 | 166 | while ( ( block = iterator.getNextParagraph( enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' ) ) ) |
166 | 167 | { |
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 | newBlock, |
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 | |
| 157 | for ( var i = 0, child, count = item.contents.length; i < count; i++ ) |
149 | 158 | { |
150 | | // Create completely new blocks here. |
151 | | if ( dir || item.element.hasAttributes() || paragraphMode != CKEDITOR.ENTER_BR ) |
| 159 | child = item.contents[ i ]; |
| 160 | if ( child.type == CKEDITOR.NODE_ELEMENT && child.isBlockBoundary() ) |
152 | 161 | { |
153 | | currentListItem = doc.createElement( paragraphName ); |
154 | | item.element.copyAttributes( currentListItem, { type:1, value:1 } ); |
| 162 | // Apply direction on content blocks. |
| 163 | if ( dirLoose && !child.getDirection() ) |
| 164 | child.setAttribute( 'dir', orgDir ); |
155 | 165 | |
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 ); |
| 166 | newBlock = null; |
161 | 167 | } |
162 | | else |
163 | | currentListItem = new CKEDITOR.dom.documentFragment( doc ); |
164 | | } |
| 168 | else if ( dirLoose || !enterBr ) |
| 169 | { |
| 170 | // Wrap inline contents with new block, just to remain item direction. |
| 171 | if ( !newBlock ) |
| 172 | { |
| 173 | newBlock = doc.createElement( paragraphName ); |
| 174 | dirLoose && newBlock.setAttribute( 'dir', orgDir ); |
| 175 | } |
165 | 176 | |
166 | | if ( currentListItem.type == CKEDITOR.NODE_ELEMENT ) |
167 | | { |
168 | | if ( item.grandparent.getDirection( 1 ) != orgDir ) |
169 | | currentListItem.setAttribute( 'dir', orgDir ); |
170 | | } |
| 177 | newBlock.append( child.clone( 1, 1 ) ); |
| 178 | } |
171 | 179 | |
172 | | for ( i = 0 ; i < item.contents.length ; i++ ) |
173 | | currentListItem.append( item.contents[i].clone( 1, 1 ) ); |
| 180 | currentListItem.append( newBlock || child.clone( 1, 1 ) ); |
| 181 | } |
174 | 182 | |
175 | 183 | if ( currentListItem.type == CKEDITOR.NODE_DOCUMENT_FRAGMENT |
176 | 184 | && currentIndex != listArray.length - 1 ) |
… |
… |
|
190 | 198 | } |
191 | 199 | } |
192 | 200 | |
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 | 201 | var currentListItemName = currentListItem.$.nodeName.toLowerCase(); |
208 | 202 | if ( !CKEDITOR.env.ie && ( currentListItemName == 'div' || currentListItemName == 'p' ) ) |
209 | 203 | currentListItem.appendBogus(); |
… |
… |
|
214 | 208 | else |
215 | 209 | return null; |
216 | 210 | |
| 211 | newBlock = null; |
| 212 | |
| 213 | |
217 | 214 | if ( listArray.length <= currentIndex || Math.max( listArray[ currentIndex ].indent, 0 ) < indentLevel ) |
218 | 215 | break; |
219 | 216 | } |
… |
… |
|
378 | 375 | |
379 | 376 | listsCreated.push( listNode ); |
380 | 377 | |
381 | | var contentBlock, listItem; |
| 378 | var contentBlock, blockDir, listItem; |
382 | 379 | |
383 | 380 | while ( listContents.length ) |
384 | 381 | { |
385 | 382 | contentBlock = listContents.shift(); |
386 | 383 | listItem = doc.createElement( 'li' ); |
387 | 384 | |
388 | | // Preserve preformat block and heading structure when converting to list item. (#5335) (#5271) |
389 | | if ( contentBlock.is( 'pre' ) || headerTagRegex.test( contentBlock.getName() ) ) |
| 385 | // Take it off the tree to void bothering |
| 386 | // the direction change event. |
| 387 | contentBlock.remove(); |
| 388 | |
| 389 | if ( blockDir = contentBlock.getDirection() ) |
| 390 | { |
| 391 | contentBlock.removeStyle( 'direction' ); |
| 392 | contentBlock.removeAttribute( 'dir' ); |
| 393 | } |
| 394 | |
| 395 | // Preserve the block when converting to list item if: |
| 396 | // 1. In preformat; (#5335) |
| 397 | // 2. In heading structure; (#5271) |
| 398 | // 3. Styled or attributed. (#6461) |
| 399 | if ( contentBlock.is( 'pre' ) |
| 400 | || headerTagRegex.test( contentBlock.getName() ) |
| 401 | || contentBlock.hasAttributes() ) |
390 | 402 | contentBlock.appendTo( listItem ); |
391 | 403 | else |
392 | 404 | { |
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 | 405 | contentBlock.moveChildren( listItem ); |
401 | 406 | contentBlock.remove(); |
402 | 407 | } |
| 408 | |
| 409 | // Apply text direction on list item unless it's already applied on root. (#7657) |
| 410 | if ( blockDir && !listDir ) |
| 411 | listItem.setAttribute( 'dir', blockDir ); |
403 | 412 | |
404 | 413 | listItem.appendTo( listNode ); |
405 | 414 | } |