dkodaj/rte/5.0.1

NOTE: the latest version is 10.0.1

Mini-Rte

Pure Elm rich text editor for relatively short texts (< 2000 words / 12K characters). It supports non-Western keyboard input via CompositionEvent.

Demo

Limitations

It cannot justify text.

It gets sluggish for longer texts (discussion on Elm-Discourse). If you need better performance, use mweiss/elm-rte-toolkit.

Javascript

To communicate with the browser's clipboard (to be able to copy text from the RTE to other apps and paste text from other apps into the RTE), you'll need to add two ports to your app:

--from JavaScript to Elm

port fromBrowserClipboard : (String -> msg) -> Sub msg

--from Elm to JavaScript

port toBrowserClipboard : String -> Cmd msg

These ports belong in your subscriptions and update functions. See the example's Main.elm.

You will also need a bit of JS:

app.ports.toBrowserClipboard.subscribe(txt => {
    navigator.clipboard.writeText(txt).then(function() {
        // Copied from app to clipboard
    }, function(err) {
        console.log(err)
    });
});

window.addEventListener('paste', (event) => {            
    app.ports.fromBrowserClipboard.send(event.clipboardData.getData('text'))                        
})

You can use a more complicated callback to allow copy/pasting images into the RTE. See the example's index.html.