diff --git a/mailnews/compose/resources/content/MsgComposeCommands.js b/mailnews/compose/resources/content/MsgComposeCommands.js index d610f460ad76..e39dc1c401ce 100644 --- a/mailnews/compose/resources/content/MsgComposeCommands.js +++ b/mailnews/compose/resources/content/MsgComposeCommands.js @@ -251,8 +251,8 @@ var gComposeRecyclingListener = { document.getElementById("FormatToolbar").hidden = false; } - // Stop InlineSpellChecker so personal dictionary is saved - StopInlineSpellChecker(); + // Stop InlineSpellCheckerUI so personal dictionary is saved + InlineSpellCheckerUI.enabled = false; //Reset editor EditorResetFontAndColorAttributes(); @@ -630,21 +630,20 @@ function updateComposeItems() } catch(e) {} } -function openEditorContextMenu() +function openEditorContextMenu(popup) { // if we have a mispelled word, show spellchecker context // menuitems as well as the usual context menu - var spellCheckNoSuggestionsItem = document.getElementById('spellCheckNoSuggestions'); - var word; - var misspelledWordStatus = InlineSpellChecker.updateSuggestionsMenu(document.getElementById('msgComposeContext'), - spellCheckNoSuggestionsItem, word); - - var hideSpellingItems = (misspelledWordStatus == kSpellNoMispelling); - spellCheckNoSuggestionsItem.hidden = hideSpellingItems || misspelledWordStatus != kSpellNoSuggestionsFound; - document.getElementById('spellCheckAddToDictionary').hidden = hideSpellingItems; - document.getElementById('spellCheckIgnoreWord').hidden = hideSpellingItems; - document.getElementById('spellCheckAddSep').hidden = hideSpellingItems; - document.getElementById('spellCheckSuggestionsSeparator').hidden = hideSpellingItems; + InlineSpellCheckerUI.clearSuggestionsFromMenu(); + InlineSpellCheckerUI.initFromEvent(document.popupRangeParent, document.popupRangeOffset); + var onMisspelling = InlineSpellCheckerUI.overMisspelling; + document.getElementById('spellCheckSuggestionsSeparator').hidden = !onMisspelling; + document.getElementById('spellCheckAddToDictionary').hidden = !onMisspelling; + document.getElementById('spellCheckIgnoreWord').hidden = !onMisspelling; + var separator = document.getElementById('spellCheckAddSep'); + separator.hidden = !onMisspelling; + document.getElementById('spellCheckNoSuggestions').hidden = !onMisspelling || + InlineSpellCheckerUI.addSuggestionsToMenu(popup, separator, 5); updateEditItems(); } @@ -1361,6 +1360,7 @@ function ComposeStartup(recycled, aParams) // Do setup common to Message Composer and Web Composer EditorSharedStartup(); + InitLanguageMenu(); } var msgCompFields = gMsgCompose.compFields; @@ -1548,8 +1548,8 @@ function ComposeUnload() { dump("\nComposeUnload from XUL\n"); - // Stop InlineSpellChecker so personal dictionary is saved - StopInlineSpellChecker(); + // Stop InlineSpellCheckerUI so personal dictionary is saved + InlineSpellCheckerUI.enabled = false; EditorCleanup(); @@ -2099,7 +2099,7 @@ function SelectAddress() // walk through the recipients list and add them to the inline spell checker ignore list function addRecipientsToIgnoreList(aAddressesToAdd) { - if (InlineSpellChecker.inlineSpellChecker && InlineSpellChecker.inlineSpellChecker.enableRealTimeSpell) + if (InlineSpellCheckerUI.enabled) { // break the list of potentially many recipients back into individual names var hdrParser = Components.classes["@mozilla.org/messenger/headerparser;1"].getService(Components.interfaces.nsIMsgHeaderParser); @@ -2118,24 +2118,7 @@ function addRecipientsToIgnoreList(aAddressesToAdd) tokenizedNames = tokenizedNames.concat(splitNames); } - InlineSpellChecker.inlineSpellChecker.ignoreWords(tokenizedNames, tokenizedNames.length); - } -} - -function StopInlineSpellChecker() -{ - if (InlineSpellChecker.inlineSpellChecker) - InlineSpellChecker.editor.setSpellcheckUserOverride(false); -} - -function ToggleInlineSpellChecker(target) -{ - if (InlineSpellChecker.inlineSpellChecker) - { - InlineSpellChecker.editor.setSpellcheckUserOverride(!InlineSpellChecker.inlineSpellChecker.enableRealTimeSpell); - - if (InlineSpellChecker.inlineSpellChecker.enableRealTimeSpell) - InlineSpellChecker.checkDocument(window.content.document); + InlineSpellCheckerUI.mInlineSpellChecker.ignoreWords(tokenizedNames, tokenizedNames.length); } } @@ -2251,9 +2234,8 @@ function ChangeLanguage(event) sPrefs.setComplexValue("spellchecker.dictionary", nsISupportsString, str); // now check the document over again with the new dictionary - if (InlineSpellChecker.inlineSpellChecker) - if (InlineSpellChecker.inlineSpellChecker.enableRealTimeSpell) - InlineSpellChecker.checkDocument(window.content.document); + if (InlineSpellCheckerUI.enabled) + InlineSpellCheckerUI.mInlineSpellChecker.spellCheckRange(null); } event.stopPropagation(); } @@ -3341,11 +3323,7 @@ function AutoSave() function InitEditor(editor) { gMsgCompose.initEditor(editor, window.content); - try { - InlineSpellChecker.Init(editor, sPrefs.getBoolPref("mail.spellcheck.inline")); - } catch (e) { - // InlineSpellChecker.Init throws if there is no inline spellchecker - // so disable menuitem. - document.getElementById('menu_inlineSpellCheck').setAttribute('disabled', true); - } + InlineSpellCheckerUI.init(editor); + InlineSpellCheckerUI.enabled = sPrefs.getBoolPref("mail.spellcheck.inline"); + document.getElementById("menu_inlineSpellCheck").setAttribute("disabled", !InlineSpellCheckerUI.canSpellCheck); } diff --git a/mailnews/compose/resources/content/messengercompose.xul b/mailnews/compose/resources/content/messengercompose.xul index 69bc6e2c5891..22712ce3774d 100644 --- a/mailnews/compose/resources/content/messengercompose.xul +++ b/mailnews/compose/resources/content/messengercompose.xul @@ -94,7 +94,6 @@