Bug 1559789 - Align chat spellcheck with compose spellcheck so each chat can have its own language. r=aceman
authorJorg K <jorgk@jorgk.com>
Mon, 17 Jun 2019 13:12:27 +0200
changeset 35882 a3afad972033c878524e3a2c5ae5cb14e302af35
parent 35881 5bea2e886928c797445ca4c3ae13fab9d295b05b
child 35883 7cbed5436d28759d687e9a39e58ed40d7ab5121c
push id392
push userclokep@gmail.com
push dateMon, 02 Sep 2019 20:17:19 +0000
reviewersaceman
bugs1559789
Bug 1559789 - Align chat spellcheck with compose spellcheck so each chat can have its own language. r=aceman
mail/components/im/content/chat-messenger.js
--- a/mail/components/im/content/chat-messenger.js
+++ b/mail/components/im/content/chat-messenger.js
@@ -745,16 +745,31 @@ var chatHandler = {
         conv.addEventListener("contextmenu", (e) => {
           // Stash away the original event's parent and range for later use.
           gRangeParent = e.rangeParent;
           gRangeOffset = e.rangeOffset;
           let popup = document.getElementById("chatContextMenu");
           popup.openPopupAtScreen(e.screenX, e.screenY, true);
           e.preventDefault();
         });
+
+        // Set "mail editor mask" so changing the language doesn't
+        // affect the global preference and multiple chats can have
+        // individual languages.
+        conv.editor.editor.flags |= Ci.nsIPlaintextEditor.eEditorMailMask;
+
+        // Initialise language to the default.
+        conv.editor.setAttribute("lang",
+          Services.prefs.getStringPref("spellchecker.dictionary"));
+
+        // Attach listener so we hear about language changes.
+        document.addEventListener("spellcheck-changed", (e) => {
+          let conv = chatHandler._getActiveConvView();
+          conv.editor.setAttribute("lang", e.detail.dictionary);
+        });
       } else {
         item.convView.onConvResize();
       }
 
       convDeck.selectedPanel = item.convView;
       item.convView.updateConvStatus();
       item.update();