ultisuite-client/lib/email-preview-iframe-height.ts
R3D347HR4Y 8a02c10ba3 Add environment configuration and update email view components
- Created a .cursorignore file to manage local environment files.
- Updated .env.example to reflect changes in the public app URL.
- Modified the gmail workspace configuration to include the drive-suite path.
- Enhanced email view components to support attachment handling and fallback for plain text bodies.
- Improved user experience by updating attachment display logic and integrating inline attachment support.
2026-06-04 00:12:43 +02:00

41 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/** Hauteur utile du corps dun iframe daperçu mail (évite le scrollHeight fantôme). */
export const EMAIL_PREVIEW_MIN_IFRAME_HEIGHT = 120
const CONTENT_MEASURE_SELECTORS =
"p,div,span,td,th,li,h1,h2,h3,h4,h5,h6,table,img,blockquote,pre,hr,a,section,article,footer,header"
export function measureEmailPreviewIframeHeight(doc: Document): number {
const body = doc.body
const view = doc.defaultView
if (!body || !view) return EMAIL_PREVIEW_MIN_IFRAME_HEIGHT
const scrollEstimate = Math.max(
body.scrollHeight,
body.offsetHeight,
doc.documentElement?.scrollHeight ?? 0,
doc.documentElement?.offsetHeight ?? 0
)
const bodyTop = body.getBoundingClientRect().top
let contentBottom = bodyTop
for (const el of body.querySelectorAll(CONTENT_MEASURE_SELECTORS)) {
const cs = view.getComputedStyle(el)
if (cs.display === "none" || cs.visibility === "hidden") continue
const rect = el.getBoundingClientRect()
if (rect.height < 1 && rect.width < 1) continue
contentBottom = Math.max(contentBottom, rect.bottom)
}
const hasVisibleLayout = contentBottom > bodyTop + 8
if (hasVisibleLayout) {
const boundEstimate = Math.ceil(contentBottom - bodyTop) + 4
if (boundEstimate < scrollEstimate * 0.92) {
return Math.max(EMAIL_PREVIEW_MIN_IFRAME_HEIGHT, boundEstimate)
}
}
return Math.max(EMAIL_PREVIEW_MIN_IFRAME_HEIGHT, scrollEstimate + 2)
}