courrier preview
This commit is contained in:
parent
c1aa1e8f10
commit
bbe4bc06c2
@ -64,14 +64,11 @@ export default function ComposeEmailAdapter({
|
||||
const adapted = {
|
||||
id: initialEmail.id,
|
||||
subject: formatted.subject,
|
||||
// Format to/cc as expected by ComposeEmail
|
||||
to: formatted.to || initialEmail.from, // Will set recipient to original sender
|
||||
cc: formatted.cc,
|
||||
// Include the original content for quoting
|
||||
to: formatted.to,
|
||||
cc: formatted.cc || '',
|
||||
content: formatted.content?.html || formatted.content?.text || '',
|
||||
html: formatted.content?.html,
|
||||
text: formatted.content?.text,
|
||||
// Copy over attachments if needed
|
||||
attachments: initialEmail.attachments || []
|
||||
};
|
||||
|
||||
@ -85,14 +82,11 @@ export default function ComposeEmailAdapter({
|
||||
const adapted = {
|
||||
id: initialEmail.id,
|
||||
subject: formatted.subject,
|
||||
// Forward doesn't pre-fill recipients
|
||||
to: '',
|
||||
cc: '',
|
||||
// Include the forwarded content
|
||||
content: formatted.content?.html || formatted.content?.text || '',
|
||||
html: formatted.content?.html,
|
||||
text: formatted.content?.text,
|
||||
// Copy over attachments
|
||||
attachments: initialEmail.attachments || []
|
||||
};
|
||||
|
||||
|
||||
@ -99,8 +99,23 @@ const RichEmailEditor: React.FC<RichEmailEditorProps> = ({
|
||||
// Detect text direction
|
||||
const direction = detectTextDirection(initialContent);
|
||||
|
||||
// Process HTML content using centralized utility
|
||||
const sanitizedContent = processHtmlContent(initialContent);
|
||||
// Check if content already appears to be properly formatted as a reply or forward
|
||||
const isPreFormattedContent = (
|
||||
(initialContent.includes('---------- Forwarded message ----------') ||
|
||||
initialContent.includes('wrote:')) &&
|
||||
initialContent.includes('<blockquote')
|
||||
);
|
||||
|
||||
// Process HTML content using centralized utility or use as-is if pre-formatted
|
||||
let sanitizedContent;
|
||||
if (isPreFormattedContent) {
|
||||
console.log('Content appears to be pre-formatted as reply/forward, using as-is');
|
||||
// Just do basic sanitization without additional processing
|
||||
sanitizedContent = sanitizeHtml(initialContent);
|
||||
} else {
|
||||
// Full processing for regular content
|
||||
sanitizedContent = processHtmlContent(initialContent);
|
||||
}
|
||||
|
||||
// Log sanitized content details for debugging
|
||||
console.log('Sanitized content details:', {
|
||||
@ -239,8 +254,23 @@ const RichEmailEditor: React.FC<RichEmailEditorProps> = ({
|
||||
// Detect text direction
|
||||
const direction = detectTextDirection(initialContent);
|
||||
|
||||
// Process HTML content using centralized utility
|
||||
const sanitizedContent = processHtmlContent(initialContent);
|
||||
// Check if content already appears to be properly formatted as a reply or forward
|
||||
const isPreFormattedContent = (
|
||||
(initialContent.includes('---------- Forwarded message ----------') ||
|
||||
initialContent.includes('wrote:')) &&
|
||||
initialContent.includes('<blockquote')
|
||||
);
|
||||
|
||||
// Process HTML content using centralized utility or use as-is if pre-formatted
|
||||
let sanitizedContent;
|
||||
if (isPreFormattedContent) {
|
||||
console.log('Content appears to be pre-formatted as reply/forward, using as-is');
|
||||
// Just do basic sanitization without additional processing
|
||||
sanitizedContent = sanitizeHtml(initialContent);
|
||||
} else {
|
||||
// Full processing for regular content
|
||||
sanitizedContent = processHtmlContent(initialContent);
|
||||
}
|
||||
|
||||
// Log sanitized content details for debugging
|
||||
console.log('Sanitized content details:', {
|
||||
|
||||
@ -281,26 +281,26 @@ export function formatReplyEmail(originalEmail: EmailMessage | LegacyEmailMessag
|
||||
const sender = fromStr;
|
||||
const date = dateStr;
|
||||
|
||||
// Process the original content using formatEmailContent for consistent rendering
|
||||
const { text: textContent, html: originalHtmlContent } = extractEmailContent(email.content);
|
||||
// Extract raw content from the original email
|
||||
const { text: originalTextContent, html: originalHtmlContent } = extractEmailContent(email.content);
|
||||
|
||||
// Get the properly formatted content using the same utility as the preview panel
|
||||
const processedContent = formatEmailContent(email.content);
|
||||
// First sanitize the original content
|
||||
const sanitizedContent = sanitizeHtml(originalHtmlContent || originalTextContent);
|
||||
|
||||
// Create the quoted reply HTML
|
||||
const htmlContent = `
|
||||
// Build the reply structure with sanitized but not yet fully formatted content
|
||||
const replyStructure = `
|
||||
<div style="margin: 20px 0 10px 0; color: #666; border-bottom: 1px solid #ddd; padding-bottom: 5px;">
|
||||
On ${date}, ${sender} wrote:
|
||||
</div>
|
||||
<blockquote style="margin: 0; padding-left: 10px; border-left: 3px solid #ddd; color: #505050; background-color: #f9f9f9; padding: 10px;">
|
||||
${processedContent}
|
||||
${sanitizedContent}
|
||||
</blockquote>
|
||||
`;
|
||||
|
||||
// Format plain text reply if available
|
||||
let formattedTextContent = '';
|
||||
if (textContent) {
|
||||
const lines = textContent.split(/\r\n|\r|\n/);
|
||||
if (originalTextContent) {
|
||||
const lines = originalTextContent.split(/\r\n|\r|\n/);
|
||||
formattedTextContent = `On ${date}, ${sender} wrote:\n\n${lines.map(line => `> ${line}`).join('\n')}`;
|
||||
}
|
||||
|
||||
@ -309,8 +309,8 @@ export function formatReplyEmail(originalEmail: EmailMessage | LegacyEmailMessag
|
||||
cc: cc || undefined,
|
||||
subject,
|
||||
content: {
|
||||
html: htmlContent,
|
||||
text: formattedTextContent || textContent,
|
||||
html: replyStructure,
|
||||
text: formattedTextContent || originalTextContent,
|
||||
isHtml: true,
|
||||
direction: typeof email.content === 'object' && email.content ? email.content.direction || 'ltr' : 'ltr',
|
||||
},
|
||||
@ -374,14 +374,14 @@ export function formatForwardedEmail(originalEmail: EmailMessage | LegacyEmailMe
|
||||
// Original sent date
|
||||
const date = dateStr;
|
||||
|
||||
// Process the original content using formatEmailContent for consistent rendering
|
||||
const { text: textContent } = extractEmailContent(email.content);
|
||||
// Extract raw content from the original email
|
||||
const { text: originalTextContent, html: originalHtmlContent } = extractEmailContent(email.content);
|
||||
|
||||
// Get the properly formatted content using the same utility as the preview panel
|
||||
const processedContent = formatEmailContent(email.content);
|
||||
// First sanitize the original content
|
||||
const sanitizedContent = sanitizeHtml(originalHtmlContent || originalTextContent);
|
||||
|
||||
// Create the forwarded email HTML content with the properly processed content
|
||||
const htmlContent = `
|
||||
// Build the forward structure with sanitized but not yet fully formatted content
|
||||
const forwardStructure = `
|
||||
<div style="margin: 20px 0 10px 0; color: #666; font-family: Arial, sans-serif;">
|
||||
---------- Forwarded message ----------<br>
|
||||
<table style="margin: 10px 0 15px 0; border-collapse: collapse; font-size: 13px; color: #333;">
|
||||
@ -412,13 +412,13 @@ export function formatForwardedEmail(originalEmail: EmailMessage | LegacyEmailMe
|
||||
</table>
|
||||
</div>
|
||||
<blockquote style="margin: 0; padding-left: 10px; border-left: 3px solid #ddd; color: #505050; background-color: #f9f9f9; padding: 10px;">
|
||||
${processedContent}
|
||||
${sanitizedContent}
|
||||
</blockquote>
|
||||
`;
|
||||
|
||||
// Format plain text version
|
||||
let formattedTextContent = '';
|
||||
if (textContent) {
|
||||
if (originalTextContent) {
|
||||
formattedTextContent = `
|
||||
---------- Forwarded message ----------
|
||||
From: ${fromStr}
|
||||
@ -427,7 +427,7 @@ Subject: ${email.subject || ''}
|
||||
To: ${toStr}
|
||||
${ccStr ? `Cc: ${ccStr}\n` : ''}
|
||||
|
||||
${textContent}
|
||||
${originalTextContent}
|
||||
`.trim();
|
||||
}
|
||||
|
||||
@ -435,8 +435,8 @@ ${textContent}
|
||||
to: '',
|
||||
subject,
|
||||
content: {
|
||||
html: htmlContent,
|
||||
text: formattedTextContent || textContent,
|
||||
html: forwardStructure,
|
||||
text: formattedTextContent || originalTextContent,
|
||||
isHtml: true,
|
||||
direction: typeof email.content === 'object' && email.content ? email.content.direction || 'ltr' : 'ltr',
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user