@maily-to/shared 0.0.2 → 2.0.0-beta.2

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.d.mts CHANGED
@@ -1,114 +1,1040 @@
1
- import * as CSS$1 from "csstype";
2
- import * as CSS from "csstype";
1
+ import { Properties } from "csstype";
3
2
 
4
- //#region src/theme.d.ts
5
- declare const allowedFallbackFonts: readonly ["Arial", "Helvetica", "Verdana", "Georgia", "Times New Roman", "serif", "sans-serif", "monospace", "cursive", "fantasy"];
3
+ //#region src/alignment.d.ts
4
+ declare const TEXT_ALIGNMENTS: {
5
+ readonly LEFT: 'left';
6
+ readonly CENTER: 'center';
7
+ readonly RIGHT: 'right';
8
+ };
9
+ type AllowedTextAlignment = (typeof TEXT_ALIGNMENTS)[keyof typeof TEXT_ALIGNMENTS];
10
+ declare const allowedTextAligns: readonly AllowedTextAlignment[];
11
+ declare const DEFAULT_TEXT_ALIGN: AllowedTextAlignment;
12
+ declare function isAllowedTextAlignment(value: unknown): value is AllowedTextAlignment;
13
+ //#endregion
14
+ //#region src/field-mode.d.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
+ 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;
30
+ //#endregion
31
+ //#region src/border.d.ts
32
+ declare const BORDER_STYLES: {
33
+ readonly SOLID: 'solid';
34
+ readonly DASHED: 'dashed';
35
+ readonly DOTTED: 'dotted';
36
+ };
37
+ type AllowedBorderStyle = (typeof BORDER_STYLES)[keyof typeof BORDER_STYLES];
38
+ declare const DEFAULT_BORDER_STYLE: AllowedBorderStyle;
39
+ declare const DEFAULT_BORDER_COLOR = "#000000";
40
+ /**
41
+ * Full border configuration for a node. Includes border style, color,
42
+ * per-side widths (top/right/bottom/left), per-corner radii, and
43
+ * field modes that control whether each group is edited uniformly
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;
59
+ };
60
+ /**
61
+ * Converts a BorderStyleConfig into CSS properties for inline styles.
62
+ * When all widths or radii are equal (or the mode is "uniform"), emits
63
+ * shorthand CSS; otherwise emits per-side longhand properties.
64
+ */
65
+ declare function getBorderStyle(config: BorderStyleConfig): Properties;
66
+ //#endregion
67
+ //#region src/button-kind.d.ts
68
+ /**
69
+ * Button layout kinds.
70
+ * "tight" renders the button at its content width,
71
+ * "full-width" stretches it to fill the container.
72
+ */
73
+ declare const BUTTON_KINDS: {
74
+ readonly TIGHT: 'tight';
75
+ readonly FULL_WIDTH: 'full-width';
76
+ };
77
+ type AllowedButtonKind = (typeof BUTTON_KINDS)[keyof typeof BUTTON_KINDS];
78
+ declare const allowedButtonKinds: readonly AllowedButtonKind[];
79
+ declare const DEFAULT_BUTTON_KIND: AllowedButtonKind;
80
+ declare function isAllowedButtonKind(value: unknown): value is AllowedButtonKind;
81
+ //#endregion
82
+ //#region src/constants.d.ts
83
+ /** HTML data attribute key used to identify node types in rendered output. */
84
+ 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
+ declare const MAILY_ERROR_PREFIX = "[Maily Error]";
89
+ /** URL for filing bug reports against the Maily repository. */
90
+ declare const MAILY_BUG_REPORT_URL = "https://github.com/arikchakma/maily.to/issues/new";
91
+ //#endregion
92
+ //#region src/font.d.ts
93
+ /**
94
+ * List of allowed fallback font families. These are system fonts or
95
+ * generic font families that serve as fallbacks when a web font
96
+ * fails to load.
97
+ */
98
+ declare const allowedFallbackFonts: readonly ['Arial', 'Helvetica', 'Verdana', 'Georgia', 'Times New Roman', 'serif', 'sans-serif', 'monospace', 'cursive', 'fantasy'];
6
99
  type FallbackFont = (typeof allowedFallbackFonts)[number];
7
- declare const allowedFontFormats: readonly ["woff", "woff2", "truetype", "opentype", "embedded-opentype", "svg"];
100
+ declare const allowedFontFormats: readonly ['woff', 'woff2', 'truetype', 'opentype', 'embedded-opentype', 'svg'];
8
101
  type FontFormat = (typeof allowedFontFormats)[number];
9
- type FontWeight = CSS$1.Properties["fontWeight"];
10
- type FontStyle = CSS$1.Properties["fontStyle"];
102
+ type FontStyle = Properties['fontStyle'];
103
+ /**
104
+ * Configuration for a font used in the editor or renderer.
105
+ * Specifies the primary font family, a fallback, and an optional
106
+ * web font URL with its format for @font-face loading.
107
+ */
11
108
  interface FontProps {
12
- /** The font you want to use. NOTE: Do not insert multiple fonts here, use fallbackFontFamily for that */
13
109
  fontFamily: string;
14
- /** An array is possible, but the order of the array is the priority order */
15
110
  fallbackFontFamily: FallbackFont;
16
- /** Not all clients support web fonts. For support check: https://www.caniemail.com/features/css-at-font-face/ */
17
111
  webFont?: {
18
112
  url: string;
19
113
  format: FontFormat;
20
114
  };
21
- /** Default: 'normal' */
22
115
  fontStyle?: FontStyle;
23
- /** Default: 400 */
24
- fontWeight?: FontWeight;
116
+ fontWeight?: number;
25
117
  }
