pub struct NodeSpec {
pub content: Option<ContentRule>,
pub group: Option<String>,
pub marks: Option<HashSet<String>>,
pub attrs: Option<HashSet<String>>,
pub required_attrs: HashSet<String>,
}Expand description
Rules for one node type.
Fields§
§content: Option<ContentRule>Allowed content: a set of child types (array form) or a content
expression (string form). None = any child allowed.
group: Option<String>Groups this node belongs to (space-separated, ProseMirror-style), so
content expressions can reference it by group name (e.g. block).
marks: Option<HashSet<String>>Allowed mark types on this node. None = any mark allowed.
attrs: Option<HashSet<String>>Allowed attribute keys. None = any attrs allowed.
required_attrs: HashSet<String>Attribute keys that must be present.
Implementations§
Source§impl NodeSpec
impl NodeSpec
Sourcepub fn content<I, S>(self, types: I) -> Self
pub fn content<I, S>(self, types: I) -> Self
Restrict allowed child node types (any count/order). For ordering and
cardinality use content_match.
Sourcepub fn content_match(self, expr: &str) -> Self
pub fn content_match(self, expr: &str) -> Self
Restrict content with a ProseMirror content expression (e.g.
"heading paragraph+"). Panics on an invalid expression — use
try_content_match to handle the error.
Sourcepub fn try_content_match(self, expr: &str) -> Result<Self, ParseExprError>
pub fn try_content_match(self, expr: &str) -> Result<Self, ParseExprError>
Fallible content_match.
Sourcepub fn group(self, group: impl Into<String>) -> Self
pub fn group(self, group: impl Into<String>) -> Self
Set the groups this node belongs to (space-separated, e.g. "block").
Sourcepub fn content_types(&self) -> Option<&HashSet<String>>
pub fn content_types(&self) -> Option<&HashSet<String>>
The allowed child-type set, if content is the array form (not an
expression). Convenience accessor for the content field.
Sourcepub fn required_attrs<I, S>(self, keys: I) -> Self
pub fn required_attrs<I, S>(self, keys: I) -> Self
Set attribute keys that must be present.