@git-diff-view/react 0.0.32 → 0.0.33

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.
@@ -214,6 +214,25 @@ const getElementRoot = (element) => {
214
214
  }
215
215
  return document;
216
216
  };
217
+ const getDiffIdFromElement = (element) => {
218
+ if (element) {
219
+ if (typeof element.closest === "function") {
220
+ const diffRoot = element.closest('[data-component="git-diff-view"]');
221
+ const ele = diffRoot.querySelector(".diff-view-wrapper");
222
+ return ele.getAttribute("id");
223
+ }
224
+ else {
225
+ let el = element;
226
+ while (el) {
227
+ if (el.getAttribute && el.getAttribute("data-component") === "git-diff-view") {
228
+ const ele = el.querySelector(".diff-view-wrapper");
229
+ return ele.getAttribute("id");
230
+ }
231
+ el = el.parentElement;
232
+ }
233
+ }
234
+ }
235
+ };
217
236
 
218
237
  const diffFontSizeName = "--diff-font-size--";
219
238
  const diffAsideWidthName = "--diff-aside-width--";
@@ -940,6 +959,10 @@ const DiffSplitViewNormal = React.memo(({ diffFile }) => {
940
959
  removeAllSelection();
941
960
  return;
942
961
  }
962
+ const id = getDiffIdFromElement(ele);
963
+ if (id && id !== `diff-root${diffFile.getId()}`) {
964
+ return;
965
+ }
943
966
  while (ele && ele instanceof HTMLElement) {
944
967
  const state = ele.getAttribute("data-state");
945
968
  const side = ele.getAttribute("data-side");
@@ -1279,6 +1302,10 @@ const DiffSplitViewWrap = React.memo(({ diffFile }) => {
1279
1302
  removeAllSelection();
1280
1303
  return;
1281
1304
  }
1305
+ const id = getDiffIdFromElement(ele);
1306
+ if (id && id !== `diff-root${diffFile.getId()}`) {
1307
+ return;
1308
+ }
1282
1309
  while (ele && ele instanceof HTMLElement) {
1283
1310
  const state = ele.getAttribute("data-state");
1284
1311
  const side = ele.getAttribute("data-side");
@@ -1739,6 +1766,10 @@ const DiffUnifiedView = React.memo(({ diffFile }) => {
1739
1766
  removeAllSelection();
1740
1767
  return;
1741
1768
  }
1769
+ const id = getDiffIdFromElement(ele);
1770
+ if (id && id !== `diff-root${diffFile.getId()}`) {
1771
+ return;
1772
+ }
1742
1773
  while (ele && ele instanceof HTMLElement) {
1743
1774
  const state = ele.getAttribute("data-state");
1744
1775
  if (state) {
@@ -1855,7 +1886,7 @@ const InternalDiffView = (props) => {
1855
1886
  }, [useDiffContext, wrapperRef]);
1856
1887
  const value = React.useMemo(() => ({ useDiffContext }), [useDiffContext]);
1857
1888
  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.32", "data-highlighter": diffFile._getHighlighterName(), ref: wrapperRef },
1889
+ React__namespace.createElement("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-theme": diffFile._getTheme() || "light", "data-version": "0.0.33", "data-highlighter": diffFile._getHighlighterName(), ref: wrapperRef },
1859
1890
  React__namespace.createElement("div", { className: "diff-style-root", style: {
1860
1891
  // @ts-ignore
1861
1892
  [diffFontSizeName]: diffViewFontSize + "px",
@@ -1934,7 +1965,7 @@ const DiffViewWithRef = (props, ref) => {
1934
1965
  const InnerDiffView = React.forwardRef(DiffViewWithRef);
1935
1966
  InnerDiffView.displayName = "DiffView";
1936
1967
  const DiffView = InnerDiffView;
1937
- const version = "0.0.32";
1968
+ const version = "0.0.33";
1938
1969
 
1939
1970
  Object.defineProperty(exports, "SplitSide", {
1940
1971
  enumerable: true,