diff --git a/public/mail.js b/public/mail.js index 700738b..3c3a9fb 100644 --- a/public/mail.js +++ b/public/mail.js @@ -33,6 +33,14 @@ function mailDoc(html, images) { return ` ${html}`; } +/** On a phone the message is as tall as its text and the page scrolls, so there is one scroll, not a box inside a page. (The box keeps its own scroll on a wide screen.) No scripts run in it: only same-origin so its height can be read. */ +function mailFit(fr) { + if (!fr) return; + const fit = () => { if (!fr.isConnected) return; if (innerWidth >= 1024) { fr.style.height = ''; return; } try { const d = fr.contentDocument; d.documentElement.style.overflowY = 'hidden'; fr.style.height = Math.max(160, Math.ceil(d.documentElement.scrollHeight) + 2) + 'px'; } catch {} }; + fr.addEventListener('load', () => { fit(); try { fr.contentDocument.addEventListener('load', fit, true); } catch {} setTimeout(fit, 300); setTimeout(fit, 1200); }); + if (!mailFit.on) { mailFit.on = true; addEventListener('resize', () => { const f = document.querySelector('.mbody'); if (f) f.dispatchEvent(new Event('fit')); }); } + fr.addEventListener('fit', fit); +} const mailHasRemote = html => /]+src=["']?https?:|url\(\s*["']?https?:/i.test(html || ''); // ---- unread badge and Home card @@ -462,8 +470,9 @@ function mailDrawReader() { ${m.attachments.length ? `
${m.attachments.map(a => `${icon('clip')}${esc(a.name)} ${esc(fmtSize(a.size || 0))}`).join('')}
` : ''} ${remote ? '
Pictures are hidden to protect your privacy.
' : ''} - `; + `; if ($('#mshow')) $('#mshow').onclick = () => { mail.images = true; mailDrawReader(); }; + mailFit(rd.querySelector('.mbody')); rd.querySelectorAll('[data-a]').forEach(b => b.onclick = () => mailAction(b.dataset.a)); } diff --git a/public/style.css b/public/style.css index 0b3cd4b..4713a6e 100644 --- a/public/style.css +++ b/public/style.css @@ -539,14 +539,14 @@ body.lyropen { overflow: hidden; } .mact, .matt { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; } .mact .btn, .matt .btn { min-height: 38px; } .mimg { background: var(--panel2); border-radius: 10px; padding: 8px 12px; font-size: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } -.mbody { width: 100%; flex: 1; min-height: 55dvh; border: 1px solid var(--line); border-radius: 12px; background: #fff; } +.mbody { width: 100%; flex: none; height: 60dvh; min-height: 0; border: 1px solid var(--line); border-radius: 12px; background: #fff; } @media (min-width: 1024px) { .mailapp { grid-template-columns: 340px minmax(0, 1fr); height: calc(100dvh - 40px); min-height: 0; } .mailapp[data-mode] .mlist, .mailapp[data-mode] .mread { display: block; } .mailapp[data-mode] .mread { display: flex; } .mlist, .mread { overflow-y: auto; min-height: 0; } .mback { display: none; } - .mbody { min-height: 0; } + .mbody { flex: 1; height: auto; } } @media (min-width: 1500px) { .mailapp { grid-template-columns: 190px 340px minmax(0, 1fr); } diff --git a/public/sw.js b/public/sw.js index 61b0c9d..c6ce896 100644 --- a/public/sw.js +++ b/public/sw.js @@ -1,5 +1,5 @@ // App-shell cache only; Seafile/API traffic always goes to the network. -const CACHE = 'hub-v48'; +const CACHE = 'hub-v49'; const SHARE = 'hub-share'; // files shared into the app from other apps, held until the person picks a folder const SHELL = ['/icon.svg', '/manifest.webmanifest', '/icons/icon-192.png', '/icons/apple-touch-icon.png'];