Index: _source/plugins/editingblock/plugin.js =================================================================== --- _source/plugins/editingblock/plugin.js (revision 3808) +++ _source/plugins/editingblock/plugin.js (working copy) @@ -171,6 +171,7 @@ var currentMode = getMode( this ); data = currentMode.getData(); + data = this.fire( 'beforeModeUnload', data ); currentMode.unload( holderElement ); this.mode = ''; } Index: _source/plugins/undo/plugin.js =================================================================== --- _source/plugins/undo/plugin.js (revision 3808) +++ _source/plugins/undo/plugin.js (working copy) @@ -81,22 +81,17 @@ } ); + // 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(); }); Index: CHANGES.html =================================================================== --- CHANGES.html (revision 3797) +++ CHANGES.html Thu Jul 02 13:31:16 CST 2009 @@ -88,6 +88,7 @@