Hi ya,
While in rich text edit mode on the editor, i want want it so that when the user presses their tab key, it actually inserts a tab (and not spaces).
The reason is that when they press a tab it will show it as a tab since they will be inside <pre> tags. When people want to display source code they do not want to have to keep deleting spaces all the time and trying to align them up again.
I have managed to do it by hacking the source, but i would really like it to be done via the plugin option.
This is the code that deals with the insertion of tabs.
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 ) ; }
Re: How to insert tabs (not &nbsp;'s)?
this.TabText += '\xa0' ;
with
this.TabText = '\t' ;
to keep the tabs, but the it probably won't be exactly what you expect. Outside of <pre>'s the browser will collapse multiple tabs into a single space, so it will appear that nothing happens when you hit the tab key.
Done right, the editor would check the context and would insert non-breakable spaces outside of <pre> and would keep tabs inside. Unfortunately, this is not the case and I always use the source mode when pasting code (after encoding angle brackets, ampersands and replacing tabs with regular spaces (0x20)).
Re: How to insert tabs (not &nbsp;'s)?
Re: How to insert tabs (not &nbsp;'s)?
Re: How to insert tabs (not &nbsp;'s)?