mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-07 05:04:58 +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 {
|
export default {
|
||||||
applySignature(body, signature) {
|
applySignature(body, signature) {
|
||||||
// https://regex101.com/r/nC0qL2/1
|
// https://regex101.com/r/nC0qL2/2
|
||||||
const signatureRegex = /<signature>[^]*<\/signature>/;
|
const signatureRegex = /(<br\/>){0,2}<signature>[^]*<\/signature>/;
|
||||||
|
|
||||||
let newBody = body;
|
let newBody = body;
|
||||||
let paddingBefore = '';
|
let paddingBefore = '';
|
||||||
|
@ -23,6 +23,6 @@ export default {
|
||||||
|
|
||||||
const contentBefore = newBody.slice(0, insertionPoint);
|
const contentBefore = newBody.slice(0, insertionPoint);
|
||||||
const contentAfter = newBody.slice(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});
|
SignatureComposerExtension.prepareNewDraft({draft: a});
|
||||||
expect(a.body).toEqual(`This is a test! <signature>${TEST_SIGNATURE}<br/></signature><div class="gmail_quote">Hello world</div>`);
|
expect(a.body).toEqual(`This is a test! <signature>${TEST_SIGNATURE}<br/></signature><div class="gmail_quote">Hello world</div>`);
|
||||||
SignatureComposerExtension.prepareNewDraft({draft: b});
|
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 = [
|
const scenarios = [
|
||||||
|
@ -50,17 +50,17 @@ describe("SignatureComposerExtension", () => {
|
||||||
{
|
{
|
||||||
name: 'Populated signature div',
|
name: 'Populated signature div',
|
||||||
body: `This is a test! <signature><br/><br/><div>SIG</div></signature>`,
|
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',
|
name: 'Empty signature div',
|
||||||
body: 'This is a test! <signature></signature>',
|
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',
|
name: 'With newlines',
|
||||||
body: 'This is a test! <signature>\n<br>\n<div>SIG</div>\n</signature>',
|
body: 'This is a test!<br/> <signature>\n<br>\n<div>SIG</div>\n</signature>',
|
||||||
expected: `This is a test! <signature><br/><br/>${TEST_SIGNATURE}</signature>`,
|
expected: `This is a test!<br/> <br/><br/><signature>${TEST_SIGNATURE}</signature>`,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue