From 7d3be1f3c8ac361b2632be2cb16ebd18fb41f3cf Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Fri, 26 Sep 2014 17:41:17 -0400
Subject: [PATCH] Fix restoring draft messages from localStorage if editor mode differs (#1490016)

---
 program/js/app.js |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/program/js/app.js b/program/js/app.js
index 2018cfb..eb3ff67 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -3617,11 +3617,15 @@
   this.toggle_editor = function(props, obj, e)
   {
     // @todo: this should work also with many editors on page
-    var result = this.editor.toggle(props.html);
+    var result = this.editor.toggle(props.html, props.noconvert || false);
+
+    // satisfy the expectations of aftertoggle-editor event subscribers
+    props.mode = props.html ? 'html' : 'plain';
 
     if (!result && e) {
       // fix selector value if operation failed
-      $(e.target).filter('select').val(props.html ? 'plain' : 'html');
+      props.mode = props.html ? 'plain' : 'html';
+      $(e.target).filter('select').val(props.mode);
     }
 
     if (result) {
@@ -3924,7 +3928,7 @@
 
       // initialize HTML editor
       if ((formdata._is_html == '1' && !html_mode) || (formdata._is_html != '1' && html_mode)) {
-        this.command('toggle-editor', {id: this.env.composebody, html: !html_mode});
+        this.command('toggle-editor', {id: this.env.composebody, html: !html_mode, noconvert: true});
       }
     }
   };

--
Gitblit v1.9.1