Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ngx-text-diff

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-text-diff

A Text Diff component for Angular.

  • 0.5.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.7K
decreased by-25.8%
Maintainers
1
Weekly downloads
 
Created
Source

ngx-text-diff

  • A simple text diff component to be used with Angular and based on google diff match patch library.

Dependencies

  • diff-match-patch : ^1.0.4
  • angular-core >= 6.0.0

Demo

Ngx Text Diff Demo

Installation

npm i ngx-text-diff

API

module: NgxTextDiffModule
component: NgxTextDiffComponent
selector: td-ngx-text-diff

Inputs

InputTypeRequiredDescription
leftstringYesFirst text to be compared
rightstringYesSecond text to be compared
diffContentObservableOptionalDiffContent observable
formatDiffTableFormatOptional, default: SideBySidePossible values:
-SideBySide
-LineByLine
loadingbooleanOptional, default: falsePossible values:
-true: shows an loading spinner.
- false: hides the loading spinner
hideMatchingLinesbooleanOptional, default: falsePossible values:
-true: Only shows lines with differences.
- false: shows all lines
showToolbarbooleanOptional, default: truePossible values:
-true: shows the toolbar.
- false: hides the format toolbar
showBtnToolbarbooleanOptional, default: truePossible values:
-true: shows the format toolbar.
- false: hides the format toolbar
outerContainerClassanyOptionalngClass object for the outer div
outerContainerStyleanyOptionalngStyle object for the outer style
toolbarClassanyOptionalngClass object for the toolbar div
toolbarStyleanyOptionalngStyle object for the toolbar style
compareRowsClassanyOptionalngClass object for the div surrounding the table rows
compareRowsStyleanyOptionalngStyle object for the div surrounding the table rows

Output

InputTypeRequiredDescription
compareResultsDiffResultsOptionalEvent fired when comparison is executed

Custom Objects

export interface DiffContent {
  leftContent: string;
  rightContent: string;
}

export type DiffTableFormat = 'SideBySide' | 'LineByLine';

export interface DiffResults {
  hasDiff: boolean;
  diffsCount: number;
  rowsWithDiff: {
    leftLineNumber?: number;
    rightLineNumber?: number;
    numDiffs: number;
  }[];
}

Usage

  1. Register the NgxTextDiffModule in a module, for example app module.
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { NgxTextDiffModule } from 'ngx-text-diff';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule, NgxTextDiffModule],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule {}

Build the NgxTextDiff module

Run ng build ngx-text-diff to build the library. The build artifacts will be stored in the dist/ngx-text-diff directory.

Credits

This project is based on google diff match patch.

Keywords

FAQs

Package last updated on 14 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc