Skip to Content

@stesura/core/schema

The document schema. stesuraSchema() builds it; the node and mark specs, node names and the global-attribute system are exported for custom schemas.

The *_NODES lists are default bindings only: stesuraSchema’s globalAttributes.nodes can change them per schema. Gate runtime behaviour on the is*Type / get*NodeNames predicates, which read the constructed schema.

Functions & values

BLOCK_CONTENT_CLASS

NameTypeDefault
blank"pm-blank"

No inline children at all — the block renders as a bare trailing break.

trailingBreak"pm-trailing-break"

ProseMirror renders a br.ProseMirror-trailingBreak inside this block.

atomEnd"pm-atom-end"

Ends in a non-text inline node other than a hard break. The trailing <br> renders after it, so an ::after pilcrow would land on the next line (MT-12); these blocks get a widget marker instead (see plugins/invisible-characters/pilcrow-decorations.ts).

anchorFloat"pm-anchor-float"

Contains a square/tight anchored image, so the block must contain its float.

hasDeletion"pm-tc-del"

At least one child carries the track-changes deletion mark.

allDeleted"pm-tc-all-del"

Every child carries the deletion mark — nothing renders in show-off mode.

blockContentClasses

Parameters:
NameTypeDefault
nodeNode
Returns:
string

buildCoreGlobalAttributes

Parameters:
NameTypeDefault
nodeSpecsRecord<string, NodeSpec>
Returns:
{ trackChanges: { nodes: string[]; attrs: { trackChanges: { default: null; }; }; toDOM: (node: Node) => {}; getAttrs: (dom: HTMLElement) => { trackChanges: null; } | { trackChanges: { ...; }; }; }; ... 13 more ...; suppressLineNumbers: { ...; }; }

ENDNOTE_NODE_NAMES

NameTypeDefault
anchor"endnote_anchor"
body"endnote_body"
container"endnotes"
refAttrstring

FOOTNOTE_NODE_NAMES

NameTypeDefault
anchor"footnote_anchor"
body"footnote_body"
container"footnotes"
refAttrstring

getBlockTrackChangeNodeNames

Parameters:
NameTypeDefault
schemaSchema<any, any>
Returns:
ReadonlySet<string>

getCodeBlockSpec

Parameters:
NameTypeDefault
stateOrSchemaStateOrSchema
Returns:
false | NodeType

getCommentsSpecs

Parameters:
NameTypeDefault
stateOrSchemaStateOrSchema
Returns:
false | { commentOpenSpec: NodeType; commentCloseSpec: NodeType; }

getCounterNodeSpec

Parameters:
NameTypeDefault
stateOrSchemaStateOrSchema
Returns:
false | NodeType

getCrossReferenceSpec

Parameters:
NameTypeDefault
stateOrSchemaStateOrSchema
Returns:
false | NodeType

getEndnotesSpecs

Parameters:
NameTypeDefault
stateOrSchemaStateOrSchema
Returns:
false | { endnoteBodySpec: NodeType; endnoteAnchorSpec: NodeType; endnotesSpec: NodeType; }

getFileSpec

Parameters:
NameTypeDefault
stateOrSchemaStateOrSchema
Returns:
false | NodeType

getFootnotesSpecs

Parameters:
NameTypeDefault
stateOrSchemaStateOrSchema
Returns:
false | { footnoteBodySpec: NodeType; footnoteAnchorSpec: NodeType; footnotesSpec: NodeType; }

getFormattedNodeNames

Parameters:
NameTypeDefault
schemaSchema<any, any>
Returns:
ReadonlySet<string>

getGlobalDOMAttributesMap

Parameters:
NameTypeDefault
schemaSchema<any, any>
Returns:
GlobalDOMAttributesMap

getHighlightMarkSpec

Parameters:
NameTypeDefault
stateOrSchemaEditorState | Schema<any, any>
Returns:
false | MarkType

getHorizontalRuleSpec

Parameters:
NameTypeDefault
stateOrSchemaStateOrSchema
Returns:
false | NodeType

getImageAnchoredSpec

Parameters:
NameTypeDefault
stateOrSchemaStateOrSchema
Returns:
false | NodeType

getImageSpec

Parameters:
NameTypeDefault
stateOrSchemaStateOrSchema
Returns:
false | NodeType

getMathDisplaySpec

Parameters:
NameTypeDefault
stateOrSchemaStateOrSchema
Returns:
false | NodeType

getMathInlineSpec

Parameters:
NameTypeDefault
stateOrSchemaStateOrSchema
Returns:
false | NodeType

getNumberedNodeNames

Parameters:
NameTypeDefault
schemaSchema<any, any>
Returns:
ReadonlySet<string>

getPageBreakSpec

Parameters:
NameTypeDefault
stateOrSchemaStateOrSchema
Returns:
false | NodeType

getPageNumberSpec

Parameters:
NameTypeDefault
stateOrSchemaStateOrSchema
Returns:
false | NodeType

getPaginatedNodeNames

Parameters:
NameTypeDefault
schemaSchema<any, any>
Returns:
ReadonlySet<string>

getProofreadIgnoreMarkSpec

Parameters:
NameTypeDefault
stateOrSchemaEditorState | Schema<any, any>
Returns:
false | MarkType

getProofreadNodeNames

Parameters:
NameTypeDefault
schemaSchema<any, any>
Returns:
ReadonlySet<string>

getSectionSpecs

Parameters:
NameTypeDefault
stateOrSchemaStateOrSchema
Returns:
false | { sectionContentSpec: NodeType; sectionSpec: NodeType; sectionHeaderSpec: NodeType; sectionFooterSpec: NodeType; headerFooterContentSpec: NodeType; }

getSpacedNodeNames

Parameters:
NameTypeDefault
schemaSchema<any, any>
Returns:
ReadonlySet<string>

getStyledBlockNodeNames

Parameters:
NameTypeDefault
schemaSchema<any, any>
Returns:
ReadonlySet<string>

getTableSpecs

Parameters:
NameTypeDefault
stateOrSchemaStateOrSchema
Returns:
false | { tableCellSpec: NodeType; tableRowSpec: NodeType; tableSpec: NodeType; }

getTextStyleMarkSpec

Parameters:
NameTypeDefault
stateOrSchemaEditorState | Schema<any, any>
Returns:
false | MarkType

getTocSpec

Parameters:
NameTypeDefault
stateOrSchemaStateOrSchema
Returns:
false | NodeType

getUploadBlockSpec

Parameters:
NameTypeDefault
stateOrSchemaStateOrSchema
Returns:
false | NodeType

GLOBAL_ATTRIBUTE_MARKER

NameTypeDefault
toString() => string
valueOf() => symbol
descriptionstring | undefined
__@toPrimitive@11298(hint: string) => symbol
__@toStringTag@4720string

isBlockTrackChangesType

Parameters:
NameTypeDefault
typeNodeType
Returns:
boolean

isFormattedType

Parameters:
NameTypeDefault
typeNodeType
Returns:
boolean

isNumberedType

Parameters:
NameTypeDefault
typeNodeType
Returns:
boolean

isPaginatedType

Parameters:
NameTypeDefault
typeNodeType
Returns:
boolean

isProofreadType

Parameters:
NameTypeDefault
typeNodeType
Returns:
boolean

isSpacedType

Parameters:
NameTypeDefault
typeNodeType
Returns:
boolean

isStyledBlockType

Parameters:
NameTypeDefault
typeNodeType
Returns:
boolean

marks

NameTypeDefault
emMarkSpec
strongMarkSpec
codeMarkSpec
underlineMarkSpec
strikethroughMarkSpec
superscriptMarkSpec
subscriptMarkSpec
highlightMarkSpec
borderMarkSpec
textStyleMarkSpec
proofReadIgnoreMarkSpec
deletionMarkSpec
insertionMarkSpec
modificationMarkSpec

mathStyleFromMarks

Parameters:
NameTypeDefault
storedreadonly MathMarkJSON[]
Returns:
MathStyle

NODE_NAMES

NameTypeDefault
Doc"doc"
Paragraph"paragraph"
Heading"heading"
Counter"counter_node"
TOC"toc"
HorizontalRule"horizontal_rule"
PageBreak"page_break"
Image"image"
ImageAnchored"image_anchored"
MathInline"math_inline"
MathDisplay"math_display"
Table"table"
TableRow"table_row"
TableCell"table_cell"
CodeBlock"code_block"
HardBreak"hard_break"
BoundaryOpenNode"boundary_open_node"
BoundaryCloseNode"boundary_close_node"
PageNumber"page_number"
CommentOpen"comment_open"
CommentClose"comment_close"
UploadBlock"upload_block"
File"file"
SectionHeaderFooterContent"header_footer_content"
Section"section"
SectionHeader"section_header"
SectionFooter"section_footer"
SectionContent"section_content"
Footnotes"footnotes"
FootnoteAnchor"footnote_anchor"
FootnoteBody"footnote_body"
Endnotes"endnotes"
EndnoteAnchor"endnote_anchor"
EndnoteBody"endnote_body"
CrossReference"cross_reference"

nodes

NameTypeDefault
docNodeSpec
textNodeSpec
paragraphNodeSpec
headingNodeSpec
counter_nodeNodeSpec
tocNodeSpec
horizontal_ruleNodeSpec
page_breakNodeSpec
imageNodeSpec
image_anchoredNodeSpec
math_inlineNodeSpec
math_displayNodeSpec
tableNodeSpec
table_rowNodeSpec
table_cellNodeSpec
code_blockNodeSpec
hard_breakNodeSpec
boundary_open_nodeNodeSpec
boundary_close_nodeNodeSpec
page_numberNodeSpec
comment_openNodeSpec
comment_closeNodeSpec
upload_blockNodeSpec
fileNodeSpec
sectionNodeSpec
section_headerNodeSpec
section_contentNodeSpec
footnotesNodeSpec
footnote_anchorNodeSpec
footnote_bodyNodeSpec
endnotesNodeSpec
endnote_anchorNodeSpec
endnote_bodyNodeSpec
cross_referenceNodeSpec

resolveGlobalAttributes

Parameters:
NameTypeDefault
nodeSpecsRecord<string, NodeSpec>
configGlobalAttributesConfig<Record<string, GlobalAttributeDefinition>>
options{ assertReservedNames?: boolean; }
Returns:
GlobalAttributeMap

stesuraSchema

Parameters:
NameTypeDefault
props{ nodes?: Record<string, StesuraNodeSpec>; marks?: Record<string, MarkSpec>; globalAttributes?: GlobalAttributesConfig<D>; }
Returns:
Schema<"doc" | "text" | "paragraph" | "heading" | "counter_node" | "toc" | "horizontal_rule" | "page_break" | "image" | "image_anchored" | "math_inline" | "math_display" | "table" | ... 22 more ... | "cross_reference", "link" | ... 13 more ... | "modification">

withGlobalAttributes

Parameters:
NameTypeDefault
nodesT
configGlobalAttributesConfig
Returns:
T

Types

GlobalAttributesConfig

NameTypeDefault
definitionsD
nodesPartial<Record<GlobalAttributeKey | (keyof D & string), GlobalAttributeNodesDelta>>

GlobalDOMAttributesMap

NameTypeDefault
clear() => void
delete(key: string) => boolean
forEach(callbackfn: (value: (node: Node) => Record<string, string>, key: string, map: Map<string, (node: Node) => Record<string, string>>) => void, thisArg?: any) => void
get(key: string) => ((node: Node) => Record<string, string>) | undefined
has(key: string) => boolean
set(key: string, value: (node: Node) => Record<string, string>) => GlobalDOMAttributesMap
sizenumber
entries() => MapIterator<[string, (node: Node) => Record<string, string>]>
keys() => MapIterator<string>
values() => MapIterator<(node: Node) => Record<string, string>>
__@iterator@36() => MapIterator<[string, (node: Node) => Record<string, string>]>
__@toStringTag@4720string

MathMarkJSON

NameTypeDefault
typestring
attrsAttrs

MathStyle

NameTypeDefault
colorstring
fontSizenumber

Points, matching the textStyle attr.

bgColorstring

NoteKindNodeNames

NameTypeDefault
anchorNodeNameValue
bodyNodeNameValue
containerNodeNameValue
refAttrstring

Anchor/body attribute holding the note ref (not “id” — the uniqueId plugin owns that).

StesuraNodeSpec

NameTypeDefault
spacingRoleSpacingRole

Spacing-plugin role. When absent, an unspaced wrapper-shaped node (block node with block content, not an atom) is "passThrough" and everything else is a "boundary". Set it only to override that inference.

contentstring

The content expression for this node, as described in the schema guide . When not given, the node does not allow any content.

marksstring

The marks that are allowed inside of this node. May be a space-separated string referring to mark names or groups, "_" to explicitly allow all marks, or "" to disallow marks. When not given, nodes with inline content default to allowing all marks, other nodes default to not allowing marks.

groupstring

The group or space-separated groups to which this node belongs, which can be referred to in the content expressions for the schema.

inlineboolean

Should be set to true for inline nodes. (Implied for text nodes.)

atomboolean

Can be set to true to indicate that, though this isn’t a leaf node , it doesn’t have directly editable content and should be treated as a single unit in the view.

attrs{ [name: string]: AttributeSpec; }

The attributes that nodes of this type get.

selectableboolean

Controls whether nodes of this type can be selected as a node selection . Defaults to true for non-text nodes.

draggableboolean

Determines whether nodes of this type can be dragged without being selected. Defaults to false.

codeboolean

Can be used to indicate that this node contains code, which causes some commands to behave differently.

whitespace"pre" | "normal"

Controls way whitespace in this a node is parsed. The default is "normal", which causes the DOM parser  to collapse whitespace in normal mode, and normalize it (replacing newlines and such with spaces) otherwise. "pre" causes the parser to preserve spaces inside the node. When this option isn’t given, but code is true, whitespace will default to "pre". Note that this option doesn’t influence the way the node is rendered—that should be handled by toDOM and/or styling.

definingAsContextboolean

Determines whether this node is considered an important parent node during replace operations (such as paste). Non-defining (the default) nodes get dropped when their entire content is replaced, whereas defining nodes persist and wrap the inserted content.

definingForContentboolean

In inserted content the defining parents of the content are preserved when possible. Typically, non-default-paragraph textblock types, and possibly list items, are marked as defining.

definingboolean

When enabled, enables both definingAsContext and definingForContent.

isolatingboolean

When enabled (default is false), the sides of nodes of this type count as boundaries that regular editing operations, like backspacing or lifting, won’t cross. An example of a node that should probably have this enabled is a table cell.

toDOM(node: Node) => DOMOutputSpec

Defines the default way a node of this type should be serialized to DOM/HTML (as used by DOMSerializer.fromSchema). Should return a DOM node or an array structure  that describes one, with an optional number zero (“hole”) in it to indicate where the node’s content should be inserted.

For text nodes, the default is to create a text DOM node. Though it is possible to create a serializer where text is rendered differently, this is not supported inside the editor, so you shouldn’t override that in your text node spec.

parseDOMreadonly TagParseRule[]

Associates DOM parser information with this node, which can be used by DOMParser.fromSchema to automatically derive a parser. The node field in the rules is implied (the name of this node will be filled in automatically). If you supply your own parser, you do not need to also specify parsing rules in your schema.

toDebugString(node: Node) => string

Defines the default way a node of this type should be serialized to a string representation for debugging (e.g. in error messages).

leafText(node: Node) => string

Defines the default way a leaf node  of this type should be serialized to a string (as used by Node.textBetween and Node.textContent).

linebreakReplacementboolean

A single inline node in a schema can be set to be a linebreak equivalent. When converting between block types that support the node and block types that don’t but have whitespace set to "pre", setBlockType will convert between newline characters to or from linebreak nodes as appropriate.

disableDropCursorboolean | ((view: EditorView, pos: { pos: number; inside: number; }, event: DragEvent) => boolean)

Other exports

ExportTypeDescription
BLOCK_TRACK_CHANGES_NODESstring[]Default nodes carrying block-level track changes (trackChanges and trackChangesModification).
FORMATTED_NODESstring[]Default nodes carrying the formatting global attributes (formatting, which injects indent, plus textAlign / direction / suppressLineNumbers).
GATE_ATTRSreadonly ["numbering", "pagination", "indent", "spacing", "styleId", "proofingLanguage", "trackChanges"]The attrs the predicates key on, one per predicate. Reserved: a node spec or custom global attribute declaring one throws a RangeError.
GateAttr"numbering" | "pagination" | "indent" | "spacing" | "styleId" | "proofingLanguage" | "trackChanges"
GlobalAttributeKey"numbering" | "proofingLanguage" | "formatting" | "textAlign" | "spacing" | "styleId" | "blockStyling" | "uniqueId" | "direction" | "trackChanges" | "trackChangesModification" | "suppressLineNumbers" | "nodeComment" | "pagination" | "blockContentClasses"Names of the core global attributes.
GlobalAttributeNodesDeltaGlobalAttributeNodesDeltaNode-binding delta for one global attribute: true grants it to the node type, false revokes a default binding, absent keeps the default.
NodeNameValue"doc" | "paragraph" | "heading" | "counter_node" | "toc" | "horizontal_rule" | "page_break" | "image" | "image_anchored" | "math_inline" | "math_display" | "table" | "table_row" | "table_cell" | "code_block" | "hard_break" | "boundary_open_node" | "boundary_close_node" | "page_number" | "comment_open" | "comment_close" | "upload_block" | "file" | "header_footer_content" | "section" | "section_header" | "section_footer" | "section_content" | "footnotes" | "footnote_anchor" | "footnote_body" | "endnotes" | "endnote_anchor" | "endnote_body" | "cross_reference"
NUMBERED_NODESstring[]Default nodes carrying the numbering attr.
PAGINATED_NODESstring[]Default nodes carrying the pagination attr (keepWithNext / keepLines / widowOrphan / pageBreakBefore).
PROOFREAD_NODESstring[]Default nodes carrying the proofingLanguage attr.
SPACED_NODESstring[]Default nodes carrying the spacing attr.
SpacingRole"passThrough" | "boundary"How a non-spaced block container takes part in the spacing plugin’s margin-collapse chains: "passThrough": its children join the surrounding chain, so margins collapse across its edges. The inferred default for wrapper nodes (block nodes with block content). "boundary": its children form an isolated chain (like a table cell).
STYLED_BLOCK_NODESstring[]Default nodes carrying block styling (styleId and blockStyling).
Last updated on