- // To expand empty blocks or line spaces after <br>, we need\r
- // instead to have any char, which will be later deleted using the\r
- // selection.\r
- // \ufeff = Zero Width No-Break Space (U+FEFF). (#1359)\r
- this.document.createText( '\ufeff' ).insertBefore( startNode );\r
+ // The isStartMarkerAlone logic comes from V2. It guarantees that the lines\r
+ // will expand and that the cursor will be blinking on the right place.\r
+ // Actually, we are using this flag just to avoid using this hack in all\r
+ // situations, but just on those needed.\r
+ var next = startNode.getNext( notWhitespaces );\r
+ isStartMarkerAlone = ( !( next && next.getText && next.getText().match( fillerTextRegex ) ) // already a filler there?\r
+ && ( forceExpand || !startNode.hasPrevious() || ( startNode.getPrevious().is && startNode.getPrevious().is( 'br' ) ) ) );\r
+\r
+ // Append a temporary <span></span> before the selection.\r
+ // This is needed to avoid IE destroying selections inside empty\r
+ // inline elements, like <b></b> (#253).\r
+ // It is also needed when placing the selection right after an inline\r
+ // element to avoid the selection moving inside of it.\r
+ dummySpan = this.document.createElement( 'span' );\r
+ dummySpan.setHtml( '' ); // Zero Width No-Break Space (U+FEFF). See #1359.\r
+ dummySpan.insertBefore( startNode );\r
+\r
+ if ( isStartMarkerAlone )\r
+ {\r
+ // To expand empty blocks or line spaces after <br>, we need\r
+ // instead to have any char, which will be later deleted using the\r
+ // selection.\r
+ // \ufeff = Zero Width No-Break Space (U+FEFF). (#1359)\r
+ this.document.createText( '\ufeff' ).insertBefore( startNode );\r
+ }\r