dkodaj/rte/1.1.3

NOTE: the latest version is 10.0.1

Mini-Rte

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

Demo

Limitations

It cannot justify text.

It gets increasingly slow for longer texts because of frequent trips to the DOM when calculating the cursor's position (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.

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'))                        
})