/*\r
-Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
For licensing, see LICENSE.html or http://ckeditor.com/license\r
*/\r
\r
\r
init : function( editor )\r
{\r
- var sourcearea = CKEDITOR.plugins.sourcearea;\r
+ var sourcearea = CKEDITOR.plugins.sourcearea,\r
+ win = CKEDITOR.document.getWindow();\r
\r
editor.on( 'editingBlockReady', function()\r
{\r
textarea.setAttributes(\r
{\r
dir : 'ltr',\r
- tabIndex : -1\r
+ tabIndex : CKEDITOR.env.webkit ? -1 : editor.tabIndex,\r
+ 'role' : 'textbox',\r
+ 'aria-label' : editor.lang.editorTitle.replace( '%1', editor.name )\r
});\r
textarea.addClass( 'cke_source' );\r
+ textarea.addClass( 'cke_enable_context_menu' );\r
\r
var styles =\r
{\r
'text-align' : 'left'\r
};\r
\r
- // The textarea height/width='100%' doesn't\r
- // constraint to the 'td' in IE strick mode\r
+ // Having to make <textarea> fixed sized to conque the following bugs:\r
+ // 1. The textarea height/width='100%' doesn't constraint to the 'td' in IE6/7.\r
+ // 2. Unexpected vertical-scrolling behavior happens whenever focus is moving out of editor\r
+ // if text content within it has overflowed. (#4762)\r
if ( CKEDITOR.env.ie )\r
{\r
- if ( !CKEDITOR.env.ie8Compat )\r
+ onResize = function()\r
{\r
- onResize = function()\r
- {\r
- // Holder rectange size is stretched by textarea,\r
- // so hide it just for a moment.\r
- textarea.hide();\r
- textarea.setStyle( 'height', holderElement.$.clientHeight + 'px' );\r
- // When we have proper holder size, show textarea again.\r
- textarea.show();\r
- };\r
- editor.on( 'resize', onResize );\r
- styles.height = holderElement.$.clientHeight + 'px';\r
- }\r
+ // Holder rectange size is stretched by textarea,\r
+ // so hide it just for a moment.\r
+ textarea.hide();\r
+ textarea.setStyle( 'height', holderElement.$.clientHeight + 'px' );\r
+ textarea.setStyle( 'width', holderElement.$.clientWidth + 'px' );\r
+ // When we have proper holder size, show textarea again.\r
+ textarea.show();\r
+ };\r
+\r
+ editor.on( 'resize', onResize );\r
+ win.on( 'resize', onResize );\r
+ setTimeout( onResize, 0 );\r
}\r
- else\r
+ // As we prevent click to put focus on editor container,\r
+ // while 'mousedown' inside <textarea> is also captured,\r
+ // but we must stop the even propagation, otherwise\r
+ // it's not possible to place the caret inside of it (non IE and IE9).\r
+ if ( document.addEventListener )\r
{\r
- // By some yet unknown reason, we must stop the\r
- // mousedown propagation for the textarea,\r
- // otherwise it's not possible to place the caret\r
- // inside of it (non IE).\r
textarea.on( 'mousedown', function( evt )\r
{\r
- evt = evt.data.$;\r
- if ( evt.stopPropagation )\r
- evt.stopPropagation();\r
+ evt.data.stopPropagation();\r
} );\r
}\r
\r
holderElement.append( textarea );\r
textarea.setStyles( styles );\r
\r
+ editor.fire( 'ariaWidget', textarea );\r
+\r
+ textarea.on( 'blur', function()\r
+ {\r
+ editor.focusManager.blur();\r
+ });\r
+\r
+ textarea.on( 'focus', function()\r
+ {\r
+ editor.focusManager.focus();\r
+ });\r
+\r
// The editor data "may be dirty" after this point.\r
editor.mayBeDirty = true;\r
\r
loadData : function( data )\r
{\r
textarea.setValue( data );\r
+ editor.fire( 'dataReady' );\r
},\r
\r
getData : function()\r
\r
unload : function( holderElement )\r
{\r
+ textarea.clearCustomData();\r
editor.textarea = textarea = null;\r
\r
if ( onResize )\r
+ {\r
editor.removeListener( 'resize', onResize );\r
+ win.removeListener( 'resize', onResize );\r
+ }\r
\r
if ( CKEDITOR.env.ie && CKEDITOR.env.version < 8 )\r
holderElement.removeStyle( 'position' );\r
source :\r
{\r
modes : { wysiwyg:1, source:1 },\r
+ editorFocus : false,\r
\r
exec : function( editor )\r
{\r