Skip to main content

Creating a Node

Use the static create method to define a new node.
Partial<NodeConfig<Options, Storage>> | (() => Partial<NodeConfig<Options, Storage>>)
The node configuration object or a function that returns a configuration object.

Configuration Options

Nodes inherit all configuration options from Extension, plus the following:

content

Define the content expression for the node.
string
A ProseMirror content expression defining what content this node can contain.
Examples

marks

Define which marks are allowed inside the node.
string
Space-separated mark names, "_" to allow all marks, or "" to disallow marks.
Example

group

Define the group(s) this node belongs to.
string
Space-separated group names (e.g., 'block', 'inline').
Example

inline

Whether the node is an inline node.
boolean
default:"false"
Set to true for inline nodes.
Example

atom

Whether the node is atomic (non-editable as a unit).
boolean
default:"false"
Set to true for atomic nodes that should be treated as a single unit.
Example

selectable

Whether the node can be selected.
boolean
default:"true"
Whether the node can be selected with a node selection.
Example

draggable

Whether the node can be dragged.
boolean
default:"false"
Whether the node can be dragged without being selected.
Example

code

Whether the node contains code.
boolean
default:"false"
Indicates that this node contains code, affecting command behavior.
Example

defining

Whether the node is defining.
boolean
default:"false"
When enabled, affects context for schema operations.

isolating

Whether the node is isolating.
boolean
default:"false"
When enabled, the sides of this node count as boundaries that regular editing operations won’t cross.
Example

topNode

Whether this node should be the top-level node (document).
boolean
default:"false"
Set to true for the document node.
Example

parseHTML()

Define how to parse HTML into this node.
Example

renderHTML()

Define how to render the node as HTML.
Example

renderText()

Define how to render the node as plain text.
Example

addAttributes()

Define attributes for the node.
Example

addNodeView()

Define a custom node view.
Example

Methods

configure()

Create a configured version of the node.
Partial<Options>
Options to override the default options.
Example

extend()

Extend the node with additional configuration.
Partial<ExtendedConfig> | (() => Partial<ExtendedConfig>)
Additional configuration or a function that returns configuration.
Example

Complete Example