@maily-to/shared 2.0.0-beta.2 → 2.0.0-beta.21
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 +881 -692
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +475 -669
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +475 -669
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +849 -662
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -7
- package/readme.md +43 -7
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let stylecast = require("stylecast");
|
|
2
3
|
//#region src/alignment.ts
|
|
3
4
|
const TEXT_ALIGNMENTS = {
|
|
4
5
|
LEFT: "left",
|
|
@@ -11,55 +12,149 @@ function isAllowedTextAlignment(value) {
|
|
|
11
12
|
return typeof value === "string" && allowedTextAligns.includes(value);
|
|
12
13
|
}
|
|
13
14
|
//#endregion
|
|
14
|
-
//#region src/field-mode.ts
|
|
15
|
-
/**
|
|
16
|
-
* Controls how multi-value fields (padding, margin, border) are edited.
|
|
17
|
-
* "none" disables the field, "uniform" links all sides to one value,
|
|
18
|
-
* "mixed" allows independent per-side values, "preset" uses predefined
|
|
19
|
-
* size options (e.g. small/medium/large).
|
|
20
|
-
*/
|
|
21
|
-
const FIELD_MODE = {
|
|
22
|
-
NONE: "none",
|
|
23
|
-
MIXED: "mixed",
|
|
24
|
-
UNIFORM: "uniform",
|
|
25
|
-
PRESET: "preset"
|
|
26
|
-
};
|
|
27
|
-
const allowedFieldModes = Object.values(FIELD_MODE);
|
|
28
|
-
function isAllowedFieldMode(mode) {
|
|
29
|
-
return typeof mode === "string" && allowedFieldModes.includes(mode);
|
|
30
|
-
}
|
|
31
|
-
//#endregion
|
|
32
15
|
//#region src/border.ts
|
|
33
16
|
const BORDER_STYLES = {
|
|
34
17
|
SOLID: "solid",
|
|
35
18
|
DASHED: "dashed",
|
|
36
19
|
DOTTED: "dotted"
|
|
37
20
|
};
|
|
21
|
+
const allowedBorderStyles = Object.freeze(Object.values(BORDER_STYLES));
|
|
38
22
|
const DEFAULT_BORDER_STYLE = BORDER_STYLES.SOLID;
|
|
39
|
-
|
|
23
|
+
function isAllowedBorderStyle(value) {
|
|
24
|
+
return typeof value === "string" && allowedBorderStyles.includes(value);
|
|
25
|
+
}
|
|
40
26
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
27
|
+
* Reads the width, style and colour of a border from the `border` shorthand,
|
|
28
|
+
* letting any longhand already in the style win. The shorthand lists its
|
|
29
|
+
* parts in any order, so each is recognised by shape rather than position.
|
|
44
30
|
*/
|
|
45
|
-
function
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
31
|
+
function getBorderParts(style) {
|
|
32
|
+
const parts = (style.border ?? "").trim().split(/\s+/).filter(Boolean);
|
|
33
|
+
let color;
|
|
34
|
+
let borderStyle;
|
|
35
|
+
let width;
|
|
36
|
+
for (const part of parts) if (isAllowedBorderStyle(part) || part === "none") borderStyle = part;
|
|
37
|
+
else if (/^[\d.]/.test(part)) width = part;
|
|
38
|
+
else color = part;
|
|
49
39
|
return {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
borderBottomWidth: `${borderBottomWidth}px`,
|
|
54
|
-
borderLeftWidth: `${borderLeftWidth}px`,
|
|
55
|
-
borderStyle,
|
|
56
|
-
borderColor
|
|
57
|
-
},
|
|
58
|
-
...isBorderRadiusUniform ? { borderRadius: `${borderTopLeftRadius}px` } : { borderRadius: `${borderTopLeftRadius}px ${borderTopRightRadius}px ${borderBottomRightRadius}px ${borderBottomLeftRadius}px` }
|
|
40
|
+
color: style.borderColor ?? color,
|
|
41
|
+
style: style.borderStyle ?? borderStyle,
|
|
42
|
+
width: style.borderWidth ?? width
|
|
59
43
|
};
|
|
60
44
|
}
|
|
61
45
|
//#endregion
|
|
62
|
-
//#region src/
|
|
46
|
+
//#region src/box.ts
|
|
47
|
+
const BOX_SIDES = [
|
|
48
|
+
"top",
|
|
49
|
+
"right",
|
|
50
|
+
"bottom",
|
|
51
|
+
"left"
|
|
52
|
+
];
|
|
53
|
+
const BOX_CORNERS = [
|
|
54
|
+
"topLeft",
|
|
55
|
+
"topRight",
|
|
56
|
+
"bottomRight",
|
|
57
|
+
"bottomLeft"
|
|
58
|
+
];
|
|
59
|
+
function capitalize(value) {
|
|
60
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* CSS box shorthands repeat their values when fewer than four are given:
|
|
64
|
+
* one applies to every edge, two to the vertical then horizontal pair, and
|
|
65
|
+
* three to top, the horizontal pair, then bottom.
|
|
66
|
+
*/
|
|
67
|
+
function getShorthandEdges(shorthand) {
|
|
68
|
+
const parts = (shorthand ?? "").trim().split(/\s+/).filter(Boolean);
|
|
69
|
+
if (parts.length === 0) return null;
|
|
70
|
+
const [first, second = first, third = first, fourth = second] = parts;
|
|
71
|
+
return [
|
|
72
|
+
first,
|
|
73
|
+
second,
|
|
74
|
+
third,
|
|
75
|
+
fourth
|
|
76
|
+
].map(toLength);
|
|
77
|
+
}
|
|
78
|
+
function toLength(value) {
|
|
79
|
+
const parsed = Number.parseFloat(value);
|
|
80
|
+
return Number.isNaN(parsed) ? 0 : parsed;
|
|
81
|
+
}
|
|
82
|
+
function getLonghand(style, property, edge, suffix) {
|
|
83
|
+
return style[`${property}${capitalize(edge)}${suffix}`];
|
|
84
|
+
}
|
|
85
|
+
function toShorthand(edges) {
|
|
86
|
+
const [first, second, third, fourth] = edges;
|
|
87
|
+
return (first === third && second === fourth ? first === second ? [first] : [first, second] : [
|
|
88
|
+
first,
|
|
89
|
+
second,
|
|
90
|
+
third,
|
|
91
|
+
fourth
|
|
92
|
+
]).map((value) => `${value}px`).join(" ");
|
|
93
|
+
}
|
|
94
|
+
function getBoxSides(style, property) {
|
|
95
|
+
const [top, right, bottom, left] = getShorthandEdges(style[property]) ?? [
|
|
96
|
+
0,
|
|
97
|
+
0,
|
|
98
|
+
0,
|
|
99
|
+
0
|
|
100
|
+
];
|
|
101
|
+
const sides = {
|
|
102
|
+
bottom,
|
|
103
|
+
left,
|
|
104
|
+
right,
|
|
105
|
+
top
|
|
106
|
+
};
|
|
107
|
+
for (const side of BOX_SIDES) {
|
|
108
|
+
const longhand = getLonghand(style, property, side, "");
|
|
109
|
+
if (longhand !== void 0) sides[side] = toLength(longhand);
|
|
110
|
+
}
|
|
111
|
+
return sides;
|
|
112
|
+
}
|
|
113
|
+
function toBoxSides(property, values) {
|
|
114
|
+
const declarations = { [property]: toShorthand([
|
|
115
|
+
values.top,
|
|
116
|
+
values.right,
|
|
117
|
+
values.bottom,
|
|
118
|
+
values.left
|
|
119
|
+
]) };
|
|
120
|
+
for (const side of BOX_SIDES) declarations[`${property}${capitalize(side)}`] = null;
|
|
121
|
+
return declarations;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Radius shorthands run clockwise from the top-left corner, and repeat the
|
|
125
|
+
* same way box shorthands do.
|
|
126
|
+
*/
|
|
127
|
+
function getBoxCorners(style, property) {
|
|
128
|
+
const [topLeft, topRight, bottomRight, bottomLeft] = getShorthandEdges(style[property]) ?? [
|
|
129
|
+
0,
|
|
130
|
+
0,
|
|
131
|
+
0,
|
|
132
|
+
0
|
|
133
|
+
];
|
|
134
|
+
const corners = {
|
|
135
|
+
bottomLeft,
|
|
136
|
+
bottomRight,
|
|
137
|
+
topLeft,
|
|
138
|
+
topRight
|
|
139
|
+
};
|
|
140
|
+
for (const corner of BOX_CORNERS) {
|
|
141
|
+
const longhand = getLonghand(style, "border", corner, "Radius");
|
|
142
|
+
if (longhand !== void 0) corners[corner] = toLength(longhand);
|
|
143
|
+
}
|
|
144
|
+
return corners;
|
|
145
|
+
}
|
|
146
|
+
function toBoxCorners(property, values) {
|
|
147
|
+
const declarations = { [property]: toShorthand([
|
|
148
|
+
values.topLeft,
|
|
149
|
+
values.topRight,
|
|
150
|
+
values.bottomRight,
|
|
151
|
+
values.bottomLeft
|
|
152
|
+
]) };
|
|
153
|
+
for (const corner of BOX_CORNERS) declarations[`border${capitalize(corner)}Radius`] = null;
|
|
154
|
+
return declarations;
|
|
155
|
+
}
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/button.ts
|
|
63
158
|
/**
|
|
64
159
|
* Button layout kinds.
|
|
65
160
|
* "tight" renders the button at its content width,
|
|
@@ -75,14 +170,49 @@ function isAllowedButtonKind(value) {
|
|
|
75
170
|
return typeof value === "string" && allowedButtonKinds.includes(value);
|
|
76
171
|
}
|
|
77
172
|
//#endregion
|
|
173
|
+
//#region src/math.ts
|
|
174
|
+
function clamp(value, [min, max]) {
|
|
175
|
+
return Math.min(Math.max(value, min), max);
|
|
176
|
+
}
|
|
177
|
+
function percentage(portion, total) {
|
|
178
|
+
return clamp(portion / total * 100, [0, 100]);
|
|
179
|
+
}
|
|
180
|
+
function roundTo(value, decimals) {
|
|
181
|
+
const factor = 10 ** decimals;
|
|
182
|
+
return Math.round(value * factor) / factor;
|
|
183
|
+
}
|
|
184
|
+
function absoluteFromPercentage(percentage, total) {
|
|
185
|
+
return Math.round(total * percentage / 100);
|
|
186
|
+
}
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region src/column.ts
|
|
189
|
+
const PERCENTAGE_PATTERN = /^(\d+(?:\.\d+)?)%$/;
|
|
190
|
+
const PIXEL_PATTERN = /^(\d+(?:\.\d+)?)px$/;
|
|
191
|
+
const CSS_LENGTH_PATTERN = /^\d+(?:\.\d+)?(?:px|pt|pc|in|cm|mm|em|rem|ex|ch|vw|vh|vmin|vmax)$/;
|
|
192
|
+
function getColumnWidth(value) {
|
|
193
|
+
const declaration = value?.trim();
|
|
194
|
+
if (!declaration) return null;
|
|
195
|
+
const percentage = PERCENTAGE_PATTERN.exec(declaration);
|
|
196
|
+
if (percentage) return Number(percentage[1]);
|
|
197
|
+
return CSS_LENGTH_PATTERN.test(declaration) ? declaration : null;
|
|
198
|
+
}
|
|
199
|
+
function getColumnWidthValue(width) {
|
|
200
|
+
return typeof width === "number" ? `${width}%` : width;
|
|
201
|
+
}
|
|
202
|
+
function getColumnWidthPercent(options) {
|
|
203
|
+
const { containerWidth, width } = options;
|
|
204
|
+
if (width === null || width === void 0) return null;
|
|
205
|
+
if (typeof width === "number") return width;
|
|
206
|
+
const percentage = PERCENTAGE_PATTERN.exec(width);
|
|
207
|
+
if (percentage) return Number(percentage[1]);
|
|
208
|
+
const pixels = PIXEL_PATTERN.exec(width);
|
|
209
|
+
if (pixels && containerWidth > 0) return roundTo(Number(pixels[1]) / containerWidth * 100, 3);
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
//#endregion
|
|
78
213
|
//#region src/constants.ts
|
|
79
|
-
/** HTML data attribute key used to identify node types in rendered output. */
|
|
80
214
|
const DATA_NODE_TYPE_KEY = "data-node-type";
|
|
81
|
-
/** HTML data attribute key used to store serialized visibility rules. */
|
|
82
|
-
const DATA_VISIBILITY_RULE_KEY = "data-visibility-rule";
|
|
83
|
-
/** Prefix prepended to all Maily error messages for easy identification. */
|
|
84
215
|
const MAILY_ERROR_PREFIX = "[Maily Error]";
|
|
85
|
-
/** URL for filing bug reports against the Maily repository. */
|
|
86
216
|
const MAILY_BUG_REPORT_URL = "https://github.com/arikchakma/maily.to/issues/new";
|
|
87
217
|
//#endregion
|
|
88
218
|
//#region src/font.ts
|
|
@@ -103,14 +233,6 @@ const allowedFallbackFonts = [
|
|
|
103
233
|
"cursive",
|
|
104
234
|
"fantasy"
|
|
105
235
|
];
|
|
106
|
-
const allowedFontFormats = [
|
|
107
|
-
"woff",
|
|
108
|
-
"woff2",
|
|
109
|
-
"truetype",
|
|
110
|
-
"opentype",
|
|
111
|
-
"embedded-opentype",
|
|
112
|
-
"svg"
|
|
113
|
-
];
|
|
114
236
|
/**
|
|
115
237
|
* Default font configuration: Inter with sans-serif fallback,
|
|
116
238
|
* loaded from the Maily CDN as woff2.
|
|
@@ -119,19 +241,18 @@ const DEFAULT_FONT = {
|
|
|
119
241
|
fallbackFontFamily: "sans-serif",
|
|
120
242
|
fontFamily: "Inter",
|
|
121
243
|
webFont: {
|
|
122
|
-
|
|
123
|
-
|
|
244
|
+
format: "woff2",
|
|
245
|
+
url: "https://cdn.usemaily.com/fonts/v0/inter.woff2"
|
|
124
246
|
}
|
|
125
247
|
};
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
document.head.appendChild(styleElement);
|
|
248
|
+
function getFontFamilyNames(value) {
|
|
249
|
+
return value.split(",").map((font) => {
|
|
250
|
+
return font.trim().replace(/['"]/g, "");
|
|
251
|
+
}).filter(Boolean);
|
|
252
|
+
}
|
|
253
|
+
function getFontFamilyValue(options) {
|
|
254
|
+
const { fallbackFontFamily, fontFamily } = options;
|
|
255
|
+
return [fontFamily ? `'${fontFamily}'` : null, fallbackFontFamily].filter(Boolean).join(", ");
|
|
135
256
|
}
|
|
136
257
|
/**
|
|
137
258
|
* Generates a @font-face CSS rule string for the given font configuration.
|
|
@@ -139,242 +260,17 @@ function loadFont(font) {
|
|
|
139
260
|
* source URL when available.
|
|
140
261
|
*/
|
|
141
262
|
function getFontFaceStyle(font) {
|
|
142
|
-
const {
|
|
263
|
+
const { fallbackFontFamily, fontFamily, fontStyle = "normal", fontWeight = 400, webFont } = font;
|
|
143
264
|
return `@font-face {font-family: '${fontFamily}';font-style: ${fontStyle};font-weight: ${fontWeight};mso-font-alt: '${fallbackFontFamily}';${webFont ? `src: url(${webFont.url}) format('${webFont.format}');` : ""}}`;
|
|
144
265
|
}
|
|
145
|
-
//#endregion
|
|
146
|
-
//#region src/css-variables.ts
|
|
147
|
-
/**
|
|
148
|
-
* Returns a CSS variable object for the given name and value.
|
|
149
|
-
* If the value is nullish or empty, returns an empty object so that
|
|
150
|
-
* the default CSS variable value is not overridden. Numbers are
|
|
151
|
-
* automatically suffixed with "px".
|
|
152
|
-
*/
|
|
153
|
-
function getVariableValue(name, value) {
|
|
154
|
-
if (value === void 0 || value === null || value === "") return {};
|
|
155
|
-
return { [name]: typeof value === "number" ? `${value}px` : value };
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Converts an EditorThemeOptions object into a flat map of Maily CSS
|
|
159
|
-
* custom properties (--mly-*). Used to apply theme overrides as inline
|
|
160
|
-
* styles on the editor or renderer root element. Covers body background,
|
|
161
|
-
* container dimensions and borders, button colors, link color, and
|
|
162
|
-
* font family settings.
|
|
163
|
-
*/
|
|
164
|
-
function getMailyCssVariables(theme) {
|
|
165
|
-
const font = theme.font || DEFAULT_FONT;
|
|
166
|
-
return {
|
|
167
|
-
...getVariableValue("--mly-body-background-color", theme.body?.backgroundColor),
|
|
168
|
-
...getVariableValue("--mly-body-padding-top", theme.body?.paddingTop),
|
|
169
|
-
...getVariableValue("--mly-body-padding-right", theme.body?.paddingRight),
|
|
170
|
-
...getVariableValue("--mly-body-padding-bottom", theme.body?.paddingBottom),
|
|
171
|
-
...getVariableValue("--mly-body-padding-left", theme.body?.paddingLeft),
|
|
172
|
-
...getVariableValue("--mly-container-background-color", theme.container?.backgroundColor),
|
|
173
|
-
...getVariableValue("--mly-container-max-width", theme.container?.maxWidth),
|
|
174
|
-
...getVariableValue("--mly-container-min-width", theme.container?.minWidth),
|
|
175
|
-
...getVariableValue("--mly-container-padding-top", theme.container?.paddingTop),
|
|
176
|
-
...getVariableValue("--mly-container-padding-right", theme.container?.paddingRight),
|
|
177
|
-
...getVariableValue("--mly-container-padding-bottom", theme.container?.paddingBottom),
|
|
178
|
-
...getVariableValue("--mly-container-padding-left", theme.container?.paddingLeft),
|
|
179
|
-
...getVariableValue("--mly-container-border-radius", theme.container?.borderRadius),
|
|
180
|
-
...getVariableValue("--mly-container-border-width", theme.container?.borderWidth),
|
|
181
|
-
...getVariableValue("--mly-container-border-color", theme.container?.borderColor),
|
|
182
|
-
...getVariableValue("--mly-button-background-color", theme.button?.backgroundColor),
|
|
183
|
-
...getVariableValue("--mly-button-text-color", theme.button?.color),
|
|
184
|
-
...getVariableValue("--mly-button-padding-top", theme.button?.paddingTop),
|
|
185
|
-
...getVariableValue("--mly-button-padding-right", theme.button?.paddingRight),
|
|
186
|
-
...getVariableValue("--mly-button-padding-bottom", theme.button?.paddingBottom),
|
|
187
|
-
...getVariableValue("--mly-button-padding-left", theme.button?.paddingLeft),
|
|
188
|
-
...getVariableValue("--mly-link-color", theme.link?.color),
|
|
189
|
-
...getVariableValue("--mly-font-family", font.fontFamily),
|
|
190
|
-
...getVariableValue("--mly-font-fallback-family", font.fallbackFontFamily),
|
|
191
|
-
"--mly-font": `var(--mly-font-family), var(--mly-font-fallback-family)`
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
//#endregion
|
|
195
|
-
//#region src/html-code-block.ts
|
|
196
|
-
/**
|
|
197
|
-
* Tab options for the HTML code block node.
|
|
198
|
-
* "code" shows the raw HTML source, "preview" renders it visually.
|
|
199
|
-
*/
|
|
200
|
-
const HTML_CODE_BLOCK_TABS = {
|
|
201
|
-
CODE: "code",
|
|
202
|
-
PREVIEW: "preview"
|
|
203
|
-
};
|
|
204
|
-
const DEFAULT_HTML_CODE_BLOCK_TAB = HTML_CODE_BLOCK_TABS.CODE;
|
|
205
|
-
//#endregion
|
|
206
|
-
//#region src/math.ts
|
|
207
|
-
function clamp(value, [min, max]) {
|
|
208
|
-
return Math.min(Math.max(value, min), max);
|
|
209
|
-
}
|
|
210
|
-
function percentage(portion, total) {
|
|
211
|
-
return clamp(portion / total * 100, [0, 100]);
|
|
212
|
-
}
|
|
213
|
-
function absoluteFromPercentage(percentage, total) {
|
|
214
|
-
return Math.round(total * percentage / 100);
|
|
215
|
-
}
|
|
216
|
-
function roundTo(value, decimals) {
|
|
217
|
-
const factor = Math.pow(10, decimals);
|
|
218
|
-
return Math.round(value * factor) / factor;
|
|
219
|
-
}
|
|
220
|
-
//#endregion
|
|
221
|
-
//#region src/image-width.ts
|
|
222
|
-
const MIN_IMAGE_WIDTH_PERCENTAGE = 5;
|
|
223
|
-
const MAX_IMAGE_WIDTH_PERCENTAGE = 100;
|
|
224
|
-
const MAX_IMAGE_WIDTH_PIXELS = 600;
|
|
225
|
-
/**
|
|
226
|
-
* Converts any ImageWidth value to a clamped percentage number.
|
|
227
|
-
* Handles "auto" (→ 100), percentage strings (e.g. "50%" → 50),
|
|
228
|
-
* and legacy pixel numbers (converted relative to maxWidthPixels).
|
|
229
|
-
* Returns 100 for null or unrecognized values.
|
|
230
|
-
*/
|
|
231
|
-
function parseWidthToPercentage(width, maxWidthPixels = MAX_IMAGE_WIDTH_PIXELS) {
|
|
232
|
-
if (typeof width === "string") {
|
|
233
|
-
if (width === "auto") return 100;
|
|
234
|
-
return width.endsWith("%") ? clampImageWidthPercentage(parseInt(width)) : 100;
|
|
235
|
-
}
|
|
236
|
-
if (typeof width === "number") return clampImageWidthPercentage(Math.round(100 * width / maxWidthPixels));
|
|
237
|
-
return 100;
|
|
238
|
-
}
|
|
239
|
-
function clampImageWidthPercentage(width) {
|
|
240
|
-
return clamp(width, [5, 100]);
|
|
241
|
-
}
|
|
242
|
-
//#endregion
|
|
243
|
-
//#region src/mark.ts
|
|
244
|
-
/** Registry of all inline mark type strings used in the document JSON. */
|
|
245
|
-
const MAILY_MARK_TYPES = {
|
|
246
|
-
BOLD: "bold",
|
|
247
|
-
ITALIC: "italic",
|
|
248
|
-
STRIKE: "strike",
|
|
249
|
-
UNDERLINE: "underline",
|
|
250
|
-
LINK: "link",
|
|
251
|
-
CODE: "code",
|
|
252
|
-
TEXT_STYLE: "textStyle",
|
|
253
|
-
HIGHLIGHT: "highlight"
|
|
254
|
-
};
|
|
255
|
-
const allowedMarkTypes = Object.values(MAILY_MARK_TYPES);
|
|
256
|
-
//#endregion
|
|
257
|
-
//#region src/node.ts
|
|
258
266
|
/**
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
* document JSON.
|
|
262
|
-
*/
|
|
263
|
-
const MAILY_NODE_TYPES = {
|
|
264
|
-
DOCUMENT: "doc",
|
|
265
|
-
PARAGRAPH: "paragraph",
|
|
266
|
-
TEXT: "text",
|
|
267
|
-
HEADING: "heading",
|
|
268
|
-
VARIABLE: "variable",
|
|
269
|
-
IMAGE: "image",
|
|
270
|
-
SPACER: "spacer",
|
|
271
|
-
SECTION: "section",
|
|
272
|
-
COLUMNS: "columns",
|
|
273
|
-
COLUMN: "column",
|
|
274
|
-
BULLET_LIST: "bulletList",
|
|
275
|
-
ORDERED_LIST: "orderedList",
|
|
276
|
-
LIST_ITEM: "listItem",
|
|
277
|
-
HORIZONTAL_RULE: "horizontalRule",
|
|
278
|
-
BUTTON: "button",
|
|
279
|
-
REPEAT: "repeat",
|
|
280
|
-
HTML_CODE_BLOCK: "htmlCodeBlock",
|
|
281
|
-
BLOCKQUOTE: "blockquote",
|
|
282
|
-
HARD_BREAK: "hardBreak",
|
|
283
|
-
FOOTER: "footer",
|
|
284
|
-
INLINE_IMAGE: "inlineImage",
|
|
285
|
-
LINK_CARD: "linkCard"
|
|
286
|
-
};
|
|
287
|
-
/**
|
|
288
|
-
* Tiptap extension types that attach attributes to nodes but are
|
|
289
|
-
* not document nodes themselves (e.g. fontStyle, visibility).
|
|
290
|
-
*/
|
|
291
|
-
const MAILY_EXTENSION_TYPES = {
|
|
292
|
-
FONT_STYLE: "fontStyle",
|
|
293
|
-
VISIBILITY: "visibility"
|
|
294
|
-
};
|
|
295
|
-
const allowedNodeTypes = Object.values(MAILY_NODE_TYPES);
|
|
296
|
-
//#endregion
|
|
297
|
-
//#region src/is.ts
|
|
298
|
-
function guard(type) {
|
|
299
|
-
return (node) => node.type === type;
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* Type guards for Maily nodes and marks. Provides narrowing functions
|
|
303
|
-
* for every node type (is.paragraph, is.button, etc.) and mark type
|
|
304
|
-
* (is.bold, is.link, etc.), plus structural checks like is.parent
|
|
305
|
-
* and is.marked. Each guard narrows the input to its specific type.
|
|
306
|
-
*
|
|
307
|
-
* Example:
|
|
308
|
-
* if (is.paragraph(node)) {
|
|
309
|
-
* node.attrs.textAlign // narrowed to ParagraphNode
|
|
310
|
-
* }
|
|
267
|
+
* Injects a @font-face style element into the document head to load
|
|
268
|
+
* the given font. Only works in browser environments.
|
|
311
269
|
*/
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
parent(node) {
|
|
317
|
-
return Array.isArray(node?.content);
|
|
318
|
-
},
|
|
319
|
-
marked(node) {
|
|
320
|
-
return Array.isArray(node?.marks);
|
|
321
|
-
},
|
|
322
|
-
node(node) {
|
|
323
|
-
return typeof node === "object" && node !== null && "type" in node && allowedNodeTypes.includes(node.type);
|
|
324
|
-
},
|
|
325
|
-
doc: guard(MAILY_NODE_TYPES.DOCUMENT),
|
|
326
|
-
paragraph: guard(MAILY_NODE_TYPES.PARAGRAPH),
|
|
327
|
-
text: guard(MAILY_NODE_TYPES.TEXT),
|
|
328
|
-
heading: guard(MAILY_NODE_TYPES.HEADING),
|
|
329
|
-
variable: guard(MAILY_NODE_TYPES.VARIABLE),
|
|
330
|
-
image: guard(MAILY_NODE_TYPES.IMAGE),
|
|
331
|
-
inlineImage: guard(MAILY_NODE_TYPES.INLINE_IMAGE),
|
|
332
|
-
spacer: guard(MAILY_NODE_TYPES.SPACER),
|
|
333
|
-
section: guard(MAILY_NODE_TYPES.SECTION),
|
|
334
|
-
button: guard(MAILY_NODE_TYPES.BUTTON),
|
|
335
|
-
columns: guard(MAILY_NODE_TYPES.COLUMNS),
|
|
336
|
-
column: guard(MAILY_NODE_TYPES.COLUMN),
|
|
337
|
-
repeat: guard(MAILY_NODE_TYPES.REPEAT),
|
|
338
|
-
bulletList: guard(MAILY_NODE_TYPES.BULLET_LIST),
|
|
339
|
-
orderedList: guard(MAILY_NODE_TYPES.ORDERED_LIST),
|
|
340
|
-
listItem: guard(MAILY_NODE_TYPES.LIST_ITEM),
|
|
341
|
-
horizontalRule: guard(MAILY_NODE_TYPES.HORIZONTAL_RULE),
|
|
342
|
-
htmlCodeBlock: guard(MAILY_NODE_TYPES.HTML_CODE_BLOCK),
|
|
343
|
-
blockquote: guard(MAILY_NODE_TYPES.BLOCKQUOTE),
|
|
344
|
-
hardBreak: guard(MAILY_NODE_TYPES.HARD_BREAK),
|
|
345
|
-
footer: guard(MAILY_NODE_TYPES.FOOTER),
|
|
346
|
-
linkCard: guard(MAILY_NODE_TYPES.LINK_CARD),
|
|
347
|
-
mark(mark) {
|
|
348
|
-
return typeof mark === "object" && mark !== null && "type" in mark && allowedMarkTypes.includes(mark.type);
|
|
349
|
-
},
|
|
350
|
-
bold: guard(MAILY_MARK_TYPES.BOLD),
|
|
351
|
-
italic: guard(MAILY_MARK_TYPES.ITALIC),
|
|
352
|
-
strike: guard(MAILY_MARK_TYPES.STRIKE),
|
|
353
|
-
underline: guard(MAILY_MARK_TYPES.UNDERLINE),
|
|
354
|
-
link: guard(MAILY_MARK_TYPES.LINK),
|
|
355
|
-
code: guard(MAILY_MARK_TYPES.CODE),
|
|
356
|
-
textStyle: guard(MAILY_MARK_TYPES.TEXT_STYLE),
|
|
357
|
-
highlight: guard(MAILY_MARK_TYPES.HIGHLIGHT)
|
|
358
|
-
};
|
|
359
|
-
/** Type guard that checks if a value is defined (not null or undefined). */
|
|
360
|
-
function isDef(val) {
|
|
361
|
-
return val !== void 0 && val !== null;
|
|
362
|
-
}
|
|
363
|
-
/** Type guard that checks if a value is a boolean. */
|
|
364
|
-
function isBoolean(val) {
|
|
365
|
-
return typeof val === "boolean";
|
|
366
|
-
}
|
|
367
|
-
/** Type guard that checks if a value is a number. */
|
|
368
|
-
function isNumber(val) {
|
|
369
|
-
return typeof val === "number";
|
|
370
|
-
}
|
|
371
|
-
/** Type guard that checks if a value is a string. */
|
|
372
|
-
function isString(val) {
|
|
373
|
-
return typeof val === "string";
|
|
374
|
-
}
|
|
375
|
-
/** Type guard that checks if a value is a non-null object. */
|
|
376
|
-
function isObject(val) {
|
|
377
|
-
return typeof val === "object" && val !== null;
|
|
270
|
+
function loadFont(font) {
|
|
271
|
+
const styleElement = document.createElement("style");
|
|
272
|
+
styleElement.textContent = getFontFaceStyle(font);
|
|
273
|
+
document.head.appendChild(styleElement);
|
|
378
274
|
}
|
|
379
275
|
//#endregion
|
|
380
276
|
//#region src/font-style.ts
|
|
@@ -386,57 +282,57 @@ const DEFAULT_FONT_FAMILIES = [
|
|
|
386
282
|
{
|
|
387
283
|
fontFamily: "Inter",
|
|
388
284
|
webFont: {
|
|
389
|
-
|
|
390
|
-
|
|
285
|
+
format: "woff2",
|
|
286
|
+
url: "https://cdn.usemaily.com/fonts/v0/inter.woff2"
|
|
391
287
|
}
|
|
392
288
|
},
|
|
393
289
|
{
|
|
394
290
|
fontFamily: "Roboto",
|
|
395
291
|
webFont: {
|
|
396
|
-
|
|
397
|
-
|
|
292
|
+
format: "woff2",
|
|
293
|
+
url: "https://cdn.usemaily.com/fonts/v0/roboto.woff2"
|
|
398
294
|
}
|
|
399
295
|
},
|
|
400
296
|
{
|
|
401
297
|
fontFamily: "Open Sans",
|
|
402
298
|
webFont: {
|
|
403
|
-
|
|
404
|
-
|
|
299
|
+
format: "woff2",
|
|
300
|
+
url: "https://cdn.usemaily.com/fonts/v0/open-sans.woff2"
|
|
405
301
|
}
|
|
406
302
|
},
|
|
407
303
|
{
|
|
408
304
|
fontFamily: "Lato",
|
|
409
305
|
webFont: {
|
|
410
|
-
|
|
411
|
-
|
|
306
|
+
format: "woff2",
|
|
307
|
+
url: "https://cdn.usemaily.com/fonts/v0/lato.woff2"
|
|
412
308
|
}
|
|
413
309
|
},
|
|
414
310
|
{
|
|
415
311
|
fontFamily: "Montserrat",
|
|
416
312
|
webFont: {
|
|
417
|
-
|
|
418
|
-
|
|
313
|
+
format: "woff2",
|
|
314
|
+
url: "https://cdn.usemaily.com/fonts/v0/montserrat.woff2"
|
|
419
315
|
}
|
|
420
316
|
},
|
|
421
317
|
{
|
|
422
318
|
fontFamily: "Poppins",
|
|
423
319
|
webFont: {
|
|
424
|
-
|
|
425
|
-
|
|
320
|
+
format: "woff2",
|
|
321
|
+
url: "https://cdn.usemaily.com/fonts/v0/poppins.woff2"
|
|
426
322
|
}
|
|
427
323
|
},
|
|
428
324
|
{
|
|
429
325
|
fontFamily: "Raleway",
|
|
430
326
|
webFont: {
|
|
431
|
-
|
|
432
|
-
|
|
327
|
+
format: "woff2",
|
|
328
|
+
url: "https://cdn.usemaily.com/fonts/v0/raleway.woff2"
|
|
433
329
|
}
|
|
434
330
|
},
|
|
435
331
|
{
|
|
436
332
|
fontFamily: "Ubuntu",
|
|
437
333
|
webFont: {
|
|
438
|
-
|
|
439
|
-
|
|
334
|
+
format: "woff2",
|
|
335
|
+
url: "https://cdn.usemaily.com/fonts/v0/ubuntu.woff2"
|
|
440
336
|
}
|
|
441
337
|
},
|
|
442
338
|
{ fontFamily: "Arial" },
|
|
@@ -451,7 +347,6 @@ const FONT_STYLES = {
|
|
|
451
347
|
NORMAL: "normal",
|
|
452
348
|
ITALIC: "italic"
|
|
453
349
|
};
|
|
454
|
-
/** Preset options for the font size dropdown in the editor. */
|
|
455
350
|
const FONT_SIZE_PRESETS = [
|
|
456
351
|
{
|
|
457
352
|
value: 12,
|
|
@@ -478,7 +373,6 @@ const FONT_SIZE_PRESETS = [
|
|
|
478
373
|
label: "2XL"
|
|
479
374
|
}
|
|
480
375
|
];
|
|
481
|
-
/** Preset options for the line height dropdown in the editor. */
|
|
482
376
|
const LINE_HEIGHT_PRESETS = [
|
|
483
377
|
{
|
|
484
378
|
value: 1,
|
|
@@ -502,30 +396,7 @@ const LINE_HEIGHT_PRESETS = [
|
|
|
502
396
|
}
|
|
503
397
|
];
|
|
504
398
|
const DEFAULT_FONT_FAMILY = "Inter";
|
|
505
|
-
const DEFAULT_FONT_SIZE = 15;
|
|
506
|
-
const DEFAULT_FONT_WEIGHT = 400;
|
|
507
|
-
const DEFAULT_LINE_HEIGHT = 1.75;
|
|
508
399
|
const DEFAULT_FONT_FALLBACK = "sans-serif";
|
|
509
|
-
/**
|
|
510
|
-
* Builds a CSS properties object from a node's font attributes,
|
|
511
|
-
* falling back to the provided defaults for any null values.
|
|
512
|
-
* Only includes properties that have a resolved value.
|
|
513
|
-
*/
|
|
514
|
-
function getFontStyle(attrs, defaults) {
|
|
515
|
-
const { fontFamily, fontFallback, fontSize, fontWeight, lineHeight, fontStyle } = attrs;
|
|
516
|
-
const size = fontSize ?? defaults?.fontSize;
|
|
517
|
-
const weight = fontWeight ?? defaults?.fontWeight;
|
|
518
|
-
const line = lineHeight ?? defaults?.lineHeight;
|
|
519
|
-
const style = fontStyle ?? defaults?.fontStyle;
|
|
520
|
-
const fontFamilyParts = [fontFamily, fontFallback].filter(Boolean);
|
|
521
|
-
return {
|
|
522
|
-
...fontFamilyParts.length > 0 && { fontFamily: fontFamilyParts.join(", ") },
|
|
523
|
-
...isDef(size) ? { fontSize: `${size}px` } : {},
|
|
524
|
-
...isDef(weight) ? { fontWeight: weight } : {},
|
|
525
|
-
...isDef(line) ? { lineHeight: line } : {},
|
|
526
|
-
...isDef(style) ? { fontStyle: style } : {}
|
|
527
|
-
};
|
|
528
|
-
}
|
|
529
400
|
//#endregion
|
|
530
401
|
//#region src/font-weight.ts
|
|
531
402
|
/**
|
|
@@ -541,9 +412,42 @@ const FONT_WEIGHTS = {
|
|
|
541
412
|
};
|
|
542
413
|
//#endregion
|
|
543
414
|
//#region src/function.ts
|
|
544
|
-
/** A no-operation function. Useful as a default callback or placeholder. */
|
|
545
415
|
function noop() {}
|
|
546
416
|
//#endregion
|
|
417
|
+
//#region src/html-code-block.ts
|
|
418
|
+
/**
|
|
419
|
+
* Tab options for the HTML code block node.
|
|
420
|
+
* "code" shows the raw HTML source, "preview" renders it visually.
|
|
421
|
+
*/
|
|
422
|
+
const HTML_CODE_BLOCK_TABS = {
|
|
423
|
+
CODE: "code",
|
|
424
|
+
PREVIEW: "preview"
|
|
425
|
+
};
|
|
426
|
+
const DEFAULT_HTML_CODE_BLOCK_TAB = HTML_CODE_BLOCK_TABS.CODE;
|
|
427
|
+
//#endregion
|
|
428
|
+
//#region src/image.ts
|
|
429
|
+
const MIN_IMAGE_WIDTH_PERCENTAGE = 5;
|
|
430
|
+
const MAX_IMAGE_WIDTH_PERCENTAGE = 100;
|
|
431
|
+
const DEFAULT_CONTAINER_WIDTH_PIXELS = 600;
|
|
432
|
+
const PIXEL_SUFFIX = "px";
|
|
433
|
+
function getPixels(value) {
|
|
434
|
+
const length = value.endsWith(PIXEL_SUFFIX) ? value.slice(0, -2) : value;
|
|
435
|
+
if (length === "") return null;
|
|
436
|
+
const pixels = Number(length);
|
|
437
|
+
return Number.isFinite(pixels) ? pixels : null;
|
|
438
|
+
}
|
|
439
|
+
function parseWidthToPercentage(width, containerWidthPixels = 600) {
|
|
440
|
+
if (width === null || width === void 0 || width === "auto") return 100;
|
|
441
|
+
const value = String(width).trim();
|
|
442
|
+
if (value.endsWith("%")) return clampImageWidthPercentage(Number.parseFloat(value));
|
|
443
|
+
const pixels = getPixels(value);
|
|
444
|
+
if (pixels === null) return 100;
|
|
445
|
+
return clampImageWidthPercentage(Math.round(100 * pixels / containerWidthPixels));
|
|
446
|
+
}
|
|
447
|
+
function clampImageWidthPercentage(width) {
|
|
448
|
+
return clamp(width, [5, 100]);
|
|
449
|
+
}
|
|
450
|
+
//#endregion
|
|
547
451
|
//#region src/invariant.ts
|
|
548
452
|
function invariant(value, message) {
|
|
549
453
|
if (value === false || value === null || typeof value === "undefined") {
|
|
@@ -553,25 +457,133 @@ Please open an issue! ${MAILY_BUG_REPORT_URL}`);
|
|
|
553
457
|
}
|
|
554
458
|
}
|
|
555
459
|
//#endregion
|
|
556
|
-
//#region src/
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
460
|
+
//#region src/mark.ts
|
|
461
|
+
const MAILY_MARK_TYPES = {
|
|
462
|
+
BOLD: "bold",
|
|
463
|
+
ITALIC: "italic",
|
|
464
|
+
STRIKE: "strike",
|
|
465
|
+
UNDERLINE: "underline",
|
|
466
|
+
LINK: "link",
|
|
467
|
+
CODE: "code",
|
|
468
|
+
TEXT_STYLE: "textStyle",
|
|
469
|
+
HIGHLIGHT: "highlight",
|
|
470
|
+
SPAN: "span"
|
|
471
|
+
};
|
|
472
|
+
const allowedMarkTypes = Object.values(MAILY_MARK_TYPES);
|
|
473
|
+
//#endregion
|
|
474
|
+
//#region src/node.ts
|
|
475
|
+
const MAILY_NODE_TYPES = {
|
|
476
|
+
DOCUMENT: "doc",
|
|
477
|
+
BODY: "body",
|
|
478
|
+
CONTAINER: "container",
|
|
479
|
+
SECTION: "section",
|
|
480
|
+
DIV: "div",
|
|
481
|
+
COLUMNS: "columns",
|
|
482
|
+
COLUMN: "column",
|
|
483
|
+
IMAGE: "image",
|
|
484
|
+
INLINE_IMAGE: "inlineImage",
|
|
485
|
+
INLINE_SPAN: "inlineSpan",
|
|
486
|
+
SPACER: "spacer",
|
|
487
|
+
BUTTON: "button",
|
|
488
|
+
FOOTER: "footer",
|
|
489
|
+
PARAGRAPH: "paragraph",
|
|
490
|
+
HEADING: "heading",
|
|
491
|
+
BLOCKQUOTE: "blockquote",
|
|
492
|
+
HORIZONTAL_RULE: "horizontalRule",
|
|
493
|
+
HTML_CODE_BLOCK: "htmlCodeBlock",
|
|
494
|
+
REPEAT: "repeat",
|
|
495
|
+
HARD_BREAK: "hardBreak",
|
|
496
|
+
BULLET_LIST: "bulletList",
|
|
497
|
+
ORDERED_LIST: "orderedList",
|
|
498
|
+
LIST_ITEM: "listItem",
|
|
499
|
+
TEXT: "text",
|
|
500
|
+
VARIABLE: "variable",
|
|
501
|
+
TABLE: "table",
|
|
502
|
+
TABLE_ROW: "tableRow",
|
|
503
|
+
TABLE_CELL: "tableCell",
|
|
504
|
+
TABLE_HEADER: "tableHeader",
|
|
505
|
+
LINK_CARD: "linkCard"
|
|
506
|
+
};
|
|
507
|
+
const MAILY_EXTENSION_TYPES = {
|
|
508
|
+
STYLE: "style",
|
|
509
|
+
THEME: "theme",
|
|
510
|
+
VISIBILITY: "visibility"
|
|
511
|
+
};
|
|
512
|
+
const allowedNodeTypes = Object.values(MAILY_NODE_TYPES);
|
|
513
|
+
const DEFAULT_VARIABLE_ATTRIBUTES = {
|
|
514
|
+
fallback: null,
|
|
515
|
+
isDefaultEditable: true,
|
|
516
|
+
label: null,
|
|
517
|
+
required: true,
|
|
518
|
+
style: null
|
|
519
|
+
};
|
|
520
|
+
//#endregion
|
|
521
|
+
//#region src/is.ts
|
|
522
|
+
function guard(type) {
|
|
523
|
+
return (value) => value.type === type;
|
|
524
|
+
}
|
|
525
|
+
function isObject(val) {
|
|
526
|
+
return typeof val === "object" && val !== null;
|
|
527
|
+
}
|
|
528
|
+
const is = {
|
|
529
|
+
node(value) {
|
|
530
|
+
return typeof value === "object" && value !== null && "type" in value && allowedNodeTypes.includes(value.type);
|
|
531
|
+
},
|
|
532
|
+
mark(value) {
|
|
533
|
+
return typeof value === "object" && value !== null && "type" in value && allowedMarkTypes.includes(value.type);
|
|
534
|
+
},
|
|
535
|
+
parent(node) {
|
|
536
|
+
return Array.isArray(node?.content);
|
|
537
|
+
},
|
|
538
|
+
marked(node) {
|
|
539
|
+
return Array.isArray(node?.marks);
|
|
540
|
+
},
|
|
541
|
+
doc: guard(MAILY_NODE_TYPES.DOCUMENT),
|
|
542
|
+
body: guard(MAILY_NODE_TYPES.BODY),
|
|
543
|
+
container: guard(MAILY_NODE_TYPES.CONTAINER),
|
|
544
|
+
section: guard(MAILY_NODE_TYPES.SECTION),
|
|
545
|
+
div: guard(MAILY_NODE_TYPES.DIV),
|
|
546
|
+
columns: guard(MAILY_NODE_TYPES.COLUMNS),
|
|
547
|
+
column: guard(MAILY_NODE_TYPES.COLUMN),
|
|
548
|
+
image: guard(MAILY_NODE_TYPES.IMAGE),
|
|
549
|
+
inlineImage: guard(MAILY_NODE_TYPES.INLINE_IMAGE),
|
|
550
|
+
inlineSpan: guard(MAILY_NODE_TYPES.INLINE_SPAN),
|
|
551
|
+
spacer: guard(MAILY_NODE_TYPES.SPACER),
|
|
552
|
+
button: guard(MAILY_NODE_TYPES.BUTTON),
|
|
553
|
+
footer: guard(MAILY_NODE_TYPES.FOOTER),
|
|
554
|
+
paragraph: guard(MAILY_NODE_TYPES.PARAGRAPH),
|
|
555
|
+
heading: guard(MAILY_NODE_TYPES.HEADING),
|
|
556
|
+
blockquote: guard(MAILY_NODE_TYPES.BLOCKQUOTE),
|
|
557
|
+
horizontalRule: guard(MAILY_NODE_TYPES.HORIZONTAL_RULE),
|
|
558
|
+
hardBreak: guard(MAILY_NODE_TYPES.HARD_BREAK),
|
|
559
|
+
htmlCodeBlock: guard(MAILY_NODE_TYPES.HTML_CODE_BLOCK),
|
|
560
|
+
repeat: guard(MAILY_NODE_TYPES.REPEAT),
|
|
561
|
+
bulletList: guard(MAILY_NODE_TYPES.BULLET_LIST),
|
|
562
|
+
orderedList: guard(MAILY_NODE_TYPES.ORDERED_LIST),
|
|
563
|
+
listItem: guard(MAILY_NODE_TYPES.LIST_ITEM),
|
|
564
|
+
linkCard: guard(MAILY_NODE_TYPES.LINK_CARD),
|
|
565
|
+
text: guard(MAILY_NODE_TYPES.TEXT),
|
|
566
|
+
variable: guard(MAILY_NODE_TYPES.VARIABLE),
|
|
567
|
+
table: guard(MAILY_NODE_TYPES.TABLE),
|
|
568
|
+
tableRow: guard(MAILY_NODE_TYPES.TABLE_ROW),
|
|
569
|
+
tableCell: guard(MAILY_NODE_TYPES.TABLE_CELL),
|
|
570
|
+
tableHeader: guard(MAILY_NODE_TYPES.TABLE_HEADER),
|
|
571
|
+
bold: guard(MAILY_MARK_TYPES.BOLD),
|
|
572
|
+
italic: guard(MAILY_MARK_TYPES.ITALIC),
|
|
573
|
+
strike: guard(MAILY_MARK_TYPES.STRIKE),
|
|
574
|
+
underline: guard(MAILY_MARK_TYPES.UNDERLINE),
|
|
575
|
+
link: guard(MAILY_MARK_TYPES.LINK),
|
|
576
|
+
code: guard(MAILY_MARK_TYPES.CODE),
|
|
577
|
+
textStyle: guard(MAILY_MARK_TYPES.TEXT_STYLE),
|
|
578
|
+
highlight: guard(MAILY_MARK_TYPES.HIGHLIGHT),
|
|
579
|
+
span: guard(MAILY_MARK_TYPES.SPAN)
|
|
580
|
+
};
|
|
581
|
+
function isDef(value) {
|
|
582
|
+
return value !== void 0 && value !== null;
|
|
571
583
|
}
|
|
572
584
|
//#endregion
|
|
573
585
|
//#region src/object.ts
|
|
574
|
-
function
|
|
586
|
+
function isMergeableObject(value) {
|
|
575
587
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
576
588
|
}
|
|
577
589
|
/**
|
|
@@ -585,332 +597,256 @@ function isMergableObject(value) {
|
|
|
585
597
|
*/
|
|
586
598
|
function deepMerge(target, ...sources) {
|
|
587
599
|
const result = { ...target };
|
|
588
|
-
for (const source of sources) for (const [key, value] of Object.entries(source)) result[key] =
|
|
600
|
+
for (const source of sources) for (const [key, value] of Object.entries(source)) result[key] = isMergeableObject(value) && isMergeableObject(result[key]) ? {
|
|
589
601
|
...result[key],
|
|
590
602
|
...value
|
|
591
603
|
} : value;
|
|
592
604
|
return result;
|
|
593
605
|
}
|
|
594
|
-
function isObjectDeepEqual(first, second) {
|
|
595
|
-
if (first === second) return true;
|
|
596
|
-
for (const key of Object.keys(first)) if (first[key] !== second[key]) return false;
|
|
597
|
-
return true;
|
|
598
|
-
}
|
|
599
606
|
//#endregion
|
|
600
|
-
//#region src/
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
607
|
+
//#region src/spacing.ts
|
|
608
|
+
const BLOCK_CONTAINER_TYPES = [
|
|
609
|
+
MAILY_NODE_TYPES.DOCUMENT,
|
|
610
|
+
MAILY_NODE_TYPES.BODY,
|
|
611
|
+
MAILY_NODE_TYPES.CONTAINER,
|
|
612
|
+
MAILY_NODE_TYPES.SECTION,
|
|
613
|
+
MAILY_NODE_TYPES.DIV,
|
|
614
|
+
MAILY_NODE_TYPES.COLUMN,
|
|
615
|
+
MAILY_NODE_TYPES.REPEAT,
|
|
616
|
+
MAILY_NODE_TYPES.BULLET_LIST,
|
|
617
|
+
MAILY_NODE_TYPES.ORDERED_LIST
|
|
618
|
+
];
|
|
619
|
+
const MARGIN_TOP_ABSORBER_TYPES = [MAILY_NODE_TYPES.SPACER];
|
|
620
|
+
const MARGIN_BOTTOM_ABSORBER_TYPES = [MAILY_NODE_TYPES.SPACER, MAILY_NODE_TYPES.HORIZONTAL_RULE];
|
|
621
|
+
function getSuppressedMargins(position) {
|
|
622
|
+
const { isFirst, isLast, nextType, parentType, previousType } = position;
|
|
623
|
+
const stacks = parentType !== void 0 && BLOCK_CONTAINER_TYPES.includes(parentType);
|
|
609
624
|
return {
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
paddingBottom: `${paddingBottom}px`,
|
|
613
|
-
paddingLeft: `${paddingLeft}px`
|
|
625
|
+
marginBottom: !stacks || isLast || MARGIN_BOTTOM_ABSORBER_TYPES.includes(nextType ?? ""),
|
|
626
|
+
marginTop: !stacks || isFirst || MARGIN_TOP_ABSORBER_TYPES.includes(previousType ?? "")
|
|
614
627
|
};
|
|
615
628
|
}
|
|
616
629
|
//#endregion
|
|
617
|
-
//#region src/
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
630
|
+
//#region src/style.ts
|
|
631
|
+
function parseInlineStyles(style) {
|
|
632
|
+
return (0, stylecast.objectify)(style, { reactify: true });
|
|
633
|
+
}
|
|
634
|
+
function stringifyInlineStyles(style) {
|
|
635
|
+
return (0, stylecast.stringify)(style, { kebabCase: true });
|
|
636
|
+
}
|
|
637
|
+
function expandInlineStyles(style) {
|
|
638
|
+
return (0, stylecast.expand)(style, { camelCase: true });
|
|
639
|
+
}
|
|
640
|
+
function collapseInlineStyles(style) {
|
|
641
|
+
return (0, stylecast.collapse)(style, { camelCase: true });
|
|
642
|
+
}
|
|
643
|
+
function mergeInlineStyles(under, over) {
|
|
644
|
+
return collapseInlineStyles({
|
|
645
|
+
...expandInlineStyles(under),
|
|
646
|
+
...expandInlineStyles(over)
|
|
647
|
+
});
|
|
621
648
|
}
|
|
622
649
|
//#endregion
|
|
623
|
-
//#region src/
|
|
624
|
-
/** Text direction values matching the HTML `dir` attribute: ltr, rtl, auto. */
|
|
650
|
+
//#region src/direction.ts
|
|
625
651
|
const TEXT_DIRECTIONS = {
|
|
626
652
|
LTR: "ltr",
|
|
627
653
|
RTL: "rtl",
|
|
628
654
|
AUTO: "auto"
|
|
629
655
|
};
|
|
630
|
-
const allowedTextDirections = Object.freeze(Object.values(TEXT_DIRECTIONS));
|
|
631
656
|
const DEFAULT_TEXT_DIRECTION = TEXT_DIRECTIONS.AUTO;
|
|
632
|
-
function isAllowedTextDirection(value) {
|
|
633
|
-
return typeof value === "string" && allowedTextDirections.includes(value);
|
|
634
|
-
}
|
|
635
|
-
/**
|
|
636
|
-
* Returns a CSS `direction` property object for the given dir value.
|
|
637
|
-
* Returns an empty object for "auto" or nullish values, since the
|
|
638
|
-
* browser default is sufficient in those cases.
|
|
639
|
-
*/
|
|
640
657
|
function getCssDirection(dir) {
|
|
641
658
|
if (dir && dir !== TEXT_DIRECTIONS.AUTO) return { direction: dir };
|
|
642
659
|
return {};
|
|
643
660
|
}
|
|
644
661
|
//#endregion
|
|
645
|
-
//#region src/theme.ts
|
|
646
|
-
const DEFAULT_LINK_TEXT_COLOR = "#111827";
|
|
647
|
-
const DEFAULT_RENDERER_THEME = {
|
|
648
|
-
paragraph: {
|
|
649
|
-
color: "#374151",
|
|
650
|
-
fontSize: 15,
|
|
651
|
-
lineHeight: 1.75,
|
|
652
|
-
fontWeight: FONT_WEIGHTS.NORMAL
|
|
653
|
-
},
|
|
654
|
-
heading: {
|
|
655
|
-
defaults: { color: "#111827" },
|
|
656
|
-
h1: {
|
|
657
|
-
fontSize: 36,
|
|
658
|
-
lineHeight: 1.1111111,
|
|
659
|
-
fontWeight: FONT_WEIGHTS.SEMIBOLD
|
|
660
|
-
},
|
|
661
|
-
h2: {
|
|
662
|
-
fontSize: 30,
|
|
663
|
-
lineHeight: 1.3333333,
|
|
664
|
-
fontWeight: FONT_WEIGHTS.SEMIBOLD
|
|
665
|
-
},
|
|
666
|
-
h3: {
|
|
667
|
-
fontSize: 24,
|
|
668
|
-
lineHeight: 1.6,
|
|
669
|
-
fontWeight: FONT_WEIGHTS.SEMIBOLD
|
|
670
|
-
}
|
|
671
|
-
},
|
|
672
|
-
footer: {
|
|
673
|
-
color: "#64748B",
|
|
674
|
-
fontSize: 14,
|
|
675
|
-
lineHeight: 1.7142857,
|
|
676
|
-
fontWeight: FONT_WEIGHTS.NORMAL
|
|
677
|
-
},
|
|
678
|
-
blockquote: {
|
|
679
|
-
color: "#374151",
|
|
680
|
-
borderColor: "#D1D5DB",
|
|
681
|
-
fontSize: 15,
|
|
682
|
-
lineHeight: 1.75,
|
|
683
|
-
fontWeight: FONT_WEIGHTS.MEDIUM,
|
|
684
|
-
fontStyle: FONT_STYLES.ITALIC
|
|
685
|
-
},
|
|
686
|
-
horizontalRule: { color: "#EAEAEA" },
|
|
687
|
-
code: {
|
|
688
|
-
color: "#111827",
|
|
689
|
-
backgroundColor: "#EFEFEF"
|
|
690
|
-
},
|
|
691
|
-
linkCard: {
|
|
692
|
-
titleColor: "#111827",
|
|
693
|
-
descriptionColor: "#374151",
|
|
694
|
-
badgeTextColor: "#374151",
|
|
695
|
-
badgeBackgroundColor: "#fff085",
|
|
696
|
-
subTitleColor: "#6B7280",
|
|
697
|
-
borderColor: "#E5E7EB"
|
|
698
|
-
},
|
|
699
|
-
container: {
|
|
700
|
-
backgroundColor: "#ffffff",
|
|
701
|
-
maxWidth: 600,
|
|
702
|
-
minWidth: 300,
|
|
703
|
-
paddingTop: 8,
|
|
704
|
-
paddingRight: 8,
|
|
705
|
-
paddingBottom: 8,
|
|
706
|
-
paddingLeft: 8,
|
|
707
|
-
borderRadius: 0,
|
|
708
|
-
borderWidth: 0,
|
|
709
|
-
borderColor: "transparent"
|
|
710
|
-
},
|
|
711
|
-
body: {
|
|
712
|
-
backgroundColor: "#ffffff",
|
|
713
|
-
paddingTop: 0,
|
|
714
|
-
paddingRight: 0,
|
|
715
|
-
paddingBottom: 0,
|
|
716
|
-
paddingLeft: 0
|
|
717
|
-
},
|
|
718
|
-
button: {
|
|
719
|
-
backgroundColor: "#000000",
|
|
720
|
-
color: "#ffffff",
|
|
721
|
-
paddingTop: 10,
|
|
722
|
-
paddingRight: 32,
|
|
723
|
-
paddingBottom: 10,
|
|
724
|
-
paddingLeft: 32,
|
|
725
|
-
fontSize: 14,
|
|
726
|
-
lineHeight: 1.4285714,
|
|
727
|
-
fontWeight: FONT_WEIGHTS.SEMIBOLD
|
|
728
|
-
},
|
|
729
|
-
link: { color: DEFAULT_LINK_TEXT_COLOR },
|
|
730
|
-
listMarker: { color: "#d1d5dc" },
|
|
731
|
-
font: DEFAULT_FONT
|
|
732
|
-
};
|
|
733
|
-
const DEFAULT_EDITOR_THEME = {
|
|
734
|
-
container: {
|
|
735
|
-
backgroundColor: "#ffffff",
|
|
736
|
-
maxWidth: 600,
|
|
737
|
-
minWidth: 300,
|
|
738
|
-
paddingTop: 8,
|
|
739
|
-
paddingRight: 8,
|
|
740
|
-
paddingBottom: 8,
|
|
741
|
-
paddingLeft: 8,
|
|
742
|
-
borderRadius: 0,
|
|
743
|
-
borderWidth: 0,
|
|
744
|
-
borderColor: "transparent"
|
|
745
|
-
},
|
|
746
|
-
body: {
|
|
747
|
-
backgroundColor: "#ffffff",
|
|
748
|
-
paddingTop: 0,
|
|
749
|
-
paddingRight: 0,
|
|
750
|
-
paddingBottom: 0,
|
|
751
|
-
paddingLeft: 0
|
|
752
|
-
},
|
|
753
|
-
button: {
|
|
754
|
-
backgroundColor: "#000000",
|
|
755
|
-
color: "#ffffff",
|
|
756
|
-
paddingTop: 10,
|
|
757
|
-
paddingRight: 32,
|
|
758
|
-
paddingBottom: 10,
|
|
759
|
-
paddingLeft: 32
|
|
760
|
-
},
|
|
761
|
-
link: { color: DEFAULT_LINK_TEXT_COLOR },
|
|
762
|
-
font: DEFAULT_FONT
|
|
763
|
-
};
|
|
764
|
-
/**
|
|
765
|
-
* Resolves the baseline font defaults for a node type from the
|
|
766
|
-
* renderer theme. Falls back to paragraph defaults for unknown types.
|
|
767
|
-
*/
|
|
768
|
-
function getNodeFontStyleDefaults(nodeType, level) {
|
|
769
|
-
const paragraph = DEFAULT_RENDERER_THEME.paragraph;
|
|
770
|
-
const fallback = {
|
|
771
|
-
fontSize: paragraph.fontSize,
|
|
772
|
-
lineHeight: paragraph.lineHeight,
|
|
773
|
-
fontWeight: paragraph.fontWeight
|
|
774
|
-
};
|
|
775
|
-
if (nodeType === MAILY_NODE_TYPES.HEADING) {
|
|
776
|
-
const heading = DEFAULT_RENDERER_THEME.heading;
|
|
777
|
-
const key = `h${level ?? 1}`;
|
|
778
|
-
const entry = heading?.[key];
|
|
779
|
-
return {
|
|
780
|
-
fontSize: entry?.fontSize ?? fallback.fontSize,
|
|
781
|
-
lineHeight: entry?.lineHeight ?? fallback.lineHeight,
|
|
782
|
-
fontWeight: entry?.fontWeight ?? fallback.fontWeight
|
|
783
|
-
};
|
|
784
|
-
}
|
|
785
|
-
if (nodeType === MAILY_NODE_TYPES.BUTTON) {
|
|
786
|
-
const btn = DEFAULT_RENDERER_THEME.button;
|
|
787
|
-
return {
|
|
788
|
-
fontSize: btn?.fontSize ?? fallback.fontSize,
|
|
789
|
-
lineHeight: btn?.lineHeight ?? fallback.lineHeight,
|
|
790
|
-
fontWeight: btn?.fontWeight ?? fallback.fontWeight
|
|
791
|
-
};
|
|
792
|
-
}
|
|
793
|
-
if (nodeType === MAILY_NODE_TYPES.BLOCKQUOTE) {
|
|
794
|
-
const bq = DEFAULT_RENDERER_THEME.blockquote;
|
|
795
|
-
return {
|
|
796
|
-
fontSize: bq?.fontSize ?? fallback.fontSize,
|
|
797
|
-
lineHeight: bq?.lineHeight ?? fallback.lineHeight,
|
|
798
|
-
fontWeight: bq?.fontWeight ?? fallback.fontWeight,
|
|
799
|
-
fontStyle: bq?.fontStyle ?? void 0
|
|
800
|
-
};
|
|
801
|
-
}
|
|
802
|
-
if (nodeType === MAILY_NODE_TYPES.FOOTER) {
|
|
803
|
-
const ft = DEFAULT_RENDERER_THEME.footer;
|
|
804
|
-
return {
|
|
805
|
-
fontSize: ft?.fontSize ?? fallback.fontSize,
|
|
806
|
-
lineHeight: ft?.lineHeight ?? fallback.lineHeight,
|
|
807
|
-
fontWeight: ft?.fontWeight ?? fallback.fontWeight
|
|
808
|
-
};
|
|
809
|
-
}
|
|
810
|
-
return fallback;
|
|
811
|
-
}
|
|
812
|
-
//#endregion
|
|
813
662
|
//#region src/variable.ts
|
|
814
|
-
/** Default opening delimiter for variable placeholders in text. */
|
|
815
663
|
const DEFAULT_VARIABLE_START_TRIGGER = "{{";
|
|
816
|
-
/** Default closing delimiter for variable placeholders in text. */
|
|
817
664
|
const DEFAULT_VARIABLE_END_TRIGGER = "}}";
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
/**
|
|
829
|
-
* Serializes a variable node's attributes into a delimited string.
|
|
830
|
-
* Output format: `{{id|label|required|hideDefaultValue}}`.
|
|
831
|
-
* Used to represent structured variable data as a template string
|
|
832
|
-
* in plain text contexts.
|
|
833
|
-
*/
|
|
665
|
+
const LEGACY_HIDE_DEFAULT_VALUE = "hideDefaultValue";
|
|
666
|
+
function getQuotedValue(value) {
|
|
667
|
+
return `"${value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
|
|
668
|
+
}
|
|
669
|
+
function getSerializedAttribute(options) {
|
|
670
|
+
const { name, value } = options;
|
|
671
|
+
if (value === void 0 || value === DEFAULT_VARIABLE_ATTRIBUTES[name]) return null;
|
|
672
|
+
if (typeof value === "boolean") return `${name}=${value}`;
|
|
673
|
+
return typeof value === "string" ? `${name}=${getQuotedValue(value)}` : null;
|
|
674
|
+
}
|
|
834
675
|
function serializeVariableToText(variable) {
|
|
835
|
-
const { id, label, required
|
|
676
|
+
const { fallback, id, isDefaultEditable, label, required, style } = variable;
|
|
836
677
|
return [
|
|
837
678
|
"{{",
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
679
|
+
[id, ...[
|
|
680
|
+
getSerializedAttribute({
|
|
681
|
+
name: "fallback",
|
|
682
|
+
value: fallback
|
|
683
|
+
}),
|
|
684
|
+
getSerializedAttribute({
|
|
685
|
+
name: "isDefaultEditable",
|
|
686
|
+
value: isDefaultEditable
|
|
687
|
+
}),
|
|
688
|
+
getSerializedAttribute({
|
|
689
|
+
name: "label",
|
|
690
|
+
value: label === id ? null : label
|
|
691
|
+
}),
|
|
692
|
+
getSerializedAttribute({
|
|
693
|
+
name: "required",
|
|
694
|
+
value: required
|
|
695
|
+
}),
|
|
696
|
+
getSerializedAttribute({
|
|
697
|
+
name: "style",
|
|
698
|
+
value: style
|
|
699
|
+
})
|
|
700
|
+
].filter((attribute) => {
|
|
701
|
+
return attribute !== null;
|
|
702
|
+
})].join(" "),
|
|
845
703
|
"}}"
|
|
846
704
|
].join("");
|
|
847
705
|
}
|
|
848
|
-
function
|
|
849
|
-
|
|
706
|
+
function getReferenceTokens(inner) {
|
|
707
|
+
const tokens = [];
|
|
708
|
+
let token = "";
|
|
709
|
+
let quoted = false;
|
|
710
|
+
for (let index = 0; index < inner.length; index += 1) {
|
|
711
|
+
const character = inner[index];
|
|
712
|
+
if (quoted && character === "\\" && index + 1 < inner.length) {
|
|
713
|
+
token += character + inner[index + 1];
|
|
714
|
+
index += 1;
|
|
715
|
+
continue;
|
|
716
|
+
}
|
|
717
|
+
if (character === "\"") {
|
|
718
|
+
quoted = !quoted;
|
|
719
|
+
token += character;
|
|
720
|
+
continue;
|
|
721
|
+
}
|
|
722
|
+
if (!quoted && /\s/.test(character)) {
|
|
723
|
+
if (token) {
|
|
724
|
+
tokens.push(token);
|
|
725
|
+
token = "";
|
|
726
|
+
}
|
|
727
|
+
continue;
|
|
728
|
+
}
|
|
729
|
+
token += character;
|
|
730
|
+
}
|
|
731
|
+
if (token) tokens.push(token);
|
|
732
|
+
return tokens;
|
|
733
|
+
}
|
|
734
|
+
function getUnquotedValue(value) {
|
|
735
|
+
if (value.startsWith("\"") && value.endsWith("\"") && value.length > 1) return value.slice(1, -1).replace(/\\"/g, "\"").replace(/\\\\/g, "\\");
|
|
736
|
+
if (value === "true") return true;
|
|
737
|
+
if (value === "false") return false;
|
|
738
|
+
return value;
|
|
850
739
|
}
|
|
851
|
-
/**
|
|
852
|
-
* Deserializes a variable string back into VariableAttributes.
|
|
853
|
-
* Expected input format: `{{id|label|required|hideDefaultValue}}`.
|
|
854
|
-
* Missing fields default to undefined; boolean fields are parsed
|
|
855
|
-
* from "true"/"false" strings.
|
|
856
|
-
*/
|
|
857
740
|
function deserializeVariableFromText(text) {
|
|
858
|
-
const [id
|
|
741
|
+
const [id = "", ...pairs] = getReferenceTokens(text.slice(2, text.length - 2).trim());
|
|
742
|
+
const attributes = { id };
|
|
743
|
+
for (const pair of pairs) {
|
|
744
|
+
const separator = pair.indexOf("=");
|
|
745
|
+
if (separator <= 0) continue;
|
|
746
|
+
const key = pair.slice(0, separator);
|
|
747
|
+
const value = getUnquotedValue(pair.slice(separator + 1));
|
|
748
|
+
if (key === LEGACY_HIDE_DEFAULT_VALUE) {
|
|
749
|
+
attributes.isDefaultEditable ??= value !== true;
|
|
750
|
+
continue;
|
|
751
|
+
}
|
|
752
|
+
attributes[key] = value;
|
|
753
|
+
}
|
|
859
754
|
return {
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
required: parseBoolean(required, true),
|
|
863
|
-
hideDefaultValue: parseBoolean(hideDefaultValue, false)
|
|
755
|
+
...DEFAULT_VARIABLE_ATTRIBUTES,
|
|
756
|
+
...attributes
|
|
864
757
|
};
|
|
865
758
|
}
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
759
|
+
function getVariableSegments(content) {
|
|
760
|
+
const segments = [];
|
|
761
|
+
let plain = "";
|
|
762
|
+
let index = 0;
|
|
763
|
+
while (index < content.length) {
|
|
764
|
+
if (!content.startsWith("{{", index)) {
|
|
765
|
+
plain += content[index];
|
|
766
|
+
index += 1;
|
|
767
|
+
continue;
|
|
768
|
+
}
|
|
769
|
+
const end = getReferenceEnd({
|
|
770
|
+
content,
|
|
771
|
+
start: index
|
|
772
|
+
});
|
|
773
|
+
if (end === -1) {
|
|
774
|
+
plain += content[index];
|
|
775
|
+
index += 1;
|
|
776
|
+
continue;
|
|
777
|
+
}
|
|
778
|
+
if (plain) {
|
|
779
|
+
segments.push({
|
|
780
|
+
isReference: false,
|
|
781
|
+
text: plain
|
|
782
|
+
});
|
|
783
|
+
plain = "";
|
|
784
|
+
}
|
|
785
|
+
segments.push({
|
|
786
|
+
isReference: true,
|
|
787
|
+
text: content.slice(index, end)
|
|
788
|
+
});
|
|
789
|
+
index = end;
|
|
790
|
+
}
|
|
791
|
+
if (plain) segments.push({
|
|
792
|
+
isReference: false,
|
|
793
|
+
text: plain
|
|
794
|
+
});
|
|
795
|
+
return segments;
|
|
796
|
+
}
|
|
797
|
+
function getReferenceEnd(options) {
|
|
798
|
+
const { content, start } = options;
|
|
799
|
+
let quoted = false;
|
|
800
|
+
for (let index = start + 2; index < content.length; index += 1) {
|
|
801
|
+
const character = content[index];
|
|
802
|
+
if (quoted && character === "\\") {
|
|
803
|
+
index += 1;
|
|
804
|
+
continue;
|
|
805
|
+
}
|
|
806
|
+
if (character === "\"") {
|
|
807
|
+
quoted = !quoted;
|
|
808
|
+
continue;
|
|
809
|
+
}
|
|
810
|
+
if (!quoted && content.startsWith("}}", index)) return index + 2;
|
|
811
|
+
}
|
|
812
|
+
return -1;
|
|
813
|
+
}
|
|
872
814
|
function buildDocFromVariableText(content) {
|
|
873
|
-
const parts = content.split(VARIABLE_PLACEHOLDER_REGEX);
|
|
874
815
|
return {
|
|
875
816
|
type: MAILY_NODE_TYPES.DOCUMENT,
|
|
876
817
|
content: [{
|
|
877
818
|
type: MAILY_NODE_TYPES.PARAGRAPH,
|
|
878
|
-
content:
|
|
879
|
-
|
|
819
|
+
content: getVariableSegments(content).map((segment) => {
|
|
820
|
+
return segment.isReference ? {
|
|
880
821
|
type: MAILY_NODE_TYPES.VARIABLE,
|
|
881
|
-
attrs: deserializeVariableFromText(
|
|
882
|
-
}
|
|
883
|
-
if (part) return {
|
|
822
|
+
attrs: deserializeVariableFromText(segment.text)
|
|
823
|
+
} : {
|
|
884
824
|
type: MAILY_NODE_TYPES.TEXT,
|
|
885
|
-
text:
|
|
825
|
+
text: segment.text
|
|
886
826
|
};
|
|
887
|
-
|
|
888
|
-
}).filter(Boolean)
|
|
827
|
+
})
|
|
889
828
|
}]
|
|
890
829
|
};
|
|
891
830
|
}
|
|
892
|
-
/**
|
|
893
|
-
* Checks if a string contains at least one variable placeholder.
|
|
894
|
-
* Returns true for strings like "Hello {{name}}", false for plain text.
|
|
895
|
-
* Uses index-based scanning instead of regex for performance.
|
|
896
|
-
*/
|
|
897
831
|
function hasVariableInText(text) {
|
|
898
832
|
const start = text.indexOf("{{");
|
|
899
833
|
if (start === -1) return false;
|
|
900
834
|
return text.indexOf("}}", start + 2) !== -1;
|
|
901
835
|
}
|
|
902
|
-
function parseBoolean(value, defaultValue) {
|
|
903
|
-
if (value === "true") return true;
|
|
904
|
-
if (value === "false") return false;
|
|
905
|
-
return defaultValue;
|
|
906
|
-
}
|
|
907
836
|
//#endregion
|
|
908
837
|
//#region src/visibility.ts
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
838
|
+
const VISIBILITY_ACTIONS = {
|
|
839
|
+
SHOW: "show",
|
|
840
|
+
HIDE: "hide"
|
|
841
|
+
};
|
|
842
|
+
const allowedVisibilityActions = Object.values(VISIBILITY_ACTIONS);
|
|
843
|
+
const VISIBILITY_ACTION_OPTIONS = [{
|
|
844
|
+
label: "Show if",
|
|
845
|
+
value: VISIBILITY_ACTIONS.SHOW
|
|
846
|
+
}, {
|
|
847
|
+
label: "Hide if",
|
|
848
|
+
value: VISIBILITY_ACTIONS.HIDE
|
|
849
|
+
}];
|
|
914
850
|
const VISIBILITY_OPERATORS = {
|
|
915
851
|
IS_TRUE: "is_true",
|
|
916
852
|
IS_FALSE: "is_false",
|
|
@@ -923,96 +859,346 @@ const VISIBILITY_OPERATORS = {
|
|
|
923
859
|
GREATER_THAN: "greater_than",
|
|
924
860
|
LESS_THAN: "less_than"
|
|
925
861
|
};
|
|
862
|
+
const allowedVisibilityOperators = Object.values(VISIBILITY_OPERATORS);
|
|
926
863
|
const VISIBILITY_OPERATOR_OPTIONS = [
|
|
927
864
|
{
|
|
928
|
-
|
|
929
|
-
|
|
865
|
+
label: "Is true",
|
|
866
|
+
value: VISIBILITY_OPERATORS.IS_TRUE
|
|
930
867
|
},
|
|
931
868
|
{
|
|
932
|
-
|
|
933
|
-
|
|
869
|
+
label: "Is false",
|
|
870
|
+
value: VISIBILITY_OPERATORS.IS_FALSE
|
|
934
871
|
},
|
|
935
872
|
{
|
|
936
|
-
|
|
937
|
-
|
|
873
|
+
label: "Equals",
|
|
874
|
+
value: VISIBILITY_OPERATORS.EQUALS
|
|
938
875
|
},
|
|
939
876
|
{
|
|
940
|
-
|
|
941
|
-
|
|
877
|
+
label: "Not equals",
|
|
878
|
+
value: VISIBILITY_OPERATORS.NOT_EQUALS
|
|
942
879
|
},
|
|
943
880
|
{
|
|
944
|
-
|
|
945
|
-
|
|
881
|
+
label: "Contains",
|
|
882
|
+
value: VISIBILITY_OPERATORS.CONTAINS
|
|
946
883
|
},
|
|
947
884
|
{
|
|
948
|
-
|
|
949
|
-
|
|
885
|
+
label: "Not contains",
|
|
886
|
+
value: VISIBILITY_OPERATORS.NOT_CONTAINS
|
|
950
887
|
},
|
|
951
888
|
{
|
|
952
|
-
|
|
953
|
-
|
|
889
|
+
label: "Starts with",
|
|
890
|
+
value: VISIBILITY_OPERATORS.STARTS_WITH
|
|
954
891
|
},
|
|
955
892
|
{
|
|
956
|
-
|
|
957
|
-
|
|
893
|
+
label: "Ends with",
|
|
894
|
+
value: VISIBILITY_OPERATORS.ENDS_WITH
|
|
958
895
|
},
|
|
959
896
|
{
|
|
960
|
-
|
|
961
|
-
|
|
897
|
+
label: "Greater than",
|
|
898
|
+
value: VISIBILITY_OPERATORS.GREATER_THAN
|
|
962
899
|
},
|
|
963
900
|
{
|
|
964
|
-
|
|
965
|
-
|
|
901
|
+
label: "Less than",
|
|
902
|
+
value: VISIBILITY_OPERATORS.LESS_THAN
|
|
966
903
|
}
|
|
967
904
|
];
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
NONE: "none",
|
|
975
|
-
SHOW: "show",
|
|
976
|
-
HIDE: "hide"
|
|
905
|
+
const VISIBILITY_OPERATORS_WITHOUT_VALUE = [VISIBILITY_OPERATORS.IS_TRUE, VISIBILITY_OPERATORS.IS_FALSE];
|
|
906
|
+
const DEFAULT_VISIBILITY_RULE = {
|
|
907
|
+
action: VISIBILITY_ACTIONS.SHOW,
|
|
908
|
+
operator: VISIBILITY_OPERATORS.EQUALS,
|
|
909
|
+
value: "",
|
|
910
|
+
variable: ""
|
|
977
911
|
};
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
912
|
+
function getVisibilityValueSupport(operator) {
|
|
913
|
+
return !VISIBILITY_OPERATORS_WITHOUT_VALUE.includes(operator);
|
|
914
|
+
}
|
|
915
|
+
function getVisibilityRule(options) {
|
|
916
|
+
const { action, operator, value, variable } = options;
|
|
917
|
+
const isAllowedAction = allowedVisibilityActions.some((candidate) => {
|
|
918
|
+
return candidate === action;
|
|
919
|
+
});
|
|
920
|
+
const isAllowedOperator = allowedVisibilityOperators.some((candidate) => {
|
|
921
|
+
return candidate === operator;
|
|
922
|
+
});
|
|
923
|
+
if (!(isAllowedAction && isAllowedOperator)) return null;
|
|
924
|
+
return {
|
|
925
|
+
action,
|
|
926
|
+
operator,
|
|
927
|
+
value: getVisibilityValueSupport(operator) ? value ?? "" : "",
|
|
928
|
+
variable: variable ?? ""
|
|
929
|
+
};
|
|
930
|
+
}
|
|
931
|
+
//#endregion
|
|
932
|
+
//#region src/theme.ts
|
|
933
|
+
const DEFAULT_CONTAINER_MAX_WIDTH = 600;
|
|
934
|
+
const BASIC_NODE_THEME = {
|
|
935
|
+
blockquote: {
|
|
936
|
+
borderColor: "#d1d5db",
|
|
937
|
+
borderLeftStyle: "solid",
|
|
938
|
+
borderLeftWidth: "4px",
|
|
939
|
+
color: "#374151",
|
|
940
|
+
fontSize: "15px",
|
|
941
|
+
fontStyle: "italic",
|
|
942
|
+
fontWeight: "500",
|
|
943
|
+
lineHeight: "26px",
|
|
944
|
+
marginBottom: "20px",
|
|
945
|
+
marginLeft: "0",
|
|
946
|
+
marginRight: "0",
|
|
947
|
+
marginTop: "20px",
|
|
948
|
+
paddingLeft: "16px"
|
|
982
949
|
},
|
|
983
|
-
{
|
|
984
|
-
|
|
985
|
-
|
|
950
|
+
body: { fontFamily: getFontFamilyValue({
|
|
951
|
+
fallbackFontFamily: DEFAULT_FONT.fallbackFontFamily,
|
|
952
|
+
fontFamily: DEFAULT_FONT.fontFamily
|
|
953
|
+
}) },
|
|
954
|
+
bulletList: {
|
|
955
|
+
fontSize: "14px",
|
|
956
|
+
lineHeight: "24px",
|
|
957
|
+
listStyleType: "disc",
|
|
958
|
+
margin: "0",
|
|
959
|
+
paddingLeft: "26px"
|
|
986
960
|
},
|
|
987
|
-
{
|
|
988
|
-
|
|
989
|
-
|
|
961
|
+
button: {
|
|
962
|
+
backgroundColor: "#000000",
|
|
963
|
+
borderRadius: "9999px",
|
|
964
|
+
color: "#ffffff",
|
|
965
|
+
fontSize: "14px",
|
|
966
|
+
fontWeight: "500",
|
|
967
|
+
lineHeight: "20px",
|
|
968
|
+
padding: "10px 32px"
|
|
969
|
+
},
|
|
970
|
+
code: {
|
|
971
|
+
borderRadius: "8px",
|
|
972
|
+
fontFamily: "ui-monospace, monospace",
|
|
973
|
+
fontSize: "85%",
|
|
974
|
+
padding: "2px 6px"
|
|
975
|
+
},
|
|
976
|
+
h1: {
|
|
977
|
+
fontSize: "36px",
|
|
978
|
+
fontWeight: "800",
|
|
979
|
+
lineHeight: "40px"
|
|
980
|
+
},
|
|
981
|
+
h2: {
|
|
982
|
+
fontSize: "30px",
|
|
983
|
+
fontWeight: "700",
|
|
984
|
+
lineHeight: "40px"
|
|
985
|
+
},
|
|
986
|
+
h3: {
|
|
987
|
+
fontSize: "24px",
|
|
988
|
+
fontWeight: "600",
|
|
989
|
+
lineHeight: "38px"
|
|
990
|
+
},
|
|
991
|
+
heading: {
|
|
992
|
+
color: "#101828",
|
|
993
|
+
marginBottom: "12px",
|
|
994
|
+
marginTop: "0"
|
|
995
|
+
},
|
|
996
|
+
horizontalRule: {
|
|
997
|
+
border: "none",
|
|
998
|
+
borderTop: "1px solid #eaeaea",
|
|
999
|
+
marginBottom: "32px",
|
|
1000
|
+
marginTop: "32px"
|
|
1001
|
+
},
|
|
1002
|
+
htmlCodeBlock: { marginBottom: "32px" },
|
|
1003
|
+
link: {
|
|
1004
|
+
color: "#0000ee",
|
|
1005
|
+
textDecoration: "underline"
|
|
1006
|
+
},
|
|
1007
|
+
listItem: {
|
|
1008
|
+
marginBottom: "4px",
|
|
1009
|
+
paddingLeft: "6px"
|
|
1010
|
+
},
|
|
1011
|
+
orderedList: {
|
|
1012
|
+
fontSize: "14px",
|
|
1013
|
+
lineHeight: "24px",
|
|
1014
|
+
listStyleType: "decimal",
|
|
1015
|
+
margin: "0",
|
|
1016
|
+
paddingLeft: "26px"
|
|
1017
|
+
},
|
|
1018
|
+
footer: {
|
|
1019
|
+
color: "#64748B",
|
|
1020
|
+
display: "block",
|
|
1021
|
+
fontSize: "14px",
|
|
1022
|
+
fontWeight: "400",
|
|
1023
|
+
lineHeight: "24px",
|
|
1024
|
+
marginBottom: "0",
|
|
1025
|
+
marginTop: "0"
|
|
1026
|
+
},
|
|
1027
|
+
paragraph: {
|
|
1028
|
+
color: "#18181b",
|
|
1029
|
+
fontSize: "14px",
|
|
1030
|
+
lineHeight: "24px",
|
|
1031
|
+
marginBottom: "14px",
|
|
1032
|
+
marginTop: "0"
|
|
1033
|
+
},
|
|
1034
|
+
section: { padding: "8px" }
|
|
1035
|
+
};
|
|
1036
|
+
const MAILY_NODE_THEME = {
|
|
1037
|
+
blockquote: {
|
|
1038
|
+
borderLeftColor: "#d1d5db",
|
|
1039
|
+
borderLeftStyle: "solid",
|
|
1040
|
+
borderLeftWidth: "4px",
|
|
1041
|
+
color: "#374151",
|
|
1042
|
+
fontSize: "15px",
|
|
1043
|
+
fontStyle: "italic",
|
|
1044
|
+
fontWeight: "500",
|
|
1045
|
+
lineHeight: "1.75",
|
|
1046
|
+
marginBottom: "20px",
|
|
1047
|
+
marginLeft: "0",
|
|
1048
|
+
marginRight: "0",
|
|
1049
|
+
marginTop: "20px",
|
|
1050
|
+
paddingLeft: "16px"
|
|
1051
|
+
},
|
|
1052
|
+
body: {
|
|
1053
|
+
backgroundColor: "#ffffff",
|
|
1054
|
+
fontFamily: getFontFamilyValue({
|
|
1055
|
+
fallbackFontFamily: DEFAULT_FONT.fallbackFontFamily,
|
|
1056
|
+
fontFamily: DEFAULT_FONT.fontFamily
|
|
1057
|
+
}),
|
|
1058
|
+
padding: "0"
|
|
1059
|
+
},
|
|
1060
|
+
bulletList: {
|
|
1061
|
+
listStyleType: "disc",
|
|
1062
|
+
marginBottom: "20px",
|
|
1063
|
+
marginLeft: "0",
|
|
1064
|
+
marginRight: "0",
|
|
1065
|
+
marginTop: "0",
|
|
1066
|
+
paddingLeft: "26px"
|
|
1067
|
+
},
|
|
1068
|
+
button: {
|
|
1069
|
+
backgroundColor: "#000000",
|
|
1070
|
+
borderRadius: "9999px",
|
|
1071
|
+
color: "#ffffff",
|
|
1072
|
+
fontSize: "14px",
|
|
1073
|
+
fontWeight: "600",
|
|
1074
|
+
lineHeight: "1.4285714",
|
|
1075
|
+
marginBottom: "20px",
|
|
1076
|
+
padding: "10px 32px"
|
|
1077
|
+
},
|
|
1078
|
+
code: {
|
|
1079
|
+
backgroundColor: "#efefef",
|
|
1080
|
+
borderRadius: "8px",
|
|
1081
|
+
color: "#111827",
|
|
1082
|
+
fontFamily: "ui-monospace, monospace",
|
|
1083
|
+
fontSize: "85%",
|
|
1084
|
+
padding: "2px 6px"
|
|
1085
|
+
},
|
|
1086
|
+
container: {
|
|
1087
|
+
backgroundColor: "#ffffff",
|
|
1088
|
+
maxWidth: `600px`,
|
|
1089
|
+
minWidth: "300px",
|
|
1090
|
+
padding: "8px"
|
|
1091
|
+
},
|
|
1092
|
+
footer: {
|
|
1093
|
+
color: "#64748b",
|
|
1094
|
+
display: "block",
|
|
1095
|
+
fontSize: "14px",
|
|
1096
|
+
fontWeight: "400",
|
|
1097
|
+
lineHeight: "1.7142857",
|
|
1098
|
+
marginBottom: "20px",
|
|
1099
|
+
marginTop: "0"
|
|
1100
|
+
},
|
|
1101
|
+
h1: {
|
|
1102
|
+
fontSize: "36px",
|
|
1103
|
+
fontWeight: "600",
|
|
1104
|
+
lineHeight: "1.1111111"
|
|
1105
|
+
},
|
|
1106
|
+
h2: {
|
|
1107
|
+
fontSize: "30px",
|
|
1108
|
+
fontWeight: "600",
|
|
1109
|
+
lineHeight: "1.3333333"
|
|
1110
|
+
},
|
|
1111
|
+
h3: {
|
|
1112
|
+
fontSize: "24px",
|
|
1113
|
+
fontWeight: "600",
|
|
1114
|
+
lineHeight: "1.6"
|
|
1115
|
+
},
|
|
1116
|
+
heading: {
|
|
1117
|
+
color: "#111827",
|
|
1118
|
+
marginBottom: "12px",
|
|
1119
|
+
marginTop: "0"
|
|
1120
|
+
},
|
|
1121
|
+
horizontalRule: {
|
|
1122
|
+
border: "none",
|
|
1123
|
+
borderTop: "1px solid #eaeaea",
|
|
1124
|
+
marginBottom: "32px",
|
|
1125
|
+
marginTop: "32px"
|
|
1126
|
+
},
|
|
1127
|
+
htmlCodeBlock: { marginBottom: "32px" },
|
|
1128
|
+
link: {
|
|
1129
|
+
color: "#111827",
|
|
1130
|
+
textDecoration: "underline"
|
|
1131
|
+
},
|
|
1132
|
+
listItem: {
|
|
1133
|
+
color: "#d1d5dc",
|
|
1134
|
+
marginBottom: "8px",
|
|
1135
|
+
marginTop: "8px",
|
|
1136
|
+
paddingLeft: "6px"
|
|
1137
|
+
},
|
|
1138
|
+
orderedList: {
|
|
1139
|
+
listStyleType: "decimal",
|
|
1140
|
+
marginBottom: "20px",
|
|
1141
|
+
marginLeft: "0",
|
|
1142
|
+
marginRight: "0",
|
|
1143
|
+
marginTop: "0",
|
|
1144
|
+
paddingLeft: "26px"
|
|
1145
|
+
},
|
|
1146
|
+
paragraph: {
|
|
1147
|
+
color: "#374151",
|
|
1148
|
+
fontSize: "15px",
|
|
1149
|
+
fontWeight: "400",
|
|
1150
|
+
lineHeight: "1.75",
|
|
1151
|
+
marginBottom: "20px",
|
|
1152
|
+
marginTop: "0",
|
|
1153
|
+
MozOsxFontSmoothing: "grayscale",
|
|
1154
|
+
WebkitFontSmoothing: "antialiased"
|
|
1155
|
+
},
|
|
1156
|
+
section: {
|
|
1157
|
+
backgroundColor: "#f7f7f7",
|
|
1158
|
+
border: "2px solid #e2e2e2",
|
|
1159
|
+
borderRadius: "0",
|
|
1160
|
+
marginBottom: "20px",
|
|
1161
|
+
padding: "0"
|
|
990
1162
|
}
|
|
991
|
-
|
|
1163
|
+
};
|
|
1164
|
+
function extendNodeTheme(options) {
|
|
1165
|
+
const { extension, preset } = options;
|
|
1166
|
+
return deepMerge(preset, extension);
|
|
1167
|
+
}
|
|
1168
|
+
function getThemeDeclarations(options) {
|
|
1169
|
+
const { attrs, theme, type } = options;
|
|
1170
|
+
const declarations = theme[type];
|
|
1171
|
+
if (type !== MAILY_NODE_TYPES.HEADING) return declarations;
|
|
1172
|
+
const level = typeof attrs?.level === "number" ? theme[`h${attrs.level}`] : void 0;
|
|
1173
|
+
if (!(declarations || level)) return;
|
|
1174
|
+
return {
|
|
1175
|
+
...declarations,
|
|
1176
|
+
...level
|
|
1177
|
+
};
|
|
1178
|
+
}
|
|
992
1179
|
//#endregion
|
|
1180
|
+
exports.BASIC_NODE_THEME = BASIC_NODE_THEME;
|
|
1181
|
+
exports.BLOCK_CONTAINER_TYPES = BLOCK_CONTAINER_TYPES;
|
|
993
1182
|
exports.BORDER_STYLES = BORDER_STYLES;
|
|
1183
|
+
exports.BOX_CORNERS = BOX_CORNERS;
|
|
1184
|
+
exports.BOX_SIDES = BOX_SIDES;
|
|
994
1185
|
exports.BUTTON_KINDS = BUTTON_KINDS;
|
|
995
1186
|
exports.DATA_NODE_TYPE_KEY = DATA_NODE_TYPE_KEY;
|
|
996
|
-
exports.DATA_VISIBILITY_RULE_KEY = DATA_VISIBILITY_RULE_KEY;
|
|
997
|
-
exports.DEFAULT_BORDER_COLOR = DEFAULT_BORDER_COLOR;
|
|
998
1187
|
exports.DEFAULT_BORDER_STYLE = DEFAULT_BORDER_STYLE;
|
|
999
1188
|
exports.DEFAULT_BUTTON_KIND = DEFAULT_BUTTON_KIND;
|
|
1000
|
-
exports.
|
|
1189
|
+
exports.DEFAULT_CONTAINER_MAX_WIDTH = DEFAULT_CONTAINER_MAX_WIDTH;
|
|
1190
|
+
exports.DEFAULT_CONTAINER_WIDTH_PIXELS = DEFAULT_CONTAINER_WIDTH_PIXELS;
|
|
1001
1191
|
exports.DEFAULT_FONT = DEFAULT_FONT;
|
|
1002
1192
|
exports.DEFAULT_FONT_FALLBACK = DEFAULT_FONT_FALLBACK;
|
|
1003
1193
|
exports.DEFAULT_FONT_FAMILIES = DEFAULT_FONT_FAMILIES;
|
|
1004
1194
|
exports.DEFAULT_FONT_FAMILY = DEFAULT_FONT_FAMILY;
|
|
1005
|
-
exports.DEFAULT_FONT_SIZE = DEFAULT_FONT_SIZE;
|
|
1006
|
-
exports.DEFAULT_FONT_WEIGHT = DEFAULT_FONT_WEIGHT;
|
|
1007
1195
|
exports.DEFAULT_HTML_CODE_BLOCK_TAB = DEFAULT_HTML_CODE_BLOCK_TAB;
|
|
1008
|
-
exports.DEFAULT_LINE_HEIGHT = DEFAULT_LINE_HEIGHT;
|
|
1009
|
-
exports.DEFAULT_LINK_TEXT_COLOR = DEFAULT_LINK_TEXT_COLOR;
|
|
1010
|
-
exports.DEFAULT_RENDERER_THEME = DEFAULT_RENDERER_THEME;
|
|
1011
1196
|
exports.DEFAULT_TEXT_ALIGN = DEFAULT_TEXT_ALIGN;
|
|
1012
1197
|
exports.DEFAULT_TEXT_DIRECTION = DEFAULT_TEXT_DIRECTION;
|
|
1198
|
+
exports.DEFAULT_VARIABLE_ATTRIBUTES = DEFAULT_VARIABLE_ATTRIBUTES;
|
|
1013
1199
|
exports.DEFAULT_VARIABLE_END_TRIGGER = DEFAULT_VARIABLE_END_TRIGGER;
|
|
1014
1200
|
exports.DEFAULT_VARIABLE_START_TRIGGER = DEFAULT_VARIABLE_START_TRIGGER;
|
|
1015
|
-
exports.
|
|
1201
|
+
exports.DEFAULT_VISIBILITY_RULE = DEFAULT_VISIBILITY_RULE;
|
|
1016
1202
|
exports.FONT_SIZE_PRESETS = FONT_SIZE_PRESETS;
|
|
1017
1203
|
exports.FONT_STYLES = FONT_STYLES;
|
|
1018
1204
|
exports.FONT_WEIGHTS = FONT_WEIGHTS;
|
|
@@ -1022,60 +1208,63 @@ exports.MAILY_BUG_REPORT_URL = MAILY_BUG_REPORT_URL;
|
|
|
1022
1208
|
exports.MAILY_ERROR_PREFIX = MAILY_ERROR_PREFIX;
|
|
1023
1209
|
exports.MAILY_EXTENSION_TYPES = MAILY_EXTENSION_TYPES;
|
|
1024
1210
|
exports.MAILY_MARK_TYPES = MAILY_MARK_TYPES;
|
|
1211
|
+
exports.MAILY_NODE_THEME = MAILY_NODE_THEME;
|
|
1025
1212
|
exports.MAILY_NODE_TYPES = MAILY_NODE_TYPES;
|
|
1213
|
+
exports.MARGIN_BOTTOM_ABSORBER_TYPES = MARGIN_BOTTOM_ABSORBER_TYPES;
|
|
1214
|
+
exports.MARGIN_TOP_ABSORBER_TYPES = MARGIN_TOP_ABSORBER_TYPES;
|
|
1026
1215
|
exports.MAX_IMAGE_WIDTH_PERCENTAGE = MAX_IMAGE_WIDTH_PERCENTAGE;
|
|
1027
1216
|
exports.MIN_IMAGE_WIDTH_PERCENTAGE = MIN_IMAGE_WIDTH_PERCENTAGE;
|
|
1028
|
-
exports.OPERATORS_WITHOUT_VALUE = OPERATORS_WITHOUT_VALUE;
|
|
1029
1217
|
exports.TEXT_ALIGNMENTS = TEXT_ALIGNMENTS;
|
|
1030
1218
|
exports.TEXT_DIRECTIONS = TEXT_DIRECTIONS;
|
|
1031
|
-
exports.VARIABLE_PLACEHOLDER_REGEX = VARIABLE_PLACEHOLDER_REGEX;
|
|
1032
|
-
exports.VARIABLE_TEXT_DELIMITER = VARIABLE_TEXT_DELIMITER;
|
|
1033
1219
|
exports.VISIBILITY_ACTIONS = VISIBILITY_ACTIONS;
|
|
1034
1220
|
exports.VISIBILITY_ACTION_OPTIONS = VISIBILITY_ACTION_OPTIONS;
|
|
1035
1221
|
exports.VISIBILITY_OPERATORS = VISIBILITY_OPERATORS;
|
|
1036
1222
|
exports.VISIBILITY_OPERATOR_OPTIONS = VISIBILITY_OPERATOR_OPTIONS;
|
|
1037
1223
|
exports.absoluteFromPercentage = absoluteFromPercentage;
|
|
1038
|
-
exports.allowedButtonKinds = allowedButtonKinds;
|
|
1039
1224
|
exports.allowedFallbackFonts = allowedFallbackFonts;
|
|
1040
|
-
exports.allowedFieldModes = allowedFieldModes;
|
|
1041
|
-
exports.allowedFontFormats = allowedFontFormats;
|
|
1042
1225
|
exports.allowedMarkTypes = allowedMarkTypes;
|
|
1043
1226
|
exports.allowedNodeTypes = allowedNodeTypes;
|
|
1044
|
-
exports.allowedTextAligns = allowedTextAligns;
|
|
1045
|
-
exports.allowedTextDirections = allowedTextDirections;
|
|
1046
1227
|
exports.buildDocFromVariableText = buildDocFromVariableText;
|
|
1047
1228
|
exports.clamp = clamp;
|
|
1048
1229
|
exports.clampImageWidthPercentage = clampImageWidthPercentage;
|
|
1049
1230
|
exports.deepMerge = deepMerge;
|
|
1050
1231
|
exports.deserializeVariableFromText = deserializeVariableFromText;
|
|
1051
|
-
exports.
|
|
1232
|
+
exports.expandInlineStyles = expandInlineStyles;
|
|
1233
|
+
exports.extendNodeTheme = extendNodeTheme;
|
|
1234
|
+
exports.getBorderParts = getBorderParts;
|
|
1235
|
+
exports.getBoxCorners = getBoxCorners;
|
|
1236
|
+
exports.getBoxSides = getBoxSides;
|
|
1237
|
+
exports.getColumnWidth = getColumnWidth;
|
|
1238
|
+
exports.getColumnWidthPercent = getColumnWidthPercent;
|
|
1239
|
+
exports.getColumnWidthValue = getColumnWidthValue;
|
|
1052
1240
|
exports.getCssDirection = getCssDirection;
|
|
1053
1241
|
exports.getFontFaceStyle = getFontFaceStyle;
|
|
1054
|
-
exports.
|
|
1055
|
-
exports.
|
|
1056
|
-
exports.
|
|
1057
|
-
exports.
|
|
1058
|
-
exports.
|
|
1059
|
-
exports.
|
|
1242
|
+
exports.getFontFamilyNames = getFontFamilyNames;
|
|
1243
|
+
exports.getFontFamilyValue = getFontFamilyValue;
|
|
1244
|
+
exports.getSuppressedMargins = getSuppressedMargins;
|
|
1245
|
+
exports.getThemeDeclarations = getThemeDeclarations;
|
|
1246
|
+
exports.getVariableSegments = getVariableSegments;
|
|
1247
|
+
exports.getVisibilityRule = getVisibilityRule;
|
|
1248
|
+
exports.getVisibilityValueSupport = getVisibilityValueSupport;
|
|
1060
1249
|
exports.hasVariableInText = hasVariableInText;
|
|
1061
1250
|
exports.invariant = invariant;
|
|
1062
1251
|
exports.is = is;
|
|
1252
|
+
exports.isAllowedBorderStyle = isAllowedBorderStyle;
|
|
1063
1253
|
exports.isAllowedButtonKind = isAllowedButtonKind;
|
|
1064
|
-
exports.isAllowedFieldMode = isAllowedFieldMode;
|
|
1065
1254
|
exports.isAllowedTextAlignment = isAllowedTextAlignment;
|
|
1066
|
-
exports.isAllowedTextDirection = isAllowedTextDirection;
|
|
1067
|
-
exports.isBoolean = isBoolean;
|
|
1068
1255
|
exports.isDef = isDef;
|
|
1069
|
-
exports.
|
|
1256
|
+
exports.isMergeableObject = isMergeableObject;
|
|
1070
1257
|
exports.isObject = isObject;
|
|
1071
|
-
exports.isObjectDeepEqual = isObjectDeepEqual;
|
|
1072
|
-
exports.isString = isString;
|
|
1073
1258
|
exports.loadFont = loadFont;
|
|
1259
|
+
exports.mergeInlineStyles = mergeInlineStyles;
|
|
1074
1260
|
exports.noop = noop;
|
|
1261
|
+
exports.parseInlineStyles = parseInlineStyles;
|
|
1075
1262
|
exports.parseWidthToPercentage = parseWidthToPercentage;
|
|
1076
1263
|
exports.percentage = percentage;
|
|
1077
1264
|
exports.roundTo = roundTo;
|
|
1078
1265
|
exports.serializeVariableToText = serializeVariableToText;
|
|
1079
|
-
exports.
|
|
1266
|
+
exports.stringifyInlineStyles = stringifyInlineStyles;
|
|
1267
|
+
exports.toBoxCorners = toBoxCorners;
|
|
1268
|
+
exports.toBoxSides = toBoxSides;
|
|
1080
1269
|
|
|
1081
1270
|
//# sourceMappingURL=index.cjs.map
|