1312 | | // Move the end boundary of the main range to match the tool range. |
1313 | | ieRange.setEndPoint( 'EndToEnd', ieRangeEnd ); |
1314 | | ieRange.moveEnd( 'character', -1 ); |
1315 | | } |
1316 | | else |
1317 | | { |
1318 | | // The isStartMarkerAlone logic comes from V2. It guarantees that the lines |
1319 | | // will expand and that the cursor will be blinking on the right place. |
1320 | | // Actually, we are using this flag just to avoid using this hack in all |
1321 | | // situations, but just on those needed. |
1322 | | var next = startNode.getNext( notWhitespaces ); |
1323 | | isStartMarkerAlone = ( !( next && next.getText && next.getText().match( fillerTextRegex ) ) // already a filler there? |
1324 | | && ( forceExpand || !startNode.hasPrevious() || ( startNode.getPrevious().is && startNode.getPrevious().is( 'br' ) ) ) ); |
| 1315 | // Move the end boundary of the main range to match the tool range. |
| 1316 | ieRange.setEndPoint( 'EndToEnd', ieRangeEnd ); |
| 1317 | ieRange.moveEnd( 'character', -1 ); |
| 1318 | } |
| 1319 | else |
| 1320 | { |
| 1321 | // The isStartMarkerAlone logic comes from V2. It guarantees that the lines |
| 1322 | // will expand and that the cursor will be blinking on the right place. |
| 1323 | // Actually, we are using this flag just to avoid using this hack in all |
| 1324 | // situations, but just on those needed. |
| 1325 | var next = startNode.getNext( notWhitespaces ); |
| 1326 | isStartMarkerAlone = ( !( next && next.getText && next.getText().match( fillerTextRegex ) ) // already a filler there? |
| 1327 | && ( forceExpand || !startNode.hasPrevious() || ( startNode.getPrevious().is && startNode.getPrevious().is( 'br' ) ) ) ); |
1326 | | // Append a temporary <span></span> before the selection. |
1327 | | // This is needed to avoid IE destroying selections inside empty |
1328 | | // inline elements, like <b></b> (#253). |
1329 | | // It is also needed when placing the selection right after an inline |
1330 | | // element to avoid the selection moving inside of it. |
1331 | | dummySpan = this.document.createElement( 'span' ); |
1332 | | dummySpan.setHtml( '' ); // Zero Width No-Break Space (U+FEFF). See #1359. |
1333 | | dummySpan.insertBefore( startNode ); |
| 1329 | // Append a temporary <span></span> before the selection. |
| 1330 | // This is needed to avoid IE destroying selections inside empty |
| 1331 | // inline elements, like <b></b> (#253). |
| 1332 | // It is also needed when placing the selection right after an inline |
| 1333 | // element to avoid the selection moving inside of it. |
| 1334 | dummySpan = this.document.createElement( 'span' ); |
| 1335 | dummySpan.setHtml( '' ); // Zero Width No-Break Space (U+FEFF). See #1359. |
| 1336 | dummySpan.insertBefore( startNode ); |
1335 | | if ( isStartMarkerAlone ) |
1336 | | { |
1337 | | // To expand empty blocks or line spaces after <br>, we need |
1338 | | // instead to have any char, which will be later deleted using the |
1339 | | // selection. |
1340 | | // \ufeff = Zero Width No-Break Space (U+FEFF). (#1359) |
1341 | | this.document.createText( '\ufeff' ).insertBefore( startNode ); |
1342 | | } |
1343 | | } |
1344 | | |
1345 | | // Remove the markers (reset the position, because of the changes in the DOM tree). |
1346 | | this.setStartBefore( startNode ); |
1347 | | startNode.remove(); |
| 1338 | if ( isStartMarkerAlone ) |
| 1339 | { |
| 1340 | // To expand empty blocks or line spaces after <br>, we need |
| 1341 | // instead to have any char, which will be later deleted using the |
| 1342 | // selection. |
| 1343 | // \ufeff = Zero Width No-Break Space (U+FEFF). (#1359) |
| 1344 | this.document.createText( '\ufeff' ).insertBefore( startNode ); |
| 1345 | } |
| 1346 | } |
| 1347 | } |
| 1348 | catch( er ){} |
| 1349 | // Make sure the bookmark nodes are removed even if making the selection fails. (#7106) |
| 1350 | finally |
| 1351 | { |
| 1352 | // Remove the markers (reset the position, because of the changes in the DOM tree). |
| 1353 | this.setStartBefore( startNode ); |
| 1354 | startNode.remove(); |
| 1355 | } |