Skip to content

Clipboard API support #109

Open
Open
@mweiss

Description

@mweiss

Some clipboard functions require synchronous access to methods, like on the copy event using clipboardData.setData or the paste event and clipboardData.getData. If I handle the copy event in Elm and use a port from Elm to JS, it won't be handled synchronously by js. If I handle the copy event in a custom element in js, I run into the same issue trying to get the data back to JS (e.g. there's no two way synchronization technique that I know of). I think one workaround to this would be to add clipboard API support to the Browser.Events module and/or add specialized onCopy and onPaste functions to Html.Events module.

Note that one workaround for getting clipboard data on the paste event was to use a custom element to listen to the event, then using a custom event with the types of data I wanted (e.g. clipboardData.getData('text/html')), dispatching that, and then handling the event in Elm. You can see it here: https://github.com/mweiss/elm-rte-toolkit/blob/1.0.1/js/elmEditor.js#L303

However, I do not know of a corresponding solution to clipboardData.setData.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions