// Gets a snapshot image which represent the current document status.\r
function Image( editor )\r
{\r
- var selection = editor.getSelection();\r
-\r
- this.contents = editor.getSnapshot();\r
- this.bookmarks = selection && selection.createBookmarks2( true );\r
+ var contents = editor.getSnapshot(),\r
+ selection = contents && editor.getSelection();\r
\r
// In IE, we need to remove the expando attributes.\r
- if ( CKEDITOR.env.ie )\r
- this.contents = this.contents.replace( /\s+_cke_expando=".*?"/g, '' );\r
+ CKEDITOR.env.ie && contents && ( contents = contents.replace( /\s+_cke_expando=".*?"/g, '' ) );\r
+\r
+ this.contents = contents;\r
+ this.bookmarks = selection && selection.createBookmarks2( true );\r
}\r
\r
// Attributes that browser may changing them when setting via innerHTML.\r
otherContents = otherImage.contents;\r
\r
// For IE6/7 : Comparing only the protected attribute values but not the original ones.(#4522)\r
- if( CKEDITOR.env.ie && ( CKEDITOR.env.ie7Compat || CKEDITOR.env.ie6Compat ) )\r
+ if ( CKEDITOR.env.ie && ( CKEDITOR.env.ie7Compat || CKEDITOR.env.ie6Compat ) )\r
{\r
thisContents = thisContents.replace( protectedAttrs, '' );\r
otherContents = otherContents.replace( protectedAttrs, '' );\r
}\r
\r
- if( thisContents != otherContents )\r
+ if ( thisContents != otherContents )\r
return false;\r
\r
if ( contentOnly )\r
if ( !image )\r
image = new Image( this.editor );\r
\r
+ // Do nothing if it was not possible to retrieve an image.\r
+ if ( image.contents === false )\r
+ return false;\r
+\r
// Check if this is a duplicate. In such case, do nothing.\r
if ( this.currentImage && image.equals( this.currentImage, onContentOnly ) )\r
return false;\r
\r
this.index = image.index;\r
\r
- this.currentImage = image;\r
+ // Update current image with the actual editor\r
+ // content, since actualy content may differ from\r
+ // the original snapshot due to dom change. (#4622)\r
+ this.snapshots.splice( this.index, 1, ( this.currentImage = new Image( this.editor ) ) );\r
\r
this.fireChange();\r
},\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
+ * fired by plugins and customizations to make the editor saving undo snapshots.\r
+ * @name CKEDITOR.editor#saveSnapshot\r
+ * @event\r
+ */\r