This module contains types related to the nodes in an editor.
An editor consists of two types of nodes, block and inline. Block nodes are used to represent hierarchical structures like blockquotes, tables and nested lists. Inline nodes are used to represent flat structures, like text, inline images, and hard breaks.
Creates a block node. The arguments are as follows
element is the element this block node representschildNodes are the children related to this block node.block
(Element.element paragraph [])
(inlineChildren <| Array.fromList [ plainText "some text" ])the childNodes from a block node.
a block node with the given element set
a block node with the given children set
Children represents what children an editor block node can have. A block node may have other block nodes as children, inline leaf nodes as children, or it may be a leaf itself.
BlockChildren are child nodes that are all blocks.
Creates children from a block array
blockChildren (Array.fromList [ paragraphNode ])Returns a block array from block children
InlineChildren are child nodes that are all inline. Internally, it's represented as both
a flat structure (which can be accessed via inlineArray), and a hierarchical structure
(which can be accessed via inlineTree).
Creates children derived from an inline array.
an array of inline nodes (flat structure)
a tree of mark nodes with inline leaf indices
a lookup array that maps the index of the inline array to its path in the inline tree
Transforms a list of list of marks to an array of inline tree nodes
An inline leaf node represents an inline element in your document. It can either be an inline leaf node, like an image or line break, or a text node.
An inline tree is the nested structure of an inline array. Because marks when rendered can span multiple inline nodes, inline content is still technically hierarchical. When rendering or parsing, it can be useful to see this information as a tree instead of an array.
MarkNode node that represents a mark and its inline childrenLeafNode the index of the inline in the inline arrayCreates an Inline from an Element and Mark
Creates an inline that represents some text with marks
A node path is a list of indexes that represent the path from a node to a child. It's the main type used to identify where a node is in the editor.
Returns the parent path of the given path
parent [0, 1, 2]
--> [0, 1]Increments the last index in a node path if one exists.
increment [0, 1]
--> [0, 2]Decrements the last index in a node path if one exists.
decrement [0, 0]
--> [0, 0]String representation of a path.
toString [0, 0]
--> "0:0"Returns the common ancestor of the two paths.
commonAncestor [0, 1, 2] [0, 1, 4]
--> [0, 1]
A
Blockrepresents a block element in your document. A block can either have other block nodes as children, have all inline leaf nodes as children (e.g a text block), or be a leaf node.