@atlaskit/editor-plugin-show-diff 8.3.5 → 8.3.7

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlaskit/editor-plugin-show-diff
2
2
 
3
+ ## 8.3.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [`c07f198dda226`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c07f198dda226) -
8
+ NO-ISSUE: Always scroll diff into view even if it's in viewport already
9
+ - Updated dependencies
10
+
11
+ ## 8.3.6
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies
16
+
3
17
  ## 8.3.5
4
18
 
5
19
  ### Patch Changes
@@ -15,16 +15,6 @@ exports.scrollToFirstDecoration = exports.scrollToActiveDecoration = void 0;
15
15
  */
16
16
  var SCROLL_TOP_MARGIN_PX = 100;
17
17
 
18
- /**
19
- * Checks if element is not visible in the viewport, accounting
20
- * for the scroll margin offset used during scrolling.
21
- */
22
- function shouldScrollIntoView(element) {
23
- var rect = element.getBoundingClientRect();
24
- var viewportHeight = window.innerHeight || document.documentElement.clientHeight;
25
- return !(rect.top >= SCROLL_TOP_MARGIN_PX && rect.bottom <= viewportHeight);
26
- }
27
-
28
18
  /**
29
19
  * Returns the resolved HTMLElement for a given DOM node, walking up to the
30
20
  * parent element if the node itself is not an Element (e.g. a text node).
@@ -67,14 +57,14 @@ var scrollToFirstDecoration = exports.scrollToFirstDecoration = function scrollT
67
57
  if ((_decoration$spec = decoration.spec) !== null && _decoration$spec !== void 0 && (_decoration$spec = _decoration$spec.key) !== null && _decoration$spec !== void 0 && _decoration$spec.startsWith('diff-widget') && decoration !== null && decoration !== void 0 && (_decoration$type = decoration.type) !== null && _decoration$type !== void 0 && _decoration$type.toDOM) {
68
58
  // @ts-expect-error - decoration.type is not typed public API
69
59
  var widgetDom = decoration.type.toDOM;
70
- if (shouldScrollIntoView(widgetDom)) {
71
- scrollToSelection(widgetDom);
72
- }
60
+ // Always scroll to the top of this decoration even if it's in view already
61
+ scrollToSelection(widgetDom);
73
62
  } else {
74
63
  var _view$domAtPos;
75
64
  var targetNode = view.nodeDOM(decoration === null || decoration === void 0 ? void 0 : decoration.from);
76
65
  var node = targetNode instanceof Element ? targetNode : (_view$domAtPos = view.domAtPos(decoration === null || decoration === void 0 ? void 0 : decoration.from)) === null || _view$domAtPos === void 0 ? void 0 : _view$domAtPos.node;
77
- if (node instanceof HTMLElement && shouldScrollIntoView(node)) {
66
+ if (node instanceof HTMLElement) {
67
+ // Always scroll to the top of this decoration even if it's in view already
78
68
  scrollToSelection(node);
79
69
  }
80
70
  }
@@ -9,16 +9,6 @@
9
9
  */
10
10
  const SCROLL_TOP_MARGIN_PX = 100;
11
11
 
12
- /**
13
- * Checks if element is not visible in the viewport, accounting
14
- * for the scroll margin offset used during scrolling.
15
- */
16
- function shouldScrollIntoView(element) {
17
- const rect = element.getBoundingClientRect();
18
- const viewportHeight = window.innerHeight || document.documentElement.clientHeight;
19
- return !(rect.top >= SCROLL_TOP_MARGIN_PX && rect.bottom <= viewportHeight);
20
- }
21
-
22
12
  /**
23
13
  * Returns the resolved HTMLElement for a given DOM node, walking up to the
24
14
  * parent element if the node itself is not an Element (e.g. a text node).
@@ -61,14 +51,14 @@ export const scrollToFirstDecoration = (view, decorations) => {
61
51
  if ((_decoration$spec = decoration.spec) !== null && _decoration$spec !== void 0 && (_decoration$spec$key = _decoration$spec.key) !== null && _decoration$spec$key !== void 0 && _decoration$spec$key.startsWith('diff-widget') && decoration !== null && decoration !== void 0 && (_decoration$type = decoration.type) !== null && _decoration$type !== void 0 && _decoration$type.toDOM) {
62
52
  // @ts-expect-error - decoration.type is not typed public API
63
53
  const widgetDom = decoration.type.toDOM;
64
- if (shouldScrollIntoView(widgetDom)) {
65
- scrollToSelection(widgetDom);
66
- }
54
+ // Always scroll to the top of this decoration even if it's in view already
55
+ scrollToSelection(widgetDom);
67
56
  } else {
68
57
  var _view$domAtPos;
69
58
  const targetNode = view.nodeDOM(decoration === null || decoration === void 0 ? void 0 : decoration.from);
70
59
  const node = targetNode instanceof Element ? targetNode : (_view$domAtPos = view.domAtPos(decoration === null || decoration === void 0 ? void 0 : decoration.from)) === null || _view$domAtPos === void 0 ? void 0 : _view$domAtPos.node;
71
- if (node instanceof HTMLElement && shouldScrollIntoView(node)) {
60
+ if (node instanceof HTMLElement) {
61
+ // Always scroll to the top of this decoration even if it's in view already
72
62
  scrollToSelection(node);
73
63
  }
74
64
  }
@@ -9,16 +9,6 @@
9
9
  */
