79 | | var walker = new CKEDITOR.dom.walker( range ), |
80 | | ignoreBookmarkTextEvaluator = CKEDITOR.dom.walker.bookmark( true, true ); |
81 | | // Avoid anchor inside bookmark inner text. |
82 | | walker.evaluator = ignoreBookmarkTextEvaluator; |
83 | | this._.nextNode = walker.next(); |
84 | | // TODO: It's better to have walker.reset() used here. |
85 | | walker = new CKEDITOR.dom.walker( range ); |
86 | | walker.evaluator = ignoreBookmarkTextEvaluator; |
87 | | var lastNode = walker.previous(); |
88 | | this._.lastNode = lastNode.getNextSourceNode( true ); |
| 79 | if ( !range.collapsed ) |
| 80 | { |
| 81 | var walker = new CKEDITOR.dom.walker( range.clone() ), |
| 82 | ignoreBookmarkTextEvaluator = CKEDITOR.dom.walker.bookmark( true, true ); |
| 83 | // Avoid anchor inside bookmark inner text. |
| 84 | walker.evaluator = ignoreBookmarkTextEvaluator; |
| 85 | this._.nextNode = walker.next(); |
| 86 | // TODO: It's better to have walker.reset() used here. |
| 87 | walker = new CKEDITOR.dom.walker( range.clone() ); |
| 88 | walker.evaluator = ignoreBookmarkTextEvaluator; |
| 89 | var lastNode = walker.previous(); |
| 90 | this._.lastNode = lastNode.getNextSourceNode( true ); |
90 | | // We may have an empty text node at the end of block due to [3770]. |
91 | | // If that node is the lastNode, it would cause our logic to leak to the |
92 | | // next block.(#3887) |
93 | | if ( this._.lastNode && |
94 | | this._.lastNode.type == CKEDITOR.NODE_TEXT && |
95 | | !CKEDITOR.tools.trim( this._.lastNode.getText() ) && |
96 | | this._.lastNode.getParent().isBlockBoundary() ) |
97 | | { |
98 | | var testRange = new CKEDITOR.dom.range( range.document ); |
99 | | testRange.moveToPosition( this._.lastNode, CKEDITOR.POSITION_AFTER_END ); |
100 | | if ( testRange.checkEndOfBlock() ) |
101 | | { |
102 | | var path = new CKEDITOR.dom.elementPath( testRange.endContainer ); |
103 | | var lastBlock = path.block || path.blockLimit; |
104 | | this._.lastNode = lastBlock.getNextSourceNode( true ); |
105 | | } |
106 | | } |
| 92 | // We may have an empty text node at the end of block due to [3770]. |
| 93 | // If that node is the lastNode, it would cause our logic to leak to the |
| 94 | // next block.(#3887) |
| 95 | if ( this._.lastNode && |
| 96 | this._.lastNode.type == CKEDITOR.NODE_TEXT && |
| 97 | !CKEDITOR.tools.trim( this._.lastNode.getText() ) && |
| 98 | this._.lastNode.getParent().isBlockBoundary() ) |
| 99 | { |
| 100 | var testRange = new CKEDITOR.dom.range( range.document ); |
| 101 | testRange.moveToPosition( this._.lastNode, CKEDITOR.POSITION_AFTER_END ); |
| 102 | if ( testRange.checkEndOfBlock() ) |
| 103 | { |
| 104 | var path = new CKEDITOR.dom.elementPath( testRange.endContainer ); |
| 105 | var lastBlock = path.block || path.blockLimit; |
| 106 | this._.lastNode = lastBlock.getNextSourceNode( true ); |
| 107 | } |
| 108 | } |