mweiss/elm-rte-toolkit/1.0.4

RichText.Config.Spec

A spec describes what nodes and marks can be in an editor.

type Spec

A spec describes what nodes and marks can be in an editor. It's used internally to encode an editor to html, and to transform html to editor nodes. Note for the latter, the order of nodes and marks is significant, because that is the order in which each node and mark's decoder method is applied.

simpleSpec : Spec
simpleSpec =
    emptySpec
        |> withElementDefinitions
            [ codeBlock
            , crazyBlock
            , paragraph
            , image
            ]
        |> withMarkDefinitions
            [ bold
            , italic
            ]

An empty spec

markDefinitions : Spec -> List MarkDefinition

list of MarkDefinition from a spec

markDefinition : String -> Spec -> Maybe MarkDefinition

Returns the mark definition with the given name from a spec.

markDefinition "bold" markdown
--> Just (bold mark definition)
elementDefinitions : Spec -> List ElementDefinition

list of ElementDefinition from a spec

elementDefinition : String -> Spec -> Maybe ElementDefinition

Returns the element definition with the given name from a spec.

elementDefinition "paragraph" markdown
--> Just (paragraph element definition)
withMarkDefinitions : List MarkDefinition -> Spec -> Spec

a spec with the given mark definitions

withElementDefinitions : List ElementDefinition -> Spec -> Spec

a spec with the given element definitions