Index: /CKEditor/trunk/_source/core/editor.js
===================================================================
--- /CKEditor/trunk/_source/core/editor.js	(revision 3003)
+++ /CKEditor/trunk/_source/core/editor.js	(revision 3004)
@@ -401,4 +401,18 @@
 		},
 
+		getSnapshot : function()
+		{
+			var data = this.fire( 'getSnapshot' );
+
+			if ( typeof data != 'string' )
+			{
+				var element = this.element;
+				if ( element && this.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE )
+					data = element.is( 'textarea' ) ? element.getValue() : element.getHtml();
+			}
+
+			return data;
+		},
+
 		/**
 		 * Sets the editor data. The data must be provided in raw format.
@@ -441,4 +455,15 @@
 		{
 			this.fire( 'insertElement', element );
+		},
+
+		checkDirty : function()
+		{
+			return ( this.mayBeDirty && this._.previousValue !== this.getSnapshot() );
+		},
+
+		resetDirty : function()
+		{
+			if ( this.mayBeDirty )
+				this._.previousValue = this.getSnapshot();
 		},
 
Index: /CKEditor/trunk/_source/plugins/editingblock/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/editingblock/plugin.js	(revision 3003)
+++ /CKEditor/trunk/_source/plugins/editingblock/plugin.js	(revision 3004)
@@ -65,4 +65,10 @@
 					}
 				});
+
+			editor.on( 'getSnapshot', function( event )
+				{
+					if ( editor.mode )
+						event.data = getMode( editor ).getSnapshotData();
+				});
 		}
 	});
@@ -100,5 +106,6 @@
 	{
 		var data,
-			holderElement = this.getThemeSpace( 'contents' );
+			holderElement = this.getThemeSpace( 'contents' ),
+			isDirty = this.checkDirty();
 
 		// Unload the previous mode.
@@ -121,8 +128,14 @@
 			throw '[CKEDITOR.editor.setMode] Unknown mode "' + mode + '".';
 
+		if ( !isDirty )
+		{
+			this.on( 'mode', function()
+				{
+					this.resetDirty();
+					this.removeListener( 'mode', arguments.callee );
+				});
+		}
+
 		modeEditor.load( holderElement, data || this.getData() );
-
-		this.mode = mode;
-		this.fire( 'mode' );
 	};
 
Index: /CKEditor/trunk/_source/plugins/sourcearea/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/sourcearea/plugin.js	(revision 3003)
+++ /CKEditor/trunk/_source/plugins/sourcearea/plugin.js	(revision 3004)
@@ -64,6 +64,12 @@
 							holderElement.append( textarea );
 
+							// The editor data "may be dirty" after this point.
+							editor.mayBeDirty = true;
+
 							// Set the <textarea> value.
 							this.loadData( data );
+
+							editor.mode = 'source';
+							editor.fire( 'mode' );
 						},
 
Index: /CKEditor/trunk/_source/plugins/wysiwygarea/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/wysiwygarea/plugin.js	(revision 3003)
+++ /CKEditor/trunk/_source/plugins/wysiwygarea/plugin.js	(revision 3004)
@@ -130,5 +130,6 @@
 						iframe,
 						isLoadingData,
-						isPendingFocus;
+						isPendingFocus,
+						fireMode;
 
 					// The following information is needed for IE only.
@@ -242,4 +243,11 @@
 						editor.fire( 'contentDom' );
 
+						if ( fireMode )
+						{
+							editor.mode = 'wysiwyg';
+							editor.fire( 'mode' );
+							fireMode = false;
+						}
+
 						isLoadingData = false;
 
@@ -258,4 +266,10 @@
 								if ( !isCustomDomain || !CKEDITOR.env.gecko )
 									createIFrame();
+
+								// The editor data "may be dirty" after this
+								// point.
+								editor.mayBeDirty = true;
+
+								fireMode = true;
 
 								if ( isSnapshot )
