mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
When reply/sending e-mail:
- remove Microsoft Office styling - remove HubSpot HTML attributes
This commit is contained in:
parent
8b2d183f07
commit
f9ded86221
1 changed files with 30 additions and 18 deletions
|
|
@ -52,7 +52,7 @@ const
|
||||||
*/
|
*/
|
||||||
replySubjectAdd = (prefix, subject) => {
|
replySubjectAdd = (prefix, subject) => {
|
||||||
prefix = prefix.toUpperCase().trim();
|
prefix = prefix.toUpperCase().trim();
|
||||||
subject = subject.replace(/[\s]+/g, ' ').trim();
|
subject = subject.replace(/\s+/g, ' ').trim();
|
||||||
|
|
||||||
let drop = false,
|
let drop = false,
|
||||||
re = 'RE' === prefix,
|
re = 'RE' === prefix,
|
||||||
|
|
@ -102,7 +102,7 @@ class ComposePopupView extends AbstractViewPopup {
|
||||||
const fEmailOutInHelper = (context, identity, name, isIn) => {
|
const fEmailOutInHelper = (context, identity, name, isIn) => {
|
||||||
if (identity && context && identity[name]() && (isIn ? true : context[name]())) {
|
if (identity && context && identity[name]() && (isIn ? true : context[name]())) {
|
||||||
const identityEmail = identity[name]();
|
const identityEmail = identity[name]();
|
||||||
let list = context[name]().trim().split(/[,]/);
|
let list = context[name]().trim().split(',');
|
||||||
|
|
||||||
list = list.filter(email => {
|
list = list.filter(email => {
|
||||||
email = email.trim();
|
email = email.trim();
|
||||||
|
|
@ -183,6 +183,7 @@ class ComposePopupView extends AbstractViewPopup {
|
||||||
attacheMultipleAllowed: false,
|
attacheMultipleAllowed: false,
|
||||||
addAttachmentEnabled: false,
|
addAttachmentEnabled: false,
|
||||||
|
|
||||||
|
// div.textAreaParent
|
||||||
composeEditorArea: null,
|
composeEditorArea: null,
|
||||||
|
|
||||||
currentIdentity: this.identities()[0] ? this.identities()[0] : null
|
currentIdentity: this.identities()[0] ? this.identities()[0] : null
|
||||||
|
|
@ -341,6 +342,19 @@ class ComposePopupView extends AbstractViewPopup {
|
||||||
|
|
||||||
getMessageRequestParams(sSaveFolder)
|
getMessageRequestParams(sSaveFolder)
|
||||||
{
|
{
|
||||||
|
let TextIsHtml = this.oEditor.isHtml() ? 1 : 0,
|
||||||
|
Text = this.oEditor.getData(true);
|
||||||
|
if (TextIsHtml) {
|
||||||
|
let l;
|
||||||
|
do {
|
||||||
|
l = Text.length;
|
||||||
|
Text = Text
|
||||||
|
// Remove Microsoft Office styling
|
||||||
|
.replace(/(<[^>]+[;"'])\s*mso-[a-z-]+\s*:[^;"']+/gi, '$1')
|
||||||
|
// Remove hubspot data-hs- attributes
|
||||||
|
.replace(/(<[^>]+)\s+data-hs-[a-z-]+=("[^"]+"|'[^']+')/gi, '$1');
|
||||||
|
} while (l != Text.length)
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
IdentityID: this.currentIdentity() ? this.currentIdentity().id() : '',
|
IdentityID: this.currentIdentity() ? this.currentIdentity().id() : '',
|
||||||
MessageFolder: this.draftFolder(),
|
MessageFolder: this.draftFolder(),
|
||||||
|
|
@ -351,8 +365,8 @@ class ComposePopupView extends AbstractViewPopup {
|
||||||
Bcc: this.bcc(),
|
Bcc: this.bcc(),
|
||||||
ReplyTo: this.replyTo(),
|
ReplyTo: this.replyTo(),
|
||||||
Subject: this.subject(),
|
Subject: this.subject(),
|
||||||
TextIsHtml: this.oEditor && this.oEditor.isHtml() ? 1 : 0,
|
TextIsHtml: TextIsHtml,
|
||||||
Text: this.oEditor ? this.oEditor.getData(true) : '',
|
Text: Text,
|
||||||
DraftInfo: this.aDraftInfo,
|
DraftInfo: this.aDraftInfo,
|
||||||
InReplyTo: this.sInReplyTo,
|
InReplyTo: this.sInReplyTo,
|
||||||
References: this.sReferences,
|
References: this.sReferences,
|
||||||
|
|
@ -518,7 +532,7 @@ class ComposePopupView extends AbstractViewPopup {
|
||||||
}
|
}
|
||||||
|
|
||||||
openOpenPgpPopup() {
|
openOpenPgpPopup() {
|
||||||
if (PgpUserStore.capaOpenPGP() && this.oEditor && !this.oEditor.isHtml()) {
|
if (PgpUserStore.capaOpenPGP() && !this.oEditor.isHtml()) {
|
||||||
showScreenPopup(ComposeOpenPgpPopupView, [
|
showScreenPopup(ComposeOpenPgpPopupView, [
|
||||||
result => this.editor(editor => editor.setPlain(result)),
|
result => this.editor(editor => editor.setPlain(result)),
|
||||||
this.oEditor.getData(false),
|
this.oEditor.getData(false),
|
||||||
|
|
@ -670,8 +684,10 @@ class ComposePopupView extends AbstractViewPopup {
|
||||||
}
|
}
|
||||||
|
|
||||||
editor(fOnInit) {
|
editor(fOnInit) {
|
||||||
if (fOnInit) {
|
if (fOnInit && this.composeEditorArea()) {
|
||||||
if (!this.oEditor && this.composeEditorArea()) {
|
if (this.oEditor) {
|
||||||
|
fOnInit(this.oEditor);
|
||||||
|
} else {
|
||||||
// setTimeout(() => {
|
// setTimeout(() => {
|
||||||
this.oEditor = new HtmlEditor(
|
this.oEditor = new HtmlEditor(
|
||||||
this.composeEditorArea(),
|
this.composeEditorArea(),
|
||||||
|
|
@ -680,8 +696,6 @@ class ComposePopupView extends AbstractViewPopup {
|
||||||
bHtml => this.isHtml(!!bHtml)
|
bHtml => this.isHtml(!!bHtml)
|
||||||
);
|
);
|
||||||
// }, 1000);
|
// }, 1000);
|
||||||
} else if (this.oEditor) {
|
|
||||||
fOnInit(this.oEditor);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -692,16 +706,16 @@ class ComposePopupView extends AbstractViewPopup {
|
||||||
signature = signature.replace(/{{FROM-FULL}}/g, fromLine);
|
signature = signature.replace(/{{FROM-FULL}}/g, fromLine);
|
||||||
|
|
||||||
if (!fromLine.includes(' ') && 0 < fromLine.indexOf('@')) {
|
if (!fromLine.includes(' ') && 0 < fromLine.indexOf('@')) {
|
||||||
fromLine = fromLine.replace(/@[\S]+/, '');
|
fromLine = fromLine.replace(/@\S+/, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
signature = signature.replace(/{{FROM}}/g, fromLine);
|
signature = signature.replace(/{{FROM}}/g, fromLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
return signature
|
return signature
|
||||||
.replace(/[\r]/g, '')
|
.replace(/\r/g, '')
|
||||||
.replace(/[\s]{1,2}?{{FROM}}/g, '')
|
.replace(/\s{1,2}?{{FROM}}/g, '')
|
||||||
.replace(/[\s]{1,2}?{{FROM-FULL}}/g, '')
|
.replace(/\s{1,2}?{{FROM-FULL}}/g, '')
|
||||||
.replace(/{{DATE}}/g, new Date().format('LLLL'))
|
.replace(/{{DATE}}/g, new Date().format('LLLL'))
|
||||||
.replace(/{{TIME}}/g, new Date().format('LT'))
|
.replace(/{{TIME}}/g, new Date().format('LT'))
|
||||||
.replace(/{{MOMENT:[^}]+}}/g, '');
|
.replace(/{{MOMENT:[^}]+}}/g, '');
|
||||||
|
|
@ -1085,8 +1099,8 @@ class ComposePopupView extends AbstractViewPopup {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!this.to()) {
|
if (!this.to()) {
|
||||||
this.to.focused(true);
|
this.to.focused(true);
|
||||||
} else if (this.oEditor && !this.to.focused()) {
|
} else if (!this.to.focused()) {
|
||||||
this.oEditor.focus();
|
this.oEditor && this.oEditor.focus();
|
||||||
}
|
}
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
@ -1470,9 +1484,7 @@ class ComposePopupView extends AbstractViewPopup {
|
||||||
this.sending(false);
|
this.sending(false);
|
||||||
this.saving(false);
|
this.saving(false);
|
||||||
|
|
||||||
if (this.oEditor) {
|
this.oEditor && this.oEditor.clear();
|
||||||
this.oEditor.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue