jxxcarlson / elm-editor / 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 : EditorModel.Config -> ( Editor, Platform.Cmd.Cmd EditorMsg.EMsg )

Initialize the editor with a configuration

initWithContent : String -> EditorModel.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 : Basics.Float -> Basics.Float -> Editor -> Editor

Resize the editor

sendLine : Editor -> ( Editor, Platform.Cmd.Cmd EditorMsg.EMsg )

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

syncMessages : List EditorMsg.EMsg

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

Using the editor


type alias EditorMsg =
EditorMsg.EMsg

The messages to which the editor responds

getLines : Editor -> Array String

Get the current editor content

getContextMenu : Editor -> ContextMenu EditorMsg.Context

Get the context menu

update : EditorMsg.EMsg -> Editor -> ( Editor, Platform.Cmd.Cmd EditorMsg.EMsg )

Update the editor with a message

view : Editor -> Html EditorMsg.EMsg

View function for the editor

Cursor

insertAtCursor : String -> Editor -> Editor

Insert a string into the editor at a given cursor location

lineAtCursor : Editor -> String

Return the line where the cursor is

getCursor : Editor -> { line : Basics.Int, column : Basics.Int }

setCursor : { line : Basics.Int, column : Basics.Int } -> Editor -> Editor

Set the editor's cursor to a given position

Clipboard

placeInClipboard : String -> Editor -> Editor

Place string in the editor's clipboard

Getting data from the editor

getContent : Editor -> String

Retrieve text from editor

getLineHeight : Editor -> Basics.Float

getSelectedString : Editor -> Maybe String

getWrapOption : Editor -> EditorMsg.WrapOption

indexOf : Editor -> String -> List Basics.Int

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