@maily-to/shared 2.0.0-beta.1 → 2.0.0-beta.11
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 +872 -692
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +465 -669
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +465 -669
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +840 -662
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -7
- package/readme.md +43 -7
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/alignment.ts","../src/field-mode.ts","../src/border.ts","../src/button-kind.ts","../src/constants.ts","../src/font.ts","../src/css-variables.ts","../src/html-code-block.ts","../src/math.ts","../src/image-width.ts","../src/mark.ts","../src/node.ts","../src/is.ts","../src/font-style.ts","../src/font-weight.ts","../src/function.ts","../src/invariant.ts","../src/margin.ts","../src/object.ts","../src/padding.ts","../src/promise.ts","../src/text-direction.ts","../src/theme.ts","../src/variable.ts","../src/visibility.ts"],"sourcesContent":["export const TEXT_ALIGNMENTS = {\n LEFT: 'left',\n CENTER: 'center',\n RIGHT: 'right',\n} as const;\n\nexport type AllowedTextAlignment =\n (typeof TEXT_ALIGNMENTS)[keyof typeof TEXT_ALIGNMENTS];\n\nexport const allowedTextAligns: readonly AllowedTextAlignment[] = Object.freeze(\n Object.values(TEXT_ALIGNMENTS)\n);\n\nexport const DEFAULT_TEXT_ALIGN: AllowedTextAlignment = TEXT_ALIGNMENTS.LEFT;\n\nexport function isAllowedTextAlignment(\n value: unknown\n): value is AllowedTextAlignment {\n return (\n typeof value === 'string' &&\n allowedTextAligns.includes(value as AllowedTextAlignment)\n );\n}\n","/**\n * Controls how multi-value fields (padding, margin, border) are edited.\n * \"none\" disables the field, \"uniform\" links all sides to one value,\n * \"mixed\" allows independent per-side values, \"preset\" uses predefined\n * size options (e.g. small/medium/large).\n */\nexport const FIELD_MODE = {\n NONE: 'none',\n MIXED: 'mixed',\n UNIFORM: 'uniform',\n PRESET: 'preset',\n} as const;\n\nexport type AllowedFieldMode = (typeof FIELD_MODE)[keyof typeof FIELD_MODE];\n\nexport const allowedFieldModes = Object.values(\n FIELD_MODE\n) as readonly AllowedFieldMode[];\n\nexport function isAllowedFieldMode(mode: unknown): mode is AllowedFieldMode {\n return (\n typeof mode === 'string' &&\n allowedFieldModes.includes(mode as AllowedFieldMode)\n );\n}\n","import type { Properties } from 'csstype';\n\nimport type { AllowedFieldMode } from './field-mode';\nimport { FIELD_MODE } from './field-mode';\n\nexport const BORDER_STYLES = {\n SOLID: 'solid',\n DASHED: 'dashed',\n DOTTED: 'dotted',\n} as const;\n\nexport type AllowedBorderStyle =\n (typeof BORDER_STYLES)[keyof typeof BORDER_STYLES];\n\nexport const DEFAULT_BORDER_STYLE: AllowedBorderStyle = BORDER_STYLES.SOLID;\n\nexport const DEFAULT_BORDER_COLOR = '#000000';\n\n/**\n * Full border configuration for a node. Includes border style, color,\n * per-side widths (top/right/bottom/left), per-corner radii, and\n * field modes that control whether each group is edited uniformly\n * or independently.\n */\nexport type BorderStyleConfig = {\n borderStyle: AllowedBorderStyle;\n\n borderColor: string;\n\n borderWidthMode: AllowedFieldMode;\n borderTopWidth: number;\n borderRightWidth: number;\n borderBottomWidth: number;\n borderLeftWidth: number;\n\n borderRadiusMode: AllowedFieldMode;\n borderTopLeftRadius: number;\n borderTopRightRadius: number;\n borderBottomRightRadius: number;\n borderBottomLeftRadius: number;\n};\n\n/**\n * Converts a BorderStyleConfig into CSS properties for inline styles.\n * When all widths or radii are equal (or the mode is \"uniform\"), emits\n * shorthand CSS; otherwise emits per-side longhand properties.\n */\nexport function getBorderStyle(config: BorderStyleConfig): Properties {\n const {\n borderStyle = DEFAULT_BORDER_STYLE,\n borderColor = DEFAULT_BORDER_COLOR,\n borderWidthMode,\n borderTopWidth,\n borderRightWidth,\n borderBottomWidth,\n borderLeftWidth,\n borderRadiusMode,\n borderTopLeftRadius,\n borderTopRightRadius,\n borderBottomRightRadius,\n borderBottomLeftRadius,\n } = config;\n\n const isBorderWidthUniform =\n borderWidthMode === FIELD_MODE.UNIFORM ||\n (borderLeftWidth === borderRightWidth &&\n borderRightWidth === borderBottomWidth &&\n borderBottomWidth === borderTopWidth);\n const isBorderRadiusUniform =\n borderRadiusMode === FIELD_MODE.UNIFORM ||\n (borderTopLeftRadius === borderTopRightRadius &&\n borderTopRightRadius === borderBottomRightRadius &&\n borderBottomRightRadius === borderBottomLeftRadius);\n\n return {\n ...(isBorderWidthUniform\n ? { border: `${borderTopWidth}px ${borderStyle} ${borderColor}` }\n : {\n borderTopWidth: `${borderTopWidth}px`,\n borderRightWidth: `${borderRightWidth}px`,\n borderBottomWidth: `${borderBottomWidth}px`,\n borderLeftWidth: `${borderLeftWidth}px`,\n borderStyle,\n borderColor,\n }),\n ...(isBorderRadiusUniform\n ? { borderRadius: `${borderTopLeftRadius}px` }\n : {\n borderRadius: `${borderTopLeftRadius}px ${borderTopRightRadius}px ${borderBottomRightRadius}px ${borderBottomLeftRadius}px`,\n }),\n };\n}\n","/**\n * Button layout kinds.\n * \"tight\" renders the button at its content width,\n * \"full-width\" stretches it to fill the container.\n */\nexport const BUTTON_KINDS = {\n TIGHT: 'tight',\n FULL_WIDTH: 'full-width',\n} as const;\n\nexport type AllowedButtonKind =\n (typeof BUTTON_KINDS)[keyof typeof BUTTON_KINDS];\n\nexport const allowedButtonKinds: readonly AllowedButtonKind[] = Object.freeze(\n Object.values(BUTTON_KINDS)\n);\n\nexport const DEFAULT_BUTTON_KIND: AllowedButtonKind = BUTTON_KINDS.TIGHT;\n\nexport function isAllowedButtonKind(\n value: unknown\n): value is AllowedButtonKind {\n return (\n typeof value === 'string' &&\n allowedButtonKinds.includes(value as AllowedButtonKind)\n );\n}\n","/** HTML data attribute key used to identify node types in rendered output. */\nexport const DATA_NODE_TYPE_KEY = 'data-node-type';\n\n/** HTML data attribute key used to store serialized visibility rules. */\nexport const DATA_VISIBILITY_RULE_KEY = 'data-visibility-rule';\n\n/** Prefix prepended to all Maily error messages for easy identification. */\nexport const MAILY_ERROR_PREFIX = '[Maily Error]';\n\n/** URL for filing bug reports against the Maily repository. */\nexport const MAILY_BUG_REPORT_URL =\n 'https://github.com/arikchakma/maily.to/issues/new';\n","import type { Properties } from 'csstype';\n\n/**\n * List of allowed fallback font families. These are system fonts or\n * generic font families that serve as fallbacks when a web font\n * fails to load.\n */\nexport const allowedFallbackFonts = [\n 'Arial',\n 'Helvetica',\n 'Verdana',\n 'Georgia',\n 'Times New Roman',\n 'serif',\n 'sans-serif',\n 'monospace',\n 'cursive',\n 'fantasy',\n] as const;\n\nexport type FallbackFont = (typeof allowedFallbackFonts)[number];\n\nexport const allowedFontFormats = [\n 'woff',\n 'woff2',\n 'truetype',\n 'opentype',\n 'embedded-opentype',\n 'svg',\n] as const;\n\nexport type FontFormat = (typeof allowedFontFormats)[number];\n\ntype FontStyle = Properties['fontStyle'];\n\n/**\n * Configuration for a font used in the editor or renderer.\n * Specifies the primary font family, a fallback, and an optional\n * web font URL with its format for @font-face loading.\n */\nexport interface FontProps {\n fontFamily: string;\n fallbackFontFamily: FallbackFont;\n webFont?: {\n url: string;\n format: FontFormat;\n };\n fontStyle?: FontStyle;\n fontWeight?: number;\n}\n\n/**\n * Default font configuration: Inter with sans-serif fallback,\n * loaded from the Maily CDN as woff2.\n */\nexport const DEFAULT_FONT: FontProps = {\n fallbackFontFamily: 'sans-serif',\n fontFamily: 'Inter',\n webFont: {\n url: 'https://cdn.usemaily.com/fonts/v0/inter.woff2',\n format: 'woff2',\n },\n};\n\n/**\n * Injects a @font-face style element into the document head to load\n * the given font. Only works in browser environments.\n */\nexport function loadFont(font: FontProps): void {\n const style = getFontFaceStyle(font);\n\n const styleElement = document.createElement('style');\n styleElement.textContent = style;\n document.head.appendChild(styleElement);\n}\n\n/**\n * Generates a @font-face CSS rule string for the given font configuration.\n * Includes the font family, style, weight, MSO fallback, and web font\n * source URL when available.\n */\nexport function getFontFaceStyle(font: FontProps): string {\n const {\n fontFamily,\n fallbackFontFamily,\n webFont,\n fontWeight = 400,\n fontStyle = 'normal',\n } = font;\n\n const src = webFont\n ? `src: url(${webFont.url}) format('${webFont.format}');`\n : '';\n\n const style = /* css */ `@font-face {font-family: '${fontFamily}';font-style: ${fontStyle};font-weight: ${fontWeight};mso-font-alt: '${fallbackFontFamily}';${src}}`;\n\n return style;\n}\n","import type { Properties } from 'csstype';\n\nimport { DEFAULT_FONT } from './font';\nimport type { EditorThemeOptions } from './theme';\n\ndeclare module 'csstype' {\n interface Properties {\n [index: `--mly-${string}`]: any;\n }\n}\n\n/**\n * Returns a CSS variable object for the given name and value.\n * If the value is nullish or empty, returns an empty object so that\n * the default CSS variable value is not overridden. Numbers are\n * automatically suffixed with \"px\".\n */\nexport function getVariableValue(\n name: `--mly-${string}`,\n value: unknown\n): Properties {\n if (value === undefined || value === null || value === '') {\n return {};\n }\n\n return {\n [name]: typeof value === 'number' ? `${value}px` : value,\n };\n}\n\n/**\n * Converts an EditorThemeOptions object into a flat map of Maily CSS\n * custom properties (--mly-*). Used to apply theme overrides as inline\n * styles on the editor or renderer root element. Covers body background,\n * container dimensions and borders, button colors, link color, and\n * font family settings.\n */\nexport function getMailyCssVariables(theme: EditorThemeOptions): Properties {\n const font = theme.font || DEFAULT_FONT;\n\n return {\n ...getVariableValue(\n '--mly-body-background-color',\n theme.body?.backgroundColor\n ),\n ...getVariableValue('--mly-body-padding-top', theme.body?.paddingTop),\n ...getVariableValue('--mly-body-padding-right', theme.body?.paddingRight),\n ...getVariableValue('--mly-body-padding-bottom', theme.body?.paddingBottom),\n ...getVariableValue('--mly-body-padding-left', theme.body?.paddingLeft),\n\n ...getVariableValue(\n '--mly-container-background-color',\n theme.container?.backgroundColor\n ),\n ...getVariableValue('--mly-container-max-width', theme.container?.maxWidth),\n ...getVariableValue('--mly-container-min-width', theme.container?.minWidth),\n\n ...getVariableValue(\n '--mly-container-padding-top',\n theme.container?.paddingTop\n ),\n ...getVariableValue(\n '--mly-container-padding-right',\n theme.container?.paddingRight\n ),\n ...getVariableValue(\n '--mly-container-padding-bottom',\n theme.container?.paddingBottom\n ),\n ...getVariableValue(\n '--mly-container-padding-left',\n theme.container?.paddingLeft\n ),\n\n ...getVariableValue(\n '--mly-container-border-radius',\n theme.container?.borderRadius\n ),\n ...getVariableValue(\n '--mly-container-border-width',\n theme.container?.borderWidth\n ),\n ...getVariableValue(\n '--mly-container-border-color',\n theme.container?.borderColor\n ),\n\n ...getVariableValue(\n '--mly-button-background-color',\n theme.button?.backgroundColor\n ),\n ...getVariableValue('--mly-button-text-color', theme.button?.color),\n ...getVariableValue('--mly-button-padding-top', theme.button?.paddingTop),\n ...getVariableValue(\n '--mly-button-padding-right',\n theme.button?.paddingRight\n ),\n ...getVariableValue(\n '--mly-button-padding-bottom',\n theme.button?.paddingBottom\n ),\n ...getVariableValue('--mly-button-padding-left', theme.button?.paddingLeft),\n\n ...getVariableValue('--mly-link-color', theme.link?.color),\n\n ...getVariableValue('--mly-font-family', font.fontFamily),\n ...getVariableValue('--mly-font-fallback-family', font.fallbackFontFamily),\n '--mly-font': `var(--mly-font-family), var(--mly-font-fallback-family)`,\n };\n}\n","/**\n * Tab options for the HTML code block node.\n * \"code\" shows the raw HTML source, \"preview\" renders it visually.\n */\nexport const HTML_CODE_BLOCK_TABS = {\n CODE: 'code',\n PREVIEW: 'preview',\n} as const;\n\nexport type AllowedHtmlCodeBlockTab =\n (typeof HTML_CODE_BLOCK_TABS)[keyof typeof HTML_CODE_BLOCK_TABS];\n\nexport const DEFAULT_HTML_CODE_BLOCK_TAB: AllowedHtmlCodeBlockTab =\n HTML_CODE_BLOCK_TABS.CODE;\n","export function clamp(value: number, [min, max]: [number, number]): number {\n return Math.min(Math.max(value, min), max);\n}\n\nexport function percentage(portion: number, total: number): number {\n return clamp((portion / total) * 100, [0, 100]);\n}\n\nexport function absoluteFromPercentage(\n percentage: number,\n total: number\n): number {\n return Math.round((total * percentage) / 100);\n}\n\nexport function roundTo(value: number, decimals: number): number {\n const factor = Math.pow(10, decimals);\n return Math.round(value * factor) / factor;\n}\n","import { clamp } from './math';\n\n/**\n * Represents an image width value — can be a pixel number, a percentage\n * string (e.g. \"50%\"), or the literal \"auto\" for full-width.\n */\nexport type ImageWidth = number | string;\n\nexport const MIN_IMAGE_WIDTH_PERCENTAGE = 5;\nexport const MAX_IMAGE_WIDTH_PERCENTAGE = 100;\n\nconst MAX_IMAGE_WIDTH_PIXELS = 600;\n\n/**\n * Converts any ImageWidth value to a clamped percentage number.\n * Handles \"auto\" (→ 100), percentage strings (e.g. \"50%\" → 50),\n * and legacy pixel numbers (converted relative to maxWidthPixels).\n * Returns 100 for null or unrecognized values.\n */\nexport function parseWidthToPercentage(\n width: ImageWidth | null,\n maxWidthPixels: number = MAX_IMAGE_WIDTH_PIXELS\n): number {\n if (typeof width === 'string') {\n if (width === 'auto') {\n return 100;\n }\n\n return width.endsWith('%')\n ? clampImageWidthPercentage(parseInt(width))\n : 100;\n }\n\n // it's here for backwards compatibility\n // use string instead of fixed number\n if (typeof width === 'number') {\n const percentage = Math.round((100 * width) / maxWidthPixels);\n return clampImageWidthPercentage(percentage);\n }\n\n return 100;\n}\n\nexport function clampImageWidthPercentage(width: number) {\n return clamp(width, [MIN_IMAGE_WIDTH_PERCENTAGE, MAX_IMAGE_WIDTH_PERCENTAGE]);\n}\n","/** Registry of all inline mark type strings used in the document JSON. */\nexport const MAILY_MARK_TYPES = {\n BOLD: 'bold',\n ITALIC: 'italic',\n STRIKE: 'strike',\n UNDERLINE: 'underline',\n LINK: 'link',\n CODE: 'code',\n TEXT_STYLE: 'textStyle',\n HIGHLIGHT: 'highlight',\n} as const;\n\nexport type MailyMarkType =\n (typeof MAILY_MARK_TYPES)[keyof typeof MAILY_MARK_TYPES];\n\nexport const allowedMarkTypes = Object.values(MAILY_MARK_TYPES);\n\n/**\n * Base shape shared by all inline marks. Individual mark types\n * narrow the type field and optionally add typed attrs.\n */\nexport type BaseMailyMark = {\n type: MailyMarkType;\n attrs?: Record<string, any>;\n};\n\n/** Bold */\nexport type BoldMark = BaseMailyMark & {\n type: typeof MAILY_MARK_TYPES.BOLD;\n};\n\n/** Italic */\nexport type ItalicMark = BaseMailyMark & {\n type: typeof MAILY_MARK_TYPES.ITALIC;\n};\n\n/** Strike */\nexport type StrikeMark = BaseMailyMark & {\n type: typeof MAILY_MARK_TYPES.STRIKE;\n};\n\n/** Underline */\nexport type UnderlineMark = BaseMailyMark & {\n type: typeof MAILY_MARK_TYPES.UNDERLINE;\n};\n\n/** Link */\nexport type LinkAttributes = {\n href: string;\n target?: string;\n};\n\nexport type LinkMark = BaseMailyMark & {\n type: typeof MAILY_MARK_TYPES.LINK;\n attrs: LinkAttributes;\n};\n\n/** Code */\nexport type CodeAttributes = {};\n\nexport type CodeMark = BaseMailyMark & {\n type: typeof MAILY_MARK_TYPES.CODE;\n attrs: CodeAttributes;\n};\n\n/** Text Style */\nexport type TextStyleAttributes = {\n color: string;\n};\n\nexport type TextStyleMark = BaseMailyMark & {\n type: typeof MAILY_MARK_TYPES.TEXT_STYLE;\n attrs: TextStyleAttributes;\n};\n\n/** Highlight */\nexport type HighlightAttributes = {\n color: string;\n};\n\nexport type HighlightMark = BaseMailyMark & {\n type: typeof MAILY_MARK_TYPES.HIGHLIGHT;\n attrs: HighlightAttributes;\n};\n\nexport type AnyMailyMark =\n | BoldMark\n | ItalicMark\n | StrikeMark\n | UnderlineMark\n | LinkMark\n | CodeMark\n | TextStyleMark\n | HighlightMark;\n","import type { AllowedTextAlignment } from './alignment';\nimport type { BorderStyleConfig } from './border';\nimport type { AllowedButtonKind } from './button-kind';\nimport type { AllowedFieldMode } from './field-mode';\nimport type { FontStyleAttributes } from './font-style';\nimport type { AllowedHtmlCodeBlockTab } from './html-code-block';\nimport type { MarginStyleConfig } from './margin';\nimport type { AnyMailyMark } from './mark';\nimport type { PaddingStyleConfig } from './padding';\nimport type { TextDirection } from './text-direction';\nimport type { VisibilityRule } from './visibility';\n\n/**\n * Registry of all document node type strings. These map 1:1 to\n * Tiptap extension names and are used as discriminators in the\n * document JSON.\n */\nexport const MAILY_NODE_TYPES = {\n DOCUMENT: 'doc',\n PARAGRAPH: 'paragraph',\n TEXT: 'text',\n HEADING: 'heading',\n VARIABLE: 'variable',\n IMAGE: 'image',\n SPACER: 'spacer',\n SECTION: 'section',\n COLUMNS: 'columns',\n COLUMN: 'column',\n BULLET_LIST: 'bulletList',\n ORDERED_LIST: 'orderedList',\n LIST_ITEM: 'listItem',\n HORIZONTAL_RULE: 'horizontalRule',\n BUTTON: 'button',\n REPEAT: 'repeat',\n HTML_CODE_BLOCK: 'htmlCodeBlock',\n BLOCKQUOTE: 'blockquote',\n HARD_BREAK: 'hardBreak',\n FOOTER: 'footer',\n INLINE_IMAGE: 'inlineImage',\n LINK_CARD: 'linkCard',\n} as const;\n\n/**\n * Tiptap extension types that attach attributes to nodes but are\n * not document nodes themselves (e.g. fontStyle, visibility).\n */\nexport const MAILY_EXTENSION_TYPES = {\n FONT_STYLE: 'fontStyle',\n VISIBILITY: 'visibility',\n} as const;\n\nexport const allowedNodeTypes = Object.values(MAILY_NODE_TYPES);\n\nexport type MailyNodeType =\n (typeof MAILY_NODE_TYPES)[keyof typeof MAILY_NODE_TYPES];\n\n/**\n * Global attributes mixed into every node by Tiptap extensions:\n * text direction, unique id, and conditional visibility.\n */\nexport type WithExtraAttrs = {\n dir?: TextDirection | null;\n id?: string | null;\n visibilityRule?: VisibilityRule | null;\n};\n\n/**\n * Base shape shared by all document nodes. Individual node types\n * narrow the type field, add typed attrs, and constrain content.\n */\nexport type BaseMailyNode = {\n type: MailyNodeType;\n attrs?: Record<string, any> & WithExtraAttrs;\n content?: AnyMailyNode[];\n marks?: AnyMailyMark[];\n text?: string;\n};\n\n/** Document */\nexport type DocumentAttributes = {\n version: number;\n};\n\nexport type DocumentNode = BaseMailyNode & {\n type: typeof MAILY_NODE_TYPES.DOCUMENT;\n attrs: DocumentAttributes;\n content: BaseMailyNode[];\n};\n\n/** Paragraph */\nexport type ParagraphAttributes = {\n id: string;\n textAlign: AllowedTextAlignment;\n} & FontStyleAttributes;\n\nexport type ParagraphNode = BaseMailyNode & {\n type: typeof MAILY_NODE_TYPES.PARAGRAPH;\n attrs: ParagraphAttributes;\n};\n\n/** Text */\nexport type TextNode = BaseMailyNode & {\n type: typeof MAILY_NODE_TYPES.TEXT;\n text: string;\n};\n\n/** Heading */\nexport type HeadingLevel = 1 | 2 | 3;\nexport type HeadingAttributes = {\n id: string;\n level: HeadingLevel;\n} & FontStyleAttributes;\n\nexport type HeadingNode = BaseMailyNode & {\n type: typeof MAILY_NODE_TYPES.HEADING;\n attrs: HeadingAttributes;\n};\n\n/**\n * Variable\n * Attributes for a template variable node. The id and label must not\n * contain `|` characters — that delimiter is used when serializing\n * variable data to plain text (see serializeVariableToText).\n */\nexport type VariableAttributes = {\n /** Stored as `data-id`. Identifies which variable this node represents. */\n id: string | null;\n /** Stored as `data-label`. Display text shown in the editor instead of the id. */\n label?: string | null;\n /** Stored as `data-fallback`. Used when the variable has no value at render time. */\n fallback?: string | null;\n required?: boolean;\n hideDefaultValue?: boolean;\n /** The character that opens the variable suggestion popup (e.g. `@`). */\n variableSuggestionChar?: string;\n};\n\nexport type VariableNode = BaseMailyNode & {\n type: typeof MAILY_NODE_TYPES.VARIABLE;\n attrs: VariableAttributes;\n content: never;\n};\n\n/** Image */\nexport type ImageAttributes = {\n src: string;\n alt?: string;\n title?: string;\n width: string;\n\n align: AllowedTextAlignment;\n externalLink: string | null;\n} & BorderStyleConfig;\n\nexport type ImageNode = BaseMailyNode & {\n type: typeof MAILY_NODE_TYPES.IMAGE;\n attrs: ImageAttributes;\n content: never;\n};\n\n/** Spacer */\nexport type SpacerAttributes = {\n height: number;\n heightMode: AllowedFieldMode;\n};\n\nexport type SpacerNode = BaseMailyNode & {\n type: typeof MAILY_NODE_TYPES.SPACER;\n attrs: SpacerAttributes;\n content: never;\n};\n\n/** Section */\nexport type SectionAttributes = {\n backgroundColor: string;\n align: AllowedTextAlignment;\n} & BorderStyleConfig &\n PaddingStyleConfig &\n MarginStyleConfig;\n\nexport type SectionNode = BaseMailyNode & {\n type: typeof MAILY_NODE_TYPES.SECTION;\n attrs: SectionAttributes;\n content: AnyMailyNode[];\n};\n\n/** Bullet List */\nexport type BulletListAttributes = {\n id: string;\n};\n\nexport type BulletListNode = BaseMailyNode & {\n type: typeof MAILY_NODE_TYPES.BULLET_LIST;\n attrs: BulletListAttributes;\n content: AnyMailyNode[];\n};\n\n/** Ordered List */\nexport type OrderedListAttributes = {\n id: string;\n};\n\nexport type OrderedListNode = BaseMailyNode & {\n type: typeof MAILY_NODE_TYPES.ORDERED_LIST;\n attrs: OrderedListAttributes;\n content: AnyMailyNode[];\n};\n\n/** List Item */\nexport type ListItemAttributes = {\n id: string;\n};\n\nexport type ListItemNode = BaseMailyNode & {\n type: typeof MAILY_NODE_TYPES.LIST_ITEM;\n attrs: ListItemAttributes;\n content: AnyMailyNode[];\n};\n\n/** Blockquote */\nexport type BlockquoteAttributes = {\n id: string;\n} & FontStyleAttributes;\n\nexport type BlockquoteNode = BaseMailyNode & {\n type: typeof MAILY_NODE_TYPES.BLOCKQUOTE;\n attrs: BlockquoteAttributes;\n content: AnyMailyNode[];\n};\n\n/** Horizontal Rule */\nexport type HorizontalRuleAttributes = {\n id: string;\n};\n\nexport type HorizontalRuleNode = BaseMailyNode & {\n type: typeof MAILY_NODE_TYPES.HORIZONTAL_RULE;\n attrs: HorizontalRuleAttributes;\n content: never;\n};\n\n/** Button */\nexport type ButtonAttributes = {\n url: string;\n kind: AllowedButtonKind;\n alignment: AllowedTextAlignment | null;\n backgroundColor: string | null;\n color: string | null;\n paddingMode: AllowedFieldMode;\n paddingTop: number;\n paddingRight: number;\n paddingBottom: number;\n paddingLeft: number;\n} & BorderStyleConfig &\n FontStyleAttributes;\n\nexport type ButtonNode = BaseMailyNode & {\n type: typeof MAILY_NODE_TYPES.BUTTON;\n attrs: ButtonAttributes;\n content: AnyMailyNode[];\n};\n\n/** HTML Code Block */\nexport type HtmlCodeBlockAttributes = {\n activeTab: AllowedHtmlCodeBlockTab;\n language: string;\n};\n\nexport type HtmlCodeBlockNode = BaseMailyNode & {\n type: typeof MAILY_NODE_TYPES.HTML_CODE_BLOCK;\n attrs: HtmlCodeBlockAttributes;\n content: AnyMailyNode[];\n};\n\n/** Repeat */\nexport type RepeatAttributes = {\n each: string;\n};\n\nexport type RepeatNode = BaseMailyNode & {\n type: typeof MAILY_NODE_TYPES.REPEAT;\n attrs: RepeatAttributes;\n content: AnyMailyNode[];\n};\n\n/** Columns (container for multiple columns) */\nexport type ColumnsAttributes = {\n columnCount: number;\n gap: number;\n};\n\nexport type ColumnsNode = BaseMailyNode & {\n type: typeof MAILY_NODE_TYPES.COLUMNS;\n attrs: ColumnsAttributes;\n content: ColumnNode[];\n};\n\n/** Column (individual column within columns container) */\nexport type ColumnAttributes = {\n width: number | null; // null = auto (equal space), number = percentage\n verticalAlign: 'top' | 'middle' | 'bottom';\n};\n\nexport type ColumnNode = BaseMailyNode & {\n type: typeof MAILY_NODE_TYPES.COLUMN;\n attrs: ColumnAttributes;\n content: AnyMailyNode[];\n};\n\n/** Hard Break */\nexport type HardBreakNode = BaseMailyNode & {\n type: typeof MAILY_NODE_TYPES.HARD_BREAK;\n content: never;\n};\n\n/** Footer */\nexport type FooterAttributes = {\n id: string;\n textAlign: AllowedTextAlignment;\n} & FontStyleAttributes;\n\nexport type FooterNode = BaseMailyNode & {\n type: typeof MAILY_NODE_TYPES.FOOTER;\n attrs: FooterAttributes;\n};\n\n/** Inline Image */\nexport type InlineImageAttributes = {\n src: string;\n alt?: string;\n title?: string;\n width: number;\n height: number;\n externalLink: string | null;\n};\n\nexport type InlineImageNode = BaseMailyNode & {\n type: typeof MAILY_NODE_TYPES.INLINE_IMAGE;\n attrs: InlineImageAttributes;\n content: never;\n};\n\n/** Link Card */\nexport type LinkCardAttributes = {\n title: string;\n description: string;\n link: string;\n linkTitle: string;\n image: string;\n subTitle: string;\n badgeText: string;\n};\n\nexport type LinkCardNode = BaseMailyNode & {\n type: typeof MAILY_NODE_TYPES.LINK_CARD;\n attrs: LinkCardAttributes;\n content: never;\n};\n\nexport type AnyMailyNode =\n | DocumentNode\n | ParagraphNode\n | TextNode\n | HeadingNode\n | VariableNode\n | ImageNode\n | SpacerNode\n | SectionNode\n | RepeatNode\n | ColumnsNode\n | ColumnNode\n | BulletListNode\n | OrderedListNode\n | ListItemNode\n | HorizontalRuleNode\n | ButtonNode\n | HtmlCodeBlockNode\n | BlockquoteNode\n | HardBreakNode\n | FooterNode\n | InlineImageNode\n | LinkCardNode;\n","import type {\n AnyMailyMark,\n BoldMark,\n CodeMark,\n HighlightMark,\n ItalicMark,\n LinkMark,\n MailyMarkType,\n StrikeMark,\n TextStyleMark,\n UnderlineMark,\n} from './mark';\nimport { allowedMarkTypes, MAILY_MARK_TYPES } from './mark';\nimport type {\n AnyMailyNode,\n BlockquoteNode,\n BulletListNode,\n ButtonNode,\n ColumnNode,\n ColumnsNode,\n DocumentNode,\n FooterNode,\n HardBreakNode,\n HeadingNode,\n HorizontalRuleNode,\n HtmlCodeBlockNode,\n ImageNode,\n InlineImageNode,\n LinkCardNode,\n ListItemNode,\n MailyNodeType,\n OrderedListNode,\n ParagraphNode,\n RepeatNode,\n SectionNode,\n SpacerNode,\n TextNode,\n VariableNode,\n} from './node';\nimport { allowedNodeTypes, MAILY_NODE_TYPES } from './node';\n\nfunction guard<T extends AnyMailyNode | AnyMailyMark>(type: string) {\n return (node: AnyMailyNode | AnyMailyMark): node is T => node.type === type;\n}\n\n/**\n * Type guards for Maily nodes and marks. Provides narrowing functions\n * for every node type (is.paragraph, is.button, etc.) and mark type\n * (is.bold, is.link, etc.), plus structural checks like is.parent\n * and is.marked. Each guard narrows the input to its specific type.\n *\n * Example:\n * if (is.paragraph(node)) {\n * node.attrs.textAlign // narrowed to ParagraphNode\n * }\n */\nexport const is = {\n any(value: unknown): value is AnyMailyNode | AnyMailyMark {\n return this.node(value) || this.mark(value);\n },\n parent(\n node: AnyMailyNode\n ): node is AnyMailyNode & { content: AnyMailyNode[] } {\n return Array.isArray(node?.content);\n },\n marked(node: AnyMailyNode): node is AnyMailyNode & { marks: AnyMailyMark[] } {\n return Array.isArray(node?.marks);\n },\n // Node\n node(node: unknown): node is AnyMailyNode {\n return (\n typeof node === 'object' &&\n node !== null &&\n 'type' in node &&\n allowedNodeTypes.includes(node.type as MailyNodeType)\n );\n },\n doc: guard<DocumentNode>(MAILY_NODE_TYPES.DOCUMENT),\n paragraph: guard<ParagraphNode>(MAILY_NODE_TYPES.PARAGRAPH),\n text: guard<TextNode>(MAILY_NODE_TYPES.TEXT),\n heading: guard<HeadingNode>(MAILY_NODE_TYPES.HEADING),\n variable: guard<VariableNode>(MAILY_NODE_TYPES.VARIABLE),\n image: guard<ImageNode>(MAILY_NODE_TYPES.IMAGE),\n inlineImage: guard<InlineImageNode>(MAILY_NODE_TYPES.INLINE_IMAGE),\n spacer: guard<SpacerNode>(MAILY_NODE_TYPES.SPACER),\n section: guard<SectionNode>(MAILY_NODE_TYPES.SECTION),\n button: guard<ButtonNode>(MAILY_NODE_TYPES.BUTTON),\n columns: guard<ColumnsNode>(MAILY_NODE_TYPES.COLUMNS),\n column: guard<ColumnNode>(MAILY_NODE_TYPES.COLUMN),\n repeat: guard<RepeatNode>(MAILY_NODE_TYPES.REPEAT),\n bulletList: guard<BulletListNode>(MAILY_NODE_TYPES.BULLET_LIST),\n orderedList: guard<OrderedListNode>(MAILY_NODE_TYPES.ORDERED_LIST),\n listItem: guard<ListItemNode>(MAILY_NODE_TYPES.LIST_ITEM),\n horizontalRule: guard<HorizontalRuleNode>(MAILY_NODE_TYPES.HORIZONTAL_RULE),\n htmlCodeBlock: guard<HtmlCodeBlockNode>(MAILY_NODE_TYPES.HTML_CODE_BLOCK),\n blockquote: guard<BlockquoteNode>(MAILY_NODE_TYPES.BLOCKQUOTE),\n hardBreak: guard<HardBreakNode>(MAILY_NODE_TYPES.HARD_BREAK),\n footer: guard<FooterNode>(MAILY_NODE_TYPES.FOOTER),\n linkCard: guard<LinkCardNode>(MAILY_NODE_TYPES.LINK_CARD),\n\n // Mark\n mark(mark: unknown): mark is AnyMailyMark {\n return (\n typeof mark === 'object' &&\n mark !== null &&\n 'type' in mark &&\n allowedMarkTypes.includes(mark.type as MailyMarkType)\n );\n },\n bold: guard<BoldMark>(MAILY_MARK_TYPES.BOLD),\n italic: guard<ItalicMark>(MAILY_MARK_TYPES.ITALIC),\n strike: guard<StrikeMark>(MAILY_MARK_TYPES.STRIKE),\n underline: guard<UnderlineMark>(MAILY_MARK_TYPES.UNDERLINE),\n link: guard<LinkMark>(MAILY_MARK_TYPES.LINK),\n code: guard<CodeMark>(MAILY_MARK_TYPES.CODE),\n textStyle: guard<TextStyleMark>(MAILY_MARK_TYPES.TEXT_STYLE),\n highlight: guard<HighlightMark>(MAILY_MARK_TYPES.HIGHLIGHT),\n};\n\n/** Type guard that checks if a value is defined (not null or undefined). */\nexport function isDef<T = any>(val?: T | null): val is T {\n return val !== undefined && val !== null;\n}\n\n/** Type guard that checks if a value is a boolean. */\nexport function isBoolean(val: any): val is boolean {\n return typeof val === 'boolean';\n}\n\n/** Type guard that checks if a value is a number. */\nexport function isNumber(val: any): val is number {\n return typeof val === 'number';\n}\n\n/** Type guard that checks if a value is a string. */\nexport function isString(val: unknown): val is string {\n return typeof val === 'string';\n}\n\n/** Type guard that checks if a value is a non-null object. */\nexport function isObject(val: unknown): val is object {\n return typeof val === 'object' && val !== null;\n}\n","import type { Properties } from 'csstype';\n\nimport type { FallbackFont, FontFormat } from './font';\nimport type { FontWeight } from './font-weight';\nimport { isDef } from './is';\n\n/**\n * Entry for the font picker dropdown. Web fonts include a CDN URL\n * and format for @font-face loading; system fonts omit the webFont field.\n */\nexport type FontFamilyItem = {\n fontFamily: string;\n label?: string;\n webFont?: { url: string; format: FontFormat };\n};\n\n/**\n * Built-in font options served from the Maily CDN. System fonts\n * (Arial, Helvetica, etc.) are included without a webFont field.\n */\nexport const DEFAULT_FONT_FAMILIES: FontFamilyItem[] = [\n {\n fontFamily: 'Inter',\n webFont: {\n url: 'https://cdn.usemaily.com/fonts/v0/inter.woff2',\n format: 'woff2',\n },\n },\n {\n fontFamily: 'Roboto',\n webFont: {\n url: 'https://cdn.usemaily.com/fonts/v0/roboto.woff2',\n format: 'woff2',\n },\n },\n {\n fontFamily: 'Open Sans',\n webFont: {\n url: 'https://cdn.usemaily.com/fonts/v0/open-sans.woff2',\n format: 'woff2',\n },\n },\n {\n fontFamily: 'Lato',\n webFont: {\n url: 'https://cdn.usemaily.com/fonts/v0/lato.woff2',\n format: 'woff2',\n },\n },\n {\n fontFamily: 'Montserrat',\n webFont: {\n url: 'https://cdn.usemaily.com/fonts/v0/montserrat.woff2',\n format: 'woff2',\n },\n },\n {\n fontFamily: 'Poppins',\n webFont: {\n url: 'https://cdn.usemaily.com/fonts/v0/poppins.woff2',\n format: 'woff2',\n },\n },\n {\n fontFamily: 'Raleway',\n webFont: {\n url: 'https://cdn.usemaily.com/fonts/v0/raleway.woff2',\n format: 'woff2',\n },\n },\n {\n fontFamily: 'Ubuntu',\n webFont: {\n url: 'https://cdn.usemaily.com/fonts/v0/ubuntu.woff2',\n format: 'woff2',\n },\n },\n { fontFamily: 'Arial' },\n { fontFamily: 'Helvetica' },\n { fontFamily: 'Georgia' },\n { fontFamily: 'Times New Roman' },\n { fontFamily: 'Verdana' },\n { fontFamily: 'Courier New' },\n { fontFamily: 'Trebuchet MS' },\n];\n\nexport type FontFamily = string;\n\nexport const FONT_STYLES = {\n NORMAL: 'normal',\n ITALIC: 'italic',\n} as const;\n\nexport type FontStyleValue = (typeof FONT_STYLES)[keyof typeof FONT_STYLES];\n\n/** Preset options for the font size dropdown in the editor. */\nexport const FONT_SIZE_PRESETS = [\n { value: 12, label: 'Small' },\n { value: 14, label: 'Normal' },\n { value: 16, label: 'Medium' },\n { value: 18, label: 'Large' },\n { value: 24, label: 'XL' },\n { value: 32, label: '2XL' },\n] as const;\n\n/** Preset options for the line height dropdown in the editor. */\nexport const LINE_HEIGHT_PRESETS = [\n { value: 1, label: 'Tight' },\n { value: 1.25, label: 'Snug' },\n { value: 1.5, label: 'Normal' },\n { value: 1.75, label: 'Relaxed' },\n { value: 2, label: 'Loose' },\n] as const;\n\nexport const DEFAULT_FONT_FAMILY: FontFamily = 'Inter';\nexport const DEFAULT_FONT_SIZE = 15;\nexport const DEFAULT_FONT_WEIGHT: FontWeight = 400;\nexport const DEFAULT_LINE_HEIGHT = 1.75;\nexport const DEFAULT_FONT_FALLBACK: FallbackFont = 'sans-serif';\n\n/**\n * Per-node font style overrides. Null values mean \"inherit from\n * the theme defaults\" — only non-null values produce inline CSS.\n */\nexport type FontStyleAttributes = {\n fontFamily: FontFamily | null;\n fontFallback: FallbackFont | null;\n fontSize: number | null;\n fontWeight: FontWeight | null;\n lineHeight: number | null;\n fontStyle: FontStyleValue | null;\n};\n\n/**\n * Baseline font values used when a node's FontStyleAttributes are null.\n * Each node type (paragraph, heading, button, etc.) has its own defaults\n * defined in the renderer theme.\n */\nexport type NodeFontStyleDefaults = {\n fontSize: number;\n lineHeight: number;\n fontWeight: number;\n fontStyle?: FontStyleValue;\n};\n\n/**\n * Builds a CSS properties object from a node's font attributes,\n * falling back to the provided defaults for any null values.\n * Only includes properties that have a resolved value.\n */\nexport function getFontStyle(\n attrs: FontStyleAttributes,\n defaults?: Partial<NodeFontStyleDefaults>\n): Properties {\n const {\n fontFamily,\n fontFallback,\n fontSize,\n fontWeight,\n lineHeight,\n fontStyle,\n } = attrs;\n\n const size = fontSize ?? defaults?.fontSize;\n const weight = fontWeight ?? defaults?.fontWeight;\n const line = lineHeight ?? defaults?.lineHeight;\n const style = fontStyle ?? defaults?.fontStyle;\n\n const fontFamilyParts = [fontFamily, fontFallback].filter(Boolean);\n\n return {\n ...(fontFamilyParts.length > 0 && {\n fontFamily: fontFamilyParts.join(', '),\n }),\n ...(isDef(size) ? { fontSize: `${size}px` } : {}),\n ...(isDef(weight) ? { fontWeight: weight } : {}),\n ...(isDef(line) ? { lineHeight: line } : {}),\n ...(isDef(style) ? { fontStyle: style } : {}),\n };\n}\n","/**\n * Numeric font weight values mapped to semantic names.\n * Normal (400), Medium (500), Semibold (600), Bold (700), Extra Bold (800).\n */\nexport const FONT_WEIGHTS = {\n NORMAL: 400,\n MEDIUM: 500,\n SEMIBOLD: 600,\n BOLD: 700,\n EXTRA_BOLD: 800,\n} as const;\n\nexport type FontWeight = (typeof FONT_WEIGHTS)[keyof typeof FONT_WEIGHTS];\n","export type Noop = () => void;\n\n/** A no-operation function. Useful as a default callback or placeholder. */\nexport function noop(): void {}\n","import { MAILY_BUG_REPORT_URL, MAILY_ERROR_PREFIX } from './constants';\n\n/**\n * Assertion function that throws if the value is false, null, or undefined.\n * Used as a development-time guard to catch impossible states early.\n * Logs a bug report URL before throwing to help with issue filing.\n */\nexport function invariant(value: boolean, message?: string): asserts value;\n\nexport function invariant<T>(\n value: T | null | undefined,\n message?: string\n): asserts value is T;\n\nexport function invariant(value: any, message?: string) {\n if (value === false || value === null || typeof value === 'undefined') {\n console.error(\n `${MAILY_ERROR_PREFIX}: The following error is a bug in Maily;\nPlease open an issue! ${MAILY_BUG_REPORT_URL}`\n );\n throw new Error(message);\n }\n}\n","import type { Properties } from 'csstype';\n\nimport type { AllowedFieldMode } from './field-mode';\nimport { FIELD_MODE } from './field-mode';\n\n/**\n * Per-side margin configuration for a node. Includes a field mode\n * that controls whether margin is edited uniformly or per-side,\n * and individual values for each side in pixels.\n */\nexport type MarginStyleConfig = {\n marginMode: AllowedFieldMode;\n marginTop: number;\n marginRight: number;\n marginBottom: number;\n marginLeft: number;\n};\n\n/**\n * Converts a MarginStyleConfig into CSS properties for inline styles.\n * When all sides are equal (or mode is \"uniform\"), emits shorthand CSS;\n * otherwise emits per-side longhand properties.\n */\nexport function getMarginStyle(config: MarginStyleConfig): Properties {\n const { marginMode, marginTop, marginRight, marginBottom, marginLeft } =\n config;\n\n const isMarginUniform =\n marginMode === FIELD_MODE.UNIFORM ||\n (marginLeft === marginRight &&\n marginRight === marginBottom &&\n marginBottom === marginTop);\n\n if (isMarginUniform) {\n return { margin: `${marginTop}px` };\n }\n\n return {\n marginTop: `${marginTop}px`,\n marginRight: `${marginRight}px`,\n marginBottom: `${marginBottom}px`,\n marginLeft: `${marginLeft}px`,\n };\n}\n","function isMergableObject(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\n/**\n * One-level deep merge of plain objects. Nested plain objects are\n * shallow-merged; primitives, arrays, and null are replaced outright.\n * Does not mutate the target — returns a new object.\n *\n * Example:\n * deepMerge({ a: 1, nested: { x: 1, y: 2 } }, { nested: { y: 3 } })\n * // => { a: 1, nested: { x: 1, y: 3 } }\n */\nexport function deepMerge<T extends object>(\n target: T,\n ...sources: Partial<T>[]\n): T {\n const result: Record<string, unknown> = { ...target } as Record<\n string,\n unknown\n >;\n\n for (const source of sources) {\n for (const [key, value] of Object.entries(source as object)) {\n result[key] =\n isMergableObject(value) && isMergableObject(result[key])\n ? { ...result[key], ...value }\n : value;\n }\n }\n\n return result as T;\n}\n\nexport function isObjectDeepEqual(first: object, second: object): boolean {\n if (first === second) {\n return true;\n }\n\n for (const key of Object.keys(first) as Array<keyof typeof first>) {\n if (first[key] !== (second as typeof first)[key]) {\n return false;\n }\n }\n\n return true;\n}\n","import type { Properties } from 'csstype';\n\nimport type { AllowedFieldMode } from './field-mode';\nimport { FIELD_MODE } from './field-mode';\n\n/**\n * Per-side padding configuration for a node. Includes a field mode\n * that controls whether padding is edited uniformly or per-side,\n * and individual values for each side in pixels.\n */\nexport type PaddingStyleConfig = {\n paddingMode: AllowedFieldMode;\n paddingTop: number;\n paddingRight: number;\n paddingBottom: number;\n paddingLeft: number;\n};\n\n/**\n * Converts a PaddingStyleConfig into CSS properties for inline styles.\n * When all sides are equal (or mode is \"uniform\"), emits shorthand CSS;\n * otherwise emits per-side longhand properties.\n */\nexport function getPaddingStyle(config: PaddingStyleConfig): Properties {\n const { paddingMode, paddingTop, paddingRight, paddingBottom, paddingLeft } =\n config;\n\n const isPaddingUniform =\n paddingMode === FIELD_MODE.UNIFORM ||\n (paddingLeft === paddingRight &&\n paddingRight === paddingBottom &&\n paddingBottom === paddingTop);\n\n if (isPaddingUniform) {\n return { padding: `${paddingTop}px` };\n }\n\n return {\n paddingTop: `${paddingTop}px`,\n paddingRight: `${paddingRight}px`,\n paddingBottom: `${paddingBottom}px`,\n paddingLeft: `${paddingLeft}px`,\n };\n}\n","/** Returns a promise that resolves after the given number of milliseconds. */\nexport function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n","/** Text direction values matching the HTML `dir` attribute: ltr, rtl, auto. */\nexport const TEXT_DIRECTIONS = {\n LTR: 'ltr',\n RTL: 'rtl',\n AUTO: 'auto',\n} as const;\n\nexport type TextDirection =\n (typeof TEXT_DIRECTIONS)[keyof typeof TEXT_DIRECTIONS];\n\nexport const allowedTextDirections: readonly TextDirection[] = Object.freeze(\n Object.values(TEXT_DIRECTIONS)\n);\n\nexport const DEFAULT_TEXT_DIRECTION: TextDirection = TEXT_DIRECTIONS.AUTO;\n\nexport function isAllowedTextDirection(value: unknown): value is TextDirection {\n return (\n typeof value === 'string' &&\n allowedTextDirections.includes(value as TextDirection)\n );\n}\n\n/**\n * Returns a CSS `direction` property object for the given dir value.\n * Returns an empty object for \"auto\" or nullish values, since the\n * browser default is sufficient in those cases.\n */\nexport function getCssDirection(\n dir: TextDirection | null | undefined\n): Record<string, Omit<TextDirection, typeof TEXT_DIRECTIONS.AUTO>> {\n if (dir && dir !== TEXT_DIRECTIONS.AUTO) {\n return { direction: dir };\n }\n\n return {};\n}\n","import type { FontProps } from './font';\nimport { DEFAULT_FONT } from './font';\nimport { FONT_STYLES } from './font-style';\nimport type { FontStyleValue, NodeFontStyleDefaults } from './font-style';\nimport { FONT_WEIGHTS } from './font-weight';\nimport type { HeadingLevel } from './node';\nimport { MAILY_NODE_TYPES } from './node';\n\n/**\n * Shared theme properties used by both the editor and renderer.\n * Controls global styling for the body, container, buttons, links,\n * and font. Extended by EditorThemeOptions and RendererThemeOptions.\n */\nexport interface BaseThemeOptions {\n container?: Partial<{\n backgroundColor: string;\n maxWidth: number;\n minWidth: number;\n borderRadius: number;\n borderWidth: number;\n borderColor: string;\n\n paddingTop: number;\n paddingRight: number;\n paddingBottom: number;\n paddingLeft: number;\n }>;\n body?: Partial<{\n backgroundColor: string;\n paddingTop: number;\n paddingRight: number;\n paddingBottom: number;\n paddingLeft: number;\n }>;\n button?: Partial<{\n paddingTop: number;\n paddingRight: number;\n paddingBottom: number;\n paddingLeft: number;\n backgroundColor: string;\n color: string;\n }>;\n link?: Partial<{\n color: string;\n }>;\n font?: Pick<\n FontProps,\n 'fontFamily' | 'fallbackFontFamily' | 'webFont'\n > | null;\n listMarker?: Partial<{\n color: string;\n }>;\n}\n\n/**\n * Editor-specific theme. Currently identical to the base — the editor\n * does not yet support per-node color customization, which is why\n * it's kept separate from the renderer theme.\n */\nexport interface EditorThemeOptions extends BaseThemeOptions {}\n\n/** Per-node styling overrides in the renderer theme. */\nexport type NodeThemeEntry = Partial<{\n color: string;\n fontSize: number;\n lineHeight: number;\n fontWeight: number;\n}>;\n\nexport type HeadingLevelTheme = Partial<{\n fontSize: number;\n lineHeight: number;\n fontWeight: number;\n}>;\n\n/**\n * Renderer-specific theme. Extends the base with per-node styling\n * grouped by node type — each key corresponds to a node and contains\n * all relevant style properties for that node.\n */\nexport interface RendererThemeOptions extends BaseThemeOptions {\n paragraph?: NodeThemeEntry;\n heading?: Partial<{\n defaults: Partial<{ color: string }>;\n h1: HeadingLevelTheme;\n h2: HeadingLevelTheme;\n h3: HeadingLevelTheme;\n }>;\n footer?: NodeThemeEntry;\n blockquote?: NodeThemeEntry &\n Partial<{\n borderColor: string;\n fontStyle: FontStyleValue;\n }>;\n horizontalRule?: Partial<{ color: string }>;\n code?: Partial<{ color: string; backgroundColor: string }>;\n\n button?: BaseThemeOptions['button'] &\n Partial<{\n fontSize: number;\n lineHeight: number;\n fontWeight: number;\n }>;\n linkCard?: Partial<{\n titleColor: string;\n descriptionColor: string;\n badgeTextColor: string;\n badgeBackgroundColor: string;\n subTitleColor: string;\n borderColor: string;\n }>;\n}\n\nexport const DEFAULT_LINK_TEXT_COLOR = '#111827';\n\nexport const DEFAULT_RENDERER_THEME: RendererThemeOptions = {\n paragraph: {\n color: '#374151',\n fontSize: 15,\n lineHeight: 1.75,\n fontWeight: FONT_WEIGHTS.NORMAL,\n },\n heading: {\n defaults: { color: '#111827' },\n h1: {\n fontSize: 36,\n lineHeight: 1.1111111,\n fontWeight: FONT_WEIGHTS.SEMIBOLD,\n },\n h2: {\n fontSize: 30,\n lineHeight: 1.3333333,\n fontWeight: FONT_WEIGHTS.SEMIBOLD,\n },\n h3: {\n fontSize: 24,\n lineHeight: 1.6,\n fontWeight: FONT_WEIGHTS.SEMIBOLD,\n },\n },\n footer: {\n color: '#64748B',\n fontSize: 14,\n lineHeight: 1.7142857,\n fontWeight: FONT_WEIGHTS.NORMAL,\n },\n blockquote: {\n color: '#374151',\n borderColor: '#D1D5DB',\n fontSize: 15,\n lineHeight: 1.75,\n fontWeight: FONT_WEIGHTS.MEDIUM,\n fontStyle: FONT_STYLES.ITALIC,\n },\n horizontalRule: { color: '#EAEAEA' },\n code: { color: '#111827', backgroundColor: '#EFEFEF' },\n linkCard: {\n titleColor: '#111827',\n descriptionColor: '#374151',\n badgeTextColor: '#374151',\n badgeBackgroundColor: '#fff085',\n subTitleColor: '#6B7280',\n borderColor: '#E5E7EB',\n },\n\n container: {\n backgroundColor: '#ffffff',\n maxWidth: 600,\n minWidth: 300,\n paddingTop: 8,\n paddingRight: 8,\n paddingBottom: 8,\n paddingLeft: 8,\n\n borderRadius: 0,\n borderWidth: 0,\n borderColor: 'transparent',\n },\n body: {\n backgroundColor: '#ffffff',\n\n paddingTop: 0,\n paddingRight: 0,\n paddingBottom: 0,\n paddingLeft: 0,\n },\n button: {\n backgroundColor: '#000000',\n color: '#ffffff',\n paddingTop: 10,\n paddingRight: 32,\n paddingBottom: 10,\n paddingLeft: 32,\n fontSize: 14,\n lineHeight: 1.4285714,\n fontWeight: FONT_WEIGHTS.SEMIBOLD,\n },\n link: {\n color: DEFAULT_LINK_TEXT_COLOR,\n },\n listMarker: {\n color: '#d1d5dc',\n },\n font: DEFAULT_FONT,\n};\n\nexport const DEFAULT_EDITOR_THEME: EditorThemeOptions = {\n container: {\n backgroundColor: '#ffffff',\n maxWidth: 600,\n minWidth: 300,\n paddingTop: 8,\n paddingRight: 8,\n paddingBottom: 8,\n paddingLeft: 8,\n\n borderRadius: 0,\n borderWidth: 0,\n borderColor: 'transparent',\n },\n body: {\n backgroundColor: '#ffffff',\n\n paddingTop: 0,\n paddingRight: 0,\n paddingBottom: 0,\n paddingLeft: 0,\n },\n button: {\n backgroundColor: '#000000',\n color: '#ffffff',\n paddingTop: 10,\n paddingRight: 32,\n paddingBottom: 10,\n paddingLeft: 32,\n },\n link: {\n color: DEFAULT_LINK_TEXT_COLOR,\n },\n font: DEFAULT_FONT,\n};\n\n/**\n * Resolves the baseline font defaults for a node type from the\n * renderer theme. Falls back to paragraph defaults for unknown types.\n */\nexport function getNodeFontStyleDefaults(\n nodeType: string,\n level?: HeadingLevel\n): NodeFontStyleDefaults {\n const paragraph = DEFAULT_RENDERER_THEME.paragraph!;\n const fallback: NodeFontStyleDefaults = {\n fontSize: paragraph.fontSize!,\n lineHeight: paragraph.lineHeight!,\n fontWeight: paragraph.fontWeight!,\n };\n\n if (nodeType === MAILY_NODE_TYPES.HEADING) {\n const heading = DEFAULT_RENDERER_THEME.heading;\n const key = `h${level ?? 1}` as 'h1' | 'h2' | 'h3';\n const entry = heading?.[key];\n return {\n fontSize: entry?.fontSize ?? fallback.fontSize,\n lineHeight: entry?.lineHeight ?? fallback.lineHeight,\n fontWeight: entry?.fontWeight ?? fallback.fontWeight,\n };\n }\n\n if (nodeType === MAILY_NODE_TYPES.BUTTON) {\n const btn = DEFAULT_RENDERER_THEME.button;\n return {\n fontSize: btn?.fontSize ?? fallback.fontSize,\n lineHeight: btn?.lineHeight ?? fallback.lineHeight,\n fontWeight: btn?.fontWeight ?? fallback.fontWeight,\n };\n }\n\n if (nodeType === MAILY_NODE_TYPES.BLOCKQUOTE) {\n const bq = DEFAULT_RENDERER_THEME.blockquote;\n return {\n fontSize: bq?.fontSize ?? fallback.fontSize,\n lineHeight: bq?.lineHeight ?? fallback.lineHeight,\n fontWeight: bq?.fontWeight ?? fallback.fontWeight,\n fontStyle: bq?.fontStyle ?? undefined,\n };\n }\n\n if (nodeType === MAILY_NODE_TYPES.FOOTER) {\n const ft = DEFAULT_RENDERER_THEME.footer;\n return {\n fontSize: ft?.fontSize ?? fallback.fontSize,\n lineHeight: ft?.lineHeight ?? fallback.lineHeight,\n fontWeight: ft?.fontWeight ?? fallback.fontWeight,\n };\n }\n\n return fallback;\n}\n","import { MAILY_NODE_TYPES } from './node';\nimport type { VariableAttributes } from './node';\n\n/** Default opening delimiter for variable placeholders in text. */\nexport const DEFAULT_VARIABLE_START_TRIGGER = '{{';\n\n/** Default closing delimiter for variable placeholders in text. */\nexport const DEFAULT_VARIABLE_END_TRIGGER = '}}';\n\n/**\n * Regex that matches variable placeholders like {{name}} in a string.\n * Uses a non-greedy match to handle multiple variables in one string.\n */\nexport const VARIABLE_PLACEHOLDER_REGEX = /({{.*?}})/g;\n\n/**\n * Delimiter used between fields inside a serialized variable string.\n * Format: {{id|label|required|hideDefaultValue}}.\n */\nexport const VARIABLE_TEXT_DELIMITER = '|';\n\n/**\n * Serializes a variable node's attributes into a delimited string.\n * Output format: `{{id|label|required|hideDefaultValue}}`.\n * Used to represent structured variable data as a template string\n * in plain text contexts.\n */\nexport function serializeVariableToText(variable: VariableAttributes): string {\n const { id, label, required = true, hideDefaultValue = false } = variable;\n\n return [\n DEFAULT_VARIABLE_START_TRIGGER,\n defaultStringifyValue(id),\n VARIABLE_TEXT_DELIMITER,\n defaultStringifyValue(label),\n VARIABLE_TEXT_DELIMITER,\n required,\n VARIABLE_TEXT_DELIMITER,\n hideDefaultValue,\n DEFAULT_VARIABLE_END_TRIGGER,\n ].join('');\n}\n\nfunction defaultStringifyValue(value: string | null | undefined) {\n return value ?? '';\n}\n\n/**\n * Deserializes a variable string back into VariableAttributes.\n * Expected input format: `{{id|label|required|hideDefaultValue}}`.\n * Missing fields default to undefined; boolean fields are parsed\n * from \"true\"/\"false\" strings.\n */\nexport function deserializeVariableFromText(text: string): VariableAttributes {\n const inner = text\n .slice(\n DEFAULT_VARIABLE_START_TRIGGER.length,\n text.length - DEFAULT_VARIABLE_END_TRIGGER.length\n )\n .trim();\n\n const [id, label, required, hideDefaultValue] = inner.split(\n VARIABLE_TEXT_DELIMITER\n );\n\n return {\n id,\n label: label || null,\n required: parseBoolean(required, true),\n hideDefaultValue: parseBoolean(hideDefaultValue, false),\n };\n}\n\n/**\n * Parses a string containing variable placeholders (e.g. \"Hello {{name}}\")\n * into a Tiptap-compatible document JSON with text and variable nodes.\n * Splits on {{...}} boundaries and creates the appropriate node type\n * for each segment.\n */\nexport function buildDocFromVariableText(content: string) {\n const parts = content.split(VARIABLE_PLACEHOLDER_REGEX);\n\n return {\n type: MAILY_NODE_TYPES.DOCUMENT,\n content: [\n {\n type: MAILY_NODE_TYPES.PARAGRAPH,\n content: parts\n .flatMap((part) => {\n if (\n part.startsWith(DEFAULT_VARIABLE_START_TRIGGER) &&\n part.endsWith(DEFAULT_VARIABLE_END_TRIGGER)\n ) {\n return {\n type: MAILY_NODE_TYPES.VARIABLE,\n attrs: deserializeVariableFromText(part),\n };\n }\n\n if (part) {\n return { type: MAILY_NODE_TYPES.TEXT, text: part };\n }\n\n return [];\n })\n .filter(Boolean),\n },\n ],\n };\n}\n\n/**\n * Checks if a string contains at least one variable placeholder.\n * Returns true for strings like \"Hello {{name}}\", false for plain text.\n * Uses index-based scanning instead of regex for performance.\n */\nexport function hasVariableInText(text: string): boolean {\n const start = text.indexOf(DEFAULT_VARIABLE_START_TRIGGER);\n if (start === -1) {\n return false;\n }\n\n return (\n text.indexOf(\n DEFAULT_VARIABLE_END_TRIGGER,\n start + DEFAULT_VARIABLE_START_TRIGGER.length\n ) !== -1\n );\n}\n\nfunction parseBoolean(\n value?: string,\n defaultValue?: boolean\n): boolean | undefined {\n if (value === 'true') {\n return true;\n }\n if (value === 'false') {\n return false;\n }\n\n return defaultValue;\n}\n","/**\n * Comparison operators for conditional visibility rules.\n * Used to evaluate a template variable against a value\n * to decide whether a node should be shown or hidden.\n */\nexport const VISIBILITY_OPERATORS = {\n IS_TRUE: 'is_true',\n IS_FALSE: 'is_false',\n EQUALS: 'equals',\n NOT_EQUALS: 'not_equals',\n CONTAINS: 'contains',\n NOT_CONTAINS: 'not_contains',\n STARTS_WITH: 'starts_with',\n ENDS_WITH: 'ends_with',\n GREATER_THAN: 'greater_than',\n LESS_THAN: 'less_than',\n} as const;\n\nexport type AllowedVisibilityOperator =\n (typeof VISIBILITY_OPERATORS)[keyof typeof VISIBILITY_OPERATORS];\n\nexport const VISIBILITY_OPERATOR_OPTIONS: {\n value: AllowedVisibilityOperator;\n label: string;\n}[] = [\n { value: VISIBILITY_OPERATORS.IS_TRUE, label: 'Is true' },\n { value: VISIBILITY_OPERATORS.IS_FALSE, label: 'Is false' },\n { value: VISIBILITY_OPERATORS.EQUALS, label: 'Equals' },\n { value: VISIBILITY_OPERATORS.NOT_EQUALS, label: 'Not equals' },\n { value: VISIBILITY_OPERATORS.CONTAINS, label: 'Contains' },\n { value: VISIBILITY_OPERATORS.NOT_CONTAINS, label: 'Not contains' },\n { value: VISIBILITY_OPERATORS.STARTS_WITH, label: 'Starts with' },\n { value: VISIBILITY_OPERATORS.ENDS_WITH, label: 'Ends with' },\n { value: VISIBILITY_OPERATORS.GREATER_THAN, label: 'Greater than' },\n { value: VISIBILITY_OPERATORS.LESS_THAN, label: 'Less than' },\n];\n\n/**\n * Unary operators that don't require a comparison value.\n * The UI hides the value input field when one of these is selected.\n */\nexport const OPERATORS_WITHOUT_VALUE: AllowedVisibilityOperator[] = [\n VISIBILITY_OPERATORS.IS_TRUE,\n VISIBILITY_OPERATORS.IS_FALSE,\n];\n\nexport const VISIBILITY_ACTIONS = {\n NONE: 'none',\n SHOW: 'show',\n HIDE: 'hide',\n} as const;\n\nexport type AllowedVisibilityAction =\n (typeof VISIBILITY_ACTIONS)[keyof typeof VISIBILITY_ACTIONS];\n\nexport const VISIBILITY_ACTION_OPTIONS: {\n value: AllowedVisibilityAction;\n label: string;\n}[] = [\n { value: VISIBILITY_ACTIONS.NONE, label: 'None' },\n { value: VISIBILITY_ACTIONS.SHOW, label: 'Show if' },\n { value: VISIBILITY_ACTIONS.HIDE, label: 'Hide if' },\n];\n\n/**\n * Defines when a node is conditionally shown or hidden based on\n * a template variable. Evaluated at render time by the renderer.\n */\nexport type VisibilityRule = {\n action: AllowedVisibilityAction;\n variable: string;\n operator: AllowedVisibilityOperator;\n value: string;\n};\n\n/** Mixin for nodes that support conditional visibility. */\nexport type WithVisibilityAttrs = {\n visibilityRule?: VisibilityRule | null;\n};\n"],"mappings":";AAAA,MAAa,kBAAkB;CAC7B,MAAM;CACN,QAAQ;CACR,OAAO;CACR;AAKD,MAAa,oBAAqD,OAAO,OACvE,OAAO,OAAO,gBAAgB,CAC/B;AAED,MAAa,qBAA2C,gBAAgB;AAExE,SAAgB,uBACd,OAC+B;AAC/B,QACE,OAAO,UAAU,YACjB,kBAAkB,SAAS,MAA8B;;;;;;;;;;ACd7D,MAAa,aAAa;CACxB,MAAM;CACN,OAAO;CACP,SAAS;CACT,QAAQ;CACT;AAID,MAAa,oBAAoB,OAAO,OACtC,WACD;AAED,SAAgB,mBAAmB,MAAyC;AAC1E,QACE,OAAO,SAAS,YAChB,kBAAkB,SAAS,KAAyB;;;;AC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ACvD,MAAM,QAAQ,KAAK,QAAA,KAAuC;AAC1D,KAAI,UAAU,GACZ,QAAO;AAGT,QACE,KAAK,QAAA,MAEH,QAAQ,EACT,KAAK;;AAIV,SAAS,aACP,OACA,cACqB;AACrB,KAAI,UAAU,OACZ,QAAO;AAET,KAAI,UAAU,QACZ,QAAO;AAGT,QAAO;;;;;;;;;ACxIT,MAAa,uBAAuB;CAClC,SAAS;CACT,UAAU;CACV,QAAQ;CACR,YAAY;CACZ,UAAU;CACV,cAAc;CACd,aAAa;CACb,WAAW;CACX,cAAc;CACd,WAAW;CACZ;AAKD,MAAa,8BAGP;CACJ;EAAE,OAAO,qBAAqB;EAAS,OAAO;EAAW;CACzD;EAAE,OAAO,qBAAqB;EAAU,OAAO;EAAY;CAC3D;EAAE,OAAO,qBAAqB;EAAQ,OAAO;EAAU;CACvD;EAAE,OAAO,qBAAqB;EAAY,OAAO;EAAc;CAC/D;EAAE,OAAO,qBAAqB;EAAU,OAAO;EAAY;CAC3D;EAAE,OAAO,qBAAqB;EAAc,OAAO;EAAgB;CACnE;EAAE,OAAO,qBAAqB;EAAa,OAAO;EAAe;CACjE;EAAE,OAAO,qBAAqB;EAAW,OAAO;EAAa;CAC7D;EAAE,OAAO,qBAAqB;EAAc,OAAO;EAAgB;CACnE;EAAE,OAAO,qBAAqB;EAAW,OAAO;EAAa;CAC9D;;;;;AAMD,MAAa,0BAAuD,CAClE,qBAAqB,SACrB,qBAAqB,SACtB;AAED,MAAa,qBAAqB;CAChC,MAAM;CACN,MAAM;CACN,MAAM;CACP;AAKD,MAAa,4BAGP;CACJ;EAAE,OAAO,mBAAmB;EAAM,OAAO;EAAQ;CACjD;EAAE,OAAO,mBAAmB;EAAM,OAAO;EAAW;CACpD;EAAE,OAAO,mBAAmB;EAAM,OAAO;EAAW;CACrD"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/alignment.ts","../src/border.ts","../src/box.ts","../src/button.ts","../src/math.ts","../src/column.ts","../src/constants.ts","../src/font.ts","../src/font-style.ts","../src/font-weight.ts","../src/function.ts","../src/html-code-block.ts","../src/image.ts","../src/invariant.ts","../src/mark.ts","../src/node.ts","../src/is.ts","../src/object.ts","../src/spacing.ts","../src/style.ts","../src/direction.ts","../src/variable.ts","../src/visibility.ts","../src/theme.ts"],"sourcesContent":["export const TEXT_ALIGNMENTS = {\n LEFT: 'left',\n CENTER: 'center',\n RIGHT: 'right',\n} as const;\n\nexport type AllowedTextAlignment =\n (typeof TEXT_ALIGNMENTS)[keyof typeof TEXT_ALIGNMENTS];\n\nconst allowedTextAligns: readonly AllowedTextAlignment[] = Object.freeze(\n Object.values(TEXT_ALIGNMENTS)\n);\n\nexport const DEFAULT_TEXT_ALIGN: AllowedTextAlignment = TEXT_ALIGNMENTS.LEFT;\n\nexport function isAllowedTextAlignment(\n value: unknown\n): value is AllowedTextAlignment {\n return (\n typeof value === 'string' &&\n allowedTextAligns.includes(value as AllowedTextAlignment)\n );\n}\n","import type { InlineStyle } from './style';\n\nexport const BORDER_STYLES = {\n SOLID: 'solid',\n DASHED: 'dashed',\n DOTTED: 'dotted',\n} as const;\n\nexport type AllowedBorderStyle =\n (typeof BORDER_STYLES)[keyof typeof BORDER_STYLES];\n\nconst allowedBorderStyles: readonly AllowedBorderStyle[] = Object.freeze(\n Object.values(BORDER_STYLES)\n);\n\nexport const DEFAULT_BORDER_STYLE: AllowedBorderStyle = BORDER_STYLES.SOLID;\n\nexport function isAllowedBorderStyle(\n value: unknown\n): value is AllowedBorderStyle {\n return (\n typeof value === 'string' &&\n allowedBorderStyles.includes(value as AllowedBorderStyle)\n );\n}\n\nexport type BorderParts = {\n color: string | undefined;\n style: string | undefined;\n width: string | undefined;\n};\n\n/**\n * Reads the width, style and colour of a border from the `border` shorthand,\n * letting any longhand already in the style win. The shorthand lists its\n * parts in any order, so each is recognised by shape rather than position.\n */\nexport function getBorderParts(style: InlineStyle): BorderParts {\n const parts = (style.border ?? '').trim().split(/\\s+/).filter(Boolean);\n\n let color: string | undefined;\n let borderStyle: string | undefined;\n let width: string | undefined;\n\n for (const part of parts) {\n if (isAllowedBorderStyle(part) || part === 'none') {\n borderStyle = part;\n } else if (/^[\\d.]/.test(part)) {\n width = part;\n } else {\n color = part;\n }\n }\n\n return {\n color: style.borderColor ?? color,\n style: style.borderStyle ?? borderStyle,\n width: style.borderWidth ?? width,\n };\n}\n","import type { InlineStyle } from './style';\n\nexport const BOX_SIDES = ['top', 'right', 'bottom', 'left'] as const;\nexport type BoxSide = (typeof BOX_SIDES)[number];\nexport type BoxSideValues = Record<BoxSide, number>;\n\nexport const BOX_CORNERS = [\n 'topLeft',\n 'topRight',\n 'bottomRight',\n 'bottomLeft',\n] as const;\nexport type BoxCorner = (typeof BOX_CORNERS)[number];\nexport type BoxCornerValues = Record<BoxCorner, number>;\n\nfunction capitalize(value: string) {\n return value.charAt(0).toUpperCase() + value.slice(1);\n}\n\n/**\n * CSS box shorthands repeat their values when fewer than four are given:\n * one applies to every edge, two to the vertical then horizontal pair, and\n * three to top, the horizontal pair, then bottom.\n */\nfunction getShorthandEdges(shorthand: string | undefined) {\n const parts = (shorthand ?? '').trim().split(/\\s+/).filter(Boolean);\n if (parts.length === 0) {\n return null;\n }\n\n const [first, second = first, third = first, fourth = second] = parts;\n\n return [first, second, third, fourth].map(toLength);\n}\n\nfunction toLength(value: string) {\n const parsed = Number.parseFloat(value);\n\n return Number.isNaN(parsed) ? 0 : parsed;\n}\n\nfunction getLonghand(\n style: InlineStyle,\n property: string,\n edge: string,\n suffix: string\n) {\n return style[`${property}${capitalize(edge)}${suffix}`];\n}\n\nfunction toShorthand(edges: number[]) {\n const [first, second, third, fourth] = edges;\n const values =\n first === third && second === fourth\n ? first === second\n ? [first]\n : [first, second]\n : [first, second, third, fourth];\n\n return values.map((value) => `${value}px`).join(' ');\n}\n\nexport function getBoxSides(\n style: InlineStyle,\n property: string\n): BoxSideValues {\n const edges = getShorthandEdges(style[property]) ?? [0, 0, 0, 0];\n const [top, right, bottom, left] = edges;\n const sides: BoxSideValues = { bottom, left, right, top };\n\n for (const side of BOX_SIDES) {\n const longhand = getLonghand(style, property, side, '');\n if (longhand !== undefined) {\n sides[side] = toLength(longhand);\n }\n }\n\n return sides;\n}\n\nexport function toBoxSides(\n property: string,\n values: BoxSideValues\n): Record<string, string | null> {\n const declarations: Record<string, string | null> = {\n [property]: toShorthand([\n values.top,\n values.right,\n values.bottom,\n values.left,\n ]),\n };\n\n for (const side of BOX_SIDES) {\n declarations[`${property}${capitalize(side)}`] = null;\n }\n\n return declarations;\n}\n\n/**\n * Radius shorthands run clockwise from the top-left corner, and repeat the\n * same way box shorthands do.\n */\nexport function getBoxCorners(\n style: InlineStyle,\n property: string\n): BoxCornerValues {\n const edges = getShorthandEdges(style[property]) ?? [0, 0, 0, 0];\n const [topLeft, topRight, bottomRight, bottomLeft] = edges;\n const corners: BoxCornerValues = {\n bottomLeft,\n bottomRight,\n topLeft,\n topRight,\n };\n\n for (const corner of BOX_CORNERS) {\n const longhand = getLonghand(style, 'border', corner, 'Radius');\n if (longhand !== undefined) {\n corners[corner] = toLength(longhand);\n }\n }\n\n return corners;\n}\n\nexport function toBoxCorners(\n property: string,\n values: BoxCornerValues\n): Record<string, string | null> {\n const declarations: Record<string, string | null> = {\n [property]: toShorthand([\n values.topLeft,\n values.topRight,\n values.bottomRight,\n values.bottomLeft,\n ]),\n };\n\n for (const corner of BOX_CORNERS) {\n declarations[`border${capitalize(corner)}Radius`] = null;\n }\n\n return declarations;\n}\n","/**\n * Button layout kinds.\n * \"tight\" renders the button at its content width,\n * \"full-width\" stretches it to fill the container.\n */\nexport const BUTTON_KINDS = {\n TIGHT: 'tight',\n FULL_WIDTH: 'full-width',\n} as const;\n\nexport type AllowedButtonKind =\n (typeof BUTTON_KINDS)[keyof typeof BUTTON_KINDS];\n\nconst allowedButtonKinds: readonly AllowedButtonKind[] = Object.freeze(\n Object.values(BUTTON_KINDS)\n);\n\nexport const DEFAULT_BUTTON_KIND: AllowedButtonKind = BUTTON_KINDS.TIGHT;\n\nexport function isAllowedButtonKind(\n value: unknown\n): value is AllowedButtonKind {\n return (\n typeof value === 'string' &&\n allowedButtonKinds.includes(value as AllowedButtonKind)\n );\n}\n","export function clamp(value: number, [min, max]: [number, number]): number {\n return Math.min(Math.max(value, min), max);\n}\n\nexport function percentage(portion: number, total: number): number {\n return clamp((portion / total) * 100, [0, 100]);\n}\n\nexport function roundTo(value: number, decimals: number): number {\n const factor = 10 ** decimals;\n\n return Math.round(value * factor) / factor;\n}\n\nexport function absoluteFromPercentage(\n percentage: number,\n total: number\n): number {\n return Math.round((total * percentage) / 100);\n}\n","import { roundTo } from './math';\n\nexport type ColumnWidth = number | string;\n\nconst PERCENTAGE_PATTERN = /^(\\d+(?:\\.\\d+)?)%$/;\nconst PIXEL_PATTERN = /^(\\d+(?:\\.\\d+)?)px$/;\nconst CSS_LENGTH_PATTERN =\n /^\\d+(?:\\.\\d+)?(?:px|pt|pc|in|cm|mm|em|rem|ex|ch|vw|vh|vmin|vmax)$/;\n\nexport function getColumnWidth(\n value: string | null | undefined\n): ColumnWidth | null {\n const declaration = value?.trim();\n if (!declaration) {\n return null;\n }\n\n const percentage = PERCENTAGE_PATTERN.exec(declaration);\n if (percentage) {\n return Number(percentage[1]);\n }\n\n return CSS_LENGTH_PATTERN.test(declaration) ? declaration : null;\n}\n\nexport function getColumnWidthValue(width: ColumnWidth): string {\n return typeof width === 'number' ? `${width}%` : width;\n}\n\ntype ColumnWidthPercentOptions = {\n containerWidth: number;\n width: ColumnWidth | null | undefined;\n};\n\nexport function getColumnWidthPercent(\n options: ColumnWidthPercentOptions\n): number | null {\n const { containerWidth, width } = options;\n\n if (width === null || width === undefined) {\n return null;\n }\n\n if (typeof width === 'number') {\n return width;\n }\n\n const percentage = PERCENTAGE_PATTERN.exec(width);\n if (percentage) {\n return Number(percentage[1]);\n }\n\n const pixels = PIXEL_PATTERN.exec(width);\n if (pixels && containerWidth > 0) {\n return roundTo((Number(pixels[1]) / containerWidth) * 100, 3);\n }\n\n return null;\n}\n","export const DATA_NODE_TYPE_KEY = 'data-node-type';\n\nexport const MAILY_ERROR_PREFIX = '[Maily Error]';\n\nexport const MAILY_BUG_REPORT_URL =\n 'https://github.com/arikchakma/maily.to/issues/new';\n","import type { Properties } from 'csstype';\n\n/**\n * List of allowed fallback font families. These are system fonts or\n * generic font families that serve as fallbacks when a web font\n * fails to load.\n */\nexport const allowedFallbackFonts = [\n 'Arial',\n 'Helvetica',\n 'Verdana',\n 'Georgia',\n 'Times New Roman',\n 'serif',\n 'sans-serif',\n 'monospace',\n 'cursive',\n 'fantasy',\n] as const;\n\nexport type FallbackFont = (typeof allowedFallbackFonts)[number];\n\nconst allowedFontFormats = [\n 'woff',\n 'woff2',\n 'truetype',\n 'opentype',\n 'embedded-opentype',\n 'svg',\n] as const;\n\nexport type FontFormat = (typeof allowedFontFormats)[number];\n\ntype FontStyle = Properties['fontStyle'];\n\n/**\n * Configuration for a font used in the editor or renderer.\n * Specifies the primary font family, a fallback, and an optional\n * web font URL with its format for @font-face loading.\n */\nexport interface FontProps {\n fontFamily: string;\n fallbackFontFamily: FallbackFont;\n webFont?: {\n url: string;\n format: FontFormat;\n };\n fontStyle?: FontStyle;\n fontWeight?: number;\n}\n\n/**\n * Default font configuration: Inter with sans-serif fallback,\n * loaded from the Maily CDN as woff2.\n */\nexport const DEFAULT_FONT: FontProps = {\n fallbackFontFamily: 'sans-serif',\n fontFamily: 'Inter',\n webFont: {\n format: 'woff2',\n url: 'https://cdn.usemaily.com/fonts/v0/inter.woff2',\n },\n};\n\nexport function getFontFamilyNames(value: string): string[] {\n return value\n .split(',')\n .map((font) => {\n return font.trim().replace(/['\"]/g, '');\n })\n .filter(Boolean);\n}\n\nexport type FontFamilyValueOptions = {\n fallbackFontFamily?: string | null;\n fontFamily?: string | null;\n};\n\nexport function getFontFamilyValue(options: FontFamilyValueOptions): string {\n const { fallbackFontFamily, fontFamily } = options;\n\n return [fontFamily ? `'${fontFamily}'` : null, fallbackFontFamily]\n .filter(Boolean)\n .join(', ');\n}\n\n/**\n * Generates a @font-face CSS rule string for the given font configuration.\n * Includes the font family, style, weight, MSO fallback, and web font\n * source URL when available.\n */\nexport function getFontFaceStyle(font: FontProps): string {\n const {\n fallbackFontFamily,\n fontFamily,\n fontStyle = 'normal',\n fontWeight = 400,\n webFont,\n } = font;\n\n const src = webFont\n ? `src: url(${webFont.url}) format('${webFont.format}');`\n : '';\n\n return /* css */ `@font-face {font-family: '${fontFamily}';font-style: ${fontStyle};font-weight: ${fontWeight};mso-font-alt: '${fallbackFontFamily}';${src}}`;\n}\n\n/**\n * Injects a @font-face style element into the document head to load\n * the given font. Only works in browser environments.\n */\nexport function loadFont(font: FontProps): void {\n const styleElement = document.createElement('style');\n styleElement.textContent = getFontFaceStyle(font);\n document.head.appendChild(styleElement);\n}\n","import type { FallbackFont, FontFormat } from './font';\n\n/**\n * Entry for the font picker dropdown. Web fonts include a CDN URL\n * and format for @font-face loading; system fonts omit the webFont field.\n */\nexport type FontFamilyItem = {\n fontFamily: string;\n label?: string;\n webFont?: { url: string; format: FontFormat };\n};\n\n/**\n * Built-in font options served from the Maily CDN. System fonts\n * (Arial, Helvetica, etc.) are included without a webFont field.\n */\nexport const DEFAULT_FONT_FAMILIES: FontFamilyItem[] = [\n {\n fontFamily: 'Inter',\n webFont: {\n format: 'woff2',\n url: 'https://cdn.usemaily.com/fonts/v0/inter.woff2',\n },\n },\n {\n fontFamily: 'Roboto',\n webFont: {\n format: 'woff2',\n url: 'https://cdn.usemaily.com/fonts/v0/roboto.woff2',\n },\n },\n {\n fontFamily: 'Open Sans',\n webFont: {\n format: 'woff2',\n url: 'https://cdn.usemaily.com/fonts/v0/open-sans.woff2',\n },\n },\n {\n fontFamily: 'Lato',\n webFont: {\n format: 'woff2',\n url: 'https://cdn.usemaily.com/fonts/v0/lato.woff2',\n },\n },\n {\n fontFamily: 'Montserrat',\n webFont: {\n format: 'woff2',\n url: 'https://cdn.usemaily.com/fonts/v0/montserrat.woff2',\n },\n },\n {\n fontFamily: 'Poppins',\n webFont: {\n format: 'woff2',\n url: 'https://cdn.usemaily.com/fonts/v0/poppins.woff2',\n },\n },\n {\n fontFamily: 'Raleway',\n webFont: {\n format: 'woff2',\n url: 'https://cdn.usemaily.com/fonts/v0/raleway.woff2',\n },\n },\n {\n fontFamily: 'Ubuntu',\n webFont: {\n format: 'woff2',\n url: 'https://cdn.usemaily.com/fonts/v0/ubuntu.woff2',\n },\n },\n { fontFamily: 'Arial' },\n { fontFamily: 'Helvetica' },\n { fontFamily: 'Georgia' },\n { fontFamily: 'Times New Roman' },\n { fontFamily: 'Verdana' },\n { fontFamily: 'Courier New' },\n { fontFamily: 'Trebuchet MS' },\n];\n\nexport type FontFamily = string;\n\nexport const FONT_STYLES = {\n NORMAL: 'normal',\n ITALIC: 'italic',\n} as const;\n\nexport type FontStyleValue = (typeof FONT_STYLES)[keyof typeof FONT_STYLES];\n\nexport const FONT_SIZE_PRESETS = [\n { value: 12, label: 'Small' },\n { value: 14, label: 'Normal' },\n { value: 16, label: 'Medium' },\n { value: 18, label: 'Large' },\n { value: 24, label: 'XL' },\n { value: 32, label: '2XL' },\n] as const;\n\nexport const LINE_HEIGHT_PRESETS = [\n { value: 1, label: 'Tight' },\n { value: 1.25, label: 'Snug' },\n { value: 1.5, label: 'Normal' },\n { value: 1.75, label: 'Relaxed' },\n { value: 2, label: 'Loose' },\n] as const;\n\nexport const DEFAULT_FONT_FAMILY: FontFamily = 'Inter';\nexport const DEFAULT_FONT_FALLBACK: FallbackFont = 'sans-serif';\n","/**\n * Numeric font weight values mapped to semantic names.\n * Normal (400), Medium (500), Semibold (600), Bold (700), Extra Bold (800).\n */\nexport const FONT_WEIGHTS = {\n NORMAL: 400,\n MEDIUM: 500,\n SEMIBOLD: 600,\n BOLD: 700,\n EXTRA_BOLD: 800,\n} as const;\n\nexport type FontWeight = (typeof FONT_WEIGHTS)[keyof typeof FONT_WEIGHTS];\n","export function noop(): void {}\n","/**\n * Tab options for the HTML code block node.\n * \"code\" shows the raw HTML source, \"preview\" renders it visually.\n */\nexport const HTML_CODE_BLOCK_TABS = {\n CODE: 'code',\n PREVIEW: 'preview',\n} as const;\n\nexport type AllowedHtmlCodeBlockTab =\n (typeof HTML_CODE_BLOCK_TABS)[keyof typeof HTML_CODE_BLOCK_TABS];\n\nexport const DEFAULT_HTML_CODE_BLOCK_TAB: AllowedHtmlCodeBlockTab =\n HTML_CODE_BLOCK_TABS.CODE;\n","import { clamp } from './math';\n\nexport type ImageWidth = number | string;\n\nexport const MIN_IMAGE_WIDTH_PERCENTAGE = 5;\nexport const MAX_IMAGE_WIDTH_PERCENTAGE = 100;\n\nexport const DEFAULT_CONTAINER_WIDTH_PIXELS = 600;\n\nconst PIXEL_SUFFIX = 'px';\n\nfunction getPixels(value: string) {\n const length = value.endsWith(PIXEL_SUFFIX)\n ? value.slice(0, -PIXEL_SUFFIX.length)\n : value;\n\n if (length === '') {\n return null;\n }\n\n const pixels = Number(length);\n\n return Number.isFinite(pixels) ? pixels : null;\n}\n\nexport function parseWidthToPercentage(\n width: ImageWidth | null | undefined,\n containerWidthPixels: number = DEFAULT_CONTAINER_WIDTH_PIXELS\n): number {\n if (width === null || width === undefined || width === 'auto') {\n return MAX_IMAGE_WIDTH_PERCENTAGE;\n }\n\n const value = String(width).trim();\n if (value.endsWith('%')) {\n return clampImageWidthPercentage(Number.parseFloat(value));\n }\n\n const pixels = getPixels(value);\n if (pixels === null) {\n return MAX_IMAGE_WIDTH_PERCENTAGE;\n }\n\n return clampImageWidthPercentage(\n Math.round((100 * pixels) / containerWidthPixels)\n );\n}\n\nexport function clampImageWidthPercentage(width: number) {\n return clamp(width, [MIN_IMAGE_WIDTH_PERCENTAGE, MAX_IMAGE_WIDTH_PERCENTAGE]);\n}\n","import { MAILY_BUG_REPORT_URL, MAILY_ERROR_PREFIX } from './constants';\n\nexport function invariant(value: boolean, message?: string): asserts value;\n\nexport function invariant<T>(\n value: T | null | undefined,\n message?: string\n): asserts value is T;\n\nexport function invariant(value: unknown, message?: string) {\n if (value === false || value === null || typeof value === 'undefined') {\n console.error(\n `${MAILY_ERROR_PREFIX}: The following error is a bug in Maily;\nPlease open an issue! ${MAILY_BUG_REPORT_URL}`\n );\n throw new Error(message);\n }\n}\n","export const MAILY_MARK_TYPES = {\n BOLD: 'bold',\n ITALIC: 'italic',\n STRIKE: 'strike',\n UNDERLINE: 'underline',\n LINK: 'link',\n CODE: 'code',\n TEXT_STYLE: 'textStyle',\n HIGHLIGHT: 'highlight',\n SPAN: 'span',\n} as const;\n\nexport const allowedMarkTypes = Object.values(MAILY_MARK_TYPES);\n\nexport type MailyMarkType =\n (typeof MAILY_MARK_TYPES)[keyof typeof MAILY_MARK_TYPES];\n\nexport type MarkStyleAttributes = {\n style?: string | null;\n};\n\nexport type BaseMailyMark = {\n attrs?: MarkStyleAttributes & Record<string, unknown>;\n type: MailyMarkType;\n};\n\nexport type BoldMark = BaseMailyMark & {\n type: typeof MAILY_MARK_TYPES.BOLD;\n};\n\nexport type ItalicMark = BaseMailyMark & {\n type: typeof MAILY_MARK_TYPES.ITALIC;\n};\n\nexport type StrikeMark = BaseMailyMark & {\n type: typeof MAILY_MARK_TYPES.STRIKE;\n};\n\nexport type UnderlineMark = BaseMailyMark & {\n type: typeof MAILY_MARK_TYPES.UNDERLINE;\n};\n\nexport type LinkAttributes = MarkStyleAttributes & {\n class?: string | null;\n href: string;\n rel?: string | null;\n target?: string | null;\n title?: string | null;\n};\n\nexport type LinkMark = BaseMailyMark & {\n attrs: LinkAttributes;\n type: typeof MAILY_MARK_TYPES.LINK;\n};\n\nexport type CodeMark = BaseMailyMark & {\n type: typeof MAILY_MARK_TYPES.CODE;\n};\n\nexport type TextStyleAttributes = MarkStyleAttributes & {\n color: string;\n};\n\nexport type TextStyleMark = BaseMailyMark & {\n attrs: TextStyleAttributes;\n type: typeof MAILY_MARK_TYPES.TEXT_STYLE;\n};\n\nexport type HighlightAttributes = MarkStyleAttributes & {\n color: string;\n};\n\nexport type HighlightMark = BaseMailyMark & {\n attrs: HighlightAttributes;\n type: typeof MAILY_MARK_TYPES.HIGHLIGHT;\n};\n\nexport type SpanMark = BaseMailyMark & {\n attrs?: MarkStyleAttributes;\n type: typeof MAILY_MARK_TYPES.SPAN;\n};\n\nexport type AnyMailyMark =\n | BoldMark\n | ItalicMark\n | StrikeMark\n | UnderlineMark\n | LinkMark\n | CodeMark\n | TextStyleMark\n | HighlightMark\n | SpanMark;\n","import type { AllowedTextAlignment } from './alignment';\nimport type { AllowedButtonKind } from './button';\nimport type { ColumnWidth } from './column';\nimport type { TextDirection } from './direction';\nimport type { AllowedHtmlCodeBlockTab } from './html-code-block';\nimport type { AnyMailyMark } from './mark';\nimport type { NodeThemeOptions } from './theme';\nimport type { WithVisibilityAttrs } from './visibility';\n\nexport const MAILY_NODE_TYPES = {\n DOCUMENT: 'doc',\n BODY: 'body',\n CONTAINER: 'container',\n SECTION: 'section',\n COLUMNS: 'columns',\n COLUMN: 'column',\n IMAGE: 'image',\n INLINE_IMAGE: 'inlineImage',\n INLINE_SPAN: 'inlineSpan',\n SPACER: 'spacer',\n BUTTON: 'button',\n FOOTER: 'footer',\n PARAGRAPH: 'paragraph',\n HEADING: 'heading',\n BLOCKQUOTE: 'blockquote',\n HORIZONTAL_RULE: 'horizontalRule',\n HTML_CODE_BLOCK: 'htmlCodeBlock',\n REPEAT: 'repeat',\n HARD_BREAK: 'hardBreak',\n BULLET_LIST: 'bulletList',\n ORDERED_LIST: 'orderedList',\n LIST_ITEM: 'listItem',\n TEXT: 'text',\n VARIABLE: 'variable',\n TABLE: 'table',\n TABLE_ROW: 'tableRow',\n TABLE_CELL: 'tableCell',\n TABLE_HEADER: 'tableHeader',\n LINK_CARD: 'linkCard',\n} as const;\n\nexport const MAILY_EXTENSION_TYPES = {\n STYLE: 'style',\n THEME: 'theme',\n VISIBILITY: 'visibility',\n} as const;\n\nexport const allowedNodeTypes = Object.values(MAILY_NODE_TYPES);\n\nexport type MailyNodeType =\n (typeof MAILY_NODE_TYPES)[keyof typeof MAILY_NODE_TYPES];\n\nexport type WithExtraAttrs = {\n dir?: TextDirection | null;\n};\n\nexport type BaseMailyNode = {\n attrs?: WithExtraAttrs & Record<string, unknown>;\n content?: AnyMailyNode[];\n marks?: AnyMailyMark[];\n text?: string;\n type: MailyNodeType;\n};\n\nexport type DocumentAttributes = WithExtraAttrs & {\n theme?: NodeThemeOptions | null;\n version: number;\n};\n\nexport type DocumentNode = BaseMailyNode & {\n attrs: DocumentAttributes;\n content: AnyMailyNode[];\n type: typeof MAILY_NODE_TYPES.DOCUMENT;\n};\n\nexport type BodyAttributes = WithExtraAttrs & {\n style?: string | null;\n};\n\nexport type BodyNode = BaseMailyNode & {\n attrs?: BodyAttributes;\n content: AnyMailyNode[];\n type: typeof MAILY_NODE_TYPES.BODY;\n};\n\nexport type ContainerAttributes = WithExtraAttrs & {\n style?: string | null;\n};\n\nexport type ContainerNode = BaseMailyNode & {\n attrs?: ContainerAttributes;\n content: AnyMailyNode[];\n type: typeof MAILY_NODE_TYPES.CONTAINER;\n};\n\nexport type SectionAttributes = WithExtraAttrs &\n WithVisibilityAttrs & {\n style?: string | null;\n };\n\nexport type SectionNode = BaseMailyNode & {\n attrs?: SectionAttributes;\n content: AnyMailyNode[];\n type: typeof MAILY_NODE_TYPES.SECTION;\n};\n\nexport type RepeatAttributes = WithVisibilityAttrs & {\n each: string;\n};\n\nexport type RepeatNode = BaseMailyNode & {\n attrs: RepeatAttributes;\n content: AnyMailyNode[];\n type: typeof MAILY_NODE_TYPES.REPEAT;\n};\n\nexport type ColumnsAttributes = WithExtraAttrs &\n WithVisibilityAttrs & {\n columnCount: number;\n gap: number;\n style?: string | null;\n };\n\nexport type ColumnsNode = BaseMailyNode & {\n attrs: ColumnsAttributes;\n content: ColumnNode[];\n type: typeof MAILY_NODE_TYPES.COLUMNS;\n};\n\nexport type ColumnAttributes = WithExtraAttrs & {\n verticalAlign: string;\n width: ColumnWidth | null;\n style?: string | null;\n};\n\nexport type ColumnNode = BaseMailyNode & {\n attrs: ColumnAttributes;\n content: AnyMailyNode[];\n type: typeof MAILY_NODE_TYPES.COLUMN;\n};\n\nexport type ImageAttributes = WithExtraAttrs &\n WithVisibilityAttrs & {\n align: AllowedTextAlignment;\n alt?: string | null;\n externalLink?: string | null;\n src: string;\n style?: string | null;\n title?: string | null;\n width: string;\n };\n\nexport type ImageNode = BaseMailyNode & {\n attrs: ImageAttributes;\n type: typeof MAILY_NODE_TYPES.IMAGE;\n};\n\nexport type ButtonAttributes = WithExtraAttrs &\n WithVisibilityAttrs & {\n align: AllowedTextAlignment;\n kind: AllowedButtonKind;\n style?: string | null;\n url: string;\n };\n\nexport type ButtonNode = BaseMailyNode & {\n attrs: ButtonAttributes;\n content: AnyMailyNode[];\n type: typeof MAILY_NODE_TYPES.BUTTON;\n};\n\nexport type FooterAttributes = WithExtraAttrs & {\n style?: string | null;\n};\n\nexport type FooterNode = BaseMailyNode & {\n attrs?: FooterAttributes;\n content: AnyMailyNode[];\n type: typeof MAILY_NODE_TYPES.FOOTER;\n};\n\nexport type InlineImageAttributes = WithExtraAttrs & {\n alt?: string | null;\n externalLink?: string | null;\n height: number;\n src: string;\n style?: string | null;\n title?: string | null;\n width: number;\n};\n\nexport type InlineImageNode = BaseMailyNode & {\n attrs: InlineImageAttributes;\n type: typeof MAILY_NODE_TYPES.INLINE_IMAGE;\n};\n\nexport type InlineSpanAttributes = WithExtraAttrs & {\n style?: string | null;\n};\n\nexport type InlineSpanNode = BaseMailyNode & {\n attrs?: InlineSpanAttributes;\n type: typeof MAILY_NODE_TYPES.INLINE_SPAN;\n};\n\nexport type SpacerAttributes = WithExtraAttrs &\n WithVisibilityAttrs & {\n height: number;\n style?: string | null;\n };\n\nexport type SpacerNode = BaseMailyNode & {\n attrs: SpacerAttributes;\n type: typeof MAILY_NODE_TYPES.SPACER;\n};\n\nexport type ParagraphAttributes = WithExtraAttrs &\n WithVisibilityAttrs & {\n style?: string | null;\n };\n\nexport type ParagraphNode = BaseMailyNode & {\n attrs?: ParagraphAttributes;\n type: typeof MAILY_NODE_TYPES.PARAGRAPH;\n};\n\nexport type HeadingLevel = 1 | 2 | 3;\n\nexport type HeadingAttributes = WithExtraAttrs &\n WithVisibilityAttrs & {\n level: HeadingLevel;\n style?: string | null;\n };\n\nexport type HeadingNode = BaseMailyNode & {\n attrs: HeadingAttributes;\n type: typeof MAILY_NODE_TYPES.HEADING;\n};\n\nexport type BlockquoteAttributes = WithExtraAttrs & {\n style?: string | null;\n};\n\nexport type BlockquoteNode = BaseMailyNode & {\n attrs?: BlockquoteAttributes;\n content: AnyMailyNode[];\n type: typeof MAILY_NODE_TYPES.BLOCKQUOTE;\n};\n\nexport type HorizontalRuleAttributes = WithVisibilityAttrs & {\n style?: string | null;\n};\n\nexport type HorizontalRuleNode = BaseMailyNode & {\n attrs?: HorizontalRuleAttributes;\n type: typeof MAILY_NODE_TYPES.HORIZONTAL_RULE;\n};\n\nexport type HardBreakNode = BaseMailyNode & {\n type: typeof MAILY_NODE_TYPES.HARD_BREAK;\n};\n\nexport type BulletListAttributes = WithExtraAttrs &\n WithVisibilityAttrs & {\n style?: string | null;\n };\n\nexport type BulletListNode = BaseMailyNode & {\n attrs?: BulletListAttributes;\n content: ListItemNode[];\n type: typeof MAILY_NODE_TYPES.BULLET_LIST;\n};\n\nexport type OrderedListAttributes = WithExtraAttrs &\n WithVisibilityAttrs & {\n start?: number;\n style?: string | null;\n };\n\nexport type OrderedListNode = BaseMailyNode & {\n attrs?: OrderedListAttributes;\n content: ListItemNode[];\n type: typeof MAILY_NODE_TYPES.ORDERED_LIST;\n};\n\nexport type ListItemAttributes = WithExtraAttrs & {\n style?: string | null;\n};\n\nexport type ListItemNode = BaseMailyNode & {\n attrs?: ListItemAttributes;\n content: AnyMailyNode[];\n type: typeof MAILY_NODE_TYPES.LIST_ITEM;\n};\n\nexport type HtmlCodeBlockAttributes = WithExtraAttrs &\n WithVisibilityAttrs & {\n activeTab: AllowedHtmlCodeBlockTab;\n language: string;\n style?: string | null;\n };\n\nexport type HtmlCodeBlockNode = BaseMailyNode & {\n attrs: HtmlCodeBlockAttributes;\n content: AnyMailyNode[];\n type: typeof MAILY_NODE_TYPES.HTML_CODE_BLOCK;\n};\n\nexport type TextNode = BaseMailyNode & {\n marks?: AnyMailyMark[];\n text: string;\n type: typeof MAILY_NODE_TYPES.TEXT;\n};\n\nexport type VariableAttributes = WithExtraAttrs & {\n fallback?: string | null;\n /** @deprecated Use `isDefaultEditable` instead. */\n hideDefaultValue?: boolean;\n id: string;\n isDefaultEditable?: boolean;\n label?: string | null;\n required?: boolean;\n style?: string | null;\n};\n\nexport const DEFAULT_VARIABLE_ATTRIBUTES = {\n fallback: null,\n isDefaultEditable: true,\n label: null,\n required: true,\n style: null,\n} satisfies Omit<VariableAttributes, 'id'>;\n\nexport type VariableNode = BaseMailyNode & {\n attrs: VariableAttributes;\n type: typeof MAILY_NODE_TYPES.VARIABLE;\n};\n\nexport type TableAttributes = {\n border?: number;\n cellpadding?: number;\n cellspacing?: number;\n responsive: boolean;\n style?: string | null;\n};\n\nexport type TableNode = BaseMailyNode & {\n attrs: TableAttributes;\n content: TableRowNode[];\n type: typeof MAILY_NODE_TYPES.TABLE;\n};\n\nexport type TableRowAttributes = {\n style?: string | null;\n};\n\nexport type TableRowNode = BaseMailyNode & {\n attrs?: TableRowAttributes;\n content: (TableCellNode | TableHeaderNode)[];\n type: typeof MAILY_NODE_TYPES.TABLE_ROW;\n};\n\nexport type TableCellAttributes = {\n colspan: number;\n colwidth: number[] | null;\n rowspan: number;\n style?: string | null;\n};\n\nexport type TableCellNode = BaseMailyNode & {\n attrs: TableCellAttributes;\n content: AnyMailyNode[];\n type: typeof MAILY_NODE_TYPES.TABLE_CELL;\n};\n\nexport type TableHeaderAttributes = TableCellAttributes;\n\nexport type TableHeaderNode = BaseMailyNode & {\n attrs: TableHeaderAttributes;\n content: AnyMailyNode[];\n type: typeof MAILY_NODE_TYPES.TABLE_HEADER;\n};\n\nexport type LinkCardAttributes = WithExtraAttrs &\n WithVisibilityAttrs & {\n badgeText: string;\n description: string;\n image: string;\n link: string;\n linkTitle: string;\n style?: string | null;\n subTitle: string;\n title: string;\n };\n\nexport type LinkCardNode = BaseMailyNode & {\n attrs: LinkCardAttributes;\n type: typeof MAILY_NODE_TYPES.LINK_CARD;\n};\n\nexport type AnyMailyNode =\n | BodyNode\n | ContainerNode\n | BlockquoteNode\n | ButtonNode\n | ColumnNode\n | ColumnsNode\n | BulletListNode\n | DocumentNode\n | FooterNode\n | HardBreakNode\n | HeadingNode\n | ImageNode\n | InlineImageNode\n | InlineSpanNode\n | HorizontalRuleNode\n | HtmlCodeBlockNode\n | LinkCardNode\n | ListItemNode\n | OrderedListNode\n | ParagraphNode\n | RepeatNode\n | SectionNode\n | SpacerNode\n | TableCellNode\n | TableHeaderNode\n | TableNode\n | TableRowNode\n | TextNode\n | VariableNode;\n","import type {\n AnyMailyMark,\n BoldMark,\n CodeMark,\n HighlightMark,\n ItalicMark,\n LinkMark,\n MailyMarkType,\n SpanMark,\n StrikeMark,\n TextStyleMark,\n UnderlineMark,\n} from './mark';\nimport { allowedMarkTypes, MAILY_MARK_TYPES } from './mark';\nimport type {\n AnyMailyNode,\n BlockquoteNode,\n BodyNode,\n BulletListNode,\n ContainerNode,\n DocumentNode,\n FooterNode,\n HardBreakNode,\n HeadingNode,\n HorizontalRuleNode,\n HtmlCodeBlockNode,\n ImageNode,\n InlineImageNode,\n InlineSpanNode,\n LinkCardNode,\n ListItemNode,\n MailyNodeType,\n OrderedListNode,\n ButtonNode,\n ColumnNode,\n ColumnsNode,\n ParagraphNode,\n RepeatNode,\n SectionNode,\n SpacerNode,\n TableCellNode,\n TableHeaderNode,\n TableNode,\n TableRowNode,\n TextNode,\n VariableNode,\n} from './node';\nimport { allowedNodeTypes, MAILY_NODE_TYPES } from './node';\n\nfunction guard<T extends AnyMailyNode | AnyMailyMark>(type: string) {\n return (value: AnyMailyNode | AnyMailyMark): value is T =>\n value.type === type;\n}\n\nexport function isObject(val: unknown): val is object {\n return typeof val === 'object' && val !== null;\n}\n\nexport const is = {\n node(value: unknown): value is AnyMailyNode {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'type' in value &&\n allowedNodeTypes.includes(value.type as MailyNodeType)\n );\n },\n mark(value: unknown): value is AnyMailyMark {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'type' in value &&\n allowedMarkTypes.includes(value.type as MailyMarkType)\n );\n },\n parent(\n node: AnyMailyNode\n ): node is AnyMailyNode & { content: AnyMailyNode[] } {\n return Array.isArray(node?.content);\n },\n marked(node: AnyMailyNode): node is AnyMailyNode & { marks: AnyMailyMark[] } {\n return Array.isArray(node?.marks);\n },\n doc: guard<DocumentNode>(MAILY_NODE_TYPES.DOCUMENT),\n body: guard<BodyNode>(MAILY_NODE_TYPES.BODY),\n container: guard<ContainerNode>(MAILY_NODE_TYPES.CONTAINER),\n section: guard<SectionNode>(MAILY_NODE_TYPES.SECTION),\n columns: guard<ColumnsNode>(MAILY_NODE_TYPES.COLUMNS),\n column: guard<ColumnNode>(MAILY_NODE_TYPES.COLUMN),\n image: guard<ImageNode>(MAILY_NODE_TYPES.IMAGE),\n inlineImage: guard<InlineImageNode>(MAILY_NODE_TYPES.INLINE_IMAGE),\n inlineSpan: guard<InlineSpanNode>(MAILY_NODE_TYPES.INLINE_SPAN),\n spacer: guard<SpacerNode>(MAILY_NODE_TYPES.SPACER),\n button: guard<ButtonNode>(MAILY_NODE_TYPES.BUTTON),\n footer: guard<FooterNode>(MAILY_NODE_TYPES.FOOTER),\n paragraph: guard<ParagraphNode>(MAILY_NODE_TYPES.PARAGRAPH),\n heading: guard<HeadingNode>(MAILY_NODE_TYPES.HEADING),\n blockquote: guard<BlockquoteNode>(MAILY_NODE_TYPES.BLOCKQUOTE),\n horizontalRule: guard<HorizontalRuleNode>(MAILY_NODE_TYPES.HORIZONTAL_RULE),\n hardBreak: guard<HardBreakNode>(MAILY_NODE_TYPES.HARD_BREAK),\n htmlCodeBlock: guard<HtmlCodeBlockNode>(MAILY_NODE_TYPES.HTML_CODE_BLOCK),\n repeat: guard<RepeatNode>(MAILY_NODE_TYPES.REPEAT),\n bulletList: guard<BulletListNode>(MAILY_NODE_TYPES.BULLET_LIST),\n orderedList: guard<OrderedListNode>(MAILY_NODE_TYPES.ORDERED_LIST),\n listItem: guard<ListItemNode>(MAILY_NODE_TYPES.LIST_ITEM),\n linkCard: guard<LinkCardNode>(MAILY_NODE_TYPES.LINK_CARD),\n text: guard<TextNode>(MAILY_NODE_TYPES.TEXT),\n variable: guard<VariableNode>(MAILY_NODE_TYPES.VARIABLE),\n table: guard<TableNode>(MAILY_NODE_TYPES.TABLE),\n tableRow: guard<TableRowNode>(MAILY_NODE_TYPES.TABLE_ROW),\n tableCell: guard<TableCellNode>(MAILY_NODE_TYPES.TABLE_CELL),\n tableHeader: guard<TableHeaderNode>(MAILY_NODE_TYPES.TABLE_HEADER),\n bold: guard<BoldMark>(MAILY_MARK_TYPES.BOLD),\n italic: guard<ItalicMark>(MAILY_MARK_TYPES.ITALIC),\n strike: guard<StrikeMark>(MAILY_MARK_TYPES.STRIKE),\n underline: guard<UnderlineMark>(MAILY_MARK_TYPES.UNDERLINE),\n link: guard<LinkMark>(MAILY_MARK_TYPES.LINK),\n code: guard<CodeMark>(MAILY_MARK_TYPES.CODE),\n textStyle: guard<TextStyleMark>(MAILY_MARK_TYPES.TEXT_STYLE),\n highlight: guard<HighlightMark>(MAILY_MARK_TYPES.HIGHLIGHT),\n span: guard<SpanMark>(MAILY_MARK_TYPES.SPAN),\n};\n\nexport function isDef<T>(value: T | null | undefined): value is T {\n return value !== undefined && value !== null;\n}\n","export function isMergeableObject(\n value: unknown\n): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\n/**\n * One-level deep merge of plain objects. Nested plain objects are\n * shallow-merged; primitives, arrays, and null are replaced outright.\n * Does not mutate the target — returns a new object.\n *\n * Example:\n * deepMerge({ a: 1, nested: { x: 1, y: 2 } }, { nested: { y: 3 } })\n * // => { a: 1, nested: { x: 1, y: 3 } }\n */\nexport function deepMerge<T extends object>(\n target: T,\n ...sources: Partial<T>[]\n): T {\n const result = { ...target } as Record<string, unknown>;\n\n for (const source of sources) {\n for (const [key, value] of Object.entries(source)) {\n result[key] =\n isMergeableObject(value) && isMergeableObject(result[key])\n ? { ...result[key], ...value }\n : value;\n }\n }\n\n return result as T;\n}\n","import { MAILY_NODE_TYPES } from './node';\n\nexport const BLOCK_CONTAINER_TYPES: string[] = [\n MAILY_NODE_TYPES.DOCUMENT,\n MAILY_NODE_TYPES.BODY,\n MAILY_NODE_TYPES.CONTAINER,\n MAILY_NODE_TYPES.SECTION,\n MAILY_NODE_TYPES.COLUMN,\n MAILY_NODE_TYPES.REPEAT,\n MAILY_NODE_TYPES.BULLET_LIST,\n MAILY_NODE_TYPES.ORDERED_LIST,\n];\n\nexport const MARGIN_TOP_ABSORBER_TYPES: string[] = [MAILY_NODE_TYPES.SPACER];\n\nexport const MARGIN_BOTTOM_ABSORBER_TYPES: string[] = [\n MAILY_NODE_TYPES.SPACER,\n MAILY_NODE_TYPES.HORIZONTAL_RULE,\n];\n\nexport type NodePosition = {\n isFirst: boolean;\n isLast: boolean;\n nextType?: string | undefined;\n parentType?: string | undefined;\n previousType?: string | undefined;\n};\n\nexport function getSuppressedMargins(position: NodePosition) {\n const { isFirst, isLast, nextType, parentType, previousType } = position;\n const stacks =\n parentType !== undefined && BLOCK_CONTAINER_TYPES.includes(parentType);\n\n return {\n marginBottom:\n !stacks ||\n isLast ||\n MARGIN_BOTTOM_ABSORBER_TYPES.includes(nextType ?? ''),\n marginTop:\n !stacks ||\n isFirst ||\n MARGIN_TOP_ABSORBER_TYPES.includes(previousType ?? ''),\n };\n}\n","import { collapse, expand, objectify, stringify } from 'stylecast';\n\nexport type InlineStyle = Record<string, string>;\n\nexport function parseInlineStyles(style: string): InlineStyle {\n return objectify(style, { reactify: true });\n}\n\nexport function stringifyInlineStyles(style: InlineStyle): string {\n return stringify(style, { kebabCase: true });\n}\n\nexport function expandInlineStyles(style: InlineStyle): InlineStyle {\n return expand(style, { camelCase: true });\n}\n\nfunction collapseInlineStyles(style: InlineStyle): InlineStyle {\n return collapse(style, { camelCase: true });\n}\n\nexport function mergeInlineStyles(\n under: InlineStyle,\n over: InlineStyle\n): InlineStyle {\n return collapseInlineStyles({\n ...expandInlineStyles(under),\n ...expandInlineStyles(over),\n });\n}\n","export const TEXT_DIRECTIONS = {\n LTR: 'ltr',\n RTL: 'rtl',\n AUTO: 'auto',\n} as const;\n\nexport type TextDirection =\n (typeof TEXT_DIRECTIONS)[keyof typeof TEXT_DIRECTIONS];\n\nexport const DEFAULT_TEXT_DIRECTION: TextDirection = TEXT_DIRECTIONS.AUTO;\n\nexport function getCssDirection(dir: TextDirection | null | undefined) {\n if (dir && dir !== TEXT_DIRECTIONS.AUTO) {\n return { direction: dir };\n }\n\n return {};\n}\n","import { DEFAULT_VARIABLE_ATTRIBUTES, MAILY_NODE_TYPES } from './node';\nimport type { VariableAttributes } from './node';\n\nexport const DEFAULT_VARIABLE_START_TRIGGER = '{{';\n\nexport const DEFAULT_VARIABLE_END_TRIGGER = '}}';\n\ntype VariableAttributeName = keyof typeof DEFAULT_VARIABLE_ATTRIBUTES;\n\nconst LEGACY_HIDE_DEFAULT_VALUE = 'hideDefaultValue';\n\nfunction getQuotedValue(value: string): string {\n return `\"${value.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')}\"`;\n}\n\ntype SerializedAttributeOptions = {\n name: VariableAttributeName;\n value: VariableAttributes[VariableAttributeName];\n};\n\nfunction getSerializedAttribute(\n options: SerializedAttributeOptions\n): string | null {\n const { name, value } = options;\n\n if (value === undefined || value === DEFAULT_VARIABLE_ATTRIBUTES[name]) {\n return null;\n }\n\n if (typeof value === 'boolean') {\n return `${name}=${value}`;\n }\n\n return typeof value === 'string' ? `${name}=${getQuotedValue(value)}` : null;\n}\n\nexport function serializeVariableToText(variable: VariableAttributes): string {\n const { fallback, id, isDefaultEditable, label, required, style } = variable;\n\n const attributes = [\n getSerializedAttribute({ name: 'fallback', value: fallback }),\n getSerializedAttribute({\n name: 'isDefaultEditable',\n value: isDefaultEditable,\n }),\n getSerializedAttribute({\n name: 'label',\n value: label === id ? null : label,\n }),\n getSerializedAttribute({ name: 'required', value: required }),\n getSerializedAttribute({ name: 'style', value: style }),\n ].filter((attribute) => {\n return attribute !== null;\n });\n\n return [\n DEFAULT_VARIABLE_START_TRIGGER,\n [id, ...attributes].join(' '),\n DEFAULT_VARIABLE_END_TRIGGER,\n ].join('');\n}\n\nfunction getReferenceTokens(inner: string): string[] {\n const tokens: string[] = [];\n let token = '';\n let quoted = false;\n\n for (let index = 0; index < inner.length; index += 1) {\n const character = inner[index]!;\n\n if (quoted && character === '\\\\' && index + 1 < inner.length) {\n token += character + inner[index + 1];\n index += 1;\n continue;\n }\n\n if (character === '\"') {\n quoted = !quoted;\n token += character;\n continue;\n }\n\n if (!quoted && /\\s/.test(character)) {\n if (token) {\n tokens.push(token);\n token = '';\n }\n continue;\n }\n\n token += character;\n }\n\n if (token) {\n tokens.push(token);\n }\n\n return tokens;\n}\n\nfunction getUnquotedValue(value: string): unknown {\n if (value.startsWith('\"') && value.endsWith('\"') && value.length > 1) {\n return value.slice(1, -1).replace(/\\\\\"/g, '\"').replace(/\\\\\\\\/g, '\\\\');\n }\n\n if (value === 'true') {\n return true;\n }\n if (value === 'false') {\n return false;\n }\n\n return value;\n}\n\nexport function deserializeVariableFromText(text: string): VariableAttributes {\n const inner = text\n .slice(\n DEFAULT_VARIABLE_START_TRIGGER.length,\n text.length - DEFAULT_VARIABLE_END_TRIGGER.length\n )\n .trim();\n\n const [id = '', ...pairs] = getReferenceTokens(inner);\n const attributes: Record<string, unknown> = { id };\n\n for (const pair of pairs) {\n const separator = pair.indexOf('=');\n if (separator <= 0) {\n continue;\n }\n\n const key = pair.slice(0, separator);\n const value = getUnquotedValue(pair.slice(separator + 1));\n\n if (key === LEGACY_HIDE_DEFAULT_VALUE) {\n attributes.isDefaultEditable ??= value !== true;\n continue;\n }\n\n attributes[key] = value;\n }\n\n return {\n ...DEFAULT_VARIABLE_ATTRIBUTES,\n ...attributes,\n } as VariableAttributes;\n}\n\ntype VariableSegment = {\n isReference: boolean;\n text: string;\n};\n\nexport function getVariableSegments(content: string): VariableSegment[] {\n const segments: VariableSegment[] = [];\n let plain = '';\n let index = 0;\n\n while (index < content.length) {\n if (!content.startsWith(DEFAULT_VARIABLE_START_TRIGGER, index)) {\n plain += content[index];\n index += 1;\n continue;\n }\n\n const end = getReferenceEnd({ content, start: index });\n if (end === -1) {\n plain += content[index];\n index += 1;\n continue;\n }\n\n if (plain) {\n segments.push({ isReference: false, text: plain });\n plain = '';\n }\n\n segments.push({ isReference: true, text: content.slice(index, end) });\n index = end;\n }\n\n if (plain) {\n segments.push({ isReference: false, text: plain });\n }\n\n return segments;\n}\n\ntype ReferenceEndOptions = {\n content: string;\n start: number;\n};\n\nfunction getReferenceEnd(options: ReferenceEndOptions): number {\n const { content, start } = options;\n let quoted = false;\n\n for (\n let index = start + DEFAULT_VARIABLE_START_TRIGGER.length;\n index < content.length;\n index += 1\n ) {\n const character = content[index]!;\n\n if (quoted && character === '\\\\') {\n index += 1;\n continue;\n }\n\n if (character === '\"') {\n quoted = !quoted;\n continue;\n }\n\n if (!quoted && content.startsWith(DEFAULT_VARIABLE_END_TRIGGER, index)) {\n return index + DEFAULT_VARIABLE_END_TRIGGER.length;\n }\n }\n\n return -1;\n}\n\nexport function buildDocFromVariableText(content: string) {\n return {\n type: MAILY_NODE_TYPES.DOCUMENT,\n content: [\n {\n type: MAILY_NODE_TYPES.PARAGRAPH,\n content: getVariableSegments(content).map((segment) => {\n return segment.isReference\n ? {\n type: MAILY_NODE_TYPES.VARIABLE,\n attrs: deserializeVariableFromText(segment.text),\n }\n : { type: MAILY_NODE_TYPES.TEXT, text: segment.text };\n }),\n },\n ],\n };\n}\n\nexport function hasVariableInText(text: string): boolean {\n const start = text.indexOf(DEFAULT_VARIABLE_START_TRIGGER);\n if (start === -1) {\n return false;\n }\n\n return (\n text.indexOf(\n DEFAULT_VARIABLE_END_TRIGGER,\n start + DEFAULT_VARIABLE_START_TRIGGER.length\n ) !== -1\n );\n}\n","export const VISIBILITY_ACTIONS = {\n SHOW: 'show',\n HIDE: 'hide',\n} as const;\n\nexport type AllowedVisibilityAction =\n (typeof VISIBILITY_ACTIONS)[keyof typeof VISIBILITY_ACTIONS];\n\nconst allowedVisibilityActions = Object.values(VISIBILITY_ACTIONS);\n\nexport const VISIBILITY_ACTION_OPTIONS: {\n label: string;\n value: AllowedVisibilityAction;\n}[] = [\n { label: 'Show if', value: VISIBILITY_ACTIONS.SHOW },\n { label: 'Hide if', value: VISIBILITY_ACTIONS.HIDE },\n];\n\nexport const VISIBILITY_OPERATORS = {\n IS_TRUE: 'is_true',\n IS_FALSE: 'is_false',\n EQUALS: 'equals',\n NOT_EQUALS: 'not_equals',\n CONTAINS: 'contains',\n NOT_CONTAINS: 'not_contains',\n STARTS_WITH: 'starts_with',\n ENDS_WITH: 'ends_with',\n GREATER_THAN: 'greater_than',\n LESS_THAN: 'less_than',\n} as const;\n\nexport type AllowedVisibilityOperator =\n (typeof VISIBILITY_OPERATORS)[keyof typeof VISIBILITY_OPERATORS];\n\nconst allowedVisibilityOperators = Object.values(VISIBILITY_OPERATORS);\n\nexport const VISIBILITY_OPERATOR_OPTIONS: {\n label: string;\n value: AllowedVisibilityOperator;\n}[] = [\n { label: 'Is true', value: VISIBILITY_OPERATORS.IS_TRUE },\n { label: 'Is false', value: VISIBILITY_OPERATORS.IS_FALSE },\n { label: 'Equals', value: VISIBILITY_OPERATORS.EQUALS },\n { label: 'Not equals', value: VISIBILITY_OPERATORS.NOT_EQUALS },\n { label: 'Contains', value: VISIBILITY_OPERATORS.CONTAINS },\n { label: 'Not contains', value: VISIBILITY_OPERATORS.NOT_CONTAINS },\n { label: 'Starts with', value: VISIBILITY_OPERATORS.STARTS_WITH },\n { label: 'Ends with', value: VISIBILITY_OPERATORS.ENDS_WITH },\n { label: 'Greater than', value: VISIBILITY_OPERATORS.GREATER_THAN },\n { label: 'Less than', value: VISIBILITY_OPERATORS.LESS_THAN },\n];\n\nconst VISIBILITY_OPERATORS_WITHOUT_VALUE: AllowedVisibilityOperator[] = [\n VISIBILITY_OPERATORS.IS_TRUE,\n VISIBILITY_OPERATORS.IS_FALSE,\n];\n\nexport type VisibilityRule = {\n action: AllowedVisibilityAction;\n operator: AllowedVisibilityOperator;\n value: string;\n variable: string;\n};\n\nexport type WithVisibilityAttrs = {\n visibilityRule?: VisibilityRule | null;\n};\n\nexport const DEFAULT_VISIBILITY_RULE: VisibilityRule = {\n action: VISIBILITY_ACTIONS.SHOW,\n operator: VISIBILITY_OPERATORS.EQUALS,\n value: '',\n variable: '',\n};\n\nexport function getVisibilityValueSupport(\n operator: AllowedVisibilityOperator\n): boolean {\n return !VISIBILITY_OPERATORS_WITHOUT_VALUE.includes(operator);\n}\n\ntype VisibilityRuleOptions = {\n action: string | null | undefined;\n operator: string | null | undefined;\n value: string | null | undefined;\n variable: string | null | undefined;\n};\n\nexport function getVisibilityRule(\n options: VisibilityRuleOptions\n): VisibilityRule | null {\n const { action, operator, value, variable } = options;\n\n const isAllowedAction = allowedVisibilityActions.some((candidate) => {\n return candidate === action;\n });\n const isAllowedOperator = allowedVisibilityOperators.some((candidate) => {\n return candidate === operator;\n });\n\n if (!(isAllowedAction && isAllowedOperator)) {\n return null;\n }\n\n return {\n action: action as AllowedVisibilityAction,\n operator: operator as AllowedVisibilityOperator,\n value: getVisibilityValueSupport(operator as AllowedVisibilityOperator)\n ? (value ?? '')\n : '',\n variable: variable ?? '',\n };\n}\n","import { DEFAULT_FONT, getFontFamilyValue } from './font';\nimport { MAILY_NODE_TYPES } from './node';\nimport { deepMerge } from './object';\nimport type { InlineStyle } from './style';\n\nexport type NodeThemeOptions = {\n blockquote?: InlineStyle;\n body?: InlineStyle;\n bulletList?: InlineStyle;\n button?: InlineStyle;\n code?: InlineStyle;\n container?: InlineStyle;\n footer?: InlineStyle;\n h1?: InlineStyle;\n h2?: InlineStyle;\n h3?: InlineStyle;\n heading?: InlineStyle;\n horizontalRule?: InlineStyle;\n htmlCodeBlock?: InlineStyle;\n link?: InlineStyle;\n listItem?: InlineStyle;\n orderedList?: InlineStyle;\n paragraph?: InlineStyle;\n section?: InlineStyle;\n table?: InlineStyle;\n tableCell?: InlineStyle;\n tableRow?: InlineStyle;\n};\n\nexport const DEFAULT_CONTAINER_MAX_WIDTH = 600;\n\nexport const BASIC_NODE_THEME: NodeThemeOptions = {\n blockquote: {\n borderColor: '#d1d5db',\n borderLeftStyle: 'solid',\n borderLeftWidth: '4px',\n color: '#374151',\n fontSize: '15px',\n fontStyle: 'italic',\n fontWeight: '500',\n lineHeight: '26px',\n marginBottom: '20px',\n marginLeft: '0',\n marginRight: '0',\n marginTop: '20px',\n paddingLeft: '16px',\n },\n body: {\n fontFamily: getFontFamilyValue({\n fallbackFontFamily: DEFAULT_FONT.fallbackFontFamily,\n fontFamily: DEFAULT_FONT.fontFamily,\n }),\n },\n bulletList: {\n listStyleType: 'disc',\n margin: '0',\n paddingLeft: '26px',\n },\n button: {\n backgroundColor: '#000000',\n borderRadius: '9999px',\n color: '#ffffff',\n fontSize: '14px',\n fontWeight: '500',\n lineHeight: '20px',\n padding: '10px 32px',\n },\n code: {\n borderRadius: '8px',\n fontFamily: 'ui-monospace, monospace',\n fontSize: '85%',\n padding: '2px 6px',\n },\n h1: {\n fontSize: '36px',\n fontWeight: '800',\n lineHeight: '40px',\n },\n h2: {\n fontSize: '30px',\n fontWeight: '700',\n lineHeight: '40px',\n },\n h3: {\n fontSize: '24px',\n fontWeight: '600',\n lineHeight: '38px',\n },\n heading: {\n color: '#101828',\n marginBottom: '12px',\n marginTop: '0',\n },\n horizontalRule: {\n border: 'none',\n borderTop: '1px solid #eaeaea',\n marginBottom: '32px',\n marginTop: '32px',\n },\n htmlCodeBlock: {\n marginBottom: '32px',\n },\n link: {\n color: '#0000ee',\n textDecoration: 'underline',\n },\n listItem: {\n marginBottom: '8px',\n paddingLeft: '6px',\n },\n orderedList: {\n listStyleType: 'decimal',\n margin: '0',\n paddingLeft: '26px',\n },\n footer: {\n color: '#64748B',\n display: 'block',\n fontSize: '14px',\n fontWeight: '400',\n lineHeight: '24px',\n marginBottom: '0',\n marginTop: '0',\n },\n paragraph: {\n color: '#18181b',\n fontSize: '14px',\n lineHeight: '24px',\n },\n section: {\n padding: '8px',\n },\n};\n\nexport const MAILY_NODE_THEME: NodeThemeOptions = {\n blockquote: {\n borderLeftColor: '#d1d5db',\n borderLeftStyle: 'solid',\n borderLeftWidth: '4px',\n color: '#374151',\n fontSize: '15px',\n fontStyle: 'italic',\n fontWeight: '500',\n lineHeight: '1.75',\n marginBottom: '20px',\n marginLeft: '0',\n marginRight: '0',\n marginTop: '20px',\n paddingLeft: '16px',\n },\n body: {\n backgroundColor: '#ffffff',\n fontFamily: getFontFamilyValue({\n fallbackFontFamily: DEFAULT_FONT.fallbackFontFamily,\n fontFamily: DEFAULT_FONT.fontFamily,\n }),\n padding: '0',\n },\n bulletList: {\n listStyleType: 'disc',\n marginBottom: '20px',\n marginLeft: '0',\n marginRight: '0',\n marginTop: '0',\n paddingLeft: '26px',\n },\n button: {\n backgroundColor: '#000000',\n borderRadius: '9999px',\n color: '#ffffff',\n fontSize: '14px',\n fontWeight: '600',\n lineHeight: '1.4285714',\n marginBottom: '20px',\n padding: '10px 32px',\n },\n code: {\n backgroundColor: '#efefef',\n borderRadius: '8px',\n color: '#111827',\n fontFamily: 'ui-monospace, monospace',\n fontSize: '85%',\n padding: '2px 6px',\n },\n container: {\n backgroundColor: '#ffffff',\n maxWidth: `${DEFAULT_CONTAINER_MAX_WIDTH}px`,\n minWidth: '300px',\n padding: '8px',\n },\n footer: {\n color: '#64748b',\n display: 'block',\n fontSize: '14px',\n fontWeight: '400',\n lineHeight: '1.7142857',\n marginBottom: '20px',\n marginTop: '0',\n },\n h1: {\n fontSize: '36px',\n fontWeight: '600',\n lineHeight: '1.1111111',\n },\n h2: {\n fontSize: '30px',\n fontWeight: '600',\n lineHeight: '1.3333333',\n },\n h3: {\n fontSize: '24px',\n fontWeight: '600',\n lineHeight: '1.6',\n },\n heading: {\n color: '#111827',\n marginBottom: '12px',\n marginTop: '0',\n },\n horizontalRule: {\n border: 'none',\n borderTop: '1px solid #eaeaea',\n marginBottom: '32px',\n marginTop: '32px',\n },\n htmlCodeBlock: {\n marginBottom: '32px',\n },\n link: {\n color: '#111827',\n textDecoration: 'underline',\n },\n listItem: {\n color: '#d1d5dc',\n marginBottom: '8px',\n marginTop: '8px',\n paddingLeft: '6px',\n },\n orderedList: {\n listStyleType: 'decimal',\n marginBottom: '20px',\n marginLeft: '0',\n marginRight: '0',\n marginTop: '0',\n paddingLeft: '26px',\n },\n paragraph: {\n color: '#374151',\n fontSize: '15px',\n fontWeight: '400',\n lineHeight: '1.75',\n marginBottom: '20px',\n marginTop: '0',\n MozOsxFontSmoothing: 'grayscale',\n WebkitFontSmoothing: 'antialiased',\n },\n section: {\n backgroundColor: '#f7f7f7',\n border: '2px solid #e2e2e2',\n borderRadius: '0',\n marginBottom: '20px',\n padding: '0',\n },\n};\n\nexport type ExtendNodeThemeOptions = {\n extension: NodeThemeOptions;\n preset: NodeThemeOptions;\n};\n\nexport function extendNodeTheme(\n options: ExtendNodeThemeOptions\n): NodeThemeOptions {\n const { extension, preset } = options;\n\n return deepMerge(preset, extension);\n}\n\nexport type ThemeDeclarationsOptions = {\n attrs?: Record<string, unknown> | undefined;\n theme: NodeThemeOptions;\n type: string;\n};\n\nexport function getThemeDeclarations(\n options: ThemeDeclarationsOptions\n): InlineStyle | undefined {\n const { attrs, theme, type } = options;\n const declarations = theme[type as keyof NodeThemeOptions];\n\n if (type !== MAILY_NODE_TYPES.HEADING) {\n return declarations;\n }\n\n const level =\n typeof attrs?.level === 'number'\n ? theme[`h${attrs.level}` as keyof NodeThemeOptions]\n : undefined;\n if (!(declarations || level)) {\n return;\n }\n\n return { ...declarations, ...level };\n}\n"],"mappings":";;AAAA,MAAa,kBAAkB;CAC7B,MAAM;CACN,QAAQ;CACR,OAAO;AACT;AAKA,MAAM,oBAAqD,OAAO,OAChE,OAAO,OAAO,eAAe,CAC/B;AAEA,MAAa,qBAA2C,gBAAgB;AAExE,SAAgB,uBACd,OAC+B;CAC/B,OACE,OAAO,UAAU,YACjB,kBAAkB,SAAS,KAA6B;AAE5D;;;ACpBA,MAAa,gBAAgB;CAC3B,OAAO;CACP,QAAQ;CACR,QAAQ;AACV;AAKA,MAAM,sBAAqD,OAAO,OAChE,OAAO,OAAO,aAAa,CAC7B;AAEA,MAAa,uBAA2C,cAAc;AAEtE,SAAgB,qBACd,OAC6B;CAC7B,OACE,OAAO,UAAU,YACjB,oBAAoB,SAAS,KAA2B;AAE5D;;;;;;AAaA,SAAgB,eAAe,OAAiC;CAC9D,MAAM,SAAS,MAAM,UAAU,GAAA,CAAI,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO;CAErE,IAAI;CACJ,IAAI;CACJ,IAAI;CAEJ,KAAK,MAAM,QAAQ,OACjB,IAAI,qBAAqB,IAAI,KAAK,SAAS,QACzC,cAAc;MACT,IAAI,SAAS,KAAK,IAAI,GAC3B,QAAQ;MAER,QAAQ;CAIZ,OAAO;EACL,OAAO,MAAM,eAAe;EAC5B,OAAO,MAAM,eAAe;EAC5B,OAAO,MAAM,eAAe;CAC9B;AACF;;;ACzDA,MAAa,YAAY;CAAC;CAAO;CAAS;CAAU;AAAM;AAI1D,MAAa,cAAc;CACzB;CACA;CACA;CACA;AACF;AAIA,SAAS,WAAW,OAAe;CACjC,OAAO,MAAM,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,MAAM,MAAM,CAAC;AACtD;;;;;;AAOA,SAAS,kBAAkB,WAA+B;CACxD,MA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M,eAAe,MAAM;CAE3B,IAAI,SAAS,iBAAiB,SAC5B,OAAO;CAGT,MAAM,QACJ,OAAO,OAAO,UAAU,WACpB,MAAM,IAAI,MAAM,WAChB,KAAA;CACN,IAAI,EAAE,gBAAgB,QACpB;CAGF,OAAO;EAAE,GAAG;EAAc,GAAG;CAAM;AACrC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maily-to/shared",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.11",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Shared utilities for Maily",
|
|
6
6
|
"keywords": [
|
|
@@ -33,20 +33,21 @@
|
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"csstype": "^3.2.3"
|
|
36
|
+
"csstype": "^3.2.3",
|
|
37
|
+
"stylecast": "^0.2.0"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
|
-
"bumpp": "^
|
|
40
|
-
"typescript": "^
|
|
41
|
-
"vite-plus": "
|
|
40
|
+
"bumpp": "^12.1.1",
|
|
41
|
+
"typescript": "^7.0.2",
|
|
42
|
+
"vite-plus": "0.3.0",
|
|
42
43
|
"@maily-to/tsconfig": "0.0.0"
|
|
43
44
|
},
|
|
44
45
|
"scripts": {
|
|
45
46
|
"build": "vp pack",
|
|
46
47
|
"clean": "rm -rf dist",
|
|
47
|
-
"dev": "vp pack --watch",
|
|
48
|
+
"dev": "vp pack --watch --no-clean",
|
|
48
49
|
"release": "bumpp",
|
|
49
|
-
"test": "vp test run",
|
|
50
|
+
"test": "vp test run --passWithNoTests",
|
|
50
51
|
"test:watch": "vp test"
|
|
51
52
|
}
|
|
52
53
|
}
|
package/readme.md
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
<br>
|
|
3
|
-
|
|
4
|
-
<div align="center"><strong>@maily-to/shared</strong></div>
|
|
5
|
-
<div align="center">Shared utilities for <a href="https://maily.to">Maily</a>.</div>
|
|
6
|
-
<br />
|
|
1
|
+
[](https://maily.to)
|
|
7
2
|
|
|
8
3
|
<p align="center">
|
|
9
|
-
<a href="https://github.com/arikchakma/maily.to/blob/main/
|
|
4
|
+
<a href="https://github.com/arikchakma/maily.to/blob/main/LICENSE">
|
|
10
5
|
<img src="https://img.shields.io/badge/License-MIT-222222.svg" />
|
|
11
6
|
</a>
|
|
12
7
|
<a href="https://buymeacoffee.com/arikchakma">
|
|
@@ -24,6 +19,47 @@ Install `@maily-to/shared` from your command line.
|
|
|
24
19
|
pnpm add @maily-to/shared
|
|
25
20
|
```
|
|
26
21
|
|
|
22
|
+
<br>
|
|
23
|
+
|
|
24
|
+
### What is in here
|
|
25
|
+
|
|
26
|
+
`@maily-to/shared` is the root package. It owns the vocabulary that
|
|
27
|
+
`@maily-to/core`, `@maily-to/render`, and `@maily-to/migration` all speak, and
|
|
28
|
+
it depends on none of them.
|
|
29
|
+
|
|
30
|
+
| Export group | Contents |
|
|
31
|
+
| -------------- | ------------------------------------------------------------------ |
|
|
32
|
+
| Document types | `DocumentNode`, `AnyMailyNode`, node and mark attribute types |
|
|
33
|
+
| Guards | `guard<T>()`-derived type guards for every node and mark |
|
|
34
|
+
| Style | `InlineStyle` and the helpers that read and write a `style` object |
|
|
35
|
+
| Theme | `NodeThemeOptions`, `BASIC_NODE_THEME` |
|
|
36
|
+
| Constants | `MAILY_NODE_TYPES`, `MAILY_MARK_TYPES`, trigger and limit values |
|
|
37
|
+
|
|
38
|
+
#### Documents
|
|
39
|
+
|
|
40
|
+
A Maily document is a Tiptap `doc` whose hierarchy mirrors the HTML it renders
|
|
41
|
+
to — `doc > body > container+ > blocks`. Authored styling lives in each node's
|
|
42
|
+
and mark's `style` attribute, so a document carries its own appearance and the
|
|
43
|
+
renderer applies no theme of its own.
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
import type { DocumentNode } from '@maily-to/shared';
|
|
47
|
+
import { BASIC_NODE_THEME, MAILY_NODE_TYPES } from '@maily-to/shared';
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
#### Themes
|
|
51
|
+
|
|
52
|
+
`NodeThemeOptions` maps a node type to an `InlineStyle`. `BASIC_NODE_THEME` is
|
|
53
|
+
a plain starter theme. Pass it to `ThemeExtension` to start from it, or omit it
|
|
54
|
+
for an unthemed document.
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
import { BASIC_NODE_THEME } from '@maily-to/shared';
|
|
58
|
+
import { ThemeExtension } from '@maily-to/core/extensions';
|
|
59
|
+
|
|
60
|
+
ThemeExtension.configure({ theme: BASIC_NODE_THEME });
|
|
61
|
+
```
|
|
62
|
+
|
|
27
63
|
### Contributions
|
|
28
64
|
|
|
29
65
|
Feel free to submit pull requests, create issues, or spread the word.
|