345 | | // Compensate a <br> before the first node if the previous node of list is a non-blocks.(#3836) |
346 | | var docFragment = newList.listNode, firstNode, previousNode; |
347 | | if ( ( firstNode = docFragment.getFirst() ) |
348 | | && !( firstNode.is && firstNode.isBlockBoundary() ) |
349 | | && ( previousNode = groupObj.root.getPrevious( true ) ) |
350 | | && !( previousNode.is && previousNode.isBlockBoundary( { br : 1 } ) ) ) |
351 | | editor.document.createElement( 'br' ).insertBefore( firstNode ); |
| 345 | // Compensate <br> before/after the list node if the surrounds are non-blocks.(#3836) |
| 346 | var docFragment = newList.listNode, boundaryNode, siblingNode; |
| 347 | function compensateBrs( isStart ) |
| 348 | { |
| 349 | if ( ( boundaryNode = docFragment[ isStart ? 'getFirst' : 'getLast' ]() ) |
| 350 | && !( boundaryNode.is && boundaryNode.isBlockBoundary() ) |
| 351 | && ( siblingNode = groupObj.root[ isStart ? 'getPrevious' : 'getNext' ] |
| 352 | ( CKEDITOR.dom.walker.whitespaces( true ) ) ) |
| 353 | && !( siblingNode.is && siblingNode.isBlockBoundary( { br : 1 } ) ) ) |
| 354 | editor.document.createElement( 'br' )[ isStart ? 'insertBefore' : 'insertAfter' ]( boundaryNode ); |
| 355 | } |
| 356 | compensateBrs( true ); |
| 357 | compensateBrs(); |