rupertlssmith / rte-toolkit-patch / RichText.Model.State

A State consists of a root block and a selection. State allows you to keep track of and manipulate the contents of the editor.


type State

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 : 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