- var boundaryNodes = range.getBoundaryNodes();\r
- var firstNode = boundaryNodes.startNode;\r
- var lastNode = boundaryNodes.endNode.getNextSourceNode( true );\r
-\r
- // Probably the document end is reached, we need a marker node.\r
- if ( !lastNode )\r
- {\r
- var marker;\r
- lastNode = marker = document.createText( '' );\r
- lastNode.insertAfter( range.endContainer );\r
- }\r
- // The detection algorithm below skips the contents inside bookmark nodes, so\r
- // we'll need to make sure lastNode isn't the inside a bookmark node.\r
- var lastParent = lastNode.getParent();\r
- if ( lastParent && lastParent.getAttribute( '_fck_bookmark' ) )\r
- lastNode = lastParent;\r
-\r
- if ( lastNode.equals( firstNode ) )\r
- {\r
- // If the last node is the same as the the first one, we must move\r
- // it to the next one, otherwise the first one will not be\r
- // processed.\r
- lastNode = lastNode.getNextSourceNode( true );\r
-\r
- // It may happen that there are no more nodes after it (the end of\r
- // the document), so we must add something there to make our code\r
- // simpler.\r
- if ( !lastNode )\r
- {\r
- lastNode = marker = document.createText( '' );\r
- lastNode.insertAfter( firstNode );\r
- }\r
- }\r
+ var boundaryNodes = range.createBookmark(),\r
+ firstNode = boundaryNodes.startNode,\r
+ lastNode = boundaryNodes.endNode;\r