@atlaskit/editor-plugin-show-diff 13.0.7 → 13.0.8

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,13 @@
1
1
  # @atlaskit/editor-plugin-show-diff
2
2
 
3
+ ## 13.0.8
4
+
5
+ ### Patch Changes
6
+
7
+ - [`d4fbe7dee465e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d4fbe7dee465e) -
8
+ Consolidate diff decoration scrolling into a single internal helper.
9
+ - Updated dependencies
10
+
3
11
  ## 13.0.7
4
12
 
5
13
  ### Patch Changes
@@ -187,7 +187,7 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
187
187
  if (pluginState !== null && pluginState !== void 0 && pluginState.scrollIntoView && (0, _isExtendedEnabled.isExtendedEnabled)(pluginState === null || pluginState === void 0 ? void 0 : pluginState.diffType)) {
188
188
  var _cancelPendingScrollT;
189
189
  (_cancelPendingScrollT = cancelPendingScrollToDecoration) === null || _cancelPendingScrollT === void 0 || _cancelPendingScrollT();
190
- cancelPendingScrollToDecoration = (0, _scrollToDiff.scrollToFirstDecoration)(view, (0, _getScrollableDecorations.getScrollableDecorations)(pluginState.decorations, view.state.doc, pluginState === null || pluginState === void 0 ? void 0 : pluginState.diffType));
190
+ cancelPendingScrollToDecoration = (0, _scrollToDiff.scrollToDecoration)(view, (0, _getScrollableDecorations.getScrollableDecorations)(pluginState.decorations, view.state.doc, pluginState === null || pluginState === void 0 ? void 0 : pluginState.diffType));
191
191
 
192
192
  // Reset the flag so we don't scroll again on subsequent updates
193
193
  view.dispatch(view.state.tr.setMeta(showDiffPluginKey, {
@@ -208,7 +208,7 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
208
208
  // avoid a circular dependency; expand picks up the meta if loaded (no-op if not).
209
209
  api === null || api === void 0 || api.core.actions.execute((0, _expand.toggleExpandRange)(activeDecoration.from, activeDecoration.to, true));
210
210
  }
211
- cancelPendingScrollToDecoration = (0, _scrollToDiff.scrollToActiveDecoration)(view, scrollableDecorations, pluginState.activeIndex);
211
+ cancelPendingScrollToDecoration = (0, _scrollToDiff.scrollToDecoration)(view, scrollableDecorations, pluginState.activeIndex);
212
212
  }
213
213
  },
214
214
  destroy: function destroy() {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.scrollToFirstDecoration = exports.scrollToActiveDecoration = void 0;
6
+ exports.scrollToDecoration = void 0;
7
7
  var _decorationKeys = require("./decorations/decorationKeys");
8
8
  /**
9
9
  * Extra space above the scrolled-to element so it does not sit flush under the
@@ -40,29 +40,13 @@ function scrollToSelection(node) {
40
40
  }
41
41
 
42
42
  /**
43
- * Schedules scrolling to the first diff decoration after the next frame.
44
- * Unlike `scrollToActiveDecoration`, this does not require an active index —
45
- * it simply scrolls to bring the first decoration into view.
46
- *
47
- * The caller must pass the list of scrollable decorations as produced by
48
- * `getScrollableDecorations`, which is filtered (non-scrollable decorations
49
- * removed) and sorted by document position. This guarantees "first" means the
50
- * topmost scrollable diff in the document rather than an arbitrary decoration
51
- * from the raw `DecorationSet` ordering. This is delegated to
52
- * `scrollToActiveDecoration` at index 0 so both scroll paths behave identically.
53
- *
54
- * @returns A function that cancels the scheduled `requestAnimationFrame` if it has not run yet.
55
- */
56
- var scrollToFirstDecoration = exports.scrollToFirstDecoration = function scrollToFirstDecoration(view, scrollableDecorations) {
57
- return scrollToActiveDecoration(view, scrollableDecorations, 0);
58
- };
59
-
60
- /**
61
- * Schedules scrolling to the decoration at the given index after the next frame.
43
+ * Schedules scrolling to the decoration at the given index after the next frame. Defaults to the
44
+ * first decoration when no index is provided.
62
45
  *
63
46
  * @returns A function that cancels the scheduled `requestAnimationFrame` if it has not run yet.
64
47
  */
65
- var scrollToActiveDecoration = exports.scrollToActiveDecoration = function scrollToActiveDecoration(view, decorations, activeIndex) {
48
+ var scrollToDecoration = exports.scrollToDecoration = function scrollToDecoration(view, decorations) {
49
+ var activeIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
66
50
  var decoration = decorations[activeIndex];
67
51
  if (!decoration) {
68
52
  return function () {};
@@ -9,7 +9,7 @@ import { enforceCustomStepRegisters } from './enforceCustomStepRegisters';
9
9
  import { getScrollableDecorations } from './getScrollableDecorations';
10
10
  import { isExtendedEnabled } from './isExtendedEnabled';
11
11
  import { NodeViewSerializer } from './NodeViewSerializer';
12
- import { scrollToActiveDecoration, scrollToFirstDecoration } from './scrollToDiff';
12
+ import { scrollToDecoration } from './scrollToDiff';
13
13
  export const showDiffPluginKey = new PluginKey('showDiffPlugin');
14
14
  export const createPlugin = (config, getIntl, api, onEditorView) => {
15
15
  enforceCustomStepRegisters();
@@ -194,7 +194,7 @@ export const createPlugin = (config, getIntl, api, onEditorView) => {
194
194
  if (pluginState !== null && pluginState !== void 0 && pluginState.scrollIntoView && isExtendedEnabled(pluginState === null || pluginState === void 0 ? void 0 : pluginState.diffType)) {
195
195
  var _cancelPendingScrollT;
196
196
  (_cancelPendingScrollT = cancelPendingScrollToDecoration) === null || _cancelPendingScrollT === void 0 ? void 0 : _cancelPendingScrollT();
197
- cancelPendingScrollToDecoration = scrollToFirstDecoration(view, getScrollableDecorations(pluginState.decorations, view.state.doc, pluginState === null || pluginState === void 0 ? void 0 : pluginState.diffType));
197
+ cancelPendingScrollToDecoration = scrollToDecoration(view, getScrollableDecorations(pluginState.decorations, view.state.doc, pluginState === null || pluginState === void 0 ? void 0 : pluginState.diffType));
198
198
 
199
199
  // Reset the flag so we don't scroll again on subsequent updates
200
200
  view.dispatch(view.state.tr.setMeta(showDiffPluginKey, {
@@ -215,7 +215,7 @@ export const createPlugin = (config, getIntl, api, onEditorView) => {
215
215
  // avoid a circular dependency; expand picks up the meta if loaded (no-op if not).
216
216
  api === null || api === void 0 ? void 0 : api.core.actions.execute(toggleExpandRange(activeDecoration.from, activeDecoration.to, true));
217
217
  }
218
- cancelPendingScrollToDecoration = scrollToActiveDecoration(view, scrollableDecorations, pluginState.activeIndex);
218
+ cancelPendingScrollToDecoration = scrollToDecoration(view, scrollableDecorations, pluginState.activeIndex);
219
219
  }
220
220
  },
221
221
  destroy() {
@@ -35,27 +35,12 @@ function scrollToSelection(node) {
35
35
  }
36
36
 
37
37
  /**
38
- * Schedules scrolling to the first diff decoration after the next frame.
39
- * Unlike `scrollToActiveDecoration`, this does not require an active index —
40
- * it simply scrolls to bring the first decoration into view.
41
- *
42
- * The caller must pass the list of scrollable decorations as produced by
43
- * `getScrollableDecorations`, which is filtered (non-scrollable decorations
44
- * removed) and sorted by document position. This guarantees "first" means the
45
- * topmost scrollable diff in the document rather than an arbitrary decoration
46
- * from the raw `DecorationSet` ordering. This is delegated to
47
- * `scrollToActiveDecoration` at index 0 so both scroll paths behave identically.
48
- *
49
- * @returns A function that cancels the scheduled `requestAnimationFrame` if it has not run yet.
50
- */
51
- export const scrollToFirstDecoration = (view, scrollableDecorations) => scrollToActiveDecoration(view, scrollableDecorations, 0);
52
-
53
- /**
54
- * Schedules scrolling to the decoration at the given index after the next frame.
38
+ * Schedules scrolling to the decoration at the given index after the next frame. Defaults to the
39
+ * first decoration when no index is provided.
55
40
  *
56
41
  * @returns A function that cancels the scheduled `requestAnimationFrame` if it has not run yet.
57
42
  */
58
- export const scrollToActiveDecoration = (view, decorations, activeIndex) => {
43
+ export const scrollToDecoration = (view, decorations, activeIndex = 0) => {
59
44
  const decoration = decorations[activeIndex];
60
45
  if (!decoration) {
61
46
  return () => {};
@@ -12,7 +12,7 @@ import { enforceCustomStepRegisters } from './enforceCustomStepRegisters';
12
12
  import { getScrollableDecorations } from './getScrollableDecorations';
13
13
  import { isExtendedEnabled } from './isExtendedEnabled';
14
14
  import { NodeViewSerializer } from './NodeViewSerializer';
15
- import { scrollToActiveDecoration, scrollToFirstDecoration } from './scrollToDiff';
15
+ import { scrollToDecoration } from './scrollToDiff';
16
16
  export var showDiffPluginKey = new PluginKey('showDiffPlugin');
17
17
  export var createPlugin = function createPlugin(config, getIntl, api, onEditorView) {
18
18
  enforceCustomStepRegisters();
@@ -180,7 +180,7 @@ export var createPlugin = function createPlugin(config, getIntl, api, onEditorVi
180
180
  if (pluginState !== null && pluginState !== void 0 && pluginState.scrollIntoView && isExtendedEnabled(pluginState === null || pluginState === void 0 ? void 0 : pluginState.diffType)) {
181
181
  var _cancelPendingScrollT;
182
182
  (_cancelPendingScrollT = cancelPendingScrollToDecoration) === null || _cancelPendingScrollT === void 0 || _cancelPendingScrollT();
183
- cancelPendingScrollToDecoration = scrollToFirstDecoration(view, getScrollableDecorations(pluginState.decorations, view.state.doc, pluginState === null || pluginState === void 0 ? void 0 : pluginState.diffType));
183
+ cancelPendingScrollToDecoration = scrollToDecoration(view, getScrollableDecorations(pluginState.decorations, view.state.doc, pluginState === null || pluginState === void 0 ? void 0 : pluginState.diffType));
184
184
 
185
185
  // Reset the flag so we don't scroll again on subsequent updates
186
186
  view.dispatch(view.state.tr.setMeta(showDiffPluginKey, {
@@ -201,7 +201,7 @@ export var createPlugin = function createPlugin(config, getIntl, api, onEditorVi
201
201
  // avoid a circular dependency; expand picks up the meta if loaded (no-op if not).
202
202
  api === null || api === void 0 || api.core.actions.execute(toggleExpandRange(activeDecoration.from, activeDecoration.to, true));
203
203
  }
204
- cancelPendingScrollToDecoration = scrollToActiveDecoration(view, scrollableDecorations, pluginState.activeIndex);
204
+ cancelPendingScrollToDecoration = scrollToDecoration(view, scrollableDecorations, pluginState.activeIndex);
205
205
  }
206
206
  },
207
207
  destroy: function destroy() {
@@ -35,29 +35,13 @@ function scrollToSelection(node) {
35
35
  }
36
36
 
37
37
  /**
38
- * Schedules scrolling to the first diff decoration after the next frame.
39
- * Unlike `scrollToActiveDecoration`, this does not require an active index —
40
- * it simply scrolls to bring the first decoration into view.
41
- *
42
- * The caller must pass the list of scrollable decorations as produced by
43
- * `getScrollableDecorations`, which is filtered (non-scrollable decorations
44
- * removed) and sorted by document position. This guarantees "first" means the
45
- * topmost scrollable diff in the document rather than an arbitrary decoration
46
- * from the raw `DecorationSet` ordering. This is delegated to
47
- * `scrollToActiveDecoration` at index 0 so both scroll paths behave identically.
48
- *
49
- * @returns A function that cancels the scheduled `requestAnimationFrame` if it has not run yet.
50
- */
51
- export var scrollToFirstDecoration = function scrollToFirstDecoration(view, scrollableDecorations) {
52
- return scrollToActiveDecoration(view, scrollableDecorations, 0);
53
- };
54
-
55
- /**
56
- * Schedules scrolling to the decoration at the given index after the next frame.
38
+ * Schedules scrolling to the decoration at the given index after the next frame. Defaults to the
39
+ * first decoration when no index is provided.
57
40
  *
58
41
  * @returns A function that cancels the scheduled `requestAnimationFrame` if it has not run yet.
59
42
  */
60
- export var scrollToActiveDecoration = function scrollToActiveDecoration(view, decorations, activeIndex) {
43
+ export var scrollToDecoration = function scrollToDecoration(view, decorations) {
44
+ var activeIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
61
45
  var decoration = decorations[activeIndex];
62
46
  if (!decoration) {
63
47
  return function () {};
@@ -1,22 +1,8 @@
1
1
  import type { EditorView, Decoration } from '@atlaskit/editor-prosemirror/view';
2
2
  /**
3
- * Schedules scrolling to the first diff decoration after the next frame.
4
- * Unlike `scrollToActiveDecoration`, this does not require an active index —
5
- * it simply scrolls to bring the first decoration into view.
6
- *
7
- * The caller must pass the list of scrollable decorations as produced by
8
- * `getScrollableDecorations`, which is filtered (non-scrollable decorations
9
- * removed) and sorted by document position. This guarantees "first" means the
10
- * topmost scrollable diff in the document rather than an arbitrary decoration
11
- * from the raw `DecorationSet` ordering. This is delegated to
12
- * `scrollToActiveDecoration` at index 0 so both scroll paths behave identically.
13
- *
14
- * @returns A function that cancels the scheduled `requestAnimationFrame` if it has not run yet.
15
- */
16
- export declare const scrollToFirstDecoration: (view: EditorView, scrollableDecorations: Decoration[]) => (() => void);
17
- /**
18
- * Schedules scrolling to the decoration at the given index after the next frame.
3
+ * Schedules scrolling to the decoration at the given index after the next frame. Defaults to the
4
+ * first decoration when no index is provided.
19
5
  *
20
6
  * @returns A function that cancels the scheduled `requestAnimationFrame` if it has not run yet.
21
7
  */
22
- export declare const scrollToActiveDecoration: (view: EditorView, decorations: Decoration[], activeIndex: number) => (() => void);
8
+ export declare const scrollToDecoration: (view: EditorView, decorations: Decoration[], activeIndex?: number) => (() => void);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-show-diff",
3
- "version": "13.0.7",
3
+ "version": "13.0.8",
4
4
  "description": "ShowDiff plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "devDependencies": {
39
39
  "@atlaskit/adf-utils": "^20.6.0",
40
- "@atlaskit/button": "^25.0.0",
40
+ "@atlaskit/button": "^25.1.0",
41
41
  "@atlaskit/css": "^1.0.0",
42
42
  "@atlaskit/dropdown-menu": "^18.0.0",
43
43
  "@atlaskit/editor-core": "^224.1.0",
@@ -53,7 +53,7 @@
53
53
  "react-intl": "^7.0.0"
54
54
  },
55
55
  "peerDependencies": {
56
- "@atlaskit/editor-common": "^119.7.0",
56
+ "@atlaskit/editor-common": "^119.8.0",
57
57
  "react": "^18.2.0 || ^19.2.0"
58
58
  },
59
59
  "techstack": {