An element represents the parameters of any non-text node.
RichText.Internal.Definitions.Element
An Element
represents the parameters of non-text nodes. It consists of an element name,
a list of attributes, and a set of annotations.
element : RichText.Internal.Definitions.ElementDefinition -> List RichText.Model.Attribute.Attribute -> Element
Creates an element. The arguments are as follows:
The first argument is the ElementDefinition
that defines this element. Note that even though
elements require an element definition, it's still safe to use (==)
because the function arguments
are not stored on the resulting Element
.
The second argument is element's list of attributes.
element header [IntegerAttribute "level" 1]
--> creates a header (h1) element
annotations : Element -> Set String
Annotations from an element
annotations (element horizontal_rule [] (Set.singleton selectable))
--> Set [ selectable ]
attributes : Element -> List RichText.Model.Attribute.Attribute
Attributes from an element
attributes (element image [StringAttribute "src" "logo.svg"])
--> [StringAttribute "src" "logo.svg"]
name : Element -> String
Name from an element
name (element image [StringAttribute "src" "logo.svg"])
--> "image"
withAnnotations : Set String -> Element -> Element
An element with the annotations changed to the given set
element <| withAnnotations (Set.singleton selectable)
--> an element with the annotations changed to the singleton selectable set
withAttributes : List RichText.Model.Attribute.Attribute -> Element -> Element
An element with the attributes changed to the given list
element <| withAnnotations [StringAttribute "src" "logo.svg"]
--> an element with the attributes changed to the list provided