X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fclipboard%2Fdialogs%2Fpaste.js;h=cec04d387972a8038b569a67f25b6bb6e3b734d8;hb=2f22c0c38f17e75be5541089076885442aaa2377;hp=6923afbbaf4786167fc721406c2490d4c199462c;hpb=9afde8772159bd3436f1f5b7862960307710ae5a;p=ckeditor.git diff --git a/_source/plugins/clipboard/dialogs/paste.js b/_source/plugins/clipboard/dialogs/paste.js index 6923afb..cec04d3 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-2012, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -45,7 +45,7 @@ CKEDITOR.dialog.add( 'paste', function( editor ) case 9 : case CKEDITOR.SHIFT + 9 : - this.changeFocus( true ); + this.changeFocus( 1 ); processed = 1; } @@ -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,15 +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(), - html = iframe.$.contentWindow.document.body.innerHTML; - - setTimeout( function(){ - editor.fire( 'paste', { 'html' : html } ); - }, 0 ); - + this.commitContent(); }, contents : [ @@ -203,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 ); } } ]