@git-diff-view/react 0.0.34 → 0.0.36
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/dist/cjs/index.development.js +8 -8
- package/dist/cjs/index.development.js.map +1 -1
- package/dist/cjs/index.production.js +8 -8
- package/dist/cjs/index.production.js.map +1 -1
- package/dist/css/diff-view-pure.css +13 -13
- package/dist/css/diff-view.css +13 -519
- package/dist/esm/index.mjs +9 -9
- package/dist/esm/index.mjs.map +1 -1
- package/index.d.ts +15 -13
- package/package.json +3 -3
- package/readme.md +123 -72
- package/src/_base.css +0 -1
- package/src/_com.css +13 -13
- package/src/components/DiffAddWidget.tsx +4 -1
- package/src/components/DiffSplitHunkLineNormal.tsx +2 -2
- package/src/components/DiffUnifiedExtendLine.tsx +1 -1
- package/src/components/DiffUnifiedWidgetLine.tsx +1 -1
- package/src/components/v2/DiffSplitHunkLineNormal_v2.tsx +2 -2
- package/styles/diff-view-pure.css +13 -13
- package/styles/diff-view.css +13 -519
- package/src/_base_pure.css +0 -2
- package/src/tailwind_pure.css +0 -3
package/index.d.ts
CHANGED
|
@@ -14,11 +14,12 @@ declare class File$1 {
|
|
|
14
14
|
readonly lang: DiffHighlighterLang | string;
|
|
15
15
|
readonly fileName?: string;
|
|
16
16
|
ast?: DiffAST;
|
|
17
|
+
theme?: "light" | "dark";
|
|
17
18
|
rawFile: Record<number, string>;
|
|
18
19
|
hasDoRaw: boolean;
|
|
19
20
|
rawLength?: number;
|
|
20
|
-
syntaxFile: Record<number, SyntaxLineWithTemplate>;
|
|
21
|
-
plainFile: Record<number, {
|
|
21
|
+
syntaxFile: Record<number | string, SyntaxLineWithTemplate>;
|
|
22
|
+
plainFile: Record<number | string, {
|
|
22
23
|
value: string;
|
|
23
24
|
template?: string;
|
|
24
25
|
}>;
|
|
@@ -123,12 +124,12 @@ export declare class DiffFile {
|
|
|
123
124
|
getSplitLineIndexByLineNumber: (lineNumber: number, side: SplitSide) => number;
|
|
124
125
|
getSplitRightLine: (index: number) => SplitLineItem;
|
|
125
126
|
getSplitHunkLine: (index: number) => DiffHunkItem;
|
|
126
|
-
onSplitHunkExpand: (dir: "up" | "down" | "all", index: number, needTrigger?: boolean) => void;
|
|
127
|
+
onSplitHunkExpand: (dir: "up" | "down" | "all" | "up-all" | "down-all", index: number, needTrigger?: boolean) => void;
|
|
127
128
|
getUnifiedLine: (index: number) => UnifiedLineItem;
|
|
128
129
|
getUnifiedLineByLineNumber: (lienNumber: number, side: SplitSide) => UnifiedLineItem;
|
|
129
130
|
getUnifiedLineIndexByLineNumber: (lineNumber: number, side: SplitSide) => number;
|
|
130
131
|
getUnifiedHunkLine: (index: number) => DiffHunkItem;
|
|
131
|
-
onUnifiedHunkExpand: (dir: "up" | "down" | "all", index: number, needTrigger?: boolean) => void;
|
|
132
|
+
onUnifiedHunkExpand: (dir: "up" | "down" | "all" | "up-all" | "down-all", index: number, needTrigger?: boolean) => void;
|
|
132
133
|
onAllExpand: (mode: "split" | "unified") => void;
|
|
133
134
|
get hasExpandSplitAll(): boolean;
|
|
134
135
|
get hasExpandUnifiedAll(): boolean;
|
|
@@ -162,21 +163,21 @@ export declare class DiffFile {
|
|
|
162
163
|
hasBuildUnified: boolean;
|
|
163
164
|
oldFileLines: Record<number, string>;
|
|
164
165
|
oldFileDiffLines: Record<string, DiffLineItem>;
|
|
165
|
-
oldFilePlainLines: Record<number, {
|
|
166
|
+
oldFilePlainLines: Record<string | number, {
|
|
166
167
|
value: string;
|
|
167
168
|
template?: string;
|
|
168
169
|
}>;
|
|
169
|
-
oldFileSyntaxLines: Record<number, SyntaxLine & {
|
|
170
|
+
oldFileSyntaxLines: Record<string | number, SyntaxLine & {
|
|
170
171
|
template?: string;
|
|
171
172
|
}>;
|
|
172
173
|
oldFilePlaceholderLines: Record<string, boolean>;
|
|
173
174
|
newFileLines: Record<number, string>;
|
|
174
175
|
newFileDiffLines: Record<string, DiffLineItem>;
|
|
175
|
-
newFilePlainLines: Record<number, {
|
|
176
|
+
newFilePlainLines: Record<string | number, {
|
|
176
177
|
value: string;
|
|
177
178
|
template?: string;
|
|
178
179
|
}>;
|
|
179
|
-
newFileSyntaxLines: Record<number, SyntaxLine & {
|
|
180
|
+
newFileSyntaxLines: Record<string | number, SyntaxLine & {
|
|
180
181
|
template?: string;
|
|
181
182
|
}>;
|
|
182
183
|
newFilePlaceholderLines: Record<string, boolean>;
|
|
@@ -224,21 +225,21 @@ export declare class DiffFile {
|
|
|
224
225
|
hasBuildUnified: boolean;
|
|
225
226
|
oldFileLines: Record<number, string>;
|
|
226
227
|
oldFileDiffLines: Record<string, DiffLineItem>;
|
|
227
|
-
oldFilePlainLines: Record<number, {
|
|
228
|
+
oldFilePlainLines: Record<string | number, {
|
|
228
229
|
value: string;
|
|
229
230
|
template?: string;
|
|
230
231
|
}>;
|
|
231
|
-
oldFileSyntaxLines: Record<number, SyntaxLine & {
|
|
232
|
+
oldFileSyntaxLines: Record<string | number, SyntaxLine & {
|
|
232
233
|
template?: string;
|
|
233
234
|
}>;
|
|
234
235
|
oldFilePlaceholderLines: Record<string, boolean>;
|
|
235
236
|
newFileLines: Record<number, string>;
|
|
236
237
|
newFileDiffLines: Record<string, DiffLineItem>;
|
|
237
|
-
newFilePlainLines: Record<number, {
|
|
238
|
+
newFilePlainLines: Record<string | number, {
|
|
238
239
|
value: string;
|
|
239
240
|
template?: string;
|
|
240
241
|
}>;
|
|
241
|
-
newFileSyntaxLines: Record<number, SyntaxLine & {
|
|
242
|
+
newFileSyntaxLines: Record<string | number, SyntaxLine & {
|
|
242
243
|
template?: string;
|
|
243
244
|
}>;
|
|
244
245
|
newFilePlaceholderLines: Record<string, boolean>;
|
|
@@ -312,11 +313,12 @@ export declare class DiffLine {
|
|
|
312
313
|
readonly noTrailingNewLine: boolean;
|
|
313
314
|
changes?: IRange;
|
|
314
315
|
diffChanges?: DiffRange;
|
|
316
|
+
_diffChanges?: DiffRange;
|
|
315
317
|
plainTemplate?: string;
|
|
316
318
|
plainTemplateMode?: "fast-diff" | "relative";
|
|
317
319
|
syntaxTemplate?: string;
|
|
318
320
|
syntaxTemplateMode?: "fast-diff" | "relative";
|
|
319
|
-
constructor(text: string, type: DiffLineType, originalLineNumber: number | null, oldLineNumber: number | null, newLineNumber: number | null, noTrailingNewLine?: boolean, changes?: IRange, diffChanges?: DiffRange, plainTemplate?: string, plainTemplateMode?: "fast-diff" | "relative", syntaxTemplate?: string, syntaxTemplateMode?: "fast-diff" | "relative");
|
|
321
|
+
constructor(text: string, type: DiffLineType, originalLineNumber: number | null, oldLineNumber: number | null, newLineNumber: number | null, noTrailingNewLine?: boolean, changes?: IRange, diffChanges?: DiffRange, _diffChanges?: DiffRange, plainTemplate?: string, plainTemplateMode?: "fast-diff" | "relative", syntaxTemplate?: string, syntaxTemplateMode?: "fast-diff" | "relative");
|
|
320
322
|
withNoTrailingNewLine(noTrailingNewLine: boolean): DiffLine;
|
|
321
323
|
isIncludeableLine(): boolean;
|
|
322
324
|
equals(other: DiffLine): boolean;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "@git-diff-view/react",
|
|
4
4
|
"author": "MrWangJustToDo",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "0.0.
|
|
6
|
+
"version": "0.0.36",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"types": "index.d.ts",
|
|
9
9
|
"files": [
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"react diff component"
|
|
62
62
|
],
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@git-diff-view/core": "^0.0.
|
|
64
|
+
"@git-diff-view/core": "^0.0.36",
|
|
65
65
|
"@types/hast": "^3.0.0",
|
|
66
66
|
"fast-diff": "^1.3.0",
|
|
67
67
|
"highlight.js": "^11.11.0",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"scripts": {
|
|
84
84
|
"gen:type": "dts-bundle-generator -o index.d.ts dist/types/index.d.ts",
|
|
85
85
|
"gen:css1": "postcss src/tailwind.css -o dist/css/diff-view.css",
|
|
86
|
-
"gen:css2": "postcss src/
|
|
86
|
+
"gen:css2": "postcss src/tailwind.css -o dist/css/diff-view-pure.css",
|
|
87
87
|
"gen:css": "npm run gen:css1 && npm run gen:css2"
|
|
88
88
|
}
|
|
89
89
|
}
|
package/readme.md
CHANGED
|
@@ -1,103 +1,154 @@
|
|
|
1
|
-
|
|
1
|
+
# @git-diff-view/react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> A high-performance React diff view component with GitHub-style UI
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/@git-diff-view/react)
|
|
6
|
+
[](https://www.npmjs.com/package/@git-diff-view/react)
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- ✅ Split & Unified views
|
|
11
|
+
- ✅ Syntax highlighting with full context
|
|
12
|
+
- ✅ Light & Dark themes
|
|
13
|
+
- ✅ SSR & RSC support
|
|
14
|
+
- ✅ Widget & extend data system
|
|
15
|
+
- ✅ High performance with Web Worker support
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @git-diff-view/react
|
|
21
|
+
# or
|
|
22
|
+
pnpm add @git-diff-view/react
|
|
23
|
+
# or
|
|
24
|
+
yarn add @git-diff-view/react
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
### Basic Usage
|
|
8
30
|
|
|
9
31
|
```tsx
|
|
10
32
|
import { DiffView, DiffModeEnum } from "@git-diff-view/react";
|
|
11
33
|
import "@git-diff-view/react/styles/diff-view.css";
|
|
12
34
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
diffViewAddWidget
|
|
28
|
-
onAddWidgetClick={({ side, lineNumber }) => void}
|
|
29
|
-
renderWidgetLine={({ onClose, side, lineNumber }) => ReactNode}
|
|
30
|
-
/>
|
|
31
|
-
|
|
35
|
+
function MyDiffView() {
|
|
36
|
+
return (
|
|
37
|
+
<DiffView
|
|
38
|
+
data={{
|
|
39
|
+
oldFile: { fileName: "old.ts", content: "..." },
|
|
40
|
+
newFile: { fileName: "new.ts", content: "..." },
|
|
41
|
+
hunks: ["..."]
|
|
42
|
+
}}
|
|
43
|
+
diffViewMode={DiffModeEnum.Split}
|
|
44
|
+
diffViewTheme="dark"
|
|
45
|
+
diffViewHighlight
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
32
49
|
```
|
|
33
50
|
|
|
34
|
-
|
|
51
|
+
### Advanced Usage with DiffFile
|
|
52
|
+
|
|
53
|
+
**File Comparison Mode**
|
|
35
54
|
|
|
36
55
|
```tsx
|
|
37
|
-
|
|
56
|
+
import { DiffView } from "@git-diff-view/react";
|
|
38
57
|
import { DiffFile, generateDiffFile } from "@git-diff-view/file";
|
|
58
|
+
import "@git-diff-view/react/styles/diff-view.css";
|
|
59
|
+
|
|
39
60
|
const file = generateDiffFile(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
data?.newFile?.content || "",
|
|
44
|
-
data?.oldFile?.fileLang || "",
|
|
45
|
-
data?.newFile?.fileLang || ""
|
|
61
|
+
"old.ts", oldContent,
|
|
62
|
+
"new.ts", newContent,
|
|
63
|
+
"typescript", "typescript"
|
|
46
64
|
);
|
|
47
|
-
file.initTheme('
|
|
65
|
+
file.initTheme('dark');
|
|
48
66
|
file.init();
|
|
49
67
|
file.buildSplitDiffLines();
|
|
50
|
-
file.buildUnifiedDiffLines();
|
|
51
68
|
|
|
52
|
-
|
|
69
|
+
<DiffView diffFile={file} />
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Git Diff Mode**
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
import { DiffView } from "@git-diff-view/react";
|
|
53
76
|
import { DiffFile } from "@git-diff-view/core";
|
|
77
|
+
import "@git-diff-view/react/styles/diff-view.css";
|
|
78
|
+
|
|
54
79
|
const file = new DiffFile(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
80
|
+
oldFileName,
|
|
81
|
+
oldContent,
|
|
82
|
+
newFileName,
|
|
83
|
+
newContent,
|
|
84
|
+
hunks,
|
|
85
|
+
oldFileLang,
|
|
86
|
+
newFileLang
|
|
62
87
|
);
|
|
63
|
-
file.initTheme('
|
|
88
|
+
file.initTheme('dark');
|
|
64
89
|
file.init();
|
|
65
90
|
file.buildSplitDiffLines();
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
// use current data to render
|
|
69
|
-
<DiffView diffFile={file} {...props} />;
|
|
70
|
-
// or use the bundle data to render, eg: postMessage/httpRequest
|
|
71
|
-
const bundle = file.getBundle();
|
|
72
|
-
const diffFile = DiffFile.createInstance(data || {}, bundle);
|
|
73
|
-
<DiffView diffFile={diffFile} {...props} />;
|
|
91
|
+
|
|
92
|
+
<DiffView diffFile={file} />
|
|
74
93
|
```
|
|
75
|
-
### example
|
|
76
94
|
|
|
77
|
-
|
|
78
|
-
#### [react-ssr-example](https://github.com/MrWangJustToDo/git-diff-view/tree/main/ui/next-page-example)
|
|
79
|
-
#### [react-rsc-example](https://github.com/MrWangJustToDo/git-diff-view/tree/main/ui/next-app-example)
|
|
95
|
+
## Styling
|
|
80
96
|
|
|
81
|
-
|
|
97
|
+
```tsx
|
|
98
|
+
// Default styles with Tailwind (next release will be pure CSS)
|
|
99
|
+
import "@git-diff-view/react/styles/diff-view.css";
|
|
100
|
+
|
|
101
|
+
// Pure CSS (no Tailwind conflicts)
|
|
102
|
+
import "@git-diff-view/react/styles/diff-view-pure.css";
|
|
103
|
+
```
|
|
82
104
|
|
|
83
|
-
|
|
84
|
-

|
|
85
|
-

|
|
105
|
+
## API Reference
|
|
86
106
|
|
|
87
107
|
### Props
|
|
88
108
|
|
|
89
|
-
|
|
|
90
|
-
|
|
91
|
-
| data
|
|
92
|
-
| diffFile
|
|
93
|
-
|
|
|
94
|
-
|
|
|
95
|
-
|
|
|
96
|
-
|
|
|
97
|
-
|
|
|
98
|
-
|
|
|
99
|
-
|
|
|
100
|
-
|
|
|
101
|
-
|
|
|
102
|
-
| onAddWidgetClick |
|
|
109
|
+
| Prop | Type | Description |
|
|
110
|
+
|------|------|-------------|
|
|
111
|
+
| `data` | `DiffData` | Diff data with `oldFile`, `newFile`, and `hunks` |
|
|
112
|
+
| `diffFile` | `DiffFile` | Pre-processed diff file instance |
|
|
113
|
+
| `diffViewMode` | `Split \| Unified` | View mode (default: `Split`) |
|
|
114
|
+
| `diffViewTheme` | `light \| dark` | Theme (default: `light`) |
|
|
115
|
+
| `diffViewHighlight` | `boolean` | Enable syntax highlighting |
|
|
116
|
+
| `diffViewWrap` | `boolean` | Enable line wrapping |
|
|
117
|
+
| `diffViewFontSize` | `number` | Font size in pixels |
|
|
118
|
+
| `diffViewAddWidget` | `boolean` | Enable widget button |
|
|
119
|
+
| `renderWidgetLine` | `(props) => ReactNode` | Custom widget renderer |
|
|
120
|
+
| `renderExtendLine` | `(props) => ReactNode` | Custom extend data renderer |
|
|
121
|
+
| `extendData` | `ExtendData` | Additional data per line |
|
|
122
|
+
| `onAddWidgetClick` | `(props) => void` | Widget button click handler |
|
|
123
|
+
|
|
124
|
+
### DiffData Type
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
type DiffData = {
|
|
128
|
+
oldFile?: {
|
|
129
|
+
fileName?: string | null;
|
|
130
|
+
fileLang?: string | null;
|
|
131
|
+
content?: string | null;
|
|
132
|
+
};
|
|
133
|
+
newFile?: {
|
|
134
|
+
fileName?: string | null;
|
|
135
|
+
fileLang?: string | null;
|
|
136
|
+
content?: string | null;
|
|
137
|
+
};
|
|
138
|
+
hunks: string[];
|
|
139
|
+
};
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Examples
|
|
143
|
+
|
|
144
|
+
- [Basic React Example](https://github.com/MrWangJustToDo/git-diff-view/tree/main/ui/react-example)
|
|
145
|
+
- [Next.js SSR Example](https://github.com/MrWangJustToDo/git-diff-view/tree/main/ui/next-page-example)
|
|
146
|
+
- [Next.js RSC Example](https://github.com/MrWangJustToDo/git-diff-view/tree/main/ui/next-app-example)
|
|
147
|
+
|
|
148
|
+
## Live Demo
|
|
149
|
+
|
|
150
|
+
Try it online: [https://mrwangjusttodo.github.io/git-diff-view](https://mrwangjusttodo.github.io/git-diff-view)
|
|
151
|
+
|
|
152
|
+
## License
|
|
103
153
|
|
|
154
|
+
MIT © [MrWangJustToDo](https://github.com/MrWangJustToDo)
|
package/src/_base.css
CHANGED
package/src/_com.css
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
[data-theme="light"] .diff-style-root {
|
|
6
6
|
--diff-border--: #dedede;
|
|
7
|
-
--diff-add-content--: #
|
|
7
|
+
--diff-add-content--: #dafbe1;
|
|
8
8
|
--diff-del-content--: #ffebe9;
|
|
9
|
-
--diff-add-lineNumber--: #
|
|
10
|
-
--diff-del-lineNumber--: #
|
|
9
|
+
--diff-add-lineNumber--: #aceebb;
|
|
10
|
+
--diff-del-lineNumber--: #ffcecb;
|
|
11
11
|
--diff-plain-content--: #ffffff;
|
|
12
12
|
--diff-expand-content--: #fafafa;
|
|
13
13
|
--diff-plain-lineNumber--: #fafafa;
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
--diff-plain-lineNumber-color--: #555555;
|
|
16
16
|
--diff-expand-lineNumber-color--: #555555;
|
|
17
17
|
--diff-hunk-content--: #ddf4ff;
|
|
18
|
-
--diff-hunk-lineNumber--: #
|
|
18
|
+
--diff-hunk-lineNumber--: #b6e3ff;
|
|
19
19
|
--diff-hunk-lineNumber-hover--: #0969da;
|
|
20
|
-
--diff-add-content-highlight--: #
|
|
21
|
-
--diff-del-content-highlight--: #
|
|
20
|
+
--diff-add-content-highlight--: #aceebb;
|
|
21
|
+
--diff-del-content-highlight--: #ffcecb;
|
|
22
22
|
--diff-add-widget--: #0969d2;
|
|
23
23
|
--diff-add-widget-color--: #ffffff;
|
|
24
24
|
--diff-empty-content--: #fafafa;
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
|
|
36
36
|
[data-theme="dark"] .diff-style-root {
|
|
37
37
|
--diff-border--: #3d444d;
|
|
38
|
-
--diff-add-content--: #
|
|
39
|
-
--diff-del-content--: #
|
|
40
|
-
--diff-add-lineNumber--: #
|
|
41
|
-
--diff-del-lineNumber--: #
|
|
38
|
+
--diff-add-content--: #18271f;
|
|
39
|
+
--diff-del-content--: #23191c;
|
|
40
|
+
--diff-add-lineNumber--: #284228;
|
|
41
|
+
--diff-del-lineNumber--: #4f2828;
|
|
42
42
|
--diff-plain-content--: #0d1117;
|
|
43
43
|
--diff-expand-content--: #161b22;
|
|
44
44
|
--diff-plain-lineNumber--: #161b22;
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
--diff-plain-lineNumber-color--: #a0aaab;
|
|
47
47
|
--diff-expand-lineNumber-color--: #a0aaab;
|
|
48
48
|
--diff-hunk-content--: #131d2e;
|
|
49
|
-
--diff-hunk-lineNumber--: #
|
|
49
|
+
--diff-hunk-lineNumber--: #0c2d6b;
|
|
50
50
|
--diff-hunk-lineNumber-hover--: #1f6feb;
|
|
51
|
-
--diff-add-content-highlight--: #
|
|
52
|
-
--diff-del-content-highlight--: #
|
|
51
|
+
--diff-add-content-highlight--: #2f5732;
|
|
52
|
+
--diff-del-content-highlight--: #713431;
|
|
53
53
|
--diff-add-widget--: #0969d2;
|
|
54
54
|
--diff-add-widget-color--: #ffffff;
|
|
55
55
|
--diff-empty-content--: #161b22;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { addWidgetBGName, addWidgetColorName, diffFontSizeName } from "@git-diff-view/utils";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { SplitSide } from "./DiffView";
|
|
5
|
+
|
|
5
6
|
import type { DiffFile } from "@git-diff-view/core";
|
|
6
7
|
|
|
7
8
|
export const DiffSplitAddWidget = ({
|
|
@@ -21,6 +22,7 @@ export const DiffSplitAddWidget = ({
|
|
|
21
22
|
}) => {
|
|
22
23
|
return (
|
|
23
24
|
<div
|
|
25
|
+
data-add-widget={SplitSide[side]}
|
|
24
26
|
className={
|
|
25
27
|
"diff-add-widget-wrapper invisible select-none transition-transform hover:scale-110 group-hover:visible" +
|
|
26
28
|
(className ? " " + className : "")
|
|
@@ -63,6 +65,7 @@ export const DiffUnifiedAddWidget = ({
|
|
|
63
65
|
}) => {
|
|
64
66
|
return (
|
|
65
67
|
<div
|
|
68
|
+
data-add-widget={SplitSide[side]}
|
|
66
69
|
className="diff-add-widget-wrapper invisible absolute left-[100%] translate-x-[-50%] select-none transition-transform hover:scale-110 group-hover:visible"
|
|
67
70
|
style={{
|
|
68
71
|
width: `calc(var(${diffFontSizeName}) * 1.4)`,
|
|
@@ -163,8 +163,8 @@ const InternalDiffSplitHunkLineGitLab = ({
|
|
|
163
163
|
|
|
164
164
|
useSyncHeight({
|
|
165
165
|
selector: `tr[data-line="${lineNumber}-hunk"]`,
|
|
166
|
-
side: SplitSide[
|
|
167
|
-
enable:
|
|
166
|
+
side: SplitSide[SplitSide.old],
|
|
167
|
+
enable: side === SplitSide.new,
|
|
168
168
|
});
|
|
169
169
|
|
|
170
170
|
const couldExpand = expandEnabled && currentHunk && currentHunk.splitInfo;
|
|
@@ -32,7 +32,7 @@ const InternalDiffUnifiedExtendLine = ({
|
|
|
32
32
|
// TODO use css variable to get width
|
|
33
33
|
const width = useDomWidth({
|
|
34
34
|
selector: ".unified-diff-table-wrapper",
|
|
35
|
-
enable: typeof renderExtendLine === "function"
|
|
35
|
+
enable: typeof renderExtendLine === "function",
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
if (!renderExtendLine) return null;
|
|
@@ -44,7 +44,7 @@ const InternalDiffUnifiedWidgetLine = ({
|
|
|
44
44
|
|
|
45
45
|
const width = useDomWidth({
|
|
46
46
|
selector: ".unified-diff-table-wrapper",
|
|
47
|
-
enable: typeof renderWidgetLine === "function"
|
|
47
|
+
enable: typeof renderWidgetLine === "function",
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
if (!renderWidgetLine) return null;
|
|
@@ -154,8 +154,8 @@ const InternalDiffSplitHunkLineGitLab = ({
|
|
|
154
154
|
|
|
155
155
|
useSyncHeight({
|
|
156
156
|
selector: `div[data-state="hunk"][data-line="${lineNumber}-hunk"]`,
|
|
157
|
-
side: SplitSide[
|
|
158
|
-
enable:
|
|
157
|
+
side: SplitSide[SplitSide.old],
|
|
158
|
+
enable: side === SplitSide.new,
|
|
159
159
|
});
|
|
160
160
|
|
|
161
161
|
const couldExpand = expandEnabled && currentHunk && currentHunk.splitInfo;
|
|
@@ -267,10 +267,10 @@
|
|
|
267
267
|
}
|
|
268
268
|
.diff-tailwindcss-wrapper[data-theme="light"] .diff-style-root {
|
|
269
269
|
--diff-border--: #dedede;
|
|
270
|
-
--diff-add-content--: #
|
|
270
|
+
--diff-add-content--: #dafbe1;
|
|
271
271
|
--diff-del-content--: #ffebe9;
|
|
272
|
-
--diff-add-lineNumber--: #
|
|
273
|
-
--diff-del-lineNumber--: #
|
|
272
|
+
--diff-add-lineNumber--: #aceebb;
|
|
273
|
+
--diff-del-lineNumber--: #ffcecb;
|
|
274
274
|
--diff-plain-content--: #ffffff;
|
|
275
275
|
--diff-expand-content--: #fafafa;
|
|
276
276
|
--diff-plain-lineNumber--: #fafafa;
|
|
@@ -278,10 +278,10 @@
|
|
|
278
278
|
--diff-plain-lineNumber-color--: #555555;
|
|
279
279
|
--diff-expand-lineNumber-color--: #555555;
|
|
280
280
|
--diff-hunk-content--: #ddf4ff;
|
|
281
|
-
--diff-hunk-lineNumber--: #
|
|
281
|
+
--diff-hunk-lineNumber--: #b6e3ff;
|
|
282
282
|
--diff-hunk-lineNumber-hover--: #0969da;
|
|
283
|
-
--diff-add-content-highlight--: #
|
|
284
|
-
--diff-del-content-highlight--: #
|
|
283
|
+
--diff-add-content-highlight--: #aceebb;
|
|
284
|
+
--diff-del-content-highlight--: #ffcecb;
|
|
285
285
|
--diff-add-widget--: #0969d2;
|
|
286
286
|
--diff-add-widget-color--: #ffffff;
|
|
287
287
|
--diff-empty-content--: #fafafa;
|
|
@@ -296,10 +296,10 @@
|
|
|
296
296
|
}
|
|
297
297
|
.diff-tailwindcss-wrapper[data-theme="dark"] .diff-style-root {
|
|
298
298
|
--diff-border--: #3d444d;
|
|
299
|
-
--diff-add-content--: #
|
|
300
|
-
--diff-del-content--: #
|
|
301
|
-
--diff-add-lineNumber--: #
|
|
302
|
-
--diff-del-lineNumber--: #
|
|
299
|
+
--diff-add-content--: #18271f;
|
|
300
|
+
--diff-del-content--: #23191c;
|
|
301
|
+
--diff-add-lineNumber--: #284228;
|
|
302
|
+
--diff-del-lineNumber--: #4f2828;
|
|
303
303
|
--diff-plain-content--: #0d1117;
|
|
304
304
|
--diff-expand-content--: #161b22;
|
|
305
305
|
--diff-plain-lineNumber--: #161b22;
|
|
@@ -307,10 +307,10 @@
|
|
|
307
307
|
--diff-plain-lineNumber-color--: #a0aaab;
|
|
308
308
|
--diff-expand-lineNumber-color--: #a0aaab;
|
|
309
309
|
--diff-hunk-content--: #131d2e;
|
|
310
|
-
--diff-hunk-lineNumber--: #
|
|
310
|
+
--diff-hunk-lineNumber--: #0c2d6b;
|
|
311
311
|
--diff-hunk-lineNumber-hover--: #1f6feb;
|
|
312
|
-
--diff-add-content-highlight--: #
|
|
313
|
-
--diff-del-content-highlight--: #
|
|
312
|
+
--diff-add-content-highlight--: #2f5732;
|
|
313
|
+
--diff-del-content-highlight--: #713431;
|
|
314
314
|
--diff-add-widget--: #0969d2;
|
|
315
315
|
--diff-add-widget-color--: #ffffff;
|
|
316
316
|
--diff-empty-content--: #161b22;
|