@git-diff-view/react 0.0.36 → 0.0.38
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 +36 -109
- package/dist/cjs/index.development.js.map +1 -1
- package/dist/cjs/index.production.js +36 -109
- package/dist/cjs/index.production.js.map +1 -1
- package/dist/css/diff-view-pure.css +0 -3
- package/dist/css/diff-view.css +0 -3
- package/dist/esm/index.mjs +37 -110
- package/dist/esm/index.mjs.map +1 -1
- package/index.d.ts +12 -9
- package/package.json +2 -2
- package/src/components/DiffContent.tsx +15 -161
- package/src/components/DiffUnifiedContentLine.tsx +117 -122
- package/src/components/DiffView.tsx +14 -5
- package/styles/diff-view-pure.css +0 -3
- package/styles/diff-view.css +0 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */
|
|
2
2
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
3
|
-
import { DiffFile, _cacheMap, SplitSide } from "@git-diff-view/core";
|
|
3
|
+
import { DiffFile, _cacheMap, SplitSide, highlighter as buildInHighlighter } from "@git-diff-view/core";
|
|
4
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";
|
|
@@ -315,10 +315,19 @@ const DiffViewWithRef = <T extends unknown>(
|
|
|
315
315
|
if (!diffFile) return;
|
|
316
316
|
|
|
317
317
|
if (props.diffViewHighlight) {
|
|
318
|
-
|
|
318
|
+
const finalHighlighter = registerHighlighter || buildInHighlighter;
|
|
319
|
+
|
|
320
|
+
if (
|
|
321
|
+
finalHighlighter.name !== diffFile._getHighlighterName() ||
|
|
322
|
+
finalHighlighter.type !== diffFile._getHighlighterType()
|
|
323
|
+
) {
|
|
324
|
+
diffFile.initSyntax({ registerHighlighter: finalHighlighter });
|
|
325
|
+
diffFile.notifyAll();
|
|
326
|
+
} else {
|
|
327
|
+
diffFile.initSyntax({ registerHighlighter: finalHighlighter });
|
|
328
|
+
if (finalHighlighter.type !== "class") diffFile.notifyAll();
|
|
329
|
+
}
|
|
319
330
|
}
|
|
320
|
-
|
|
321
|
-
diffFile.notifyAll();
|
|
322
331
|
}, [diffFile, props.diffViewHighlight, registerHighlighter, diffViewTheme]);
|
|
323
332
|
|
|
324
333
|
useEffect(() => {
|
|
@@ -334,7 +343,7 @@ const DiffViewWithRef = <T extends unknown>(
|
|
|
334
343
|
const cb = diffFile.subscribe(init);
|
|
335
344
|
|
|
336
345
|
return cb;
|
|
337
|
-
}, [diffFile]);
|
|
346
|
+
}, [diffFile, diffViewTheme]);
|
|
338
347
|
|
|
339
348
|
// fix react strict mode error
|
|
340
349
|
useUnmount(() => (__DEV__ ? diffFile?._destroy?.() : diffFile?.clear?.()), [diffFile]);
|
package/styles/diff-view.css
CHANGED