118
+ /**
119
+ * Default font configuration: Inter with sans-serif fallback,
120
+ * loaded from the Maily CDN as woff2.
121
+ */
122
+ declare const DEFAULT_FONT: FontProps;
123
+ /**
124
+ * Injects a @font-face style element into the document head to load
125
+ * the given font. Only works in browser environments.
126
+ */
127
+ declare function loadFont(font: FontProps): void;
128
+ /**
129
+ * Generates a @font-face CSS rule string for the given font configuration.
130
+ * Includes the font family, style, weight, MSO fallback, and web font
131
+ * source URL when available.
132
+ */
133
+ declare function getFontFaceStyle(font: FontProps): string;
134
+ //#endregion
135
+ //#region src/font-weight.d.ts
136
+ /**
137
+ * Numeric font weight values mapped to semantic names.
138
+ * Normal (400), Medium (500), Semibold (600), Bold (700), Extra Bold (800).
139
+ */
140
+ declare const FONT_WEIGHTS: {
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];
148
+ //#endregion
149
+ //#region src/font-style.d.ts
150
+ /**
151
+ * Entry for the font picker dropdown. Web fonts include a CDN URL
152
+ * and format for @font-face loading; system fonts omit the webFont field.
153
+ */
154
+ type FontFamilyItem = {
155
+ fontFamily: string;
156
+ label?: string;
157
+ webFont?: {
158
+ url: string;
159
+ format: FontFormat;
160
+ };
161
+ };
162
+ /**
163
+ * Built-in font options served from the Maily CDN. System fonts
164
+ * (Arial, Helvetica, etc.) are included without a webFont field.
165
+ */
166
+ declare const DEFAULT_FONT_FAMILIES: FontFamilyItem[];
167
+ type FontFamily = string;
168
+ declare const FONT_STYLES: {
169
+ readonly NORMAL: 'normal';
170
+ readonly ITALIC: 'italic';
171
+ };
172
+ type FontStyleValue = (typeof FONT_STYLES)[keyof typeof FONT_STYLES];
173
+ /** Preset options for the font size dropdown in the editor. */
174
+ declare const FONT_SIZE_PRESETS: readonly [{
175
+ readonly value: 12;
176
+ readonly label: 'Small';
177
+ }, {
178
+ readonly value: 14;
179
+ readonly label: 'Normal';
180
+ }, {
181
+ readonly value: 16;
182
+ readonly label: 'Medium';
183
+ }, {
184
+ readonly value: 18;
185
+ readonly label: 'Large';
186
+ }, {
187
+ readonly value: 24;
188
+ readonly label: 'XL';
189
+ }, {
190
+ readonly value: 32;
191
+ readonly label: '2XL';
192
+ }];
193
+ /** Preset options for the line height dropdown in the editor. */
194
+ declare const LINE_HEIGHT_PRESETS: readonly [{
195
+ readonly value: 1;
196
+ readonly label: 'Tight';
197
+ }, {
198
+ readonly value: 1.25;
199
+ readonly label: 'Snug';
200
+ }, {
201
+ readonly value: 1.5;
202
+ readonly label: 'Normal';
203
+ }, {
204
+ readonly value: 1.75;
205
+ readonly label: 'Relaxed';
206
+ }, {
207
+ readonly value: 2;
208
+ readonly label: 'Loose';
209
+ }];
210
+ 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
+ declare const DEFAULT_FONT_FALLBACK: FallbackFont;
215
+ /**
216
+ * Per-node font style overrides. Null values mean "inherit from
217
+ * the theme defaults" — only non-null values produce inline CSS.
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.
231
+ */
232
+ type NodeFontStyleDefaults = {
233
+ fontSize: number;
234
+ lineHeight: number;
235
+ fontWeight: number;
236
+ fontStyle?: FontStyleValue;
237
+ };
238
+ /**
239
+ * Builds a CSS properties object from a node's font attributes,
240
+ * falling back to the provided defaults for any null values.
241
+ * Only includes properties that have a resolved value.
242
+ */
243
+ declare function getFontStyle(attrs: FontStyleAttributes, defaults?: Partial<NodeFontStyleDefaults>): Properties;
244
+ //#endregion
245
+ //#region src/html-code-block.d.ts
246
+ /**
247
+ * Tab options for the HTML code block node.
248
+ * "code" shows the raw HTML source, "preview" renders it visually.
249
+ */
250
+ declare const HTML_CODE_BLOCK_TABS: {
251
+ readonly CODE: 'code';
252
+ readonly PREVIEW: 'preview';
253
+ };
254
+ type AllowedHtmlCodeBlockTab = (typeof HTML_CODE_BLOCK_TABS)[keyof typeof HTML_CODE_BLOCK_TABS];
255
+ declare const DEFAULT_HTML_CODE_BLOCK_TAB: AllowedHtmlCodeBlockTab;
256
+ //#endregion
257
+ //#region src/margin.d.ts
258
+ /**
259
+ * Per-side margin configuration for a node. Includes a field mode
260
+ * that controls whether margin is edited uniformly or per-side,
261
+ * and individual values for each side in pixels.
262
+ */
263
+ type MarginStyleConfig = {
264
+ marginMode: AllowedFieldMode;
265
+ marginTop: number;
266
+ marginRight: number;
267
+ marginBottom: number;
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;
276
+ //#endregion
277
+ //#region src/mark.d.ts
278
+ /** Registry of all inline mark type strings used in the document JSON. */
279
+ declare const MAILY_MARK_TYPES: {
280
+ readonly BOLD: 'bold';
281
+ readonly ITALIC: 'italic';
282
+ readonly STRIKE: 'strike';
283
+ readonly UNDERLINE: 'underline';
284
+ readonly LINK: 'link';
285
+ readonly CODE: 'code';
286
+ readonly TEXT_STYLE: 'textStyle';
287
+ readonly HIGHLIGHT: 'highlight';
288
+ };
289
+ type MailyMarkType = (typeof MAILY_MARK_TYPES)[keyof typeof MAILY_MARK_TYPES];
290
+ declare const allowedMarkTypes: ("bold" | "code" | "highlight" | "italic" | "link" | "strike" | "textStyle" | "underline")[];
291
+ /**
292
+ * Base shape shared by all inline marks. Individual mark types
293
+ * narrow the type field and optionally add typed attrs.
294
+ */
295
+ type BaseMailyMark = {
296
+ type: MailyMarkType;
297
+ attrs?: Record<string, any>;
298
+ };
299
+ /** Bold */
300
+ type BoldMark = BaseMailyMark & {
301
+ type: typeof MAILY_MARK_TYPES.BOLD;
302
+ };
303
+ /** Italic */
304
+ type ItalicMark = BaseMailyMark & {
305
+ type: typeof MAILY_MARK_TYPES.ITALIC;
306
+ };
307
+ /** Strike */
308
+ type StrikeMark = BaseMailyMark & {
309
+ type: typeof MAILY_MARK_TYPES.STRIKE;
310
+ };
311
+ /** Underline */
312
+ type UnderlineMark = BaseMailyMark & {
313
+ type: typeof MAILY_MARK_TYPES.UNDERLINE;
314
+ };
315
+ /** Link */
316
+ type LinkAttributes = {
317
+ href: string;
318
+ target?: string;
319
+ };
320
+ type LinkMark = BaseMailyMark & {
321
+ type: typeof MAILY_MARK_TYPES.LINK;
322
+ attrs: LinkAttributes;
323
+ };
324
+ /** Code */
325
+ type CodeAttributes = {};
326
+ type CodeMark = BaseMailyMark & {
327
+ type: typeof MAILY_MARK_TYPES.CODE;
328
+ attrs: CodeAttributes;
329
+ };
330
+ /** Text Style */
331
+ type TextStyleAttributes = {
332
+ color: string;
333
+ };
334
+ type TextStyleMark = BaseMailyMark & {
335
+ type: typeof MAILY_MARK_TYPES.TEXT_STYLE;
336
+ attrs: TextStyleAttributes;
337
+ };
338
+ /** Highlight */
339
+ type HighlightAttributes = {
340
+ color: string;
341
+ };
342
+ type HighlightMark = BaseMailyMark & {
343
+ type: typeof MAILY_MARK_TYPES.HIGHLIGHT;
344
+ attrs: HighlightAttributes;
345
+ };
346
+ type AnyMailyMark = BoldMark | ItalicMark | StrikeMark | UnderlineMark | LinkMark | CodeMark | TextStyleMark | HighlightMark;
347
+ //#endregion
348
+ //#region src/padding.d.ts
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;
360
+ };
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;
367
+ //#endregion
368
+ //#region src/text-direction.d.ts
369
+ /** Text direction values matching the HTML `dir` attribute: ltr, rtl, auto. */
370
+ declare const TEXT_DIRECTIONS: {
371
+ readonly LTR: 'ltr';
372
+ readonly RTL: 'rtl';
373
+ readonly AUTO: 'auto';
374
+ };
375
+ type TextDirection = (typeof TEXT_DIRECTIONS)[keyof typeof TEXT_DIRECTIONS];
376
+ declare const allowedTextDirections: readonly TextDirection[];
377
+ declare const DEFAULT_TEXT_DIRECTION: TextDirection;
378
+ declare function isAllowedTextDirection(value: unknown): value is TextDirection;
379
+ /**
380
+ * Returns a CSS `direction` property object for the given dir value.
381
+ * Returns an empty object for "auto" or nullish values, since the
382
+ * browser default is sufficient in those cases.
383
+ */
384
+ declare function getCssDirection(dir: TextDirection | null | undefined): Record<string, Omit<TextDirection, typeof TEXT_DIRECTIONS.AUTO>>;
385
+ //#endregion
386
+ //#region src/visibility.d.ts
387
+ /**
388
+ * Comparison operators for conditional visibility rules.
389
+ * Used to evaluate a template variable against a value
390
+ * to decide whether a node should be shown or hidden.
391
+ */
392
+ declare const VISIBILITY_OPERATORS: {
393
+ readonly IS_TRUE: 'is_true';
394
+ readonly IS_FALSE: 'is_false';
395
+ readonly EQUALS: 'equals';
396
+ readonly NOT_EQUALS: 'not_equals';
397
+ readonly CONTAINS: 'contains';
398
+ readonly NOT_CONTAINS: 'not_contains';
399
+ readonly STARTS_WITH: 'starts_with';
400
+ readonly ENDS_WITH: 'ends_with';
401
+ readonly GREATER_THAN: 'greater_than';
402
+ readonly LESS_THAN: 'less_than';
403
+ };
404
+ type AllowedVisibilityOperator = (typeof VISIBILITY_OPERATORS)[keyof typeof VISIBILITY_OPERATORS];
405
+ 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
+ label: string;
423
+ }[];
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
+ type VisibilityRule = {
429
+ action: AllowedVisibilityAction;
430
+ variable: string;
431
+ operator: AllowedVisibilityOperator;
432
+ value: string;
433
+ };
434
+ /** Mixin for nodes that support conditional visibility. */
435
+ type WithVisibilityAttrs = {
436
+ visibilityRule?: VisibilityRule | null;
437
+ };
438
+ //#endregion
439
+ //#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
+ declare const MAILY_NODE_TYPES: {
446
+ readonly DOCUMENT: 'doc';
447
+ readonly PARAGRAPH: 'paragraph';
448
+ readonly TEXT: 'text';
449
+ readonly HEADING: 'heading';
450
+ readonly VARIABLE: 'variable';
451
+ readonly IMAGE: 'image';
452
+ readonly SPACER: 'spacer';
453
+ readonly SECTION: 'section';
454
+ readonly COLUMNS: 'columns';
455
+ readonly COLUMN: 'column';
456
+ readonly BULLET_LIST: 'bulletList';
457
+ readonly ORDERED_LIST: 'orderedList';
458
+ readonly LIST_ITEM: 'listItem';
459
+ readonly HORIZONTAL_RULE: 'horizontalRule';
460
+ readonly BUTTON: 'button';
461
+ readonly REPEAT: 'repeat';
462
+ readonly HTML_CODE_BLOCK: 'htmlCodeBlock';
463
+ readonly BLOCKQUOTE: 'blockquote';
464
+ readonly HARD_BREAK: 'hardBreak';
465
+ readonly FOOTER: 'footer';
466
+ readonly INLINE_IMAGE: 'inlineImage';
467
+ readonly LINK_CARD: 'linkCard';
468
+ };
469
+ /**
470
+ * Tiptap extension types that attach attributes to nodes but are
471
+ * not document nodes themselves (e.g. fontStyle, visibility).
472
+ */
473
+ declare const MAILY_EXTENSION_TYPES: {
474
+ readonly FONT_STYLE: 'fontStyle';
475
+ readonly VISIBILITY: 'visibility';
476
+ };
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")[];
478
+ 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
+ type WithExtraAttrs = {
484
+ dir?: TextDirection | null;
485
+ id?: string | null;
486
+ visibilityRule?: VisibilityRule | null;
487
+ };
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
+ type BaseMailyNode = {
493
+ type: MailyNodeType;
494
+ attrs?: Record<string, any> & WithExtraAttrs;
495
+ content?: AnyMailyNode[];
496
+ marks?: AnyMailyMark[];
497
+ text?: string;
498
+ };
499
+ /** Document */
500
+ type DocumentAttributes = {
501
+ version: number;
502
+ };
503
+ type DocumentNode = BaseMailyNode & {
504
+ type: typeof MAILY_NODE_TYPES.DOCUMENT;
505
+ attrs: DocumentAttributes;
506
+ content: BaseMailyNode[];
507
+ };
508
+ /** Paragraph */
509
+ type ParagraphAttributes = {
510
+ id: string;
511
+ textAlign: AllowedTextAlignment;
512
+ } & FontStyleAttributes;
513
+ type ParagraphNode = BaseMailyNode & {
514
+ type: typeof MAILY_NODE_TYPES.PARAGRAPH;
515
+ attrs: ParagraphAttributes;
516
+ };
517
+ /** Text */
518
+ type TextNode = BaseMailyNode & {
519
+ type: typeof MAILY_NODE_TYPES.TEXT;
520
+ text: string;
521
+ };
522
+ /** Heading */
523
+ type HeadingLevel = 1 | 2 | 3;
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;
531
+ };
532
+ /**
533
+ * Variable
534
+ * Attributes for a template variable node. The id and label must not
535
+ * contain `|` characters — that delimiter is used when serializing
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;
545
+ };
546
+ type VariableNode = BaseMailyNode & {
547
+ type: typeof MAILY_NODE_TYPES.VARIABLE;
548
+ attrs: VariableAttributes;
549
+ content: never;
550
+ };
551
+ /** Image */
552
+ type ImageAttributes = {
553
+ src: string;
554
+ alt?: string;
555
+ title?: string;
556
+ width: string;
557
+ align: AllowedTextAlignment;
558
+ externalLink: string | null;
559
+ } & BorderStyleConfig;
560
+ type ImageNode = BaseMailyNode & {
561
+ type: typeof MAILY_NODE_TYPES.IMAGE;
562
+ attrs: ImageAttributes;
563
+ content: never;
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;
574
+ };
575
+ /** Section */
576
+ type SectionAttributes = {
577
+ backgroundColor: string;
578
+ align: AllowedTextAlignment;
579
+ } & BorderStyleConfig & PaddingStyleConfig & MarginStyleConfig;
580
+ type SectionNode = BaseMailyNode & {
581
+ type: typeof MAILY_NODE_TYPES.SECTION;
582
+ attrs: SectionAttributes;
583
+ content: AnyMailyNode[];
584
+ };
585
+ /** Bullet List */
586
+ type BulletListAttributes = {
587
+ id: string;
588
+ };
589
+ type BulletListNode = BaseMailyNode & {
590
+ type: typeof MAILY_NODE_TYPES.BULLET_LIST;
591
+ attrs: BulletListAttributes;
592
+ content: AnyMailyNode[];
593
+ };
594
+ /** Ordered List */
595
+ type OrderedListAttributes = {
596
+ id: string;
597
+ };
598
+ type OrderedListNode = BaseMailyNode & {
599
+ type: typeof MAILY_NODE_TYPES.ORDERED_LIST;
600
+ attrs: OrderedListAttributes;
601
+ content: AnyMailyNode[];
602
+ };
603
+ /** List Item */
604
+ type ListItemAttributes = {
605
+ id: string;
606
+ };
607
+ type ListItemNode = BaseMailyNode & {
608
+ type: typeof MAILY_NODE_TYPES.LIST_ITEM;
609
+ attrs: ListItemAttributes;
610
+ content: AnyMailyNode[];
611
+ };
612
+ /** Blockquote */
613
+ type BlockquoteAttributes = {
614
+ id: string;
615
+ } & FontStyleAttributes;
616
+ type BlockquoteNode = BaseMailyNode & {
617
+ type: typeof MAILY_NODE_TYPES.BLOCKQUOTE;
618
+ attrs: BlockquoteAttributes;
619
+ content: AnyMailyNode[];
620
+ };
621
+ /** Horizontal Rule */
622
+ type HorizontalRuleAttributes = {
623
+ id: string;
624
+ };
625
+ type HorizontalRuleNode = BaseMailyNode & {
626
+ type: typeof MAILY_NODE_TYPES.HORIZONTAL_RULE;
627
+ attrs: HorizontalRuleAttributes;
628
+ content: never;
629
+ };
630
+ /** Button */
631
+ type ButtonAttributes = {
632
+ url: string;
633
+ kind: AllowedButtonKind;
634
+ alignment: AllowedTextAlignment | null;
635
+ backgroundColor: string | null;
636
+ color: string | null;
637
+ paddingMode: AllowedFieldMode;
638
+ paddingTop: number;
639
+ paddingRight: number;
640
+ paddingBottom: number;
641
+ paddingLeft: number;
642
+ } & BorderStyleConfig & FontStyleAttributes;
643
+ type ButtonNode = BaseMailyNode & {
644
+ type: typeof MAILY_NODE_TYPES.BUTTON;
645
+ attrs: ButtonAttributes;
646
+ content: AnyMailyNode[];
647
+ };
648
+ /** HTML Code Block */
649
+ type HtmlCodeBlockAttributes = {
650
+ activeTab: AllowedHtmlCodeBlockTab;
651
+ language: string;
652
+ };
653
+ type HtmlCodeBlockNode = BaseMailyNode & {
654
+ type: typeof MAILY_NODE_TYPES.HTML_CODE_BLOCK;
655
+ attrs: HtmlCodeBlockAttributes;
656
+ content: AnyMailyNode[];
657
+ };
658
+ /** Repeat */
659
+ type RepeatAttributes = {
660
+ each: string;
661
+ };
662
+ type RepeatNode = BaseMailyNode & {
663
+ type: typeof MAILY_NODE_TYPES.REPEAT;
664
+ attrs: RepeatAttributes;
665
+ content: AnyMailyNode[];
666
+ };
667
+ /** Columns (container for multiple columns) */
668
+ type ColumnsAttributes = {
669
+ columnCount: number;
670
+ gap: number;
671
+ };
672
+ type ColumnsNode = BaseMailyNode & {
673
+ type: typeof MAILY_NODE_TYPES.COLUMNS;
674
+ attrs: ColumnsAttributes;
675
+ content: ColumnNode[];
676
+ };
677
+ /** Column (individual column within columns container) */
678
+ type ColumnAttributes = {
679
+ width: number | null;
680
+ verticalAlign: 'top' | 'middle' | 'bottom';
681
+ };
682
+ type ColumnNode = BaseMailyNode & {
683
+ type: typeof MAILY_NODE_TYPES.COLUMN;
684
+ attrs: ColumnAttributes;
685
+ content: AnyMailyNode[];
686
+ };
687
+ /** Hard Break */
688
+ type HardBreakNode = BaseMailyNode & {
689
+ type: typeof MAILY_NODE_TYPES.HARD_BREAK;
690
+ content: never;
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;
714
+ };
715
+ /** Link Card */
716
+ type LinkCardAttributes = {
717
+ title: string;
718
+ description: string;
719
+ link: string;
720
+ linkTitle: string;
721
+ image: string;
722
+ subTitle: string;
723
+ badgeText: string;
724
+ };
725
+ type LinkCardNode = BaseMailyNode & {
726
+ type: typeof MAILY_NODE_TYPES.LINK_CARD;
727
+ attrs: LinkCardAttributes;
728
+ content: never;
729
+ };
730
+ type AnyMailyNode = DocumentNode | ParagraphNode | TextNode | HeadingNode | VariableNode | ImageNode | SpacerNode | SectionNode | RepeatNode | ColumnsNode | ColumnNode | BulletListNode | OrderedListNode | ListItemNode | HorizontalRuleNode | ButtonNode | HtmlCodeBlockNode | BlockquoteNode | HardBreakNode | FooterNode | InlineImageNode | LinkCardNode;
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
+ */
26
738
  interface BaseThemeOptions {
27
- container?: Partial<Pick<CSS$1.Properties, "backgroundColor" | "maxWidth" | "minWidth" | "paddingTop" | "paddingRight" | "paddingBottom" | "paddingLeft" | "borderRadius" | "borderWidth" | "borderColor">>;
28
- body?: Partial<Pick<CSS$1.Properties, "backgroundColor" | "paddingTop" | "paddingRight" | "paddingBottom" | "paddingLeft">>;
29
- button?: Partial<Pick<CSS$1.Properties, "paddingTop" | "paddingRight" | "paddingBottom" | "paddingLeft" | "backgroundColor" | "color">>;
30
- link?: Partial<Pick<CSS$1.Properties, "color">>;
31
- font?: Pick<FontProps, "fontFamily" | "fallbackFontFamily" | "webFont"> | null;
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
+ }>;
32
773
  }
