mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-08 01:04:39 +08:00
579d4ad71b
Summary: - Fixes #1239 - Adds action in composer view to indicate when draft partcipants have changed. This seemed like the simplest way to listen for this change without adding another extension point - Updates signature plugin to listen to this action and update signature accordingly - Adds test Test Plan: - Unit tests Reviewers: evan, bengotow Reviewed By: bengotow Differential Revision: https://phab.nylas.com/D2614
29 lines
792 B
JavaScript
29 lines
792 B
JavaScript
|
|
const SignatureUtils = {
|
|
|
|
applySignature(body, signature) {
|
|
const signatureRegex = /<div class="nylas-n1-signature">.*<\/div>/;
|
|
|
|
let signatureHTML = '<div class="nylas-n1-signature">' + signature + '</div>';
|
|
let insertionPoint = body.search(signatureRegex)
|
|
let newBody = body;
|
|
|
|
// If there is a signature already present
|
|
if (insertionPoint !== -1) {
|
|
// Remove it
|
|
newBody = newBody.replace(signatureRegex, "")
|
|
} else {
|
|
insertionPoint = newBody.indexOf('<blockquote');
|
|
|
|
if (insertionPoint === -1) {
|
|
insertionPoint = newBody.length
|
|
signatureHTML = '<br/><br/>' + signatureHTML
|
|
}
|
|
}
|
|
return newBody.slice(0, insertionPoint) + signatureHTML + newBody.slice(insertionPoint)
|
|
},
|
|
|
|
}
|
|
|
|
export default SignatureUtils;
|
|
|