Ticket #4999: 4999_2.patch

File 4999_2.patch, 1.4 KB (added by Garry Yao, 14 years ago)
  • _source/core/editor.js

     
    582582                 *
    583583                 * @param {String} data HTML code to replace the curent content in the editor.
    584584                 * @param {Function} callback Function to be called after the setData is completed.
     585                 * @param {Boolean} noUndo Specify false to avoid editor from creating undo snapshot for this load.   
    585586                 * @example
    586587                 * CKEDITOR.instances.editor1.<b>setData( '&lt;p&gt;This is the editor data.&lt;/p&gt;' )</b>;
    587588                 * CKEDITOR.instances.editor1.setData( '&lt;p&gt;Some other editor data.&lt;/p&gt;', function()
     
    589590                 *              CKEDITOR.instances.editor1.checkDirty();        // true
    590591                 * } );
    591592                 */
    592                 setData : function( data , callback )
     593                setData : function( data , callback, noUndo )
    593594                {
    594                         if( callback )
    595                         {
    596                                 this.on( 'dataReady', function( evt )
     595                        noUndo !== false && this.fire( 'saveSnapshot' );
     596
     597                        this.on( 'dataReady', function( evt )
    597598                                {
    598599                                        evt.removeListener();
    599                                         callback.call( evt.editor );
    600                                 } );
    601                         }
     600                                        callback && callback.call( evt.editor );
     601                                        noUndo !== false && this.fire( 'saveSnapshot' );
     602                                });
    602603                        // Fire "setData" so data manipulation may happen.
    603604                        var eventData = { dataValue : data };
    604605                        this.fire( 'setData', eventData );
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy