Skip to Content
API Referencecorecore/constants

@stesura/core/constants

Defaults and presets a host’s own UI needs: page formats and margins, fonts and sizes, line heights, highlight colours, zoom bounds, proofing languages, the built-in stylesheet and colour themes, and the default AI author. The global-attribute node lists are in core/schema.

Functions & values

DEFAULT_PAGE_MARGINS

NameTypeDefault
topnumber
bottomnumber
leftnumber
labelstring
valuestring
defaultboolean

DEFAULT_PAGE_SIZE

NameTypeDefault
widthnumber
heightnumber

DEFAULT_SPACING

NameTypeDefault
beforenumber | null
afternumber | null
contextualboolean | null

Word’s “don’t add space between paragraphs of the same style” (w:contextualSpacing): between two blocks of one style, the before/after of a block that sets it is ignored. Inherits through the style like the other fields; null inherits.

DEFAULT_TEXT_STYLE

NameTypeDefault
colorstring | null
fontSizenumber
fontFamilystring
capsnull
letterSpacingnull
bgColorstring
colorThemenull
bgColorThemenull
offnull

findFontFamily

Find the FONT_FAMILIES entry for ANY alias of a font, case-insensitively: internal value (“Tinos”), Microsoft/Word name (“Times New Roman”), UI label, or SpaceDot face (“SpaceDot10”). Accepts a full CSS stack and returns the first part that matches. Returns null for unknown fonts.

This is the single lookup every consumer must use — matching on value only silently misses DOCX names (a “Times New Roman” import previously fell through to the local system font and the SpaceDot01 space-dot face).

Parameters:
NameTypeDefault
rawstring
Returns:
{ label: string; value: string; ms: string; group: "Sans Serif" | "Serif" | "Monospace" | "Script"; spaceDot: "SpaceDot01" | "SpaceDot02" | "SpaceDot03" | "SpaceDot04" | "SpaceDot05" | ... 8 more ... | "SpaceDot14"; singleLine: number; } | null

fontFamilyToCssStack

CSS font-family stack (without the var(--space-font…) prefix) for a stored fontFamily attribute: web font, the shipped emoji font, the script fallbacks, then the metric-compatible Microsoft local font (identical layout while the web font loads) and the group generic. Unknown fonts emit their substitute’s stack — never the raw name (see resolveDisplayFont); the original name still round-trips via the mark attr / data-font-family.

Parameters:
NameTypeDefault
namestring
Returns:
string

normalizeFontFamily

Normalize a font name to the internal FONT_FAMILIES value (“Times New Roman” → “Tinos”). Unknown fonts are preserved verbatim (first cleaned name) so they round-trip through DOCX export, which passes non-internal names through unchanged. Returns null for empty input.

Parameters:
NameTypeDefault
rawstring
Returns:
string | null

resolveDisplayFont

The FONT_FAMILIES entry actually used to RENDER a stored fontFamily. Supported fonts resolve exactly; unsupported ones (kept verbatim in the document for DOCX round-tripping) get a deterministic supported substitute: curated table first, then a serif/sans/mono/script heuristic on the name.

Unsupported fonts are never rendered directly — a locally installed face would make layout (and pagination) differ per machine, and would mismatch the SpaceDot space widths.

Parameters:
NameTypeDefault
rawstring
Returns:
{ label: string; value: string; ms: string; group: "Sans Serif" | "Serif" | "Monospace" | "Script"; spaceDot: "SpaceDot01" | "SpaceDot02" | "SpaceDot03" | "SpaceDot04" | "SpaceDot05" | ... 8 more ... | "SpaceDot14"; singleLine: number; }

singleLineFactor

Word’s single line, × the font size, for a stored fontFamily or a computed CSS stack: the rendered font’s (resolveDisplayFont), so an unknown font spaces like its substitute.

Parameters:
NameTypeDefault
rawstring
Returns:
number

spaceDotFontFamily

SpaceDot face (invisible-characters space glyphs) for a stored fontFamily. Resolved through resolveDisplayFont so the face always matches the font that’s actually rendered — including substituted unknown fonts.

Parameters:
NameTypeDefault
namestring
Returns:
"SpaceDot01" | "SpaceDot02" | "SpaceDot03" | "SpaceDot04" | "SpaceDot05" | "SpaceDot06" | "SpaceDot07" | "SpaceDot08" | "SpaceDot09" | "SpaceDot10" | "SpaceDot11" | "SpaceDot12" | "SpaceDot13" | "SpaceDot14"

FontFamilyEntry

One entry of FONT_FAMILIES.

NameTypeDefault
labelstring
valuestring
msstring
group"Sans Serif" | "Serif" | "Monospace" | "Script"
spaceDot"SpaceDot01" | "SpaceDot02" | "SpaceDot03" | "SpaceDot04" | "SpaceDot05" | "SpaceDot06" | "SpaceDot07" | "SpaceDot08" | "SpaceDot09" | "SpaceDot10" | "SpaceDot11" | "SpaceDot12" | "SpaceDot13" | "SpaceDot14"
singleLinenumber

Word’s single line for the ms font, × the font size: what Word’s line spacing multiplies. Font metrics (win ascent + descent + external leading; Aptos: its typo metrics), checked against Word over COM (2026-10-20).

UnderlineType

Underline styles the editor renders, as OOXML w:u/@w:val tokens — every entry has a matching UNDERLINE_TYPES row supplying its CSS, and DOCX export writes the value straight through.

Word defines eight more (words, the dashLong/dotDash family, wavyDouble), excluded because nothing draws them; DOCX import maps them to the nearest style here.

NameTypeDefault
SINGLE"single"
DOUBLE"double"
THICK"thick"
DOTTED"dotted"
DOTTEDHEAVY"dottedHeavy"
DASH"dash"
DASHEDHEAVY"dashedHeavy"
WAVE"wave"
WAVYHEAVY"wavyHeavy"

Types

ProofingLanguageOption

One entry of a proofing-language list: the proofingLanguage value and its label.

NameTypeDefault
valuestring
labelstring

Other exports

ExportTypeDescription
AUTO_COLOR"auto"Sentinel for Word’s “automatic” font color (w:color w:val="auto"): an EXPLICIT value that overrides an inherited color and resolves at render time to whichever of black/white contrasts with the nearest background. Stored verbatim in the color slot of textStyle marks and character styles so it round-trips through DOCX; never valid in any other color slot.
BUILT_IN_THEMESreadonly DocumentTheme[]Word’s colour sets, in its Design › Colors order: the choices for setDocumentTheme.
BORDER_STYLESBorderStyle[]Supported border styles.
CAPS_VALUES["all", "small", "none"]The two casing formats plus an explicit off.
CASE_CHANGES["sentence", "uppercase", "lowercase", "capitalize"]changeCase modes, in menu order.
DEFAULT_AI_USERCurrentUserAuthor of AI suggestions and comments when the host supplies no user; also the scope of “accept/reject all”.
DEFAULT_FONT"Arial"
DEFAULT_FONT_SIZE12
DEFAULT_LINE_HEIGHT278 / 240Current Word’s Normal (w:line="278"), shown as 1.15.
DEFAULT_PAGE_FORMAT`PageFormatsundefined`
DEFAULT_DOCUMENT_THEMEDocumentThemeThe theme a new document gets: Office 2013 - 2022, the colours existing documents were written against.
DEFAULT_PROOFING_LANGUAGE"en-GB"The default doc.attrs.language, and the fallback when it is empty: the language a block is proofed in when nothing declares one.
DEFAULT_STYLE_SHEETStyleSheetThe built-in stylesheet.
DEFAULT_TEXT_DIRECTION"ltr"The text direction a document resolves to when neither the paragraph nor the section declares one. Hosts override it per document via the dir doc attr (setDocDirection), not by editing this.
DEFAULT_THEME_MAPPINGDocumentTheme["mapping"]Word’s default w:clrSchemeMapping: background1/2 read lt1/lt2, text1/2 read dk1/dk2.
FONT_FAMILIESFontFamilyEntry[]The font picker’s fonts. Each maps a Word font (label, ms) to the open substitute the editor renders (value, bundled in @stesura/fonts/fonts.css), plus its picker group and SpaceDot face.
FONT_FAMILY_GROUPSreadonly ["Sans Serif", "Serif", "Monospace", "Script"]Font picker groups, in order.
FONT_SIZESnumber[]Preset font sizes, in points.
HIGHLIGHT_COLORS`([“yellow”, string][“lime”, string]
HighlightColors"yellow" | "lime" | "aqua" | "fuchsia" | "red"
INHERIT_LIST_REF"__inherit"Reserved numbering.listRef meaning “the list comes from the paragraph’s style; the other fields on this attr are per-paragraph overrides”. Stamped by the numbering plugin, never a real key in doc.attrs.listConfigs — writers and guards reject it.
LINE_HEIGHTS{ label: string; value: number; }[]Word’s line-spacing menu: multiples of the font’s single line.
MARGINSPageMargins[]Page margin presets, in px. Narrow is the default.
PAGE_FORMATSPageFormats[]Page size presets, in px. A4 is the default.
SPACE_DOT_FONTSreadonly ["SpaceDot01", "SpaceDot02", "SpaceDot03", "SpaceD…SpaceDot font families, one per editor font: space-only faces that draw a dot for spaces when invisible characters are shown.
SUPPORTED_LANGUAGESreadonly ProofingLanguageOption[]The proofing languages the UI offers, each checkable by the packaged LanguageTool backend. Hosts with another backend pass their own list to the language selectors.
UNDERLINE_TYPESUnderline[]CSS rendering for each UnderlineType.
ZOOM_DEFAULT100
ZOOM_MAX200
ZOOM_MIN50
Last updated on