Ticket #6706: 6707_2.patch
File 6707_2.patch, 4.7 KB (added by , 13 years ago) |
---|
-
_source/plugins/selection/plugin.js
90 90 if ( start.type == CKEDITOR.NODE_TEXT ) 91 91 return false; 92 92 93 // Empty inline at the start of block. (#6706) 94 if ( CKEDITOR.env.ie ) 95 { 96 return !CKEDITOR.tools.trim( start.getHtml() ) 97 && isInlineCt( start ) 98 && range.checkStartOfBlock() 99 && !range.checkEndOfBlock(); 100 } 93 101 // 1. Empty inline element. <span>^</span> 94 102 // 2. Adjoin to inline element. <p><strong>text</strong>^</p> 95 103 // 3. The only empty block in document. <body><p>^</p></body> (#7222) 96 return !CKEDITOR.tools.trim( start.getHtml() ) ? isInlineCt( start ) || singletonBlock( start ) 104 else if ( CKEDITOR.env.webkit ) 105 return !CKEDITOR.tools.trim( start.getHtml() ) ? isInlineCt( start ) || singletonBlock( start ) 97 106 : isInlineCt( start.getChild( offset - 1 ) ) || isInlineCt( start.getChild( offset ) ); 107 98 108 } 99 109 100 110 var selectAllCmd = … … 170 180 } 171 181 } 172 182 183 function introduceFillingChar( range ) 184 { 185 // Append a zero-width space so WebKit will not try to 186 // move the selection by itself (#1272). 187 var fillingChar = createFillingChar( range.document ); 188 range.insertNode( fillingChar ); 189 190 var next = fillingChar.getNext(); 191 192 // If the filling char is followed by a <br>, whithout 193 // having something before it, it'll not blink. 194 // Let's remove it in this case. 195 if ( next && !fillingChar.getPrevious() && next.type == CKEDITOR.NODE_ELEMENT && next.getName() == 'br' ) 196 { 197 removeFillingChar( range.document ); 198 range.moveToPosition( next, CKEDITOR.POSITION_BEFORE_START ); 199 } 200 else 201 range.moveToPosition( fillingChar, CKEDITOR.POSITION_AFTER_END ); 202 } 203 173 204 CKEDITOR.plugins.add( 'selection', 174 205 { 175 206 init : function( editor ) 176 207 { 177 // On WebKit only, we need a special "filling" char on some situations178 // (#1272). Here we set the events that shouldinvalidate that char.179 if ( CKEDITOR.env.webkit )208 // We need a special "filling char" in some situations to make the cursor blink on collapsed selection (#1272) (#6706). 209 // Here we set the events that invalidate that char. 210 if ( CKEDITOR.env.webkit || CKEDITOR.env.ie ) 180 211 { 181 212 editor.on( 'selectionChange', function() { checkFillingChar( editor.document ); } ); 182 213 editor.on( 'beforeSetMode', function() { removeFillingChar( editor.document ); } ); … … 205 236 206 237 if ( fillingChar ) 207 238 { 208 // If cursor is right blinking by side of the filler node, save it for restoring, 209 // as the following text substitution will blind it. (#7437) 210 var sel = doc.$.defaultView.getSelection(); 211 if ( sel.type == 'Caret' && sel.anchorNode == fillingChar.$ ) 212 resetSelection = 1; 239 if ( CKEDITOR.env.webkit ) 240 { 241 // If cursor is right blinking by side of the filler node, save it for restoring, 242 // as the following text substitution will blind it. (#7437) 243 var sel = doc.$.defaultView.getSelection(); 244 if ( sel.type == 'Caret' && sel.anchorNode == fillingChar.$ ) 245 resetSelection = 1; 246 } 213 247 214 248 fillingCharBefore = fillingChar.getText(); 215 249 fillingChar.setText( fillingCharBefore.replace( /\u200B/g, '' ) ); … … 1280 1314 ranges.length = 1; 1281 1315 } 1282 1316 1283 if ( ranges[ 0 ] ) 1284 ranges[ 0 ].select(); 1317 var range = ranges[ 0 ]; 1285 1318 1319 if ( range ) 1320 { 1321 removeFillingChar( this.document ); 1322 if ( range.collapsed && rangeRequiresFix( range ) ) 1323 introduceFillingChar( range ); 1324 1325 range.select(); 1326 } 1327 1286 1328 this.reset(); 1287 1329 } 1288 1330 else … … 1352 1394 && CKEDITOR.env.webkit 1353 1395 && rangeRequiresFix( range ) ) 1354 1396 { 1355 // Append a zero-width space so WebKit will not try to 1356 // move the selection by itself (#1272). 1357 var fillingChar = createFillingChar( this.document ); 1358 range.insertNode( fillingChar ) ; 1359 1360 var next = fillingChar.getNext(); 1361 1362 // If the filling char is followed by a <br>, whithout 1363 // having something before it, it'll not blink. 1364 // Let's remove it in this case. 1365 if ( next && !fillingChar.getPrevious() && next.type == CKEDITOR.NODE_ELEMENT && next.getName() == 'br' ) 1366 { 1367 removeFillingChar( this.document ); 1368 range.moveToPosition( next, CKEDITOR.POSITION_BEFORE_START ); 1369 } 1370 else 1371 range.moveToPosition( fillingChar, CKEDITOR.POSITION_AFTER_END ); 1372 } 1397 introduceFillingChar( range ); 1398 } 1373 1399 1374 1400 nativeRange.setStart( range.startContainer.$, range.startOffset ); 1375 1401