386 | | // Probably the document end is reached, we need a marker node. |
387 | | if ( !lastNode ) |
388 | | { |
389 | | var marker; |
390 | | lastNode = marker = document.createText( '' ); |
391 | | lastNode.insertAfter( range.endContainer ); |
392 | | } |
393 | | // The detection algorithm below skips the contents inside bookmark nodes, so |
394 | | // we'll need to make sure lastNode isn't the inside a bookmark node. |
395 | | var lastParent = lastNode.getParent(); |
396 | | if ( lastParent && lastParent.getAttribute( '_fck_bookmark' ) ) |
397 | | lastNode = lastParent; |
398 | | |
399 | | if ( lastNode.equals( firstNode ) ) |
400 | | { |
401 | | // If the last node is the same as the the first one, we must move |
402 | | // it to the next one, otherwise the first one will not be |
403 | | // processed. |
404 | | lastNode = lastNode.getNextSourceNode( true ); |
405 | | |
406 | | // It may happen that there are no more nodes after it (the end of |
407 | | // the document), so we must add something there to make our code |
408 | | // simpler. |
409 | | if ( !lastNode ) |
410 | | { |
411 | | lastNode = marker = document.createText( '' ); |
412 | | lastNode.insertAfter( firstNode ); |
413 | | } |
414 | | } |
415 | | |