This module contains functions to validate and reduce editor state. These methods are used every time a command is applied.
Validates the state against the spec and returns the valid state if everything is okay, otherwise returns a comma separated string of error messages.
example : State
example =
state
(block
(Element.element doc [])
(blockChildren <|
Array.fromList
[ block
(Element.element paragraph [])
(inlineChildren <| Array.fromList [ plainText "text" ])
]
)
)
(Just <| caret [ 0, 0 ] 2)
(Ok example) == (validate markdown example)
--> TrueJust the selection translation function that gets called in reduce. Note that this is really only
useful if you're creating transforms that merge or remove inline nodes and you can't find a way
to easily figure out the new selection state.
Reduces the state with the following rules: