ProsemirrorEx.Schema.List (prosemirror_ex v0.3.0)

Copy Markdown View Source

DX sugar porting prosemirror-schema-list node specs and addListNodes/3.

Provides base specs for ordered and bullet lists and list items, plus helpers to append them to a schema node list. Does not include list commands (wrapInList, splitListItem, etc.).

Example

nodes =
  ProsemirrorEx.Schema.Basic.nodes()
  |> add_list_nodes("paragraph block*", "block")

schema = ProsemirrorEx.Model.Schema.new(%{
  "nodes" => nodes,
  "marks" => ProsemirrorEx.Schema.Basic.marks()
})

Summary

Functions

Appends ordered_list, bullet_list, and list_item to a node list.

Base bullet list node spec.

Base list item node spec.

Returns the three list node entries as {name, spec} tuples.

Base ordered list node spec.

Functions

add_list_nodes(nodes, item_content, list_group \\ nil)

@spec add_list_nodes([{String.t(), map()}], String.t(), String.t() | nil) :: [
  {String.t(), map()}
]

Appends ordered_list, bullet_list, and list_item to a node list.

nodes is a list of {name, spec} tuples in this project's schema format. Returns a new list with the three list nodes appended.

bullet_list()

@spec bullet_list() :: map()

Base bullet list node spec.

Content and group are not set — use add_list_nodes/3 or nodes/2 to fill those in.

list_item()

@spec list_item() :: map()

Base list item node spec.

Marked as defining. Content is not set — use add_list_nodes/3 or nodes/2 to fill it in.

nodes(item_content, list_group \\ nil)

@spec nodes(String.t(), String.t() | nil) :: [{String.t(), map()}]

Returns the three list node entries as {name, spec} tuples.

item_content sets the list item content expression (e.g. "paragraph block*"). When list_group is a string, both list types get "group" => list_group; when nil, no group is set.

ordered_list()

@spec ordered_list() :: map()

Base ordered list node spec.

Has a single order attribute defaulting to 1. Content and group are not set — use add_list_nodes/3 or nodes/2 to fill those in.