I’m working on a basic text editor implemented in Elm (need it for elm-browser for ElmEurope), and felt like sharing here.
A live demo:
So far there’s support for:
- basic writing / deleting
- arrows movement
- mouse movement (by clicking)
- selection (by mouse)
Yet to do (but no promises):
- text insertion after selection should replace the text (doesn’t)
- context menu on rightclick?
- cut / copy / paste
Basically I don’t delegate anything to textareas etc. - I’m listening to events and rendering everything myself, so there’s total control over what the user is doing (selection etc.)
A thing to note is the “throw random
update and see if things break” test suite, I’m quite proud of the tests and they’ve been very useful (found quite a number of bugs) https://github.com/Janiczek/elm-editor/blob/master/tests/CodeEditor.elm
I hope this inspires somebody to try do some stuff in Elm they’ve been needing but seemed too big / hard for them! You might, like me with this project, find out it’s in your reach - no doubt thanks to Elm