dkodaj/rte/9.0.8

NOTE: the latest version is 10.0.1

MiniRte.Types

type Msg
= CharacterLimitReached Int
| FromBrowserClipboard String
| Internal InternalMsg
| ToBrowserClipboard String

CharacterLimitReached int -- get notified if too much text is entered | FromBrowserClipboard String -- see package description | Internal msg -- not part of the API | ToBrowserClipboard String

= 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 : Int
, highlightStyling : List ( String, String )
, indent : Int
, nodeType : Maybe String
, styling : List ( String, String )
}
type Child
= Child EmbeddedHtmlRecord
type alias FontStyle =
{ classes : List String
, fontFamily : List String
, fontSize : Maybe Float
, styling : List ( String, String )
}