/elm-text-editor

A prototype of a pure Elm text editor, forked from work of Sydney Nemzer.

Primary LanguageElmBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

A Pure Elm Text Editor

This project, a text editor written in pure Elm, is a fork of work by Sydney Nemzer. His demo, inspired by prior work of Martin Janiczek, shows the feasibility of writing such a text editor and establishes an elegant and powerful foundation for future work. Many kudos to Sydney.

This forked repo adds scrolling, copy, cut, and paste, search and replace, text wrap, and an API for embedding the editor in another app. Here are some examples which make use of the present library.

  • Demo-simple

  • Demo This one implements external copy-paste: copy something somewhere with Cmd-C or whatever, then use ctrl-shift-V to paste it in the editor. At the moment, external copy-paste only works in Chrome.

  • Markdown Example The editor is hosted by an app that renders text written Markdown. The text may include mathematics written in TeX/LaTeX. The app features left-to-right sync: doing ctrl-shift-S in the editor window (Left) synchronizes the source text with the rendered text (Right). Still to do: right-to-left sync. And much more.

Running the examples

npm install

npm start

Embedding the Editor

  • Use the demo-simple and demo apps of this repo as models, or consult the Markdown Example Code
  • In order to implement external copy-paste (ctrl-shift V), the Demo and Markdown Example apps import a module Outside into Main. This module uses ports and references outside.js in index.html

Plans

  • I would very much like this to be a community project; it is a tool that many of us can use to good end. I've posted some issues on the repo, and welcome comments, pull requests, and more issues.

  • I may post a Road Map later, but Sydney Nemzer's README is an excellent place to begin.

Credits

I would like to thank Folkert de Vries for help improving the performance of the editor.