X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fpastefromword%2Fplugin.js;h=c9bd2ec65d894ee23c92b6fde512af1003b5ad29;hb=1056598c95187351dc58f4991d331e2258d038b5;hp=a5d389665e8533b1f27f9cf687562fabbb9aff3e;hpb=c6e377a02b54abc07129d72b632763c727476a15;p=ckeditor.git diff --git a/_source/plugins/pastefromword/plugin.js b/_source/plugins/pastefromword/plugin.js index a5d3896..c9bd2ec 100644 --- a/_source/plugins/pastefromword/plugin.js +++ b/_source/plugins/pastefromword/plugin.js @@ -1,9 +1,11 @@ /* -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 */ (function() { + function forceHtmlMode( evt ) { evt.data.mode = 'html'; } + CKEDITOR.plugins.add( 'pastefromword', { init : function( editor ) @@ -12,9 +14,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // Flag indicate this command is actually been asked instead of a generic // pasting. var forceFromWord = 0; - var resetFromWord = function() + var resetFromWord = function( evt ) { - setTimeout( function() { forceFromWord = 0; }, 0 ); + evt && evt.removeListener(); + editor.removeListener( 'beforePaste', forceHtmlMode ); + forceFromWord && setTimeout( function() { forceFromWord = 0; }, 0 ); }; // Features bring by this command beside the normal process: @@ -26,15 +30,25 @@ For licensing, see LICENSE.html or http://ckeditor.com/license canUndo : false, exec : function() { + // Ensure the received data format is HTML and apply content filtering. (#6718) forceFromWord = 1; - if ( editor.execCommand( 'paste' ) === false ) + editor.on( 'beforePaste', forceHtmlMode ); + + if ( editor.execCommand( 'paste', 'html' ) === false ) { - editor.on( 'dialogHide', function ( evt ) - { - evt.removeListener(); - resetFromWord(); - }); + editor.on( 'dialogShow', function ( evt ) + { + evt.removeListener(); + evt.data.on( 'cancel', resetFromWord ); + }); + + editor.on( 'dialogHide', function( evt ) + { + evt.data.removeListener( 'cancel', resetFromWord ); + } ); } + + editor.on( 'afterPaste', resetFromWord ); } }); @@ -45,6 +59,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license command : 'pastefromword' }); + editor.on( 'pasteState', function( evt ) + { + editor.getCommand( 'pastefromword' ).setState( evt.data ); + }); + editor.on( 'paste', function( evt ) { var data = evt.data, @@ -87,11 +106,13 @@ For licensing, see LICENSE.html or http://ckeditor.com/license || ( this.path + 'filter/default.js' ) ); // Load with busy indicator. - CKEDITOR.scriptLoader.load( filterFilePath, callback, null, false, true ); + CKEDITOR.scriptLoader.load( filterFilePath, callback, null, true ); } return !isLoaded; - } + }, + + requires : [ 'clipboard' ] }); })();