Gathering detailed insights and metrics for ngx-clipboard
Gathering detailed insights and metrics for ngx-clipboard
Gathering detailed insights and metrics for ngx-clipboard
Gathering detailed insights and metrics for ngx-clipboard
npm install ngx-clipboard
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
505 Stars
426 Commits
93 Forks
8 Watching
19 Branches
31 Contributors
Updated on 22 Oct 2024
Minified
Minified + Gzipped
TypeScript (82.41%)
JavaScript (7.28%)
HTML (6.92%)
CSS (3.23%)
Shell (0.15%)
Cumulative downloads
Total Downloads
Last day
-11.7%
25,714
Compared to previous day
Last week
-3.1%
144,481
Compared to previous week
Last month
10.4%
644,788
Compared to previous month
Last year
4.1%
6,949,856
Compared to previous year
2
2
From 6.0.0, there is no other JS dependency anymore. Just Angular.
It works with angular version 2.0.0 and up
To make more sense with the future versioning scheme of Angular, the directive selector is now rename to ngxClipboard
The code are pretty much the same, in v8.0.0 it uses InjectionToken which requires angular4 and above.
You can get it on npm.
1npm install ngx-clipboard --save
Open your module file e.g app.module.ts
and update imports array
1import { ClipboardModule } from 'ngx-clipboard'; 2... 3imports: [ 4... 5 ClipboardModule, 6... 7]
If you use SystemJS to load your files, you might have to update your config:
1System.config({ 2 map: { 3 'ngx-clipboard': 'node_modules/ngx-clipboard' 4 } 5});
This library support multiple kinds of copy source.
cbContent
attribute1<button ngxClipboard [cbContent]="'target string'">Copy</button>
You can assign the parent container to avoid focus trapper issue, #145
1<div #container> 2 <button ngxClipboard [cbContent]="'target string'" [container]="container">Copy</button> 3</div>
1.... 2 3<input type="text" #inputTarget /> 4 5<button [ngxClipboard]="inputTarget">Copy</button>
copy
from ClipboardService
to copy any text you dynamically created.1import { ClipboardService } from 'ngx-clipboard' 2 3... 4 5constructor(private _clipboardService: ClipboardService){ 6... 7} 8 9copy(text: string){ 10 this._clipboardService.copy(text) 11}
cbOnSuccess
callback attribute is triggered after copy was successful with $event: {isSuccess: true, content: string}
1<button (cbOnSuccess)="copied($event)" [cbContent]="'example string'">Copied</button>
Or updating parameters directly like so
1<button (cbOnSuccess)="isCopied = true" [cbContent]="'example string'">Copied</button>
cbOnError
callback attribute is triggered when there's failure in copying with $event:{isSuccess: false}
You can also use the structural directive *ngxClipboardIfSupported to conditionally render the host element
1<button ngxClipboard *ngxClipboardIfSupported [cbContent]="'target string'" (cbOnSuccess)="isCopied = true"> 2 Copy 3</button>
Special thanks to @surajpoddar16 for implementing this feature
To handle copy response globally, you can subscribe to copyResponse$
exposed by the ClipboardService
export class ClipboardResponseService {
constructor(
private _clipboardService: ClipboardService,
private _toasterService: ToasterService
) {
this.handleClipboardResponse();
}
handleClipboardResponse() {
this._clipboardService.copyResponse$.subscribe((res: IClipboardResponse) => {
if (res.isSuccess) {
this._toasterService.pop('success', undefined, res.successMessage);
}
});
}
}
Special thanks to @surajpoddar16 for implementing this feature
This library creates a textarea element at the root of the body for its internal use. By default it only destroys it when the directive is destroyed. If you'd like it to be destroyed after each copy to clipboard, provide root level module configuration like this:
1ClipboardService.configure({ cleanUpAfterCopy: true });
Special thanks to @DmitryEfimenko for implementing this feature
1npm i && npm run build
To run demo code locally
npm run start
Please ask your general questions at https://stackoverflow.com/questions/tagged/ngx-clipboard
Kudos to
Thierry Templier This project is inspired by his answer on StackOverflow.
The core function is ported from clipboard.js by @zenorocha.
This project was generated with Angular CLI version 7.
Big thanks to BrowserStack for letting the maintainers use their service to debug browser issues.
This project exists thanks to all the people who contribute. [Contribute].
Become a financial contributor and help us sustain our community. [Contribute]
Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
4 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 4
Reason
Found 5/12 approved changesets -- score normalized to 4
Reason
9 existing vulnerabilities detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
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
Score
Last Scanned on 2024-11-18
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