react-diff-viewer-continued 3.2.0 → 3.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/release.yml +1 -1
- package/.github/workflows/test.yml +25 -0
- package/CHANGELOG.md +15 -2
- package/README.md +3 -1
- package/lib/compute-lines.js +25 -11
- package/package.json +10 -10
- package/release.config.js +17 -11
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
name: Test
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
pull_request:
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
release:
|
|
8
|
+
name: Unit tests
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- name: Checkout
|
|
12
|
+
uses: actions/checkout@v2
|
|
13
|
+
with:
|
|
14
|
+
fetch-depth: 0
|
|
15
|
+
- name: Setup Node.js
|
|
16
|
+
uses: actions/setup-node@v2
|
|
17
|
+
with:
|
|
18
|
+
node-version: 'lts/*'
|
|
19
|
+
- uses: pnpm/action-setup@v2.2.2
|
|
20
|
+
with:
|
|
21
|
+
version: latest
|
|
22
|
+
- name: Install dependencies
|
|
23
|
+
run: pnpm i
|
|
24
|
+
- name: Run unit tests
|
|
25
|
+
run: pnpm run test
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
## [3.2.2](https://github.com/aeolun/react-diff-viewer-continued/compare/v3.2.1...v3.2.2) (2022-10-10)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* move the dependencies for development only to `devDependencies` ([206394c](https://github.com/aeolun/react-diff-viewer-continued/commit/206394cb16352f2c3601383b8510b4dee9578405))
|
|
7
|
+
|
|
8
|
+
## [3.2.1](https://github.com/aeolun/react-diff-viewer-continued/compare/v3.2.0...v3.2.1) (2022-07-07)
|
|
2
9
|
|
|
3
10
|
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* correct diff line numbering ([bab9977](https://github.com/aeolun/react-diff-viewer-continued/commit/bab99777fd687f85be68fb5c2990e554b6cb70bf))
|
|
14
|
+
|
|
15
|
+
# [3.2.0](https://github.com/aeolun/react-diff-viewer-continued/compare/v3.1.1...v3.2.0) (2022-07-07)
|
|
16
|
+
|
|
4
17
|
### Features
|
|
5
18
|
|
|
6
|
-
|
|
19
|
+
- update library for react 17, and add custom gutters ([7193350](https://github.com/aeolun/react-diff-viewer-continued/commit/7193350187ed5b13989e6d5e5ade40f3a45c943b))
|
package/README.md
CHANGED
|
@@ -8,6 +8,8 @@ A simple and beautiful text diff viewer component made with [Diff](https://githu
|
|
|
8
8
|
|
|
9
9
|
Inspired from Github diff viewer, it includes features like split view, inline view, word diff, line highlight and more. It is highly customizable and it supports almost all languages.
|
|
10
10
|
|
|
11
|
+
Most credit goes to [Pranesh Ravi](https://praneshravi.in) who created the [original diff viewer](https://github.com/praneshr/react-diff-viewer). I've just made a few modifications and updated the dependencies so they work with modern stacks.
|
|
12
|
+
|
|
11
13
|
## Install
|
|
12
14
|
|
|
13
15
|
```bash
|
|
@@ -60,7 +62,7 @@ class Diff extends PureComponent {
|
|
|
60
62
|
## Props
|
|
61
63
|
|
|
62
64
|
| Prop | Type | Default | Description |
|
|
63
|
-
|
|
65
|
+
| ------------------------- | ------------------------- | ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
64
66
|
| oldValue | `string` | `''` | Old value as string. |
|
|
65
67
|
| newValue | `string` | `''` | New value as string. |
|
|
66
68
|
| splitView | `boolean` | `true` | Switch between `unified` and `split` view. |
|
package/lib/compute-lines.js
CHANGED
|
@@ -105,9 +105,7 @@ const computeLineInformation = (oldString, newString, disableWordDiff = false, c
|
|
|
105
105
|
return undefined;
|
|
106
106
|
}
|
|
107
107
|
if (added || removed) {
|
|
108
|
-
|
|
109
|
-
diffLines.push(counter);
|
|
110
|
-
}
|
|
108
|
+
let countAsChange = true;
|
|
111
109
|
if (removed) {
|
|
112
110
|
leftLineNumber += 1;
|
|
113
111
|
left.lineNumber = leftLineNumber;
|
|
@@ -128,16 +126,25 @@ const computeLineInformation = (oldString, newString, disableWordDiff = false, c
|
|
|
128
126
|
// right and left values.
|
|
129
127
|
ignoreDiffIndexes.push(`${diffIndex + 1}-${lineIndex}`);
|
|
130
128
|
right.lineNumber = lineNumber;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
129
|
+
if (left.value === rightValue) {
|
|
130
|
+
// The new value is exactly the same as the old
|
|
131
|
+
countAsChange = false;
|
|
132
|
+
right.type = 0;
|
|
133
|
+
left.type = 0;
|
|
135
134
|
right.value = rightValue;
|
|
136
135
|
}
|
|
137
136
|
else {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
left
|
|
137
|
+
right.type = type;
|
|
138
|
+
// Do word level diff and assign the corresponding values to the
|
|
139
|
+
// left and right diff information object.
|
|
140
|
+
if (disableWordDiff) {
|
|
141
|
+
right.value = rightValue;
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
const computedDiff = computeDiff(line, rightValue, compareMethod);
|
|
145
|
+
right.value = computedDiff.right;
|
|
146
|
+
left.value = computedDiff.left;
|
|
147
|
+
}
|
|
141
148
|
}
|
|
142
149
|
}
|
|
143
150
|
}
|
|
@@ -148,6 +155,11 @@ const computeLineInformation = (oldString, newString, disableWordDiff = false, c
|
|
|
148
155
|
right.type = DiffType.ADDED;
|
|
149
156
|
right.value = line;
|
|
150
157
|
}
|
|
158
|
+
if (countAsChange && !evaluateOnlyFirstLine) {
|
|
159
|
+
if (!diffLines.includes(counter)) {
|
|
160
|
+
diffLines.push(counter);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
151
163
|
}
|
|
152
164
|
else {
|
|
153
165
|
leftLineNumber += 1;
|
|
@@ -159,7 +171,9 @@ const computeLineInformation = (oldString, newString, disableWordDiff = false, c
|
|
|
159
171
|
right.type = DiffType.DEFAULT;
|
|
160
172
|
right.value = line;
|
|
161
173
|
}
|
|
162
|
-
|
|
174
|
+
if (!evaluateOnlyFirstLine) {
|
|
175
|
+
counter += 1;
|
|
176
|
+
}
|
|
163
177
|
return { right, left };
|
|
164
178
|
})
|
|
165
179
|
.filter(Boolean);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-diff-viewer-continued",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Continuation of a simple and beautiful text diff viewer component made with diff and React",
|
|
6
6
|
"keywords": [
|
|
@@ -35,21 +35,17 @@
|
|
|
35
35
|
"prettier": "prettier --write ."
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@babel/core": "^7.18.6",
|
|
39
|
-
"@babel/preset-env": "^7.18.6",
|
|
40
|
-
"@babel/preset-react": "^7.18.6",
|
|
41
|
-
"@babel/preset-typescript": "^7.18.6",
|
|
42
38
|
"classnames": "^2.3.1",
|
|
43
39
|
"diff": "^5.1.0",
|
|
44
40
|
"emotion": "^10.0.27",
|
|
45
|
-
"jest": "^28.1.2",
|
|
46
|
-
"jest-environment-jsdom": "^28.1.2",
|
|
47
41
|
"memoize-one": "^6.0.0",
|
|
48
|
-
"
|
|
49
|
-
"prop-types": "^15.8.1",
|
|
50
|
-
"sass": "^1.53.0"
|
|
42
|
+
"prop-types": "^15.8.1"
|
|
51
43
|
},
|
|
52
44
|
"devDependencies": {
|
|
45
|
+
"@babel/core": "^7.18.6",
|
|
46
|
+
"@babel/preset-env": "^7.18.6",
|
|
47
|
+
"@babel/preset-react": "^7.18.6",
|
|
48
|
+
"@babel/preset-typescript": "^7.18.6",
|
|
53
49
|
"@semantic-release/changelog": "6.0.1",
|
|
54
50
|
"@semantic-release/git": "10.0.1",
|
|
55
51
|
"@testing-library/react": "^12.1.5",
|
|
@@ -75,11 +71,15 @@
|
|
|
75
71
|
"file-loader": "^6.2.0",
|
|
76
72
|
"gh-pages": "^4.0.0",
|
|
77
73
|
"html-webpack-plugin": "^5.5.0",
|
|
74
|
+
"jest": "^28.1.2",
|
|
75
|
+
"jest-environment-jsdom": "^28.1.2",
|
|
78
76
|
"mini-css-extract-plugin": "^2.6.1",
|
|
79
77
|
"mocha": "^10.0.0",
|
|
78
|
+
"prettier": "^2.7.1",
|
|
80
79
|
"raw-loader": "^4.0.2",
|
|
81
80
|
"react": "^17.0.2",
|
|
82
81
|
"react-dom": "^17.0.2",
|
|
82
|
+
"sass": "^1.53.0",
|
|
83
83
|
"sass-loader": "^13.0.2",
|
|
84
84
|
"semantic-release": "^19.0.3",
|
|
85
85
|
"spy": "^1.0.0",
|
package/release.config.js
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
branches: [
|
|
2
|
+
branches: ['master'],
|
|
3
3
|
plugins: [
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"@semantic-release/npm",
|
|
4
|
+
'@semantic-release/commit-analyzer',
|
|
5
|
+
'@semantic-release/release-notes-generator',
|
|
6
|
+
'@semantic-release/npm',
|
|
7
|
+
'@semantic-release/changelog',
|
|
8
|
+
'@semantic-release/github',
|
|
10
9
|
[
|
|
11
|
-
|
|
10
|
+
'@semantic-release/git',
|
|
12
11
|
{
|
|
13
|
-
message:
|
|
14
|
-
|
|
12
|
+
message:
|
|
13
|
+
'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}',
|
|
14
|
+
assets: [
|
|
15
|
+
'CHANGELOG.md',
|
|
16
|
+
'package.json',
|
|
17
|
+
'package-lock.json',
|
|
18
|
+
'pnpm-lock.yaml',
|
|
19
|
+
'npm-shrinkwrap.json',
|
|
20
|
+
],
|
|
15
21
|
},
|
|
16
22
|
],
|
|
17
23
|
],
|
|
18
|
-
}
|
|
24
|
+
};
|