@maily-to/shared 2.0.0-beta.2 → 2.0.0-beta.20
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.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Properties } from "csstype";
|
|
2
|
-
|
|
3
2
|
//#region src/alignment.d.ts
|
|
4
3
|
declare const TEXT_ALIGNMENTS: {
|
|
5
4
|
readonly LEFT: 'left';
|
|
@@ -7,26 +6,15 @@ declare const TEXT_ALIGNMENTS: {
|
|
|
7
6
|
readonly RIGHT: 'right';
|
|
8
7
|
};
|
|
9
8
|
type AllowedTextAlignment = (typeof TEXT_ALIGNMENTS)[keyof typeof TEXT_ALIGNMENTS];
|
|
10
|
-
declare const allowedTextAligns: readonly AllowedTextAlignment[];
|
|
11
9
|
declare const DEFAULT_TEXT_ALIGN: AllowedTextAlignment;
|
|
12
10
|
declare function isAllowedTextAlignment(value: unknown): value is AllowedTextAlignment;
|
|
13
11
|
//#endregion
|
|
14
|
-
//#region src/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*/
|
|
21
|
-
declare const FIELD_MODE: {
|
|
22
|
-
readonly NONE: 'none';
|
|
23
|
-
readonly MIXED: 'mixed';
|
|
24
|
-
readonly UNIFORM: 'uniform';
|
|
25
|
-
readonly PRESET: 'preset';
|
|
26
|
-
};
|
|
27
|
-
type AllowedFieldMode = (typeof FIELD_MODE)[keyof typeof FIELD_MODE];
|
|
28
|
-
declare const allowedFieldModes: readonly AllowedFieldMode[];
|
|
29
|
-
declare function isAllowedFieldMode(mode: unknown): mode is AllowedFieldMode;
|
|
12
|
+
//#region src/style.d.ts
|
|
13
|
+
type InlineStyle = Record<string, string>;
|
|
14
|
+
declare function parseInlineStyles(style: string): InlineStyle;
|
|
15
|
+
declare function stringifyInlineStyles(style: InlineStyle): string;
|
|
16
|
+
declare function expandInlineStyles(style: InlineStyle): InlineStyle;
|
|
17
|
+
declare function mergeInlineStyles(under: InlineStyle, over: InlineStyle): InlineStyle;
|
|
30
18
|
//#endregion
|
|
31
19
|
//#region src/border.d.ts
|
|
32
20
|
declare const BORDER_STYLES: {
|
|
@@ -36,35 +24,36 @@ declare const BORDER_STYLES: {
|
|
|
36
24
|
};
|
|
37
25
|
type AllowedBorderStyle = (typeof BORDER_STYLES)[keyof typeof BORDER_STYLES];
|
|
38
26
|
declare const DEFAULT_BORDER_STYLE: AllowedBorderStyle;
|
|
39
|
-
declare
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
* or independently.
|
|
45
|
-
*/
|
|
46
|
-
type BorderStyleConfig = {
|
|
47
|
-
borderStyle: AllowedBorderStyle;
|
|
48
|
-
borderColor: string;
|
|
49
|
-
borderWidthMode: AllowedFieldMode;
|
|
50
|
-
borderTopWidth: number;
|
|
51
|
-
borderRightWidth: number;
|
|
52
|
-
borderBottomWidth: number;
|
|
53
|
-
borderLeftWidth: number;
|
|
54
|
-
borderRadiusMode: AllowedFieldMode;
|
|
55
|
-
borderTopLeftRadius: number;
|
|
56
|
-
borderTopRightRadius: number;
|
|
57
|
-
borderBottomRightRadius: number;
|
|
58
|
-
borderBottomLeftRadius: number;
|
|
27
|
+
declare function isAllowedBorderStyle(value: unknown): value is AllowedBorderStyle;
|
|
28
|
+
type BorderParts = {
|
|
29
|
+
color: string | undefined;
|
|
30
|
+
style: string | undefined;
|
|
31
|
+
width: string | undefined;
|
|
59
32
|
};
|
|
60
33
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
34
|
+
* Reads the width, style and colour of a border from the `border` shorthand,
|
|
35
|
+
* letting any longhand already in the style win. The shorthand lists its
|
|
36
|
+
* parts in any order, so each is recognised by shape rather than position.
|
|
64
37
|
*/
|
|
65
|
-
declare function
|
|
38
|
+
declare function getBorderParts(style: InlineStyle): BorderParts;
|
|
66
39
|
//#endregion
|
|
67
|
-
//#region src/
|
|
40
|
+
//#region src/box.d.ts
|
|
41
|
+
declare const BOX_SIDES: readonly ['top', 'right', 'bottom', 'left'];
|
|
42
|
+
type BoxSide = (typeof BOX_SIDES)[number];
|
|
43
|
+
type BoxSideValues = Record<BoxSide, number>;
|
|
44
|
+
declare const BOX_CORNERS: readonly ['topLeft', 'topRight', 'bottomRight', 'bottomLeft'];
|
|
45
|
+
type BoxCorner = (typeof BOX_CORNERS)[number];
|
|
46
|
+
type BoxCornerValues = Record<BoxCorner, number>;
|
|
47
|
+
declare function getBoxSides(style: InlineStyle, property: string): BoxSideValues;
|
|
48
|
+
declare function toBoxSides(property: string, values: BoxSideValues): Record<string, string | null>;
|
|
49
|
+
/**
|
|
50
|
+
* Radius shorthands run clockwise from the top-left corner, and repeat the
|
|
51
|
+
* same way box shorthands do.
|
|
52
|
+
*/
|
|
53
|
+
declare function getBoxCorners(style: InlineStyle, property: string): BoxCornerValues;
|
|
54
|
+
declare function toBoxCorners(property: string, values: BoxCornerValues): Record<string, string | null>;
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/button.d.ts
|
|
68
57
|
/**
|
|
69
58
|
* Button layout kinds.
|
|
70
59
|
* "tight" renders the button at its content width,
|
|
@@ -75,18 +64,22 @@ declare const BUTTON_KINDS: {
|
|
|
75
64
|
readonly FULL_WIDTH: 'full-width';
|
|
76
65
|
};
|
|
77
66
|
type AllowedButtonKind = (typeof BUTTON_KINDS)[keyof typeof BUTTON_KINDS];
|
|
78
|
-
declare const allowedButtonKinds: readonly AllowedButtonKind[];
|
|
79
67
|
declare const DEFAULT_BUTTON_KIND: AllowedButtonKind;
|
|
80
68
|
declare function isAllowedButtonKind(value: unknown): value is AllowedButtonKind;
|
|
81
69
|
//#endregion
|
|
70
|
+
//#region src/column.d.ts
|
|
71
|
+
type ColumnWidth = number | string;
|
|
72
|
+
declare function getColumnWidth(value: string | null | undefined): ColumnWidth | null;
|
|
73
|
+
declare function getColumnWidthValue(width: ColumnWidth): string;
|
|
74
|
+
type ColumnWidthPercentOptions = {
|
|
75
|
+
containerWidth: number;
|
|
76
|
+
width: ColumnWidth | null | undefined;
|
|
77
|
+
};
|
|
78
|
+
declare function getColumnWidthPercent(options: ColumnWidthPercentOptions): number | null;
|
|
79
|
+
//#endregion
|
|
82
80
|
//#region src/constants.d.ts
|
|
83
|
-
/** HTML data attribute key used to identify node types in rendered output. */
|
|
84
81
|
declare const DATA_NODE_TYPE_KEY = "data-node-type";
|
|
85
|
-
/** HTML data attribute key used to store serialized visibility rules. */
|
|
86
|
-
declare const DATA_VISIBILITY_RULE_KEY = "data-visibility-rule";
|
|
87
|
-
/** Prefix prepended to all Maily error messages for easy identification. */
|
|
88
82
|
declare const MAILY_ERROR_PREFIX = "[Maily Error]";
|
|
89
|
-
/** URL for filing bug reports against the Maily repository. */
|
|
90
83
|
declare const MAILY_BUG_REPORT_URL = "https://github.com/arikchakma/maily.to/issues/new";
|
|
91
84
|
//#endregion
|
|
92
85
|
//#region src/font.d.ts
|
|
@@ -120,31 +113,23 @@ interface FontProps {
|
|
|
120
113
|
* loaded from the Maily CDN as woff2.
|
|
121
114
|
*/
|
|
122
115
|
declare const DEFAULT_FONT: FontProps;
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
116
|
+
declare function getFontFamilyNames(value: string): string[];
|
|
117
|
+
type FontFamilyValueOptions = {
|
|
118
|
+
fallbackFontFamily?: string | null;
|
|
119
|
+
fontFamily?: string | null;
|
|
120
|
+
};
|
|
121
|
+
declare function getFontFamilyValue(options: FontFamilyValueOptions): string;
|
|
128
122
|
/**
|
|
129
123
|
* Generates a @font-face CSS rule string for the given font configuration.
|
|
130
124
|
* Includes the font family, style, weight, MSO fallback, and web font
|
|
131
125
|
* source URL when available.
|
|
132
126
|
*/
|
|
133
127
|
declare function getFontFaceStyle(font: FontProps): string;
|
|
134
|
-
//#endregion
|
|
135
|
-
//#region src/font-weight.d.ts
|
|
136
128
|
/**
|
|
137
|
-
*
|
|
138
|
-
*
|
|
129
|
+
* Injects a @font-face style element into the document head to load
|
|
130
|
+
* the given font. Only works in browser environments.
|
|
139
131
|
*/
|
|
140
|
-
declare
|
|
141
|
-
readonly NORMAL: 400;
|
|
142
|
-
readonly MEDIUM: 500;
|
|
143
|
-
readonly SEMIBOLD: 600;
|
|
144
|
-
readonly BOLD: 700;
|
|
145
|
-
readonly EXTRA_BOLD: 800;
|
|
146
|
-
};
|
|
147
|
-
type FontWeight = (typeof FONT_WEIGHTS)[keyof typeof FONT_WEIGHTS];
|
|
132
|
+
declare function loadFont(font: FontProps): void;
|
|
148
133
|
//#endregion
|
|
149
134
|
//#region src/font-style.d.ts
|
|
150
135
|
/**
|
|
@@ -170,7 +155,6 @@ declare const FONT_STYLES: {
|
|
|
170
155
|
readonly ITALIC: 'italic';
|
|
171
156
|
};
|
|
172
157
|
type FontStyleValue = (typeof FONT_STYLES)[keyof typeof FONT_STYLES];
|
|
173
|
-
/** Preset options for the font size dropdown in the editor. */
|
|
174
158
|
declare const FONT_SIZE_PRESETS: readonly [{
|
|
175
159
|
readonly value: 12;
|
|
176
160
|
readonly label: 'Small';
|
|
@@ -190,7 +174,6 @@ declare const FONT_SIZE_PRESETS: readonly [{
|
|
|
190
174
|
readonly value: 32;
|
|
191
175
|
readonly label: '2XL';
|
|
192
176
|
}];
|
|
193
|
-
/** Preset options for the line height dropdown in the editor. */
|
|
194
177
|
declare const LINE_HEIGHT_PRESETS: readonly [{
|
|
195
178
|
readonly value: 1;
|
|
196
179
|
readonly label: 'Tight';
|
|
@@ -208,39 +191,24 @@ declare const LINE_HEIGHT_PRESETS: readonly [{
|
|
|
208
191
|
readonly label: 'Loose';
|
|
209
192
|
}];
|
|
210
193
|
declare const DEFAULT_FONT_FAMILY: FontFamily;
|
|
211
|
-
declare const DEFAULT_FONT_SIZE = 15;
|
|
212
|
-
declare const DEFAULT_FONT_WEIGHT: FontWeight;
|
|
213
|
-
declare const DEFAULT_LINE_HEIGHT = 1.75;
|
|
214
194
|
declare const DEFAULT_FONT_FALLBACK: FallbackFont;
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region src/font-weight.d.ts
|
|
215
197
|
/**
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*/
|
|
219
|
-
type FontStyleAttributes = {
|
|
220
|
-
fontFamily: FontFamily | null;
|
|
221
|
-
fontFallback: FallbackFont | null;
|
|
222
|
-
fontSize: number | null;
|
|
223
|
-
fontWeight: FontWeight | null;
|
|
224
|
-
lineHeight: number | null;
|
|
225
|
-
fontStyle: FontStyleValue | null;
|
|
226
|
-
};
|
|
227
|
-
/**
|
|
228
|
-
* Baseline font values used when a node's FontStyleAttributes are null.
|
|
229
|
-
* Each node type (paragraph, heading, button, etc.) has its own defaults
|
|
230
|
-
* defined in the renderer theme.
|
|
198
|
+
* Numeric font weight values mapped to semantic names.
|
|
199
|
+
* Normal (400), Medium (500), Semibold (600), Bold (700), Extra Bold (800).
|
|
231
200
|
*/
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
201
|
+
declare const FONT_WEIGHTS: {
|
|
202
|
+
readonly NORMAL: 400;
|
|
203
|
+
readonly MEDIUM: 500;
|
|
204
|
+
readonly SEMIBOLD: 600;
|
|
205
|
+
readonly BOLD: 700;
|
|
206
|
+
readonly EXTRA_BOLD: 800;
|
|
237
207
|
};
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
*/
|
|
243
|
-
declare function getFontStyle(attrs: FontStyleAttributes, defaults?: Partial<NodeFontStyleDefaults>): Properties;
|
|
208
|
+
type FontWeight = (typeof FONT_WEIGHTS)[keyof typeof FONT_WEIGHTS];
|
|
209
|
+
//#endregion
|
|
210
|
+
//#region src/function.d.ts
|
|
211
|
+
declare function noop(): void;
|
|
244
212
|
//#endregion
|
|
245
213
|
//#region src/html-code-block.d.ts
|
|
246
214
|
/**
|
|
@@ -254,28 +222,19 @@ declare const HTML_CODE_BLOCK_TABS: {
|
|
|
254
222
|
type AllowedHtmlCodeBlockTab = (typeof HTML_CODE_BLOCK_TABS)[keyof typeof HTML_CODE_BLOCK_TABS];
|
|
255
223
|
declare const DEFAULT_HTML_CODE_BLOCK_TAB: AllowedHtmlCodeBlockTab;
|
|
256
224
|
//#endregion
|
|
257
|
-
//#region src/
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
marginLeft: number;
|
|
269
|
-
};
|
|
270
|
-
/**
|
|
271
|
-
* Converts a MarginStyleConfig into CSS properties for inline styles.
|
|
272
|
-
* When all sides are equal (or mode is "uniform"), emits shorthand CSS;
|
|
273
|
-
* otherwise emits per-side longhand properties.
|
|
274
|
-
*/
|
|
275
|
-
declare function getMarginStyle(config: MarginStyleConfig): Properties;
|
|
225
|
+
//#region src/image.d.ts
|
|
226
|
+
type ImageWidth = number | string;
|
|
227
|
+
declare const MIN_IMAGE_WIDTH_PERCENTAGE = 5;
|
|
228
|
+
declare const MAX_IMAGE_WIDTH_PERCENTAGE = 100;
|
|
229
|
+
declare const DEFAULT_CONTAINER_WIDTH_PIXELS = 600;
|
|
230
|
+
declare function parseWidthToPercentage(width: ImageWidth | null | undefined, containerWidthPixels?: number): number;
|
|
231
|
+
declare function clampImageWidthPercentage(width: number): number;
|
|
232
|
+
//#endregion
|
|
233
|
+
//#region src/invariant.d.ts
|
|
234
|
+
declare function invariant(value: boolean, message?: string): asserts value;
|
|
235
|
+
declare function invariant<T>(value: T | null | undefined, message?: string): asserts value is T;
|
|
276
236
|
//#endregion
|
|
277
237
|
//#region src/mark.d.ts
|
|
278
|
-
/** Registry of all inline mark type strings used in the document JSON. */
|
|
279
238
|
declare const MAILY_MARK_TYPES: {
|
|
280
239
|
readonly BOLD: 'bold';
|
|
281
240
|
readonly ITALIC: 'italic';
|
|
@@ -285,110 +244,126 @@ declare const MAILY_MARK_TYPES: {
|
|
|
285
244
|
readonly CODE: 'code';
|
|
286
245
|
readonly TEXT_STYLE: 'textStyle';
|
|
287
246
|
readonly HIGHLIGHT: 'highlight';
|
|
247
|
+
readonly SPAN: 'span';
|
|
288
248
|
};
|
|
249
|
+
declare const allowedMarkTypes: ("bold" | "code" | "highlight" | "italic" | "link" | "span" | "strike" | "textStyle" | "underline")[];
|
|
289
250
|
type MailyMarkType = (typeof MAILY_MARK_TYPES)[keyof typeof MAILY_MARK_TYPES];
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
* narrow the type field and optionally add typed attrs.
|
|
294
|
-
*/
|
|
251
|
+
type MarkStyleAttributes = {
|
|
252
|
+
style?: string | null;
|
|
253
|
+
};
|
|
295
254
|
type BaseMailyMark = {
|
|
255
|
+
attrs?: MarkStyleAttributes & Record<string, unknown>;
|
|
296
256
|
type: MailyMarkType;
|
|
297
|
-
attrs?: Record<string, any>;
|
|
298
257
|
};
|
|
299
|
-
/** Bold */
|
|
300
258
|
type BoldMark = BaseMailyMark & {
|
|
301
259
|
type: typeof MAILY_MARK_TYPES.BOLD;
|
|
302
260
|
};
|
|
303
|
-
/** Italic */
|
|
304
261
|
type ItalicMark = BaseMailyMark & {
|
|
305
262
|
type: typeof MAILY_MARK_TYPES.ITALIC;
|
|
306
263
|
};
|
|
307
|
-
/** Strike */
|
|
308
264
|
type StrikeMark = BaseMailyMark & {
|
|
309
265
|
type: typeof MAILY_MARK_TYPES.STRIKE;
|
|
310
266
|
};
|
|
311
|
-
/** Underline */
|
|
312
267
|
type UnderlineMark = BaseMailyMark & {
|
|
313
268
|
type: typeof MAILY_MARK_TYPES.UNDERLINE;
|
|
314
269
|
};
|
|
315
|
-
|
|
316
|
-
|
|
270
|
+
type LinkAttributes = MarkStyleAttributes & {
|
|
271
|
+
class?: string | null;
|
|
317
272
|
href: string;
|
|
318
|
-
|
|
273
|
+
rel?: string | null;
|
|
274
|
+
target?: string | null;
|
|
275
|
+
title?: string | null;
|
|
319
276
|
};
|
|
320
277
|
type LinkMark = BaseMailyMark & {
|
|
321
|
-
type: typeof MAILY_MARK_TYPES.LINK;
|
|
322
278
|
attrs: LinkAttributes;
|
|
279
|
+
type: typeof MAILY_MARK_TYPES.LINK;
|
|
323
280
|
};
|
|
324
|
-
/** Code */
|
|
325
|
-
type CodeAttributes = {};
|
|
326
281
|
type CodeMark = BaseMailyMark & {
|
|
327
282
|
type: typeof MAILY_MARK_TYPES.CODE;
|
|
328
|
-
attrs: CodeAttributes;
|
|
329
283
|
};
|
|
330
|
-
|
|
331
|
-
type TextStyleAttributes = {
|
|
284
|
+
type TextStyleAttributes = MarkStyleAttributes & {
|
|
332
285
|
color: string;
|
|
333
286
|
};
|
|
334
287
|
type TextStyleMark = BaseMailyMark & {
|
|
335
|
-
type: typeof MAILY_MARK_TYPES.TEXT_STYLE;
|
|
336
288
|
attrs: TextStyleAttributes;
|
|
289
|
+
type: typeof MAILY_MARK_TYPES.TEXT_STYLE;
|
|
337
290
|
};
|
|
338
|
-
|
|
339
|
-
type HighlightAttributes = {
|
|
291
|
+
type HighlightAttributes = MarkStyleAttributes & {
|
|
340
292
|
color: string;
|
|
341
293
|
};
|
|
342
294
|
type HighlightMark = BaseMailyMark & {
|
|
343
|
-
type: typeof MAILY_MARK_TYPES.HIGHLIGHT;
|
|
344
295
|
attrs: HighlightAttributes;
|
|
296
|
+
type: typeof MAILY_MARK_TYPES.HIGHLIGHT;
|
|
345
297
|
};
|
|
346
|
-
type
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* Per-side padding configuration for a node. Includes a field mode
|
|
351
|
-
* that controls whether padding is edited uniformly or per-side,
|
|
352
|
-
* and individual values for each side in pixels.
|
|
353
|
-
*/
|
|
354
|
-
type PaddingStyleConfig = {
|
|
355
|
-
paddingMode: AllowedFieldMode;
|
|
356
|
-
paddingTop: number;
|
|
357
|
-
paddingRight: number;
|
|
358
|
-
paddingBottom: number;
|
|
359
|
-
paddingLeft: number;
|
|
298
|
+
type SpanMark = BaseMailyMark & {
|
|
299
|
+
attrs?: MarkStyleAttributes;
|
|
300
|
+
type: typeof MAILY_MARK_TYPES.SPAN;
|
|
360
301
|
};
|
|
361
|
-
|
|
362
|
-
* Converts a PaddingStyleConfig into CSS properties for inline styles.
|
|
363
|
-
* When all sides are equal (or mode is "uniform"), emits shorthand CSS;
|
|
364
|
-
* otherwise emits per-side longhand properties.
|
|
365
|
-
*/
|
|
366
|
-
declare function getPaddingStyle(config: PaddingStyleConfig): Properties;
|
|
302
|
+
type AnyMailyMark = BoldMark | ItalicMark | StrikeMark | UnderlineMark | LinkMark | CodeMark | TextStyleMark | HighlightMark | SpanMark;
|
|
367
303
|
//#endregion
|
|
368
|
-
//#region src/
|
|
369
|
-
/** Text direction values matching the HTML `dir` attribute: ltr, rtl, auto. */
|
|
304
|
+
//#region src/direction.d.ts
|
|
370
305
|
declare const TEXT_DIRECTIONS: {
|
|
371
306
|
readonly LTR: 'ltr';
|
|
372
307
|
readonly RTL: 'rtl';
|
|
373
308
|
readonly AUTO: 'auto';
|
|
374
309
|
};
|
|
375
310
|
type TextDirection = (typeof TEXT_DIRECTIONS)[keyof typeof TEXT_DIRECTIONS];
|
|
376
|
-
declare const allowedTextDirections: readonly TextDirection[];
|
|
377
311
|
declare const DEFAULT_TEXT_DIRECTION: TextDirection;
|
|
378
|
-
declare function
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
312
|
+
declare function getCssDirection(dir: TextDirection | null | undefined): {
|
|
313
|
+
direction: "ltr" | "rtl";
|
|
314
|
+
} | {
|
|
315
|
+
direction?: undefined;
|
|
316
|
+
};
|
|
317
|
+
//#endregion
|
|
318
|
+
//#region src/theme.d.ts
|
|
319
|
+
type NodeThemeOptions = {
|
|
320
|
+
blockquote?: InlineStyle;
|
|
321
|
+
body?: InlineStyle;
|
|
322
|
+
bulletList?: InlineStyle;
|
|
323
|
+
button?: InlineStyle;
|
|
324
|
+
code?: InlineStyle;
|
|
325
|
+
container?: InlineStyle;
|
|
326
|
+
footer?: InlineStyle;
|
|
327
|
+
h1?: InlineStyle;
|
|
328
|
+
h2?: InlineStyle;
|
|
329
|
+
h3?: InlineStyle;
|
|
330
|
+
heading?: InlineStyle;
|
|
331
|
+
horizontalRule?: InlineStyle;
|
|
332
|
+
htmlCodeBlock?: InlineStyle;
|
|
333
|
+
link?: InlineStyle;
|
|
334
|
+
listItem?: InlineStyle;
|
|
335
|
+
orderedList?: InlineStyle;
|
|
336
|
+
paragraph?: InlineStyle;
|
|
337
|
+
section?: InlineStyle;
|
|
338
|
+
table?: InlineStyle;
|
|
339
|
+
tableCell?: InlineStyle;
|
|
340
|
+
tableRow?: InlineStyle;
|
|
341
|
+
};
|
|
342
|
+
declare const DEFAULT_CONTAINER_MAX_WIDTH = 600;
|
|
343
|
+
declare const BASIC_NODE_THEME: NodeThemeOptions;
|
|
344
|
+
declare const MAILY_NODE_THEME: NodeThemeOptions;
|
|
345
|
+
type ExtendNodeThemeOptions = {
|
|
346
|
+
extension: NodeThemeOptions;
|
|
347
|
+
preset: NodeThemeOptions;
|
|
348
|
+
};
|
|
349
|
+
declare function extendNodeTheme(options: ExtendNodeThemeOptions): NodeThemeOptions;
|
|
350
|
+
type ThemeDeclarationsOptions = {
|
|
351
|
+
attrs?: Record<string, unknown> | undefined;
|
|
352
|
+
theme: NodeThemeOptions;
|
|
353
|
+
type: string;
|
|
354
|
+
};
|
|
355
|
+
declare function getThemeDeclarations(options: ThemeDeclarationsOptions): InlineStyle | undefined;
|
|
385
356
|
//#endregion
|
|
386
357
|
//#region src/visibility.d.ts
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
358
|
+
declare const VISIBILITY_ACTIONS: {
|
|
359
|
+
readonly SHOW: 'show';
|
|
360
|
+
readonly HIDE: 'hide';
|
|
361
|
+
};
|
|
362
|
+
type AllowedVisibilityAction = (typeof VISIBILITY_ACTIONS)[keyof typeof VISIBILITY_ACTIONS];
|
|
363
|
+
declare const VISIBILITY_ACTION_OPTIONS: {
|
|
364
|
+
label: string;
|
|
365
|
+
value: AllowedVisibilityAction;
|
|
366
|
+
}[];
|
|
392
367
|
declare const VISIBILITY_OPERATORS: {
|
|
393
368
|
readonly IS_TRUE: 'is_true';
|
|
394
369
|
readonly IS_FALSE: 'is_false';
|
|
@@ -403,566 +378,416 @@ declare const VISIBILITY_OPERATORS: {
|
|
|
403
378
|
};
|
|
404
379
|
type AllowedVisibilityOperator = (typeof VISIBILITY_OPERATORS)[keyof typeof VISIBILITY_OPERATORS];
|
|
405
380
|
declare const VISIBILITY_OPERATOR_OPTIONS: {
|
|
406
|
-
value: AllowedVisibilityOperator;
|
|
407
|
-
label: string;
|
|
408
|
-
}[];
|
|
409
|
-
/**
|
|
410
|
-
* Unary operators that don't require a comparison value.
|
|
411
|
-
* The UI hides the value input field when one of these is selected.
|
|
412
|
-
*/
|
|
413
|
-
declare const OPERATORS_WITHOUT_VALUE: AllowedVisibilityOperator[];
|
|
414
|
-
declare const VISIBILITY_ACTIONS: {
|
|
415
|
-
readonly NONE: 'none';
|
|
416
|
-
readonly SHOW: 'show';
|
|
417
|
-
readonly HIDE: 'hide';
|
|
418
|
-
};
|
|
419
|
-
type AllowedVisibilityAction = (typeof VISIBILITY_ACTIONS)[keyof typeof VISIBILITY_ACTIONS];
|
|
420
|
-
declare const VISIBILITY_ACTION_OPTIONS: {
|
|
421
|
-
value: AllowedVisibilityAction;
|
|
422
381
|
label: string;
|
|
382
|
+
value: AllowedVisibilityOperator;
|
|
423
383
|
}[];
|
|
424
|
-
/**
|
|
425
|
-
* Defines when a node is conditionally shown or hidden based on
|
|
426
|
-
* a template variable. Evaluated at render time by the renderer.
|
|
427
|
-
*/
|
|
428
384
|
type VisibilityRule = {
|
|
429
385
|
action: AllowedVisibilityAction;
|
|
430
|
-
variable: string;
|
|
431
386
|
operator: AllowedVisibilityOperator;
|
|
432
387
|
value: string;
|
|
388
|
+
variable: string;
|
|
433
389
|
};
|
|
434
|
-
/** Mixin for nodes that support conditional visibility. */
|
|
435
390
|
type WithVisibilityAttrs = {
|
|
436
391
|
visibilityRule?: VisibilityRule | null;
|
|
437
392
|
};
|
|
393
|
+
declare const DEFAULT_VISIBILITY_RULE: VisibilityRule;
|
|
394
|
+
declare function getVisibilityValueSupport(operator: AllowedVisibilityOperator): boolean;
|
|
395
|
+
type VisibilityRuleOptions = {
|
|
396
|
+
action: string | null | undefined;
|
|
397
|
+
operator: string | null | undefined;
|
|
398
|
+
value: string | null | undefined;
|
|
399
|
+
variable: string | null | undefined;
|
|
400
|
+
};
|
|
401
|
+
declare function getVisibilityRule(options: VisibilityRuleOptions): VisibilityRule | null;
|
|
438
402
|
//#endregion
|
|
439
403
|
//#region src/node.d.ts
|
|
440
|
-
/**
|
|
441
|
-
* Registry of all document node type strings. These map 1:1 to
|
|
442
|
-
* Tiptap extension names and are used as discriminators in the
|
|
443
|
-
* document JSON.
|
|
444
|
-
*/
|
|
445
404
|
declare const MAILY_NODE_TYPES: {
|
|
446
405
|
readonly DOCUMENT: 'doc';
|
|
447
|
-
readonly
|
|
448
|
-
readonly
|
|
449
|
-
readonly HEADING: 'heading';
|
|
450
|
-
readonly VARIABLE: 'variable';
|
|
451
|
-
readonly IMAGE: 'image';
|
|
452
|
-
readonly SPACER: 'spacer';
|
|
406
|
+
readonly BODY: 'body';
|
|
407
|
+
readonly CONTAINER: 'container';
|
|
453
408
|
readonly SECTION: 'section';
|
|
409
|
+
readonly DIV: 'div';
|
|
454
410
|
readonly COLUMNS: 'columns';
|
|
455
411
|
readonly COLUMN: 'column';
|
|
456
|
-
readonly
|
|
457
|
-
readonly
|
|
458
|
-
readonly
|
|
459
|
-
readonly
|
|
412
|
+
readonly IMAGE: 'image';
|
|
413
|
+
readonly INLINE_IMAGE: 'inlineImage';
|
|
414
|
+
readonly INLINE_SPAN: 'inlineSpan';
|
|
415
|
+
readonly SPACER: 'spacer';
|
|
460
416
|
readonly BUTTON: 'button';
|
|
461
|
-
readonly
|
|
462
|
-
readonly
|
|
417
|
+
readonly FOOTER: 'footer';
|
|
418
|
+
readonly PARAGRAPH: 'paragraph';
|
|
419
|
+
readonly HEADING: 'heading';
|
|
463
420
|
readonly BLOCKQUOTE: 'blockquote';
|
|
421
|
+
readonly HORIZONTAL_RULE: 'horizontalRule';
|
|
422
|
+
readonly HTML_CODE_BLOCK: 'htmlCodeBlock';
|
|
423
|
+
readonly REPEAT: 'repeat';
|
|
464
424
|
readonly HARD_BREAK: 'hardBreak';
|
|
465
|
-
readonly
|
|
466
|
-
readonly
|
|
425
|
+
readonly BULLET_LIST: 'bulletList';
|
|
426
|
+
readonly ORDERED_LIST: 'orderedList';
|
|
427
|
+
readonly LIST_ITEM: 'listItem';
|
|
428
|
+
readonly TEXT: 'text';
|
|
429
|
+
readonly VARIABLE: 'variable';
|
|
430
|
+
readonly TABLE: 'table';
|
|
431
|
+
readonly TABLE_ROW: 'tableRow';
|
|
432
|
+
readonly TABLE_CELL: 'tableCell';
|
|
433
|
+
readonly TABLE_HEADER: 'tableHeader';
|
|
467
434
|
readonly LINK_CARD: 'linkCard';
|
|
468
435
|
};
|
|
469
|
-
/**
|
|
470
|
-
* Tiptap extension types that attach attributes to nodes but are
|
|
471
|
-
* not document nodes themselves (e.g. fontStyle, visibility).
|
|
472
|
-
*/
|
|
473
436
|
declare const MAILY_EXTENSION_TYPES: {
|
|
474
|
-
readonly
|
|
437
|
+
readonly STYLE: 'style';
|
|
438
|
+
readonly THEME: 'theme';
|
|
475
439
|
readonly VISIBILITY: 'visibility';
|
|
476
440
|
};
|
|
477
|
-
declare const allowedNodeTypes: ("blockquote" | "bulletList" | "button" | "column" | "columns" | "doc" | "footer" | "hardBreak" | "heading" | "horizontalRule" | "htmlCodeBlock" | "image" | "inlineImage" | "linkCard" | "listItem" | "orderedList" | "paragraph" | "repeat" | "section" | "spacer" | "text" | "variable")[];
|
|
441
|
+
declare const allowedNodeTypes: ("blockquote" | "body" | "bulletList" | "button" | "column" | "columns" | "container" | "div" | "doc" | "footer" | "hardBreak" | "heading" | "horizontalRule" | "htmlCodeBlock" | "image" | "inlineImage" | "inlineSpan" | "linkCard" | "listItem" | "orderedList" | "paragraph" | "repeat" | "section" | "spacer" | "table" | "tableCell" | "tableHeader" | "tableRow" | "text" | "variable")[];
|
|
478
442
|
type MailyNodeType = (typeof MAILY_NODE_TYPES)[keyof typeof MAILY_NODE_TYPES];
|
|
479
|
-
/**
|
|
480
|
-
* Global attributes mixed into every node by Tiptap extensions:
|
|
481
|
-
* text direction, unique id, and conditional visibility.
|
|
482
|
-
*/
|
|
483
443
|
type WithExtraAttrs = {
|
|
484
444
|
dir?: TextDirection | null;
|
|
485
|
-
id?: string | null;
|
|
486
|
-
visibilityRule?: VisibilityRule | null;
|
|
487
445
|
};
|
|
488
|
-
/**
|
|
489
|
-
* Base shape shared by all document nodes. Individual node types
|
|
490
|
-
* narrow the type field, add typed attrs, and constrain content.
|
|
491
|
-
*/
|
|
492
446
|
type BaseMailyNode = {
|
|
493
|
-
|
|
494
|
-
attrs?: Record<string, any> & WithExtraAttrs;
|
|
447
|
+
attrs?: WithExtraAttrs & Record<string, unknown>;
|
|
495
448
|
content?: AnyMailyNode[];
|
|
496
449
|
marks?: AnyMailyMark[];
|
|
497
450
|
text?: string;
|
|
451
|
+
type: MailyNodeType;
|
|
498
452
|
};
|
|
499
|
-
|
|
500
|
-
|
|
453
|
+
type DocumentAttributes = WithExtraAttrs & {
|
|
454
|
+
theme?: NodeThemeOptions | null;
|
|
501
455
|
version: number;
|
|
502
456
|
};
|
|
503
457
|
type DocumentNode = BaseMailyNode & {
|
|
504
|
-
type: typeof MAILY_NODE_TYPES.DOCUMENT;
|
|
505
458
|
attrs: DocumentAttributes;
|
|
506
|
-
content:
|
|
459
|
+
content: AnyMailyNode[];
|
|
460
|
+
type: typeof MAILY_NODE_TYPES.DOCUMENT;
|
|
507
461
|
};
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
id: string;
|
|
511
|
-
textAlign: AllowedTextAlignment;
|
|
512
|
-
} & FontStyleAttributes;
|
|
513
|
-
type ParagraphNode = BaseMailyNode & {
|
|
514
|
-
type: typeof MAILY_NODE_TYPES.PARAGRAPH;
|
|
515
|
-
attrs: ParagraphAttributes;
|
|
462
|
+
type BodyAttributes = WithExtraAttrs & {
|
|
463
|
+
style?: string | null;
|
|
516
464
|
};
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
465
|
+
type BodyNode = BaseMailyNode & {
|
|
466
|
+
attrs?: BodyAttributes;
|
|
467
|
+
content: AnyMailyNode[];
|
|
468
|
+
type: typeof MAILY_NODE_TYPES.BODY;
|
|
521
469
|
};
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
type HeadingAttributes = {
|
|
525
|
-
id: string;
|
|
526
|
-
level: HeadingLevel;
|
|
527
|
-
} & FontStyleAttributes;
|
|
528
|
-
type HeadingNode = BaseMailyNode & {
|
|
529
|
-
type: typeof MAILY_NODE_TYPES.HEADING;
|
|
530
|
-
attrs: HeadingAttributes;
|
|
470
|
+
type ContainerAttributes = WithExtraAttrs & {
|
|
471
|
+
style?: string | null;
|
|
531
472
|
};
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
* variable data to plain text (see serializeVariableToText).
|
|
537
|
-
*/
|
|
538
|
-
type VariableAttributes = {
|
|
539
|
-
/** Stored as `data-id`. Identifies which variable this node represents. */id: string | null; /** Stored as `data-label`. Display text shown in the editor instead of the id. */
|
|
540
|
-
label?: string | null; /** Stored as `data-fallback`. Used when the variable has no value at render time. */
|
|
541
|
-
fallback?: string | null;
|
|
542
|
-
required?: boolean;
|
|
543
|
-
hideDefaultValue?: boolean; /** The character that opens the variable suggestion popup (e.g. `@`). */
|
|
544
|
-
variableSuggestionChar?: string;
|
|
473
|
+
type ContainerNode = BaseMailyNode & {
|
|
474
|
+
attrs?: ContainerAttributes;
|
|
475
|
+
content: AnyMailyNode[];
|
|
476
|
+
type: typeof MAILY_NODE_TYPES.CONTAINER;
|
|
545
477
|
};
|
|
546
|
-
type
|
|
547
|
-
|
|
548
|
-
attrs: VariableAttributes;
|
|
549
|
-
content: never;
|
|
478
|
+
type SectionAttributes = WithExtraAttrs & WithVisibilityAttrs & {
|
|
479
|
+
style?: string | null;
|
|
550
480
|
};
|
|
551
|
-
|
|
552
|
-
|
|
481
|
+
type SectionNode = BaseMailyNode & {
|
|
482
|
+
attrs?: SectionAttributes;
|
|
483
|
+
content: AnyMailyNode[];
|
|
484
|
+
type: typeof MAILY_NODE_TYPES.SECTION;
|
|
485
|
+
};
|
|
486
|
+
type DivAttributes = WithExtraAttrs & {
|
|
487
|
+
style?: string | null;
|
|
488
|
+
};
|
|
489
|
+
type DivNode = BaseMailyNode & {
|
|
490
|
+
attrs?: DivAttributes;
|
|
491
|
+
content: AnyMailyNode[];
|
|
492
|
+
type: typeof MAILY_NODE_TYPES.DIV;
|
|
493
|
+
};
|
|
494
|
+
type RepeatAttributes = WithVisibilityAttrs & {
|
|
495
|
+
each: string;
|
|
496
|
+
};
|
|
497
|
+
type RepeatNode = BaseMailyNode & {
|
|
498
|
+
attrs: RepeatAttributes;
|
|
499
|
+
content: AnyMailyNode[];
|
|
500
|
+
type: typeof MAILY_NODE_TYPES.REPEAT;
|
|
501
|
+
};
|
|
502
|
+
type ColumnsAttributes = WithExtraAttrs & WithVisibilityAttrs & {
|
|
503
|
+
columnCount: number;
|
|
504
|
+
gap: number;
|
|
505
|
+
style?: string | null;
|
|
506
|
+
};
|
|
507
|
+
type ColumnsNode = BaseMailyNode & {
|
|
508
|
+
attrs: ColumnsAttributes;
|
|
509
|
+
content: ColumnNode[];
|
|
510
|
+
type: typeof MAILY_NODE_TYPES.COLUMNS;
|
|
511
|
+
};
|
|
512
|
+
type ColumnAttributes = WithExtraAttrs & {
|
|
513
|
+
verticalAlign: string;
|
|
514
|
+
width: ColumnWidth | null;
|
|
515
|
+
style?: string | null;
|
|
516
|
+
};
|
|
517
|
+
type ColumnNode = BaseMailyNode & {
|
|
518
|
+
attrs: ColumnAttributes;
|
|
519
|
+
content: AnyMailyNode[];
|
|
520
|
+
type: typeof MAILY_NODE_TYPES.COLUMN;
|
|
521
|
+
};
|
|
522
|
+
type ImageAttributes = WithExtraAttrs & WithVisibilityAttrs & {
|
|
523
|
+
align: AllowedTextAlignment;
|
|
524
|
+
alt?: string | null;
|
|
525
|
+
externalLink?: string | null;
|
|
553
526
|
src: string;
|
|
554
|
-
|
|
555
|
-
title?: string;
|
|
527
|
+
style?: string | null;
|
|
528
|
+
title?: string | null;
|
|
556
529
|
width: string;
|
|
557
|
-
|
|
558
|
-
externalLink: string | null;
|
|
559
|
-
} & BorderStyleConfig;
|
|
530
|
+
};
|
|
560
531
|
type ImageNode = BaseMailyNode & {
|
|
561
|
-
type: typeof MAILY_NODE_TYPES.IMAGE;
|
|
562
532
|
attrs: ImageAttributes;
|
|
563
|
-
|
|
564
|
-
};
|
|
565
|
-
/** Spacer */
|
|
566
|
-
type SpacerAttributes = {
|
|
567
|
-
height: number;
|
|
568
|
-
heightMode: AllowedFieldMode;
|
|
569
|
-
};
|
|
570
|
-
type SpacerNode = BaseMailyNode & {
|
|
571
|
-
type: typeof MAILY_NODE_TYPES.SPACER;
|
|
572
|
-
attrs: SpacerAttributes;
|
|
573
|
-
content: never;
|
|
533
|
+
type: typeof MAILY_NODE_TYPES.IMAGE;
|
|
574
534
|
};
|
|
575
|
-
|
|
576
|
-
type SectionAttributes = {
|
|
577
|
-
backgroundColor: string;
|
|
535
|
+
type ButtonAttributes = WithExtraAttrs & WithVisibilityAttrs & {
|
|
578
536
|
align: AllowedTextAlignment;
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
537
|
+
kind: AllowedButtonKind;
|
|
538
|
+
style?: string | null;
|
|
539
|
+
url: string;
|
|
540
|
+
};
|
|
541
|
+
type ButtonNode = BaseMailyNode & {
|
|
542
|
+
attrs: ButtonAttributes;
|
|
583
543
|
content: AnyMailyNode[];
|
|
544
|
+
type: typeof MAILY_NODE_TYPES.BUTTON;
|
|
584
545
|
};
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
id: string;
|
|
546
|
+
type FooterAttributes = WithExtraAttrs & {
|
|
547
|
+
style?: string | null;
|
|
588
548
|
};
|
|
589
|
-
type
|
|
590
|
-
|
|
591
|
-
attrs: BulletListAttributes;
|
|
549
|
+
type FooterNode = BaseMailyNode & {
|
|
550
|
+
attrs?: FooterAttributes;
|
|
592
551
|
content: AnyMailyNode[];
|
|
552
|
+
type: typeof MAILY_NODE_TYPES.FOOTER;
|
|
593
553
|
};
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
554
|
+
type InlineImageAttributes = WithExtraAttrs & {
|
|
555
|
+
alt?: string | null;
|
|
556
|
+
externalLink?: string | null;
|
|
557
|
+
height: number;
|
|
558
|
+
src: string;
|
|
559
|
+
style?: string | null;
|
|
560
|
+
title?: string | null;
|
|
561
|
+
width: number;
|
|
597
562
|
};
|
|
598
|
-
type
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
content: AnyMailyNode[];
|
|
563
|
+
type InlineImageNode = BaseMailyNode & {
|
|
564
|
+
attrs: InlineImageAttributes;
|
|
565
|
+
type: typeof MAILY_NODE_TYPES.INLINE_IMAGE;
|
|
602
566
|
};
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
id: string;
|
|
567
|
+
type InlineSpanAttributes = WithExtraAttrs & {
|
|
568
|
+
style?: string | null;
|
|
606
569
|
};
|
|
607
|
-
type
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
570
|
+
type InlineSpanNode = BaseMailyNode & {
|
|
571
|
+
attrs?: InlineSpanAttributes;
|
|
572
|
+
type: typeof MAILY_NODE_TYPES.INLINE_SPAN;
|
|
573
|
+
};
|
|
574
|
+
type SpacerAttributes = WithExtraAttrs & WithVisibilityAttrs & {
|
|
575
|
+
height: number;
|
|
576
|
+
style?: string | null;
|
|
577
|
+
};
|
|
578
|
+
type SpacerNode = BaseMailyNode & {
|
|
579
|
+
attrs: SpacerAttributes;
|
|
580
|
+
type: typeof MAILY_NODE_TYPES.SPACER;
|
|
581
|
+
};
|
|
582
|
+
type ParagraphAttributes = WithExtraAttrs & WithVisibilityAttrs & {
|
|
583
|
+
style?: string | null;
|
|
584
|
+
};
|
|
585
|
+
type ParagraphNode = BaseMailyNode & {
|
|
586
|
+
attrs?: ParagraphAttributes;
|
|
587
|
+
type: typeof MAILY_NODE_TYPES.PARAGRAPH;
|
|
588
|
+
};
|
|
589
|
+
type HeadingLevel = 1 | 2 | 3;
|
|
590
|
+
type HeadingAttributes = WithExtraAttrs & WithVisibilityAttrs & {
|
|
591
|
+
level: HeadingLevel;
|
|
592
|
+
style?: string | null;
|
|
593
|
+
};
|
|
594
|
+
type HeadingNode = BaseMailyNode & {
|
|
595
|
+
attrs: HeadingAttributes;
|
|
596
|
+
type: typeof MAILY_NODE_TYPES.HEADING;
|
|
597
|
+
};
|
|
598
|
+
type BlockquoteAttributes = WithExtraAttrs & {
|
|
599
|
+
style?: string | null;
|
|
611
600
|
};
|
|
612
|
-
/** Blockquote */
|
|
613
|
-
type BlockquoteAttributes = {
|
|
614
|
-
id: string;
|
|
615
|
-
} & FontStyleAttributes;
|
|
616
601
|
type BlockquoteNode = BaseMailyNode & {
|
|
617
|
-
|
|
618
|
-
attrs: BlockquoteAttributes;
|
|
602
|
+
attrs?: BlockquoteAttributes;
|
|
619
603
|
content: AnyMailyNode[];
|
|
604
|
+
type: typeof MAILY_NODE_TYPES.BLOCKQUOTE;
|
|
620
605
|
};
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
id: string;
|
|
606
|
+
type HorizontalRuleAttributes = WithVisibilityAttrs & {
|
|
607
|
+
style?: string | null;
|
|
624
608
|
};
|
|
625
609
|
type HorizontalRuleNode = BaseMailyNode & {
|
|
610
|
+
attrs?: HorizontalRuleAttributes;
|
|
626
611
|
type: typeof MAILY_NODE_TYPES.HORIZONTAL_RULE;
|
|
627
|
-
attrs: HorizontalRuleAttributes;
|
|
628
|
-
content: never;
|
|
629
612
|
};
|
|
630
|
-
|
|
631
|
-
type
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
613
|
+
type HardBreakNode = BaseMailyNode & {
|
|
614
|
+
type: typeof MAILY_NODE_TYPES.HARD_BREAK;
|
|
615
|
+
};
|
|
616
|
+
type BulletListAttributes = WithExtraAttrs & WithVisibilityAttrs & {
|
|
617
|
+
style?: string | null;
|
|
618
|
+
};
|
|
619
|
+
type BulletListNode = BaseMailyNode & {
|
|
620
|
+
attrs?: BulletListAttributes;
|
|
621
|
+
content: ListItemNode[];
|
|
622
|
+
type: typeof MAILY_NODE_TYPES.BULLET_LIST;
|
|
623
|
+
};
|
|
624
|
+
type OrderedListAttributes = WithExtraAttrs & WithVisibilityAttrs & {
|
|
625
|
+
start?: number;
|
|
626
|
+
style?: string | null;
|
|
627
|
+
};
|
|
628
|
+
type OrderedListNode = BaseMailyNode & {
|
|
629
|
+
attrs?: OrderedListAttributes;
|
|
630
|
+
content: ListItemNode[];
|
|
631
|
+
type: typeof MAILY_NODE_TYPES.ORDERED_LIST;
|
|
632
|
+
};
|
|
633
|
+
type ListItemAttributes = WithExtraAttrs & {
|
|
634
|
+
style?: string | null;
|
|
635
|
+
};
|
|
636
|
+
type ListItemNode = BaseMailyNode & {
|
|
637
|
+
attrs?: ListItemAttributes;
|
|
646
638
|
content: AnyMailyNode[];
|
|
639
|
+
type: typeof MAILY_NODE_TYPES.LIST_ITEM;
|
|
647
640
|
};
|
|
648
|
-
|
|
649
|
-
type HtmlCodeBlockAttributes = {
|
|
641
|
+
type HtmlCodeBlockAttributes = WithExtraAttrs & WithVisibilityAttrs & {
|
|
650
642
|
activeTab: AllowedHtmlCodeBlockTab;
|
|
651
643
|
language: string;
|
|
644
|
+
style?: string | null;
|
|
652
645
|
};
|
|
653
646
|
type HtmlCodeBlockNode = BaseMailyNode & {
|
|
654
|
-
type: typeof MAILY_NODE_TYPES.HTML_CODE_BLOCK;
|
|
655
647
|
attrs: HtmlCodeBlockAttributes;
|
|
656
648
|
content: AnyMailyNode[];
|
|
649
|
+
type: typeof MAILY_NODE_TYPES.HTML_CODE_BLOCK;
|
|
657
650
|
};
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
type RepeatNode = BaseMailyNode & {
|
|
663
|
-
type: typeof MAILY_NODE_TYPES.REPEAT;
|
|
664
|
-
attrs: RepeatAttributes;
|
|
665
|
-
content: AnyMailyNode[];
|
|
651
|
+
type TextNode = BaseMailyNode & {
|
|
652
|
+
marks?: AnyMailyMark[];
|
|
653
|
+
text: string;
|
|
654
|
+
type: typeof MAILY_NODE_TYPES.TEXT;
|
|
666
655
|
};
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
656
|
+
type VariableAttributes = WithExtraAttrs & {
|
|
657
|
+
fallback?: string | null;
|
|
658
|
+
/** @deprecated Use `isDefaultEditable` instead. */
|
|
659
|
+
hideDefaultValue?: boolean;
|
|
660
|
+
id: string;
|
|
661
|
+
isDefaultEditable?: boolean;
|
|
662
|
+
label?: string | null;
|
|
663
|
+
required?: boolean;
|
|
664
|
+
style?: string | null;
|
|
671
665
|
};
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
666
|
+
declare const DEFAULT_VARIABLE_ATTRIBUTES: {
|
|
667
|
+
fallback: null;
|
|
668
|
+
isDefaultEditable: true;
|
|
669
|
+
label: null;
|
|
670
|
+
required: true;
|
|
671
|
+
style: null;
|
|
676
672
|
};
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
verticalAlign: 'top' | 'middle' | 'bottom';
|
|
673
|
+
type VariableNode = BaseMailyNode & {
|
|
674
|
+
attrs: VariableAttributes;
|
|
675
|
+
type: typeof MAILY_NODE_TYPES.VARIABLE;
|
|
681
676
|
};
|
|
682
|
-
type
|
|
683
|
-
|
|
684
|
-
|
|
677
|
+
type TableAttributes = {
|
|
678
|
+
border?: number;
|
|
679
|
+
cellpadding?: number;
|
|
680
|
+
cellspacing?: number;
|
|
681
|
+
responsive: boolean;
|
|
682
|
+
style?: string | null;
|
|
683
|
+
};
|
|
684
|
+
type TableNode = BaseMailyNode & {
|
|
685
|
+
attrs: TableAttributes;
|
|
686
|
+
content: TableRowNode[];
|
|
687
|
+
type: typeof MAILY_NODE_TYPES.TABLE;
|
|
688
|
+
};
|
|
689
|
+
type TableRowAttributes = {
|
|
690
|
+
style?: string | null;
|
|
691
|
+
};
|
|
692
|
+
type TableRowNode = BaseMailyNode & {
|
|
693
|
+
attrs?: TableRowAttributes;
|
|
694
|
+
content: (TableCellNode | TableHeaderNode)[];
|
|
695
|
+
type: typeof MAILY_NODE_TYPES.TABLE_ROW;
|
|
696
|
+
};
|
|
697
|
+
type TableCellAttributes = {
|
|
698
|
+
colspan: number;
|
|
699
|
+
colwidth: number[] | null;
|
|
700
|
+
rowspan: number;
|
|
701
|
+
style?: string | null;
|
|
702
|
+
};
|
|
703
|
+
type TableCellNode = BaseMailyNode & {
|
|
704
|
+
attrs: TableCellAttributes;
|
|
685
705
|
content: AnyMailyNode[];
|
|
706
|
+
type: typeof MAILY_NODE_TYPES.TABLE_CELL;
|
|
686
707
|
};
|
|
687
|
-
|
|
688
|
-
type
|
|
689
|
-
|
|
690
|
-
content:
|
|
691
|
-
|
|
692
|
-
/** Footer */
|
|
693
|
-
type FooterAttributes = {
|
|
694
|
-
id: string;
|
|
695
|
-
textAlign: AllowedTextAlignment;
|
|
696
|
-
} & FontStyleAttributes;
|
|
697
|
-
type FooterNode = BaseMailyNode & {
|
|
698
|
-
type: typeof MAILY_NODE_TYPES.FOOTER;
|
|
699
|
-
attrs: FooterAttributes;
|
|
700
|
-
};
|
|
701
|
-
/** Inline Image */
|
|
702
|
-
type InlineImageAttributes = {
|
|
703
|
-
src: string;
|
|
704
|
-
alt?: string;
|
|
705
|
-
title?: string;
|
|
706
|
-
width: number;
|
|
707
|
-
height: number;
|
|
708
|
-
externalLink: string | null;
|
|
709
|
-
};
|
|
710
|
-
type InlineImageNode = BaseMailyNode & {
|
|
711
|
-
type: typeof MAILY_NODE_TYPES.INLINE_IMAGE;
|
|
712
|
-
attrs: InlineImageAttributes;
|
|
713
|
-
content: never;
|
|
708
|
+
type TableHeaderAttributes = TableCellAttributes;
|
|
709
|
+
type TableHeaderNode = BaseMailyNode & {
|
|
710
|
+
attrs: TableHeaderAttributes;
|
|
711
|
+
content: AnyMailyNode[];
|
|
712
|
+
type: typeof MAILY_NODE_TYPES.TABLE_HEADER;
|
|
714
713
|
};
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
title: string;
|
|
714
|
+
type LinkCardAttributes = WithExtraAttrs & WithVisibilityAttrs & {
|
|
715
|
+
badgeText: string;
|
|
718
716
|
description: string;
|
|
717
|
+
image: string;
|
|
719
718
|
link: string;
|
|
720
719
|
linkTitle: string;
|
|
721
|
-
|
|
720
|
+
style?: string | null;
|
|
722
721
|
subTitle: string;
|
|
723
|
-
|
|
722
|
+
title: string;
|
|
724
723
|
};
|
|
725
724
|
type LinkCardNode = BaseMailyNode & {
|
|
726
|
-
type: typeof MAILY_NODE_TYPES.LINK_CARD;
|
|
727
725
|
attrs: LinkCardAttributes;
|
|
728
|
-
|
|
726
|
+
type: typeof MAILY_NODE_TYPES.LINK_CARD;
|
|
729
727
|
};
|
|
730
|
-
type AnyMailyNode =
|
|
731
|
-
//#endregion
|
|
732
|
-
//#region src/theme.d.ts
|
|
733
|
-
/**
|
|
734
|
-
* Shared theme properties used by both the editor and renderer.
|
|
735
|
-
* Controls global styling for the body, container, buttons, links,
|
|
736
|
-
* and font. Extended by EditorThemeOptions and RendererThemeOptions.
|
|
737
|
-
*/
|
|
738
|
-
interface BaseThemeOptions {
|
|
739
|
-
container?: Partial<{
|
|
740
|
-
backgroundColor: string;
|
|
741
|
-
maxWidth: number;
|
|
742
|
-
minWidth: number;
|
|
743
|
-
borderRadius: number;
|
|
744
|
-
borderWidth: number;
|
|
745
|
-
borderColor: string;
|
|
746
|
-
paddingTop: number;
|
|
747
|
-
paddingRight: number;
|
|
748
|
-
paddingBottom: number;
|
|
749
|
-
paddingLeft: number;
|
|
750
|
-
}>;
|
|
751
|
-
body?: Partial<{
|
|
752
|
-
backgroundColor: string;
|
|
753
|
-
paddingTop: number;
|
|
754
|
-
paddingRight: number;
|
|
755
|
-
paddingBottom: number;
|
|
756
|
-
paddingLeft: number;
|
|
757
|
-
}>;
|
|
758
|
-
button?: Partial<{
|
|
759
|
-
paddingTop: number;
|
|
760
|
-
paddingRight: number;
|
|
761
|
-
paddingBottom: number;
|
|
762
|
-
paddingLeft: number;
|
|
763
|
-
backgroundColor: string;
|
|
764
|
-
color: string;
|
|
765
|
-
}>;
|
|
766
|
-
link?: Partial<{
|
|
767
|
-
color: string;
|
|
768
|
-
}>;
|
|
769
|
-
font?: Pick<FontProps, 'fontFamily' | 'fallbackFontFamily' | 'webFont'> | null;
|
|
770
|
-
listMarker?: Partial<{
|
|
771
|
-
color: string;
|
|
772
|
-
}>;
|
|
773
|
-
}
|
|
774
|
-
/**
|
|
775
|
-
* Editor-specific theme. Currently identical to the base — the editor
|
|
776
|
-
* does not yet support per-node color customization, which is why
|
|
777
|
-
* it's kept separate from the renderer theme.
|
|
778
|
-
*/
|
|
779
|
-
interface EditorThemeOptions extends BaseThemeOptions {}
|
|
780
|
-
/** Per-node styling overrides in the renderer theme. */
|
|
781
|
-
type NodeThemeEntry = Partial<{
|
|
782
|
-
color: string;
|
|
783
|
-
fontSize: number;
|
|
784
|
-
lineHeight: number;
|
|
785
|
-
fontWeight: number;
|
|
786
|
-
}>;
|
|
787
|
-
type HeadingLevelTheme = Partial<{
|
|
788
|
-
fontSize: number;
|
|
789
|
-
lineHeight: number;
|
|
790
|
-
fontWeight: number;
|
|
791
|
-
}>;
|
|
792
|
-
/**
|
|
793
|
-
* Renderer-specific theme. Extends the base with per-node styling
|
|
794
|
-
* grouped by node type — each key corresponds to a node and contains
|
|
795
|
-
* all relevant style properties for that node.
|
|
796
|
-
*/
|
|
797
|
-
interface RendererThemeOptions extends BaseThemeOptions {
|
|
798
|
-
paragraph?: NodeThemeEntry;
|
|
799
|
-
heading?: Partial<{
|
|
800
|
-
defaults: Partial<{
|
|
801
|
-
color: string;
|
|
802
|
-
}>;
|
|
803
|
-
h1: HeadingLevelTheme;
|
|
804
|
-
h2: HeadingLevelTheme;
|
|
805
|
-
h3: HeadingLevelTheme;
|
|
806
|
-
}>;
|
|
807
|
-
footer?: NodeThemeEntry;
|
|
808
|
-
blockquote?: NodeThemeEntry & Partial<{
|
|
809
|
-
borderColor: string;
|
|
810
|
-
fontStyle: FontStyleValue;
|
|
811
|
-
}>;
|
|
812
|
-
horizontalRule?: Partial<{
|
|
813
|
-
color: string;
|
|
814
|
-
}>;
|
|
815
|
-
code?: Partial<{
|
|
816
|
-
color: string;
|
|
817
|
-
backgroundColor: string;
|
|
818
|
-
}>;
|
|
819
|
-
button?: BaseThemeOptions['button'] & Partial<{
|
|
820
|
-
fontSize: number;
|
|
821
|
-
lineHeight: number;
|
|
822
|
-
fontWeight: number;
|
|
823
|
-
}>;
|
|
824
|
-
linkCard?: Partial<{
|
|
825
|
-
titleColor: string;
|
|
826
|
-
descriptionColor: string;
|
|
827
|
-
badgeTextColor: string;
|
|
828
|
-
badgeBackgroundColor: string;
|
|
829
|
-
subTitleColor: string;
|
|
830
|
-
borderColor: string;
|
|
831
|
-
}>;
|
|
832
|
-
}
|
|
833
|
-
declare const DEFAULT_LINK_TEXT_COLOR = "#111827";
|
|
834
|
-
declare const DEFAULT_RENDERER_THEME: RendererThemeOptions;
|
|
835
|
-
declare const DEFAULT_EDITOR_THEME: EditorThemeOptions;
|
|
836
|
-
/**
|
|
837
|
-
* Resolves the baseline font defaults for a node type from the
|
|
838
|
-
* renderer theme. Falls back to paragraph defaults for unknown types.
|
|
839
|
-
*/
|
|
840
|
-
declare function getNodeFontStyleDefaults(nodeType: string, level?: HeadingLevel): NodeFontStyleDefaults;
|
|
841
|
-
//#endregion
|
|
842
|
-
//#region src/css-variables.d.ts
|
|
843
|
-
declare module 'csstype' {
|
|
844
|
-
interface Properties {
|
|
845
|
-
[index: `--mly-${string}`]: any;
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
/**
|
|
849
|
-
* Returns a CSS variable object for the given name and value.
|
|
850
|
-
* If the value is nullish or empty, returns an empty object so that
|
|
851
|
-
* the default CSS variable value is not overridden. Numbers are
|
|
852
|
-
* automatically suffixed with "px".
|
|
853
|
-
*/
|
|
854
|
-
declare function getVariableValue(name: `--mly-${string}`, value: unknown): Properties;
|
|
855
|
-
/**
|
|
856
|
-
* Converts an EditorThemeOptions object into a flat map of Maily CSS
|
|
857
|
-
* custom properties (--mly-*). Used to apply theme overrides as inline
|
|
858
|
-
* styles on the editor or renderer root element. Covers body background,
|
|
859
|
-
* container dimensions and borders, button colors, link color, and
|
|
860
|
-
* font family settings.
|
|
861
|
-
*/
|
|
862
|
-
declare function getMailyCssVariables(theme: EditorThemeOptions): Properties;
|
|
863
|
-
//#endregion
|
|
864
|
-
//#region src/image-width.d.ts
|
|
865
|
-
/**
|
|
866
|
-
* Represents an image width value — can be a pixel number, a percentage
|
|
867
|
-
* string (e.g. "50%"), or the literal "auto" for full-width.
|
|
868
|
-
*/
|
|
869
|
-
type ImageWidth = number | string;
|
|
870
|
-
declare const MIN_IMAGE_WIDTH_PERCENTAGE = 5;
|
|
871
|
-
declare const MAX_IMAGE_WIDTH_PERCENTAGE = 100;
|
|
872
|
-
/**
|
|
873
|
-
* Converts any ImageWidth value to a clamped percentage number.
|
|
874
|
-
* Handles "auto" (→ 100), percentage strings (e.g. "50%" → 50),
|
|
875
|
-
* and legacy pixel numbers (converted relative to maxWidthPixels).
|
|
876
|
-
* Returns 100 for null or unrecognized values.
|
|
877
|
-
*/
|
|
878
|
-
declare function parseWidthToPercentage(width: ImageWidth | null, maxWidthPixels?: number): number;
|
|
879
|
-
declare function clampImageWidthPercentage(width: number): number;
|
|
880
|
-
//#endregion
|
|
881
|
-
//#region src/function.d.ts
|
|
882
|
-
type Noop = () => void;
|
|
883
|
-
/** A no-operation function. Useful as a default callback or placeholder. */
|
|
884
|
-
declare function noop(): void;
|
|
885
|
-
//#endregion
|
|
886
|
-
//#region src/invariant.d.ts
|
|
887
|
-
/**
|
|
888
|
-
* Assertion function that throws if the value is false, null, or undefined.
|
|
889
|
-
* Used as a development-time guard to catch impossible states early.
|
|
890
|
-
* Logs a bug report URL before throwing to help with issue filing.
|
|
891
|
-
*/
|
|
892
|
-
declare function invariant(value: boolean, message?: string): asserts value;
|
|
893
|
-
declare function invariant<T>(value: T | null | undefined, message?: string): asserts value is T;
|
|
728
|
+
type AnyMailyNode = BodyNode | ContainerNode | BlockquoteNode | ButtonNode | ColumnNode | ColumnsNode | BulletListNode | DocumentNode | FooterNode | HardBreakNode | HeadingNode | ImageNode | InlineImageNode | InlineSpanNode | HorizontalRuleNode | HtmlCodeBlockNode | LinkCardNode | ListItemNode | OrderedListNode | ParagraphNode | RepeatNode | SectionNode | DivNode | SpacerNode | TableCellNode | TableHeaderNode | TableNode | TableRowNode | TextNode | VariableNode;
|
|
894
729
|
//#endregion
|
|
895
730
|
//#region src/is.d.ts
|
|
896
|
-
|
|
897
|
-
* Type guards for Maily nodes and marks. Provides narrowing functions
|
|
898
|
-
* for every node type (is.paragraph, is.button, etc.) and mark type
|
|
899
|
-
* (is.bold, is.link, etc.), plus structural checks like is.parent
|
|
900
|
-
* and is.marked. Each guard narrows the input to its specific type.
|
|
901
|
-
*
|
|
902
|
-
* Example:
|
|
903
|
-
* if (is.paragraph(node)) {
|
|
904
|
-
* node.attrs.textAlign // narrowed to ParagraphNode
|
|
905
|
-
* }
|
|
906
|
-
*/
|
|
731
|
+
declare function isObject(val: unknown): val is object;
|
|
907
732
|
declare const is: {
|
|
908
|
-
|
|
733
|
+
node(value: unknown): value is AnyMailyNode;
|
|
734
|
+
mark(value: unknown): value is AnyMailyMark;
|
|
909
735
|
parent(node: AnyMailyNode): node is AnyMailyNode & {
|
|
910
736
|
content: AnyMailyNode[];
|
|
911
737
|
};
|
|
912
738
|
marked(node: AnyMailyNode): node is AnyMailyNode & {
|
|
913
739
|
marks: AnyMailyMark[];
|
|
914
740
|
};
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
htmlCodeBlock: (
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
declare function
|
|
956
|
-
/** Type guard that checks if a value is a non-null object. */
|
|
957
|
-
declare function isObject(val: unknown): val is object;
|
|
741
|
+
doc: (value: AnyMailyNode | AnyMailyMark) => value is DocumentNode;
|
|
742
|
+
body: (value: AnyMailyNode | AnyMailyMark) => value is BodyNode;
|
|
743
|
+
container: (value: AnyMailyNode | AnyMailyMark) => value is ContainerNode;
|
|
744
|
+
section: (value: AnyMailyNode | AnyMailyMark) => value is SectionNode;
|
|
745
|
+
div: (value: AnyMailyNode | AnyMailyMark) => value is DivNode;
|
|
746
|
+
columns: (value: AnyMailyNode | AnyMailyMark) => value is ColumnsNode;
|
|
747
|
+
column: (value: AnyMailyNode | AnyMailyMark) => value is ColumnNode;
|
|
748
|
+
image: (value: AnyMailyNode | AnyMailyMark) => value is ImageNode;
|
|
749
|
+
inlineImage: (value: AnyMailyNode | AnyMailyMark) => value is InlineImageNode;
|
|
750
|
+
inlineSpan: (value: AnyMailyNode | AnyMailyMark) => value is InlineSpanNode;
|
|
751
|
+
spacer: (value: AnyMailyNode | AnyMailyMark) => value is SpacerNode;
|
|
752
|
+
button: (value: AnyMailyNode | AnyMailyMark) => value is ButtonNode;
|
|
753
|
+
footer: (value: AnyMailyNode | AnyMailyMark) => value is FooterNode;
|
|
754
|
+
paragraph: (value: AnyMailyNode | AnyMailyMark) => value is ParagraphNode;
|
|
755
|
+
heading: (value: AnyMailyNode | AnyMailyMark) => value is HeadingNode;
|
|
756
|
+
blockquote: (value: AnyMailyNode | AnyMailyMark) => value is BlockquoteNode;
|
|
757
|
+
horizontalRule: (value: AnyMailyNode | AnyMailyMark) => value is HorizontalRuleNode;
|
|
758
|
+
hardBreak: (value: AnyMailyNode | AnyMailyMark) => value is HardBreakNode;
|
|
759
|
+
htmlCodeBlock: (value: AnyMailyNode | AnyMailyMark) => value is HtmlCodeBlockNode;
|
|
760
|
+
repeat: (value: AnyMailyNode | AnyMailyMark) => value is RepeatNode;
|
|
761
|
+
bulletList: (value: AnyMailyNode | AnyMailyMark) => value is BulletListNode;
|
|
762
|
+
orderedList: (value: AnyMailyNode | AnyMailyMark) => value is OrderedListNode;
|
|
763
|
+
listItem: (value: AnyMailyNode | AnyMailyMark) => value is ListItemNode;
|
|
764
|
+
linkCard: (value: AnyMailyNode | AnyMailyMark) => value is LinkCardNode;
|
|
765
|
+
text: (value: AnyMailyNode | AnyMailyMark) => value is TextNode;
|
|
766
|
+
variable: (value: AnyMailyNode | AnyMailyMark) => value is VariableNode;
|
|
767
|
+
table: (value: AnyMailyNode | AnyMailyMark) => value is TableNode;
|
|
768
|
+
tableRow: (value: AnyMailyNode | AnyMailyMark) => value is TableRowNode;
|
|
769
|
+
tableCell: (value: AnyMailyNode | AnyMailyMark) => value is TableCellNode;
|
|
770
|
+
tableHeader: (value: AnyMailyNode | AnyMailyMark) => value is TableHeaderNode;
|
|
771
|
+
bold: (value: AnyMailyNode | AnyMailyMark) => value is BoldMark;
|
|
772
|
+
italic: (value: AnyMailyNode | AnyMailyMark) => value is ItalicMark;
|
|
773
|
+
strike: (value: AnyMailyNode | AnyMailyMark) => value is StrikeMark;
|
|
774
|
+
underline: (value: AnyMailyNode | AnyMailyMark) => value is UnderlineMark;
|
|
775
|
+
link: (value: AnyMailyNode | AnyMailyMark) => value is LinkMark;
|
|
776
|
+
code: (value: AnyMailyNode | AnyMailyMark) => value is CodeMark;
|
|
777
|
+
textStyle: (value: AnyMailyNode | AnyMailyMark) => value is TextStyleMark;
|
|
778
|
+
highlight: (value: AnyMailyNode | AnyMailyMark) => value is HighlightMark;
|
|
779
|
+
span: (value: AnyMailyNode | AnyMailyMark) => value is SpanMark;
|
|
780
|
+
};
|
|
781
|
+
declare function isDef<T>(value: T | null | undefined): value is T;
|
|
958
782
|
//#endregion
|
|
959
783
|
//#region src/math.d.ts
|
|
960
784
|
declare function clamp(value: number, [min, max]: [number, number]): number;
|
|
961
785
|
declare function percentage(portion: number, total: number): number;
|
|
962
|
-
declare function absoluteFromPercentage(percentage: number, total: number): number;
|
|
963
786
|
declare function roundTo(value: number, decimals: number): number;
|
|
787
|
+
declare function absoluteFromPercentage(percentage: number, total: number): number;
|
|
964
788
|
//#endregion
|
|
965
789
|
//#region src/object.d.ts
|
|
790
|
+
declare function isMergeableObject(value: unknown): value is Record<string, unknown>;
|
|
966
791
|
/**
|
|
967
792
|
* One-level deep merge of plain objects. Nested plain objects are
|
|
968
793
|
* shallow-merged; primitives, arrays, and null are replaced outright.
|
|
@@ -973,47 +798,33 @@ declare function roundTo(value: number, decimals: number): number;
|
|
|
973
798
|
* // => { a: 1, nested: { x: 1, y: 3 } }
|
|
974
799
|
*/
|
|
975
800
|
declare function deepMerge<T extends object>(target: T, ...sources: Partial<T>[]): T;
|
|
976
|
-
declare function isObjectDeepEqual(first: object, second: object): boolean;
|
|
977
801
|
//#endregion
|
|
978
|
-
//#region src/
|
|
979
|
-
|
|
980
|
-
declare
|
|
802
|
+
//#region src/spacing.d.ts
|
|
803
|
+
declare const BLOCK_CONTAINER_TYPES: string[];
|
|
804
|
+
declare const MARGIN_TOP_ABSORBER_TYPES: string[];
|
|
805
|
+
declare const MARGIN_BOTTOM_ABSORBER_TYPES: string[];
|
|
806
|
+
type NodePosition = {
|
|
807
|
+
isFirst: boolean;
|
|
808
|
+
isLast: boolean;
|
|
809
|
+
nextType?: string | undefined;
|
|
810
|
+
parentType?: string | undefined;
|
|
811
|
+
previousType?: string | undefined;
|
|
812
|
+
};
|
|
813
|
+
declare function getSuppressedMargins(position: NodePosition): {
|
|
814
|
+
marginBottom: boolean;
|
|
815
|
+
marginTop: boolean;
|
|
816
|
+
};
|
|
981
817
|
//#endregion
|
|
982
818
|
//#region src/variable.d.ts
|
|
983
|
-
/** Default opening delimiter for variable placeholders in text. */
|
|
984
819
|
declare const DEFAULT_VARIABLE_START_TRIGGER = "{{";
|
|
985
|
-
/** Default closing delimiter for variable placeholders in text. */
|
|
986
820
|
declare const DEFAULT_VARIABLE_END_TRIGGER = "}}";
|
|
987
|
-
/**
|
|
988
|
-
* Regex that matches variable placeholders like {{name}} in a string.
|
|
989
|
-
* Uses a non-greedy match to handle multiple variables in one string.
|
|
990
|
-
*/
|
|
991
|
-
declare const VARIABLE_PLACEHOLDER_REGEX: RegExp;
|
|
992
|
-
/**
|
|
993
|
-
* Delimiter used between fields inside a serialized variable string.
|
|
994
|
-
* Format: {{id|label|required|hideDefaultValue}}.
|
|
995
|
-
*/
|
|
996
|
-
declare const VARIABLE_TEXT_DELIMITER = "|";
|
|
997
|
-
/**
|
|
998
|
-
* Serializes a variable node's attributes into a delimited string.
|
|
999
|
-
* Output format: `{{id|label|required|hideDefaultValue}}`.
|
|
1000
|
-
* Used to represent structured variable data as a template string
|
|
1001
|
-
* in plain text contexts.
|
|
1002
|
-
*/
|
|
1003
821
|
declare function serializeVariableToText(variable: VariableAttributes): string;
|
|
1004
|
-
/**
|
|
1005
|
-
* Deserializes a variable string back into VariableAttributes.
|
|
1006
|
-
* Expected input format: `{{id|label|required|hideDefaultValue}}`.
|
|
1007
|
-
* Missing fields default to undefined; boolean fields are parsed
|
|
1008
|
-
* from "true"/"false" strings.
|
|
1009
|
-
*/
|
|
1010
822
|
declare function deserializeVariableFromText(text: string): VariableAttributes;
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
*/
|
|
823
|
+
type VariableSegment = {
|
|
824
|
+
isReference: boolean;
|
|
825
|
+
text: string;
|
|
826
|
+
};
|
|
827
|
+
declare function getVariableSegments(content: string): VariableSegment[];
|
|
1017
828
|
declare function buildDocFromVariableText(content: string): {
|
|
1018
829
|
type: "doc";
|
|
1019
830
|
content: {
|
|
@@ -1029,12 +840,7 @@ declare function buildDocFromVariableText(content: string): {
|
|
|
1029
840
|
})[];
|
|
1030
841
|
}[];
|
|
1031
842
|
};
|
|
1032
|
-
/**
|
|
1033
|
-
* Checks if a string contains at least one variable placeholder.
|
|
1034
|
-
* Returns true for strings like "Hello {{name}}", false for plain text.
|
|
1035
|
-
* Uses index-based scanning instead of regex for performance.
|
|
1036
|
-
*/
|
|
1037
843
|
declare function hasVariableInText(text: string): boolean;
|
|
1038
844
|
//#endregion
|
|
1039
|
-
export { AllowedBorderStyle, AllowedButtonKind,
|
|
845
|
+
export { AllowedBorderStyle, AllowedButtonKind, AllowedHtmlCodeBlockTab, AllowedTextAlignment, AllowedVisibilityAction, AllowedVisibilityOperator, AnyMailyMark, AnyMailyNode, BASIC_NODE_THEME, BLOCK_CONTAINER_TYPES, BORDER_STYLES, BOX_CORNERS, BOX_SIDES, BUTTON_KINDS, BaseMailyMark, BaseMailyNode, BlockquoteAttributes, BlockquoteNode, BodyAttributes, BodyNode, BoldMark, BorderParts, BoxCorner, BoxCornerValues, BoxSide, BoxSideValues, BulletListAttributes, BulletListNode, ButtonAttributes, ButtonNode, CodeMark, ColumnAttributes, ColumnNode, ColumnWidth, ColumnsAttributes, ColumnsNode, ContainerAttributes, ContainerNode, DATA_NODE_TYPE_KEY, DEFAULT_BORDER_STYLE, DEFAULT_BUTTON_KIND, DEFAULT_CONTAINER_MAX_WIDTH, DEFAULT_CONTAINER_WIDTH_PIXELS, DEFAULT_FONT, DEFAULT_FONT_FALLBACK, DEFAULT_FONT_FAMILIES, DEFAULT_FONT_FAMILY, DEFAULT_HTML_CODE_BLOCK_TAB, DEFAULT_TEXT_ALIGN, DEFAULT_TEXT_DIRECTION, DEFAULT_VARIABLE_ATTRIBUTES, DEFAULT_VARIABLE_END_TRIGGER, DEFAULT_VARIABLE_START_TRIGGER, DEFAULT_VISIBILITY_RULE, DivAttributes, DivNode, DocumentAttributes, DocumentNode, ExtendNodeThemeOptions, FONT_SIZE_PRESETS, FONT_STYLES, FONT_WEIGHTS, FallbackFont, FontFamily, FontFamilyItem, FontFamilyValueOptions, FontFormat, FontProps, FontStyleValue, FontWeight, FooterAttributes, FooterNode, HTML_CODE_BLOCK_TABS, HardBreakNode, HeadingAttributes, HeadingLevel, HeadingNode, HighlightAttributes, HighlightMark, HorizontalRuleAttributes, HorizontalRuleNode, HtmlCodeBlockAttributes, HtmlCodeBlockNode, ImageAttributes, ImageNode, ImageWidth, InlineImageAttributes, InlineImageNode, InlineSpanAttributes, InlineSpanNode, InlineStyle, ItalicMark, LINE_HEIGHT_PRESETS, LinkAttributes, LinkCardAttributes, LinkCardNode, LinkMark, ListItemAttributes, ListItemNode, MAILY_BUG_REPORT_URL, MAILY_ERROR_PREFIX, MAILY_EXTENSION_TYPES, MAILY_MARK_TYPES, MAILY_NODE_THEME, MAILY_NODE_TYPES, MARGIN_BOTTOM_ABSORBER_TYPES, MARGIN_TOP_ABSORBER_TYPES, MAX_IMAGE_WIDTH_PERCENTAGE, MIN_IMAGE_WIDTH_PERCENTAGE, MailyMarkType, MailyNodeType, MarkStyleAttributes, NodePosition, NodeThemeOptions, OrderedListAttributes, OrderedListNode, ParagraphAttributes, ParagraphNode, RepeatAttributes, RepeatNode, SectionAttributes, SectionNode, SpacerAttributes, SpacerNode, SpanMark, StrikeMark, TEXT_ALIGNMENTS, TEXT_DIRECTIONS, TableAttributes, TableCellAttributes, TableCellNode, TableHeaderAttributes, TableHeaderNode, TableNode, TableRowAttributes, TableRowNode, TextDirection, TextNode, TextStyleAttributes, TextStyleMark, ThemeDeclarationsOptions, UnderlineMark, VISIBILITY_ACTIONS, VISIBILITY_ACTION_OPTIONS, VISIBILITY_OPERATORS, VISIBILITY_OPERATOR_OPTIONS, VariableAttributes, VariableNode, VisibilityRule, WithExtraAttrs, WithVisibilityAttrs, absoluteFromPercentage, allowedFallbackFonts, allowedMarkTypes, allowedNodeTypes, buildDocFromVariableText, clamp, clampImageWidthPercentage, deepMerge, deserializeVariableFromText, expandInlineStyles, extendNodeTheme, getBorderParts, getBoxCorners, getBoxSides, getColumnWidth, getColumnWidthPercent, getColumnWidthValue, getCssDirection, getFontFaceStyle, getFontFamilyNames, getFontFamilyValue, getSuppressedMargins, getThemeDeclarations, getVariableSegments, getVisibilityRule, getVisibilityValueSupport, hasVariableInText, invariant, is, isAllowedBorderStyle, isAllowedButtonKind, isAllowedTextAlignment, isDef, isMergeableObject, isObject, loadFont, mergeInlineStyles, noop, parseInlineStyles, parseWidthToPercentage, percentage, roundTo, serializeVariableToText, stringifyInlineStyles, toBoxCorners, toBoxSides };
|
|
1040
846
|
//# sourceMappingURL=index.d.cts.map
|