mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-04 19:54:32 +08:00
fix(signatures): Fix signature switching between accounts in composer
This commit is contained in:
parent
01cad1351c
commit
0056773769
2 changed files with 8 additions and 8 deletions
|
@ -1,7 +1,7 @@
|
|||
export default {
|
||||
applySignature(body, signature) {
|
||||
// https://regex101.com/r/nC0qL2/1
|
||||
const signatureRegex = /<signature>[^]*<\/signature>/;
|
||||
// https://regex101.com/r/nC0qL2/2
|
||||
const signatureRegex = /(<br\/>){0,2}<signature>[^]*<\/signature>/;
|
||||
|
||||
let newBody = body;
|
||||
let paddingBefore = '';
|
||||
|
@ -23,6 +23,6 @@ export default {
|
|||
|
||||
const contentBefore = newBody.slice(0, insertionPoint);
|
||||
const contentAfter = newBody.slice(insertionPoint);
|
||||
return `${contentBefore}<signature>${paddingBefore}${signature}${paddingAfter}</signature>${contentAfter}`;
|
||||
return `${contentBefore}${paddingBefore}<signature>${signature}${paddingAfter}</signature>${contentAfter}`;
|
||||
},
|
||||
};
|
||||
|
|
|
@ -38,7 +38,7 @@ describe("SignatureComposerExtension", () => {
|
|||
SignatureComposerExtension.prepareNewDraft({draft: a});
|
||||
expect(a.body).toEqual(`This is a test! <signature>${TEST_SIGNATURE}<br/></signature><div class="gmail_quote">Hello world</div>`);
|
||||
SignatureComposerExtension.prepareNewDraft({draft: b});
|
||||
expect(b.body).toEqual(`This is a another test.<signature><br/><br/>${TEST_SIGNATURE}</signature>`);
|
||||
expect(b.body).toEqual(`This is a another test.<br/><br/><signature>${TEST_SIGNATURE}</signature>`);
|
||||
});
|
||||
|
||||
const scenarios = [
|
||||
|
@ -50,17 +50,17 @@ describe("SignatureComposerExtension", () => {
|
|||
{
|
||||
name: 'Populated signature div',
|
||||
body: `This is a test! <signature><br/><br/><div>SIG</div></signature>`,
|
||||
expected: `This is a test! <signature><br/><br/>${TEST_SIGNATURE}</signature>`,
|
||||
expected: `This is a test! <br/><br/><signature>${TEST_SIGNATURE}</signature>`,
|
||||
},
|
||||
{
|
||||
name: 'Empty signature div',
|
||||
body: 'This is a test! <signature></signature>',
|
||||
expected: `This is a test! <signature><br/><br/>${TEST_SIGNATURE}</signature>`,
|
||||
expected: `This is a test! <br/><br/><signature>${TEST_SIGNATURE}</signature>`,
|
||||
},
|
||||
{
|
||||
name: 'With newlines',
|
||||
body: 'This is a test! <signature>\n<br>\n<div>SIG</div>\n</signature>',
|
||||
expected: `This is a test! <signature><br/><br/>${TEST_SIGNATURE}</signature>`,
|
||||
body: 'This is a test!<br/> <signature>\n<br>\n<div>SIG</div>\n</signature>',
|
||||
expected: `This is a test!<br/> <br/><br/><signature>${TEST_SIGNATURE}</signature>`,
|
||||
},
|
||||
]
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue