X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fclipboard%2Fdialogs%2Fpaste.js;h=e0813ec9b84628c67f3d5529bb2983a459112faa;hb=4e90e78dc97789709ee7404359a5517540c27553;hp=70527ad46db6b335ca261a642c9fe615c34cf039;hpb=059b4c2fef02528bf1af189f7996e80652faddfb;p=ckeditor.git diff --git a/_source/plugins/clipboard/dialogs/paste.js b/_source/plugins/clipboard/dialogs/paste.js index 70527ad..e0813ec 100644 --- a/_source/plugins/clipboard/dialogs/paste.js +++ b/_source/plugins/clipboard/dialogs/paste.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -10,19 +10,25 @@ CKEDITOR.dialog.add( 'paste', function( editor ) function onPasteFrameLoad( win ) { - var doc = new CKEDITOR.dom.document( win.document ), - $ = doc.$; + var doc = new CKEDITOR.dom.document( win.document ), + docElement = doc.$; - doc.getById( "cke_actscrpt" ).remove(); + var script = doc.getById( 'cke_actscrpt' ); + script && script.remove(); CKEDITOR.env.ie ? - $.body.contentEditable = "true" : - $.designMode = "on"; + docElement.body.contentEditable = "true" : + docElement.designMode = "on"; - CKEDITOR.env.ie && doc.getWindow().on( 'blur', function() + // IE before version 8 will leave cursor blinking inside the document after + // editor blurred unless we clean up the selection. (#4716) + if ( CKEDITOR.env.ie && CKEDITOR.env.version < 8 ) { - $.body.contentEditable = "false"; - } ); + doc.getWindow().on( 'blur', function() + { + docElement.selection.empty(); + } ); + } doc.on( "keydown", function( e ) { @@ -60,22 +66,33 @@ CKEDITOR.dialog.add( 'paste', function( editor ) // inserted iframe editable. (#3366) this.parts.dialog.$.offsetHeight; - var htmlToLoad = '' + - ''; + var htmlToLoad = + '' + + '' + + '' + + ''; + + var src = + CKEDITOR.env.air ? + 'javascript:void(0)' : + isCustomDomain ? + 'javascript:void((function(){' + + 'document.open();' + + 'document.domain=\'' + document.domain + '\';' + + 'document.close();' + + '})())"' + : + ''; 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( { - width : '346px', - height : '130px', - 'background-color' : 'white', - border : '1px solid black' - } ); + e.removeListener(); + + var doc = iframe.getFrameDocument(); + doc.write( htmlToLoad ); + + if ( CKEDITOR.env.air ) + onPasteFrameLoad.call( this, doc.getWindow().$ ); + }, + this ); + iframe.setCustomData( 'dialog', this ); var field = this.getContentElement( 'general', 'editing_area' ), @@ -108,6 +118,25 @@ CKEDITOR.dialog.add( 'paste', function( editor ) container.setHtml( '' ); container.append( iframe ); + // IE need a redirect on focus to make + // the cursor blinking inside iframe. (#5461) + if ( CKEDITOR.env.ie ) + { + var focusGrabber = CKEDITOR.dom.element.createFromHtml( '' ); + focusGrabber.on( 'focus', function() + { + iframe.$.contentWindow.focus(); + }); + container.append( focusGrabber ); + + // Override focus handler on field. + field.focus = function() + { + focusGrabber.focus(); + this.fire( 'focus' ); + }; + } + field.getInputElement = function(){ return iframe; }; // Force container to scale in IE. @@ -135,7 +164,12 @@ CKEDITOR.dialog.add( 'paste', function( editor ) var container = this.getContentElement( 'general', 'editing_area' ).getElement(), iframe = container.getElementsByTag( 'iframe' ).getItem( 0 ), editor = this.getParentEditor(), - html = iframe.$.contentWindow.document.body.innerHTML; + body = iframe.getFrameDocument().getBody(), + bogus = body.getBogus(), + html; + bogus && bogus.remove(); + // Saving the contents in variable so changes until paste is complete will not take place (#7500) + html = body.getHtml(); setTimeout( function(){ editor.fire( 'paste', { 'html' : html } ); @@ -165,16 +199,13 @@ CKEDITOR.dialog.add( 'paste', function( editor ) html : '', focus : function() { - var win = this.getInputElement().$.contentWindow, - body = win && win.document.body; + var win = this.getInputElement().$.contentWindow; // #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() { - // Reactivate design mode for IE to make the cursor blinking. - CKEDITOR.env.ie && body && ( body.contentEditable = "true" ); win.focus(); }, 500 ); }