- 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.
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
/** Hauteur utile du corps d’un iframe d’aperç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)
|
||
}
|