+ // On WebKit only, we need a special "filling" char on some situations\r
+ // (#1272). Here we set the events that should invalidate that char.\r
+ if ( CKEDITOR.env.webkit )\r
+ {\r
+ editor.on( 'selectionChange', function() { checkFillingChar( editor.document ); } );\r
+ editor.on( 'beforeSetMode', function() { removeFillingChar( editor.document ); } );\r
+ editor.on( 'key', function( e )\r
+ {\r
+ // Remove the filling char before some keys get\r
+ // executed, so they'll not get blocked by it.\r
+ switch ( e.data.keyCode )\r
+ {\r
+ case 13 : // ENTER\r
+ case CKEDITOR.SHIFT + 13 : // SHIFT-ENTER\r
+ case 37 : // LEFT-ARROW\r
+ case 39 : // RIGHT-ARROW\r
+ case 8 : // BACKSPACE\r
+ removeFillingChar( editor.document );\r
+ }\r
+ }, null, null, 10 );\r
+\r
+ var fillingCharBefore,\r
+ resetSelection;\r
+\r
+ function beforeData()\r
+ {\r
+ var doc = editor.document,\r
+ fillingChar = getFillingChar( doc );\r
+\r
+ if ( fillingChar )\r
+ {\r
+ // If cursor is right blinking by side of the filler node, save it for restoring,\r
+ // as the following text substitution will blind it. (#7437)\r
+ var sel = doc.$.defaultView.getSelection();\r
+ if ( sel.type == 'Caret' && sel.anchorNode == fillingChar.$ )\r
+ resetSelection = 1;\r
+\r
+ fillingCharBefore = fillingChar.getText();\r
+ fillingChar.setText( fillingCharBefore.replace( /\u200B/g, '' ) );\r
+ }\r
+ }\r
+ function afterData()\r
+ {\r
+ var doc = editor.document,\r
+ fillingChar = getFillingChar( doc );\r
+\r
+ if ( fillingChar )\r
+ {\r
+ fillingChar.setText( fillingCharBefore );\r
+\r
+ if ( resetSelection )\r
+ {\r
+ doc.$.defaultView.getSelection().setPosition( fillingChar.$,fillingChar.getLength() );\r
+ resetSelection = 0;\r
+ }\r
+ }\r
+ }\r
+ editor.on( 'beforeUndoImage', beforeData );\r
+ editor.on( 'afterUndoImage', afterData );\r
+ editor.on( 'beforeGetData', beforeData, null, null, 0 );\r
+ editor.on( 'getData', afterData );\r
+ }\r
+\r