mjl- / mox

modern full-featured open source secure mail server for low-maintenance self-hosted email
https://www.xmox.nl
MIT License
3.38k stars 89 forks source link

Layout problem when there are many attachments #113

Open jsfan3 opened 6 months ago

jsfan3 commented 6 months ago

Please see this screenshot: there is not enough space for the email body. I suggest that attachments should be in a box that automatically collapses when the email is opened.

screenshot

mjl- commented 6 months ago

Not decoding the filenames with this charset made them longer, that should be fixed with the commit just now. But then we can still have long lists of files. I think the easiest fix indeed is to collapse the list. Probably just show the first N filenames, and a button to show/hide the rest. Let's leave this issue open until I've implemented the show/hide button. It'll be similar to the show/hide button for the To/Cc/Bcc addresses.

For the long term, it could be good to just scroll the entire message view (especially with top/down view). But that's not currently possible because the webmail code doesn't have access to the isolated iframe that holds the message, so can't read its size, so the full message view height can't be calculated. Perhaps there is a different solution, or perhaps the isolation can be relaxed a bit (the open question for me is whether that is safe to do).

jsfan3 commented 6 months ago

I am not familiar with this coding problem, and I also did not understand exactly what the problem is. However, communication between iframe and parent window is possible with the javascript Window.postMessage() method. It allows for safe cross-origin communication between the parent page and the iframe.

You can have the iframe send a message to the parent window whenever its size changes (like when the content is fully loaded or if dynamic changes occur). This message would contain the height of the iframe's content.

In the parent window, an event listener can get messages from the iframe. When a message is received, you can use the provided height to adjust the size of the iframe element in the parent document.

Documentation: https://dev-bay.com/iframe-and-parent-window-postmessage-communication/