mweiss/elm-rte-toolkit/1.0.2

NOTE: the latest version is 1.0.4

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

the root node from the state

the selection from the state

a state with the given root

a state with the given selection