X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fclipboard%2Fdialogs%2Fpaste.js;fp=_source%2Fplugins%2Fclipboard%2Fdialogs%2Fpaste.js;h=a9e2c8287305867ef8085a855675106df3d60d4d;hb=ea7e3453c7b0f023b050aca6d9f83ab372860d91;hp=0000000000000000000000000000000000000000;hpb=b93873b6532ee7515fb0d6f8b73176c44fad28f7;p=ckeditor.git diff --git a/_source/plugins/clipboard/dialogs/paste.js b/_source/plugins/clipboard/dialogs/paste.js new file mode 100644 index 0000000..a9e2c82 --- /dev/null +++ b/_source/plugins/clipboard/dialogs/paste.js @@ -0,0 +1,167 @@ +/* +Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. +For licensing, see LICENSE.html or http://ckeditor.com/license +*/ + +CKEDITOR.dialog.add( 'paste', function( editor ) +{ + var isCustomDomain = CKEDITOR.env.ie && document.domain != window.location.hostname; + + return { + title : editor.lang.clipboard.title, + + minWidth : CKEDITOR.env.ie && CKEDITOR.env.quirks ? 370 : 350, + minHeight : CKEDITOR.env.quirks ? 250 : 245, + htmlToLoad : '', + + onShow : function() + { + if ( CKEDITOR.env.ie ) + this.getParentEditor().document.getBody().$.contentEditable = 'false'; + + // FIREFOX BUG: Force the browser to render the dialog to make the to-be- + // inserted iframe editable. (#3366) + this.parts.dialog.$.offsetHeight; + + var container = this.getContentElement( 'general', 'editing_area' ).getElement(), + iframe = CKEDITOR.dom.element.createFromHtml( '' ); + + var lang = this.getParentEditor().lang; + + iframe.setStyles( + { + width : '346px', + height : '130px', + 'background-color' : 'white', + border : '1px solid black' + } ); + iframe.setCustomData( 'dialog', this ); + + var accTitle = lang.editorTitle.replace( '%1', lang.clipboard.title ); + + if ( CKEDITOR.env.ie ) + container.setHtml( '' + + CKEDITOR.tools.htmlEncode( accTitle ) + + '' ); + else + { + container.setHtml( '' ); + container.setAttributes( + { + role : 'region', + title : accTitle + } ); + iframe.setAttributes( + { + role : 'region', + title : ' ' + } ); + } + container.append( iframe ); + if ( CKEDITOR.env.ie ) + container.setStyle( 'height', ( iframe.$.offsetHeight + 2 ) + 'px' ); + + if ( isCustomDomain ) + { + CKEDITOR._cke_htmlToLoad = this.definition.htmlToLoad; + iframe.setAttribute( 'src', + 'javascript:void( (function(){' + + 'document.open();' + + 'document.domain="' + document.domain + '";' + + 'document.write( window.parent.CKEDITOR._cke_htmlToLoad );' + + 'delete window.parent.CKEDITOR._cke_htmlToLoad;' + + 'document.close();' + + '})() )' ); + } + else + { + var doc = iframe.$.contentWindow.document; + doc.open(); + doc.write( this.definition.htmlToLoad ); + doc.close(); + } + }, + + onHide : function() + { + if ( CKEDITOR.env.ie ) + this.getParentEditor().document.getBody().$.contentEditable = 'true'; + }, + + onLoad : function() + { + if ( ( CKEDITOR.env.ie7Compat || CKEDITOR.env.ie6Compat ) && editor.lang.dir == 'rtl' ) + this.parts.contents.setStyle( 'overflow', 'hidden' ); + }, + + onOk : function() + { + var container = this.getContentElement( 'general', 'editing_area' ).getElement(), + iframe = container.getElementsByTag( 'iframe' ).getItem( 0 ), + editor = this.getParentEditor(), + html = iframe.$.contentWindow.document.body.innerHTML; + + setTimeout( function(){ + editor.insertHtml( html ); + }, 0 ); + + }, + + contents : [ + { + id : 'general', + label : editor.lang.common.generalTab, + elements : [ + { + type : 'html', + id : 'securityMsg', + html : '
' + editor.lang.clipboard.securityMsg + '
' + }, + { + type : 'html', + id : 'pasteMsg', + html : '
'+editor.lang.clipboard.pasteMsg +'
' + }, + { + type : 'html', + id : 'editing_area', + style : 'width: 100%; height: 100%;', + html : '
', + focus : function() + { + var div = this.getElement(); + var iframe = div.getElementsByTag( 'iframe' ); + if ( iframe.count() < 1 ) + return; + iframe = iframe.getItem( 0 ); + + // #3291 : JAWS needs the 500ms delay to detect that the editor iframe + // iframe is no longer editable. So that it will put the focus into the + // Paste from Word dialog's editable area instead. + setTimeout( function() + { + iframe.$.contentWindow.focus(); + }, 500 ); + } + } + ] + } + ] + }; +});