X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Ftab%2Fplugin.js;h=c2646feca61f12bd9bd27cf7f08b35bd75aef5a5;hb=refs%2Ftags%2Fv3.2;hp=f2adcf99499c0eaa22540a48644688b147624904;hpb=c6e377a02b54abc07129d72b632763c727476a15;p=ckeditor.git diff --git a/_source/plugins/tab/plugin.js b/_source/plugins/tab/plugin.js index f2adcf9..c2646fe 100644 --- a/_source/plugins/tab/plugin.js +++ b/_source/plugins/tab/plugin.js @@ -15,7 +15,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { exec : function( editor ) { - editor.container.focusNext( true ); + editor.container.focusNext( true, editor.tabIndex ); } }; @@ -23,7 +23,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { exec : function( editor ) { - editor.container.focusPrevious( true ); + editor.container.focusPrevious( true, editor.tabIndex ); } }; @@ -33,54 +33,43 @@ For licensing, see LICENSE.html or http://ckeditor.com/license init : function( editor ) { - // Register the keystrokes. - var keystrokes = editor.keystrokeHandler.keystrokes; - keystrokes[ 9 /* TAB */ ] = 'tab'; - keystrokes[ CKEDITOR.SHIFT + 9 /* TAB */ ] = 'shiftTab'; - - var tabSpaces = editor.config.tabSpaces, + var tabSpaces = editor.config.tabSpaces || 0, tabText = ''; while ( tabSpaces-- ) tabText += '\xa0'; - // Register the "tab" and "shiftTab" commands. - editor.addCommand( 'tab', CKEDITOR.tools.extend( - { - exec : function( editor ) + if ( tabText ) + { + editor.on( 'key', function( ev ) { - // Fire the "tab" event, making it possible to - // customize the TAB key behavior on specific cases. - if ( !editor.fire( 'tab' ) ) + if ( ev.data.keyCode == 9 ) // TAB { - if ( tabText.length > 0 ) - editor.insertHtml( tabText ); - else - { - // All browsers jump to the next field on TAB, - // except Safari, so we have to do that manually - // here. - /// https://bugs.webkit.org/show_bug.cgi?id=20597 - return editor.execCommand( 'blur' ); - } + editor.insertHtml( tabText ); + ev.cancel(); } + }); + } - return true; - } - }, meta ) ); - - editor.addCommand( 'shiftTab', CKEDITOR.tools.extend( - { - exec : function( editor ) + if ( CKEDITOR.env.webkit ) + { + editor.on( 'key', function( ev ) { - // Fire the "tab" event, making it possible to - // customize the TAB key behavior on specific cases. - if ( !editor.fire( 'shiftTab' ) ) - return editor.execCommand( 'blurBack' ); + var keyCode = ev.data.keyCode; - return true; - } - }, meta ) ); + if ( keyCode == 9 && !tabText ) // TAB + { + ev.cancel(); + editor.execCommand( 'blur' ); + } + + if ( keyCode == ( CKEDITOR.SHIFT + 9 ) ) // SHIFT+TAB + { + editor.execCommand( 'blurBack' ); + ev.cancel(); + } + }); + } editor.addCommand( 'blur', CKEDITOR.tools.extend( blurCommand, meta ) ); editor.addCommand( 'blurBack', CKEDITOR.tools.extend( blurBackCommand, meta ) ); @@ -95,10 +84,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license * var element = CKEDITOR.document.getById( 'example' ); * element.focusNext(); */ -CKEDITOR.dom.element.prototype.focusNext = function( ignoreChildren ) +CKEDITOR.dom.element.prototype.focusNext = function( ignoreChildren, indexToUse ) { var $ = this.$, - curTabIndex = this.getTabIndex(), + curTabIndex = ( indexToUse === undefined ? this.getTabIndex() : indexToUse ), passedCurrent, enteredCurrent, elected, electedTabIndex, element, elementTabIndex; @@ -183,10 +172,10 @@ CKEDITOR.dom.element.prototype.focusNext = function( ignoreChildren ) * var element = CKEDITOR.document.getById( 'example' ); * element.focusPrevious(); */ -CKEDITOR.dom.element.prototype.focusPrevious = function( ignoreChildren ) +CKEDITOR.dom.element.prototype.focusPrevious = function( ignoreChildren, indexToUse ) { var $ = this.$, - curTabIndex = this.getTabIndex(), + curTabIndex = ( indexToUse === undefined ? this.getTabIndex() : indexToUse ), passedCurrent, enteredCurrent, elected, electedTabIndex = 0, @@ -264,9 +253,9 @@ CKEDITOR.dom.element.prototype.focusPrevious = function( ignoreChildren ) * Intructs the editor to add a number of spaces ( ) to the text when * hitting the TAB key. If set to zero, the TAB key will be used to move the * cursor focus to the next element in the page, out of the editor focus. + * @name CKEDITOR.config.tabSpaces * @type Number * @default 0 * @example * config.tabSpaces = 4; */ -CKEDITOR.config.tabSpaces = 0 ;