@git-diff-view/react 0.0.26 → 0.0.28
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 +431 -290
- package/dist/cjs/index.development.js.map +1 -1
- package/dist/cjs/index.production.js +431 -290
- package/dist/cjs/index.production.js.map +1 -1
- package/dist/css/diff-view-pure.css +4 -0
- package/dist/css/diff-view.css +4 -0
- package/dist/esm/index.mjs +362 -224
- package/dist/esm/index.mjs.map +1 -1
- package/index.d.ts +303 -23
- package/package.json +4 -3
- package/src/_base.css +3 -0
- package/src/_base_pure.css +2 -0
- package/src/_com.css +172 -0
- package/src/_theme.css +2 -0
- package/src/components/DiffAddWidget.tsx +86 -0
- package/src/components/DiffContent.tsx +367 -0
- package/src/components/DiffContent_v2.tsx +344 -0
- package/src/components/DiffExpand.tsx +25 -0
- package/src/components/DiffNoNewLine.tsx +10 -0
- package/src/components/DiffSplitContentLineNormal.tsx +164 -0
- package/src/components/DiffSplitContentLineWrap.tsx +234 -0
- package/src/components/DiffSplitExtendLineNormal.tsx +150 -0
- package/src/components/DiffSplitExtendLineWrap.tsx +133 -0
- package/src/components/DiffSplitHunkLineNormal.tsx +316 -0
- package/src/components/DiffSplitHunkLineWrap.tsx +340 -0
- package/src/components/DiffSplitView.tsx +46 -0
- package/src/components/DiffSplitViewNormal.tsx +205 -0
- package/src/components/DiffSplitViewWrap.tsx +141 -0
- package/src/components/DiffSplitWidgetLineNormal.tsx +149 -0
- package/src/components/DiffSplitWidgetLineWrap.tsx +127 -0
- package/src/components/DiffUnifiedContentLine.tsx +342 -0
- package/src/components/DiffUnifiedExtendLine.tsx +103 -0
- package/src/components/DiffUnifiedHunkLine.tsx +148 -0
- package/src/components/DiffUnifiedView.tsx +159 -0
- package/src/components/DiffUnifiedWidgetLine.tsx +104 -0
- package/src/components/DiffView.tsx +365 -0
- package/src/components/DiffViewContext.ts +11 -0
- package/src/components/DiffWidgetContext.ts +17 -0
- package/src/components/tools.ts +132 -0
- package/src/components/v2/DiffSplitContentLineNormal_v2.tsx +152 -0
- package/src/components/v2/DiffSplitContentLineWrap_v2.tsx +259 -0
- package/src/components/v2/DiffSplitExtendLineNormal_v2.tsx +146 -0
- package/src/components/v2/DiffSplitExtendLineWrap_v2.tsx +123 -0
- package/src/components/v2/DiffSplitHunkLineNormal_v2.tsx +302 -0
- package/src/components/v2/DiffSplitHunkLineWrap_v2.tsx +326 -0
- package/src/components/v2/DiffSplitViewLineNormal_v2.tsx +33 -0
- package/src/components/v2/DiffSplitViewLineWrap_v2.tsx +24 -0
- package/src/components/v2/DiffSplitViewNormal_v2.tsx +159 -0
- package/src/components/v2/DiffSplitViewWrap_v2.tsx +104 -0
- package/src/components/v2/DiffSplitView_v2.tsx +47 -0
- package/src/components/v2/DiffSplitWidgetLineNormal_v2.tsx +132 -0
- package/src/components/v2/DiffSplitWidgetLineWrap_v2.tsx +119 -0
- package/src/global.d.ts +12 -0
- package/src/hooks/useCallbackRef.ts +18 -0
- package/src/hooks/useDomWidth.ts +67 -0
- package/src/hooks/useIsMounted.ts +11 -0
- package/src/hooks/useSafeLayout.ts +5 -0
- package/src/hooks/useSyncHeight.ts +87 -0
- package/src/hooks/useTextWidth.ts +27 -0
- package/src/hooks/useUnmount.ts +10 -0
- package/src/index.ts +3 -0
- package/src/tailwind.css +3 -0
- package/src/tailwind_pure.css +3 -0
- package/styles/diff-view-pure.css +4 -0
- package/styles/diff-view.css +4 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { borderColorName, emptyBGName } from "@git-diff-view/utils";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
import { SplitSide } from "../DiffView";
|
|
5
|
+
import { useDiffViewContext } from "../DiffViewContext";
|
|
6
|
+
|
|
7
|
+
import type { DiffFile } from "@git-diff-view/core";
|
|
8
|
+
|
|
9
|
+
const InternalDiffSplitExtendLine = ({
|
|
10
|
+
index,
|
|
11
|
+
diffFile,
|
|
12
|
+
lineNumber,
|
|
13
|
+
oldLineExtend,
|
|
14
|
+
newLineExtend,
|
|
15
|
+
}: {
|
|
16
|
+
index: number;
|
|
17
|
+
diffFile: DiffFile;
|
|
18
|
+
lineNumber: number;
|
|
19
|
+
oldLineExtend: { data: any };
|
|
20
|
+
newLineExtend: { data: any };
|
|
21
|
+
}) => {
|
|
22
|
+
const { useDiffContext } = useDiffViewContext();
|
|
23
|
+
|
|
24
|
+
const oldLine = diffFile.getSplitLeftLine(index);
|
|
25
|
+
|
|
26
|
+
const newLine = diffFile.getSplitRightLine(index);
|
|
27
|
+
|
|
28
|
+
// 需要显示的时候才进行方法订阅,可以大幅度提高性能
|
|
29
|
+
const renderExtendLine = useDiffContext.useShallowStableSelector((s) => s.renderExtendLine);
|
|
30
|
+
|
|
31
|
+
if (!renderExtendLine) return null;
|
|
32
|
+
|
|
33
|
+
const oldExtendRendered =
|
|
34
|
+
oldLineExtend?.data &&
|
|
35
|
+
renderExtendLine?.({
|
|
36
|
+
diffFile,
|
|
37
|
+
side: SplitSide.old,
|
|
38
|
+
lineNumber: oldLine.lineNumber,
|
|
39
|
+
data: oldLineExtend.data,
|
|
40
|
+
onUpdate: diffFile.notifyAll,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const newExtendRendered =
|
|
44
|
+
newLineExtend?.data &&
|
|
45
|
+
renderExtendLine?.({
|
|
46
|
+
diffFile,
|
|
47
|
+
side: SplitSide.new,
|
|
48
|
+
lineNumber: newLine.lineNumber,
|
|
49
|
+
data: newLineExtend.data,
|
|
50
|
+
onUpdate: diffFile.notifyAll,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div data-line={`${lineNumber}-extend`} data-state="extend" className="diff-line diff-line-extend flex">
|
|
55
|
+
{oldExtendRendered ? (
|
|
56
|
+
<div className="diff-line-extend-old-content w-[50%] p-0">
|
|
57
|
+
<div className="diff-line-extend-wrapper">{oldExtendRendered}</div>
|
|
58
|
+
</div>
|
|
59
|
+
) : (
|
|
60
|
+
<div
|
|
61
|
+
className="diff-line-extend-old-placeholder w-[50%] select-none p-0"
|
|
62
|
+
style={{ backgroundColor: `var(${emptyBGName})` }}
|
|
63
|
+
/>
|
|
64
|
+
)}
|
|
65
|
+
<div className="diff-split-line w-[1px]" style={{ backgroundColor: `var(${borderColorName})` }} />
|
|
66
|
+
{newExtendRendered ? (
|
|
67
|
+
<div className="diff-line-extend-new-content w-[50%] p-0">
|
|
68
|
+
<div className="diff-line-extend-wrapper">{newExtendRendered}</div>
|
|
69
|
+
</div>
|
|
70
|
+
) : (
|
|
71
|
+
<div
|
|
72
|
+
className="diff-line-extend-new-placeholder w-[50%] select-none p-0"
|
|
73
|
+
style={{ backgroundColor: `var(${emptyBGName})` }}
|
|
74
|
+
/>
|
|
75
|
+
)}
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export const DiffSplitExtendLine = ({
|
|
81
|
+
index,
|
|
82
|
+
diffFile,
|
|
83
|
+
lineNumber,
|
|
84
|
+
}: {
|
|
85
|
+
index: number;
|
|
86
|
+
diffFile: DiffFile;
|
|
87
|
+
lineNumber: number;
|
|
88
|
+
}) => {
|
|
89
|
+
const { useDiffContext } = useDiffViewContext();
|
|
90
|
+
|
|
91
|
+
const oldLine = diffFile.getSplitLeftLine(index);
|
|
92
|
+
|
|
93
|
+
const newLine = diffFile.getSplitRightLine(index);
|
|
94
|
+
|
|
95
|
+
const { oldLineExtend, newLineExtend } = useDiffContext(
|
|
96
|
+
React.useCallback(
|
|
97
|
+
(s) => ({
|
|
98
|
+
oldLineExtend: s.extendData?.oldFile?.[oldLine?.lineNumber],
|
|
99
|
+
newLineExtend: s.extendData?.newFile?.[newLine?.lineNumber],
|
|
100
|
+
}),
|
|
101
|
+
[oldLine?.lineNumber, newLine?.lineNumber]
|
|
102
|
+
)
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
const hasExtend = oldLineExtend?.data || newLineExtend?.data;
|
|
106
|
+
|
|
107
|
+
// if the expand action not enabled, the `isHidden` property will never change
|
|
108
|
+
const enableExpand = diffFile.getExpandEnabled();
|
|
109
|
+
|
|
110
|
+
const currentIsShow = hasExtend && ((!oldLine?.isHidden && !newLine?.isHidden) || !enableExpand);
|
|
111
|
+
|
|
112
|
+
if (!currentIsShow) return null;
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<InternalDiffSplitExtendLine
|
|
116
|
+
index={index}
|
|
117
|
+
diffFile={diffFile}
|
|
118
|
+
lineNumber={lineNumber}
|
|
119
|
+
oldLineExtend={oldLineExtend}
|
|
120
|
+
newLineExtend={newLineExtend}
|
|
121
|
+
/>
|
|
122
|
+
);
|
|
123
|
+
};
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { composeLen, type DiffFile } from "@git-diff-view/core";
|
|
2
|
+
import {
|
|
3
|
+
hunkLineNumberBGName,
|
|
4
|
+
plainLineNumberColorName,
|
|
5
|
+
hunkContentBGName,
|
|
6
|
+
hunkContentColorName,
|
|
7
|
+
diffAsideWidthName,
|
|
8
|
+
} from "@git-diff-view/utils";
|
|
9
|
+
import * as React from "react";
|
|
10
|
+
|
|
11
|
+
import { useSyncHeight } from "../../hooks/useSyncHeight";
|
|
12
|
+
import { ExpandUp, ExpandDown, ExpandAll } from "../DiffExpand";
|
|
13
|
+
import { SplitSide, DiffModeEnum } from "../DiffView";
|
|
14
|
+
import { useDiffViewContext } from "../DiffViewContext";
|
|
15
|
+
|
|
16
|
+
const InternalDiffSplitHunkLineGitHub = ({
|
|
17
|
+
index,
|
|
18
|
+
diffFile,
|
|
19
|
+
side,
|
|
20
|
+
lineNumber,
|
|
21
|
+
}: {
|
|
22
|
+
index: number;
|
|
23
|
+
side: SplitSide;
|
|
24
|
+
diffFile: DiffFile;
|
|
25
|
+
lineNumber: number;
|
|
26
|
+
}) => {
|
|
27
|
+
const currentHunk = diffFile.getSplitHunkLine(index);
|
|
28
|
+
|
|
29
|
+
const expandEnabled = diffFile.getExpandEnabled();
|
|
30
|
+
|
|
31
|
+
useSyncHeight({
|
|
32
|
+
selector: `div[data-state="hunk"][data-line="${lineNumber}-hunk"]`,
|
|
33
|
+
side: SplitSide[SplitSide.old],
|
|
34
|
+
enable: side === SplitSide.new,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const enableHunkAction = side === SplitSide.old;
|
|
38
|
+
|
|
39
|
+
const couldExpand = expandEnabled && currentHunk && currentHunk.splitInfo;
|
|
40
|
+
|
|
41
|
+
const isExpandAll =
|
|
42
|
+
currentHunk &&
|
|
43
|
+
currentHunk.splitInfo &&
|
|
44
|
+
currentHunk.splitInfo.endHiddenIndex - currentHunk.splitInfo.startHiddenIndex < composeLen;
|
|
45
|
+
|
|
46
|
+
const isFirstLine = currentHunk && currentHunk.isFirst;
|
|
47
|
+
|
|
48
|
+
const isLastLine = currentHunk && currentHunk.isLast;
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<div
|
|
52
|
+
data-line={`${lineNumber}-hunk`}
|
|
53
|
+
data-state="hunk"
|
|
54
|
+
data-side={SplitSide[side]}
|
|
55
|
+
className="diff-line diff-line-hunk flex"
|
|
56
|
+
>
|
|
57
|
+
{enableHunkAction ? (
|
|
58
|
+
<>
|
|
59
|
+
<div
|
|
60
|
+
className="diff-line-hunk-action sticky left-0 w-[1%] min-w-[40px] select-none p-[1px]"
|
|
61
|
+
style={{
|
|
62
|
+
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
63
|
+
color: `var(${plainLineNumberColorName})`,
|
|
64
|
+
width: `var(${diffAsideWidthName})`,
|
|
65
|
+
minWidth: `var(${diffAsideWidthName})`,
|
|
66
|
+
maxWidth: `var(${diffAsideWidthName})`,
|
|
67
|
+
}}
|
|
68
|
+
>
|
|
69
|
+
{couldExpand ? (
|
|
70
|
+
isFirstLine ? (
|
|
71
|
+
<button
|
|
72
|
+
className="diff-widget-tooltip flex h-full w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]"
|
|
73
|
+
title="Expand Up"
|
|
74
|
+
data-title="Expand Up"
|
|
75
|
+
onClick={() => diffFile.onSplitHunkExpand("up", index)}
|
|
76
|
+
>
|
|
77
|
+
<ExpandUp className="fill-current" />
|
|
78
|
+
</button>
|
|
79
|
+
) : isLastLine ? (
|
|
80
|
+
<button
|
|
81
|
+
className="diff-widget-tooltip relative flex h-full w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]"
|
|
82
|
+
title="Expand Down"
|
|
83
|
+
data-title="Expand Down"
|
|
84
|
+
onClick={() => {
|
|
85
|
+
diffFile.onSplitHunkExpand("down", index);
|
|
86
|
+
}}
|
|
87
|
+
>
|
|
88
|
+
<ExpandDown className="fill-current" />
|
|
89
|
+
</button>
|
|
90
|
+
) : isExpandAll ? (
|
|
91
|
+
<button
|
|
92
|
+
className="diff-widget-tooltip flex h-full w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]"
|
|
93
|
+
title="Expand All"
|
|
94
|
+
data-title="Expand All"
|
|
95
|
+
onClick={() => diffFile.onSplitHunkExpand("all", index)}
|
|
96
|
+
>
|
|
97
|
+
<ExpandAll className="fill-current" />
|
|
98
|
+
</button>
|
|
99
|
+
) : (
|
|
100
|
+
<>
|
|
101
|
+
<button
|
|
102
|
+
className="diff-widget-tooltip flex h-[50%] w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]"
|
|
103
|
+
title="Expand Down"
|
|
104
|
+
data-title="Expand Down"
|
|
105
|
+
onClick={() => diffFile.onSplitHunkExpand("down", index)}
|
|
106
|
+
>
|
|
107
|
+
<ExpandDown className="fill-current" />
|
|
108
|
+
</button>
|
|
109
|
+
<button
|
|
110
|
+
className="diff-widget-tooltip flex h-[50%] w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]"
|
|
111
|
+
title="Expand Up"
|
|
112
|
+
data-title="Expand Up"
|
|
113
|
+
onClick={() => diffFile.onSplitHunkExpand("up", index)}
|
|
114
|
+
>
|
|
115
|
+
<ExpandUp className="fill-current" />
|
|
116
|
+
</button>
|
|
117
|
+
</>
|
|
118
|
+
)
|
|
119
|
+
) : (
|
|
120
|
+
<div className="min-h-[28px]"> </div>
|
|
121
|
+
)}
|
|
122
|
+
</div>
|
|
123
|
+
<div
|
|
124
|
+
className="diff-line-hunk-content flex w-full items-center px-[10px]"
|
|
125
|
+
style={{ backgroundColor: `var(${hunkContentBGName})`, color: `var(${hunkContentColorName})` }}
|
|
126
|
+
>
|
|
127
|
+
{currentHunk.splitInfo?.plainText || currentHunk.text}
|
|
128
|
+
</div>
|
|
129
|
+
</>
|
|
130
|
+
) : (
|
|
131
|
+
<div
|
|
132
|
+
className="diff-line-hunk-placeholder w-full select-none"
|
|
133
|
+
style={{ backgroundColor: `var(${hunkContentBGName})` }}
|
|
134
|
+
/>
|
|
135
|
+
)}
|
|
136
|
+
</div>
|
|
137
|
+
);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const InternalDiffSplitHunkLineGitLab = ({
|
|
141
|
+
index,
|
|
142
|
+
diffFile,
|
|
143
|
+
side,
|
|
144
|
+
lineNumber,
|
|
145
|
+
}: {
|
|
146
|
+
index: number;
|
|
147
|
+
side: SplitSide;
|
|
148
|
+
diffFile: DiffFile;
|
|
149
|
+
lineNumber: number;
|
|
150
|
+
}) => {
|
|
151
|
+
const currentHunk = diffFile.getSplitHunkLine(index);
|
|
152
|
+
|
|
153
|
+
const expandEnabled = diffFile.getExpandEnabled();
|
|
154
|
+
|
|
155
|
+
useSyncHeight({
|
|
156
|
+
selector: `div[data-state="hunk"][data-line="${lineNumber}-hunk"]`,
|
|
157
|
+
side: SplitSide[side],
|
|
158
|
+
enable: true,
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
const couldExpand = expandEnabled && currentHunk && currentHunk.splitInfo;
|
|
162
|
+
|
|
163
|
+
const isExpandAll =
|
|
164
|
+
currentHunk &&
|
|
165
|
+
currentHunk.splitInfo &&
|
|
166
|
+
currentHunk.splitInfo.endHiddenIndex - currentHunk.splitInfo.startHiddenIndex < composeLen;
|
|
167
|
+
|
|
168
|
+
const isFirstLine = currentHunk && currentHunk.isFirst;
|
|
169
|
+
|
|
170
|
+
const isLastLine = currentHunk && currentHunk.isLast;
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<div
|
|
174
|
+
data-line={`${lineNumber}-hunk`}
|
|
175
|
+
data-state="hunk"
|
|
176
|
+
data-side={SplitSide[side]}
|
|
177
|
+
className="diff-line diff-line-hunk flex"
|
|
178
|
+
>
|
|
179
|
+
<div
|
|
180
|
+
className="diff-line-hunk-action sticky left-0 w-[1%] min-w-[40px] select-none p-[1px]"
|
|
181
|
+
style={{
|
|
182
|
+
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
183
|
+
color: `var(${plainLineNumberColorName})`,
|
|
184
|
+
width: `var(${diffAsideWidthName})`,
|
|
185
|
+
minWidth: `var(${diffAsideWidthName})`,
|
|
186
|
+
maxWidth: `var(${diffAsideWidthName})`,
|
|
187
|
+
}}
|
|
188
|
+
>
|
|
189
|
+
{couldExpand ? (
|
|
190
|
+
isFirstLine ? (
|
|
191
|
+
<button
|
|
192
|
+
className="diff-widget-tooltip flex h-full w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]"
|
|
193
|
+
title="Expand Up"
|
|
194
|
+
data-title="Expand Up"
|
|
195
|
+
onClick={() => diffFile.onSplitHunkExpand("up", index)}
|
|
196
|
+
>
|
|
197
|
+
<ExpandUp className="fill-current" />
|
|
198
|
+
</button>
|
|
199
|
+
) : isLastLine ? (
|
|
200
|
+
<button
|
|
201
|
+
className="diff-widget-tooltip relative flex h-full w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]"
|
|
202
|
+
title="Expand Down"
|
|
203
|
+
data-title="Expand Down"
|
|
204
|
+
onClick={() => {
|
|
205
|
+
diffFile.onSplitHunkExpand("down", index);
|
|
206
|
+
}}
|
|
207
|
+
>
|
|
208
|
+
<ExpandDown className="fill-current" />
|
|
209
|
+
</button>
|
|
210
|
+
) : isExpandAll ? (
|
|
211
|
+
<button
|
|
212
|
+
className="diff-widget-tooltip flex h-full w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]"
|
|
213
|
+
title="Expand All"
|
|
214
|
+
data-title="Expand All"
|
|
215
|
+
onClick={() => diffFile.onSplitHunkExpand("all", index)}
|
|
216
|
+
>
|
|
217
|
+
<ExpandAll className="fill-current" />
|
|
218
|
+
</button>
|
|
219
|
+
) : (
|
|
220
|
+
<>
|
|
221
|
+
<button
|
|
222
|
+
className="diff-widget-tooltip flex h-[50%] w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]"
|
|
223
|
+
title="Expand Down"
|
|
224
|
+
data-title="Expand Down"
|
|
225
|
+
onClick={() => diffFile.onSplitHunkExpand("down", index)}
|
|
226
|
+
>
|
|
227
|
+
<ExpandDown className="fill-current" />
|
|
228
|
+
</button>
|
|
229
|
+
<button
|
|
230
|
+
className="diff-widget-tooltip flex h-[50%] w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]"
|
|
231
|
+
title="Expand Up"
|
|
232
|
+
data-title="Expand Up"
|
|
233
|
+
onClick={() => diffFile.onSplitHunkExpand("up", index)}
|
|
234
|
+
>
|
|
235
|
+
<ExpandUp className="fill-current" />
|
|
236
|
+
</button>
|
|
237
|
+
</>
|
|
238
|
+
)
|
|
239
|
+
) : (
|
|
240
|
+
<div className="min-h-[28px]"> </div>
|
|
241
|
+
)}
|
|
242
|
+
</div>
|
|
243
|
+
<div
|
|
244
|
+
className="diff-line-hunk-content flex w-full items-center px-[10px]"
|
|
245
|
+
style={{ backgroundColor: `var(${hunkContentBGName})`, color: `var(${hunkContentColorName})` }}
|
|
246
|
+
>
|
|
247
|
+
{currentHunk.splitInfo?.plainText || currentHunk.text}
|
|
248
|
+
</div>
|
|
249
|
+
</div>
|
|
250
|
+
);
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
const InternalDiffSplitHunkLine = ({
|
|
254
|
+
index,
|
|
255
|
+
diffFile,
|
|
256
|
+
side,
|
|
257
|
+
lineNumber,
|
|
258
|
+
}: {
|
|
259
|
+
index: number;
|
|
260
|
+
side: SplitSide;
|
|
261
|
+
diffFile: DiffFile;
|
|
262
|
+
lineNumber: number;
|
|
263
|
+
}) => {
|
|
264
|
+
const { useDiffContext } = useDiffViewContext();
|
|
265
|
+
|
|
266
|
+
const diffViewMode = useDiffContext.useShallowStableSelector((s) => s.mode);
|
|
267
|
+
|
|
268
|
+
if (
|
|
269
|
+
diffViewMode === DiffModeEnum.SplitGitHub ||
|
|
270
|
+
diffViewMode === DiffModeEnum.Split ||
|
|
271
|
+
diffViewMode === DiffModeEnum.Unified
|
|
272
|
+
) {
|
|
273
|
+
return <InternalDiffSplitHunkLineGitHub index={index} diffFile={diffFile} side={side} lineNumber={lineNumber} />;
|
|
274
|
+
} else {
|
|
275
|
+
return <InternalDiffSplitHunkLineGitLab index={index} diffFile={diffFile} side={side} lineNumber={lineNumber} />;
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
export const DiffSplitHunkLine = ({
|
|
280
|
+
index,
|
|
281
|
+
diffFile,
|
|
282
|
+
side,
|
|
283
|
+
lineNumber,
|
|
284
|
+
}: {
|
|
285
|
+
index: number;
|
|
286
|
+
side: SplitSide;
|
|
287
|
+
diffFile: DiffFile;
|
|
288
|
+
lineNumber: number;
|
|
289
|
+
}) => {
|
|
290
|
+
const currentHunk = diffFile.getSplitHunkLine(index);
|
|
291
|
+
|
|
292
|
+
const currentIsShow =
|
|
293
|
+
currentHunk &&
|
|
294
|
+
currentHunk.splitInfo &&
|
|
295
|
+
currentHunk.splitInfo.startHiddenIndex < currentHunk.splitInfo.endHiddenIndex;
|
|
296
|
+
|
|
297
|
+
const currentIsPureHunk = currentHunk && diffFile._getIsPureDiffRender() && !currentHunk.splitInfo;
|
|
298
|
+
|
|
299
|
+
if (!currentIsShow && !currentIsPureHunk) return null;
|
|
300
|
+
|
|
301
|
+
return <InternalDiffSplitHunkLine index={index} diffFile={diffFile} side={side} lineNumber={lineNumber} />;
|
|
302
|
+
};
|