react-email 6.11.0 → 6.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/cli/index.mjs +31 -2
- package/dist/components/markdown/markdown.cjs +2 -1
- package/dist/components/markdown/markdown.mjs +2 -1
- package/package.json +1 -1
- package/src/components/markdown/markdown.spec.tsx +29 -0
- package/src/components/markdown/markdown.tsx +4 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# react-email
|
|
2
2
|
|
|
3
|
+
## 6.11.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 54769fc: Prevent `email export` from deleting the project, the home directory, the email templates or the static assets when `--outDir` points at them.
|
|
8
|
+
- 6926bac: `<Markdown>` now applies `markdownCustomStyles.th` to table header cells. Header cells were previously styled with `td`, so any `th` styles were ignored.
|
|
9
|
+
|
|
3
10
|
## 6.11.0
|
|
4
11
|
|
|
5
12
|
### Minor Changes
|
package/dist/cli/index.mjs
CHANGED
|
@@ -6533,7 +6533,7 @@ const getTracingRootDir = async (usersProjectLocation) => {
|
|
|
6533
6533
|
//#region package.json
|
|
6534
6534
|
var package_default = {
|
|
6535
6535
|
name: "react-email",
|
|
6536
|
-
version: "6.11.
|
|
6536
|
+
version: "6.11.1",
|
|
6537
6537
|
description: "A live preview of your emails right in your browser.",
|
|
6538
6538
|
bin: { "email": "./dist/cli/index.mjs" },
|
|
6539
6539
|
type: "module",
|
|
@@ -7580,6 +7580,19 @@ const getEmailTemplatesFromDirectory = (emailDirectory) => {
|
|
|
7580
7580
|
for (const directory of emailDirectory.subDirectories) templatePaths.push(...getEmailTemplatesFromDirectory(directory));
|
|
7581
7581
|
return templatePaths;
|
|
7582
7582
|
};
|
|
7583
|
+
const isInside = (parent, child) => child.startsWith(`${parent}${path.sep}`);
|
|
7584
|
+
const getUnsafeOutDirMessage = (outDir, emailsDirectoryPath, { cwd, homeDirectory }) => {
|
|
7585
|
+
const resolvedOutDir = path.resolve(cwd, outDir);
|
|
7586
|
+
const resolvedEmailsDirectory = path.resolve(cwd, emailsDirectoryPath);
|
|
7587
|
+
const staticDirectory = path.join(resolvedEmailsDirectory, "static");
|
|
7588
|
+
if (resolvedOutDir === path.parse(resolvedOutDir).root) return "--outDir can't be the filesystem root.";
|
|
7589
|
+
if (resolvedOutDir === homeDirectory) return "--outDir can't be your home directory.";
|
|
7590
|
+
if (isInside(resolvedOutDir, homeDirectory)) return "--outDir can't contain your home directory.";
|
|
7591
|
+
if (resolvedOutDir === cwd) return "--outDir can't be the project directory.";
|
|
7592
|
+
if (isInside(resolvedOutDir, cwd)) return "--outDir can't contain the project directory.";
|
|
7593
|
+
if (resolvedOutDir === resolvedEmailsDirectory || isInside(resolvedOutDir, resolvedEmailsDirectory)) return "--outDir can't contain your email templates.";
|
|
7594
|
+
if (resolvedOutDir === staticDirectory || isInside(staticDirectory, resolvedOutDir)) return "--outDir can't be your static assets directory.";
|
|
7595
|
+
};
|
|
7583
7596
|
const BUILD_BATCH_SIZE = 10;
|
|
7584
7597
|
const RENDER_BATCH_SIZE = 25;
|
|
7585
7598
|
const renderWorkerSource = `
|
|
@@ -7627,7 +7640,23 @@ const exportTemplates = async (pathToWhereEmailMarkupShouldBeDumped, emailsDirec
|
|
|
7627
7640
|
else console.error(`Could not find the directory at ${emailsDirectoryPath}`);
|
|
7628
7641
|
process.exit(1);
|
|
7629
7642
|
}
|
|
7630
|
-
|
|
7643
|
+
const resolvedPathToWhereEmailMarkupShouldBeDumped = path.resolve(process.cwd(), pathToWhereEmailMarkupShouldBeDumped);
|
|
7644
|
+
if (fs.existsSync(resolvedPathToWhereEmailMarkupShouldBeDumped)) {
|
|
7645
|
+
const unsafeOutDirMessage = getUnsafeOutDirMessage(resolvedPathToWhereEmailMarkupShouldBeDumped, emailsDirectoryPath, {
|
|
7646
|
+
cwd: process.cwd(),
|
|
7647
|
+
homeDirectory: os.homedir()
|
|
7648
|
+
});
|
|
7649
|
+
if (unsafeOutDirMessage) {
|
|
7650
|
+
const message = `${unsafeOutDirMessage} Choose a different --outDir, such as "out".`;
|
|
7651
|
+
if (spinner) stopSpinnerAndPersist(spinner, {
|
|
7652
|
+
symbol: logSymbols.error,
|
|
7653
|
+
text: message
|
|
7654
|
+
});
|
|
7655
|
+
else console.error(message);
|
|
7656
|
+
process.exit(1);
|
|
7657
|
+
}
|
|
7658
|
+
fs.rmSync(resolvedPathToWhereEmailMarkupShouldBeDumped, { recursive: true });
|
|
7659
|
+
}
|
|
7631
7660
|
const allTemplates = getEmailTemplatesFromDirectory(emailsDirectoryMetadata);
|
|
7632
7661
|
try {
|
|
7633
7662
|
const userPlugins = options.esbuildPlugins ? await loadEsbuildPlugins(path.resolve(process.cwd(), options.esbuildPlugins)) : [];
|
|
@@ -80,7 +80,8 @@ const Markdown = react.forwardRef(({ children, markdownContainerStyles, markdown
|
|
|
80
80
|
renderer.tablecell = ({ tokens, align, header }) => {
|
|
81
81
|
const text = renderer.parser.parseInline(tokens);
|
|
82
82
|
const type = header ? "th" : "td";
|
|
83
|
-
|
|
83
|
+
const style = require_parse_css_in_js_to_inline_css.parseCssInJsToInlineCss(finalStyles[type]);
|
|
84
|
+
return `${`<${type}${align ? ` align="${align}"` : ""}${style !== "" ? ` style="${style}"` : ""}>`}${text}</${type}>\n`;
|
|
84
85
|
};
|
|
85
86
|
renderer.tablerow = ({ text }) => {
|
|
86
87
|
return `<tr${require_parse_css_in_js_to_inline_css.parseCssInJsToInlineCss(finalStyles.tr) !== "" ? ` style="${require_parse_css_in_js_to_inline_css.parseCssInJsToInlineCss(finalStyles.tr)}"` : ""}>\n${text}</tr>\n`;
|
|
@@ -78,7 +78,8 @@ const Markdown = React$1.forwardRef(({ children, markdownContainerStyles, markdo
|
|
|
78
78
|
renderer.tablecell = ({ tokens, align, header }) => {
|
|
79
79
|
const text = renderer.parser.parseInline(tokens);
|
|
80
80
|
const type = header ? "th" : "td";
|
|
81
|
-
|
|
81
|
+
const style = parseCssInJsToInlineCss(finalStyles[type]);
|
|
82
|
+
return `${`<${type}${align ? ` align="${align}"` : ""}${style !== "" ? ` style="${style}"` : ""}>`}${text}</${type}>\n`;
|
|
82
83
|
};
|
|
83
84
|
renderer.tablerow = ({ text }) => {
|
|
84
85
|
return `<tr${parseCssInJsToInlineCss(finalStyles.tr) !== "" ? ` style="${parseCssInJsToInlineCss(finalStyles.tr)}"` : ""}>\n${text}</tr>\n`;
|
package/package.json
CHANGED
|
@@ -218,4 +218,33 @@ console.log(\`Hello, $\{name}!\`);
|
|
|
218
218
|
</div><!--/$-->"
|
|
219
219
|
`);
|
|
220
220
|
});
|
|
221
|
+
it('applies th styles to table header cells and td styles to body cells', async () => {
|
|
222
|
+
const actualOutput = await render(
|
|
223
|
+
<Markdown
|
|
224
|
+
markdownCustomStyles={{
|
|
225
|
+
th: { fontWeight: 'bold' },
|
|
226
|
+
td: { color: 'gray' },
|
|
227
|
+
}}
|
|
228
|
+
>
|
|
229
|
+
{`| Name | Qty |
|
|
230
|
+
| ---- | --: |
|
|
231
|
+
| Apples | 3 |`}
|
|
232
|
+
</Markdown>,
|
|
233
|
+
);
|
|
234
|
+
expect(actualOutput).toMatchInlineSnapshot(`
|
|
235
|
+
"<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><!--$--><div data-id="react-email-markdown"><table role="presentation">
|
|
236
|
+
<thead>
|
|
237
|
+
<tr>
|
|
238
|
+
<th style="font-weight:bold">Name</th>
|
|
239
|
+
<th align="right" style="font-weight:bold">Qty</th>
|
|
240
|
+
</tr>
|
|
241
|
+
</thead>
|
|
242
|
+
<tbody><tr>
|
|
243
|
+
<td style="color:gray">Apples</td>
|
|
244
|
+
<td align="right" style="color:gray">3</td>
|
|
245
|
+
</tr>
|
|
246
|
+
</tbody></table>
|
|
247
|
+
</div><!--/$-->"
|
|
248
|
+
`);
|
|
249
|
+
});
|
|
221
250
|
});
|
|
@@ -197,17 +197,10 @@ export const Markdown = React.forwardRef<HTMLDivElement, MarkdownProps>(
|
|
|
197
197
|
renderer.tablecell = ({ tokens, align, header }) => {
|
|
198
198
|
const text = renderer.parser.parseInline(tokens);
|
|
199
199
|
const type = header ? 'th' : 'td';
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
: ''
|
|
205
|
-
}>`
|
|
206
|
-
: `<${type}${
|
|
207
|
-
parseCssInJsToInlineCss(finalStyles.td) !== ''
|
|
208
|
-
? ` style="${parseCssInJsToInlineCss(finalStyles.td)}"`
|
|
209
|
-
: ''
|
|
210
|
-
}>`;
|
|
200
|
+
const style = parseCssInJsToInlineCss(finalStyles[type]);
|
|
201
|
+
const tag = `<${type}${align ? ` align="${align}"` : ''}${
|
|
202
|
+
style !== '' ? ` style="${style}"` : ''
|
|
203
|
+
}>`;
|
|
211
204
|
return `${tag}${text}</${type}>\n`;
|
|
212
205
|
};
|
|
213
206
|
|