Last active
May 20, 2016 10:32
-
-
Save olemak/8ed80c649ba81afa91aa516e5692c6cb to your computer and use it in GitHub Desktop.
Adds a copy button after the tags you define (like code or pre). Clicking the button copies the preceeding element/tag text content to the OS clipboard.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated:
The first version was in EcmaScript 2015, so I figured it was a good idea to transpile it before sharing :)
Also added arguments, so rather than changing settings inside the function, it now accepts arguments.
And now that it accepts arguments, it needed to vet those arguments, so there are now tests for each of the arguments!
The two arguments are:
1: container - A DOM element. Limits the part of the document that the function affects. Default is the body node.
2: tags - An array of tag names that determines what element types (inside "container") that will receive copy buttons. Default is ['pre','code','blockquote'].