Skip to content

Commit

Permalink
Piggyback on the existing C++ code for HTML quoting, fixes #780
Browse files Browse the repository at this point in the history
  • Loading branch information
protz committed Jun 20, 2014
1 parent a999ec5 commit dfdab84
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 73 deletions.
4 changes: 3 additions & 1 deletion content/quickReply.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ function showQuickReply() {
}, 500);

var textarea = $(this).find('.textarea');
makeEditable(textarea.get(0), true);
textarea.addClass('ease selected');
let delay = isQuickCompose ? 0 : 900;
setTimeout(function() {
textarea.removeClass('ease');
scrollNodeIntoView(document.querySelector(".quickReply"));
makeEditable(textarea.get(0), true);
}, delay);
}

Expand Down Expand Up @@ -127,6 +127,8 @@ function registerQuickReplyEventListeners() {
newComposeSessionByClick(type);
});

// TODO
return;
// Autoresize sorta-thingy.
let lineHeight = parseInt(
window.getComputedStyle(document.querySelector('.quickReply .textarea'), null).lineHeight
Expand Down
72 changes: 1 addition & 71 deletions content/stub.compose-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -695,77 +695,7 @@ ComposeSession.prototype = {
this.match({
reply: function (aMessage) {
let aMsgHdr = aMessage._msgHdr;
quoteMsgHdr(aMsgHdr, function (aBody) {
// Join together the different parts
let date = (new Date(aMsgHdr.date/1000)).toLocaleString();
let [{ email, name }] = parseMimeLine(aMsgHdr.author);
let author = name || email;
let body = '<blockquote type="cite">'+aBody+'</blockquote>';
try {
[body = h.onReplyComposed(getMessageForQuickReply(), body, true)
for each ([, h] in Iterator(getHooks()))
if (typeof(h.onReplyComposed) == "function")];
} catch (e) {
Log.warn("Plugin returned an error:", e);
dumpCallStack(e);
}
// Old way:
// let body = citeString("\n"+htmlToPlainText(aBody).trim());
let quoteblock = // body already starts with a newline
strings.get("quoteIntroString", [date, author]) + body;
// Grab the identity we're using and use its parameters.
let identity = self.params.identity;
let signature = "", signatureNoDashes = "";
if (identity.sigOnReply) {
signature = getSignatureContentsForAccount(identity);
if (String.trim(signature).length) {
[signature, signatureNoDashes] =
["\n\n-- \n" + signature, "\n\n" + signature];
if (identity.suppressSigSep)
signature = signatureNoDashes;
}
}
self.stripSignatureIfNeeded = function () {
let ed = getActiveEditor();
if (identity.sigOnReply) {
if (identity.replyOnTop && !identity.sigBottom)
ed.value = ed.value.replace(signatureNoDashes, "");
else
ed.value = ed.value.replace(signature, "");
}
};
// The user might be fast and might have started typing something
// already
let node = getActiveEditor();
let txt = node.value;
let val = null;
let pos = null;
let quote = identity.autoQuote
? quoteblock
: "";
// Assemble the parts
if (identity.replyOnTop) {
if (identity.autoQuote)
quote = "\n\n" + quote;
if (!identity.sigBottom) {
pos = 0;
val = txt + signatureNoDashes + quote;
} else {
pos = 0;
val = txt + quote + signature;
}
} else {
if (identity.autoQuote)
quote = quote + "\n\n";
pos = (quote + txt).replace(/\r?\n/g, "\n").length;
val = quote + txt + signature;
}
// After we removed any trailing newlines, insert it into the textarea
node.value = val;
// I <3 HTML5 selections.
node.selectionStart = pos;
node.selectionEnd = pos;
});
quoteMsgHdrIntoIframe(aMsgHdr, getActiveEditor().node);
self.setupDone();
},

Expand Down
2 changes: 1 addition & 1 deletion modules/stdlib
Submodule stdlib updated 1 files
+24 −0 compose.js

0 comments on commit dfdab84

Please sign in to comment.