@git-diff-view/react 0.0.30 → 0.0.32
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 +63 -30
- package/dist/cjs/index.development.js.map +1 -1
- package/dist/cjs/index.production.js +63 -30
- package/dist/cjs/index.production.js.map +1 -1
- package/dist/css/diff-view-pure.css +6 -9
- package/dist/css/diff-view.css +6 -9
- package/dist/esm/index.mjs +63 -30
- package/dist/esm/index.mjs.map +1 -1
- package/index.d.ts +23 -4
- package/package.json +2 -2
- package/src/_com.css +4 -0
- package/src/components/DiffAddWidget.tsx +3 -1
- package/src/components/DiffSplitContentLineNormal.tsx +0 -1
- package/src/components/DiffSplitContentLineWrap.tsx +4 -2
- package/src/components/DiffSplitViewNormal.tsx +1 -1
- package/src/components/DiffSplitViewWrap.tsx +1 -1
- package/src/components/DiffUnifiedExtendLine.tsx +9 -3
- package/src/components/DiffUnifiedView.tsx +13 -3
- package/src/components/DiffUnifiedWidgetLine.tsx +10 -4
- package/src/components/DiffView.tsx +12 -4
- package/src/components/tools.ts +6 -0
- package/src/components/v2/DiffSplitViewNormal_v2.tsx +22 -4
- package/src/hooks/useDomWidth.ts +10 -3
- package/src/hooks/useSyncHeight.ts +10 -3
- package/styles/diff-view-pure.css +6 -9
- package/styles/diff-view.css +6 -9
- package/src/components/DiffContent_v2.tsx +0 -338
|
@@ -50,9 +50,6 @@
|
|
|
50
50
|
.diff-tailwindcss-wrapper .top-0 {
|
|
51
51
|
top: 0px;
|
|
52
52
|
}
|
|
53
|
-
.diff-tailwindcss-wrapper .top-\[1px\] {
|
|
54
|
-
top: 1px;
|
|
55
|
-
}
|
|
56
53
|
.diff-tailwindcss-wrapper .top-\[50\%\] {
|
|
57
54
|
top: 50%;
|
|
58
55
|
}
|
|
@@ -155,6 +152,9 @@
|
|
|
155
152
|
--tw-translate-y: -50%;
|
|
156
153
|
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
157
154
|
}
|
|
155
|
+
.diff-tailwindcss-wrapper .transform {
|
|
156
|
+
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
157
|
+
}
|
|
158
158
|
.diff-tailwindcss-wrapper .cursor-pointer {
|
|
159
159
|
cursor: pointer;
|
|
160
160
|
}
|
|
@@ -247,9 +247,6 @@
|
|
|
247
247
|
.diff-tailwindcss-wrapper .text-\[1\.2em\] {
|
|
248
248
|
font-size: 1.2em;
|
|
249
249
|
}
|
|
250
|
-
.diff-tailwindcss-wrapper .leading-\[1\.4\] {
|
|
251
|
-
line-height: 1.4;
|
|
252
|
-
}
|
|
253
250
|
.diff-tailwindcss-wrapper .leading-\[1\.6\] {
|
|
254
251
|
line-height: 1.6;
|
|
255
252
|
}
|
|
@@ -260,9 +257,6 @@
|
|
|
260
257
|
.diff-tailwindcss-wrapper .opacity-\[0\.5\] {
|
|
261
258
|
opacity: 0.5;
|
|
262
259
|
}
|
|
263
|
-
.diff-tailwindcss-wrapper .filter {
|
|
264
|
-
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
|
|
265
|
-
}
|
|
266
260
|
.diff-tailwindcss-wrapper .transition-transform {
|
|
267
261
|
transition-property: transform;
|
|
268
262
|
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
@@ -335,6 +329,9 @@
|
|
|
335
329
|
border-width: 0px;
|
|
336
330
|
text-align: left;
|
|
337
331
|
}
|
|
332
|
+
.diff-tailwindcss-wrapper td {
|
|
333
|
+
padding: 0;
|
|
334
|
+
}
|
|
338
335
|
.diff-tailwindcss-wrapper .diff-line-old-num,
|
|
339
336
|
.diff-tailwindcss-wrapper .diff-line-new-num,
|
|
340
337
|
.diff-tailwindcss-wrapper .diff-line-num {
|
package/dist/css/diff-view.css
CHANGED
|
@@ -556,9 +556,6 @@ video {
|
|
|
556
556
|
.diff-tailwindcss-wrapper .top-0 {
|
|
557
557
|
top: 0px;
|
|
558
558
|
}
|
|
559
|
-
.diff-tailwindcss-wrapper .top-\[1px\] {
|
|
560
|
-
top: 1px;
|
|
561
|
-
}
|
|
562
559
|
.diff-tailwindcss-wrapper .top-\[50\%\] {
|
|
563
560
|
top: 50%;
|
|
564
561
|
}
|
|
@@ -661,6 +658,9 @@ video {
|
|
|
661
658
|
--tw-translate-y: -50%;
|
|
662
659
|
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
663
660
|
}
|
|
661
|
+
.diff-tailwindcss-wrapper .transform {
|
|
662
|
+
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
663
|
+
}
|
|
664
664
|
.diff-tailwindcss-wrapper .cursor-pointer {
|
|
665
665
|
cursor: pointer;
|
|
666
666
|
}
|
|
@@ -753,9 +753,6 @@ video {
|
|
|
753
753
|
.diff-tailwindcss-wrapper .text-\[1\.2em\] {
|
|
754
754
|
font-size: 1.2em;
|
|
755
755
|
}
|
|
756
|
-
.diff-tailwindcss-wrapper .leading-\[1\.4\] {
|
|
757
|
-
line-height: 1.4;
|
|
758
|
-
}
|
|
759
756
|
.diff-tailwindcss-wrapper .leading-\[1\.6\] {
|
|
760
757
|
line-height: 1.6;
|
|
761
758
|
}
|
|
@@ -766,9 +763,6 @@ video {
|
|
|
766
763
|
.diff-tailwindcss-wrapper .opacity-\[0\.5\] {
|
|
767
764
|
opacity: 0.5;
|
|
768
765
|
}
|
|
769
|
-
.diff-tailwindcss-wrapper .filter {
|
|
770
|
-
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
|
|
771
|
-
}
|
|
772
766
|
.diff-tailwindcss-wrapper .transition-transform {
|
|
773
767
|
transition-property: transform;
|
|
774
768
|
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
@@ -841,6 +835,9 @@ video {
|
|
|
841
835
|
border-width: 0px;
|
|
842
836
|
text-align: left;
|
|
843
837
|
}
|
|
838
|
+
.diff-tailwindcss-wrapper td {
|
|
839
|
+
padding: 0;
|
|
840
|
+
}
|
|
844
841
|
.diff-tailwindcss-wrapper .diff-line-old-num,
|
|
845
842
|
.diff-tailwindcss-wrapper .diff-line-new-num,
|
|
846
843
|
.diff-tailwindcss-wrapper .diff-line-num {
|
package/dist/esm/index.mjs
CHANGED
|
@@ -186,6 +186,16 @@ const syncScroll = (left, right) => {
|
|
|
186
186
|
right.onscroll = null;
|
|
187
187
|
};
|
|
188
188
|
};
|
|
189
|
+
const getElementRoot = (element) => {
|
|
190
|
+
if (element) {
|
|
191
|
+
const root = element.getRootNode();
|
|
192
|
+
if (root instanceof ShadowRoot) {
|
|
193
|
+
return root;
|
|
194
|
+
}
|
|
195
|
+
return element.ownerDocument;
|
|
196
|
+
}
|
|
197
|
+
return document;
|
|
198
|
+
};
|
|
189
199
|
|
|
190
200
|
const diffFontSizeName = "--diff-font-size--";
|
|
191
201
|
const diffAsideWidthName = "--diff-aside-width--";
|
|
@@ -271,6 +281,7 @@ const DiffSplitAddWidget = ({ side, className, lineNumber, onWidgetClick, onOpen
|
|
|
271
281
|
(className ? " " + className : ""), style: {
|
|
272
282
|
width: `calc(var(${diffFontSizeName}) * 1.4)`,
|
|
273
283
|
height: `calc(var(${diffFontSizeName}) * 1.4)`,
|
|
284
|
+
top: `calc(var(${diffFontSizeName}) * 0.1)`,
|
|
274
285
|
} },
|
|
275
286
|
React.createElement("button", { className: "diff-add-widget z-[1] flex h-full w-full origin-center cursor-pointer items-center justify-center rounded-md text-[1.2em]", style: {
|
|
276
287
|
color: `var(${addWidgetColorName})`,
|
|
@@ -281,9 +292,10 @@ const DiffSplitAddWidget = ({ side, className, lineNumber, onWidgetClick, onOpen
|
|
|
281
292
|
} }, "+")));
|
|
282
293
|
};
|
|
283
294
|
const DiffUnifiedAddWidget = ({ lineNumber, side, onWidgetClick, onOpenAddWidget, }) => {
|
|
284
|
-
return (React.createElement("div", { className: "diff-add-widget-wrapper invisible absolute left-[100%]
|
|
295
|
+
return (React.createElement("div", { className: "diff-add-widget-wrapper invisible absolute left-[100%] translate-x-[-50%] select-none transition-transform hover:scale-110 group-hover:visible", style: {
|
|
285
296
|
width: `calc(var(${diffFontSizeName}) * 1.4)`,
|
|
286
297
|
height: `calc(var(${diffFontSizeName}) * 1.4)`,
|
|
298
|
+
top: `calc(var(${diffFontSizeName}) * 0.1)`,
|
|
287
299
|
} },
|
|
288
300
|
React.createElement("button", { className: "diff-add-widget z-[1] flex h-full w-full origin-center cursor-pointer items-center justify-center rounded-md text-[1.2em]", style: {
|
|
289
301
|
color: `var(${addWidgetColorName})`,
|
|
@@ -519,10 +531,15 @@ const DiffSplitContentLine$1 = ({ index, diffFile, lineNumber, side, enableAddWi
|
|
|
519
531
|
const useDomWidth = ({ selector, enable }) => {
|
|
520
532
|
const [width, setWidth] = useState(0);
|
|
521
533
|
const { useDiffContext } = useDiffViewContext();
|
|
522
|
-
const { id, mounted } = useDiffContext.useShallowStableSelector((s) => ({
|
|
534
|
+
const { id, mounted, dom } = useDiffContext.useShallowStableSelector((s) => ({
|
|
535
|
+
id: s.id,
|
|
536
|
+
mounted: s.mounted,
|
|
537
|
+
dom: s.dom,
|
|
538
|
+
}));
|
|
523
539
|
useEffect(() => {
|
|
524
540
|
if (enable) {
|
|
525
|
-
const
|
|
541
|
+
const rootDocument = getElementRoot(dom);
|
|
542
|
+
const container = rootDocument.querySelector(`#diff-root${id}`);
|
|
526
543
|
const wrapper = container === null || container === void 0 ? void 0 : container.querySelector(selector);
|
|
527
544
|
if (!wrapper)
|
|
528
545
|
return;
|
|
@@ -555,16 +572,21 @@ const useDomWidth = ({ selector, enable }) => {
|
|
|
555
572
|
typedWrapper.setAttribute("data-observe", "height");
|
|
556
573
|
return () => cleanCb();
|
|
557
574
|
}
|
|
558
|
-
}, [selector, enable, id, mounted]);
|
|
575
|
+
}, [selector, enable, id, mounted, dom]);
|
|
559
576
|
return width;
|
|
560
577
|
};
|
|
561
578
|
|
|
562
579
|
const useSyncHeight = ({ selector, wrapper, side, enable, }) => {
|
|
563
580
|
const { useDiffContext } = useDiffViewContext();
|
|
564
|
-
const { id, mounted } = useDiffContext.useShallowStableSelector((s) => ({
|
|
581
|
+
const { id, mounted, dom } = useDiffContext.useShallowStableSelector((s) => ({
|
|
582
|
+
id: s.id,
|
|
583
|
+
mounted: s.mounted,
|
|
584
|
+
dom: s.dom,
|
|
585
|
+
}));
|
|
565
586
|
useEffect(() => {
|
|
566
587
|
if (enable) {
|
|
567
|
-
const
|
|
588
|
+
const rootDocument = getElementRoot(dom);
|
|
589
|
+
const container = rootDocument.querySelector(`#diff-root${id}`);
|
|
568
590
|
const elements = Array.from((container === null || container === void 0 ? void 0 : container.querySelectorAll(selector)) || []);
|
|
569
591
|
const wrappers = wrapper ? Array.from((container === null || container === void 0 ? void 0 : container.querySelectorAll(wrapper)) || []) : elements;
|
|
570
592
|
if (elements.length === 2 && wrappers.length === 2) {
|
|
@@ -609,7 +631,7 @@ const useSyncHeight = ({ selector, wrapper, side, enable, }) => {
|
|
|
609
631
|
return () => cleanCb();
|
|
610
632
|
}
|
|
611
633
|
}
|
|
612
|
-
}, [selector, enable, side, id, wrapper, mounted]);
|
|
634
|
+
}, [selector, enable, side, id, wrapper, mounted, dom]);
|
|
613
635
|
};
|
|
614
636
|
|
|
615
637
|
const InternalDiffSplitExtendLine$1 = ({ index, diffFile, oldLineExtend, newLineExtend, side, lineNumber, }) => {
|
|
@@ -848,7 +870,7 @@ const DiffSplitViewTable = ({ side, diffFile, enableAddWidget, enableHighlight,
|
|
|
848
870
|
React.createElement("th", { scope: "col" },
|
|
849
871
|
SplitSide[side],
|
|
850
872
|
" line content"))),
|
|
851
|
-
React.createElement("tbody", { className: "diff-table-body leading-[1.
|
|
873
|
+
React.createElement("tbody", { className: "diff-table-body leading-[1.6]", onMouseDownCapture: onMouseDown },
|
|
852
874
|
lines.map((line) => (React.createElement(Fragment, { key: line.index },
|
|
853
875
|
React.createElement(DiffSplitHunkLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile }),
|
|
854
876
|
React.createElement(DiffSplitContentLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile, enableAddWidget: enableAddWidget, enableHighlight: enableHighlight }),
|
|
@@ -972,7 +994,10 @@ const InternalDiffSplitLine = ({ index, diffFile, lineNumber, enableAddWidget, e
|
|
|
972
994
|
const newLineNumberBG = getLineNumberBG(newLineIsAdded, false, hasDiff);
|
|
973
995
|
return (React.createElement("tr", { "data-line": lineNumber, "data-state": hasDiff ? "diff" : "plain", className: "diff-line" },
|
|
974
996
|
hasOldLine ? (React.createElement(React.Fragment, null,
|
|
975
|
-
React.createElement("td", { className: "diff-line-old-num group relative w-[1%] min-w-[40px] select-none pl-[10px] pr-[10px] text-right align-top", "data-side": SplitSide[SplitSide.old], style: {
|
|
997
|
+
React.createElement("td", { className: "diff-line-old-num group relative w-[1%] min-w-[40px] select-none pl-[10px] pr-[10px] text-right align-top", "data-side": SplitSide[SplitSide.old], style: {
|
|
998
|
+
backgroundColor: oldLineNumberBG,
|
|
999
|
+
color: `var(${hasDiff ? plainLineNumberColorName : expandLineNumberColorName})`,
|
|
1000
|
+
} },
|
|
976
1001
|
hasDiff && enableAddWidget && (React.createElement(DiffSplitAddWidget, { index: index, lineNumber: oldLine.lineNumber, side: SplitSide.old, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute left-[100%] z-[1] translate-x-[-50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
|
|
977
1002
|
React.createElement("span", { "data-line-num": oldLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 } }, oldLine.lineNumber)),
|
|
978
1003
|
React.createElement("td", { className: "diff-line-old-content group relative pr-[10px] align-top", "data-side": SplitSide[SplitSide.old], style: { backgroundColor: oldLineContentBG } },
|
|
@@ -1282,7 +1307,7 @@ const DiffSplitViewWrap = memo(({ diffFile }) => {
|
|
|
1282
1307
|
React.createElement("th", { scope: "col" }, "old line content"),
|
|
1283
1308
|
React.createElement("th", { scope: "col" }, "new line number"),
|
|
1284
1309
|
React.createElement("th", { scope: "col" }, "new line content"))),
|
|
1285
|
-
React.createElement("tbody", { className: "diff-table-body leading-[1.
|
|
1310
|
+
React.createElement("tbody", { className: "diff-table-body leading-[1.6]", onMouseDownCapture: onMouseDown },
|
|
1286
1311
|
lines.map((line) => (React.createElement(Fragment, { key: line.index },
|
|
1287
1312
|
React.createElement(DiffSplitHunkLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile }),
|
|
1288
1313
|
React.createElement(DiffSplitContentLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile, enableAddWidget: enableAddWidget, enableHighlight: enableHighlight }),
|
|
@@ -1295,6 +1320,8 @@ DiffSplitViewWrap.displayName = "DiffSplitViewWrap";
|
|
|
1295
1320
|
const createDiffConfigStore = (props, diffFileId) => {
|
|
1296
1321
|
return createStore(() => {
|
|
1297
1322
|
var _a, _b;
|
|
1323
|
+
const dom = ref();
|
|
1324
|
+
const setDom = (_dom) => (dom.value = _dom);
|
|
1298
1325
|
const id = ref(diffFileId);
|
|
1299
1326
|
const setId = (_id) => (id.value = _id);
|
|
1300
1327
|
const mode = ref(props.diffViewMode);
|
|
@@ -1347,6 +1374,8 @@ const createDiffConfigStore = (props, diffFileId) => {
|
|
|
1347
1374
|
return {
|
|
1348
1375
|
id,
|
|
1349
1376
|
setId,
|
|
1377
|
+
dom,
|
|
1378
|
+
setDom,
|
|
1350
1379
|
mode,
|
|
1351
1380
|
setMode,
|
|
1352
1381
|
mounted,
|
|
@@ -1502,20 +1531,21 @@ const DiffUnifiedContentLine = ({ index, diffFile, lineNumber, enableWrap, enabl
|
|
|
1502
1531
|
return (React.createElement(_DiffUnifiedLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, enableWrap: enableWrap, enableHighlight: enableHighlight, enableAddWidget: enableAddWidget }));
|
|
1503
1532
|
};
|
|
1504
1533
|
|
|
1505
|
-
const InternalDiffUnifiedExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newLineExtend, }) => {
|
|
1534
|
+
const InternalDiffUnifiedExtendLine = ({ index, diffFile, lineNumber, enableWrap, oldLineExtend, newLineExtend, }) => {
|
|
1506
1535
|
const { useDiffContext } = useDiffViewContext();
|
|
1507
1536
|
const renderExtendLine = useDiffContext.useShallowStableSelector((s) => s.renderExtendLine);
|
|
1508
1537
|
const unifiedItem = diffFile.getUnifiedLine(index);
|
|
1538
|
+
// TODO use css variable to get width
|
|
1509
1539
|
const width = useDomWidth({
|
|
1510
1540
|
selector: ".unified-diff-table-wrapper",
|
|
1511
|
-
enable: typeof renderExtendLine === "function",
|
|
1541
|
+
enable: typeof renderExtendLine === "function" && !enableWrap,
|
|
1512
1542
|
});
|
|
1513
1543
|
if (!renderExtendLine)
|
|
1514
1544
|
return null;
|
|
1515
1545
|
return (React.createElement("tr", { "data-line": `${lineNumber}-extend`, "data-state": "extend", className: "diff-line diff-line-extend" },
|
|
1516
1546
|
React.createElement("td", { className: "diff-line-extend-content p-0 align-top", colSpan: 2 },
|
|
1517
1547
|
React.createElement("div", { className: "diff-line-extend-wrapper sticky left-0 z-[1]", style: { width } },
|
|
1518
|
-
width > 0 &&
|
|
1548
|
+
(enableWrap ? true : width > 0) &&
|
|
1519
1549
|
(oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) !== undefined &&
|
|
1520
1550
|
(oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) !== null &&
|
|
1521
1551
|
(renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
|
|
@@ -1525,7 +1555,7 @@ const InternalDiffUnifiedExtendLine = ({ index, diffFile, lineNumber, oldLineExt
|
|
|
1525
1555
|
data: oldLineExtend.data,
|
|
1526
1556
|
onUpdate: diffFile.notifyAll,
|
|
1527
1557
|
})),
|
|
1528
|
-
width > 0 &&
|
|
1558
|
+
(enableWrap ? true : width > 0) &&
|
|
1529
1559
|
(newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data) !== undefined &&
|
|
1530
1560
|
(newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data) !== null &&
|
|
1531
1561
|
(renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
|
|
@@ -1536,7 +1566,7 @@ const InternalDiffUnifiedExtendLine = ({ index, diffFile, lineNumber, oldLineExt
|
|
|
1536
1566
|
onUpdate: diffFile.notifyAll,
|
|
1537
1567
|
}))))));
|
|
1538
1568
|
};
|
|
1539
|
-
const DiffUnifiedExtendLine = ({ index, diffFile, lineNumber, }) => {
|
|
1569
|
+
const DiffUnifiedExtendLine = ({ index, diffFile, lineNumber, enableWrap, }) => {
|
|
1540
1570
|
const { useDiffContext } = useDiffViewContext();
|
|
1541
1571
|
const unifiedItem = diffFile.getUnifiedLine(index);
|
|
1542
1572
|
const { oldLineExtend, newLineExtend } = useDiffContext(useCallback((s) => {
|
|
@@ -1549,7 +1579,7 @@ const DiffUnifiedExtendLine = ({ index, diffFile, lineNumber, }) => {
|
|
|
1549
1579
|
const hasExtend = (oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) || (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data);
|
|
1550
1580
|
if (!hasExtend || !unifiedItem || unifiedItem.isHidden)
|
|
1551
1581
|
return null;
|
|
1552
|
-
return (React.createElement(InternalDiffUnifiedExtendLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, oldLineExtend: oldLineExtend, newLineExtend: newLineExtend }));
|
|
1582
|
+
return (React.createElement(InternalDiffUnifiedExtendLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, enableWrap: enableWrap, oldLineExtend: oldLineExtend, newLineExtend: newLineExtend }));
|
|
1553
1583
|
};
|
|
1554
1584
|
|
|
1555
1585
|
const InternalDiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
|
|
@@ -1597,7 +1627,7 @@ const DiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
|
|
|
1597
1627
|
return React.createElement(InternalDiffUnifiedHunkLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
|
|
1598
1628
|
};
|
|
1599
1629
|
|
|
1600
|
-
const InternalDiffUnifiedWidgetLine = ({ index, diffFile, lineNumber, }) => {
|
|
1630
|
+
const InternalDiffUnifiedWidgetLine = ({ index, diffFile, lineNumber, enableWrap, }) => {
|
|
1601
1631
|
const { useWidget } = useDiffWidgetContext();
|
|
1602
1632
|
const setWidget = useWidget.getReadonlyState().setWidget;
|
|
1603
1633
|
const unifiedItem = diffFile.getUnifiedLine(index);
|
|
@@ -1611,21 +1641,21 @@ const InternalDiffUnifiedWidgetLine = ({ index, diffFile, lineNumber, }) => {
|
|
|
1611
1641
|
const renderWidgetLine = useDiffContext.useShallowStableSelector((s) => s.renderWidgetLine);
|
|
1612
1642
|
const width = useDomWidth({
|
|
1613
1643
|
selector: ".unified-diff-table-wrapper",
|
|
1614
|
-
enable: typeof renderWidgetLine === "function",
|
|
1644
|
+
enable: typeof renderWidgetLine === "function" && !enableWrap,
|
|
1615
1645
|
});
|
|
1616
1646
|
if (!renderWidgetLine)
|
|
1617
1647
|
return null;
|
|
1618
1648
|
return (React.createElement("tr", { "data-line": `${lineNumber}-widget`, "data-state": "widget", className: "diff-line diff-line-widget" },
|
|
1619
1649
|
React.createElement("td", { className: "diff-line-widget-content p-0", colSpan: 2 },
|
|
1620
1650
|
React.createElement("div", { className: "diff-line-widget-wrapper sticky left-0 z-[1]", style: { width } },
|
|
1621
|
-
width > 0 &&
|
|
1651
|
+
(enableWrap ? true : width > 0) &&
|
|
1622
1652
|
oldWidget &&
|
|
1623
1653
|
(renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({ diffFile, side: SplitSide.old, lineNumber: unifiedItem.oldLineNumber, onClose })),
|
|
1624
|
-
width > 0 &&
|
|
1654
|
+
(enableWrap ? true : width > 0) &&
|
|
1625
1655
|
newWidget &&
|
|
1626
1656
|
(renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({ diffFile, side: SplitSide.new, lineNumber: unifiedItem.newLineNumber, onClose }))))));
|
|
1627
1657
|
};
|
|
1628
|
-
const DiffUnifiedWidgetLine = ({ index, diffFile, lineNumber, }) => {
|
|
1658
|
+
const DiffUnifiedWidgetLine = ({ index, diffFile, lineNumber, enableWrap, }) => {
|
|
1629
1659
|
const { useWidget } = useDiffWidgetContext();
|
|
1630
1660
|
const currentIsShow = useWidget.useShallowSelector(React.useCallback((s) => {
|
|
1631
1661
|
const widgetLineNumber = s.widgetLineNumber;
|
|
@@ -1638,7 +1668,7 @@ const DiffUnifiedWidgetLine = ({ index, diffFile, lineNumber, }) => {
|
|
|
1638
1668
|
}, [diffFile, index]), (p, c) => p === c);
|
|
1639
1669
|
if (!currentIsShow)
|
|
1640
1670
|
return null;
|
|
1641
|
-
return React.createElement(InternalDiffUnifiedWidgetLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
|
|
1671
|
+
return (React.createElement(InternalDiffUnifiedWidgetLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, enableWrap: enableWrap }));
|
|
1642
1672
|
};
|
|
1643
1673
|
|
|
1644
1674
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
@@ -1731,12 +1761,12 @@ const DiffUnifiedView = memo(({ diffFile }) => {
|
|
|
1731
1761
|
React.createElement("tr", null,
|
|
1732
1762
|
React.createElement("th", { scope: "col" }, "line number"),
|
|
1733
1763
|
React.createElement("th", { scope: "col" }, "line content"))),
|
|
1734
|
-
React.createElement("tbody", { className: "diff-table-body leading-[1.
|
|
1764
|
+
React.createElement("tbody", { className: "diff-table-body leading-[1.6]", onMouseDownCapture: onMouseDown },
|
|
1735
1765
|
lines.map((item) => (React.createElement(Fragment, { key: item.index },
|
|
1736
1766
|
React.createElement(DiffUnifiedHunkLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile }),
|
|
1737
1767
|
React.createElement(DiffUnifiedContentLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile, enableWrap: enableWrap, enableHighlight: enableHighlight, enableAddWidget: enableAddWidget }),
|
|
1738
|
-
React.createElement(DiffUnifiedWidgetLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile }),
|
|
1739
|
-
React.createElement(DiffUnifiedExtendLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile })))),
|
|
1768
|
+
React.createElement(DiffUnifiedWidgetLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile, enableWrap: enableWrap }),
|
|
1769
|
+
React.createElement(DiffUnifiedExtendLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile, enableWrap: enableWrap })))),
|
|
1740
1770
|
React.createElement(DiffUnifiedHunkLine, { index: diffFile.unifiedLineLength, lineNumber: diffFile.unifiedLineLength, diffFile: diffFile })))))));
|
|
1741
1771
|
});
|
|
1742
1772
|
DiffUnifiedView.displayName = "DiffUnifiedView";
|
|
@@ -1802,9 +1832,12 @@ const InternalDiffView = (props) => {
|
|
|
1802
1832
|
onAddWidgetClick,
|
|
1803
1833
|
onCreateUseWidgetHook,
|
|
1804
1834
|
]);
|
|
1835
|
+
useEffect(() => {
|
|
1836
|
+
useDiffContext.getReadonlyState().setDom(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
|
|
1837
|
+
}, [useDiffContext, wrapperRef]);
|
|
1805
1838
|
const value = useMemo(() => ({ useDiffContext }), [useDiffContext]);
|
|
1806
1839
|
return (React.createElement(DiffViewContext.Provider, { value: value },
|
|
1807
|
-
React.createElement("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-theme": diffFile._getTheme() || "light", "data-version": "0.0.
|
|
1840
|
+
React.createElement("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-theme": diffFile._getTheme() || "light", "data-version": "0.0.32", "data-highlighter": diffFile._getHighlighterName(), ref: wrapperRef },
|
|
1808
1841
|
React.createElement("div", { className: "diff-style-root", style: {
|
|
1809
1842
|
// @ts-ignore
|
|
1810
1843
|
[diffFontSizeName]: diffViewFontSize + "px",
|
|
@@ -1858,9 +1891,9 @@ const DiffViewWithRef = (props, ref) => {
|
|
|
1858
1891
|
return;
|
|
1859
1892
|
if (props.diffViewHighlight) {
|
|
1860
1893
|
diffFile.initSyntax({ registerHighlighter });
|
|
1861
|
-
diffFile.notifyAll();
|
|
1862
1894
|
}
|
|
1863
|
-
|
|
1895
|
+
diffFile.notifyAll();
|
|
1896
|
+
}, [diffFile, props.diffViewHighlight, registerHighlighter, diffViewTheme]);
|
|
1864
1897
|
useEffect(() => {
|
|
1865
1898
|
if (!diffFile)
|
|
1866
1899
|
return;
|
|
@@ -1872,7 +1905,7 @@ const DiffViewWithRef = (props, ref) => {
|
|
|
1872
1905
|
init();
|
|
1873
1906
|
const cb = diffFile.subscribe(init);
|
|
1874
1907
|
return cb;
|
|
1875
|
-
}, [diffFile
|
|
1908
|
+
}, [diffFile]);
|
|
1876
1909
|
// fix react strict mode error
|
|
1877
1910
|
useUnmount(() => { var _a, _b; return (process.env.NODE_ENV === "development" ? (_a = diffFile === null || diffFile === void 0 ? void 0 : diffFile._destroy) === null || _a === void 0 ? void 0 : _a.call(diffFile) : (_b = diffFile === null || diffFile === void 0 ? void 0 : diffFile.clear) === null || _b === void 0 ? void 0 : _b.call(diffFile)); }, [diffFile]);
|
|
1878
1911
|
useImperativeHandle(ref, () => ({ getDiffFileInstance: () => diffFile }), [diffFile]);
|
|
@@ -1883,7 +1916,7 @@ const DiffViewWithRef = (props, ref) => {
|
|
|
1883
1916
|
const InnerDiffView = forwardRef(DiffViewWithRef);
|
|
1884
1917
|
InnerDiffView.displayName = "DiffView";
|
|
1885
1918
|
const DiffView = InnerDiffView;
|
|
1886
|
-
const version = "0.0.
|
|
1919
|
+
const version = "0.0.32";
|
|
1887
1920
|
|
|
1888
1921
|
export { DiffModeEnum, DiffView, version };
|
|
1889
1922
|
//# sourceMappingURL=index.mjs.map
|