elm / browser

Create Elm programs that run in browsers!
https://package.elm-lang.org/packages/elm/browser/latest/
BSD 3-Clause "New" or "Revised" License
313 stars 64 forks source link

Selection API support #110

Open mweiss opened 4 years ago

mweiss commented 4 years ago

Currently, there's no way of handling the selection API directly Elm. The way I've worked around this was by creating a webcomponent to track the current selection state, and using custom events to notify Elm of how the state has changed. I also used relative paths in the HTML to distinguish which elements were selected, and a custom Node type separate from the opaque Html/VirtualDom.Node type referenced in the Html module to resolve the selection. https://github.com/mweiss/elm-rte-toolkit/blob/1.0.1/js/elmEditor.js#L142

It would be nice if there were some way of keeping track of this in Elm directly without requiring a webcomponent, either with a global selection API in browser package that would keep track of this information, or with some limited support in Html.Events for a selection event that would give the selection state relative to the element.

On the discourse, there was a similar proposal a few years ago: https://discourse.elm-lang.org/t/selection-api-for-elm/1351