IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
162 | 162 | var fillingChar = doc && doc.removeCustomData( 'cke-fillingChar' ); |
163 | 163 | if ( fillingChar ) |
164 | 164 | { |
| 165 | var bm, |
| 166 | sel = doc.getSelection().getNative(), |
| 167 | // Be error proof. |
| 168 | range = sel && sel.type != 'None' && sel.getRangeAt( 0 ); |
| 169 | |
| 170 | // Text selection position might get mangled by |
| 171 | // subsequent dom modification, save it now for restoring. (#8617) |
| 172 | if ( fillingChar.getLength() > 1 |
| 173 | && range && range.intersectsNode( fillingChar.$ ) ) |
| 174 | { |
| 175 | bm = [ sel.anchorOffset, sel.focusOffset ]; |
| 176 | |
| 177 | // Anticipate the offset change brought by the removed char. |
| 178 | var startAffected = sel.anchorNode == fillingChar.$ && sel.anchorOffset > 0, |
| 179 | endAffected = sel.focusNode == fillingChar.$ && sel.focusOffset > 0; |
| 180 | startAffected && bm[ 0 ]--; |
| 181 | endAffected && bm[ 1 ]--; |
| 182 | |
| 183 | // Revert the bookmark order on reverse selection. |
| 184 | isReversedSelection( sel ) && bm.unshift( bm.pop() ); |
| 185 | } |
| 186 | |
165 | 187 | // We can't simply remove the filling node because the user |
166 | 188 | // will actually enlarge it when typing, so we just remove the |
167 | 189 | // invisible char from it. |
168 | 190 | fillingChar.setText( fillingChar.getText().replace( /\u200B/g, '' ) ); |
169 | | fillingChar = 0; |
170 | | } |
171 | | } |
| 191 | |
| 192 | // Restore the bookmark. |
| 193 | if ( bm ) |
| 194 | { |
| 195 | var rng = sel.getRangeAt( 0 ); |
| 196 | rng.setStart( rng.startContainer, bm[ 0 ] ); |
| 197 | rng.setEnd( rng.startContainer, bm[ 1 ] ); |
| 198 | sel.removeAllRanges(); |
| 199 | sel.addRange( rng ); |
| 200 | } |
| 201 | } |
| 202 | } |
172 | 203 | |
| 204 | function isReversedSelection( sel ) |
| 205 | { |
| 206 | if ( !sel.isCollapsed ) |
| 207 | { |
| 208 | var range = sel.getRangeAt( 0 ); |
| 209 | // Potentially alter an reversed selection range. |
| 210 | range.setStart( sel.anchorNode, sel.anchorOffset ); |
| 211 | range.setEnd( sel.focusNode, sel.focusOffset ); |
| 212 | return range.collapsed; |
| 213 | } |
| 214 | } |
| 215 | |
173 | 216 | CKEDITOR.plugins.add( 'selection', |
174 | 217 | { |
175 | 218 | init : function( editor ) |
… |
… |
|
180 | 223 | { |
181 | 224 | editor.on( 'selectionChange', function() { checkFillingChar( editor.document ); } ); |
182 | 225 | editor.on( 'beforeSetMode', function() { removeFillingChar( editor.document ); } ); |
183 | | editor.on( 'key', function( e ) |
184 | | { |
185 | | // Remove the filling char before some keys get |
186 | | // executed, so they'll not get blocked by it. |
187 | | switch ( e.data.keyCode ) |
188 | | { |
189 | | case 13 : // ENTER |
190 | | case CKEDITOR.SHIFT + 13 : // SHIFT-ENTER |
191 | | case 37 : // LEFT-ARROW |
192 | | case 39 : // RIGHT-ARROW |
193 | | case 8 : // BACKSPACE |
194 | | removeFillingChar( editor.document ); |
195 | | } |
196 | | }, null, null, 10 ); |
197 | 226 | |
198 | 227 | var fillingCharBefore, |
199 | 228 | resetSelection; |
… |
… |
|
517 | 546 | doc.on( 'mouseup', checkSelectionChangeTimeout, editor ); |
518 | 547 | doc.on( 'keyup', checkSelectionChangeTimeout, editor ); |
519 | 548 | doc.on( 'selectionchange', checkSelectionChangeTimeout, editor ); |
| 549 | } |
| 550 | |
| 551 | if ( CKEDITOR.env.webkit ) |
| 552 | { |
| 553 | doc.on( 'keydown', function( evt ) |
| 554 | { |
| 555 | var key = evt.data.getKey(); |
| 556 | // Remove the filling char before some keys get |
| 557 | // executed, so they'll not get blocked by it. |
| 558 | switch ( key ) |
| 559 | { |
| 560 | case 13 : // ENTER |
| 561 | case 33 : // PAGEUP |
| 562 | case 34 : // PAGEDOWN |
| 563 | case 35 : // HOME |
| 564 | case 36 : // END |
| 565 | case 37 : // LEFT-ARROW |
| 566 | case 39 : // RIGHT-ARROW |
| 567 | case 8 : // BACKSPACE |
| 568 | case 45 : // INS |
| 569 | case 46 : // DEl |
| 570 | removeFillingChar( editor.document ); |
| 571 | } |
| 572 | |
| 573 | }, null, null, 10 ); |
520 | 574 | } |
521 | 575 | }); |
522 | 576 | |