Skip to content

Add copy-example-to-clipboard button #6

Description

@morrisonlevi

Copying to the clipboard can be done in modern browsers with JavaScript's document.execCommand('copy', ...) which will copy the current selection. I'm not sure the way to feature detect support.

Essentially when a user clicks the button we need to highlight the code snippet and then copy it.

Activity

  1. Wes1262 commented on Nov 10, 2016

    @Wes1262
    Collaborator

    That used to work only in designMode/contenteditable and only if browsers were set explicitly to allow so. But just recently I read that there is a new API somewhere that doesn't require adobe flash to copy to clipboard. Though, i think it's huge effort for a very little improvement (Ctrl+C or Context>Copy isn't hard work :D) but i'll check what we can do and if we can do it easily.

  2. morrisonlevi commented on Nov 17, 2016

    @morrisonlevi
    OwnerAuthor
  3. philip commented on Dec 14, 2016

    @philip

    Idea from the audience: I wonder about using https://clipboardjs.com/ as it's well-tested and small. I've used it in the past with great success.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions