A State consists of a root block and a selection. State allows you to keep track of and manipulate the contents of the editor.
A State consists of a root block and a selection. State allows you to keep track of and manipulate the contents of the editor.
state : RichText.Model.Node.Block -> Maybe RichText.Model.Selection.Selection -> State
Creates a State
. The arguments are as follows:
root
is a block node that represents the root of the editor.
selection
is a Maybe Selection
that is the selected part of the editor
root : Block
root =
block
(Element.element doc [])
(blockChildren <|
Array.fromList
[ block
(Element.element paragraph [])
(inlineChildren <| Array.fromList [ plainText "" ])
]
)
state root Nothing
--> an empty editor state with no selection
root : State -> RichText.Model.Node.Block
the root node from the state
selection : State -> Maybe RichText.Model.Selection.Selection
the selection from the state
withRoot : RichText.Model.Node.Block -> State -> State
a state with the given root
withSelection : Maybe RichText.Model.Selection.Selection -> State -> State
a state with the given selection