@git-diff-view/react 0.0.32 → 0.0.34
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 +34 -2
- package/dist/cjs/index.development.js.map +1 -1
- package/dist/cjs/index.production.js +34 -2
- package/dist/cjs/index.production.js.map +1 -1
- package/dist/css/diff-view.css +1 -1
- package/dist/esm/index.mjs +34 -2
- package/dist/esm/index.mjs.map +1 -1
- package/index.d.ts +59 -100
- package/package.json +8 -8
- package/src/components/DiffSplitViewNormal.tsx +7 -0
- package/src/components/DiffSplitViewWrap.tsx +7 -1
- package/src/components/DiffUnifiedView.tsx +7 -1
- package/src/index.ts +2 -0
- package/styles/diff-view.css +1 -1
|
@@ -214,6 +214,26 @@ const getElementRoot = (element) => {
|
|
|
214
214
|
}
|
|
215
215
|
return document;
|
|
216
216
|
};
|
|
217
|
+
const getDiffIdFromElement = (element) => {
|
|
218
|
+
var _a, _b;
|
|
219
|
+
if (element) {
|
|
220
|
+
if (typeof element.closest === "function") {
|
|
221
|
+
const diffRoot = element.closest('[data-component="git-diff-view"]');
|
|
222
|
+
const ele = (_a = diffRoot === null || diffRoot === void 0 ? void 0 : diffRoot.querySelector) === null || _a === void 0 ? void 0 : _a.call(diffRoot, ".diff-view-wrapper");
|
|
223
|
+
return (_b = ele === null || ele === void 0 ? void 0 : ele.getAttribute) === null || _b === void 0 ? void 0 : _b.call(ele, "id");
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
let el = element;
|
|
227
|
+
while (el) {
|
|
228
|
+
if (el.getAttribute && el.getAttribute("data-component") === "git-diff-view") {
|
|
229
|
+
const ele = el.querySelector(".diff-view-wrapper");
|
|
230
|
+
return ele.getAttribute("id");
|
|
231
|
+
}
|
|
232
|
+
el = el.parentElement;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
};
|
|
217
237
|
|
|
218
238
|
const diffFontSizeName = "--diff-font-size--";
|
|
219
239
|
const diffAsideWidthName = "--diff-aside-width--";
|
|
@@ -940,6 +960,10 @@ const DiffSplitViewNormal = React.memo(({ diffFile }) => {
|
|
|
940
960
|
removeAllSelection();
|
|
941
961
|
return;
|
|
942
962
|
}
|
|
963
|
+
const id = getDiffIdFromElement(ele);
|
|
964
|
+
if (id && id !== `diff-root${diffFile.getId()}`) {
|
|
965
|
+
return;
|
|
966
|
+
}
|
|
943
967
|
while (ele && ele instanceof HTMLElement) {
|
|
944
968
|
const state = ele.getAttribute("data-state");
|
|
945
969
|
const side = ele.getAttribute("data-side");
|
|
@@ -1279,6 +1303,10 @@ const DiffSplitViewWrap = React.memo(({ diffFile }) => {
|
|
|
1279
1303
|
removeAllSelection();
|
|
1280
1304
|
return;
|
|
1281
1305
|
}
|
|
1306
|
+
const id = getDiffIdFromElement(ele);
|
|
1307
|
+
if (id && id !== `diff-root${diffFile.getId()}`) {
|
|
1308
|
+
return;
|
|
1309
|
+
}
|
|
1282
1310
|
while (ele && ele instanceof HTMLElement) {
|
|
1283
1311
|
const state = ele.getAttribute("data-state");
|
|
1284
1312
|
const side = ele.getAttribute("data-side");
|
|
@@ -1739,6 +1767,10 @@ const DiffUnifiedView = React.memo(({ diffFile }) => {
|
|
|
1739
1767
|
removeAllSelection();
|
|
1740
1768
|
return;
|
|
1741
1769
|
}
|
|
1770
|
+
const id = getDiffIdFromElement(ele);
|
|
1771
|
+
if (id && id !== `diff-root${diffFile.getId()}`) {
|
|
1772
|
+
return;
|
|
1773
|
+
}
|
|
1742
1774
|
while (ele && ele instanceof HTMLElement) {
|
|
1743
1775
|
const state = ele.getAttribute("data-state");
|
|
1744
1776
|
if (state) {
|
|
@@ -1855,7 +1887,7 @@ const InternalDiffView = (props) => {
|
|
|
1855
1887
|
}, [useDiffContext, wrapperRef]);
|
|
1856
1888
|
const value = React.useMemo(() => ({ useDiffContext }), [useDiffContext]);
|
|
1857
1889
|
return (React__namespace.createElement(DiffViewContext.Provider, { value: value },
|
|
1858
|
-
React__namespace.createElement("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-theme": diffFile._getTheme() || "light", "data-version": "0.0.
|
|
1890
|
+
React__namespace.createElement("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-theme": diffFile._getTheme() || "light", "data-version": "0.0.34", "data-highlighter": diffFile._getHighlighterName(), ref: wrapperRef },
|
|
1859
1891
|
React__namespace.createElement("div", { className: "diff-style-root", style: {
|
|
1860
1892
|
// @ts-ignore
|
|
1861
1893
|
[diffFontSizeName]: diffViewFontSize + "px",
|
|
@@ -1934,7 +1966,7 @@ const DiffViewWithRef = (props, ref) => {
|
|
|
1934
1966
|
const InnerDiffView = React.forwardRef(DiffViewWithRef);
|
|
1935
1967
|
InnerDiffView.displayName = "DiffView";
|
|
1936
1968
|
const DiffView = InnerDiffView;
|
|
1937
|
-
const version = "0.0.
|
|
1969
|
+
const version = "0.0.34";
|
|
1938
1970
|
|
|
1939
1971
|
Object.defineProperty(exports, "SplitSide", {
|
|
1940
1972
|
enumerable: true,
|