jxxcarlson/elm-editor/3.1.2

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 EditorModel

Opaque type for the editor

init : Config -> ( Editor, Cmd EMsg )

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 EMsg )

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

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

Using the editor

type alias EditorMsg =

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 : EMsg -> Editor -> ( Editor, Cmd EMsg )

Update the editor with a message

view : Editor -> Html EMsg

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
indexOf : Editor -> String -> List Int

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