Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Copy element text content or input values to the clipboard.

License

NotificationsYou must be signed in to change notification settings

github/clipboard-copy-element

Copy element text content or input values to the clipboard.

Installation

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

Usage

Script

Import as ES modules:

import'@github/clipboard-copy-element'

With a script tag:

<scripttype="module"src="./node_modules/@github/clipboard-copy-element/dist/index.js">

Markup

<clipboard-copyfor="blob-path"class="btn btn-sm BtnGroup-item">  Copy path</clipboard-copy><divid="blob-path">src/index.js</div>

Data sources

Attribute

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

Element content

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

Form input

<clipboard-copyfor="blob-path">Copy</clipboard-copy><inputid="blob-path"value="src/index.js">

Hyperlink href

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

Events

After copying to the clipboard, aclipboard-copy event is dispatched fromthe<clipboard-copy> element:

document.addEventListener('clipboard-copy',function(event){constbutton=event.targetbutton.classList.add('highlight')})

Browser support

Browsers without nativecustom element support require apolyfill.

  • Chrome
  • Firefox
  • Safari
  • Microsoft Edge

Development

npm installnpm test

License

Distributed under the MIT license. See LICENSE for details.

About

Copy element text content or input values to the clipboard.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors26


[8]ページ先頭

©2009-2025 Movatter.jp