ProsemirrorEx.Model.Schema (prosemirror_ex v0.3.0)

Copy Markdown View Source

A document schema. Holds node and mark type objects for the nodes and marks that may occur in conforming documents, and provides functionality for creating and deserializing such documents.

Ported from ProseMirror's schema.ts.

Summary

Functions

Create a mark with the given type and attributes.

Deserialize a mark from its JSON representation.

Construct a schema from a schema specification map.

Deserialize a node from its JSON representation.

Look up a node type by name.

Create a text node in the schema. Empty text nodes are not allowed.

Functions

mark(schema, type, attrs \\ nil)

Create a mark with the given type and attributes.

mark_from_json(schema, json)

Deserialize a mark from its JSON representation.

new(spec)

Construct a schema from a schema specification map.

The spec should have:

  • "nodes" => list of {name, node_spec} tuples
  • "marks" => (optional) list of {name, mark_spec} tuples
  • "topNode" => (optional) name of the top node type, defaults to "doc"

node(schema, type, attrs \\ nil, content \\ nil, marks \\ nil)

Create a node in this schema.

node_from_json(schema, json)

Deserialize a node from its JSON representation.

node_type(schema, name)

Look up a node type by name.

text(schema, text, marks \\ nil)

Create a text node in the schema. Empty text nodes are not allowed.