jxxcarlson/elm-editor/1.0.1

NOTE: the latest version is 3.1.3

Editor

Use the Editor module to embed a pure Elm text editor into another application. See ./demo in the source code for an example.

Setting up the editor

type Editor
= Editor Model

Opaque type for the editor

init : Config -> ( Editor, Cmd Msg )

Initialize the editor with a configuration

initWithContent : String -> Config -> Editor

-Initialize the the editor with given content : String

loadArray : Array String -> Editor -> Editor

Load content into the editor

loadString : String -> Editor -> Editor

Load a string into the editor

resize : Float -> Float -> Editor -> Editor

Resize the editor

sendLine : Editor -> ( Editor, Cmd Msg )

Used by a host app to scroll the editor to scroll the editor display to the line where the cursor is.

syncMessages : List Msg

Messages to be handles by a host app in some default way

Using the editor

type alias EditorMsg =
Msg

The messages to which the editor responds

getLines : Editor -> Array String

Get the current editor content

getContextMenu : Editor -> ContextMenu Context

Get the context menu

update : Msg -> Editor -> ( Editor, Cmd Msg )

Update the editor with a message

view : Editor -> Html Msg

View function for the editor

Cursor

Insert a string into the editor at a given cursor location

lineAtCursor : Editor -> String

Return the line where the cursor is

-> { line : Int
, column : Int
}
{ line : Int
, column : Int
}
-> Editor
-> Editor

Set the editor's cursor to a given position

Clipboard

Place string in the editor's clipboard

Getting data from the editor

getContent : Editor -> String

Retrieve text from editor

getSelectedString : Editor -> Maybe String
getWrapOption : Editor -> WrapOption
indexOf : Editor -> String -> Maybe ( Int, String )

Return (lineNumber, target) where target in the editor's array of lines is a string which matches the key