@maily-to/render 0.2.3 → 2.0.0-beta.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/dist/index.cjs +1428 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +230 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +194 -256
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1397 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +42 -48
- package/readme.md +20 -56
- package/dist/index.d.ts +0 -292
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,69 +1,63 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maily-to/render",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "2.0.0-beta.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A transformer that converts Maily content into HTML email templates.",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
"keywords": [
|
|
7
|
+
"email",
|
|
8
|
+
"maily.to",
|
|
9
|
+
"react"
|
|
10
|
+
],
|
|
11
|
+
"author": "Arik Chakma <arikchangma@gmail.com>",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/arikchakma/maily.to.git",
|
|
15
|
+
"directory": "packages/render"
|
|
16
|
+
},
|
|
10
17
|
"files": [
|
|
11
18
|
"dist/**"
|
|
12
19
|
],
|
|
20
|
+
"type": "module",
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"main": "./dist/index.cjs",
|
|
23
|
+
"module": "./dist/index.mjs",
|
|
24
|
+
"types": "./dist/index.d.cts",
|
|
13
25
|
"exports": {
|
|
14
26
|
".": {
|
|
15
|
-
"import":
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
}
|
|
27
|
+
"import": "./dist/index.mjs",
|
|
28
|
+
"require": "./dist/index.cjs"
|
|
29
|
+
},
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
24
34
|
},
|
|
25
35
|
"scripts": {
|
|
26
|
-
"
|
|
36
|
+
"build": "vp pack",
|
|
27
37
|
"clean": "rm -rf dist",
|
|
28
|
-
"
|
|
38
|
+
"dev": "vp pack --watch",
|
|
29
39
|
"lint": "eslint .",
|
|
30
40
|
"lint:fix": "eslint . --fix",
|
|
31
|
-
"
|
|
32
|
-
"test": "
|
|
41
|
+
"release": "bumpp",
|
|
42
|
+
"test": "vp test run"
|
|
33
43
|
},
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"url": "git+https://github.com/arikchakma/maily.to.git",
|
|
37
|
-
"directory": "packages/render"
|
|
38
|
-
},
|
|
39
|
-
"author": "Arik Chakma <arikchangma@gmail.com>",
|
|
40
|
-
"keywords": [
|
|
41
|
-
"maily.to",
|
|
42
|
-
"react",
|
|
43
|
-
"email"
|
|
44
|
-
],
|
|
45
|
-
"engines": {
|
|
46
|
-
"node": ">=18.0.0"
|
|
47
|
-
},
|
|
48
|
-
"devDependencies": {
|
|
49
|
-
"@antfu/utils": "^9.2.0",
|
|
50
|
-
"@babel/preset-react": "^7.27.1",
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@maily-to/migration": "workspace:*",
|
|
51
46
|
"@maily-to/shared": "workspace:*",
|
|
52
|
-
"@
|
|
53
|
-
"@
|
|
54
|
-
"
|
|
55
|
-
"
|
|
47
|
+
"@react-email/components": "^1.0.12",
|
|
48
|
+
"@react-email/render": "^2.0.6",
|
|
49
|
+
"juice": "^11.1.1",
|
|
50
|
+
"node-html-parser": "^7.1.0"
|
|
56
51
|
},
|
|
57
|
-
"
|
|
58
|
-
"@
|
|
59
|
-
"@react
|
|
60
|
-
"
|
|
61
|
-
"
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@maily-to/tsconfig": "workspace:*",
|
|
54
|
+
"@types/react": "catalog:",
|
|
55
|
+
"bumpp": "catalog:",
|
|
56
|
+
"typescript": "catalog:",
|
|
57
|
+
"vite-plus": "catalog:"
|
|
62
58
|
},
|
|
63
59
|
"peerDependencies": {
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
"publishConfig": {
|
|
67
|
-
"access": "public"
|
|
60
|
+
"@tiptap/core": "catalog:",
|
|
61
|
+
"react": "catalog:"
|
|
68
62
|
}
|
|
69
63
|
}
|
package/readme.md
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
<br>
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
### Install
|
|
20
20
|
|
|
21
21
|
Install `@maily-to/render` from your command line.
|
|
22
22
|
|
|
@@ -26,9 +26,9 @@ pnpm add @maily-to/render
|
|
|
26
26
|
|
|
27
27
|
<br>
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
### Getting started
|
|
30
30
|
|
|
31
|
-
Convert
|
|
31
|
+
Convert Maily editor JSON into an HTML string.
|
|
32
32
|
|
|
33
33
|
```ts
|
|
34
34
|
import { render } from '@maily-to/render';
|
|
@@ -49,69 +49,33 @@ const html = await render({
|
|
|
49
49
|
});
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
#### Variables
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
All user-provided data lives under a single `variables` key — string substitution, visibility checks, repeat arrays, and link overrides.
|
|
55
55
|
|
|
56
56
|
```ts
|
|
57
|
-
import {
|
|
57
|
+
import { render } from '@maily-to/render';
|
|
58
58
|
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
{
|
|
67
|
-
type: 'variable',
|
|
68
|
-
attrs: {
|
|
69
|
-
id: 'currentDate',
|
|
70
|
-
fallback: 'now',
|
|
71
|
-
showIfKey: null,
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
],
|
|
75
|
-
},
|
|
76
|
-
],
|
|
59
|
+
const html = await render(doc, {
|
|
60
|
+
variables: {
|
|
61
|
+
name: 'Alice', // string → variable substitution
|
|
62
|
+
active: true, // boolean → visibility rules
|
|
63
|
+
items: [{ id: 1 }], // array → repeat iteration
|
|
64
|
+
cta: 'https://example.com', // string → link href override
|
|
65
|
+
},
|
|
77
66
|
});
|
|
78
|
-
|
|
79
|
-
maily.setVariableValue('currentDate', new Date().toISOString());
|
|
80
|
-
const html = await maily.render();
|
|
81
67
|
```
|
|
82
68
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
Payload values are used for the `Repeat` and `Show If` blocks.
|
|
69
|
+
Variable resolution follows a 3-stage priority chain:
|
|
86
70
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const maily = new Maily({
|
|
91
|
-
type: 'doc',
|
|
92
|
-
content: [
|
|
93
|
-
{
|
|
94
|
-
type: 'repeat',
|
|
95
|
-
attrs: { each: 'items', showIfKey: null },
|
|
96
|
-
content: [
|
|
97
|
-
{
|
|
98
|
-
type: 'paragraph',
|
|
99
|
-
attrs: { textAlign: 'left' },
|
|
100
|
-
content: [{ type: 'text', text: 'Hello' }],
|
|
101
|
-
},
|
|
102
|
-
],
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
maily.setPayloadValue('items', ['Alice', 'Bob', 'Charlie']);
|
|
108
|
-
const html = await maily.render();
|
|
109
|
-
```
|
|
71
|
+
1. `item` — per-iteration data set by repeat nodes
|
|
72
|
+
2. `variables` — the map above
|
|
73
|
+
3. `variableFormatter` — fallback that produces a placeholder string
|
|
110
74
|
|
|
111
|
-
|
|
75
|
+
### Contributions
|
|
112
76
|
|
|
113
77
|
Feel free to submit pull requests, create issues, or spread the word.
|
|
114
78
|
|
|
115
|
-
|
|
79
|
+
### License
|
|
116
80
|
|
|
117
|
-
MIT © [Arik Chakma](https://
|
|
81
|
+
MIT © [Arik Chakma](https://x.com/imarikchakma)
|
package/dist/index.d.ts
DELETED
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
|
-
import { HtmlProps } from "@react-email/components";
|
|
3
|
-
import { JSONContent, JSONContent as JSONContent$1 } from "@tiptap/core";
|
|
4
|
-
import { RendererThemeOptions } from "@maily-to/shared";
|
|
5
|
-
|
|
6
|
-
//#region src/meta.d.ts
|
|
7
|
-
type MetaDescriptor = {
|
|
8
|
-
charSet: 'utf-8';
|
|
9
|
-
} | {
|
|
10
|
-
title: string;
|
|
11
|
-
} | {
|
|
12
|
-
name: string;
|
|
13
|
-
content: string;
|
|
14
|
-
} | {
|
|
15
|
-
property: string;
|
|
16
|
-
content: string;
|
|
17
|
-
} | {
|
|
18
|
-
httpEquiv: string;
|
|
19
|
-
content: string;
|
|
20
|
-
} | {
|
|
21
|
-
tagName: 'meta' | 'link';
|
|
22
|
-
[attribute: string]: string;
|
|
23
|
-
} | {
|
|
24
|
-
[name: string]: string;
|
|
25
|
-
};
|
|
26
|
-
type MetaDescriptors = MetaDescriptor[];
|
|
27
|
-
//#endregion
|
|
28
|
-
//#region src/preheader.d.ts
|
|
29
|
-
declare class Preheader {
|
|
30
|
-
private readonly maily;
|
|
31
|
-
constructor(maily: Maily);
|
|
32
|
-
render(content: string | JSONContent$1): string;
|
|
33
|
-
private renderNode;
|
|
34
|
-
private doc;
|
|
35
|
-
private paragraph;
|
|
36
|
-
private text;
|
|
37
|
-
private variable;
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=preheader.d.ts.map
|
|
40
|
-
//#endregion
|
|
41
|
-
//#region src/maily.d.ts
|
|
42
|
-
interface NodeOptions {
|
|
43
|
-
parent?: JSONContent$1;
|
|
44
|
-
prev?: JSONContent$1;
|
|
45
|
-
next?: JSONContent$1;
|
|
46
|
-
payloadValue?: PayloadValue;
|
|
47
|
-
}
|
|
48
|
-
interface MarkType {
|
|
49
|
-
[key: string]: any;
|
|
50
|
-
type: string;
|
|
51
|
-
attrs?: Record<string, any> | undefined;
|
|
52
|
-
}
|
|
53
|
-
interface MailyConfig {
|
|
54
|
-
/**
|
|
55
|
-
* The preview text is the snippet of text that is pulled into the inbox
|
|
56
|
-
* preview of an email client, usually right after the subject line.
|
|
57
|
-
*
|
|
58
|
-
* Default: `undefined`
|
|
59
|
-
*/
|
|
60
|
-
preview?: string | JSONContent$1;
|
|
61
|
-
/**
|
|
62
|
-
* The theme object allows you to customize the colors and font sizes of the
|
|
63
|
-
* rendered email.
|
|
64
|
-
*
|
|
65
|
-
* Default:
|
|
66
|
-
* ```js
|
|
67
|
-
* {
|
|
68
|
-
* colors: {
|
|
69
|
-
* heading: '#111827',
|
|
70
|
-
* paragraph: '#374151',
|
|
71
|
-
* horizontal: '#EAEAEA',
|
|
72
|
-
* footer: '#64748B',
|
|
73
|
-
* },
|
|
74
|
-
* fontSize: {
|
|
75
|
-
* paragraph: '15px',
|
|
76
|
-
* footer: {
|
|
77
|
-
* size: '14px',
|
|
78
|
-
* lineHeight: '24px',
|
|
79
|
-
* },
|
|
80
|
-
* },
|
|
81
|
-
* }
|
|
82
|
-
* ```
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* ```js
|
|
86
|
-
* const maily = new Maily(content, {
|
|
87
|
-
* theme: {
|
|
88
|
-
* colors: {
|
|
89
|
-
* heading: '#111827',
|
|
90
|
-
* },
|
|
91
|
-
* fontSize: {
|
|
92
|
-
* footer: {
|
|
93
|
-
* size: '14px',
|
|
94
|
-
* lineHeight: '24px',
|
|
95
|
-
* },
|
|
96
|
-
* },
|
|
97
|
-
* },
|
|
98
|
-
* });
|
|
99
|
-
* ```
|
|
100
|
-
*/
|
|
101
|
-
theme?: Partial<RendererThemeOptions>;
|
|
102
|
-
}
|
|
103
|
-
declare const DEFAULT_SECTION_BACKGROUND_COLOR = "#ffffff";
|
|
104
|
-
declare const DEFAULT_SECTION_ALIGN = "left";
|
|
105
|
-
declare const DEFAULT_SECTION_BORDER_WIDTH = 1;
|
|
106
|
-
declare const DEFAULT_SECTION_BORDER_COLOR = "#000000";
|
|
107
|
-
declare const DEFAULT_SECTION_MARGIN_TOP = 0;
|
|
108
|
-
declare const DEFAULT_SECTION_MARGIN_RIGHT = 0;
|
|
109
|
-
declare const DEFAULT_SECTION_MARGIN_BOTTOM = 0;
|
|
110
|
-
declare const DEFAULT_SECTION_MARGIN_LEFT = 0;
|
|
111
|
-
declare const DEFAULT_SECTION_PADDING_TOP = 5;
|
|
112
|
-
declare const DEFAULT_SECTION_PADDING_RIGHT = 5;
|
|
113
|
-
declare const DEFAULT_SECTION_PADDING_BOTTOM = 5;
|
|
114
|
-
declare const DEFAULT_SECTION_PADDING_LEFT = 5;
|
|
115
|
-
declare const DEFAULT_COLUMNS_WIDTH = "100%";
|
|
116
|
-
declare const DEFAULT_COLUMNS_GAP = 8;
|
|
117
|
-
declare const DEFAULT_COLUMN_BACKGROUND_COLOR = "transparent";
|
|
118
|
-
declare const DEFAULT_COLUMN_BORDER_RADIUS = 0;
|
|
119
|
-
declare const DEFAULT_COLUMN_BORDER_WIDTH = 0;
|
|
120
|
-
declare const DEFAULT_COLUMN_BORDER_COLOR = "transparent";
|
|
121
|
-
declare const DEFAULT_COLUMN_PADDING_TOP = 0;
|
|
122
|
-
declare const DEFAULT_COLUMN_PADDING_RIGHT = 0;
|
|
123
|
-
declare const DEFAULT_COLUMN_PADDING_BOTTOM = 0;
|
|
124
|
-
declare const DEFAULT_COLUMN_PADDING_LEFT = 0;
|
|
125
|
-
declare const DEFAULT_INLINE_IMAGE_HEIGHT = 20;
|
|
126
|
-
declare const DEFAULT_INLINE_IMAGE_WIDTH = 20;
|
|
127
|
-
declare const LINK_PROTOCOL_REGEX: RegExp;
|
|
128
|
-
declare const DEFAULT_META_TAGS: MetaDescriptors;
|
|
129
|
-
declare const DEFAULT_HTML_PROPS: HtmlProps;
|
|
130
|
-
interface RenderOptions {
|
|
131
|
-
/**
|
|
132
|
-
* The options object allows you to customize the output of the rendered
|
|
133
|
-
* email.
|
|
134
|
-
* - `pretty` - If `true`, the output will be formatted with indentation and
|
|
135
|
-
* line breaks.
|
|
136
|
-
* - `plainText` - If `true`, the output will be plain text instead of HTML.
|
|
137
|
-
* This is useful for testing purposes.
|
|
138
|
-
*
|
|
139
|
-
* Default: `pretty` - `false`, `plainText` - `false`
|
|
140
|
-
*/
|
|
141
|
-
pretty?: boolean;
|
|
142
|
-
plainText?: boolean;
|
|
143
|
-
}
|
|
144
|
-
type VariableFormatter = (options: {
|
|
145
|
-
variable: string;
|
|
146
|
-
fallback?: string;
|
|
147
|
-
}) => string;
|
|
148
|
-
type VariableValues = Map<string, string>;
|
|
149
|
-
type LinkValues = Map<string, string>;
|
|
150
|
-
type PayloadValue = Record<string, any> | boolean;
|
|
151
|
-
type PayloadValues = Map<string, PayloadValue>;
|
|
152
|
-
declare class Maily {
|
|
153
|
-
readonly preheader: Preheader;
|
|
154
|
-
private readonly content;
|
|
155
|
-
private config;
|
|
156
|
-
private variableFormatter;
|
|
157
|
-
private shouldReplaceVariableValues;
|
|
158
|
-
private variableValues;
|
|
159
|
-
private linkValues;
|
|
160
|
-
private openTrackingPixel;
|
|
161
|
-
private payloadValues;
|
|
162
|
-
private marksOrder;
|
|
163
|
-
private meta;
|
|
164
|
-
private htmlProps;
|
|
165
|
-
constructor(content?: JSONContent$1);
|
|
166
|
-
setPreviewText(preview?: string | JSONContent$1): void;
|
|
167
|
-
setTheme(theme: Partial<RendererThemeOptions>): void;
|
|
168
|
-
setVariableFormatter(formatter: VariableFormatter): void;
|
|
169
|
-
/**
|
|
170
|
-
* `setVariableValue` will set the variable value.
|
|
171
|
-
* It will also set `shouldReplaceVariableValues` to `true`.
|
|
172
|
-
*
|
|
173
|
-
* @param variable - The variable name
|
|
174
|
-
* @param value - The variable value
|
|
175
|
-
*/
|
|
176
|
-
setVariableValue(variable: string, value: string): void;
|
|
177
|
-
/**
|
|
178
|
-
* `setVariableValues` will set the variable values.
|
|
179
|
-
* It will also set `shouldReplaceVariableValues` to `true`.
|
|
180
|
-
*
|
|
181
|
-
* @param values - The variable values
|
|
182
|
-
*
|
|
183
|
-
* @example
|
|
184
|
-
* ```js
|
|
185
|
-
* const maily = new Maily(content);
|
|
186
|
-
* maily.setVariableValues({
|
|
187
|
-
* name: 'John Doe',
|
|
188
|
-
* email: 'john@doe.com',
|
|
189
|
-
* });
|
|
190
|
-
* ```
|
|
191
|
-
*/
|
|
192
|
-
setVariableValues(values: Record<string, string>): void;
|
|
193
|
-
setLinkValue(link: string, value: string): void;
|
|
194
|
-
setLinkValues(values: Record<string, string>): void;
|
|
195
|
-
setPayloadValue(key: string, value: PayloadValue): void;
|
|
196
|
-
setPayloadValues(values: Record<string, PayloadValue>): void;
|
|
197
|
-
/**
|
|
198
|
-
* `setOpenTrackingPixel` will set the open tracking pixel.
|
|
199
|
-
*
|
|
200
|
-
* @param pixel - The open tracking pixel
|
|
201
|
-
*/
|
|
202
|
-
setOpenTrackingPixel(pixel?: string): void;
|
|
203
|
-
/**
|
|
204
|
-
* `setShouldReplaceVariableValues` will determine whether to replace the
|
|
205
|
-
* variable values or not. Otherwise, it will just return the formatted variable.
|
|
206
|
-
*
|
|
207
|
-
* Default: `false`
|
|
208
|
-
*/
|
|
209
|
-
setShouldReplaceVariableValues(shouldReplace: boolean): void;
|
|
210
|
-
/**
|
|
211
|
-
* `setMetaTags` will add the meta tags.
|
|
212
|
-
*
|
|
213
|
-
* @param meta - The meta tags
|
|
214
|
-
*/
|
|
215
|
-
setMetaTags(meta: MetaDescriptors): void;
|
|
216
|
-
/**
|
|
217
|
-
* `setHtmlProps` will set the HTML props.
|
|
218
|
-
*
|
|
219
|
-
* @param props - The HTML props
|
|
220
|
-
*/
|
|
221
|
-
setHtmlProps(props: HtmlProps): void;
|
|
222
|
-
getAllLinks(): Set<string>;
|
|
223
|
-
private isValidUrl;
|
|
224
|
-
render(options?: RenderOptions): Promise<string>;
|
|
225
|
-
/**
|
|
226
|
-
* `children` will return the children of the content.
|
|
227
|
-
* this is useful for rendering the content in a custom component.
|
|
228
|
-
*
|
|
229
|
-
* @returns The children of the content as JSX elements
|
|
230
|
-
*/
|
|
231
|
-
children(): (react_jsx_runtime0.JSX.Element | null)[];
|
|
232
|
-
/**
|
|
233
|
-
* `markup` will render the JSON content into React Email markup.
|
|
234
|
-
* and return the raw React Tree.
|
|
235
|
-
*/
|
|
236
|
-
markup(): react_jsx_runtime0.JSX.Element;
|
|
237
|
-
private getMarginOverrideConditions;
|
|
238
|
-
private getMappedContent;
|
|
239
|
-
private renderNode;
|
|
240
|
-
private renderMark;
|
|
241
|
-
private paragraph;
|
|
242
|
-
private text;
|
|
243
|
-
private bold;
|
|
244
|
-
private italic;
|
|
245
|
-
private underline;
|
|
246
|
-
private strike;
|
|
247
|
-
private textStyle;
|
|
248
|
-
private link;
|
|
249
|
-
private removeLinkProtocol;
|
|
250
|
-
private variableUrlValue;
|
|
251
|
-
private heading;
|
|
252
|
-
private variable;
|
|
253
|
-
getVariableValue(variable: string, fallback?: string, options?: NodeOptions): string;
|
|
254
|
-
private horizontalRule;
|
|
255
|
-
private orderedList;
|
|
256
|
-
private bulletList;
|
|
257
|
-
private listItem;
|
|
258
|
-
private button;
|
|
259
|
-
private spacer;
|
|
260
|
-
private hardBreak;
|
|
261
|
-
private logo;
|
|
262
|
-
private image;
|
|
263
|
-
private footer;
|
|
264
|
-
private blockquote;
|
|
265
|
-
private code;
|
|
266
|
-
private linkCard;
|
|
267
|
-
private section;
|
|
268
|
-
private columns;
|
|
269
|
-
private adjustColumnsContent;
|
|
270
|
-
private column;
|
|
271
|
-
private repeat;
|
|
272
|
-
/**
|
|
273
|
-
* @deprecated
|
|
274
|
-
* This for node is an alias for the repeat node
|
|
275
|
-
* we will remove this in the future
|
|
276
|
-
* @param node
|
|
277
|
-
* @param options
|
|
278
|
-
* @returns JSX.Element
|
|
279
|
-
*/
|
|
280
|
-
private for;
|
|
281
|
-
private shouldShow;
|
|
282
|
-
htmlCodeBlock(node: JSONContent$1, options?: NodeOptions): JSX.Element;
|
|
283
|
-
private inlineImage;
|
|
284
|
-
}
|
|
285
|
-
//#endregion
|
|
286
|
-
//#region src/render.d.ts
|
|
287
|
-
declare function render(content: JSONContent$1, config?: MailyConfig & RenderOptions): Promise<string>;
|
|
288
|
-
//# sourceMappingURL=render.d.ts.map
|
|
289
|
-
|
|
290
|
-
//#endregion
|
|
291
|
-
export { DEFAULT_COLUMNS_GAP, DEFAULT_COLUMNS_WIDTH, DEFAULT_COLUMN_BACKGROUND_COLOR, DEFAULT_COLUMN_BORDER_COLOR, DEFAULT_COLUMN_BORDER_RADIUS, DEFAULT_COLUMN_BORDER_WIDTH, DEFAULT_COLUMN_PADDING_BOTTOM, DEFAULT_COLUMN_PADDING_LEFT, DEFAULT_COLUMN_PADDING_RIGHT, DEFAULT_COLUMN_PADDING_TOP, DEFAULT_HTML_PROPS, DEFAULT_INLINE_IMAGE_HEIGHT, DEFAULT_INLINE_IMAGE_WIDTH, DEFAULT_META_TAGS, DEFAULT_SECTION_ALIGN, DEFAULT_SECTION_BACKGROUND_COLOR, DEFAULT_SECTION_BORDER_COLOR, DEFAULT_SECTION_BORDER_WIDTH, DEFAULT_SECTION_MARGIN_BOTTOM, DEFAULT_SECTION_MARGIN_LEFT, DEFAULT_SECTION_MARGIN_RIGHT, DEFAULT_SECTION_MARGIN_TOP, DEFAULT_SECTION_PADDING_BOTTOM, DEFAULT_SECTION_PADDING_LEFT, DEFAULT_SECTION_PADDING_RIGHT, DEFAULT_SECTION_PADDING_TOP, JSONContent, LINK_PROTOCOL_REGEX, LinkValues, Maily, MailyConfig, MarkType, PayloadValue, PayloadValues, RenderOptions, VariableFormatter, VariableValues, render };
|
|
292
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/meta.tsx","../src/preheader.ts","../src/maily.tsx","../src/render.ts"],"sourcesContent":[],"mappings":"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"}
|
package/dist/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=s(require(`react`)),l=s(require(`@react-email/components`)),u=s(require(`@react-email/render`)),d=s(require(`react/jsx-runtime`)),f=s(require(`node-html-parser`)),p=s(require(`juice`)),m=e=>Object.prototype.toString.call(e),h=e=>m(e)===`[object Object]`;function g(e){return Object.keys(e)}function _(e,...t){if(!t.length)return e;let n=t.shift();return n===void 0?e:(v(e)&&v(n)&&g(n).forEach(t=>{t===`__proto__`||t===`constructor`||t===`prototype`||(v(n[t])?(e[t]||(e[t]={}),v(e[t])?_(e[t],n[t]):e[t]=n[t]):e[t]=n[t])}),_(e,...t))}function v(e){return h(e)&&!Array.isArray(e)}const y=Symbol(`p-void`);function b(){return Math.random().toString(36).substr(2,6)}function x(e){return e.filter((e,t,n)=>{let r=C(e);return t===n.findIndex(e=>C(e)===r)}).map(S).filter(Boolean)}function S(e){if(`tagName`in e){let{tagName:t,...n}=e,r=t;return(0,d.jsx)(r,{...n},JSON.stringify(n))}return`title`in e?(0,d.jsx)(`title`,{children:e.title}):`charSet`in e?(0,d.jsx)(`meta`,{charSet:e.charSet}):(0,d.jsx)(`meta`,{...e},JSON.stringify(e))}function C(e){let t=Object.keys(e).sort().reduce((t,n)=>{let r=n;return t[r]=e[r],t},{});return JSON.stringify(t)}const w={fallbackFontFamily:`sans-serif`,fontFamily:`Inter`,webFont:{url:`https://rsms.me/inter/font-files/Inter-Regular.woff2?v=3.19`,format:`woff2`}},T=`#111827`,E={colors:{heading:`#111827`,paragraph:`#374151`,horizontal:`#EAEAEA`,footer:`#64748B`,blockquoteBorder:`#D1D5DB`,codeBackground:`#EFEFEF`,codeText:`#111827`,linkCardTitle:`#111827`,linkCardDescription:`#6B7280`,linkCardBadgeText:`#111827`,linkCardBadgeBackground:`#FEF08A`,linkCardSubTitle:`#6B7280`},fontSize:{paragraph:{size:`15px`,lineHeight:`26.25px`},footer:{size:`14px`,lineHeight:`24px`}},container:{backgroundColor:`#ffffff`,maxWidth:`600px`,minWidth:`300px`,paddingTop:`0.5rem`,paddingRight:`0.5rem`,paddingBottom:`0.5rem`,paddingLeft:`0.5rem`,borderRadius:`0px`,borderWidth:`0px`,borderColor:`transparent`},body:{backgroundColor:`#ffffff`,paddingTop:`0px`,paddingRight:`0px`,paddingBottom:`0px`,paddingLeft:`0px`},button:{backgroundColor:`#000000`,color:`#ffffff`,paddingTop:`10px`,paddingRight:`32px`,paddingBottom:`10px`,paddingLeft:`32px`},link:{color:T},font:w};var D=class{constructor(e){this.maily=e}render(e){return typeof e==`string`?e:this.renderNode(e)}renderNode(e){let t=e.type||``;switch(t){case`doc`:return this.doc(e);case`paragraph`:return this.paragraph(e);case`text`:return this.text(e);case`variable`:return this.variable(e);default:return``}}doc(e){let t=e.content||[];return t.length===0?``:t.map(e=>this.renderNode(e)).join(``)}paragraph(e){let t=e.content||[];return t.length===0?``:t.map(e=>this.renderNode(e)).join(``)}text(e){return e.text||``}variable(e){let{id:t,fallback:n}=e.attrs||{};return this.maily.getVariableValue(t,n)}};const O={WebkitFontSmoothing:`antialiased`,MozOsxFontSmoothing:`grayscale`},k={h1:{fontSize:`36px`,lineHeight:`40px`,fontWeight:800},h2:{fontSize:`30px`,lineHeight:`36px`,fontWeight:700},h3:{fontSize:`24px`,lineHeight:`38px`,fontWeight:600}},A={sm:`40px`,md:`48px`,lg:`64px`},ee=`SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace`,j=`#ffffff`,M=`left`,N=1,P=`#000000`,F=0,I=0,L=0,R=0,z=5,B=5,V=5,H=5,te=`100%`,U=8,ne=`transparent`,re=0,ie=0,ae=`transparent`,W=0,G=0,K=0,q=0,J=20,Y=20,X=/https?:\/\//,Z=[{name:`viewport`,content:`width=device-width`},{httpEquiv:`X-UA-Compatible`,content:`IE=edge`},{name:`x-apple-disable-message-reformatting`},{name:`format-detection`,content:`telephone=no,address=no,email=no,date=no,url=no`},{name:`color-scheme`,content:`light`},{name:`supported-color-schemes`,content:`light`}],Q={lang:`en`,dir:`ltr`},oe={pretty:!1,plainText:!1};var $=class{preheader=new D(this);content;config={theme:E};variableFormatter=({variable:e,fallback:t})=>t?`{{${e},fallback=${t}}}`:`{{${e}}}`;shouldReplaceVariableValues=!1;variableValues=new Map;linkValues=new Map;openTrackingPixel;payloadValues=new Map;marksOrder=[`underline`,`bold`,`italic`,`textStyle`,`link`];meta=Z;htmlProps=Q;constructor(e={type:`doc`,content:[]}){this.content=e}setPreviewText(e){this.config.preview=e}setTheme(e){this.config.theme=_(this.config.theme||E,e)}setVariableFormatter(e){this.variableFormatter=e}setVariableValue(e,t){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),this.variableValues.set(e,t)}setVariableValues(e){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),Object.entries(e).forEach(([e,t])=>{this.setVariableValue(e,t)})}setLinkValue(e,t){this.linkValues.set(e,t)}setLinkValues(e){Object.entries(e).forEach(([e,t])=>{this.setLinkValue(e,t)})}setPayloadValue(e,t){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),this.payloadValues.set(e,t)}setPayloadValues(e){Object.entries(e).forEach(([e,t])=>{this.setPayloadValue(e,t)})}setOpenTrackingPixel(e){this.openTrackingPixel=e}setShouldReplaceVariableValues(e){this.shouldReplaceVariableValues=e}setMetaTags(e){this.meta.push(...e)}setHtmlProps(e){this.htmlProps={...this.htmlProps,...e}}getAllLinks(){let e=this.content.content||[],t=new Set,n=e=>e&&this.isValidUrl(e)&&!e.startsWith(`#`)&&!e.startsWith(`mailto:`)&&!e.startsWith(`tel:`)&&typeof e==`string`,r=e=>{if(e.type===`button`){let r=e.attrs?.url;n(r)&&r&&t.add(r)}else e.content&&e.content.forEach(e=>{e.marks&&e.marks.forEach(e=>{let r=e.attrs?.href;e.type===`link`&&n(r)&&t.add(r)}),e.content&&r(e)})};return e.forEach(e=>{r(e)}),t}isValidUrl(e){try{let t=new URL(e);return!0}catch(e){return!1}}async render(e=oe){let t=this.markup();return(0,u.renderAsync)(t,e)}children(){let e=this.content.content||[],t=e.map((t,n)=>{let r={prev:e[n-1],next:e[n+1],parent:t},i=this.renderNode(t,r);return i?(0,d.jsx)(c.Fragment,{children:i},b()):null});return t}markup(){let e=this.children(),{preview:t}=this.config,n=x(this.meta),r=this.htmlProps,i=this.config.theme?.container,a={...this.config.theme?.font||w,fontStyle:`normal`,fontWeight:400},o={margin:`0px`,...this.config.theme?.body},s=t?this.preheader.render(t):null,c=(0,d.jsxs)(l.Html,{...r,children:[(0,d.jsxs)(l.Head,{children:[(0,d.jsx)(l.Font,{...a}),(0,d.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`blockquote,h1,h2,h3,img,li,ol,p,ul{margin-top:0;margin-bottom:0}@media only screen and (max-width:425px){.tab-row-full{width:100%!important}.tab-col-full{display:block!important;width:100%!important}.tab-pad{padding:0!important}}`}}),n]}),(0,d.jsxs)(l.Body,{style:o,children:[s?(0,d.jsx)(l.Preview,{children:s}):null,(0,d.jsx)(l.Container,{style:{width:`100%`,marginLeft:`auto`,marginRight:`auto`,borderStyle:`solid`,...i},children:e}),this.openTrackingPixel?(0,d.jsx)(l.Img,{alt:``,src:this.openTrackingPixel,style:{display:`none`,width:`1px`,height:`1px`}}):null]})]});return c}getMarginOverrideConditions(e,t){let{parent:n,prev:r,next:i}=t||{},a=i?.type===`spacer`,o=r?.type===`spacer`,s=n?.type===`listItem`,c=n?.type===`section`&&!i,l=n?.type===`section`&&!r,u=n?.type===`column`&&!i,d=n?.type===`column`&&!r,f=n?.type===`repeat`&&!r,p=n?.type===`repeat`&&!i,m=n?.type===`show`&&!r,h=n?.type===`show`&&!i;return{isNextSpacer:a,isPrevSpacer:o,isLastSectionElement:c,isFirstSectionElement:l,isParentListItem:s,isLastColumnElement:u,isFirstColumnElement:d,isFirstRepeatElement:f,isLastRepeatElement:p,isFirstShowElement:m,isLastShowElement:h,shouldRemoveTopMargin:o||l||d||f||m,shouldRemoveBottomMargin:a||c||u||p||h}}getMappedContent(e,t){let n=e.content||[];return n.map((e,r)=>{let i=this.renderNode(e,{...t,next:n[r+1],prev:n[r-1]});return i?(0,d.jsx)(c.Fragment,{children:i},b()):null}).filter(e=>e!==null)}renderNode(e,t={}){let n=e.type||``;if(n in this)return this[n]?.(e,t);throw Error(`Node type "${n}" is not supported.`)}renderMark(e,t){let n=e?.text||(0,d.jsx)(d.Fragment,{children:`\xA0`}),r=e?.marks||[];return r.sort((e,t)=>this.marksOrder.indexOf(e.type)-this.marksOrder.indexOf(t.type)),r.reduce((e,t)=>{let n=t.type;if(n in this)return this[n]?.(t,e);throw Error(`Mark type "${n}" is not supported.`)},(0,d.jsx)(d.Fragment,{children:n}))}paragraph(e,t){let{attrs:n}=e,r=n?.textAlign||`left`,i=n?.textDirection||`ltr`,{isParentListItem:a,shouldRemoveBottomMargin:o}=this.getMarginOverrideConditions(e,t),s=this.shouldShow(e,t);if(!s)return(0,d.jsx)(d.Fragment,{});let c=a||o?0:20;return(0,d.jsx)(l.Text,{style:{...r===`left`?{}:{textAlign:r},...i===`ltr`?{}:{direction:i},...O,fontSize:this.config.theme?.fontSize?.paragraph?.size,lineHeight:this.config.theme?.fontSize?.paragraph?.lineHeight,color:this.config.theme?.colors?.paragraph,margin:`0 0 ${c}px 0`},children:e.content?this.getMappedContent(e,{...t,parent:e}):(0,d.jsx)(d.Fragment,{children:`\xA0`})})}text(e,t){if(e.marks)return this.renderMark(e,t);let n=e.text,r=n?.match(/\s/g);return r&&r.length===n?.length?(0,d.jsx)(d.Fragment,{children:r.map((e,t)=>(0,d.jsx)(c.Fragment,{children:`\xA0`},t))}):n?(0,d.jsx)(d.Fragment,{children:n}):(0,d.jsx)(d.Fragment,{children:`\xA0`})}bold(e,t){return(0,d.jsx)(`strong`,{children:t})}italic(e,t){return(0,d.jsx)(`em`,{children:t})}underline(e,t){return(0,d.jsx)(`u`,{children:t})}strike(e,t){return(0,d.jsx)(`s`,{style:{textDecoration:`line-through`},children:t})}textStyle(e,t){let{attrs:n}=e,{color:r=this.config.theme?.colors?.paragraph}=n||{};return(0,d.jsx)(`span`,{style:{color:r},children:t})}link(e,t,n){let{attrs:r}=e,i=this.config.theme?.link,a=r?.href||`#`,o=r?.target||`_blank`,s=r?.rel||`noopener noreferrer nofollow`,c=r?.isUrlVariable??!1;if(c){let e=this.removeLinkProtocol(a);a=this.variableUrlValue(e,n)}else a=this.linkValues.get(a)||a;return(0,d.jsx)(l.Link,{href:a,rel:s,style:{fontWeight:500,textDecoration:`none`,color:i?.color||T},target:o,children:t})}removeLinkProtocol(e){return e.replace(X,``)}variableUrlValue(e,t){let{payloadValue:n}=t||{},r=this.removeLinkProtocol(e);return this.shouldReplaceVariableValues?(typeof n==`object`?n[r]:n)??this.variableValues.get(r)??e:this.variableFormatter({variable:r})}heading(e,t){let{attrs:n}=e,r=`h${Number(n?.level)||1}`,i=n?.textDirection||`ltr`,a=i===`rtl`,o=a?`right`:`left`,s=n?.textAlign||o,{shouldRemoveBottomMargin:c}=this.getMarginOverrideConditions(e,t),{fontSize:u,lineHeight:f,fontWeight:p}=k[r],m=this.shouldShow(e,t);return m?(0,d.jsx)(l.Heading,{as:r,style:{...s===`left`?{}:{textAlign:s},...a?{direction:i}:{},color:this.config.theme?.colors?.heading,fontSize:u,lineHeight:f,fontWeight:p},mb:c?0:12,mt:0,mx:0,children:this.getMappedContent(e,{...t,parent:e})}):(0,d.jsx)(d.Fragment,{})}variable(e,t){let{payloadValue:n}=t||{},{id:r,fallback:i}=e.attrs||{},a=this.shouldShow(e,t);if(!a||!r)return(0,d.jsx)(d.Fragment,{});let o=this.getVariableValue(r,i,t);return e?.marks?this.renderMark({text:o,marks:e.marks},t):(0,d.jsx)(d.Fragment,{children:o})}getVariableValue(e,t,n){let{payloadValue:r}=n||{},i=this.variableFormatter({variable:e,fallback:t});return this.shouldReplaceVariableValues&&(i=(typeof r==`object`?r[e]:r)??this.variableValues.get(e)??t??i),i}horizontalRule(e,t){return(0,d.jsx)(l.Hr,{style:{marginTop:`32px`,marginBottom:`32px`}})}orderedList(e,t){let{shouldRemoveBottomMargin:n}=this.getMarginOverrideConditions(e,t);return(0,d.jsx)(l.Container,{style:{marginTop:`0px`,marginBottom:n?`0`:`20px`},children:(0,d.jsx)(`ol`,{style:{paddingLeft:`26px`,listStyleType:`decimal`},children:this.getMappedContent(e,{...t,parent:e})})})}bulletList(e,t){let{parent:n,next:r}=t||{},{shouldRemoveBottomMargin:i}=this.getMarginOverrideConditions(e,{parent:n,next:r});return(0,d.jsx)(l.Container,{style:{maxWidth:`100%`,marginTop:`0px`,marginBottom:i?`0`:`20px`},children:(0,d.jsx)(`ul`,{style:{paddingLeft:`26px`,listStyleType:`disc`},children:this.getMappedContent(e,{...t,parent:e})})})}listItem(e,t){return(0,d.jsx)(`li`,{style:{marginBottom:`8px`,marginTop:`8px`,paddingLeft:`6px`,...O},children:this.getMappedContent(e,{...t,parent:e})})}button(e,t){let{attrs:n}=e,r=this.config.theme?.button,{text:i,isTextVariable:a,url:o,isUrlVariable:s,variant:c,buttonColor:u,textColor:f,borderRadius:p,alignment:m=`left`,paddingTop:h,paddingRight:g,paddingBottom:_,paddingLeft:v}=n||{},y=u||r?.backgroundColor,b=f||r?.color,x=parseInt(String(h||r?.paddingTop))||0,S=parseInt(String(g||r?.paddingRight))||0,C=parseInt(String(_||r?.paddingBottom))||0,w=parseInt(String(v||r?.paddingLeft))||0,T=this.shouldShow(e,t);if(!T)return(0,d.jsx)(d.Fragment,{});let E=`0px`;p===`round`?E=`9999px`:p===`smooth`&&(E=`6px`);let{shouldRemoveBottomMargin:D}=this.getMarginOverrideConditions(e,t),O=s?this.variableUrlValue(o,t):this.linkValues.get(o)||o,k=a?this.variableUrlValue(i,t):i;return x+=2,C+=2,(0,d.jsx)(l.Container,{style:{textAlign:m,maxWidth:`100%`,marginBottom:D?`0px`:`20px`},children:(0,d.jsx)(l.Button,{href:O,style:{color:String(b),backgroundColor:c===`filled`?String(y):`transparent`,borderColor:String(y),borderWidth:`2px`,borderStyle:`solid`,textDecoration:`none`,fontSize:`14px`,fontWeight:500,borderRadius:E,padding:`${x}px ${S}px ${C}px ${w}px`},children:k})})}spacer(e,t){let{attrs:n}=e,{height:r}=n||{},i=this.shouldShow(e,t);return i?(0,d.jsx)(l.Container,{style:{height:`${r}px`}}):(0,d.jsx)(d.Fragment,{})}hardBreak(e,t){return(0,d.jsx)(`br`,{})}logo(e,t){let{attrs:n}=e,{src:r,isSrcVariable:i,alt:a,title:o,size:s,alignment:c=`left`}=n||{},u=this.shouldShow(e,t);if(!u)return(0,d.jsx)(d.Fragment,{});r=i?this.variableUrlValue(r,t):r;let{shouldRemoveBottomMargin:f}=this.getMarginOverrideConditions(e,t);return(0,d.jsx)(l.Row,{style:{marginTop:`0px`,marginBottom:f?`0px`:`32px`},children:(0,d.jsx)(l.Column,{align:c,children:(0,d.jsx)(l.Img,{alt:a||o||`Logo`,src:r,style:{width:A[s]||s,height:A[s]||s},title:o||a||`Logo`})})})}image(e,t){let{attrs:n}=e,{src:r,isSrcVariable:i,alt:a,title:o,width:s=`auto`,height:c=`auto`,alignment:u=`center`,externalLink:f=``,isExternalLinkVariable:p,borderRadius:m=0}=n||{},h=this.shouldShow(e,t);if(!h)return(0,d.jsx)(d.Fragment,{});let{shouldRemoveBottomMargin:g}=this.getMarginOverrideConditions(e,t);r=i?this.variableUrlValue(r,t):r,f=p?this.variableUrlValue(f,t):f;let _=s===`auto`?`auto`:Number(s),v=_===`auto`?`auto`:`${_}px`,y=c===`auto`?`auto`:Number(c),b=y===`auto`?`auto`:`${y}px`,x=(0,d.jsx)(l.Img,{alt:a||o||`Image`,src:r,style:{width:v,height:b,maxWidth:`100%`,outline:`none`,border:`none`,textDecoration:`none`,display:`block`,borderRadius:m},title:o||a||`Image`});return(0,d.jsx)(l.Row,{style:{marginTop:`0px`,marginBottom:g?`0px`:`32px`},children:(0,d.jsx)(l.Column,{align:u,children:f?(0,d.jsx)(`a`,{href:f,rel:`noopener noreferrer`,style:{display:`block`,maxWidth:`100%`,textDecoration:`none`},target:`_blank`,children:x}):x})})}footer(e,t){let{attrs:n}=e,{textAlign:r=`left`,textDirection:i=`ltr`}=n||{},{shouldRemoveBottomMargin:a}=this.getMarginOverrideConditions(e,t);return(0,d.jsx)(l.Text,{style:{fontSize:this.config.theme?.fontSize?.footer?.size,lineHeight:this.config.theme?.fontSize?.footer?.lineHeight,color:this.config.theme?.colors?.footer,marginTop:`0px`,marginBottom:a?`0px`:`20px`,textAlign:r,...i===`ltr`?{}:{direction:i},...O},children:this.getMappedContent(e,{...t,parent:e})})}blockquote(e,t){let{isPrevSpacer:n,shouldRemoveBottomMargin:r}=this.getMarginOverrideConditions(e,t);return(0,d.jsx)(`blockquote`,{style:{borderLeftWidth:`4px`,borderLeftStyle:`solid`,borderLeftColor:this.config.theme?.colors?.blockquoteBorder,paddingLeft:`16px`,marginLeft:`0px`,marginRight:`0px`,marginTop:n?`0px`:`20px`,marginBottom:r?`0px`:`20px`},children:this.getMappedContent(e,{...t,parent:e})})}code(e,t){return(0,d.jsx)(`code`,{style:{backgroundColor:this.config.theme?.colors?.codeBackground,color:this.config.theme?.colors?.codeText,padding:`2px 4px`,borderRadius:`6px`,fontFamily:ee,fontWeight:400,letterSpacing:0},children:t})}linkCard(e,t){let{attrs:n}=e,{shouldRemoveBottomMargin:r}=this.getMarginOverrideConditions(e,t),{title:i,description:a,link:o,linkTitle:s,image:c,badgeText:u,subTitle:f}=n||{},p=this.linkValues.get(o)||this.variableValues.get(o)||o||`#`;return(0,d.jsxs)(`a`,{href:p,rel:`noopener noreferrer`,style:{border:`1px solid #eaeaea`,borderRadius:`10px`,textDecoration:`none`,color:`inherit`,display:`block`,marginBottom:r?`0px`:`20px`},target:`_blank`,children:[c?(0,d.jsx)(l.Row,{style:{marginBottom:`6px`},children:(0,d.jsx)(l.Column,{style:{width:`100%`,height:`100%`},children:(0,d.jsx)(l.Img,{alt:i||`Link Card`,src:c,style:{borderRadius:`10px 10px 0 0`,width:`100%`,height:`100%`,objectFit:`cover`},title:i||`Link Card`})})}):null,(0,d.jsx)(l.Row,{style:{padding:`15px`,marginTop:0,marginBottom:0},children:(0,d.jsxs)(l.Column,{style:{verticalAlign:`top`},children:[(0,d.jsxs)(l.Row,{align:void 0,style:{marginBottom:`8px`,marginTop:`0px`},width:`auto`,children:[(0,d.jsx)(l.Column,{children:(0,d.jsx)(l.Text,{style:{fontSize:`18px`,fontWeight:600,color:this.config.theme?.colors?.linkCardTitle,margin:`0px`,...O},children:i})}),u||f?(0,d.jsxs)(l.Column,{style:{paddingLeft:`6px`,verticalAlign:`middle`},children:[u?(0,d.jsx)(`span`,{style:{fontWeight:600,color:this.config.theme?.colors?.linkCardBadgeText,padding:`4px 8px`,borderRadius:`8px`,backgroundColor:this.config.theme?.colors?.linkCardBadgeBackground,fontSize:`12px`,lineHeight:`12px`},children:u}):null,` `,f&&!u?(0,d.jsx)(`span`,{style:{fontWeight:`normal`,color:this.config.theme?.colors?.linkCardSubTitle,fontSize:`12px`,lineHeight:`12px`},children:f}):null]}):null]}),(0,d.jsxs)(l.Text,{style:{fontSize:`16px`,color:this.config.theme?.colors?.linkCardDescription,marginTop:`0px`,marginBottom:`0px`,...O},children:[a,` `,s?(0,d.jsx)(`a`,{href:p,rel:`noopener noreferrer`,style:{color:this.config.theme?.colors?.linkCardTitle,fontSize:`14px`,fontWeight:600,textDecoration:`underline`},children:s}):null]})]})})]})}section(e,t){let{attrs:n}=e,{borderRadius:r=0,backgroundColor:i=j,align:a=M,borderWidth:o=N,borderColor:s=P,marginTop:c=F,marginRight:u=I,marginBottom:f=L,marginLeft:p=R,paddingTop:m=z,paddingRight:h=B,paddingBottom:g=V,paddingLeft:_=H}=n||{},v=this.shouldShow(e,t);return v?(0,d.jsx)(l.Row,{style:{marginTop:c,marginRight:u,marginBottom:f,marginLeft:p},children:(0,d.jsx)(l.Column,{align:a,style:{borderColor:s,borderWidth:o,borderStyle:`solid`,backgroundColor:i,borderRadius:r,paddingTop:m,paddingRight:h,paddingBottom:g,paddingLeft:_},children:this.getMappedContent(e,{...t,parent:e})})}):(0,d.jsx)(d.Fragment,{})}columns(e,t){let{attrs:n}=e,r=this.shouldShow(e,t);if(!r)return(0,d.jsx)(d.Fragment,{});let[i,a]=this.adjustColumnsContent(e);return(0,d.jsx)(l.Row,{width:`${a}%`,style:{margin:0,padding:0,width:`${a}%`},className:`tab-row-full`,children:this.getMappedContent(i,{...t,parent:i})})}adjustColumnsContent(e){let{content:t=[]}=e,n=100,r=t.filter(e=>e.type===`column`&&!!Number(e.attrs?.width||0)),i=t.filter(e=>e.type===`column`&&(e.attrs?.width===`auto`||!e.attrs?.width)),a=r.reduce((e,t)=>e+Number(t.attrs?.width),0),o=n-a,s=Math.round(o/i.length),c=t.filter(e=>e.type===`column`).length,l=e.attrs?.gap??U;return[{...e,content:t.map((e,n)=>{let r=e.type===`column`&&(e.attrs?.width===`auto`||!e.attrs?.width),i=n===0,a=n>0&&n<c-1,o=n===t.length-1,u=0,d=0;if(c<3)u=i?0:l/2,d=o?0:l/2;else{let e=l/2*1.5,t=e/2;u=i?0:a?t:e,d=o?0:a?t:e}return u=Math.round(u*100)/100,d=Math.round(d*100)/100,{...e,attrs:{...e.attrs,width:r?s:e.attrs?.width,isFirstColumn:i,isLastColumn:o,index:n,paddingLeft:u,paddingRight:d}}})},i.length===0?Math.min(n,a):n]}column(e,t){let{attrs:n}=e,{width:r,verticalAlign:i=`top`,paddingLeft:a=0,paddingRight:o=0}=n||{};return(0,d.jsx)(l.Column,{width:`${Number(r)}%`,style:{width:`${Number(r)}%`,margin:0,verticalAlign:i},className:`tab-col-full`,children:(0,d.jsx)(l.Section,{style:{margin:0,paddingLeft:a,paddingRight:o},className:`tab-pad`,children:this.getMappedContent(e,{...t,parent:e})})})}repeat(e,t){let{attrs:n}=e,{each:r=``}=n||{},i=this.shouldShow(e,t);if(!i)return(0,d.jsx)(d.Fragment,{});let{payloadValue:a}=t||{};a=typeof a==`object`?a:{};let o=this.payloadValues.get(r)??a[r]??[];if(!Array.isArray(o))throw Error(`Payload value for each "${r}" is not an array`);return(0,d.jsx)(d.Fragment,{children:o.map(n=>(0,d.jsx)(c.Fragment,{children:this.getMappedContent(e,{...t,parent:e,payloadValue:n})},b()))})}for(e,t){return this.repeat(e,t)}shouldShow(e,t){let n=e?.attrs?.showIfKey??``;if(!n)return!0;let{payloadValue:r}=t||{};return r=typeof r==`object`?r:{},!!(this.payloadValues.get(n)??r[n])}htmlCodeBlock(e,t){let n=this.shouldShow(e,t);if(!n)return(0,d.jsx)(d.Fragment,{});let r=e.content?.reduce((e,n)=>{if(n?.type===`text`)return e+n?.text;if(n?.type===`variable`){let r=this.getVariableValue(n?.attrs?.id,n?.attrs?.fallback,t);return e+r}return e},``)||``,i=(0,p.default)(r),a=(0,f.parse)(i),o=a?.querySelector(`head`);o?.remove();let s=a.toString();return(0,d.jsx)(`table`,{align:`left`,width:`100%`,border:0,cellPadding:`0`,cellSpacing:`0`,role:`presentation`,children:(0,d.jsx)(`tbody`,{children:(0,d.jsx)(`tr`,{style:{width:`100%`},children:(0,d.jsx)(`td`,{style:{width:`100%`},dangerouslySetInnerHTML:{__html:s}})})})})}inlineImage(e,t){let{attrs:n}=e,{src:r,isSrcVariable:i,alt:a=``,title:o=``,height:s=J,width:c=Y,externalLink:l=``,isExternalLinkVariable:u}=n||{};r=i?this.variableUrlValue(r,t):r,l=u?this.variableUrlValue(l,t):l;let f=(0,d.jsx)(`img`,{src:r,alt:a,title:o,width:c,height:s,style:{display:`inline`,verticalAlign:`middle`,width:`${c}px`,height:`${s}px`,outline:`none`,border:`none`,textDecoration:`none`}});return l?(0,d.jsx)(`a`,{href:l,rel:`noopener noreferrer`,style:{display:`inline`,textDecoration:`none`},target:`_blank`,children:f}):f}};async function se(e,t){let{theme:n,preview:r,...i}=t||{},a=new $(e);return a.setPreviewText(r),a.setTheme(n||{}),a.render(i)}exports.DEFAULT_COLUMNS_GAP=U,exports.DEFAULT_COLUMNS_WIDTH=te,exports.DEFAULT_COLUMN_BACKGROUND_COLOR=ne,exports.DEFAULT_COLUMN_BORDER_COLOR=ae,exports.DEFAULT_COLUMN_BORDER_RADIUS=re,exports.DEFAULT_COLUMN_BORDER_WIDTH=ie,exports.DEFAULT_COLUMN_PADDING_BOTTOM=K,exports.DEFAULT_COLUMN_PADDING_LEFT=q,exports.DEFAULT_COLUMN_PADDING_RIGHT=G,exports.DEFAULT_COLUMN_PADDING_TOP=W,exports.DEFAULT_HTML_PROPS=Q,exports.DEFAULT_INLINE_IMAGE_HEIGHT=J,exports.DEFAULT_INLINE_IMAGE_WIDTH=Y,exports.DEFAULT_META_TAGS=Z,exports.DEFAULT_SECTION_ALIGN=M,exports.DEFAULT_SECTION_BACKGROUND_COLOR=j,exports.DEFAULT_SECTION_BORDER_COLOR=P,exports.DEFAULT_SECTION_BORDER_WIDTH=N,exports.DEFAULT_SECTION_MARGIN_BOTTOM=L,exports.DEFAULT_SECTION_MARGIN_LEFT=R,exports.DEFAULT_SECTION_MARGIN_RIGHT=I,exports.DEFAULT_SECTION_MARGIN_TOP=F,exports.DEFAULT_SECTION_PADDING_BOTTOM=V,exports.DEFAULT_SECTION_PADDING_LEFT=H,exports.DEFAULT_SECTION_PADDING_RIGHT=B,exports.DEFAULT_SECTION_PADDING_TOP=z,exports.LINK_PROTOCOL_REGEX=X,exports.Maily=$,exports.render=se;
|
|
2
|
-
//# sourceMappingURL=index.js.map
|