Skip to content

Releases: github/clipboard-copy-element

v1.0.4

09 Aug 08:09
99f91b7
Compare
Choose a tag to compare
  • Merge pull request #20 from github/publish-to-gpr-as-well ed91610
  • publish to GPR as a postpublish step 70ead12

v1.0.3...v1.0.4

1.0.4

09 Aug 08:09
ed91610
Compare
Choose a tag to compare

<clipboard-copy> element

Copy element text content or input values to the clipboard.

Installation

$ npm install --save @github/clipboard-copy-element

Usage

import '@github/clipboard-copy-element'
<clipboard-copy for="blob-path" class="btn btn-sm BtnGroup-item">
  Copy path
</clipboard-copy>
<div id="blob-path">src/index.js</div>

Data sources

Attribute

<clipboard-copy value="src/index.js">Copy</clipboard-copy>

Element content

<clipboard-copy for="blob-path">Copy</clipboard-copy>
<div id="blob-path">src/index.js</div>

Form input

<clipboard-copy for="blob-path">Copy</clipboard-copy>
<input id="blob-path" value="src/index.js">

Hyperlink href

<clipboard-copy for="blob-path">Copy full URL</clipboard-copy>
<a id="blob-path" href="/path/to#my-blob">Link text will not be copied</a>

Events

After copying to the clipboard, a clipboard-copy event is dispatched from
the <clipboard-copy> element:

document.addEventListener('clipboard-copy', function(event) {
  const button = event.target
  button.classList.add('highlight')
})

Browser support

Browsers without native custom element support require a polyfill.

  • Chrome
  • Firefox
  • Safari
  • Microsoft Edge

Development

npm install
npm test

License

Distributed under the MIT license. See LICENSE for details.

v1.0.3

30 Jul 09:22
4a5ce95
Compare
Choose a tag to compare
  • Merge pull request #19 from github/update-deps a5fb22f
  • run npm audit fix 0cc473a
  • update eslint-plugin-github, flow and karma-chrome-launcher to latest versions f3a5624
  • run npm update e3a96e4

v1.0.2...v1.0.3

v1.0.2

22 Jul 15:16
c68df8a
Compare
Choose a tag to compare
  • Merge pull request #17 from github/update-deps 3355875
  • update eslint, eslint-plugin-github and flow-bin manually to latest versions 186dbe6
  • run npm update 28f0ad6
  • update package name in README.md 003b465

v1.0.1...v1.0.2

v1.0.1

23 May 11:26
41fcc14
Compare
Choose a tag to compare

Package has been renamed to include the @github scope. You can now find it at https://www.npmjs.com/package/@github/clipboard-copy-element on npm.

v1.0.0...v1.0.1

v0.5.0

09 Jan 10:49
84d0fec
Compare
Choose a tag to compare
Merge pull request #6 from github/target-href

Support copying href of target anchor element