@git-diff-view/react 0.0.28 → 0.0.30

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/index.d.ts CHANGED
@@ -26,6 +26,7 @@ declare class File$1 {
26
26
  highlighterName?: DiffHighlighter["name"];
27
27
  highlighterType?: DiffHighlighter["type"];
28
28
  maxLineNumber: number;
29
+ enableTemplate: boolean;
29
30
  static createInstance(data: File$1): File$1;
30
31
  constructor(row: string, lang: DiffHighlighterLang, fileName?: string);
31
32
  constructor(row: string, lang: string, fileName?: string);
@@ -87,6 +88,9 @@ export declare class DiffFile {
87
88
  registerHighlighter?: Omit<DiffHighlighter, "getHighlighterEngine">;
88
89
  }): void;
89
90
  init(): void;
91
+ enableTemplate(): void;
92
+ disableTemplate(): void;
93
+ getIsEnableTemplate(): boolean;
90
94
  buildSplitDiffLines(): void;
91
95
  buildUnifiedDiffLines(): void;
92
96
  getSplitLeftLine: (index: number) => SplitLineItem;
@@ -165,6 +169,7 @@ export declare class DiffFile {
165
169
  };
166
170
  version: string;
167
171
  theme: "light" | "dark";
172
+ enableTemplate: boolean;
168
173
  isFullMerge: boolean;
169
174
  };
170
175
  mergeBundle: (data: ReturnType<DiffFile["getBundle"]>, notifyUpdate?: boolean) => void;
@@ -222,6 +227,7 @@ export declare class DiffFile {
222
227
  };
223
228
  version: string;
224
229
  theme: "light" | "dark";
230
+ enableTemplate: boolean;
225
231
  };
226
232
  _mergeFullBundle: (data: ReturnType<DiffFile["_getFullBundle"]>, notifyUpdate?: boolean) => void;
227
233
  _destroy: () => void;
@@ -787,6 +793,12 @@ export type SyntaxNode = {
787
793
  };
788
794
  children?: SyntaxNode[];
789
795
  };
796
+ export declare enum DiffModeEnum {
797
+ SplitGitHub = 1,
798
+ SplitGitLab = 2,
799
+ Split = 3,
800
+ Unified = 4
801
+ }
790
802
  declare const createDiffConfigStore: (props: DiffViewProps<any> & {
791
803
  isMounted: boolean;
792
804
  }, diffFileId: string) => import("reactivity-store").UseSelectorWithStore<{
@@ -932,12 +944,6 @@ declare const createDiffWidgetStore: (useDiffContextRef: RefObject<ReturnType<ty
932
944
  lineNumber?: number;
933
945
  }) => void;
934
946
  }>;
