Bug #278310 --> inline spell checking for thunderbird

sr=bienvenu
This commit is contained in:
scott%scott-macgregor.org 2005-02-02 19:54:26 +00:00
Родитель 299f3c3b27
Коммит 44f4744642
6 изменённых файлов: 111 добавлений и 43 удалений

Просмотреть файл

@ -109,6 +109,7 @@ pref("update.severity", 0);
pref("xpinstall.whitelist.add", "update.mozilla.org,addons.mozilla.org");
pref("mail.phishing.detection.enabled", true); // enable / disable phishing detection for link clicks
pref("mail.spellcheck.inline", false);
/////////////////////////////////////////////////////////////////
// Overrides of the seamonkey suite mailnews.js prefs

Просмотреть файл

@ -571,7 +571,6 @@ function GetSelectedMessages()
function SetupCommandUpdateHandlers()
{
// dump("SetupCommandUpdateHandlers\n");
top.controllers.insertControllerAt(0, defaultController);
}
@ -592,37 +591,57 @@ function CommandUpdate_MsgCompose()
updateComposeItems();
}
function updateComposeItems() {
try {
//Edit Menu
goUpdateCommand("cmd_rewrap");
//Insert Menu
if (gMsgCompose && gMsgCompose.composeHTML)
function updateComposeItems()
{
try
{
goUpdateCommand("cmd_renderedHTMLEnabler");
goUpdateCommand("cmd_decreaseFont");
goUpdateCommand("cmd_increaseFont");
goUpdateCommand("cmd_bold");
goUpdateCommand("cmd_italic");
goUpdateCommand("cmd_underline");
goUpdateCommand("cmd_ul");
goUpdateCommand("cmd_ol");
goUpdateCommand("cmd_indent");
goUpdateCommand("cmd_outdent");
goUpdateCommand("cmd_align");
goUpdateCommand("cmd_smiley");
}
//Edit Menu
goUpdateCommand("cmd_rewrap");
//Options Menu
goUpdateCommand("cmd_spelling");
goUpdateCommand("cmd_quoteMessage");
//Insert Menu
if (gMsgCompose && gMsgCompose.composeHTML)
{
goUpdateCommand("cmd_renderedHTMLEnabler");
goUpdateCommand("cmd_decreaseFont");
goUpdateCommand("cmd_increaseFont");
goUpdateCommand("cmd_bold");
goUpdateCommand("cmd_italic");
goUpdateCommand("cmd_underline");
goUpdateCommand("cmd_ul");
goUpdateCommand("cmd_ol");
goUpdateCommand("cmd_indent");
goUpdateCommand("cmd_outdent");
goUpdateCommand("cmd_align");
goUpdateCommand("cmd_smiley");
}
//Options Menu
goUpdateCommand("cmd_spelling");
goUpdateCommand("cmd_quoteMessage");
} catch(e) {}
}
function updateEditItems() {
function openEditorContextMenu()
{
// if we have a mispelled word, do one thing, otherwise show 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;
updateEditItems();
}
function updateEditItems()
{
goUpdateCommand("cmd_pasteNoFormatting");
goUpdateCommand("cmd_pasteQuote");
goUpdateCommand("cmd_delete");
@ -633,8 +652,10 @@ function updateEditItems() {
goUpdateCommand("cmd_findPrev");
}
var messageComposeOfflineObserver = {
observe: function(subject, topic, state) {
var messageComposeOfflineObserver =
{
observe: function(subject, topic, state)
{
// sanity checks
if (topic != "network:offline-status-changed") return;
if (state == "offline")
@ -1289,6 +1310,7 @@ function ComposeStartup(recycled, aParams)
gMsgCompose.compFields.returnReceipt);
document.getElementById("cmd_attachVCard").setAttribute('checked',
gMsgCompose.compFields.attachVCard);
document.getElementById("menu_inlineSpellCheck").setAttribute('checked', sPrefs.getBoolPref("mail.spellcheck.inline"));
// If recycle, editor is already created
if (!recycled)
@ -1357,8 +1379,7 @@ function ComposeStartup(recycled, aParams)
if (recycled)
{
// This sets charset and does reply quote insertion
gMsgCompose.initEditor(GetCurrentEditor(), window.content);
InitEditor();
if (gMsgCompose.composeHTML)
{
@ -1419,7 +1440,7 @@ var gMsgEditorCreationObserver =
{
var editorStyle = editor.QueryInterface(Components.interfaces.nsIEditorStyleSheets);
editorStyle.addStyleSheet("chrome://messenger/skin/messageQuotes.css");
gMsgCompose.initEditor(editor, window.content);
InitEditor();
}
}
}
@ -2020,7 +2041,6 @@ function SelectAddress()
var ccAddress = msgCompFields.cc;
var bccAddress = msgCompFields.bcc;
dump("toAddress: " + toAddress + "\n");
window.openDialog("chrome://messenger/content/addressbook/abSelectAddressesDialog.xul",
"",
"chrome,resizable,titlebar,modal",
@ -2034,6 +2054,18 @@ function SelectAddress()
AdjustFocus();
}
function ToggleInlineSpellChecker(target)
{
if (InlineSpellChecker.inlineSpellChecker)
{
InlineSpellChecker.inlineSpellChecker.enableRealTimeSpell = !InlineSpellChecker.inlineSpellChecker.enableRealTimeSpell;
target.setAttribute('checked', InlineSpellChecker.inlineSpellChecker.enableRealTimeSpell);
if (InlineSpellChecker.inlineSpellChecker.enableRealTimeSpell)
InlineSpellChecker.checkDocument(window.content.document);
}
}
function ToggleReturnReceipt(target)
{
var msgCompFields = gMsgCompose.compFields;
@ -2047,13 +2079,13 @@ function ToggleReturnReceipt(target)
function ToggleAttachVCard(target)
{
var msgCompFields = gMsgCompose.compFields;
if (msgCompFields)
{
msgCompFields.attachVCard = ! msgCompFields.attachVCard;
target.setAttribute('checked', msgCompFields.attachVCard);
gAttachVCardOptionChanged = true;
}
var msgCompFields = gMsgCompose.compFields;
if (msgCompFields)
{
msgCompFields.attachVCard = ! msgCompFields.attachVCard;
target.setAttribute('checked', msgCompFields.attachVCard);
gAttachVCardOptionChanged = true;
}
}
function queryISupportsArray(supportsArray, iid) {
@ -3302,3 +3334,10 @@ function AutoSave()
gAutoSaveTimeout = setTimeout("AutoSave()", gAutoSaveInterval);
}
function InitEditor()
{
var editor = GetCurrentEditor();
gMsgCompose.initEditor(editor, window.content);
InlineSpellChecker.Init(editor, sPrefs.getBoolPref("mail.spellcheck.inline"));
InlineSpellChecker.checkDocument(window.content.document);
}

Просмотреть файл

@ -70,6 +70,7 @@
</stringbundleset>
<script type="application/x-javascript" src="chrome://communicator/content/printing.js"/>
<script type="application/x-javascript" src="chrome://editor/content/editorInlineSpellCheck.js"/>
<script type="application/x-javascript" src="chrome://messenger/content/accountUtils.js"/>
<script type="application/x-javascript" src="chrome://messenger/content/widgetglue.js"/>
<script type="application/x-javascript" src="chrome://messenger/content/mailCore.js"/>
@ -234,9 +235,18 @@
<keyset id="editorKeys"/>
<popup id="msgComposeContext" onpopupshowing="updateEditItems();">
<popup id="msgComposeContext"
onpopupshowing="openEditorContextMenu();">
<menuitem id="spellCheckNoSuggestions" label="&spellCheckNoSuggestions.label;" disabled="true"/>
<menuseparator id="spellCheckAddSep"/>
<menuitem id="spellCheckAddToDictionary" label="&spellCheckAddToDictionary.label;" accesskey="&spellCheckAddToDictionary.accesskey;"
oncommand="InlineSpellChecker.addToDictionary(null,null);"/>
<menuitem id="spellCheckIgnoreWord" label="&spellCheckIgnoreWord.label;" accesskey="&spellCheckIgnoreWord.accesskey;"
oncommand="InlineSpellChecker.ignoreWord(null, null)"/>
<menuseparator id="spellCheckSuggestionsSeparator"/>
<menuitem label="&undo.label;" accesskey="&undo.accesskey;" command="cmd_undo"/>
<menuseparator/>
<menuitem label="&cut.label;" accesskey="&cut.accesskey;" command="cmd_cut"/>
<menuitem label="&copy.label;" accesskey="&copy.accesskey;" command="cmd_copy"/>
<menuitem label="&paste.label;" accesskey="&paste.accesskey;" command="cmd_paste"/>
@ -394,6 +404,9 @@
<menu id="optionsMenu" label="&optionsMenu.label;" accesskey="&optionsMenu.accesskey;">
<menupopup id="optionsMenuPopup">
<menuitem label="&checkSpellingCmd.label;" id="menu_checkspelling" accesskey="&checkSpellingCmd.accesskey;" key="key_checkspelling" command="cmd_spelling"/>
<menuitem label="&enableInlineSpellChecker.label;" id="menu_inlineSpellCheck"
accesskey="&enableInlineSpellChecker.accesskey;" checked="false"
type="checkbox" oncommand="ToggleInlineSpellChecker(event.target)"/>
<menuitem label="&quoteCmd.label;" accesskey="&quoteCmd.accesskey;" command="cmd_quoteMessage"/>
<menuseparator/>
<menuitem id="returnReceiptMenu" type="checkbox" label="&returnReceiptMenu.label;" accesskey="&returnReceiptMenu.accesskey;" checked="false" oncommand="ToggleReturnReceipt(event.target)"/>

Просмотреть файл

@ -12,7 +12,7 @@
<script type="application/x-javascript">
<![CDATA[
var _elementIDs = ["forwardMessageMode", "spellCheckBeforeSend", "strictlyMime",
var _elementIDs = ["forwardMessageMode", "spellCheckBeforeSend", "inlineSpellCheck", "strictlyMime",
"wrapLength", "mailWarnOnSendAccelKey", "autoSave",
"autoSaveInterval",
// auto complete prefs
@ -28,6 +28,7 @@
function Startup()
{
document.getElementById("spellCheckBeforeSend").hidden =! ("@mozilla.org/spellchecker;1" in Components.classes);
document.getElementById("inlineSpellCheck").hidden =! ("@mozilla.org/spellchecker;1" in Components.classes);
// autocomplete
enableAutocomplete();
@ -72,6 +73,10 @@
prefstring="mail.SpellCheckBeforeSend"
accesskey="&spellCheck.accesskey;"/>
<checkbox id="inlineSpellCheck" label="&spellCheckInline.label;"
prefstring="mail.spellcheck.inline"
accesskey="&spellCheckInline.accesskey;"/>
<checkbox id="strictlyMime" label="&useMIME.label;"
prefstring="mail.strictly_mime"
accesskey="&useMIME.accesskey;"/>

Просмотреть файл

@ -119,7 +119,9 @@
<!ENTITY checkSpellingCmd.label "Check Spelling...">
<!ENTITY checkSpellingCmd.key "K">
<!ENTITY checkSpellingCmd.key2 "VK_F7">
<!ENTITY checkSpellingCmd.accesskey "S">
<!ENTITY checkSpellingCmd.accesskey "h">
<!ENTITY enableInlineSpellChecker.label "Spell As You Type">
<!ENTITY enableInlineSpellChecker.accesskey "S">
<!ENTITY quoteCmd.label "Quote Message">
<!ENTITY quoteCmd.accesskey "Q">
@ -251,6 +253,11 @@
<!ENTITY smiley16Cmd.label "Lips-are-Sealed">
<!-- Message Pane Context Menu -->
<!ENTITY spellCheckNoSuggestions.label "No Suggestions Found">
<!ENTITY spellCheckIgnoreWord.label "Ignore Word">
<!ENTITY spellCheckIgnoreWord.accesskey "I">
<!ENTITY spellCheckAddToDictionary.label "Add to Dictionary">
<!ENTITY spellCheckAddToDictionary.accesskey "n">
<!ENTITY undo.label "Undo">
<!ENTITY undo.accesskey "U">
<!ENTITY cut.label "Cut">
@ -275,3 +282,4 @@
<!-- Title for the address picker panel -->
<!ENTITY addressesSidebarTitle.label "Contacts">

Просмотреть файл

@ -11,6 +11,8 @@
<!ENTITY sendingMessagesHeader.label "Composing Messages">
<!ENTITY spellCheck.label "Check spelling before sending">
<!ENTITY spellCheck.accesskey "c">
<!ENTITY spellCheckInline.label "Enable spell as you type">
<!ENTITY spellCheckInline.accesskey "n">
<!ENTITY useMIME.label "For messages that contain 8-bit characters, use 'quoted printable' MIME encoding. Leave unchecked to send the messages as is.">
<!ENTITY useMIME.accesskey "o">
<!ENTITY warnOnSendAccelKey.label "Confirm when using keyboard shortcut to send message">