2 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
\r
3 For licensing, see LICENSE.html or http://ckeditor.com/license
\r
6 CKEDITOR.dialog.add( 'paste', function( editor )
\r
8 var lang = editor.lang.clipboard;
\r
9 var isCustomDomain = CKEDITOR.env.isCustomDomain();
\r
11 function onPasteFrameLoad( win )
\r
13 var doc = new CKEDITOR.dom.document( win.document ),
\r
16 doc.getById( "cke_actscrpt" ).remove();
\r
19 $.body.contentEditable = "true" :
\r
20 $.designMode = "on";
\r
22 CKEDITOR.env.ie && doc.getWindow().on( 'blur', function()
\r
24 $.body.contentEditable = "false";
\r
27 doc.on( "keydown", function( e )
\r
29 var domEvent = e.data,
\r
30 key = domEvent.getKeystroke(),
\r
41 case CKEDITOR.SHIFT + 9 :
\r
42 this.changeFocus( true );
\r
46 processed && domEvent.preventDefault();
\r
49 editor.fire( 'ariaWidget', new CKEDITOR.dom.element( win.frameElement ) );
\r
55 minWidth : CKEDITOR.env.ie && CKEDITOR.env.quirks ? 370 : 350,
\r
56 minHeight : CKEDITOR.env.quirks ? 250 : 245,
\r
59 // FIREFOX BUG: Force the browser to render the dialog to make the to-be-
\r
60 // inserted iframe editable. (#3366)
\r
61 this.parts.dialog.$.offsetHeight;
\r
63 var htmlToLoad = '<!doctype html><html><head><style>body { margin: 3px; height: 95%; } </style></head><body>' +
\r
64 '<script id="cke_actscrpt" type="text/javascript">' +
\r
65 'window.parent.CKEDITOR.tools.callFunction( ' + CKEDITOR.tools.addFunction( onPasteFrameLoad, this ) + ', this );' +
\r
66 '</script></body></html>';
\r
68 var iframe = CKEDITOR.dom.element.createFromHtml(
\r
70 ' frameborder="0" ' +
\r
71 ' allowTransparency="true"' +
\r
72 // Support for custom document.domain in IE.
\r
74 ' src="javascript:void((function(){' +
\r
75 'document.open();' +
\r
76 'document.domain=\'' + document.domain + '\';' +
\r
77 'document.close();' +
\r
80 ' aria-label="' + lang.pasteArea + '"' +
\r
81 ' aria-describedby="' + this.getContentElement( 'general', 'pasteMsg' ).domId + '"' +
\r
82 ' aria-multiple="true"' +
\r
85 iframe.on( 'load', function( e )
\r
88 var doc = iframe.getFrameDocument().$;
\r
89 // Custom domain handling is needed after each document.open().
\r
91 if ( isCustomDomain )
\r
92 doc.domain = document.domain;
\r
93 doc.write( htmlToLoad );
\r
101 'background-color' : 'white',
\r
102 border : '1px solid black'
\r
104 iframe.setCustomData( 'dialog', this );
\r
106 var field = this.getContentElement( 'general', 'editing_area' ),
\r
107 container = field.getElement();
\r
108 container.setHtml( '' );
\r
109 container.append( iframe );
\r
111 field.getInputElement = function(){ return iframe; };
\r
113 // Force container to scale in IE.
\r
114 if ( CKEDITOR.env.ie )
\r
116 container.setStyle( 'display', 'block' );
\r
117 container.setStyle( 'height', ( iframe.$.offsetHeight + 2 ) + 'px' );
\r
121 onHide : function()
\r
123 if ( CKEDITOR.env.ie )
\r
124 this.getParentEditor().document.getBody().$.contentEditable = 'true';
\r
127 onLoad : function()
\r
129 if ( ( CKEDITOR.env.ie7Compat || CKEDITOR.env.ie6Compat ) && editor.lang.dir == 'rtl' )
\r
130 this.parts.contents.setStyle( 'overflow', 'hidden' );
\r
135 var container = this.getContentElement( 'general', 'editing_area' ).getElement(),
\r
136 iframe = container.getElementsByTag( 'iframe' ).getItem( 0 ),
\r
137 editor = this.getParentEditor(),
\r
138 html = iframe.$.contentWindow.document.body.innerHTML;
\r
140 setTimeout( function(){
\r
141 editor.fire( 'paste', { 'html' : html } );
\r
149 label : editor.lang.common.generalTab,
\r
153 id : 'securityMsg',
\r
154 html : '<div style="white-space:normal;width:340px;">' + lang.securityMsg + '</div>'
\r
159 html : '<div style="white-space:normal;width:340px;">'+lang.pasteMsg +'</div>'
\r
163 id : 'editing_area',
\r
164 style : 'width: 100%; height: 100%;',
\r
168 var win = this.getInputElement().$.contentWindow,
\r
169 body = win && win.document.body;
\r
171 // #3291 : JAWS needs the 500ms delay to detect that the editor iframe
\r
172 // iframe is no longer editable. So that it will put the focus into the
\r
173 // Paste from Word dialog's editable area instead.
\r
174 setTimeout( function()
\r
176 // Reactivate design mode for IE to make the cursor blinking.
\r
177 CKEDITOR.env.ie && body && ( body.contentEditable = "true" );
\r