react-diff-viewer-continued
Advanced tools
Comparing version 4.0.2 to 4.0.3
@@ -0,1 +1,8 @@ | ||
## [4.0.3](https://github.com/aeolun/react-diff-viewer-continued/compare/v4.0.2...v4.0.3) (2024-05-23) | ||
### Reverts | ||
* Revert "refactoring attempt" ([6a9789b](https://github.com/aeolun/react-diff-viewer-continued/commit/6a9789b0af0221bf32be11d1af9d4db3337008f4)) | ||
## [4.0.2](https://github.com/aeolun/react-diff-viewer-continued/compare/v4.0.1...v4.0.2) (2024-02-14) | ||
@@ -2,0 +9,0 @@ |
@@ -0,1 +1,2 @@ | ||
import * as diff from 'diff'; | ||
export declare enum DiffType { | ||
@@ -54,3 +55,3 @@ DEFAULT = 0, | ||
*/ | ||
declare const computeLineInformation: (oldString: string | Object, newString: string | Object, disableWordDiff?: boolean, lineCompareMethod?: string, linesOffset?: number, showLines?: string[]) => ComputedLineInformation; | ||
declare const computeLineInformation: (oldString: string | Object, newString: string | Object, disableWordDiff?: boolean, lineCompareMethod?: DiffMethod | ((oldStr: string, newStr: string) => diff.Change[]), linesOffset?: number, showLines?: string[]) => ComputedLineInformation; | ||
export { computeLineInformation }; |
@@ -69,3 +69,4 @@ "use strict"; | ||
const computeDiff = (oldValue, newValue, compareMethod = DiffMethod.CHARS) => { | ||
const diffArray = jsDiff[compareMethod](oldValue, newValue); | ||
const compareFunc = (typeof (compareMethod) === 'string') ? jsDiff[compareMethod] : compareMethod; | ||
const diffArray = compareFunc(oldValue, newValue); | ||
const computedDiff = { | ||
@@ -72,0 +73,0 @@ left: [], |
import * as React from 'react'; | ||
import { ReactElement } from 'react'; | ||
import { DiffInformation, DiffMethod, DiffType, LineInformation } from './compute-lines'; | ||
import { Change } from 'diff'; | ||
import { ReactDiffViewerStyles, ReactDiffViewerStylesOverride } from './styles'; | ||
@@ -15,3 +16,3 @@ export declare enum LineNumberPrefix { | ||
disableWordDiff?: boolean; | ||
compareMethod?: DiffMethod; | ||
compareMethod?: DiffMethod | ((oldStr: string, newStr: string) => Change[]); | ||
extraLinesSurroundingDiff?: number; | ||
@@ -18,0 +19,0 @@ hideLineNumbers?: boolean; |
@@ -288,4 +288,4 @@ "use strict"; | ||
this.render = () => { | ||
const { oldValue, newValue, useDarkTheme, leftTitle, rightTitle, splitView, hideLineNumbers, nonce, } = this.props; | ||
if (this.props.compareMethod !== compute_lines_1.DiffMethod.JSON) { | ||
const { oldValue, newValue, useDarkTheme, leftTitle, rightTitle, splitView, compareMethod, hideLineNumbers, nonce, } = this.props; | ||
if (typeof (compareMethod) === 'string' && compareMethod !== compute_lines_1.DiffMethod.JSON) { | ||
if (typeof oldValue !== 'string' || typeof newValue !== 'string') { | ||
@@ -292,0 +292,0 @@ throw Error('"oldValue" and "newValue" should be strings'); |
@@ -43,3 +43,4 @@ import * as diff from 'diff'; | ||
const computeDiff = (oldValue, newValue, compareMethod = DiffMethod.CHARS) => { | ||
const diffArray = jsDiff[compareMethod](oldValue, newValue); | ||
const compareFunc = (typeof (compareMethod) === 'string') ? jsDiff[compareMethod] : compareMethod; | ||
const diffArray = compareFunc(oldValue, newValue); | ||
const computedDiff = { | ||
@@ -46,0 +47,0 @@ left: [], |
@@ -279,4 +279,4 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; | ||
render = () => { | ||
const { oldValue, newValue, useDarkTheme, leftTitle, rightTitle, splitView, hideLineNumbers, nonce, } = this.props; | ||
if (this.props.compareMethod !== DiffMethod.JSON) { | ||
const { oldValue, newValue, useDarkTheme, leftTitle, rightTitle, splitView, compareMethod, hideLineNumbers, nonce, } = this.props; | ||
if (typeof (compareMethod) === 'string' && compareMethod !== DiffMethod.JSON) { | ||
if (typeof oldValue !== 'string' || typeof newValue !== 'string') { | ||
@@ -283,0 +283,0 @@ throw Error('"oldValue" and "newValue" should be strings'); |
{ | ||
"name": "react-diff-viewer-continued", | ||
"version": "4.0.2", | ||
"version": "4.0.3", | ||
"private": false, | ||
@@ -52,3 +52,3 @@ "description": "Continuation of a simple and beautiful text diff viewer component made with diff and React", | ||
"@types/react-dom": "^18.2.19", | ||
"gh-pages": "^4.0.0", | ||
"gh-pages": "^5.0.0", | ||
"happy-dom": "^13.3.8", | ||
@@ -55,0 +55,0 @@ "react": "^18.2.0", |
@@ -74,7 +74,7 @@ <img src='https://github.com/Aeolun/react-diff-viewer-continued/raw/master/logo_dark.png' width="100%" alt='React Diff Viewer' /> | ||
|---------------------------|---------------------------|--------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| oldValue | `string | Object` | `''` | Old value as string (or Object if using `diffJson`). | | ||
| newValue | `string | Object` | `''` | New value as string (or Object if using `diffJson`). | | ||
| oldValue | `string \| Object` | `''` | Old value as string (or Object if using `diffJson`). | | ||
| newValue | `string \| Object` | `''` | New value as string (or Object if using `diffJson`). | | ||
| splitView | `boolean` | `true` | Switch between `unified` and `split` view. | | ||
| disableWordDiff | `boolean` | `false` | Show and hide word diff in a diff line. | | ||
| compareMethod | `DiffMethod` | `DiffMethod.CHARS` | JsDiff text diff method used for diffing strings. Check out the [guide](https://github.com/praneshr/react-diff-viewer/tree/v3.0.0#text-block-diff-comparison) to use different methods. | | ||
| compareMethod | `DiffMethod \| (string, string) => diff.Change[]` | `DiffMethod.CHARS` | Uses an existing diff method when a `DiffMethod` enum is passed. If a function is passed, that function is used as the diff method. <br /> <br /> JsDiff text diff method used for diffing strings. Check out the [guide](https://github.com/praneshr/react-diff-viewer/tree/v3.0.0#text-block-diff-comparison) to use different methods. | | ||
| renderGutter | `(diffData) => ReactNode` | `undefined` | Function that can be used to render an extra gutter with various information next to the line number. | | ||
@@ -81,0 +81,0 @@ | hideLineNumbers | `boolean` | `false` | Show and hide line numbers. | |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
302590
2340
0