935
- export declare enum DiffModeEnum {
936
- SplitGitHub = 1,
937
- SplitGitLab = 2,
938
- Split = 3,
939
- Unified = 4
940
- }
941
947
  export type DiffViewProps<T> = {
942
948
  data?: {
943
949
  oldFile?: {
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.28",
6
+ "version": "0.0.30",
7
7
  "main": "index.js",
8
8
  "types": "index.d.ts",
9
9
  "files": [
@@ -61,18 +61,18 @@
61
61
  "react diff component"
62
62
  ],
63
63
  "dependencies": {
64
- "@git-diff-view/core": "^0.0.28",
64
+ "@git-diff-view/core": "^0.0.30",
65
65
  "@types/hast": "^3.0.0",
66
66
  "fast-diff": "^1.3.0",
67
67
  "highlight.js": "^11.11.0",
68
68
  "lowlight": "^3.3.0",
69
- "reactivity-store": "^0.3.10",
69
+ "reactivity-store": "^0.3.11",
70
70
  "use-sync-external-store": "^1.4.0"
71
71
  },
72
72
  "devDependencies": {
73
73
  "@types/use-sync-external-store": "^0.0.6",
74
74
  "autoprefixer": "^10.4.20",
75
- "postcss": "^8.5.1",
75
+ "postcss": "^8.5.6",
76
76
  "react": "^18.0.0",
77
77
  "tailwindcss": "^3.4.17"
78
78
  },
package/readme.md CHANGED
@@ -95,9 +95,9 @@ const diffFile = DiffFile.createInstance(data || {}, bundle);
95
95
  | extendData | a list to store the extend data to show in the `Diff View`, type: {oldFile: {lineNumber: {data: any}}, newFile: {lineNumber: {data: any}}} |
96
96
  | diffViewFontSize | the fontSize for the DiffView component, type: number |
97
97
  | diffViewHighlight | enable syntax highlight, type: boolean |
98
- | diffViewMode | the mode for the DiffView component, type: `DiffModeEnum.Split` or `DiffModeEnum.Unified` |
98
+ | diffViewMode | the mode for the DiffView component, type: `DiffModeEnum.Split` / `DiffModeEnum.Unified` |
99
99
  | diffViewWrap | enable code line auto wrap, type: boolean |
100
- | diffViewTheme | the theme for the DiffView component, type: `light` or `dark` |
100
+ | diffViewTheme | the theme for the DiffView component, type: `light` / `dark` |
101
101
  | diffViewAddWidget| enable `addWidget` button, type: boolean |
102
- | onAddWidgetClick | when the `addWidget` button clicked, type: `({ side: "old" | "new", lineNumber: number }) => void` |
102
+ | onAddWidgetClick | when the `addWidget` button clicked, type: `({ side: "old" / "new", lineNumber: number }) => void` |
103
103
 
@@ -54,23 +54,25 @@ const DiffString = ({
54
54
  operator,
55
55
  plainLine,
56
56
  enableWrap,
57
+ enableTemplate,
57
58
  }: {
58
59
  rawLine: string;
59
60
  diffLine?: DiffLine;
60
61
  operator?: "add" | "del";
61
62
  plainLine?: File["plainFile"][number];
62
63
  enableWrap?: boolean;
64
+ enableTemplate?: boolean;
63
65
  }) => {
64
66
  const changes = diffLine?.changes;
65
67
 
66
68
  if (changes?.hasLineChange) {
67
69
  const isNewLineSymbolChanged = changes.newLineSymbol;
68
70
 
69
- if (!diffLine?.plainTemplate && typeof getPlainDiffTemplate === "function") {
71
+ if (enableTemplate && !diffLine?.plainTemplate && typeof getPlainDiffTemplate === "function") {
70
72
  getPlainDiffTemplate({ diffLine, rawLine, operator });
71
73
  }
72
74
 
73
- if (diffLine?.plainTemplate) {
75
+ if (enableTemplate && diffLine?.plainTemplate) {
74
76
  return (
75
77
  <span className="diff-line-content-raw">
76
78
  <span data-template dangerouslySetInnerHTML={{ __html: diffLine.plainTemplate }} />
@@ -136,11 +138,11 @@ const DiffString = ({
136
138
  }
137
139
  }
138
140
 
139
- if (plainLine && !plainLine?.template) {
141
+ if (enableTemplate && plainLine && !plainLine?.template) {
140
142
  plainLine.template = getPlainLineTemplate(plainLine.value);
141
143
  }
142
144
 
143
- if (plainLine?.template) {
145
+ if (enableTemplate && plainLine?.template) {
144
146
  return (
145
147
  <span className="diff-line-content-raw">
146
148
  <span data-template dangerouslySetInnerHTML={{ __html: plainLine.template }} />
@@ -157,15 +159,25 @@ const DiffSyntax = ({
157
159
  operator,
158
160
  syntaxLine,
159
161
  enableWrap,
162
+ enableTemplate,
160
163
  }: {
161
164
  rawLine: string;
162
165
  diffLine?: DiffLine;
163
166
  syntaxLine?: File["syntaxFile"][number];
164
167
  operator?: "add" | "del";
165
168
  enableWrap?: boolean;
169
+ enableTemplate?: boolean;
166
170
  }) => {
167
171
  if (!syntaxLine) {
168
- return <DiffString rawLine={rawLine} diffLine={diffLine} operator={operator} />;
172
+ return (
173
+ <DiffString
174
+ rawLine={rawLine}
175
+ diffLine={diffLine}
176
+ operator={operator}
177
+ enableWrap={enableWrap}
178
+ enableTemplate={enableTemplate}
179
+ />
180
+ );
169
181
  }
170
182
 
171
183
  const changes = diffLine?.changes;
@@ -173,11 +185,11 @@ const DiffSyntax = ({
173
185
  if (changes?.hasLineChange) {
174
186
  const isNewLineSymbolChanged = changes.newLineSymbol;
175
187
 
176
- if (!diffLine?.syntaxTemplate && typeof getSyntaxDiffTemplate === "function") {
188
+ if (enableTemplate && !diffLine?.syntaxTemplate && typeof getSyntaxDiffTemplate === "function") {
177
189
  getSyntaxDiffTemplate({ diffLine, syntaxLine, operator });
178
190
  }
179
191
 
180
- if (diffLine?.syntaxTemplate) {
192
+ if (enableTemplate && diffLine?.syntaxTemplate) {
181
193
  return (
182
194
  <span className="diff-line-syntax-raw">
183
195
  <span data-template dangerouslySetInnerHTML={{ __html: diffLine.syntaxTemplate }} />
@@ -279,11 +291,11 @@ const DiffSyntax = ({
279
291
  }
280
292
  }
281
293
 
282
- if (!syntaxLine.template) {
294
+ if (enableTemplate && !syntaxLine.template) {
283
295
  syntaxLine.template = getSyntaxLineTemplate(syntaxLine);
284
296
  }
285
297
 
286
- if (syntaxLine?.template) {
298
+ if (enableTemplate && syntaxLine?.template) {
287
299
  return (
288
300
  <span className="diff-line-syntax-raw">
289
301
  <span data-template dangerouslySetInnerHTML={{ __html: syntaxLine.template }} />
@@ -310,6 +322,7 @@ const DiffSyntax = ({
310
322
 
311
323
  export const DiffContent = ({
312
324
  diffLine,
325
+ diffFile,
313
326
  rawLine,
314
327
  plainLine,
315
328
  syntaxLine,
@@ -330,6 +343,8 @@ export const DiffContent = ({
330
343
 
331
344
  const isMaxLineLengthToIgnoreSyntax = syntaxLine?.nodeList?.length > 150;
332
345
 
346
+ const isEnableTemplate = diffFile.getIsEnableTemplate?.() ?? true;
347
+
333
348
  return (
334
349
  <div
335
350
  className="diff-line-content-item pl-[2.0em]"
@@ -352,6 +367,7 @@ export const DiffContent = ({
352
367
  diffLine={diffLine}
353
368
  syntaxLine={syntaxLine}
354
369
  enableWrap={enableWrap}
370
+ enableTemplate={isEnableTemplate}
355
371
  />
356
372
  ) : (
357
373
  <DiffString
@@ -360,6 +376,7 @@ export const DiffContent = ({
360
376
  diffLine={diffLine}
361
377
  plainLine={plainLine}
362
378
  enableWrap={enableWrap}
379
+ enableTemplate={isEnableTemplate}
363
380
  />
364
381
  )}
365
382
  </div>
@@ -1,10 +1,4 @@
1
- import {
2
- DiffLineType,
3
- type DiffFile,
4
- type DiffLine,
5
- type diffChanges,
6
- type SyntaxLine,
7
- } from "@git-diff-view/core";
1
+ import { DiffLineType, type DiffFile, type DiffLine, type diffChanges, type SyntaxLine } from "@git-diff-view/core";
8
2
  import {
9
3
  addContentHighlightBGName,
10
4
  delContentHighlightBGName,
@@ -44,7 +44,7 @@ const InternalDiffSplitLine = ({
44
44
 
45
45
  const hasDiff = !!currentLine?.diff;
46
46
 
47
- const hasContent = !!currentLine.lineNumber;
47
+ const hasContent = !!currentLine?.lineNumber;
48
48
 
49
49
  const hasChange = checkDiffLineIncludeChange(currentLine?.diff);
50
50
 
@@ -78,7 +78,7 @@ const InternalDiffSplitLine = ({
78
78
  {hasContent ? (
79
79
  <>
80
80
  <td
81
- className={`diff-line-${SplitSide[side]}-num sticky left-0 w-[1%] min-w-[40px] select-none pl-[10px] pr-[10px] text-right align-top`}
81
+ className={`diff-line-${SplitSide[side]}-num sticky left-0 z-[1] w-[1%] min-w-[40px] select-none pl-[10px] pr-[10px] text-right align-top`}
82
82
  style={{
83
83
  backgroundColor: lineNumberBG,
84
84
  color: `var(${hasDiff ? plainLineNumberColorName : expandLineNumberColorName})`,
@@ -109,8 +109,8 @@ const InternalDiffSplitLine = ({
109
109
  <DiffContent
110
110
  enableWrap={false}
111
111
  diffFile={diffFile}
112
- rawLine={currentLine.value!}
113
- diffLine={currentLine.diff}
112
+ rawLine={currentLine?.value || ""}
113
+ diffLine={currentLine?.diff}
114
114
  plainLine={plainLine}
115
115
  syntaxLine={syntaxLine}
116
116
  enableHighlight={enableHighlight}
@@ -85,6 +85,8 @@ export const DiffSplitViewNormal = memo(({ diffFile }: { diffFile: DiffFile }) =
85
85
 
86
86
  const ref = useRef<HTMLStyleElement>();
87
87
 
88
+ const tempRef = useRef<SplitSide>();
89
+
88
90
  const splitLineLength = Math.max(diffFile.splitLineLength, diffFile.fileLineLength);
89
91
 
90
92
  const { useDiffContext } = useDiffViewContext();
@@ -139,13 +141,19 @@ export const DiffSplitViewNormal = memo(({ diffFile }: { diffFile: DiffFile }) =
139
141
  const state = ele.getAttribute("data-state");
140
142
  const side = ele.getAttribute("data-side");
141
143
  if (side) {
142
- setStyle(SplitSide[side]);
143
- removeAllSelection();
144
+ if (tempRef.current !== SplitSide[side]) {
145
+ tempRef.current = SplitSide[side];
146
+ setStyle(SplitSide[side]);
147
+ removeAllSelection();
148
+ }
144
149
  }
145
150
  if (state) {
146
151
  if (state === "extend" || state === "hunk" || state === "widget") {
147
- setStyle(undefined);
148
- removeAllSelection();
152
+ if (tempRef.current !== undefined) {
153
+ tempRef.current = undefined;
154
+ setStyle(undefined);
155
+ removeAllSelection();
156
+ }
149
157
  return;
150
158
  } else {
151
159
  return;
@@ -24,6 +24,8 @@ export const DiffSplitViewWrap = memo(({ diffFile }: { diffFile: DiffFile }) =>
24
24
 
25
25
  const ref = useRef<HTMLStyleElement>(null);
26
26
 
27
+ const tempRef = useRef<SplitSide>();
28
+
27
29
  const { fontSize, enableAddWidget, enableHighlight } = useDiffContext.useShallowStableSelector((s) => ({
28
30
  fontSize: s.fontSize,
29
31
  enableAddWidget: s.enableAddWidget,
@@ -67,13 +69,19 @@ export const DiffSplitViewWrap = memo(({ diffFile }: { diffFile: DiffFile }) =>
67
69
  const state = ele.getAttribute("data-state");
68
70
  const side = ele.getAttribute("data-side");
69
71
  if (side) {
70
- setStyle(SplitSide[side]);
71
- removeAllSelection();
72
+ if (tempRef.current !== SplitSide[side]) {
73
+ tempRef.current = SplitSide[side];
74
+ setStyle(SplitSide[side]);
75
+ removeAllSelection();
76
+ }
72
77
  }
73
78
  if (state) {
74
79
  if (state === "extend" || state === "hunk" || state === "widget") {
75
- setStyle(undefined);
76
- removeAllSelection();
80
+ if (tempRef.current !== undefined) {
81
+ tempRef.current = undefined;
82
+ setStyle(undefined);
83
+ removeAllSelection();
84
+ }
77
85
  return;
78
86
  } else {
79
87
  return;
@@ -29,7 +29,7 @@ const InternalDiffSplitWidgetLine = ({
29
29
 
30
30
  const newLine = diffFile.getSplitRightLine(index);
31
31
 
32
- const widgetSide = useWidget.getReadonlyState().widgetSide;
32
+ const widgetSide = useWidget.useShallowStableSelector((s) => s.widgetSide);
33
33
 
34
34
  const widgetLineNumber = useWidget.getReadonlyState().widgetLineNumber;
35
35
 
@@ -29,7 +29,7 @@ const InternalDiffSplitWidgetLine = ({
29
29
 
30
30
  const newLine = diffFile.getSplitRightLine(index);
31
31
 
32
- const widgetSide = useWidget.getReadonlyState().widgetSide;
32
+ const widgetSide = useWidget.useShallowStableSelector((s) => s.widgetSide);
33
33
 
34
34
  const widgetLineNumber = useWidget.getReadonlyState().widgetLineNumber;
35
35
 
@@ -53,7 +53,7 @@ const DiffUnifiedOldLine = ({
53
53
  return (
54
54
  <tr data-line={index} data-state="diff" className="diff-line group">
55
55
  <td
56
- className="diff-line-num sticky left-0 w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top"
56
+ className="diff-line-num sticky left-0 z-[1] w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top"
57
57
  style={{
58
58
  color: `var(${plainLineNumberColorName})`,
59
59
  backgroundColor: `var(${delLineNumberBGName})`,
@@ -125,7 +125,7 @@ const DiffUnifiedNewLine = ({
125
125
  return (
126
126
  <tr data-line={index} data-state="diff" className="diff-line group">
127
127
  <td
128
- className="diff-line-num sticky left-0 w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top"
128
+ className="diff-line-num sticky left-0 z-[1] w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top"
129
129
  style={{
130
130
  color: `var(${plainLineNumberColorName})`,
131
131
  backgroundColor: `var(${addLineNumberBGName})`,
@@ -257,7 +257,7 @@ const _DiffUnifiedLine = memo(
257
257
  return (
258
258
  <tr data-line={lineNumber} data-state={unifiedLine.diff ? "diff" : "plain"} className="diff-line group">
259
259
  <td
260
- className="diff-line-num sticky left-0 w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top"
260
+ className="diff-line-num sticky left-0 z-[1] w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top"
261
261
  style={{
262
262
  color: `var(${hasDiff ? plainLineNumberColorName : expandLineNumberColorName})`,
263
263
  width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
@@ -23,6 +23,8 @@ export const DiffUnifiedView = memo(({ diffFile }: { diffFile: DiffFile }) => {
23
23
 
24
24
  const ref = useRef<HTMLStyleElement>(null);
25
25
 
26
+ const tempRef = useRef<SplitSide>();
27
+
26
28
  const useDiffContextRef = useRef(useDiffContext);
27
29
 
28
30
  useDiffContextRef.current = useDiffContext;
@@ -87,12 +89,18 @@ export const DiffUnifiedView = memo(({ diffFile }: { diffFile: DiffFile }) => {
87
89
  const state = ele.getAttribute("data-state");
88
90
  if (state) {
89
91
  if (state === "extend" || state === "hunk" || state === "widget") {
90
- setStyle(undefined);
91
- removeAllSelection();
92
+ if (tempRef.current !== undefined) {
93
+ tempRef.current = undefined;
94
+ setStyle(undefined);
95
+ removeAllSelection();
96
+ }
92
97
  return;
93
98
  } else {
94
- setStyle(SplitSide.new);
95
- removeAllSelection();
99
+ if (tempRef.current !== SplitSide.new) {
100
+ tempRef.current = SplitSide.new;
101
+ setStyle(SplitSide.new);
102
+ removeAllSelection();
103
+ }
96
104
  return;
97
105
  }
98
106
  }
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */
2
2
  /* eslint-disable @typescript-eslint/ban-ts-comment */
3
3
  import { DiffFile, _cacheMap, SplitSide } from "@git-diff-view/core";
4
- import { diffFontSizeName } from "@git-diff-view/utils";
4
+ import { diffFontSizeName, DiffModeEnum } from "@git-diff-view/utils";
5
5
  import { memo, useEffect, useMemo, forwardRef, useImperativeHandle, useRef } from "react";
6
6
  import * as React from "react";
7
7
 
@@ -16,20 +16,11 @@ import { createDiffConfigStore } from "./tools";
16
16
 
17
17
  import type { createDiffWidgetStore } from "./tools";
18
18
  import type { DiffHighlighter, DiffHighlighterLang } from "@git-diff-view/core";
19
- import type { CSSProperties, ForwardedRef, ReactNode } from "react";
19
+ import type { CSSProperties, ForwardedRef, ReactNode, RefObject } from "react";
20
20
 
21
21
  _cacheMap.name = "@git-diff-view/react";
22
22
 
23
- export { SplitSide };
24
-
25
- export enum DiffModeEnum {
26
- // github like
27
- SplitGitHub = 1,
28
- // gitlab like
29
- SplitGitLab = 2,
30
- Split = 1 | 2,
31
- Unified = 4,
32
- }
23
+ export { SplitSide, DiffModeEnum };
33
24
 
34
25
  export type DiffViewProps<T> = {
35
26
  data?: {
@@ -97,12 +88,16 @@ type DiffViewProps_2<T> = Omit<DiffViewProps<T>, "data"> & {
97
88
  };
98
89
 
99
90
  const InternalDiffView = <T extends unknown>(
100
- props: Omit<DiffViewProps<T>, "data" | "registerHighlighter"> & { isMounted: boolean }
91
+ props: Omit<DiffViewProps<T>, "data" | "registerHighlighter"> & {
92
+ isMounted: boolean;
93
+ wrapperRef?: RefObject<HTMLDivElement>;
94
+ }
101
95
  ) => {
102
96
  const {
103
97
  diffFile,
104
98
  className,
105
99
  style,
100
+ wrapperRef,
106
101
  diffViewMode,
107
102
  diffViewWrap,
108
103
  diffViewFontSize,
@@ -118,8 +113,6 @@ const InternalDiffView = <T extends unknown>(
118
113
 
119
114
  const diffFileId = useMemo(() => diffFile.getId(), [diffFile]);
120
115
 
121
- const wrapperRef = useRef<HTMLDivElement>();
122
-
123
116
  // performance optimization
124
117
  const useDiffContext = useMemo(
125
118
  () => createDiffConfigStore(props, diffFileId),
@@ -217,15 +210,6 @@ const InternalDiffView = <T extends unknown>(
217
210
  onCreateUseWidgetHook,
218
211
  ]);
219
212
 
220
- useEffect(() => {
221
- const cb = diffFile.subscribe(() => {
222
- wrapperRef.current?.setAttribute("data-theme", diffFile._getTheme() || "light");
223
- wrapperRef.current?.setAttribute("data-highlighter", diffFile._getHighlighterName());
224
- });
225
-
226
- return cb;
227
- }, [diffFile]);
228
-
229
213
  const value = useMemo(() => ({ useDiffContext }), [useDiffContext]);
230
214
 
231
215
  return (
@@ -294,6 +278,8 @@ const DiffViewWithRef = <T extends unknown>(
294
278
 
295
279
  const diffFileRef = useRef(diffFile);
296
280
 
281
+ const wrapperRef = useRef<HTMLDivElement>();
282
+
297
283
  if (diffFileRef.current && diffFileRef.current !== diffFile) {
298
284
  diffFileRef.current.clear?.();
299
285
  diffFileRef.current = diffFile;
@@ -320,11 +306,27 @@ const DiffViewWithRef = <T extends unknown>(
320
306
 
321
307
  useEffect(() => {
322
308
  if (!diffFile) return;
309
+
323
310
  if (props.diffViewHighlight) {
324
311
  diffFile.initSyntax({ registerHighlighter });
325
312
  diffFile.notifyAll();
326
313
  }
327
- }, [diffFile, props.diffViewHighlight, registerHighlighter, diffViewTheme]);
314
+ }, [diffFile, props.diffViewHighlight, registerHighlighter]);
315
+
316
+ useEffect(() => {
317
+ if (!diffFile) return;
318
+
319
+ const init = () => {
320
+ wrapperRef.current?.setAttribute("data-theme", diffFile._getTheme() || "light");
321
+ wrapperRef.current?.setAttribute("data-highlighter", diffFile._getHighlighterName());
322
+ };
323
+
324
+ init();
325
+
326
+ const cb = diffFile.subscribe(init);
327
+
328
+ return cb;
329
+ }, [diffFile, diffViewTheme]);
328
330
 
329
331
  // fix react strict mode error
330
332
  useUnmount(() => (__DEV__ ? diffFile?._destroy?.() : diffFile?.clear?.()), [diffFile]);
@@ -339,6 +341,8 @@ const DiffViewWithRef = <T extends unknown>(
339
341
  {...restProps}
340
342
  diffFile={diffFile}
341
343
  isMounted={isMounted}
344
+ wrapperRef={wrapperRef}
345
+ diffViewTheme={diffViewTheme}
342
346
  diffViewMode={restProps.diffViewMode || DiffModeEnum.SplitGitHub}
343
347
  diffViewFontSize={restProps.diffViewFontSize || 14}
344
348
  />
@@ -76,7 +76,7 @@ const InternalDiffSplitLine = ({
76
76
  {hasContent ? (
77
77
  <>
78
78
  <div
79
- className={`diff-line-${SplitSide[side]}-num sticky left-0 flex w-[1%] min-w-[40px] select-none items-center px-[10px] text-right`}
79
+ className={`diff-line-${SplitSide[side]}-num sticky left-0 z-[1] flex w-[1%] min-w-[40px] select-none items-center px-[10px] text-right`}
80
80
  style={{
81
81
  backgroundColor: lineNumberBG,
82
82
  color: `var(${hasDiff ? plainLineNumberColorName : expandLineNumberColorName})`,