X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fplugins%2Fclipboard%2Fdialogs%2Fpaste.js;h=9a659edac23823612c5e760aac4f83979954e970;hp=e0813ec9b84628c67f3d5529bb2983a459112faa;hb=1056598c95187351dc58f4991d331e2258d038b5;hpb=4e90e78dc97789709ee7404359a5517540c27553 diff --git a/_source/plugins/clipboard/dialogs/paste.js b/_source/plugins/clipboard/dialogs/paste.js index e0813ec..9a659ed 100644 --- a/_source/plugins/clipboard/dialogs/paste.js +++ b/_source/plugins/clipboard/dialogs/paste.js @@ -66,85 +66,7 @@ CKEDITOR.dialog.add( 'paste', function( editor ) // inserted iframe editable. (#3366) this.parts.dialog.$.offsetHeight; - 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(); - doc.write( htmlToLoad ); - - if ( CKEDITOR.env.air ) - onPasteFrameLoad.call( this, doc.getWindow().$ ); - }, - this ); - - iframe.setCustomData( 'dialog', this ); - - var field = this.getContentElement( 'general', 'editing_area' ), - container = field.getElement(); - 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. - if ( CKEDITOR.env.ie ) - { - container.setStyle( 'display', 'block' ); - container.setStyle( 'height', ( iframe.$.offsetHeight + 2 ) + 'px' ); - } + this.setupContent(); }, onHide : function() @@ -161,20 +83,7 @@ CKEDITOR.dialog.add( 'paste', function( editor ) onOk : function() { - var container = this.getContentElement( 'general', 'editing_area' ).getElement(), - iframe = container.getElementsByTag( 'iframe' ).getItem( 0 ), - editor = this.getParentEditor(), - 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 } ); - }, 0 ); - + this.commitContent(); }, contents : [ @@ -208,6 +117,103 @@ CKEDITOR.dialog.add( 'paste', function( editor ) { win.focus(); }, 500 ); + }, + setup : function() + { + var dialog = this.getDialog(); + 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(); + doc.write( htmlToLoad ); + + if ( CKEDITOR.env.air ) + onPasteFrameLoad.call( this, doc.getWindow().$ ); + }, dialog ); + + iframe.setCustomData( 'dialog', dialog ); + + var container = this.getElement(); + 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. + this.focus = function() + { + focusGrabber.focus(); + this.fire( 'focus' ); + }; + } + + this.getInputElement = function(){ return iframe; }; + + // Force container to scale in IE. + if ( CKEDITOR.env.ie ) + { + container.setStyle( 'display', 'block' ); + container.setStyle( 'height', ( iframe.$.offsetHeight + 2 ) + 'px' ); + } + }, + commit : function( data ) + { + var container = this.getElement(), + editor = this.getDialog().getParentEditor(), + body = this.getInputElement().getFrameDocument().getBody(), + bogus = body.getBogus(), + html; + bogus && bogus.remove(); + + // Saving the contents so changes until paste is complete will not take place (#7500) + html = body.getHtml(); + + setTimeout( function(){ + editor.fire( 'paste', { 'html' : html } ); + }, 0 ); } } ]