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 ) ; }
this is the bit that deals with replacing the tab with X spaces:
while ( tabSpaces-- ) this.TabText += '\xa0' ;
I also think it would be most useful if this could natively be done in FCKEditor for a future release.
Thanks in advance to anyone who helps
Kind regards,
Scott
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)?
Hi ya,

I could do that, but i was looking for a cleaner way of doing it since that code is in the internals of the FCKEditor (and is compressed). Meaning each time i apply an update i will have to keep re-applying that patch.
Also, i do not want any whitespace to show outside of pre tags so that's alright
Kind regards,
Scott
Re: How to insert tabs (not &nbsp;'s)?
Re: How to insert tabs (not &nbsp;'s)?
Done it: http://dev.fckeditor.net/ticket/2740
Also, since i will be using pre tags to show data i do not want 's anyway. Since i only strip them out and replace them with a normal space. So technically i do not need nbsp's at all. I just need a tab.
Kind regards,
Scott