@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.
@@ -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
- diffFile.initSyntax({ registerHighlighter });
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]);
@@ -187,9 +187,6 @@
187
187
  .diff-tailwindcss-wrapper .break-all {
188
188
  word-break: break-all;
189
189
  }
190
- .diff-tailwindcss-wrapper .rounded-\[0\.2em\] {
191
- border-radius: 0.2em;
192
- }
193
190
  .diff-tailwindcss-wrapper .rounded-\[2px\] {
194
191
  border-radius: 2px;
195
192
  }
@@ -187,9 +187,6 @@
187
187
  .diff-tailwindcss-wrapper .break-all {
188
188
  word-break: break-all;
189
189
  }
190
- .diff-tailwindcss-wrapper .rounded-\[0\.2em\] {
191
- border-radius: 0.2em;
192
- }
193
190
  .diff-tailwindcss-wrapper .rounded-\[2px\] {
194
191
  border-radius: 2px;
195
192
  }