From 068a02ff64da12fb2c98f3b5a2b64558c75dc4bd Mon Sep 17 00:00:00 2001
From: Lei OT with line breaks
- Array.from(dom.body.querySelectorAll('br, p')).forEach((el) => {
- el.textContent = '\n' + el.textContent
- })
+ // Array.from(dom.body.querySelectorAll('br, p')).forEach((el) => {
+ // el.textContent = '
and
' + el.textContent
+ // })
// Replace
with a line of dashes
- Array.from(dom.body.querySelectorAll('hr')).forEach((el) => {
- el.textContent = '\n------------------------------------------------------------------\n'
- })
- return dom.body.textContent || ''
+ // Array.from(dom.body.querySelectorAll('hr')).forEach((el) => {
+ // el.innerHTML = '
------------------------------------------------------------------
------------------------------------------------------------------
' + return line+(dom.body.innerHTML || '') } const generateQuoteContent = (mailData, isRichText = true) => { @@ -199,6 +200,8 @@ const NewEmail = () => { mat_sn: emailAccount?.mat_sn || info?.MAI_MAT_SN || defaultMAT, opi_sn: emailAccount?.opi_sn || info?.MAI_OPI_SN || orderDetail.opi_sn || '', } + const originalContentType = info?.mailType === 'text/html'; + setIsRichText(originalContentType) let readyToInitialContent = ''; let _formValues = {}; @@ -225,6 +228,7 @@ const NewEmail = () => { subject: `Re: ${info.MAI_Subject || ''}`, ..._form2 } + readyToInitialContent += generateQuoteContent(mailData, originalContentType) break case 'replyall': _formValues = { @@ -235,6 +239,7 @@ const NewEmail = () => { subject: `Re: ${info.MAI_Subject || ''}`, ..._form2 } + readyToInitialContent += generateQuoteContent(mailData, originalContentType) break case 'forward': _formValues = { @@ -243,6 +248,7 @@ const NewEmail = () => { // coli_sn: pageParam.oid, ..._form2 } + readyToInitialContent += generateQuoteContent(mailData, originalContentType) break case 'edit': _formValues = { @@ -341,12 +347,14 @@ const NewEmail = () => { } const handleEditorChange = ({ editorStateJSON, htmlContent, textContent }) => { - // console.log('textContent', textContent); + const _text = textContent.replace(/\r\n/g, '\n').replace(/\n{2,}/g, '\n') + // console.log('textContent---\n', textContent, 'textContent'); // console.log('html', html); setHtmlContent(htmlContent) - setTextContent(textContent) + setTextContent(_text) form.setFieldValue('content', htmlContent) - const { bodyText: abstract } = parseHTMLString(htmlContent, true); + const abstract = _text; + // const { bodyText: abstract } = parseHTMLString(htmlContent, true); // form.setFieldValue('abstract', getAbstract(textContent)) const formValues = omitEmpty(form.getFieldsValue()); if (!isEmpty(formValues)) { @@ -496,8 +504,8 @@ const NewEmail = () => { body.attaList = fileList; // console.log('body', body, '\n', fileList); const values = await form.validateFields() - const preQuoteBody = !['edit', 'new'].includes(pageParam.action) && pageParam.quoteid ? (quoteContent ? quoteContent : generateQuoteContent(mailData, isRichText)) : '' - body.mailcontent = isRichText ? EmailBuilder({ subject: values.subject, content: htmlContent + preQuoteBody }) : textContent + preQuoteBody + // const preQuoteBody = !['edit', 'new'].includes(pageParam.action) && pageParam.quoteid ? (quoteContent ? quoteContent : generateQuoteContent(mailData, isRichText)) : '' + body.mailcontent = isRichText ? EmailBuilder({ subject: values.subject, content: htmlContent }) : textContent body.cc = values.cc || '' body.bcc = values.bcc || '' body.bcc = values.mailtype || '' @@ -517,6 +525,8 @@ const NewEmail = () => { try { // console.log('postSendEmail', body, '\n'); + // console.log('🎈postSendEmail mailContent', body.mailcontent, '\n'); + // throw new Error('test') // return; const mailSavedId = await postEmailSaveOrSend(body, isDraft) form.setFieldsValue({ @@ -703,20 +713,17 @@ const NewEmail = () => {