# HG changeset patch
# Parent 0c301942fbe96d02b431d060974bb260fcb3dad2
# User Jorg K
Bug 330891 - Initialise editor with editor.CR_creates_new_p preference. r=mkmelin
diff --git a/editor/ui/composer.js b/editor/ui/composer.js
--- a/editor/ui/composer.js
+++ b/editor/ui/composer.js
@@ -90,13 +90,13 @@ pref("editor.always_show_publish_dialog"
#ifndef XP_MACOSX
#ifdef XP_UNIX
pref("editor.disable_spell_checker", false);
pref("editor.dont_lock_spell_files", true);
#endif
#endif
-pref("editor.CR_creates_new_p", false);
+pref("editor.CR_creates_new_p", true);
// Pasting images from the clipboard, order of encoding preference:
// JPEG-PNG-GIF=0, PNG-JPEG-GIF=1, GIF-JPEG-PNG=2
pref("clipboard.paste_image_type", 1);
diff --git a/mail/components/compose/content/MsgComposeCommands.js b/mail/components/compose/content/MsgComposeCommands.js
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -4845,16 +4845,20 @@ function InitEditor()
// Set eEditorMailMask flag to avoid using content prefs for spell checker,
// otherwise dictionary setting in preferences is ignored and dictionary is
// inconsistent in subject and message body.
let eEditorMailMask = Components.interfaces.nsIPlaintextEditor.eEditorMailMask;
editor.flags |= eEditorMailMask;
GetMsgSubjectElement().editor.flags |= eEditorMailMask;
+ // Control insertion of line breaks.
+ editor.returnInParagraphCreatesNewParagraph =
+ Services.prefs.getBoolPref("editor.CR_creates_new_p");
+
editor.QueryInterface(nsIEditorStyleSheets);
// We use addOverrideStyleSheet rather than addStyleSheet so that we get
// a synchronous load, rather than having a late-finishing async load
// mark our editor as modified when the user hasn't typed anything yet,
// but that means the sheet must not @import slow things, especially
// not over the network.
editor.addOverrideStyleSheet("chrome://messenger/content/composerOverlay.css");
gMsgCompose.initEditor(editor, window.content);
diff --git a/mail/components/compose/content/cloudAttachmentLinkManager.js b/mail/components/compose/content/cloudAttachmentLinkManager.js
--- a/mail/components/compose/content/cloudAttachmentLinkManager.js
+++ b/mail/components/compose/content/cloudAttachmentLinkManager.js
@@ -30,43 +30,117 @@ var gCloudAttachmentLinkManager = {
bucket.removeEventListener("attachments-converted", this, false);
gMsgCompose.UnregisterStateListener(this);
},
NotifyComposeFieldsReady: function() {},
NotifyComposeBodyReady: function() {
+
+ // Look all the possible compose typed (nsIMsgComposeParams.idl):
+ switch (gComposeType) {
+ case Components.interfaces.nsIMsgCompType.New:
+ this.NotifyComposeBodyReadyNew();
+ return;
+ case Components.interfaces.nsIMsgCompType.Reply:
+ case Components.interfaces.nsIMsgCompType.ReplyAll:
+ this.NotifyComposeBodyReadyReply();
+ return;
+ case Components.interfaces.nsIMsgCompType.ForwardAsAttachment:
+ return;
+ case Components.interfaces.nsIMsgCompType.ForwardInline:
+ this.NotifyComposeBodyReadyForwardInline();
+ return;
+ case Components.interfaces.nsIMsgCompType.ReplyToSender:
+ case Components.interfaces.nsIMsgCompType.ReplyToGroup:
+ case Components.interfaces.nsIMsgCompType.ReplyToSenderAndGroup:
+ this.NotifyComposeBodyReadyReply();
+ return;
+ case Components.interfaces.nsIMsgCompType.Draft:
+ case Components.interfaces.nsIMsgCompType.Template:
+ case Components.interfaces.nsIMsgCompType.MailToUrl:
+ return;
+ case Components.interfaces.nsIMsgCompType.ReplyWithTemplate:
+ case Components.interfaces.nsIMsgCompType.ReplyToList:
+ this.NotifyComposeBodyReadyReply();
+ return;
+ case Components.interfaces.nsIMsgCompType.Redirect:
+ default:
+ dump(gComposeType+"Unexpected nsIMsgCompType in NotifyComposeBodyReady\n");
+ return;
+ }
+ },
+
+ NotifyComposeBodyReadyNew: function() {
+ let editor = GetCurrentEditor();
+ editor.enableUndo(false);
+
+ // Control insertion of line breaks.
+ let useParagraph = Services.prefs.getBoolPref("editor.CR_creates_new_p");
+ if (useParagraph) {
+ let pElement = editor.createElementWithDefaults("p");
+ let brElement = editor.createElementWithDefaults("br");
+ pElement.appendChild(brElement);
+ editor.insertElementAtSelection(pElement,true);
+ document.getElementById("cmd_paragraphState").setAttribute("state", "p");
+ } else {
+ document.getElementById("cmd_paragraphState").setAttribute("state", "");
+ }
+
+ editor.beginningOfDocument();
+ editor.enableUndo(true);
+ editor.resetModificationCount();
+ },
+
+ NotifyComposeBodyReadyReply: function() {
+ dump("+++++++++++++++++++++++++++++ reply\n");
+ },
+
+ NotifyComposeBodyReadyForwardInline: function() {
// If we're doing an inline-forward, let's take all of the current
// message text, and wrap it up into its own DIV.
- if (gComposeType != Components.interfaces.nsIMsgCompType.ForwardInline)
- return;
-
+ // This is kind of mad, since an added signature will also be wrapped
+ // into the DIV.
let mailDoc = document.getElementById("content-frame").contentDocument;
let mailBody = mailDoc.querySelector("body");
let editor = GetCurrentEditor();
let selection = editor.selection;
let container = editor.createElementWithDefaults("div");
container.setAttribute("class", "moz-forward-container");
editor.enableUndo(false);
while (mailBody.hasChildNodes()) {
container.appendChild(mailBody.removeChild(mailBody.firstChild));
}
- editor.insertLineBreak();
+
+ // Control insertion of line breaks.
+ selection.collapse(mailBody, 0);
+ let useParagraph = Services.prefs.getBoolPref("editor.CR_creates_new_p");
+ if (useParagraph) {
+ let pElement = editor.createElementWithDefaults("p");
+ let brElement = editor.createElementWithDefaults("br");
+ pElement.appendChild(brElement);
+ editor.insertElementAtSelection(pElement,true);
+ document.getElementById("cmd_paragraphState").setAttribute("state", "p");
+ } else {
+ editor.insertLineBreak();
+ document.getElementById("cmd_paragraphState").setAttribute("state", "");
+ }
+
selection.collapse(mailBody, 1);
editor.insertElementAtSelection(container, false);
- editor.insertLineBreak();
editor.beginningOfDocument();
editor.enableUndo(true);
editor.resetModificationCount();
},
+
ComposeProcessDone: function() {},
SaveInFolderDone: function() {},
handleEvent: function(event) {
let mailDoc = document.getElementById("content-frame").contentDocument;
if (event.type == "attachment-uploaded") {
if (this.cloudAttachments.length == 0)
diff --git a/mail/components/preferences/compose.xul b/mail/components/preferences/compose.xul
--- a/mail/components/preferences/compose.xul
+++ b/mail/components/preferences/compose.xul
@@ -46,16 +46,19 @@
+
@@ -149,16 +152,22 @@
+
+
+ &sendOptionsDescription.label;
diff --git a/mail/locales/en-US/chrome/messenger/preferences/compose.dtd b/mail/locales/en-US/chrome/messenger/preferences/compose.dtd
--- a/mail/locales/en-US/chrome/messenger/preferences/compose.dtd
+++ b/mail/locales/en-US/chrome/messenger/preferences/compose.dtd
@@ -21,16 +21,18 @@
+
+