33
774
  /**
34
- * The theme options for the editor.
35
- * currently, we don't allow any customizations for the colors in the editor.
36
- * that's why we have a separate theme for the editor.
37
- */
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
+ */
38
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
+ }>;
39
792
  /**
40
- * The theme options for the renderer.
41
- * currently, we don't allow any customizations for the colors in the editor.
42
- * that's why we have a separate theme for the renderer.
43
- */
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
+ */
44
797
  interface RendererThemeOptions extends BaseThemeOptions {
45
- colors?: Partial<{
46
- heading: string;
47
- paragraph: string;
48
- horizontal: string;
49
- footer: string;
50
- blockquoteBorder: string;
51
- codeBackground: string;
52
- codeText: string;
53
- linkCardTitle: string;
54
- linkCardDescription: string;
55
- linkCardBadgeText: string;
56
- linkCardBadgeBackground: string;
57
- linkCardSubTitle: string;
58
- }>;
59
- fontSize?: Partial<{
60
- paragraph: Partial<{
61
- size: string;
62
- lineHeight: string;
63
- }>;
64
- footer: Partial<{
65
- size: string;
66
- lineHeight: string;
798
+ paragraph?: NodeThemeEntry;
799
+ heading?: Partial<{
800
+ defaults: Partial<{
801
+ color: string;
67
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;
68
831
  }>;
69
832
  }
70
- declare const DEFAULT_FONT: FontProps;
71
833
  declare const DEFAULT_LINK_TEXT_COLOR = "#111827";
72
834
  declare const DEFAULT_RENDERER_THEME: RendererThemeOptions;
73
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;
74
841
  //#endregion
75
842
  //#region src/css-variables.d.ts
76
- declare module "csstype" {
843
+ declare module 'csstype' {
77
844
  interface Properties {
78
845
  [index: `--mly-${string}`]: any;
79
846
  }
80
847
  }
81
848
  /**
82
- * if the value is undefined, it will return an empty object
83
- * so that we don't override the default value
84
- * @param name - The name of the CSS variable
85
- * @param value - The value of the CSS variable
86
- * @returns The CSS variable value
87
- */
88
- declare function getVariableValue(name: `--mly-${string}`, value: any): CSS.Properties;
89
- /**
90
- * Get the CSS variables for the theme
91
- * @param theme - The theme
92
- * @returns The CSS variables
93
- * @example
94
- * ```ts
95
- * const theme = {
96
- * body: {
97
- * backgroundColor: 'red',
98
- * },
99
- * };
100
- *
101
- * const cssVariables = getCssVariables(theme);
102
- *
103
- * console.log(cssVariables);
104
- * // { '--mly-body-background-color': 'red' }
105
- */
106
- declare function getMailyCssVariables(theme: EditorThemeOptions): CSS.Properties;
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;
107
863
  //#endregion
108
- //#region src/font.d.ts
109
- type Font = Pick<FontProps, "fontFamily" | "fallbackFontFamily" | "webFont">;
110
- declare function loadFont(font: Font): void;
111
- declare function fontStyle(font: Font): string;
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;
894
+ //#endregion
895
+ //#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
+ */
907
+ declare const is: {
908
+ any(value: unknown): value is AnyMailyNode | AnyMailyMark;
909
+ parent(node: AnyMailyNode): node is AnyMailyNode & {
910
+ content: AnyMailyNode[];
911
+ };
912
+ marked(node: AnyMailyNode): node is AnyMailyNode & {
913
+ marks: AnyMailyMark[];
914
+ };
915
+ node(node: unknown): node is AnyMailyNode;
916
+ doc: (node: AnyMailyNode | AnyMailyMark) => node is DocumentNode;
917
+ paragraph: (node: AnyMailyNode | AnyMailyMark) => node is ParagraphNode;
918
+ text: (node: AnyMailyNode | AnyMailyMark) => node is TextNode;
919
+ heading: (node: AnyMailyNode | AnyMailyMark) => node is HeadingNode;
920
+ variable: (node: AnyMailyNode | AnyMailyMark) => node is VariableNode;
921
+ image: (node: AnyMailyNode | AnyMailyMark) => node is ImageNode;
922
+ inlineImage: (node: AnyMailyNode | AnyMailyMark) => node is InlineImageNode;
923
+ spacer: (node: AnyMailyNode | AnyMailyMark) => node is SpacerNode;
924
+ section: (node: AnyMailyNode | AnyMailyMark) => node is SectionNode;
925
+ button: (node: AnyMailyNode | AnyMailyMark) => node is ButtonNode;
926
+ columns: (node: AnyMailyNode | AnyMailyMark) => node is ColumnsNode;
927
+ column: (node: AnyMailyNode | AnyMailyMark) => node is ColumnNode;
928
+ repeat: (node: AnyMailyNode | AnyMailyMark) => node is RepeatNode;
929
+ bulletList: (node: AnyMailyNode | AnyMailyMark) => node is BulletListNode;
930
+ orderedList: (node: AnyMailyNode | AnyMailyMark) => node is OrderedListNode;
931
+ listItem: (node: AnyMailyNode | AnyMailyMark) => node is ListItemNode;
932
+ horizontalRule: (node: AnyMailyNode | AnyMailyMark) => node is HorizontalRuleNode;
933
+ htmlCodeBlock: (node: AnyMailyNode | AnyMailyMark) => node is HtmlCodeBlockNode;
934
+ blockquote: (node: AnyMailyNode | AnyMailyMark) => node is BlockquoteNode;
935
+ hardBreak: (node: AnyMailyNode | AnyMailyMark) => node is HardBreakNode;
936
+ footer: (node: AnyMailyNode | AnyMailyMark) => node is FooterNode;
937
+ linkCard: (node: AnyMailyNode | AnyMailyMark) => node is LinkCardNode;
938
+ mark(mark: unknown): mark is AnyMailyMark;
939
+ bold: (node: AnyMailyNode | AnyMailyMark) => node is BoldMark;
940
+ italic: (node: AnyMailyNode | AnyMailyMark) => node is ItalicMark;
941
+ strike: (node: AnyMailyNode | AnyMailyMark) => node is StrikeMark;
942
+ underline: (node: AnyMailyNode | AnyMailyMark) => node is UnderlineMark;
943
+ link: (node: AnyMailyNode | AnyMailyMark) => node is LinkMark;
944
+ code: (node: AnyMailyNode | AnyMailyMark) => node is CodeMark;
945
+ textStyle: (node: AnyMailyNode | AnyMailyMark) => node is TextStyleMark;
946
+ highlight: (node: AnyMailyNode | AnyMailyMark) => node is HighlightMark;
947
+ };
948
+ /** Type guard that checks if a value is defined (not null or undefined). */
949
+ declare function isDef<T = any>(val?: T | null): val is T;
950
+ /** Type guard that checks if a value is a boolean. */
951
+ declare function isBoolean(val: any): val is boolean;
952
+ /** Type guard that checks if a value is a number. */
953
+ declare function isNumber(val: any): val is number;
954
+ /** Type guard that checks if a value is a string. */
955
+ declare function isString(val: unknown): val is string;
956
+ /** Type guard that checks if a value is a non-null object. */
957
+ declare function isObject(val: unknown): val is object;
958
+ //#endregion
959
+ //#region src/math.d.ts
960
+ declare function clamp(value: number, [min, max]: [number, number]): number;
961
+ declare function percentage(portion: number, total: number): number;
962
+ declare function absoluteFromPercentage(percentage: number, total: number): number;
963
+ declare function roundTo(value: number, decimals: number): number;
964
+ //#endregion
965
+ //#region src/object.d.ts
966
+ /**
967
+ * One-level deep merge of plain objects. Nested plain objects are
968
+ * shallow-merged; primitives, arrays, and null are replaced outright.
969
+ * Does not mutate the target — returns a new object.
970
+ *
971
+ * Example:
972
+ * deepMerge({ a: 1, nested: { x: 1, y: 2 } }, { nested: { y: 3 } })
973
+ * // => { a: 1, nested: { x: 1, y: 3 } }
974
+ */
975
+ declare function deepMerge<T extends object>(target: T, ...sources: Partial<T>[]): T;
976
+ declare function isObjectDeepEqual(first: object, second: object): boolean;
977
+ //#endregion
978
+ //#region src/promise.d.ts
979
+ /** Returns a promise that resolves after the given number of milliseconds. */
980
+ declare function sleep(ms: number): Promise<void>;
981
+ //#endregion
982
+ //#region src/variable.d.ts
983
+ /** Default opening delimiter for variable placeholders in text. */
984
+ declare const DEFAULT_VARIABLE_START_TRIGGER = "{{";
985
+ /** Default closing delimiter for variable placeholders in text. */
986
+ 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
+ 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
+ declare function deserializeVariableFromText(text: string): VariableAttributes;
1011
+ /**
1012
+ * Parses a string containing variable placeholders (e.g. "Hello {{name}}")
1013
+ * into a Tiptap-compatible document JSON with text and variable nodes.
1014
+ * Splits on {{...}} boundaries and creates the appropriate node type
1015
+ * for each segment.
1016
+ */
1017
+ declare function buildDocFromVariableText(content: string): {
1018
+ type: "doc";
1019
+ content: {
1020
+ type: "paragraph";
1021
+ content: ({
1022
+ type: "variable";
1023
+ attrs: VariableAttributes;
1024
+ text?: undefined;
1025
+ } | {
1026
+ attrs?: undefined;
1027
+ type: "text";
1028
+ text: string;
1029
+ })[];
1030
+ }[];
1031
+ };
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
+ declare function hasVariableInText(text: string): boolean;
112
1038
  //#endregion
113
- export { BaseThemeOptions, DEFAULT_EDITOR_THEME, DEFAULT_FONT, DEFAULT_LINK_TEXT_COLOR, DEFAULT_RENDERER_THEME, EditorThemeOptions, FallbackFont, FontFormat, FontProps, RendererThemeOptions, allowedFallbackFonts, allowedFontFormats, fontStyle, getMailyCssVariables, getVariableValue, loadFont };
1039
+ export { AllowedBorderStyle, AllowedButtonKind, AllowedFieldMode, AllowedHtmlCodeBlockTab, AllowedTextAlignment, AllowedVisibilityAction, AllowedVisibilityOperator, AnyMailyMark, AnyMailyNode, BORDER_STYLES, BUTTON_KINDS, BaseMailyMark, BaseMailyNode, BaseThemeOptions, BlockquoteAttributes, BlockquoteNode, BoldMark, BorderStyleConfig, BulletListAttributes, BulletListNode, ButtonAttributes, ButtonNode, CodeAttributes, CodeMark, ColumnAttributes, ColumnNode, ColumnsAttributes, ColumnsNode, DATA_NODE_TYPE_KEY, DATA_VISIBILITY_RULE_KEY, DEFAULT_BORDER_COLOR, DEFAULT_BORDER_STYLE, DEFAULT_BUTTON_KIND, DEFAULT_EDITOR_THEME, DEFAULT_FONT, DEFAULT_FONT_FALLBACK, DEFAULT_FONT_FAMILIES, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_FONT_WEIGHT, DEFAULT_HTML_CODE_BLOCK_TAB, DEFAULT_LINE_HEIGHT, DEFAULT_LINK_TEXT_COLOR, DEFAULT_RENDERER_THEME, DEFAULT_TEXT_ALIGN, DEFAULT_TEXT_DIRECTION, DEFAULT_VARIABLE_END_TRIGGER, DEFAULT_VARIABLE_START_TRIGGER, DocumentAttributes, DocumentNode, EditorThemeOptions, FIELD_MODE, FONT_SIZE_PRESETS, FONT_STYLES, FONT_WEIGHTS, FallbackFont, FontFamily, FontFamilyItem, FontFormat, FontProps, FontStyleAttributes, FontStyleValue, FontWeight, FooterAttributes, FooterNode, HTML_CODE_BLOCK_TABS, HardBreakNode, HeadingAttributes, HeadingLevel, HeadingLevelTheme, HeadingNode, HighlightAttributes, HighlightMark, HorizontalRuleAttributes, HorizontalRuleNode, HtmlCodeBlockAttributes, HtmlCodeBlockNode, ImageAttributes, ImageNode, ImageWidth, InlineImageAttributes, InlineImageNode, 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_TYPES, MAX_IMAGE_WIDTH_PERCENTAGE, MIN_IMAGE_WIDTH_PERCENTAGE, MailyMarkType, MailyNodeType, MarginStyleConfig, NodeFontStyleDefaults, NodeThemeEntry, Noop, OPERATORS_WITHOUT_VALUE, OrderedListAttributes, OrderedListNode, PaddingStyleConfig, ParagraphAttributes, ParagraphNode, RendererThemeOptions, RepeatAttributes, RepeatNode, SectionAttributes, SectionNode, SpacerAttributes, SpacerNode, StrikeMark, TEXT_ALIGNMENTS, TEXT_DIRECTIONS, TextDirection, TextNode, TextStyleAttributes, TextStyleMark, UnderlineMark, VARIABLE_PLACEHOLDER_REGEX, VARIABLE_TEXT_DELIMITER, VISIBILITY_ACTIONS, VISIBILITY_ACTION_OPTIONS, VISIBILITY_OPERATORS, VISIBILITY_OPERATOR_OPTIONS, VariableAttributes, VariableNode, VisibilityRule, WithExtraAttrs, WithVisibilityAttrs, absoluteFromPercentage, allowedButtonKinds, allowedFallbackFonts, allowedFieldModes, allowedFontFormats, allowedMarkTypes, allowedNodeTypes, allowedTextAligns, allowedTextDirections, buildDocFromVariableText, clamp, clampImageWidthPercentage, deepMerge, deserializeVariableFromText, getBorderStyle, getCssDirection, getFontFaceStyle, getFontStyle, getMailyCssVariables, getMarginStyle, getNodeFontStyleDefaults, getPaddingStyle, getVariableValue, hasVariableInText, invariant, is, isAllowedButtonKind, isAllowedFieldMode, isAllowedTextAlignment, isAllowedTextDirection, isBoolean, isDef, isNumber, isObject, isObjectDeepEqual, isString, loadFont, noop, parseWidthToPercentage, percentage, roundTo, serializeVariableToText, sleep };
114
1040
  //# sourceMappingURL=index.d.mts.map