tianhongjie / ngx-diff

Angular 2+ component library for displaying diffs of text.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ngx-diff

Build Status

Angular 2+ component library for displaying diffs of text. Demo.

Quickstart

  1. Install ngx-diff modules from npm:

    npm install ngx-diff diff-match-patch-ts --save
    
  2. Import NgxDiffModule to your app:

    import { BrowserModule } from '@angular/platform-browser';
    import { NgModule } from '@angular/core';
    import { NgxDiffModule } from 'ngx-diff';
    import { AppComponent } from './app.component';
    
    @NgModule({
      declarations: [
        AppComponent
      ],
      imports: [
        BrowserModule,
        NgxDiffModule
      ],
      providers: [],
      bootstrap: [AppComponent]
    })
    export class AppModule { }
    
  3. Use the inline-diff component by setting the oldText and newText attributes:

    <inline-diff [oldText]="oldDocumentContents" [newText]="newDocumentContents" [lineContextSize]="4"></inline-diff>
    

Version history

Angular Version ngx-diff Version
9 0.2.0
10 0.3.0
11 0.4.0

Contributions welcome!

If you have a feature or improvement you would like to see included, please raise an issue or a PR and I will review.

License

See the LICENSE file for license rights and limitations (MIT).

About

Angular 2+ component library for displaying diffs of text.


Languages

Language:HTML 51.1%Language:TypeScript 43.0%Language:JavaScript 5.7%Language:SCSS 0.2%