@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
| Name | Type | Default |
|---|---|---|
top | number | |
right | number | |
bottom | number | |
left | number | |
label | string | |
value | string | |
default | boolean |
DEFAULT_PAGE_SIZE
| Name | Type | Default |
|---|---|---|
width | number | |
height | number |
DEFAULT_SPACING
DEFAULT_TEXT_STYLE
| Name | Type | Default |
|---|---|---|
color | string | null | |
fontSize | number | |
fontFamily | string | |
caps | null | |
letterSpacing | null | |
bgColor | string | |
colorTheme | null | |
bgColorTheme | null | |
off | null |
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).
| Name | Type | Default |
|---|---|---|
raw | string |
{ label: string; value: string; ms: string; group: "Sans Serif" | "Serif" | "Monospace" | "Script"; spaceDot: "SpaceDot01" | "SpaceDot02" | "SpaceDot03" | "SpaceDot04" | "SpaceDot05" | ... 8 more ... | "SpaceDot14"; singleLine: number; } | nullfontFamilyToCssStack
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.
| Name | Type | Default |
|---|---|---|
name | 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.
| Name | Type | Default |
|---|---|---|
raw | string |
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.
| Name | Type | Default |
|---|---|---|
raw | string |
{ 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.
| Name | Type | Default |
|---|---|---|
raw | string |
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.
| Name | Type | Default |
|---|---|---|
name | string |
"SpaceDot01" | "SpaceDot02" | "SpaceDot03" | "SpaceDot04" | "SpaceDot05" | "SpaceDot06" | "SpaceDot07" | "SpaceDot08" | "SpaceDot09" | "SpaceDot10" | "SpaceDot11" | "SpaceDot12" | "SpaceDot13" | "SpaceDot14"FontFamilyEntry
One entry of FONT_FAMILIES.
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.
| Name | Type | Default |
|---|---|---|
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.
| Name | Type | Default |
|---|---|---|
value | string | |
label | string |
Other exports
| Export | Type | Description |
|---|---|---|
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_THEMES | readonly DocumentTheme[] | Word’s colour sets, in its Design › Colors order: the choices for setDocumentTheme. |
BORDER_STYLES | BorderStyle[] | 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_USER | CurrentUser | Author of AI suggestions and comments when the host supplies no user; also the scope of “accept/reject all”. |
DEFAULT_FONT | "Arial" | |
DEFAULT_FONT_SIZE | 12 | |
DEFAULT_LINE_HEIGHT | 278 / 240 | Current Word’s Normal (w:line="278"), shown as 1.15. |
DEFAULT_PAGE_FORMAT | `PageFormats | undefined` |
DEFAULT_DOCUMENT_THEME | DocumentTheme | The 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_SHEET | StyleSheet | The 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_MAPPING | DocumentTheme["mapping"] | Word’s default w:clrSchemeMapping: background1/2 read lt1/lt2, text1/2 read dk1/dk2. |
FONT_FAMILIES | FontFamilyEntry[] | 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_GROUPS | readonly ["Sans Serif", "Serif", "Monospace", "Script"] | Font picker groups, in order. |
FONT_SIZES | number[] | 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. |
MARGINS | PageMargins[] | Page margin presets, in px. Narrow is the default. |
PAGE_FORMATS | PageFormats[] | Page size presets, in px. A4 is the default. |
SPACE_DOT_FONTS | readonly ["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_LANGUAGES | readonly 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_TYPES | Underline[] | CSS rendering for each UnderlineType. |
ZOOM_DEFAULT | 100 | |
ZOOM_MAX | 200 | |
ZOOM_MIN | 50 |