Index: _source/plugins/editingblock/plugin.js =================================================================== --- _source/plugins/editingblock/plugin.js (revision 3677) +++ _source/plugins/editingblock/plugin.js Thu Jul 02 13:24:04 CST 2009 @@ -171,6 +171,7 @@ var currentMode = getMode( this ); data = currentMode.getData(); + this.fire( 'beforeModeUnload' ); currentMode.unload( holderElement ); this.mode = ''; } Index: _source/plugins/undo/plugin.js =================================================================== --- _source/plugins/undo/plugin.js (revision 3790) +++ _source/plugins/undo/plugin.js Thu Jul 02 13:27:50 CST 2009 @@ -81,24 +81,18 @@ } ); + // Always save an undo snapshot - the previous mode might have + // changed editor contents. + editor.on( 'beforeModeUnload', function(){ + editor.mode == 'wysiwyg' && undoManager.save( true ); + } ); + // Make the undo manager available only in wysiwyg mode. editor.on( 'mode', function() { - if ( editor.mode == 'wysiwyg' ) - { - if ( !undoManager.enabled ) - { - undoManager.enabled = true; - // Always save an undo snapshot - the previous mode might have changed - // editor contents. - undoManager.save( true ); - } - } - else - undoManager.enabled = false; - + undoManager.enabled = editor.mode == 'wysiwyg'; undoManager.onChange(); - }); + } ); editor.ui.addButton( 'Undo', { Index: CHANGES.html =================================================================== --- CHANGES.html (revision 3797) +++ CHANGES.html Thu Jul 02 13:31:16 CST 2009 @@ -88,6 +88,7 @@