JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.5.3
[ckeditor.git] / _source / plugins / undo / plugin.js
index fde581f..94744ea 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -133,7 +133,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        editor.on( 'updateSnapshot', function()\r
                        {\r
                                if ( undoManager.currentImage && new Image( editor ).equals( undoManager.currentImage ) )\r
-                                       setTimeout( function () { undoManager.update(); }, 0 );\r
+                                       setTimeout( function() { undoManager.update(); }, 0 );\r
                        });\r
                }\r
        });\r
@@ -148,14 +148,19 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
        var Image = CKEDITOR.plugins.undo.Image = function( editor )\r
        {\r
                this.editor = editor;\r
+\r
+               editor.fire( 'beforeUndoImage' );\r
+\r
                var contents = editor.getSnapshot(),\r
                        selection       = contents && editor.getSelection();\r
 \r
                // In IE, we need to remove the expando attributes.\r
-               CKEDITOR.env.ie && contents && ( contents = contents.replace( /\s+_cke_expando=".*?"/g, '' ) );\r
+               CKEDITOR.env.ie && contents && ( contents = contents.replace( /\s+data-cke-expando=".*?"/g, '' ) );\r
 \r
                this.contents   = contents;\r
                this.bookmarks  = selection && selection.createBookmarks2( true );\r
+\r
+               editor.fire( 'afterUndoImage' );\r
        };\r
 \r
        // Attributes that browser may changing them when setting via innerHTML.\r
@@ -267,7 +272,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
                                                // In IE, we need to remove the expando attributes.\r
                                                if ( CKEDITOR.env.ie )\r
-                                                       currentSnapshot = currentSnapshot.replace( /\s+_cke_expando=".*?"/g, '' );\r
+                                                       currentSnapshot = currentSnapshot.replace( /\s+data-cke-expando=".*?"/g, '' );\r
 \r
                                                if ( beforeTypeImage.contents != currentSnapshot )\r
                                                {\r
@@ -339,7 +344,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                         */\r
                        this.index = -1;\r
 \r
-                       this.limit = this.editor.config.undoStackSize;\r
+                       this.limit = this.editor.config.undoStackSize || 20;\r
 \r
                        this.currentImage = null;\r
 \r
@@ -545,7 +550,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
  * @example\r
  * config.undoStackSize = 50;\r
  */\r
-CKEDITOR.config.undoStackSize = 20;\r
 \r
 /**\r
  * Fired when the editor is about to save an undo snapshot. This event can be\r
@@ -553,3 +557,23 @@ CKEDITOR.config.undoStackSize = 20;
  * @name CKEDITOR.editor#saveSnapshot\r
  * @event\r
  */\r
+\r
+/**\r
+ * Fired before an undo image is to be taken. An undo image represents the\r
+ * editor state at some point. It's saved into an undo store, so the editor is\r
+ * able to recover the editor state on undo and redo operations.\r
+ * @name CKEDITOR.editor#beforeUndoImage\r
+ * @since 3.5.3\r
+ * @see CKEDITOR.editor#afterUndoImage\r
+ * @event\r
+ */\r
+\r
+/**\r
+ * Fired after an undo image is taken. An undo image represents the\r
+ * editor state at some point. It's saved into an undo store, so the editor is\r
+ * able to recover the editor state on undo and redo operations.\r
+ * @name CKEDITOR.editor#afterUndoImage\r
+ * @since 3.5.3\r
+ * @see CKEDITOR.editor#beforeUndoImage\r
+ * @event\r
+ */\r