Ticket #3659: 3659.patch

File 3659.patch, 2.5 KB (added by Garry Yao, 15 years ago)
  • _source/plugins/newpage/plugin.js

     
    1818
    1919                                exec : function( editor )
    2020                                {
     21                                        var command = this;
     22                                        function afterCommand()
     23                                        {
     24                                                // Defer to happen after 'selectionChange'.
     25                                                setTimeout( function()
     26                                                {
     27                                                        editor.fire( 'afterCommandExec',
     28                                                        {
     29                                                                name: command.name,
     30                                                                command: command
     31                                                        } );
     32                                                }, 500 );
     33                                        }
     34                                        if ( editor.mode == 'wysiwyg')
     35                                                editor.on( 'contentDom', function( evt ){
     36
     37                                                        evt.removeListener();
     38                                afterCommand();
     39                                                } );
     40
    2141                                        editor.setData( editor.config.newpage_html );
    2242                                        editor.focus();
    23                                 }
     43
     44                                        if( editor.mode == 'source' )
     45                                                afterCommand();
     46
     47                                },
     48                                async : true
    2449                        });
    2550
    2651                editor.ui.addButton( 'NewPage',
  • _source/core/editor.js

     
    477477                                {
    478478                                        eventData.returnValue = command.exec( eventData.commandData );
    479479
    480                                         if ( this.fire( 'afterCommandExec', eventData ) !== true )
     480                                        // Fire the 'afterCommandExec' immedidately only if command is synchronous.
     481                                        if ( !command.async && this.fire( 'afterCommandExec', eventData ) !== true )
    481482                                                return eventData.returnValue;
    482483                                }
    483484                        }
  • _source/core/commanddefinition.js

     
    5252 *     canUndo : false    // No support for undo/redo
    5353 * });
    5454 */
     55
     56/**
     57 * Whether the command is asynchronous, which means the 'afterCommandExec' event
     58 * will be fired by the command itself manually, and the 'exec' function return value
     59 * of this command is meaningless.
     60 * @name  CKEDITOR.commandDefinition.async
     61 * @type {Boolean} If defined as 'true', the command is asynchronous.
     62 * @example
     63 * editorInstance.addCommand( 'alertName',
     64 * {
     65 *     exec : function( editor )
     66 *     {
     67 *         alert( editor.name );
     68 *     },
     69 *     async : true    // The command need some time to complete after exec function returns.
     70 * });
     71 */
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy