@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.
package/dist/esm/index.mjs
CHANGED
|
@@ -161,6 +161,7 @@ const useDomWidth = ({ selector, enable }) => {
|
|
|
161
161
|
return width;
|
|
162
162
|
};
|
|
163
163
|
|
|
164
|
+
// TODO
|
|
164
165
|
const useSyncHeight = ({ selector, side, enable }) => {
|
|
165
166
|
const { useDiffContext } = useDiffViewContext();
|
|
166
167
|
const id = useDiffContext(useCallback((s) => s.id, []));
|
|
@@ -172,7 +173,6 @@ const useSyncHeight = ({ selector, side, enable }) => {
|
|
|
172
173
|
const ele1 = elements[0];
|
|
173
174
|
const ele2 = elements[1];
|
|
174
175
|
const target = ele1.getAttribute("data-side") === side ? ele1 : ele2;
|
|
175
|
-
const synced = ele1.getAttribute("data-side") !== side ? ele1 : ele2;
|
|
176
176
|
const cb = () => {
|
|
177
177
|
ele1.style.height = "auto";
|
|
178
178
|
ele2.style.height = "auto";
|
|
@@ -180,7 +180,8 @@ const useSyncHeight = ({ selector, side, enable }) => {
|
|
|
180
180
|
const rect2 = ele2.getBoundingClientRect();
|
|
181
181
|
if (rect1.height !== rect2.height) {
|
|
182
182
|
const maxHeight = Math.max(rect1.height, rect2.height);
|
|
183
|
-
|
|
183
|
+
ele1.style.height = maxHeight + "px";
|
|
184
|
+
ele2.style.height = maxHeight + "px";
|
|
184
185
|
ele1.setAttribute("data-sync-height", String(maxHeight));
|
|
185
186
|
ele2.setAttribute("data-sync-height", String(maxHeight));
|
|
186
187
|
}
|
|
@@ -244,15 +245,14 @@ const _DiffSplitExtendLine$1 = ({ index, diffFile, oldLineExtend, newLineExtend,
|
|
|
244
245
|
const renderExtendLine = useDiffContext(React.useCallback((s) => s.renderExtendLine, []));
|
|
245
246
|
const currentExtend = side === SplitSide.old ? oldLineExtend : newLineExtend;
|
|
246
247
|
const currentLineNumber = side === SplitSide.old ? oldLine.lineNumber : newLine.lineNumber;
|
|
247
|
-
const otherSide = side === SplitSide.old ? SplitSide.new : SplitSide.old;
|
|
248
248
|
useSyncHeight({
|
|
249
249
|
selector: `tr[data-line="${lineNumber}-extend"]`,
|
|
250
|
-
side:
|
|
251
|
-
enable:
|
|
250
|
+
side: SplitSide[side],
|
|
251
|
+
enable: !!(currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data) && typeof renderExtendLine === "function",
|
|
252
252
|
});
|
|
253
253
|
const width = useDomWidth({
|
|
254
254
|
selector: side === SplitSide.old ? ".old-diff-table-wrapper" : ".new-diff-table-wrapper",
|
|
255
|
-
enable: !!currentExtend && typeof renderExtendLine === "function",
|
|
255
|
+
enable: !!(currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data) && typeof renderExtendLine === "function",
|
|
256
256
|
});
|
|
257
257
|
if (!renderExtendLine)
|
|
258
258
|
return null;
|
|
@@ -490,8 +490,8 @@ const _DiffSplitHunkLineGitLab = ({ index, diffFile, side, lineNumber, }) => {
|
|
|
490
490
|
const expandEnabled = diffFile.getExpandEnabled();
|
|
491
491
|
useSyncHeight({
|
|
492
492
|
selector: `tr[data-line="${lineNumber}-hunk"]`,
|
|
493
|
-
side: SplitSide[
|
|
494
|
-
enable:
|
|
493
|
+
side: SplitSide[side],
|
|
494
|
+
enable: true,
|
|
495
495
|
});
|
|
496
496
|
const couldExpand = expandEnabled && currentHunk && currentHunk.splitInfo;
|
|
497
497
|
const isExpandAll = currentHunk &&
|
|
@@ -753,13 +753,12 @@ const DiffSplitLine$1 = ({ index, diffFile, lineNumber, side, }) => {
|
|
|
753
753
|
};
|
|
754
754
|
|
|
755
755
|
const _DiffSplitWidgetLine$1 = ({ diffFile, side, lineNumber, currentLine, setWidget, currentWidget, }) => {
|
|
756
|
-
const otherSide = side === SplitSide.old ? SplitSide.new : SplitSide.old;
|
|
757
756
|
const { useDiffContext } = useDiffViewContext();
|
|
758
757
|
const renderWidgetLine = useDiffContext(React.useCallback((s) => s.renderWidgetLine, []));
|
|
759
758
|
useSyncHeight({
|
|
760
759
|
selector: `tr[data-line="${lineNumber}-widget"]`,
|
|
761
|
-
side:
|
|
762
|
-
enable:
|
|
760
|
+
side: SplitSide[side],
|
|
761
|
+
enable: currentWidget && typeof renderWidgetLine === "function",
|
|
763
762
|
});
|
|
764
763
|
const width = useDomWidth({
|
|
765
764
|
selector: side === SplitSide.old ? ".old-diff-table-wrapper" : ".new-diff-table-wrapper",
|
|
@@ -1501,7 +1500,7 @@ const _InternalDiffView = (props) => {
|
|
|
1501
1500
|
]);
|
|
1502
1501
|
const value = useMemo(() => ({ useDiffContext }), [useDiffContext]);
|
|
1503
1502
|
return (React.createElement(DiffViewContext.Provider, { value: value },
|
|
1504
|
-
React.createElement("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-version": `${"0.0.
|
|
1503
|
+
React.createElement("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-version": `${"0.0.16"}`, "data-highlighter": diffFile._getHighlighterName() },
|
|
1505
1504
|
React.createElement("div", { className: "diff-style-root", style: {
|
|
1506
1505
|
// @ts-ignore
|
|
1507
1506
|
[diffFontSizeName]: diffViewFontSize + "px",
|
|
@@ -1560,7 +1559,7 @@ const DiffViewWithRef = (props, ref) => {
|
|
|
1560
1559
|
};
|
|
1561
1560
|
const DiffView = forwardRef(DiffViewWithRef);
|
|
1562
1561
|
DiffView.displayName = "DiffView";
|
|
1563
|
-
const version = "0.0.
|
|
1562
|
+
const version = "0.0.16";
|
|
1564
1563
|
|
|
1565
1564
|
export { DiffModeEnum, DiffView, DiffViewContext, SplitSide, useDiffViewContext, version };
|
|
1566
1565
|
//# sourceMappingURL=index.mjs.map
|