1 | <div align="center" style="text-align: center;">
|
2 | <h1 style="border-bottom: none;">@reallyland/really-clipboard-copy</h1>
|
3 |
|
4 | <p>Copy content to clipboard</p>
|
5 | </div>
|
6 |
|
7 | <hr />
|
8 |
|
9 | <a href="https://www.buymeacoffee.com/RLmMhgXFb" target="_blank" rel="noopener noreferrer"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 20px !important;width: auto !important;" ></a>
|
10 | [![tippin.me][tippin-me-badge]][tippin-me-url]
|
11 | [![Follow me][follow-me-badge]][follow-me-url]
|
12 |
|
13 | [![Version][version-badge]][version-url]
|
14 | [![lit-element][lit-element-version-badge]][lit-element-url]
|
15 | [![Node version][node-version-badge]][node-version-url]
|
16 | [![MIT License][mit-license-badge]][mit-license-url]
|
17 |
|
18 | [![Downloads][downloads-badge]][downloads-url]
|
19 | [![Total downloads][total-downloads-badge]][downloads-url]
|
20 | [![Packagephobia][packagephobia-badge]][packagephobia-url]
|
21 | [![Bundlephobia][bundlephobia-badge]][bundlephobia-url]
|
22 |
|
23 | [![CircleCI][circleci-badge]][circleci-url]
|
24 | [![Dependency Status][daviddm-badge]][daviddm-url]
|
25 |
|
26 | [![codebeat badge][codebeat-badge]][codebeat-url]
|
27 | [![Codacy Badge][codacy-badge]][codacy-url]
|
28 | [![Code of Conduct][coc-badge]][coc-url]
|
29 |
|
30 | > Better element for the web
|
31 |
|
32 | ## Table of contents <!-- omit in toc -->
|
33 |
|
34 | - [Pre-requisites](#pre-requisites)
|
35 | - [Installation](#installation)
|
36 | - [Usage](#usage)
|
37 | - [Browser compatibility](#browser-compatibility)
|
38 | - [API references](#api-references)
|
39 | - [Demo](#demo)
|
40 | - [License](#license)
|
41 |
|
42 | ## Pre-requisites
|
43 |
|
44 | - [Java 8][java-url] _(`web-component-tester` works without any issue with Java 8)_
|
45 | - [Node.js][nodejs-url] >= 8.16.0
|
46 | - [NPM][npm-url] >= 6.4.1 ([NPM][npm-url] comes with [Node.js][nodejs-url], no separate installation is required.)
|
47 | - (Optional for non-[VS Code][vscode-url] users) [Syntax Highlighting for lit-html in VS Code][vscode-lit-html-url]
|
48 | - [web-component-tester][web-component-tester-url] >= 6.9.2 (For running tests, it's recommended to install globally on your system due to its insanely huge install size by running `npm i -g web-component-tester`.)
|
49 |
|
50 | ## Installation
|
51 |
|
52 | ```sh
|
53 | # Install via NPM
|
54 | $ npm install @reallyland/really-clipboard-copy
|
55 | ```
|
56 |
|
57 | ## Usage
|
58 |
|
59 | **index.html**
|
60 |
|
61 | ```html
|
62 | <html>
|
63 | <head>
|
64 | <script type="module">
|
65 | import 'https://unpkg.com/@reallyland/really-clipboard-copy@latest/dist/really-clipboard-copy.js?module';
|
66 |
|
67 | const asyncCopyEl = document.body.querySelector('.async-copy');
|
68 | const syncCopyEl = document.body.querySelector('.sync-copy');
|
69 |
|
70 | asyncCopyEl.addEventListener('copy-success', (ev) => {
|
71 | const { value } = ev.detail || {};
|
72 | console.log(`Copied value is ${value}`);
|
73 | });
|
74 | asyncCopyEl.addEventListener('copy-error', (ev) => {
|
75 | const { reason } = ev.detail || {};
|
76 | console.error(reason);
|
77 | });
|
78 |
|
79 | syncCopyEl.addEventListener('copy-success', (ev) => {
|
80 | const { value } = ev.detail || {};
|
81 | console.log(`Copied value is ${value}`);
|
82 | });
|
83 | syncCopyEl.addEventListener('copy-error', (ev) => {
|
84 | const { reason } = ev.detail || {};
|
85 | console.error(reason);
|
86 | });
|
87 | </script>
|
88 | </head>
|
89 |
|
90 | <body>
|
91 | <h2>Copy input text using Async Clipboard API if supported</h2>
|
92 | <really-clipboard-copy class="async-copy">
|
93 | <input copy-id="copiable" type="text" readonly value="Hello, World!" />
|
94 | <button copy-for="copiable">Copy</button>
|
95 | </really-clipboard-copy>
|
96 |
|
97 | <h2>Copy input text only using document.execCommand('copy')</h2>
|
98 | <really-clipboard-copy class="sync-copy" sync>
|
99 | <input copy-id="copiable" type="text" readonly value="Hello, World!" />
|
100 | <button copy-for="copiable">Copy</button>
|
101 | </really-clipboard-copy>
|
102 | </body>
|
103 | </html>
|
104 | ```
|
105 |
|
106 | ## Browser compatibility
|
107 |
|
108 | `really-clipboard-copy` works in all major browsers (Chrome, Firefox, IE, Edge, Safari, and Opera).
|
109 |
|
110 | [Heavily tested](/.circleci/config.yml) on the following browsers:
|
111 |
|
112 | | Name | OS |
|
113 | | --- | --- |
|
114 | | Internet Explorer 11 | Windows 7 |
|
115 | | Edge 13 | Windows 10 |
|
116 | | Edge 17 | Windows 10 |
|
117 | | Safari 9 | Mac OS X 10.11 |
|
118 | | Safari 10.1 | Mac OS 10.12 |
|
119 | | Chrome 41 ([WRE][wre-url]) | Linux |
|
120 | | Chrome 69 ([WRE 2019][wre-2019-url]) | Windows 10 |
|
121 | | Firefox 62 (w/o native Shadow DOM) | macOS Mojave (10.14) |
|
122 | | Firefox 63 (native Shadow DOM support) | Windows 10 |
|
123 |
|
124 | ## API references
|
125 |
|
126 | - [ReallyClipboardCopy]
|
127 |
|
128 | ## Demo
|
129 |
|
130 | [Demo@StackBlitz]
|
131 |
|
132 | ## License
|
133 |
|
134 | [MIT License](https://motss.mit-license.org/) © Rong Sen Ng (motss)
|
135 |
|
136 |
|
137 | [typescript-url]: https://github.com/Microsoft/TypeScript
|
138 | [java-url]: https://www.java.com/en/download
|
139 | [nodejs-url]: https://nodejs.org
|
140 | [npm-url]: https://www.npmjs.com
|
141 | [lit-element-url]: https://github.com/Polymer/lit-element?utm_source=github.com&utm_medium=referral&utm_content=motss/app-datepicker
|
142 | [node-releases-url]: https://nodejs.org/en/download/releases
|
143 | [vscode-url]: https://code.visualstudio.com
|
144 | [vscode-lit-html-url]: https://github.com/mjbvz/vscode-lit-html
|
145 | [web-component-tester-url]: https://github.com/Polymer/tools/tree/master/packages/web-component-tester
|
146 | [wre-url]: https://developers.google.com/search/docs/guides/rendering
|
147 | [wre-2019-url]: https://www.deepcrawl.com/blog/news/what-version-of-chrome-is-google-actually-using-for-rendering
|
148 | [ReallyClipboardCopy]: /api-references.md#reallyclipboardcopy
|
149 | [Demo@StackBlitz]: https://really-clipboard-copy.stackblitz.io
|
150 |
|
151 |
|
152 | [array-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
|
153 | [boolean-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
154 | [function-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function
|
155 | [map-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
|
156 | [number-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number
|
157 | [object-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object
|
158 | [promise-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
159 | [regexp-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
|
160 | [set-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
161 | [string-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
|
162 |
|
163 |
|
164 | [tippin-me-badge]: https://badgen.net/badge/%E2%9A%A1%EF%B8%8Ftippin.me/@igarshmyb/F0918E
|
165 | [follow-me-badge]: https://flat.badgen.net/twitter/follow/igarshmyb?icon=twitter
|
166 |
|
167 | [version-badge]: https://flat.badgen.net/npm/v/@reallyland/really-clipboard-copy?icon=npm
|
168 | [lit-element-version-badge]: https://flat.badgen.net/npm/v/lit-element/latest?icon=npm&label=lit-element
|
169 | [node-version-badge]: https://flat.badgen.net/npm/node/@reallyland/really-clipboard-copy
|
170 | [mit-license-badge]: https://flat.badgen.net/npm/license/@reallyland/really-clipboard-copy
|
171 |
|
172 | [downloads-badge]: https://flat.badgen.net/npm/dm/@reallyland/really-clipboard-copy
|
173 | [total-downloads-badge]: https://flat.badgen.net/npm/dt/@reallyland/really-clipboard-copy?label=total%20downloads
|
174 | [packagephobia-badge]: https://flat.badgen.net/packagephobia/install/@reallyland/really-clipboard-copy
|
175 | [bundlephobia-badge]: https://flat.badgen.net/bundlephobia/minzip/@reallyland/really-clipboard-copy
|
176 |
|
177 | [circleci-badge]: https://flat.badgen.net/circleci/github/reallyland/really-clipboard-copy?icon=circleci
|
178 | [daviddm-badge]: https://flat.badgen.net/david/dep/reallyland/really-clipboard-copy
|
179 |
|
180 | [codebeat-badge]: https://codebeat.co/badges/e363cf9f-88d5-4118-8190-364c7691a6e8
|
181 | [codacy-badge]: https://api.codacy.com/project/badge/Grade/e02c3d95e6274493a66ae02c604de252
|
182 | [coc-badge]: https://flat.badgen.net/badge/code%20of/conduct/pink
|
183 |
|
184 |
|
185 | [tippin-me-url]: https://tippin.me/@igarshmyb
|
186 | [follow-me-url]: https://twitter.com/igarshmyb?utm_source=github.com&utm_medium=referral&utm_content=@reallyland/really-clipboard-copy
|
187 |
|
188 | [version-url]: https://www.npmjs.com/package/@reallyland/really-clipboard-copy/v/latest?utm_source=github.com&utm_medium=referral&utm_content=@reallyland/really-clipboard-copy
|
189 | [node-version-url]: https://nodejs.org/en/download?utm_source=github.com&utm_medium=referral&utm_content=@reallyland/really-clipboard-copy
|
190 | [mit-license-url]: https://github.com/reallyland/really-clipboard-copy/blob/master/LICENSE?utm_source=github.com&utm_medium=referral&utm_content=@reallyland/really-clipboard-copy
|
191 |
|
192 | [downloads-url]: https://www.npmtrends.com/@reallyland/really-clipboard-copy
|
193 | [packagephobia-url]: https://packagephobia.now.sh/result?p=%40reallyland%2Freally-clipboard-copy
|
194 | [bundlephobia-url]: https://bundlephobia.com/result?p=@reallyland/really-clipboard-copy
|
195 |
|
196 | [circleci-url]: https://circleci.com/gh/reallyland/really-clipboard-copy/tree/master?utm_source=github.com&utm_medium=referral&utm_content=@reallyland/really-clipboard-copy
|
197 | [daviddm-url]: https://david-dm.org/reallyland/really-clipboard-copy?utm_source=github.com&utm_medium=referral&utm_content=@reallyland/really-clipboard-copy
|
198 |
|
199 | [codebeat-url]: https://codebeat.co/projects/github-com-reallyland-really-clipboard-copy-master
|
200 | [codacy-url]: https://www.codacy.com/app/motss/really-clipboard-copy?utm_source=github.com&utm_medium=referral&utm_content=reallyland/really-clipboard-copy&utm_campaign=Badge_Grade
|
201 | [coc-url]: https://github.com/reallyland/really-clipboard-copy/blob/master/code-of-conduct.md
|