Gathering detailed insights and metrics for ember-cli-clipboard
Gathering detailed insights and metrics for ember-cli-clipboard
Gathering detailed insights and metrics for ember-cli-clipboard
Gathering detailed insights and metrics for ember-cli-clipboard
A simple ember wrapper around clipboard.js
npm install ember-cli-clipboard
Module System
Unable to determine the module system for this package.
Min. Node Version
Typescript Support
Node Version
NPM Version
74 Stars
241 Commits
37 Forks
5 Watching
14 Branches
23 Contributors
Updated on 31 Oct 2024
Minified
Minified + Gzipped
JavaScript (69.02%)
Handlebars (17.76%)
SCSS (8.68%)
HTML (4.54%)
Cumulative downloads
Total Downloads
Last day
-37.9%
2,774
Compared to previous day
Last week
-17.1%
17,834
Compared to previous week
Last month
2.2%
87,328
Compared to previous month
Last year
-27.1%
1,234,374
Compared to previous year
8
1
51
A simple ember wrapper around clipboard.js (no flash)
http://jkusa.github.io/ember-cli-clipboard
1<!-- Set text directly --> 2<CopyButton 3 @text='text to be copied' 4 @onSuccess={{this.onSuccess}} 5 @onError={{this.onError}} 6> 7 Click To Copy 8</CopyButton> 9 10<!-- Get text from action that returns a string --> 11<CopyButton 12 @text={{this.getText}} 13 @onSuccess={{this.onSuccess}} 14 @onError={{this.onError}} 15> 16 Click To Copy 17</CopyButton> 18 19<!-- Get text from target element --> 20<input 21 id='url' 22 type='text' 23 value='https://github.com/jkusa/ember-cli-clipboard' 24/> 25<CopyButton 26 @target='#url' 27 @onSuccess={{this.onSuccess}} 28 @onError={{this.onError}} 29> 30 Click To Copy 31</CopyButton>
text
- string value or action that returns a string to be copiedtarget
- selector string of element or action that returns an element from which to copy textaction
- string value of operation: copy
or cut
(default is copy)container
- selector string or element object of containing element. "For use in Bootstrap Modals or with any other library that changes the focus you'll want to set the focused element as the container value".delegateClickEvent
- clipboard.js defaults event listeners to the body in order to reduce memory footprint if there are hundreds of event listeners on a page. If you want to scope the event listener to the copy button, set this property to false
buttonType
- string value of the button's type attribute (for Ember < 3.25.x
, see below)Any HTML button attribute passed to the component will be "splatted" on the button element. The one exception to this is the type
attribute due to this issue < Ember 3.25.x
.
The following clipboard.js custom events are sent as actions
onSuccess
sent on successful copyonError
sent on failed copyMore information about the clipboard.js events can be found here
Under the hood the <CopyButton>
component is powered by a {{clipboard}}
element modifier. This can be used directly as an alternative to the <CopyButton>
component. It has the same argument contract as the <CopyButton>
component except for the exclusion of the buttonType
argument.
1<button 2 class='button is-outline' 3 type='button' 4 {{clipboard text='text to be copied' onSuccess=this.onSuccess}} 5> 6 Click To Copy 7</button>
The helper is-clipboard-supported
can be used to check if clipboard.js is supported or not.
1{{#if (is-clipboard-supported)}} 2 <CopyButton @target='#url'> 3 Click To Copy 4 </CopyButton> 5{{/if}}
Some browsers do not allow simulated clicks to fire execCommand('copy')
. This makes testing difficult. To assist with integration testing, the following test helpers are available to test the wiring of the success
and error
action handlers.
triggerCopySuccess(selector='.copy-btn')
triggerCopyError(selector='.copy-btn')
1// tests/acceptance/my-test.js 2 3import { 4 triggerCopyError, 5 triggerCopySuccess, 6} from 'ember-cli-clipboard/test-support';
Example:
1// tests/acceptance/my-test.js 2 3test('copy button message', async function (assert) { 4 assert.expect(3); 5 6 await visit('/'); 7 assert.dom('.alert').doesNotExist('no alert message is initially present'); 8 9 triggerCopySuccess(); 10 11 assert 12 .dom('.alert.alert-success') 13 .exists('a success message is displayed when a copy is successful'); 14 15 triggerCopyError(); 16 17 assert 18 .dom('.alert.alert-info') 19 .exists('an error message is displayed when a copy is unsuccessful'); 20});
triggerCopySuccess(selector='.copy-btn')
triggerCopyError(selector='.copy-btn')
Example:
1// tests/integration/components/my-test.js 2 3// if using NEW ember testing api 4import { 5 triggerCopyError, 6 triggerCopySuccess, 7} from 'ember-cli-clipboard/test-support'; 8 9test('copy-button integration', async function (assert) { 10 assert.expect(2); 11 12 this.set('onSuccess', () => { 13 assert.ok(true, '`success` action handler correctly fired'); 14 }); 15 16 this.set('onError', () => { 17 assert.ok(true, '`error` action handler correctly fired'); 18 }); 19 20 await render(hbs` 21 <CopyButton 22 class="my-copy-btn" 23 @text="text to be copied" 24 @onSuccess={{this.onSuccess}} 25 @onError={{this.onError}} 26 > 27 Click To Copy 28 </CopyButton> 29 `); 30 31 //If using NEW ember testing api 32 triggerCopyError('.my-copy-btn'); 33 triggerCopySuccess('.my-copy-btn'); 34});
For browser support information, checkout the clipboard.js documentation:
https://github.com/zenorocha/clipboard.js/#browser-support
Contributions are welcomed. Please read the contributing guidelines.
This project is licensed under the MIT License.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
2 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 2
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
Reason
Found 2/11 approved changesets -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
17 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More