Ticket #8617: 8617_4.patch
File 8617_4.patch, 2.3 KB (added by , 12 years ago) |
---|
-
_source/plugins/selection/plugin.js
162 162 var fillingChar = doc && doc.removeCustomData( 'cke-fillingChar' ); 163 163 if ( fillingChar ) 164 164 { 165 var sel = doc.getSelection(); 166 // Text selection position might get mangled by 167 // subsequent dom modification. #8617[1] 168 var bm = getFixedBookmark(doc, sel); 165 169 // We can't simply remove the filling node because the user 166 170 // will actually enlarge it when typing, so we just remove the 167 171 // invisible char from it. 168 172 fillingChar.setText( fillingChar.getText().replace( /\u200B/g, '' ) ); 169 fillingChar = 0;173 bm && sel.selectBookmarks( [ bm ] ); 170 174 } 171 175 } 172 176 177 function getFixedBookmark ( doc, sel ) 178 { 179 var nativeSel = sel.getNative(); 180 if ( nativeSel.type != 'None' ) 181 { 182 var bm = sel.createBookmarks2()[ 0 ]; 183 184 if ( nativeSel.anchorNode && nativeSel.anchorNode.data ) 185 { 186 var anchorFillingCharIndex = nativeSel.anchorNode.data.indexOf( '\u200B' ); 187 if ( nativeSel.anchorOffset > anchorFillingCharIndex ) 188 bm.startOffset--; 189 } 190 191 if ( nativeSel.focusNode && nativeSel.focusNode.data ) 192 { 193 var focusFillingCharIndex = nativeSel.focusNode.data.indexOf( '\u200B' ); 194 if ( !nativeSel.isCollapsed && nativeSel.focusOffset > focusFillingCharIndex ) 195 bm.endOffset--; 196 } 197 } 198 return bm; 199 } 200 173 201 CKEDITOR.plugins.add( 'selection', 174 202 { 175 203 init : function( editor ) … … 186 214 // executed, so they'll not get blocked by it. 187 215 switch ( e.data.keyCode ) 188 216 { 189 case 13 : // ENTER190 217 case CKEDITOR.SHIFT + 13 : // SHIFT-ENTER 191 case 37 : // LEFT-ARROW 192 case 39 : // RIGHT-ARROW 193 case 8 : // BACKSPACE 218 case 13 : // ENTER 219 case 33 : // PAGEUP 220 case 34 : // PAGEDOWN 221 case 35 : // HOME 222 case 36 : // END 223 case 37 : // LEFT-ARROW 224 case 39 : // RIGHT-ARROW 225 case 8 : // BACKSPACE 226 case 45 : // INS 227 case 46 : // DEl 194 228 removeFillingChar( editor.document ); 195 229 } 196 230 }, null, null, 10 );