dkodaj / rte / MiniRte.Types


type Msg
    = CharacterLimitReached Basics.Int
    | FromBrowserClipboard String
    | Internal MiniRte.TypesThatAreNotPublic.InternalMsg
    | ToBrowserClipboard String

CharacterLimitReached allows you to get notified if too much text is entered.

FromBrowserClipboard and ToBrowserClipboard can be used to handle copy/pasting text from the RTE to other apps and vice versa. See the example.

InternalMsg is not part of the API.


type TextAlignType
    = Center
    | Left
    | Right

Writing highlighters

A highlighter is a Content -> Content function that you can inject into the model using setHighlighter. The function should modify the highlightClasses, highlightIndent, or highlightStyling fields of the elements. Each string x in highlightClasses turns into Html.(Styled.)Attribute.class x. Each (x,y) in highlightStyling turns into Html.(Styled.)Attribute.style x y. Attributes of LineBreaks apply to the paragraph (the previous non-linebreak elements) as a whole.


type alias Content =
Array Element


type Element
    = Character CharacterRecord
    | EmbeddedHtml EmbeddedHtmlRecord
    | LineBreak LineBreakRecord


type alias CharacterRecord =
{ char : Char
, fontStyle : FontStyle
, highlightClasses : List String
, highlightStyling : List ( String
, String )
, link : Maybe String 
}


type alias EmbeddedHtmlRecord =
{ attributes : List ( String
, String )
, classes : List String
, children : List Child
, highlightClasses : List String
, highlightStyling : List ( String
, String )
, nodeType : Maybe String
, styling : List ( String
, String )
, text : Maybe String 
}

You can embed any html node using this type. The RTE will only be able to delete or copy/paste these elements.

emptyEmbeddedHtml : EmbeddedHtmlRecord

An empty div.


type alias LineBreakRecord =
{ classes : List String
, highlightClasses : List String
, highlightIndent : Basics.Int
, highlightStyling : List ( String
, String )
, id : String
, indent : Basics.Int
, nodeType : Maybe String
, styling : List ( String
, String )
, textAlign : TextAlignType 
}


type Child
    = Child EmbeddedHtmlRecord


type alias FontStyle =
{ classes : List String
, fontFamily : List String
, fontSize : Maybe Basics.Float
, styling : List ( String
, String ) 
}