Ticket #6718: 6718_3.patch

File 6718_3.patch, 4.5 KB (added by Garry Yao, 13 years ago)
  • ../3.6.x/_source/plugins/clipboard/plugin.js

     
    214214
    215215                // Turn off design mode temporarily before give focus to the paste bin.
    216216                if ( mode == 'text' )
    217                 {
    218                         if ( CKEDITOR.env.ie )
    219                         {
    220                                 var ieRange = doc.getBody().$.createTextRange();
    221                                 ieRange.moveToElementText( pastebin.$ );
    222                                 ieRange.execCommand( 'Paste' );
    223                                 evt.data.preventDefault();
    224                         }
    225                         else
    226                                 pastebin.$.focus();
    227                 }
     217                        pastebin.$.focus();
    228218                else
    229219                {
    230220                        range.setStartAt( pastebin, CKEDITOR.POSITION_AFTER_START );
     
    377367
    378368                                editor.on( 'key', onKey, editor );
    379369
    380                                 var mode = editor.config.forcePasteAsPlainText ? 'text' : 'html';
    381 
    382370                                // We'll be catching all pasted content in one line, regardless of whether the
    383371                                // it's introduced by a document command execution (e.g. toolbar buttons) or
    384372                                // user paste behaviors. (e.g. Ctrl-V)
    385373                                editor.on( 'contentDom', function()
    386374                                {
    387375                                        var body = editor.document.getBody();
    388                                         body.on( ( ( mode == 'text' && CKEDITOR.env.ie ) || CKEDITOR.env.webkit ) ? 'paste' : 'beforepaste',
    389                                                 function( evt )
     376                                        body.on( 'beforepaste', function( evt )
    390377                                                {
    391378                                                        if ( depressBeforeEvent )
    392379                                                                return;
    393380
    394                                                         getClipboardData.call( editor, evt, mode, function ( data )
     381                                                        // Fire 'beforePaste' event so clipboard flavor get customized
     382                                                        // by other plugins.
     383                                                        var eventData =  { mode : 'html' };
     384                                                        editor.fire( 'beforePaste', eventData );
     385
     386                                                        getClipboardData.call( editor, evt, eventData.mode, function ( data )
    395387                                                        {
    396388                                                                // The very last guard to make sure the
    397389                                                                // paste has successfully happened.
     
    399391                                                                        return;
    400392
    401393                                                                var dataTransfer = {};
    402                                                                 dataTransfer[ mode ] = data;
     394                                                                dataTransfer[ eventData.mode ] = data;
    403395                                                                editor.fire( 'paste', dataTransfer );
    404396                                                        } );
    405397                                                });
  • ../3.6.x/_source/plugins/pastetext/plugin.js

     
    5858                                // Intercept the default pasting process.
    5959                                editor.on( 'beforeCommandExec', function ( evt )
    6060                                {
    61                                         if ( evt.data.name == 'paste' )
     61                                        var mode = evt.data.commandData;
     62                                        // Do NOT overwrite if HTML format is explicitly requested.
     63                                        if ( evt.data.name == 'paste' && mode != 'html' )
    6264                                        {
    6365                                                editor.execCommand( 'pastetext' );
    6466                                                evt.cancel();
    6567                                        }
    6668                                }, null, null, 0 );
     69
     70                                editor.on( 'beforePaste', function( evt )
     71                                {
     72                                        evt.data.mode = 'text';
     73                                });
    6774                        }
    6875
    6976                        editor.on( 'pasteState', function( evt )
     
    8289 * Whether to force all pasting operations to insert on plain text into the
    8390 * editor, loosing any formatting information possibly available in the source
    8491 * text.
     92 * <strong>Note:</strong> paste from word is not affected by this configuration.
    8593 * @name CKEDITOR.config.forcePasteAsPlainText
    8694 * @type Boolean
    8795 * @default false
  • ../3.6.x/_source/plugins/pastefromword/plugin.js

     
    1 ?/*
     1/*
    22Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
    33For licensing, see LICENSE.html or http://ckeditor.com/license
    44*/
    55(function()
    66{
     7        function forceHtmlMode( evt ) { evt.data.mode = 'html'; }
     8
    79        CKEDITOR.plugins.add( 'pastefromword',
    810        {
    911                init : function( editor )
     
    1517                        var resetFromWord = function( evt )
    1618                                {
    1719                                        evt && evt.removeListener();
     20                                        editor.removeListener( 'beforePaste', forceHtmlMode );
    1821                                        forceFromWord && setTimeout( function() { forceFromWord = 0; }, 0 );
    1922                                };
    2023
     
    2730                                canUndo : false,
    2831                                exec : function()
    2932                                {
     33                                        // Ensure the received data format is HTML and apply content filtering. (#6718)
    3034                                        forceFromWord = 1;
    31                                         if ( editor.execCommand( 'paste' ) === false )
     35                                        editor.on( 'beforePaste', forceHtmlMode );
     36
     37                                        if ( editor.execCommand( 'paste', 'html' ) === false )
    3238                                        {
    3339                                                editor.on( 'dialogShow', function ( evt )
    3440                                                {
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy