@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
blockContentClasses
Parameters:| Name | Type | Default |
|---|---|---|
node | Node |
buildCoreGlobalAttributes
Parameters:| Name | Type | Default |
|---|---|---|
nodeSpecs | Record<string, NodeSpec> |
{ trackChanges: { nodes: string[]; attrs: { trackChanges: { default: null; }; }; toDOM: (node: Node) => {}; getAttrs: (dom: HTMLElement) => { trackChanges: null; } | { trackChanges: { ...; }; }; }; ... 13 more ...; suppressLineNumbers: { ...; }; }ENDNOTE_NODE_NAMES
| Name | Type | Default |
|---|---|---|
anchor | "endnote_anchor" | |
body | "endnote_body" | |
container | "endnotes" | |
refAttr | string |
FOOTNOTE_NODE_NAMES
| Name | Type | Default |
|---|---|---|
anchor | "footnote_anchor" | |
body | "footnote_body" | |
container | "footnotes" | |
refAttr | string |
getBlockTrackChangeNodeNames
Parameters:| Name | Type | Default |
|---|---|---|
schema | Schema<any, any> |
getCodeBlockSpec
Parameters:| Name | Type | Default |
|---|---|---|
stateOrSchema | StateOrSchema |
getCommentsSpecs
Parameters:| Name | Type | Default |
|---|---|---|
stateOrSchema | StateOrSchema |
getCounterNodeSpec
Parameters:| Name | Type | Default |
|---|---|---|
stateOrSchema | StateOrSchema |
getCrossReferenceSpec
Parameters:| Name | Type | Default |
|---|---|---|
stateOrSchema | StateOrSchema |
getEndnotesSpecs
Parameters:| Name | Type | Default |
|---|---|---|
stateOrSchema | StateOrSchema |
getFileSpec
Parameters:| Name | Type | Default |
|---|---|---|
stateOrSchema | StateOrSchema |
getFootnotesSpecs
Parameters:| Name | Type | Default |
|---|---|---|
stateOrSchema | StateOrSchema |
getFormattedNodeNames
Parameters:| Name | Type | Default |
|---|---|---|
schema | Schema<any, any> |
getGlobalDOMAttributesMap
Parameters:| Name | Type | Default |
|---|---|---|
schema | Schema<any, any> |
getHighlightMarkSpec
Parameters:| Name | Type | Default |
|---|---|---|
stateOrSchema | EditorState | Schema<any, any> |
getHorizontalRuleSpec
Parameters:| Name | Type | Default |
|---|---|---|
stateOrSchema | StateOrSchema |
getImageAnchoredSpec
Parameters:| Name | Type | Default |
|---|---|---|
stateOrSchema | StateOrSchema |
getImageSpec
Parameters:| Name | Type | Default |
|---|---|---|
stateOrSchema | StateOrSchema |
getMathDisplaySpec
Parameters:| Name | Type | Default |
|---|---|---|
stateOrSchema | StateOrSchema |
getMathInlineSpec
Parameters:| Name | Type | Default |
|---|---|---|
stateOrSchema | StateOrSchema |
getNumberedNodeNames
Parameters:| Name | Type | Default |
|---|---|---|
schema | Schema<any, any> |
getPageBreakSpec
Parameters:| Name | Type | Default |
|---|---|---|
stateOrSchema | StateOrSchema |
getPageNumberSpec
Parameters:| Name | Type | Default |
|---|---|---|
stateOrSchema | StateOrSchema |
getPaginatedNodeNames
Parameters:| Name | Type | Default |
|---|---|---|
schema | Schema<any, any> |
getProofreadIgnoreMarkSpec
Parameters:| Name | Type | Default |
|---|---|---|
stateOrSchema | EditorState | Schema<any, any> |
getProofreadNodeNames
Parameters:| Name | Type | Default |
|---|---|---|
schema | Schema<any, any> |
getSectionSpecs
Parameters:| Name | Type | Default |
|---|---|---|
stateOrSchema | StateOrSchema |
false | { sectionContentSpec: NodeType; sectionSpec: NodeType; sectionHeaderSpec: NodeType; sectionFooterSpec: NodeType; headerFooterContentSpec: NodeType; }getSpacedNodeNames
Parameters:| Name | Type | Default |
|---|---|---|
schema | Schema<any, any> |
getStyledBlockNodeNames
Parameters:| Name | Type | Default |
|---|---|---|
schema | Schema<any, any> |
getTableSpecs
Parameters:| Name | Type | Default |
|---|---|---|
stateOrSchema | StateOrSchema |
getTextStyleMarkSpec
Parameters:| Name | Type | Default |
|---|---|---|
stateOrSchema | EditorState | Schema<any, any> |
getTocSpec
Parameters:| Name | Type | Default |
|---|---|---|
stateOrSchema | StateOrSchema |
getUploadBlockSpec
Parameters:| Name | Type | Default |
|---|---|---|
stateOrSchema | StateOrSchema |
GLOBAL_ATTRIBUTE_MARKER
| Name | Type | Default |
|---|---|---|
toString | () => string | |
valueOf | () => symbol | |
description | string | undefined | |
__@toPrimitive@11298 | (hint: string) => symbol | |
__@toStringTag@4720 | string |
isBlockTrackChangesType
Parameters:| Name | Type | Default |
|---|---|---|
type | NodeType |
isFormattedType
Parameters:| Name | Type | Default |
|---|---|---|
type | NodeType |
isNumberedType
Parameters:| Name | Type | Default |
|---|---|---|
type | NodeType |
isPaginatedType
Parameters:| Name | Type | Default |
|---|---|---|
type | NodeType |
isProofreadType
Parameters:| Name | Type | Default |
|---|---|---|
type | NodeType |
isSpacedType
Parameters:| Name | Type | Default |
|---|---|---|
type | NodeType |
isStyledBlockType
Parameters:| Name | Type | Default |
|---|---|---|
type | NodeType |
marks
mathStyleFromMarks
Parameters:| Name | Type | Default |
|---|---|---|
stored | readonly MathMarkJSON[] |
NODE_NAMES
nodes
resolveGlobalAttributes
Parameters:| Name | Type | Default |
|---|---|---|
nodeSpecs | Record<string, NodeSpec> | |
config | GlobalAttributesConfig<Record<string, GlobalAttributeDefinition>> | |
options | { assertReservedNames?: boolean; } |
stesuraSchema
Parameters:| Name | Type | Default |
|---|---|---|
props | { nodes?: Record<string, StesuraNodeSpec>; marks?: Record<string, MarkSpec>; globalAttributes?: GlobalAttributesConfig<D>; } |
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:| Name | Type | Default |
|---|---|---|
nodes | T | |
config | GlobalAttributesConfig |
Types
GlobalAttributesConfig
| Name | Type | Default |
|---|---|---|
definitions | D | |
nodes | Partial<Record<GlobalAttributeKey | (keyof D & string), GlobalAttributeNodesDelta>> |
GlobalDOMAttributesMap
MathMarkJSON
| Name | Type | Default |
|---|---|---|
type | string | |
attrs | Attrs |
MathStyle
| Name | Type | Default |
|---|---|---|
color | string | |
fontSize | numberPoints, matching the | |
bgColor | string |
NoteKindNodeNames
| Name | Type | Default |
|---|---|---|
anchor | NodeNameValue | |
body | NodeNameValue | |
container | NodeNameValue | |
refAttr | stringAnchor/body attribute holding the note ref (not “id” — the uniqueId plugin owns that). |
StesuraNodeSpec
| Name | Type | Default |
|---|---|---|
spacingRole | SpacingRoleSpacing-plugin role. When absent, an unspaced wrapper-shaped node (block
node with block content, not an atom) is | |
content | stringThe content expression for this node, as described in the schema guide . When not given, the node does not allow any content. | |
marks | stringThe marks that are allowed inside of this node. May be a
space-separated string referring to mark names or groups, | |
group | stringThe group or space-separated groups to which this node belongs, which can be referred to in the content expressions for the schema. | |
inline | booleanShould be set to true for inline nodes. (Implied for text nodes.) | |
atom | booleanCan 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. | |
selectable | booleanControls whether nodes of this type can be selected as a node selection . Defaults to true for non-text nodes. | |
draggable | booleanDetermines whether nodes of this type can be dragged without being selected. Defaults to false. | |
code | booleanCan 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
| |
definingAsContext | booleanDetermines 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. | |
definingForContent | booleanIn 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. | |
defining | booleanWhen enabled, enables both
| |
isolating | booleanWhen 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) => DOMOutputSpecDefines the default way a node of this type should be serialized
to DOM/HTML (as used by
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. | |
parseDOM | readonly TagParseRule[]Associates DOM parser information with this node, which can be
used by | |
toDebugString | (node: Node) => stringDefines 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) => stringDefines the default way a leaf node of
this type should be serialized to a string (as used by
| |
linebreakReplacement | booleanA 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
| |
disableDropCursor | boolean | ((view: EditorView, pos: { pos: number; inside: number; }, event: DragEvent) => boolean) |
Other exports
| Export | Type | Description |
|---|---|---|
BLOCK_TRACK_CHANGES_NODES | string[] | Default nodes carrying block-level track changes (trackChanges and trackChangesModification). |
FORMATTED_NODES | string[] | Default nodes carrying the formatting global attributes (formatting, which injects indent, plus textAlign / direction / suppressLineNumbers). |
GATE_ATTRS | readonly ["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. |
GlobalAttributeNodesDelta | GlobalAttributeNodesDelta | Node-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_NODES | string[] | Default nodes carrying the numbering attr. |
PAGINATED_NODES | string[] | Default nodes carrying the pagination attr (keepWithNext / keepLines / widowOrphan / pageBreakBefore). |
PROOFREAD_NODES | string[] | Default nodes carrying the proofingLanguage attr. |
SPACED_NODES | string[] | 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_NODES | string[] | Default nodes carrying block styling (styleId and blockStyling). |