You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

text-diff-jsx

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

text-diff-jsx

A Text Diff component for React.

0.1.0
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

text-diff-jsx

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

Dependencies

  • diff-match-patch : ^1.0.5

Installation

npm i text-diff-jsx

API

Component: TextDiff

Inputs

NameTypeRequiredDescription
originalTextstringYesFirst text to be compared
modifiedTextstringYesSecond text to be compared
formatDiffTableFormatOptional, default: SideBySidePossible values:
-SideBySide
-LineByLine
hideMatchingLinesbooleanOptional, default: falsePossible values:
-true: Only shows lines with differences.
- false: shows all lines

Custom Objects

export type DiffTableFormat = 'SideBySide' | 'LineByLine';
export type SideDiff = 'both' | 'left' | 'right';

export interface DiffTableFormatOption {
  id: string;
  name: string;
  label: string;
  value: DiffTableFormat;
  icon?: string;
  disabled?: boolean;
}

export interface DiffPart {
  content: string;
  isDiff: boolean;
}

export interface DiffLineResult {
  lineNumber: number;
  prefix: string;
  lineContent: string;
  lineDiffs: DiffPart[];
}

export interface DiffTableRowResult {
  id?: number;
  left?: DiffLineResult;
  right?: DiffLineResult;
  belongTo: SideDiff;
  hasDiffs: boolean;
  numDiffs: number;
}

export interface ProcessLinesOptions {
  id: number;
  leftLines: string[];
  rightLines: string[];
  leftNumber: number;
  rightNumber: number;
  hasDiffs?: boolean;
}

Credits

This project is based on Google Diff Match Patch.

Keywords

React

FAQs

Package last updated on 22 Aug 2021

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