Skip to content

Commit

Permalink
Fixed editor tab index.
Browse files Browse the repository at this point in the history
  • Loading branch information
Garry Yao committed May 21, 2012
1 parent 2db2670 commit 11f4494
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 15 deletions.
4 changes: 0 additions & 4 deletions core/creators/themedui.js
Expand Up @@ -305,7 +305,6 @@ CKEDITOR.replaceClass = 'ckeditor';
' class="{id} cke cke_chrome cke_editor_{name}"' +
' dir="{langDir}"' +
' lang="{langCode}"' +
( CKEDITOR.env.webkit ? ' tabindex="{tabIndex}"' : '' ) +
' role="application"' +
' aria-labelledby="cke_{name}_arialbl" {style}>' +
'<span id="cke_{name}_arialbl" class="cke_voice_label">{voiceLabel}</span>' +
Expand Down Expand Up @@ -334,8 +333,6 @@ CKEDITOR.replaceClass = 'ckeditor';

var height = editor.config.height;

var tabIndex = editor.config.tabIndex || editor.element.getAttribute( 'tabindex' ) || 0;

// The editor height is considered only if the contents space got filled.
if ( !isNaN( height ) )
height += 'px';
Expand All @@ -356,7 +353,6 @@ CKEDITOR.replaceClass = 'ckeditor';
langDir: editor.lang.dir,
langCode: editor.langCode,
voiceLabel: editor.lang.editor,
tabIndex: tabIndex,
style: ( style ? ' style="' + style + '"' : '' ),
height: height,
width: width,
Expand Down
12 changes: 12 additions & 0 deletions core/editable.js
Expand Up @@ -402,6 +402,13 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
this.setAttribute( 'dir', dir );
}

// Apply tab index on demand, with original direction saved.
if ( editor.document.equals( CKEDITOR.document ) && this.getAttribute( 'tabIndex' ) != editor.tabIndex ) {
var orgTabIndex = this.getAttribute( 'dir' ) || this.getAttribute( 'tabIndex' );
this.setCustomData( 'org_tabindex_saved', orgTabIndex );
this.setAttribute( 'tabIndex', editor.tabIndex );
}

// Create the content stylesheet for this document.
var styles = CKEDITOR.getCss();
if ( styles ) {
Expand Down Expand Up @@ -541,6 +548,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
if ( orgDir !== null )
orgDir ? this.setAttribute( 'dir', orgDir ) : this.removeAttribute( 'dir' );

// Restore original tab index.
var orgTabIndex = this.removeCustomData( 'org_tabindex_saved' );
if ( orgTabIndex !== null )
orgTabIndex ? this.setAttribute( 'tabIndex', orgTabIndex ) : this.removeAttribute( 'tabIndex' );

// Cleanup our custom classes.
var classes;
if ( classes = this.removeCustomData( 'classes' ) ) {
Expand Down
14 changes: 14 additions & 0 deletions core/editor.js
Expand Up @@ -210,6 +210,20 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
*/
editor.blockless = editor.elementMode == CKEDITOR.ELEMENT_MODE_INLINE && !CKEDITOR.dtd[ editor.element.getName() ][ 'p' ];

/**
* The <a href="http://en.wikipedia.org/wiki/Tabbing_navigation">tabbing
* navigation</a> order determined for this editor instance.
* This can be set by the <code>{@link CKEDITOR.config.tabIndex}</code>
* setting or taken from the <code>tabindex</code> attribute of the
* <code>{@link #element}</code> associated with the editor.
* @name CKEDITOR.editor.prototype.tabIndex
* @type Number
* @default 0 (zero)
* @example
* alert( editor.tabIndex ); // E.g. "0"
*/
editor.tabIndex = editor.config.tabIndex || editor.element && editor.element.getAttribute( 'tabindex' ) || 0;

// Fire the "configLoaded" event.
editor.fireOnce( 'configLoaded' );

Expand Down
13 changes: 2 additions & 11 deletions plugins/wysiwygarea/plugin.js
Expand Up @@ -76,7 +76,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
frameBorder: 0,
title: frameLabel,
src: src,
tabIndex: CKEDITOR.env.webkit ? -1 : editor.tabIndex,
tabIndex: editor.tabIndex,
allowTransparency: 'true'
});

Expand Down Expand Up @@ -122,7 +122,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license

body.spellcheck = !editor.config.disableNativeSpellChecker;

var editable = !editor.readOnly;
body.contentEditable = !editor.readOnly;

if ( CKEDITOR.env.ie ) {
// Don't display the focus border.
Expand All @@ -131,16 +131,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
// Disable and re-enable the body to avoid IE from
// taking the editing focus at startup. (#141 / #523)
body.disabled = true;
body.contentEditable = editable;
body.removeAttribute( 'disabled' );
} else {
// Prefer 'contentEditable' instead of 'designMode'. (#3593)
if ( CKEDITOR.env.gecko && CKEDITOR.env.version >= 10900 || CKEDITOR.env.opera )
doc.body.contentEditable = editable;
else if ( CKEDITOR.env.webkit )
doc.body.parentNode.contentEditable = editable;
else
doc.designMode = editable ? 'off' : 'on';
}

delete this._.isLoadingData;
Expand Down
1 change: 1 addition & 0 deletions samples/replacebyclass.html
Expand Up @@ -56,6 +56,7 @@
'sourcearea,' +
'specialchar,' +
'stylescombo,' +
'tab,' +
'table,' +
'templates,' +
'undo,' +
Expand Down
1 change: 1 addition & 0 deletions samples/replacebycode.html
Expand Up @@ -54,6 +54,7 @@
'sourcearea,' +
'specialchar,' +
'stylescombo,' +
'tab,' +
'table,' +
'templates,' +
'undo,' +
Expand Down

0 comments on commit 11f4494

Please sign in to comment.