- On ${new Date(emailToProcess?.date || Date.now()).toLocaleString()}, ${emailToProcess?.from || 'Unknown Sender'} wrote:
+ On ${new Date(emailToProcess?.date || Date.now()).toLocaleString()}, ${formatEmailAddresses(emailToProcess?.from) || 'Unknown Sender'} wrote:
+
${emailContent}
`;
@@ -243,7 +261,7 @@ export default function ComposeEmail({
// Set the content in the compose area with proper structure
formattedContent = `
`;
@@ -266,17 +284,33 @@ export default function ComposeEmail({
// After setting the HTML content, add event listeners for scrolling
const messageContents = composeBodyRef.current.querySelectorAll('.message-content');
messageContents.forEach(container => {
- container.addEventListener('wheel', (e: Event) => {
- const wheelEvent = e as WheelEvent;
- const target = e.currentTarget as HTMLElement;
- const isAtBottom = target.scrollHeight - target.scrollTop <= target.clientHeight + 1;
- const isAtTop = target.scrollTop <= 0;
+ // Make sure the container is properly styled for scrolling
+ (container as HTMLElement).style.maxHeight = '300px';
+ (container as HTMLElement).style.overflowY = 'auto';
+ (container as HTMLElement).style.border = '1px solid #e5e7eb';
+ (container as HTMLElement).style.borderRadius = '4px';
+ (container as HTMLElement).style.padding = '10px';
+
+ // Ensure wheel events are properly handled
+ if (!(container as HTMLElement).hasAttribute('data-scroll-handler-attached')) {
+ container.addEventListener('wheel', (e: Event) => {
+ const wheelEvent = e as WheelEvent;
+ const target = e.currentTarget as HTMLElement;
+
+ // Check if we're at the boundary of the scrollable area
+ const isAtBottom = target.scrollHeight - target.scrollTop <= target.clientHeight + 1;
+ const isAtTop = target.scrollTop <= 0;
+
+ // Only prevent default if we're not at the boundaries in the direction of scrolling
+ if ((wheelEvent.deltaY > 0 && !isAtBottom) || (wheelEvent.deltaY < 0 && !isAtTop)) {
+ e.stopPropagation();
+ e.preventDefault(); // Prevent the parent container from scrolling
+ }
+ }, { passive: false });
- // Let the container handle scrolling only if not at boundaries
- if ((wheelEvent.deltaY > 0 && !isAtBottom) || (wheelEvent.deltaY < 0 && !isAtTop)) {
- e.stopPropagation();
- }
- });
+ // Mark this element as having a scroll handler attached
+ (container as HTMLElement).setAttribute('data-scroll-handler-attached', 'true');
+ }
});
// Update compose state
@@ -335,6 +369,30 @@ export default function ComposeEmail({
// Make sure the div remains scrollable after input events
(div as HTMLElement).style.maxHeight = '300px';
(div as HTMLElement).style.overflowY = 'auto';
+ (div as HTMLElement).style.border = '1px solid #e5e7eb';
+ (div as HTMLElement).style.borderRadius = '4px';
+ (div as HTMLElement).style.padding = '10px';
+
+ // Ensure wheel events are properly handled
+ if (!(div as HTMLElement).hasAttribute('data-scroll-handler-attached')) {
+ div.addEventListener('wheel', (e: Event) => {
+ const wheelEvent = e as WheelEvent;
+ const target = e.currentTarget as HTMLElement;
+
+ // Check if we're at the boundary of the scrollable area
+ const isAtBottom = target.scrollHeight - target.scrollTop <= target.clientHeight + 1;
+ const isAtTop = target.scrollTop <= 0;
+
+ // Only prevent default if we're not at the boundaries in the direction of scrolling
+ if ((wheelEvent.deltaY > 0 && !isAtBottom) || (wheelEvent.deltaY < 0 && !isAtTop)) {
+ e.stopPropagation();
+ e.preventDefault(); // Prevent the parent container from scrolling
+ }
+ }, { passive: false });
+
+ // Mark this element as having a scroll handler attached
+ (div as HTMLElement).setAttribute('data-scroll-handler-attached', 'true');
+ }
});
};
@@ -511,7 +569,8 @@ export default function ComposeEmail({
minHeight: '200px',
overflowY: 'auto',
scrollbarWidth: 'thin',
- scrollbarColor: '#cbd5e0 #f3f4f6'
+ scrollbarColor: '#cbd5e0 #f3f4f6',
+ cursor: 'text'
}}
dir="ltr"
spellCheck="true"