NodeSpec
A description of a node type, used when defining a schema.
§Properties
The attributes that nodes of this type get.
Can be used to indicate that this node contains code, which causes some commands to behave differently.
The content expression for this node, as described in the schema guide. When not given, the node does not allow any content.
When enabled, enables both
definingAsContext
and
definingForContent
.
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.
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.
Determines whether nodes of this type can be dragged without being selected. Defaults to false.
The group or space-separated groups to which this node belongs, which can be referred to in the content expressions for the schema.
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.
Defines the default way a leaf node of
this type should be serialized to a string (as used by
Node.textBetween
and
Node.textContent
).
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.
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.
Controls whether nodes of this type can be selected as a node selection. Defaults to true for non-text nodes.
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.
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.