ghostCoder
ghostCoder

Reputation: 7655

How do backspace and delete work in CKEditor?

How do the backspace and delete keys work in CKEditor? If I have an iframe in the editable area, and have my cursor next to it, hitting backspace/delete deletes the iframe/removes its HTML code from there.

What I was unable to get was where is the code for this behavior? Where on hitting backspace the range is shrunken to the iframe and it was removed.

Please point me in the right direction of where this happens in the source code.

Upvotes: 1

Views: 2846

Answers (1)

Gowri
Gowri

Reputation: 16845

There is something about delete

oKeystrokeHandler.SetKeystrokes

But i don't about that behavior

var FCKEnterKey = function( targetWindow, enterMode, shiftEnterMode, tabSpaces ) 
{
   this.Window         = targetWindow ;
   this.EnterMode      = enterMode || 'p' ;
   this.ShiftEnterMode   = shiftEnterMode || 'br' ;

   // Setup the Keystroke Handler.
   var oKeystrokeHandler = new FCKKeystrokeHandler( false ) ;
   oKeystrokeHandler._EnterKey = this ;
   oKeystrokeHandler.OnKeystroke = FCKEnterKey_OnKeystroke ;

   oKeystrokeHandler.SetKeystrokes( [
      [ 13      , 'Enter' ],
      [ SHIFT + 13, 'ShiftEnter' ],
      [ 8         , 'Backspace' ],
      [ CTRL + 8   , 'CtrlBackspace' ],
      [ 46      , 'Delete' ]
   ] ) ;

   this.TabText = '' ;

   // Safari by default inserts 4 spaces on TAB, while others make the editor
   // loose focus. So, we need to handle it here to not include those spaces.
   if ( tabSpaces > 0 || FCKBrowserInfo.IsSafari )
   {
      while ( tabSpaces-- )
         this.TabText += '\xa0' ;

      oKeystrokeHandler.SetKeystrokes( [ 9, 'Tab' ] );
   }

   oKeystrokeHandler.AttachToElement( targetWindow.document ) ;
}

http://code.google.com/p/easyfckeditor/source/browse/trunk/src/main/java/oh/how/easy/fck/js/fckeditor/editor/_source/classes/fckenterkey.js?r=2

Upvotes: 1

Related Questions