X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fundo%2Fplugin.js;h=89819f0d808ff71f3934fcb6e559a85e52ed5677;hb=4e70ea24db840898be8cc21c950363a52a2a6aba;hp=fde581f07014eb0e599f49a164c0a4d6e0722a5c;hpb=8665a7c6c60586526e32e8941fe2896739b6ebfb;p=ckeditor.git diff --git a/_source/plugins/undo/plugin.js b/_source/plugins/undo/plugin.js index fde581f..89819f0 100644 --- a/_source/plugins/undo/plugin.js +++ b/_source/plugins/undo/plugin.js @@ -1,5 +1,5 @@ /* -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 */ @@ -90,7 +90,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // Make the undo manager available only in wysiwyg mode. editor.on( 'mode', function() { - undoManager.enabled = editor.mode == 'wysiwyg'; + undoManager.enabled = editor.readOnly ? false : editor.mode == 'wysiwyg'; undoManager.onChange(); }); @@ -133,7 +133,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license editor.on( 'updateSnapshot', function() { if ( undoManager.currentImage && new Image( editor ).equals( undoManager.currentImage ) ) - setTimeout( function () { undoManager.update(); }, 0 ); + setTimeout( function() { undoManager.update(); }, 0 ); }); } }); @@ -148,14 +148,19 @@ For licensing, see LICENSE.html or http://ckeditor.com/license var Image = CKEDITOR.plugins.undo.Image = function( editor ) { this.editor = editor; + + editor.fire( 'beforeUndoImage' ); + var contents = editor.getSnapshot(), selection = contents && editor.getSelection(); // In IE, we need to remove the expando attributes. - CKEDITOR.env.ie && contents && ( contents = contents.replace( /\s+_cke_expando=".*?"/g, '' ) ); + CKEDITOR.env.ie && contents && ( contents = contents.replace( /\s+data-cke-expando=".*?"/g, '' ) ); this.contents = contents; this.bookmarks = selection && selection.createBookmarks2( true ); + + editor.fire( 'afterUndoImage' ); }; // Attributes that browser may changing them when setting via innerHTML. @@ -267,7 +272,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // In IE, we need to remove the expando attributes. if ( CKEDITOR.env.ie ) - currentSnapshot = currentSnapshot.replace( /\s+_cke_expando=".*?"/g, '' ); + currentSnapshot = currentSnapshot.replace( /\s+data-cke-expando=".*?"/g, '' ); if ( beforeTypeImage.contents != currentSnapshot ) { @@ -339,7 +344,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license */ this.index = -1; - this.limit = this.editor.config.undoStackSize; + this.limit = this.editor.config.undoStackSize || 20; this.currentImage = null; @@ -540,12 +545,12 @@ For licensing, see LICENSE.html or http://ckeditor.com/license /** * The number of undo steps to be saved. The higher this setting value the more * memory is used for it. + * @name CKEDITOR.config.undoStackSize * @type Number * @default 20 * @example * config.undoStackSize = 50; */ -CKEDITOR.config.undoStackSize = 20; /** * Fired when the editor is about to save an undo snapshot. This event can be @@ -553,3 +558,23 @@ CKEDITOR.config.undoStackSize = 20; * @name CKEDITOR.editor#saveSnapshot * @event */ + +/** + * Fired before an undo image is to be taken. An undo image represents the + * editor state at some point. It's saved into an undo store, so the editor is + * able to recover the editor state on undo and redo operations. + * @name CKEDITOR.editor#beforeUndoImage + * @since 3.5.3 + * @see CKEDITOR.editor#afterUndoImage + * @event + */ + +/** + * Fired after an undo image is taken. An undo image represents the + * editor state at some point. It's saved into an undo store, so the editor is + * able to recover the editor state on undo and redo operations. + * @name CKEDITOR.editor#afterUndoImage + * @since 3.5.3 + * @see CKEDITOR.editor#beforeUndoImage + * @event + */