|
|
|
@ -28,8 +28,25 @@ const getAbstract = (longtext) => {
|
|
|
|
|
const abstract = firstLine.substring(0, 20);
|
|
|
|
|
return abstract;
|
|
|
|
|
};
|
|
|
|
|
const parseHTMLText = (html) => {
|
|
|
|
|
const parser = new DOMParser()
|
|
|
|
|
const dom = parser.parseFromString(html, 'text/html')
|
|
|
|
|
// Replace <br> and <p> with line breaks
|
|
|
|
|
Array.from(dom.body.querySelectorAll('br, p')).forEach(el => {
|
|
|
|
|
el.textContent = '\n' + el.textContent;
|
|
|
|
|
});
|
|
|
|
|
// Replace <hr> with a line of dashes
|
|
|
|
|
Array.from(dom.body.querySelectorAll('hr')).forEach(el => {
|
|
|
|
|
el.textContent = '\n------------------------------------------------------------------\n';
|
|
|
|
|
});
|
|
|
|
|
return dom.body.textContent || '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const generateQuoteContent = (mailData, isRichText = true) => {
|
|
|
|
|
const html = `<br><hr><p><b><strong >From: </strong></b><span >${((mailData.info?.MAI_From || '').replace(/</g,'<').replace(/>/g,'>'))} </span></p><p><b><strong >Sent: </strong></b><span >${mailData.info?.MAI_SendDate || ''}</span></p><p><b><strong >To: </strong></b><span >${(mailData.info?.MAI_To || '').replace(/</g,'<').replace(/>/g,'>')}</span></p><p><b><strong >Subject: </strong></b><span >${mailData.info?.MAI_Subject || ''}</span></p><p>${mailData.info?.MAI_ContentType === 'text/html' ? mailData.content : mailData.content.replace(/\r\n/g, '<br>')}</p>`
|
|
|
|
|
return isRichText ? html : parseHTMLText(html)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const generateQuoteContent = (mailData) => `<br><hr><p><b><strong >From: </strong></b><span >${((mailData.info?.MAI_From || '').replace(/</g,'<').replace(/>/g,'>'))} </span></p><p><b><strong >Sent: </strong></b><span >${mailData.info?.MAI_SendDate || ''}</span></p><p><b><strong >To: </strong></b><span >${(mailData.info?.MAI_To || '').replace(/</g,'<').replace(/>/g,'>')}</span></p><p><b><strong >Subject: </strong></b><span >${mailData.info?.MAI_Subject || ''}</span></p><p>${mailData.info?.MAI_ContentType === 'text/html' ? mailData.content : mailData.content.replace(/\r\n/g, '<br>')}</p>`;
|
|
|
|
|
|
|
|
|
|
const generateMailContent = (mailData) => `<br><br><p>${mailData.content}</p>`
|
|
|
|
|
|
|
|
|
@ -368,8 +385,8 @@ const EmailEditorPopup = ({ open, setOpen, fromEmail, fromUser, fromOrder, oid,
|
|
|
|
|
body.coli_sn = emailOrder || '';
|
|
|
|
|
// console.log('body', body, '\n', emailOrder);
|
|
|
|
|
const values = await form.validateFields();
|
|
|
|
|
const preQuoteBody = quoteContent ? quoteContent : generateQuoteContent(mailData);
|
|
|
|
|
body.mailcontent = isRichText ? EmailBuilder({ subject: values.subject, content: htmlContent+preQuoteBody }) : textContent // +preQuoteBody
|
|
|
|
|
const preQuoteBody = quoteContent ? quoteContent : generateQuoteContent(mailData, isRichText);
|
|
|
|
|
body.mailcontent = isRichText ? EmailBuilder({ subject: values.subject, content: htmlContent+preQuoteBody }) : textContent+preQuoteBody
|
|
|
|
|
body.cc = values.cc || '';
|
|
|
|
|
body.bcc = values.bcc || '';
|
|
|
|
|
const msgObj = {
|
|
|
|
|