@git-diff-view/react 0.0.15 → 0.0.16
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.
|
@@ -180,6 +180,7 @@ const DiffViewContext = React.createContext(null);
|
|
|
180
180
|
DiffViewContext.displayName = "DiffViewContext";
|
|
181
181
|
const useDiffViewContext = () => React.useContext(DiffViewContext);
|
|
182
182
|
|
|
183
|
+
// TODO
|
|
183
184
|
const useSyncHeight = ({ selector, side, enable }) => {
|
|
184
185
|
const { useDiffContext } = useDiffViewContext();
|
|
185
186
|
const id = useDiffContext(React.useCallback((s) => s.id, []));
|
|
@@ -191,7 +192,6 @@ const useSyncHeight = ({ selector, side, enable }) => {
|
|
|
191
192
|
const ele1 = elements[0];
|
|
192
193
|
const ele2 = elements[1];
|
|
193
194
|
const target = ele1.getAttribute("data-side") === side ? ele1 : ele2;
|
|
194
|
-
const synced = ele1.getAttribute("data-side") !== side ? ele1 : ele2;
|
|
195
195
|
const cb = () => {
|
|
196
196
|
ele1.style.height = "auto";
|
|
197
197
|
ele2.style.height = "auto";
|
|
@@ -199,7 +199,8 @@ const useSyncHeight = ({ selector, side, enable }) => {
|
|
|
199
199
|
const rect2 = ele2.getBoundingClientRect();
|
|
200
200
|
if (rect1.height !== rect2.height) {
|
|
201
201
|
const maxHeight = Math.max(rect1.height, rect2.height);
|
|
202
|
-
|
|
202
|
+
ele1.style.height = maxHeight + "px";
|
|
203
|
+
ele2.style.height = maxHeight + "px";
|
|
203
204
|
ele1.setAttribute("data-sync-height", String(maxHeight));
|
|
204
205
|
ele2.setAttribute("data-sync-height", String(maxHeight));
|
|
205
206
|
}
|
|
@@ -263,15 +264,14 @@ const _DiffSplitExtendLine$1 = ({ index, diffFile, oldLineExtend, newLineExtend,
|
|
|
263
264
|
const renderExtendLine = useDiffContext(React__namespace.useCallback((s) => s.renderExtendLine, []));
|
|
264
265
|
const currentExtend = side === exports.SplitSide.old ? oldLineExtend : newLineExtend;
|
|
265
266
|
const currentLineNumber = side === exports.SplitSide.old ? oldLine.lineNumber : newLine.lineNumber;
|
|
266
|
-
const otherSide = side === exports.SplitSide.old ? exports.SplitSide.new : exports.SplitSide.old;
|
|
267
267
|
useSyncHeight({
|
|
268
268
|
selector: `tr[data-line="${lineNumber}-extend"]`,
|
|
269
|
-
side:
|
|
270
|
-
enable:
|
|
269
|
+
side: exports.SplitSide[side],
|
|
270
|
+
enable: !!(currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data) && typeof renderExtendLine === "function",
|
|
271
271
|
});
|
|
272
272
|
const width = useDomWidth({
|
|
273
273
|
selector: side === exports.SplitSide.old ? ".old-diff-table-wrapper" : ".new-diff-table-wrapper",
|
|
274
|
-
enable: !!currentExtend && typeof renderExtendLine === "function",
|
|
274
|
+
enable: !!(currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data) && typeof renderExtendLine === "function",
|
|
275
275
|
});
|
|
276
276
|
if (!renderExtendLine)
|
|
277
277
|
return null;
|
|
@@ -509,8 +509,8 @@ const _DiffSplitHunkLineGitLab = ({ index, diffFile, side, lineNumber, }) => {
|
|
|
509
509
|
const expandEnabled = diffFile.getExpandEnabled();
|
|
510
510
|
useSyncHeight({
|
|
511
511
|
selector: `tr[data-line="${lineNumber}-hunk"]`,
|
|
512
|
-
side: exports.SplitSide[
|
|
513
|
-
enable:
|
|
512
|
+
side: exports.SplitSide[side],
|
|
513
|
+
enable: true,
|
|
514
514
|
});
|
|
515
515
|
const couldExpand = expandEnabled && currentHunk && currentHunk.splitInfo;
|
|
516
516
|
const isExpandAll = currentHunk &&
|
|
@@ -772,13 +772,12 @@ const DiffSplitLine$1 = ({ index, diffFile, lineNumber, side, }) => {
|
|
|
772
772
|
};
|
|
773
773
|
|
|
774
774
|
const _DiffSplitWidgetLine$1 = ({ diffFile, side, lineNumber, currentLine, setWidget, currentWidget, }) => {
|
|
775
|
-
const otherSide = side === exports.SplitSide.old ? exports.SplitSide.new : exports.SplitSide.old;
|
|
776
775
|
const { useDiffContext } = useDiffViewContext();
|
|
777
776
|
const renderWidgetLine = useDiffContext(React__namespace.useCallback((s) => s.renderWidgetLine, []));
|
|
778
777
|
useSyncHeight({
|
|
779
778
|
selector: `tr[data-line="${lineNumber}-widget"]`,
|
|
780
|
-
side:
|
|
781
|
-
enable:
|
|
779
|
+
side: exports.SplitSide[side],
|
|
780
|
+
enable: currentWidget && typeof renderWidgetLine === "function",
|
|
782
781
|
});
|
|
783
782
|
const width = useDomWidth({
|
|
784
783
|
selector: side === exports.SplitSide.old ? ".old-diff-table-wrapper" : ".new-diff-table-wrapper",
|
|
@@ -1520,7 +1519,7 @@ const _InternalDiffView = (props) => {
|
|
|
1520
1519
|
]);
|
|
1521
1520
|
const value = React.useMemo(() => ({ useDiffContext }), [useDiffContext]);
|
|
1522
1521
|
return (React__namespace.createElement(DiffViewContext.Provider, { value: value },
|
|
1523
|
-
React__namespace.createElement("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-version": `${"0.0.
|
|
1522
|
+
React__namespace.createElement("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-version": `${"0.0.16"}`, "data-highlighter": diffFile._getHighlighterName() },
|
|
1524
1523
|
React__namespace.createElement("div", { className: "diff-style-root", style: {
|
|
1525
1524
|
// @ts-ignore
|
|
1526
1525
|
[diffFontSizeName]: diffViewFontSize + "px",
|
|
@@ -1579,7 +1578,7 @@ const DiffViewWithRef = (props, ref) => {
|
|
|
1579
1578
|
};
|
|
1580
1579
|
const DiffView = React.forwardRef(DiffViewWithRef);
|
|
1581
1580
|
DiffView.displayName = "DiffView";
|
|
1582
|
-
const version = "0.0.
|
|
1581
|
+
const version = "0.0.16";
|
|
1583
1582
|
|
|
1584
1583
|
exports.DiffView = DiffView;
|
|
1585
1584
|
exports.DiffViewContext = DiffViewContext;
|