Gathering detailed insights and metrics for ngx-diff2html
Gathering detailed insights and metrics for ngx-diff2html
Gathering detailed insights and metrics for ngx-diff2html
Gathering detailed insights and metrics for ngx-diff2html
npm install ngx-diff2html
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
5 Stars
106 Commits
6 Forks
3 Watching
15 Branches
2 Contributors
Updated on 19 Aug 2024
TypeScript (72.58%)
JavaScript (13.44%)
HTML (10.41%)
CSS (3.58%)
Cumulative downloads
Total Downloads
Last day
64.8%
89
Compared to previous day
Last week
112.1%
492
Compared to previous week
Last month
-39%
1,577
Compared to previous month
Last year
284.3%
19,719
Compared to previous year
4
2
A simple text diff component for Angular, based on diff-match-patch & diff2html.
npm install --save ngx-diff2html
1. Register the NgxDiff2htmlModule
in a module, for example app module:
1 import { BrowserModule } from '@angular/platform-browser'; 2 import { NgModule } from '@angular/core'; 3 4 import { AppComponent } from './app.component'; 5+ import { NgxDiff2htmlModule } from 'ngx-diff2html'; 6 7 @NgModule({ 8 declarations: [AppComponent], 9 imports: [ 10 BrowserModule, 11+ NgxDiff2htmlModule 12 ], 13 providers: [], 14 bootstrap: [AppComponent] 15 }) 16 export class AppModule {}
2. Import diff2html css in styles.css
:
1 /* You can add global styles to this file, and also import other style files */ 2+ @import "~diff2html/bundles/css/diff2html.min.css";
3. You may also need to add the following lines to polyfills.ts
:
1 // Add global to window, assigning the value of window itself. 2+ (window as any).global = window; 3+ (window as any).process = { env: { DEBUG: undefined } };
4. Start using the component:
1<ngx-diff2html 2 left="some text" 3 right="some other text" 4></ngx-diff2html>
NgxDiff2htmlModule
NgxDiff2htmlService
NgxDiff2htmlComponent
ngx-diff2html
Input | Type | Required | Description |
---|---|---|---|
left | string | Yes | First text to be compared |
right | string | Yes | Second text to be compared |
filename | string | Optional, default: '' (empty) | Can be used to display a filename at the top of diff results |
format | DiffFormat | Optional, default: side-by-side | Possible values: - side-by-side - line-by-line |
style | DiffStyle | Optional, default: word | Possible values: - word - char |
showContext | boolean | Optional, default: false | Enable to show context lines |
Output | Type | Required | Description |
---|---|---|---|
diffChange | string | Optional | Event fired when diff changes. Returns text diff in unified format |
NgxDiff2htmlService.getDiff(text1, text2, filename)
Get text diff between text1
& text2
in unified format.
Returns:
string
diffNgxDiff2htmlService.diffToHTML(diff, format, style)
Convert unified diff string to HTML using diff2html.
Returns:
string
HTML diff1import { Component } from '@angular/core'; 2import { NgxDiff2htmlService } from 'ngx-diff2html'; 3 4@Component({ 5 selector: 'app-root', 6 template: `<div [innerHtml]="diffHTML"></div>`, 7 styles: [], 8 providers: [ 9 NgxDiff2htmlService 10 ] 11}) 12export class AppComponent { 13 14 diffHTML: string = null; 15 16 constructor(private diffService: NgxDiff2htmlService) { 17 const diff = this.diffService.getDiff('first text', 'second text'); 18 this.diffHTML = this.diffService.diffToHTML(diff); 19 } 20 21}
Run ng build ngx-diff2html
to build the project. The build artifacts will be stored in the dist/
directory.
After building your library with ng build ngx-diff2html
, go to the dist folder cd dist/ngx-diff2html
and run npm publish
.
This project is licensed under the MIT license.
No vulnerabilities found.
Reason
all changesets reviewed
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
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
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
79 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