This commit was merged in pull request #292.
This commit is contained in:
@@ -31,10 +31,13 @@ String buildEmailHtml(String htmlBody, {bool loadRemoteImages = false}) {
|
|||||||
<meta name="color-scheme" content="light">
|
<meta name="color-scheme" content="light">
|
||||||
<meta http-equiv="Content-Security-Policy" content="$csp">
|
<meta http-equiv="Content-Security-Policy" content="$csp">
|
||||||
<style>
|
<style>
|
||||||
body { margin: 0; padding: 0; font-family: sans-serif; word-break: break-word; color-scheme: light; background-color: #ffffff; color: #000000; }
|
body { margin: 0; padding: 0; font-family: sans-serif; word-break: break-word; overflow-x: hidden; color-scheme: light; background-color: #ffffff; color: #000000; }
|
||||||
img { max-width: 100%; height: auto; }
|
img { max-width: 100%; height: auto; }
|
||||||
a { color: #1976D2; }
|
a { color: #1976D2; }
|
||||||
* { box-sizing: border-box; }
|
* { box-sizing: border-box; max-width: 100%; }
|
||||||
|
table { width: 100%; border-collapse: collapse; }
|
||||||
|
td, th { overflow-wrap: break-word; word-break: break-word; }
|
||||||
|
pre { white-space: pre-wrap; word-break: break-word; overflow-x: auto; }
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -41,6 +41,20 @@ void main() {
|
|||||||
expect(html, contains('https: http: data: blob:'));
|
expect(html, contains('https: http: data: blob:'));
|
||||||
_expectLightMode(html);
|
_expectLightMode(html);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('prevents horizontal overflow so wide HTML emails are not cut off',
|
||||||
|
() {
|
||||||
|
final html =
|
||||||
|
buildEmailHtml('<table width="600"><tr><td>x</td></tr></table>');
|
||||||
|
// Body clips overflow so fixed-width email tables don't escape the viewport.
|
||||||
|
expect(html, contains('overflow-x: hidden'));
|
||||||
|
// Tables are forced to full viewport width so fixed pixel widths don't overflow.
|
||||||
|
expect(html, contains('table { width: 100%'));
|
||||||
|
// All elements are capped at viewport width via max-width.
|
||||||
|
expect(html, contains('max-width: 100%'));
|
||||||
|
// Pre-formatted text wraps instead of stretching the page.
|
||||||
|
expect(html, contains('white-space: pre-wrap'));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// On Linux (the test host) the widget falls back to plain text extracted via
|
// On Linux (the test host) the widget falls back to plain text extracted via
|
||||||
|
|||||||
Reference in New Issue
Block a user