10
10
  var SCROLL_TOP_MARGIN_PX = 100;
11
11
 
12
- /**
13
- * Checks if element is not visible in the viewport, accounting
14
- * for the scroll margin offset used during scrolling.
15
- */
16
- function shouldScrollIntoView(element) {
17
- var rect = element.getBoundingClientRect();
18
- var viewportHeight = window.innerHeight || document.documentElement.clientHeight;
19
- return !(rect.top >= SCROLL_TOP_MARGIN_PX && rect.bottom <= viewportHeight);
20
- }
21
-
22
12
  /**
23
13
  * Returns the resolved HTMLElement for a given DOM node, walking up to the
24
14
  * parent element if the node itself is not an Element (e.g. a text node).
@@ -61,14 +51,14 @@ export var scrollToFirstDecoration = function scrollToFirstDecoration(view, deco
61
51
  if ((_decoration$spec = decoration.spec) !== null && _decoration$spec !== void 0 && (_decoration$spec = _decoration$spec.key) !== null && _decoration$spec !== void 0 && _decoration$spec.startsWith('diff-widget') && decoration !== null && decoration !== void 0 && (_decoration$type = decoration.type) !== null && _decoration$type !== void 0 && _decoration$type.toDOM) {
62
52
  // @ts-expect-error - decoration.type is not typed public API
63
53
  var widgetDom = decoration.type.toDOM;
64
- if (shouldScrollIntoView(widgetDom)) {
65
- scrollToSelection(widgetDom);
66
- }
54
+ // Always scroll to the top of this decoration even if it's in view already
55
+ scrollToSelection(widgetDom);
67
56
  } else {
68
57
  var _view$domAtPos;
69
58
  var targetNode = view.nodeDOM(decoration === null || decoration === void 0 ? void 0 : decoration.from);
70
59
  var node = targetNode instanceof Element ? targetNode : (_view$domAtPos = view.domAtPos(decoration === null || decoration === void 0 ? void 0 : decoration.from)) === null || _view$domAtPos === void 0 ? void 0 : _view$domAtPos.node;
71
- if (node instanceof HTMLElement && shouldScrollIntoView(node)) {
60
+ if (node instanceof HTMLElement) {
61
+ // Always scroll to the top of this decoration even if it's in view already
72
62
  scrollToSelection(node);
73
63
  }
74
64
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-show-diff",
3
- "version": "8.3.5",
3
+ "version": "8.3.7",
4
4
  "description": "ShowDiff plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -28,14 +28,14 @@
28
28
  "sideEffects": false,
29
29
  "atlaskit:src": "src/index.ts",
30
30
  "dependencies": {
31
- "@atlaskit/adf-schema": "^52.9.0",
31
+ "@atlaskit/adf-schema": "^52.10.0",
32
32
  "@atlaskit/custom-steps": "^0.16.0",
33
33
  "@atlaskit/editor-plugin-analytics": "^10.0.0",
34
34
  "@atlaskit/editor-plugin-expand": "^11.1.0",
35
35
  "@atlaskit/editor-prosemirror": "^7.3.0",
36
36
  "@atlaskit/editor-tables": "^2.9.0",
37
37
  "@atlaskit/platform-feature-flags": "^1.1.0",
38
- "@atlaskit/tmp-editor-statsig": "^77.1.0",
38
+ "@atlaskit/tmp-editor-statsig": "^78.0.0",
39
39
  "@atlaskit/tokens": "^13.0.0",
40
40
  "@babel/runtime": "^7.0.0",
41
41
  "lodash": "^4.17.21",
@@ -46,7 +46,7 @@
46
46
  "@atlaskit/adf-utils": "^19.29.0",
47
47
  "@atlaskit/button": "^23.11.0",
48
48
  "@atlaskit/css": "^0.19.0",
49
- "@atlaskit/editor-core": "^219.3.0",
49
+ "@atlaskit/editor-core": "^219.6.0",
50
50
  "@atlaskit/editor-json-transformer": "^8.31.0",
51
51
  "@atlaskit/form": "^15.5.0",
52
52
  "@atlaskit/primitives": "^19.0.0",
@@ -58,7 +58,7 @@
58
58
  "react-intl": "^6.6.2"
59
59
  },
60
60
  "peerDependencies": {
61
- "@atlaskit/editor-common": "^114.21.0",
61
+ "@atlaskit/editor-common": "^114.27.0",
62
62
  "react": "^18.2.0"
63
63
  },
64
64
  "techstack": {