X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fplugins%2Fclipboard%2Fdialogs%2Fpaste.js;h=70527ad46db6b335ca261a642c9fe615c34cf039;hp=89038922ea581988dd46fe932cb5532ab4a4ddd2;hb=059b4c2fef02528bf1af189f7996e80652faddfb;hpb=c6e377a02b54abc07129d72b632763c727476a15 diff --git a/_source/plugins/clipboard/dialogs/paste.js b/_source/plugins/clipboard/dialogs/paste.js index 8903892..70527ad 100644 --- a/_source/plugins/clipboard/dialogs/paste.js +++ b/_source/plugins/clipboard/dialogs/paste.js @@ -5,44 +5,94 @@ For licensing, see LICENSE.html or http://ckeditor.com/license CKEDITOR.dialog.add( 'paste', function( editor ) { + var lang = editor.lang.clipboard; var isCustomDomain = CKEDITOR.env.isCustomDomain(); + function onPasteFrameLoad( win ) + { + var doc = new CKEDITOR.dom.document( win.document ), + $ = doc.$; + + doc.getById( "cke_actscrpt" ).remove(); + + CKEDITOR.env.ie ? + $.body.contentEditable = "true" : + $.designMode = "on"; + + CKEDITOR.env.ie && doc.getWindow().on( 'blur', function() + { + $.body.contentEditable = "false"; + } ); + + doc.on( "keydown", function( e ) + { + var domEvent = e.data, + key = domEvent.getKeystroke(), + processed; + + switch( key ) + { + case 27 : + this.hide(); + processed = 1; + break; + + case 9 : + case CKEDITOR.SHIFT + 9 : + this.changeFocus( true ); + processed = 1; + } + + processed && domEvent.preventDefault(); + }, this ); + + editor.fire( 'ariaWidget', new CKEDITOR.dom.element( win.frameElement ) ); + } + return { - title : editor.lang.clipboard.title, + title : lang.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; + var htmlToLoad = '' + + ''; + + var iframe = CKEDITOR.dom.element.createFromHtml( + '' ); + + iframe.on( 'load', function( e ) + { + e.removeListener(); + var doc = iframe.getFrameDocument().$; + // Custom domain handling is needed after each document.open(). + doc.open(); + if ( isCustomDomain ) + doc.domain = document.domain; + doc.write( htmlToLoad ); + doc.close(); + }, this ); iframe.setStyles( { @@ -53,48 +103,18 @@ CKEDITOR.dialog.add( 'paste', function( editor ) } ); iframe.setCustomData( 'dialog', this ); - var accTitle = lang.editorTitle.replace( '%1', lang.clipboard.title ); + var field = this.getContentElement( 'general', 'editing_area' ), + container = field.getElement(); + container.setHtml( '' ); + container.append( iframe ); + + field.getInputElement = function(){ return iframe; }; + // Force container to scale in IE. 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( 'display', 'block' ); 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(); } }, @@ -131,32 +151,31 @@ CKEDITOR.dialog.add( 'paste', function( editor ) { type : 'html', id : 'securityMsg', - html : '
' + editor.lang.clipboard.securityMsg + '
' + html : '
' + lang.securityMsg + '
' }, { type : 'html', id : 'pasteMsg', - html : '
'+editor.lang.clipboard.pasteMsg +'
' + html : '
'+lang.pasteMsg +'
' }, { type : 'html', id : 'editing_area', style : 'width: 100%; height: 100%;', - html : '
', + html : '', focus : function() { - var div = this.getElement(); - var iframe = div.getElementsByTag( 'iframe' ); - if ( iframe.count() < 1 ) - return; - iframe = iframe.getItem( 0 ); + var win = this.getInputElement().$.contentWindow, + body = win && win.document.body; // #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(); + // Reactivate design mode for IE to make the cursor blinking. + CKEDITOR.env.ie && body && ( body.contentEditable = "true" ); + win.focus(); }, 500 ); } }