2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.html or http://ckeditor.com/license
6 CKEDITOR
.dialog
.add( 'paste', function( editor
)
8 var lang
= editor
.lang
.clipboard
;
9 var isCustomDomain
= CKEDITOR
.env
.isCustomDomain();
11 function onPasteFrameLoad( win
)
13 var doc
= new CKEDITOR
.dom
.document( win
.document
),
16 var script
= doc
.getById( 'cke_actscrpt' );
17 script
&& script
.remove();
20 docElement
.body
.contentEditable
= "true" :
21 docElement
.designMode
= "on";
23 // IE before version 8 will leave cursor blinking inside the document after
24 // editor blurred unless we clean up the selection. (#4716)
25 if ( CKEDITOR
.env
.ie
&& CKEDITOR
.env
.version
< 8 )
27 doc
.getWindow().on( 'blur', function()
29 docElement
.selection
.empty();
33 doc
.on( "keydown", function( e
)
35 var domEvent
= e
.data
,
36 key
= domEvent
.getKeystroke(),
47 case CKEDITOR
.SHIFT
+ 9 :
48 this.changeFocus( true );
52 processed
&& domEvent
.preventDefault();
55 editor
.fire( 'ariaWidget', new CKEDITOR
.dom
.element( win
.frameElement
) );
61 minWidth
: CKEDITOR
.env
.ie
&& CKEDITOR
.env
.quirks
? 370 : 350,
62 minHeight
: CKEDITOR
.env
.quirks
? 250 : 245,
65 // FIREFOX BUG: Force the browser to render the dialog to make the to-be-
66 // inserted iframe editable. (#3366)
67 this.parts
.dialog
.$.offsetHeight
;
74 if ( CKEDITOR
.env
.ie
)
75 this.getParentEditor().document
.getBody().$.contentEditable
= 'true';
80 if ( ( CKEDITOR
.env
.ie7Compat
|| CKEDITOR
.env
.ie6Compat
) && editor
.lang
.dir
== 'rtl' )
81 this.parts
.contents
.setStyle( 'overflow', 'hidden' );
92 label
: editor
.lang
.common
.generalTab
,
97 html
: '<div style="white-space:normal;width:340px;">' + lang
.securityMsg
+ '</div>'
102 html
: '<div style="white-space:normal;width:340px;">'+lang
.pasteMsg
+'</div>'
107 style
: 'width: 100%; height: 100%;',
111 var win
= this.getInputElement().$.contentWindow
;
113 // #3291 : JAWS needs the 500ms delay to detect that the editor iframe
114 // iframe is no longer editable. So that it will put the focus into the
115 // Paste from Word dialog's editable area instead.
116 setTimeout( function()
123 var dialog
= this.getDialog();
125 '<html dir="' + editor
.config
.contentsLangDirection
+ '"' +
126 ' lang="' + ( editor
.config
.contentsLanguage
|| editor
.langCode
) + '">' +
127 '<head><style>body { margin: 3px; height: 95%; } </style></head><body>' +
128 '<script id="cke_actscrpt" type="text/javascript">' +
129 'window.parent.CKEDITOR.tools.callFunction( ' + CKEDITOR
.tools
.addFunction( onPasteFrameLoad
, dialog
) + ', this );' +
135 'javascript:void(0)' :
137 'javascript:void((function(){' +
139 'document.domain=\'' + document
.domain
+ '\';' +
140 'document.close();' +
145 var iframe
= CKEDITOR
.dom
.element
.createFromHtml(
147 ' class="cke_pasteframe"' +
148 ' frameborder="0" ' +
149 ' allowTransparency="true"' +
150 ' src="' + src
+ '"' +
152 ' aria-label="' + lang
.pasteArea
+ '"' +
153 ' aria-describedby="' + dialog
.getContentElement( 'general', 'pasteMsg' ).domId
+ '"' +
154 ' aria-multiple="true"' +
157 iframe
.on( 'load', function( e
)
161 var doc
= iframe
.getFrameDocument();
162 doc
.write( htmlToLoad
);
164 if ( CKEDITOR
.env
.air
)
165 onPasteFrameLoad
.call( this, doc
.getWindow().$ );
168 iframe
.setCustomData( 'dialog', dialog
);
170 var container
= this.getElement();
171 container
.setHtml( '' );
172 container
.append( iframe
);
174 // IE need a redirect on focus to make
175 // the cursor blinking inside iframe. (#5461)
176 if ( CKEDITOR
.env
.ie
)
178 var focusGrabber
= CKEDITOR
.dom
.element
.createFromHtml( '<span tabindex="-1" style="position:absolute;" role="presentation"></span>' );
179 focusGrabber
.on( 'focus', function()
181 iframe
.$.contentWindow
.focus();
183 container
.append( focusGrabber
);
185 // Override focus handler on field.
186 this.focus = function()
188 focusGrabber
.focus();
189 this.fire( 'focus' );
193 this.getInputElement = function(){ return iframe
; };
195 // Force container to scale in IE.
196 if ( CKEDITOR
.env
.ie
)
198 container
.setStyle( 'display', 'block' );
199 container
.setStyle( 'height', ( iframe
.$.offsetHeight
+ 2 ) + 'px' );
202 commit : function( data
)
204 var container
= this.getElement(),
205 editor
= this.getDialog().getParentEditor(),
206 body
= this.getInputElement().getFrameDocument().getBody(),
207 bogus
= body
.getBogus(),
209 bogus
&& bogus
.remove();
211 // Saving the contents so changes until paste is complete will not take place (#7500)
212 html
= body
.getHtml();
214 setTimeout( function(){
215 editor
.fire( 'paste', { 'html' : html
} );