2 Copyright (c) 2003-2011, 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 var script = doc.getById( 'cke_actscrpt' );
\r
17 script && script.remove();
\r
20 docElement.body.contentEditable = "true" :
\r
21 docElement.designMode = "on";
\r
23 // IE before version 8 will leave cursor blinking inside the document after
\r
24 // editor blurred unless we clean up the selection. (#4716)
\r
25 if ( CKEDITOR.env.ie && CKEDITOR.env.version < 8 )
\r
27 doc.getWindow().on( 'blur', function()
\r
29 docElement.selection.empty();
\r
33 doc.on( "keydown", function( e )
\r
35 var domEvent = e.data,
\r
36 key = domEvent.getKeystroke(),
\r
47 case CKEDITOR.SHIFT + 9 :
\r
48 this.changeFocus( true );
\r
52 processed && domEvent.preventDefault();
\r
55 editor.fire( 'ariaWidget', new CKEDITOR.dom.element( win.frameElement ) );
\r
61 minWidth : CKEDITOR.env.ie && CKEDITOR.env.quirks ? 370 : 350,
\r
62 minHeight : CKEDITOR.env.quirks ? 250 : 245,
\r
65 // FIREFOX BUG: Force the browser to render the dialog to make the to-be-
\r
66 // inserted iframe editable. (#3366)
\r
67 this.parts.dialog.$.offsetHeight;
\r
70 '<html dir="' + editor.config.contentsLangDirection + '"' +
\r
71 ' lang="' + ( editor.config.contentsLanguage || editor.langCode ) + '">' +
\r
72 '<head><style>body { margin: 3px; height: 95%; } </style></head><body>' +
\r
73 '<script id="cke_actscrpt" type="text/javascript">' +
\r
74 'window.parent.CKEDITOR.tools.callFunction( ' + CKEDITOR.tools.addFunction( onPasteFrameLoad, this ) + ', this );' +
\r
75 '</script></body>' +
\r
80 'javascript:void(0)' :
\r
82 'javascript:void((function(){' +
\r
83 'document.open();' +
\r
84 'document.domain=\'' + document.domain + '\';' +
\r
85 'document.close();' +
\r
90 var iframe = CKEDITOR.dom.element.createFromHtml(
\r
92 ' class="cke_pasteframe"' +
\r
93 ' frameborder="0" ' +
\r
94 ' allowTransparency="true"' +
\r
95 ' src="' + src + '"' +
\r
97 ' aria-label="' + lang.pasteArea + '"' +
\r
98 ' aria-describedby="' + this.getContentElement( 'general', 'pasteMsg' ).domId + '"' +
\r
99 ' aria-multiple="true"' +
\r
102 iframe.on( 'load', function( e )
\r
104 e.removeListener();
\r
106 var doc = iframe.getFrameDocument();
\r
107 doc.write( htmlToLoad );
\r
109 if ( CKEDITOR.env.air )
\r
110 onPasteFrameLoad.call( this, doc.getWindow().$ );
\r
114 iframe.setCustomData( 'dialog', this );
\r
116 var field = this.getContentElement( 'general', 'editing_area' ),
\r
117 container = field.getElement();
\r
118 container.setHtml( '' );
\r
119 container.append( iframe );
\r
121 // IE need a redirect on focus to make
\r
122 // the cursor blinking inside iframe. (#5461)
\r
123 if ( CKEDITOR.env.ie )
\r
125 var focusGrabber = CKEDITOR.dom.element.createFromHtml( '<span tabindex="-1" style="position:absolute;" role="presentation"></span>' );
\r
126 focusGrabber.on( 'focus', function()
\r
128 iframe.$.contentWindow.focus();
\r
130 container.append( focusGrabber );
\r
132 // Override focus handler on field.
\r
133 field.focus = function()
\r
135 focusGrabber.focus();
\r
136 this.fire( 'focus' );
\r
140 field.getInputElement = function(){ return iframe; };
\r
142 // Force container to scale in IE.
\r
143 if ( CKEDITOR.env.ie )
\r
145 container.setStyle( 'display', 'block' );
\r
146 container.setStyle( 'height', ( iframe.$.offsetHeight + 2 ) + 'px' );
\r
150 onHide : function()
\r
152 if ( CKEDITOR.env.ie )
\r
153 this.getParentEditor().document.getBody().$.contentEditable = 'true';
\r
156 onLoad : function()
\r
158 if ( ( CKEDITOR.env.ie7Compat || CKEDITOR.env.ie6Compat ) && editor.lang.dir == 'rtl' )
\r
159 this.parts.contents.setStyle( 'overflow', 'hidden' );
\r
164 var container = this.getContentElement( 'general', 'editing_area' ).getElement(),
\r
165 iframe = container.getElementsByTag( 'iframe' ).getItem( 0 ),
\r
166 editor = this.getParentEditor(),
\r
167 html = iframe.$.contentWindow.document.body.innerHTML;
\r
169 setTimeout( function(){
\r
170 editor.fire( 'paste', { 'html' : html } );
\r
178 label : editor.lang.common.generalTab,
\r
182 id : 'securityMsg',
\r
183 html : '<div style="white-space:normal;width:340px;">' + lang.securityMsg + '</div>'
\r
188 html : '<div style="white-space:normal;width:340px;">'+lang.pasteMsg +'</div>'
\r
192 id : 'editing_area',
\r
193 style : 'width: 100%; height: 100%;',
\r
197 var win = this.getInputElement().$.contentWindow;
\r
199 // #3291 : JAWS needs the 500ms delay to detect that the editor iframe
\r
200 // iframe is no longer editable. So that it will put the focus into the
\r
201 // Paste from Word dialog's editable area instead.
\r
202 setTimeout( function()
\r