New

docx-editor 1.x has shipped. Vue support, i18n, agents. Read the migration guide →

API Referencev1.0.2

@eigenpal/docx-editor-core/prosemirror/styles

Style utilities for ProseMirror editor

Functions(1)

Create a style resolver from document's style definitions

declare function createStyleResolver(styleDefinitions: StyleDefinitions | undefined): StyleResolver;

Classes(1)

StyleResolver provides efficient access to resolved style properties

declare class StyleResolver
MemberTypeSummary
(constructor)Constructs a new instance of the `StyleResolver` class
getDefaultCharacterStyleGet the default character style (the one marked `w:default="1"`).
getDefaultParagraphStyleGet default paragraph style (usually "Normal")
getDefaultTableStyleGet the default table style (the one marked `w:default="1"`).
getDocDefaultsGet document defaults
getParagraphStylesGet all available paragraph styles (for toolbar dropdown)
getRunStyleOwnPropertiesGet a character style's own properties WITHOUT docDefaults. Used when the caller already has docDefaults applied (e.g., from paragraph style resolution). This prevents docDefault fonts from incorrectly overriding paragraph style fonts.
getStyleGet a style by ID
getTableStylesGet all available table styles (for style gallery)
hasParagraphStyleWhether a paragraph style with the given id is defined in the document's `styles.xml`. Used by the agent toolkit to refuse `set_paragraph_style({ styleId: 'NoSuchStyle' })` instead of silently writing an invalid `<w:pStyle>` reference.
hasStyleCheck if a style exists
resolveParagraphStyleResolve paragraph style properties, including docDefaults cascade
resolveRunStyleResolve run (character) style properties

Interfaces(1)

Resolved style properties ready for rendering

interface ResolvedParagraphStyle
MemberTypeSummary
paragraphFormatting?ParagraphFormattingParagraph formatting (alignment, spacing, indentation, etc.)
runFormatting?TextFormattingDefault run formatting from the style