2 Copyright (c) 2003-2009, 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 isCustomDomain = CKEDITOR.env.isCustomDomain();
\r
11 title : editor.lang.clipboard.title,
\r
13 minWidth : CKEDITOR.env.ie && CKEDITOR.env.quirks ? 370 : 350,
\r
14 minHeight : CKEDITOR.env.quirks ? 250 : 245,
\r
15 htmlToLoad : '<!doctype html><script type="text/javascript">'
\r
16 + 'window.onload = function()'
\r
18 + 'if ( ' + CKEDITOR.env.ie + ' ) '
\r
19 + 'document.body.contentEditable = "true";'
\r
21 + 'document.designMode = "on";'
\r
22 + 'var iframe = new window.parent.CKEDITOR.dom.element( frameElement );'
\r
23 + 'var dialog = iframe.getCustomData( "dialog" );'
\r
25 + 'iframe.getFrameDocument().on( "keydown", function( e )\
\r
27 if ( e.data.getKeystroke() == 27 )\
\r
31 + '</script><style>body { margin: 3px; height: 95%; } </style><body></body>',
\r
35 if ( CKEDITOR.env.ie )
\r
36 this.getParentEditor().document.getBody().$.contentEditable = 'false';
\r
38 // FIREFOX BUG: Force the browser to render the dialog to make the to-be-
\r
39 // inserted iframe editable. (#3366)
\r
40 this.parts.dialog.$.offsetHeight;
\r
42 var container = this.getContentElement( 'general', 'editing_area' ).getElement(),
\r
43 iframe = CKEDITOR.dom.element.createFromHtml( '<iframe src="javascript:void(0)" frameborder="0" allowtransparency="1"></iframe>' );
\r
45 var lang = this.getParentEditor().lang;
\r
51 'background-color' : 'white',
\r
52 border : '1px solid black'
\r
54 iframe.setCustomData( 'dialog', this );
\r
56 var accTitle = lang.editorTitle.replace( '%1', lang.clipboard.title );
\r
58 if ( CKEDITOR.env.ie )
\r
59 container.setHtml( '<legend style="position:absolute;top:-1000000px;left:-1000000px;">'
\r
60 + CKEDITOR.tools.htmlEncode( accTitle )
\r
64 container.setHtml( '' );
\r
65 container.setAttributes(
\r
70 iframe.setAttributes(
\r
76 container.append( iframe );
\r
77 if ( CKEDITOR.env.ie )
\r
78 container.setStyle( 'height', ( iframe.$.offsetHeight + 2 ) + 'px' );
\r
80 if ( isCustomDomain )
\r
82 CKEDITOR._cke_htmlToLoad = this.definition.htmlToLoad;
\r
83 iframe.setAttribute( 'src',
\r
84 'javascript:void( (function(){' +
\r
85 'document.open();' +
\r
86 'document.domain="' + document.domain + '";' +
\r
87 'document.write( window.parent.CKEDITOR._cke_htmlToLoad );' +
\r
88 'delete window.parent.CKEDITOR._cke_htmlToLoad;' +
\r
89 'document.close();' +
\r
94 var doc = iframe.$.contentWindow.document;
\r
96 doc.write( this.definition.htmlToLoad );
\r
101 onHide : function()
\r
103 if ( CKEDITOR.env.ie )
\r
104 this.getParentEditor().document.getBody().$.contentEditable = 'true';
\r
107 onLoad : function()
\r
109 if ( ( CKEDITOR.env.ie7Compat || CKEDITOR.env.ie6Compat ) && editor.lang.dir == 'rtl' )
\r
110 this.parts.contents.setStyle( 'overflow', 'hidden' );
\r
115 var container = this.getContentElement( 'general', 'editing_area' ).getElement(),
\r
116 iframe = container.getElementsByTag( 'iframe' ).getItem( 0 ),
\r
117 editor = this.getParentEditor(),
\r
118 html = iframe.$.contentWindow.document.body.innerHTML;
\r
120 setTimeout( function(){
\r
121 editor.insertHtml( html );
\r
129 label : editor.lang.common.generalTab,
\r
133 id : 'securityMsg',
\r
134 html : '<div style="white-space:normal;width:340px;">' + editor.lang.clipboard.securityMsg + '</div>'
\r
139 html : '<div style="white-space:normal;width:340px;">'+editor.lang.clipboard.pasteMsg +'</div>'
\r
143 id : 'editing_area',
\r
144 style : 'width: 100%; height: 100%;',
\r
145 html : '<fieldset></fieldset>',
\r
148 var div = this.getElement();
\r
149 var iframe = div.getElementsByTag( 'iframe' );
\r
150 if ( iframe.count() < 1 )
\r
152 iframe = iframe.getItem( 0 );
\r
154 // #3291 : JAWS needs the 500ms delay to detect that the editor iframe
\r
155 // iframe is no longer editable. So that it will put the focus into the
\r
156 // Paste from Word dialog's editable area instead.
\r
157 setTimeout( function()
\r
159 iframe.$.contentWindow.focus();
\r