/*\r
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
For licensing, see LICENSE.html or http://ckeditor.com/license\r
*/\r
\r
CKEDITOR.dialog.add( 'paste', function( editor )\r
{\r
+ var lang = editor.lang.clipboard;\r
var isCustomDomain = CKEDITOR.env.isCustomDomain();\r
\r
+ function onPasteFrameLoad( win )\r
+ {\r
+ var doc = new CKEDITOR.dom.document( win.document ),\r
+ docElement = doc.$;\r
+\r
+ var script = doc.getById( 'cke_actscrpt' );\r
+ script && script.remove();\r
+\r
+ CKEDITOR.env.ie ?\r
+ docElement.body.contentEditable = "true" :\r
+ docElement.designMode = "on";\r
+\r
+ // IE before version 8 will leave cursor blinking inside the document after\r
+ // editor blurred unless we clean up the selection. (#4716)\r
+ if ( CKEDITOR.env.ie && CKEDITOR.env.version < 8 )\r
+ {\r
+ doc.getWindow().on( 'blur', function()\r
+ {\r
+ docElement.selection.empty();\r
+ } );\r
+ }\r
+\r
+ doc.on( "keydown", function( e )\r
+ {\r
+ var domEvent = e.data,\r
+ key = domEvent.getKeystroke(),\r
+ processed;\r
+\r
+ switch( key )\r
+ {\r
+ case 27 :\r
+ this.hide();\r
+ processed = 1;\r
+ break;\r
+\r
+ case 9 :\r
+ case CKEDITOR.SHIFT + 9 :\r
+ this.changeFocus( true );\r
+ processed = 1;\r
+ }\r
+\r
+ processed && domEvent.preventDefault();\r
+ }, this );\r
+\r
+ editor.fire( 'ariaWidget', new CKEDITOR.dom.element( win.frameElement ) );\r
+ }\r
+\r
return {\r
- title : editor.lang.clipboard.title,\r
+ title : lang.title,\r
\r
minWidth : CKEDITOR.env.ie && CKEDITOR.env.quirks ? 370 : 350,\r
minHeight : CKEDITOR.env.quirks ? 250 : 245,\r
- htmlToLoad : '<!doctype html><script type="text/javascript">'\r
- + 'window.onload = function()'\r
- + '{'\r
- + 'if ( ' + CKEDITOR.env.ie + ' ) '\r
- + 'document.body.contentEditable = "true";'\r
- + 'else '\r
- + 'document.designMode = "on";'\r
- + 'var iframe = new window.parent.CKEDITOR.dom.element( frameElement );'\r
- + 'var dialog = iframe.getCustomData( "dialog" );'\r
- + ''\r
- + 'iframe.getFrameDocument().on( "keydown", function( e )\\r
- {\\r
- if ( e.data.getKeystroke() == 27 )\\r
- dialog.hide();\\r
- });'\r
- + '};'\r
- + '</script><style>body { margin: 3px; height: 95%; } </style><body></body>',\r
-\r
onShow : function()\r
{\r
- if ( CKEDITOR.env.ie )\r
- this.getParentEditor().document.getBody().$.contentEditable = 'false';\r
-\r
// FIREFOX BUG: Force the browser to render the dialog to make the to-be-\r
// inserted iframe editable. (#3366)\r
this.parts.dialog.$.offsetHeight;\r
\r
- var container = this.getContentElement( 'general', 'editing_area' ).getElement(),\r
- iframe = CKEDITOR.dom.element.createFromHtml( '<iframe src="javascript:void(0)" frameborder="0" allowtransparency="1"></iframe>' );\r
+ var htmlToLoad =\r
+ '<html dir="' + editor.config.contentsLangDirection + '"' +\r
+ ' lang="' + ( editor.config.contentsLanguage || editor.langCode ) + '">' +\r
+ '<head><style>body { margin: 3px; height: 95%; } </style></head><body>' +\r
+ '<script id="cke_actscrpt" type="text/javascript">' +\r
+ 'window.parent.CKEDITOR.tools.callFunction( ' + CKEDITOR.tools.addFunction( onPasteFrameLoad, this ) + ', this );' +\r
+ '</script></body>' +\r
+ '</html>';\r
+\r
+ var src =\r
+ CKEDITOR.env.air ?\r
+ 'javascript:void(0)' :\r
+ isCustomDomain ?\r
+ 'javascript:void((function(){' +\r
+ 'document.open();' +\r
+ 'document.domain=\'' + document.domain + '\';' +\r
+ 'document.close();' +\r
+ '})())"'\r
+ :\r
+ '';\r
+\r
+ var iframe = CKEDITOR.dom.element.createFromHtml(\r
+ '<iframe' +\r
+ ' class="cke_pasteframe"' +\r
+ ' frameborder="0" ' +\r
+ ' allowTransparency="true"' +\r
+ ' src="' + src + '"' +\r
+ ' role="region"' +\r
+ ' aria-label="' + lang.pasteArea + '"' +\r
+ ' aria-describedby="' + this.getContentElement( 'general', 'pasteMsg' ).domId + '"' +\r
+ ' aria-multiple="true"' +\r
+ '></iframe>' );\r
+\r
+ iframe.on( 'load', function( e )\r
+ {\r
+ e.removeListener();\r
\r
- var lang = this.getParentEditor().lang;\r
+ var doc = iframe.getFrameDocument();\r
+ doc.write( htmlToLoad );\r
+\r
+ if ( CKEDITOR.env.air )\r
+ onPasteFrameLoad.call( this, doc.getWindow().$ );\r
+ },\r
+ this );\r
\r
- iframe.setStyles(\r
- {\r
- width : '346px',\r
- height : '130px',\r
- 'background-color' : 'white',\r
- border : '1px solid black'\r
- } );\r
iframe.setCustomData( 'dialog', this );\r
\r
- var accTitle = lang.editorTitle.replace( '%1', lang.clipboard.title );\r
+ var field = this.getContentElement( 'general', 'editing_area' ),\r
+ container = field.getElement();\r
+ container.setHtml( '' );\r
+ container.append( iframe );\r
\r
+ // IE need a redirect on focus to make\r
+ // the cursor blinking inside iframe. (#5461)\r
if ( CKEDITOR.env.ie )\r
- container.setHtml( '<legend style="position:absolute;top:-1000000px;left:-1000000px;">'\r
- + CKEDITOR.tools.htmlEncode( accTitle )\r
- + '</legend>' );\r
- else\r
{\r
- container.setHtml( '' );\r
- container.setAttributes(\r
- {\r
- role : 'region',\r
- title : accTitle\r
- } );\r
- iframe.setAttributes(\r
- {\r
- role : 'region',\r
- title : ' '\r
- } );\r
- }\r
- container.append( iframe );\r
- if ( CKEDITOR.env.ie )\r
- container.setStyle( 'height', ( iframe.$.offsetHeight + 2 ) + 'px' );\r
+ var focusGrabber = CKEDITOR.dom.element.createFromHtml( '<span tabindex="-1" style="position:absolute;" role="presentation"></span>' );\r
+ focusGrabber.on( 'focus', function()\r
+ {\r
+ iframe.$.contentWindow.focus();\r
+ });\r
+ container.append( focusGrabber );\r
\r
- if ( isCustomDomain )\r
- {\r
- CKEDITOR._cke_htmlToLoad = this.definition.htmlToLoad;\r
- iframe.setAttribute( 'src',\r
- 'javascript:void( (function(){' +\r
- 'document.open();' +\r
- 'document.domain="' + document.domain + '";' +\r
- 'document.write( window.parent.CKEDITOR._cke_htmlToLoad );' +\r
- 'delete window.parent.CKEDITOR._cke_htmlToLoad;' +\r
- 'document.close();' +\r
- '})() )' );\r
+ // Override focus handler on field.\r
+ field.focus = function()\r
+ {\r
+ focusGrabber.focus();\r
+ this.fire( 'focus' );\r
+ };\r
}\r
- else\r
+\r
+ field.getInputElement = function(){ return iframe; };\r
+\r
+ // Force container to scale in IE.\r
+ if ( CKEDITOR.env.ie )\r
{\r
- var doc = iframe.$.contentWindow.document;\r
- doc.open();\r
- doc.write( this.definition.htmlToLoad );\r
- doc.close();\r
+ container.setStyle( 'display', 'block' );\r
+ container.setStyle( 'height', ( iframe.$.offsetHeight + 2 ) + 'px' );\r
}\r
},\r
\r
{\r
type : 'html',\r
id : 'securityMsg',\r
- html : '<div style="white-space:normal;width:340px;">' + editor.lang.clipboard.securityMsg + '</div>'\r
+ html : '<div style="white-space:normal;width:340px;">' + lang.securityMsg + '</div>'\r
},\r
{\r
type : 'html',\r
id : 'pasteMsg',\r
- html : '<div style="white-space:normal;width:340px;">'+editor.lang.clipboard.pasteMsg +'</div>'\r
+ html : '<div style="white-space:normal;width:340px;">'+lang.pasteMsg +'</div>'\r
},\r
{\r
type : 'html',\r
id : 'editing_area',\r
style : 'width: 100%; height: 100%;',\r
- html : '<fieldset></fieldset>',\r
+ html : '',\r
focus : function()\r
{\r
- var div = this.getElement();\r
- var iframe = div.getElementsByTag( 'iframe' );\r
- if ( iframe.count() < 1 )\r
- return;\r
- iframe = iframe.getItem( 0 );\r
+ var win = this.getInputElement().$.contentWindow;\r
\r
// #3291 : JAWS needs the 500ms delay to detect that the editor iframe\r
// iframe is no longer editable. So that it will put the focus into the\r
// Paste from Word dialog's editable area instead.\r
setTimeout( function()\r
{\r
- iframe.$.contentWindow.focus();\r
+ win.focus();\r
}, 500 );\r
}\r
}\r