@atlaskit/editor-plugin-show-diff 4.1.3 → 4.1.4

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
+ ## 4.1.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [`4031146a0af6d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4031146a0af6d) -
8
+ Updating the PR to calculate the correct number of decorations for display.
9
+ - Updated dependencies
10
+
3
11
  ## 4.1.3
4
12
 
5
13
  ### Patch Changes
@@ -27,11 +27,14 @@ var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration
27
27
  // Iterate over the document nodes within the range
28
28
  doc.nodesBetween(from, to, function (node, pos) {
29
29
  if (node.isBlock) {
30
- decorations.push((0, _decorations.createBlockChangedDecoration)({
30
+ var decoration = (0, _decorations.createBlockChangedDecoration)({
31
31
  from: pos,
32
32
  to: pos + node.nodeSize,
33
33
  name: node.type.name
34
- }, colourScheme));
34
+ }, colourScheme);
35
+ if (decoration) {
36
+ decorations.push(decoration);
37
+ }
35
38
  }
36
39
  });
37
40
  return decorations;
@@ -30,7 +30,9 @@ var createInlineChangedDecoration = exports.createInlineChangedDecoration = func
30
30
  return _view.Decoration.inline(change.fromB, change.toB, {
31
31
  style: style,
32
32
  'data-testid': 'show-diff-changed-decoration'
33
- }, {});
33
+ }, {
34
+ key: 'diff-inline'
35
+ });
34
36
  };
35
37
  var getDeletedContentStyleUnbounded = exports.getDeletedContentStyleUnbounded = function getDeletedContentStyleUnbounded(colourScheme) {
36
38
  return colourScheme === 'traditional' ? _traditional.deletedTraditionalContentStyleUnbounded : _standard.deletedContentStyleUnbounded;
@@ -64,11 +66,28 @@ var getBlockNodeStyle = function getBlockNodeStyle(name, colourScheme) {
64
66
  * @returns Prosemirror inline decoration
65
67
  */
66
68
  var createBlockChangedDecoration = exports.createBlockChangedDecoration = function createBlockChangedDecoration(change, colourScheme) {
67
- return _view.Decoration.node(change.from, change.to, {
68
- style: getBlockNodeStyle(change.name, colourScheme),
69
- 'data-testid': 'show-diff-changed-decoration-node',
70
- class: getNodeClass(change.name)
71
- }, {});
69
+ if ((0, _platformFeatureFlags.fg)('platform_editor_show_diff_scroll_navigation')) {
70
+ var style = getBlockNodeStyle(change.name, colourScheme);
71
+ var className = getNodeClass(change.name);
72
+ if (style || className) {
73
+ return _view.Decoration.node(change.from, change.to, {
74
+ style: style,
75
+ 'data-testid': 'show-diff-changed-decoration-node',
76
+ class: className
77
+ }, {
78
+ key: 'diff-block'
79
+ });
80
+ }
81
+ return undefined;
82
+ } else {
83
+ return _view.Decoration.node(change.from, change.to, {
84
+ style: getBlockNodeStyle(change.name, colourScheme),
85
+ 'data-testid': 'show-diff-changed-decoration-node',
86
+ class: getNodeClass(change.name)
87
+ }, {
88
+ key: 'diff-block'
89
+ });
90
+ }
72
91
  };
73
92
  var createContentWrapper = function createContentWrapper(colourScheme) {
74
93
  var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
@@ -212,5 +231,7 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
212
231
  // Widget decoration used for deletions as the content is not in the document
213
232
  // and we want to display the deleted content with a style.
214
233
  var safeInsertPos = (0, _findSafeInsertPos.findSafeInsertPos)(newDoc, change.fromB, slice);
215
- return [_view.Decoration.widget(safeInsertPos, dom)];
234
+ return [_view.Decoration.widget(safeInsertPos, dom, {
235
+ key: 'diff-widget'
236
+ })];
216
237
  };
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.showDiffPluginKey = exports.createPlugin = void 0;
7
+ exports.showDiffPluginKey = exports.getScrollableDecorations = exports.createPlugin = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _processRawValue = require("@atlaskit/editor-common/process-raw-value");
10
10
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
@@ -17,6 +17,12 @@ var _NodeViewSerializer = require("./NodeViewSerializer");
17
17
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
18
18
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
19
19
  var showDiffPluginKey = exports.showDiffPluginKey = new _state2.PluginKey('showDiffPlugin');
20
+ var getScrollableDecorations = exports.getScrollableDecorations = function getScrollableDecorations(set) {
21
+ var _set$find;
22
+ return (_set$find = set === null || set === void 0 ? void 0 : set.find(undefined, undefined, function (spec) {
23
+ return spec.key === 'diff-inline' || spec.key === 'diff-widget' || spec.key === 'diff-block';
24
+ })) !== null && _set$find !== void 0 ? _set$find : [];
25
+ };
20
26
  var createPlugin = exports.createPlugin = function createPlugin(config, getIntl) {
21
27
  var nodeViewSerializer = new _NodeViewSerializer.NodeViewSerializer({});
22
28
  var setNodeViewSerializer = function setNodeViewSerializer(editorView) {
@@ -43,7 +49,7 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl)
43
49
  if (!pluginState || pluginState.decorations.find().length === 0) {
44
50
  return;
45
51
  }
46
- var decorations = pluginState.decorations.find();
52
+ var decorations = getScrollableDecorations(pluginState.decorations);
47
53
  var decoration = decorations[(_pluginState$activeIn = pluginState.activeIndex) !== null && _pluginState$activeIn !== void 0 ? _pluginState$activeIn : 0];
48
54
  if (!decoration) {
49
55
  return;
@@ -99,7 +105,7 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl)
99
105
  });
100
106
  } else if (((meta === null || meta === void 0 ? void 0 : meta.action) === 'SCROLL_TO_NEXT' || (meta === null || meta === void 0 ? void 0 : meta.action) === 'SCROLL_TO_PREVIOUS') && (0, _platformFeatureFlags.fg)('platform_editor_show_diff_scroll_navigation')) {
101
107
  // Update the active index in plugin state and recalculate decorations
102
- var _decorations = currentPluginState.decorations.find();
108
+ var _decorations = getScrollableDecorations(currentPluginState.decorations);
103
109
  if (_decorations.length > 0) {
104
110
  var _currentPluginState$a;
105
111
  var nextIndex = (_currentPluginState$a = currentPluginState.activeIndex) !== null && _currentPluginState$a !== void 0 ? _currentPluginState$a : 0;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.showDiffPlugin = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
9
10
  var _main = require("./pm-plugins/main");
10
11
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
11
12
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -61,7 +62,7 @@ var showDiffPlugin = exports.showDiffPlugin = function showDiffPlugin(_ref) {
61
62
  };
62
63
  }
63
64
  var pluginState = _main.showDiffPluginKey.getState(editorState);
64
- var decorationCount = (pluginState === null || pluginState === void 0 || (_pluginState$decorati = pluginState.decorations) === null || _pluginState$decorati === void 0 ? void 0 : _pluginState$decorati.find()) || [];
65
+ var decorationCount = (0, _platformFeatureFlags.fg)('platform_editor_show_diff_scroll_navigation') ? (0, _main.getScrollableDecorations)(pluginState === null || pluginState === void 0 ? void 0 : pluginState.decorations) : (pluginState === null || pluginState === void 0 || (_pluginState$decorati = pluginState.decorations) === null || _pluginState$decorati === void 0 ? void 0 : _pluginState$decorati.find()) || [];
65
66
  return {
66
67
  isDisplayingChanges: decorationCount.length > 0,
67
68
  activeIndex: pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex,
@@ -13,11 +13,14 @@ const calculateNodesForBlockDecoration = (doc, from, to, colourScheme) => {
13
13
  // Iterate over the document nodes within the range
14
14
  doc.nodesBetween(from, to, (node, pos) => {
15
15
  if (node.isBlock) {
16
- decorations.push(createBlockChangedDecoration({
16
+ const decoration = createBlockChangedDecoration({
17
17
  from: pos,
18
18
  to: pos + node.nodeSize,
19
19
  name: node.type.name
20
- }, colourScheme));
20
+ }, colourScheme);
21
+ if (decoration) {
22
+ decorations.push(decoration);
23
+ }
21
24
  }
22
25
  });
23
26
  return decorations;
@@ -23,7 +23,9 @@ export const createInlineChangedDecoration = (change, colourScheme, isActive = f
23
23
  return Decoration.inline(change.fromB, change.toB, {
24
24
  style,
25
25
  'data-testid': 'show-diff-changed-decoration'
26
- }, {});
26
+ }, {
27
+ key: 'diff-inline'
28
+ });
27
29
  };
28
30
  export const getDeletedContentStyleUnbounded = colourScheme => colourScheme === 'traditional' ? deletedTraditionalContentStyleUnbounded : deletedContentStyleUnbounded;
29
31
  export const getDeletedContentStyle = (colourScheme, isActive = false) => {
@@ -53,11 +55,30 @@ const getBlockNodeStyle = (name, colourScheme) => {
53
55
  * @param change Changeset "change" containing information about the change content + range
54
56
  * @returns Prosemirror inline decoration
55
57
  */
56
- export const createBlockChangedDecoration = (change, colourScheme) => Decoration.node(change.from, change.to, {
57
- style: getBlockNodeStyle(change.name, colourScheme),
58
- 'data-testid': 'show-diff-changed-decoration-node',
59
- class: getNodeClass(change.name)
60
- }, {});
58
+ export const createBlockChangedDecoration = (change, colourScheme) => {
59
+ if (fg('platform_editor_show_diff_scroll_navigation')) {
60
+ const style = getBlockNodeStyle(change.name, colourScheme);
61
+ const className = getNodeClass(change.name);
62
+ if (style || className) {
63
+ return Decoration.node(change.from, change.to, {
64
+ style: style,
65
+ 'data-testid': 'show-diff-changed-decoration-node',
66
+ class: className
67
+ }, {
68
+ key: 'diff-block'
69
+ });
70
+ }
71
+ return undefined;
72
+ } else {
73
+ return Decoration.node(change.from, change.to, {
74
+ style: getBlockNodeStyle(change.name, colourScheme),
75
+ 'data-testid': 'show-diff-changed-decoration-node',
76
+ class: getNodeClass(change.name)
77
+ }, {
78
+ key: 'diff-block'
79
+ });
80
+ }
81
+ };
61
82
  const createContentWrapper = (colourScheme, isActive = false) => {
62
83
  const wrapper = document.createElement('span');
63
84
  const baseStyle = convertToInlineCss({
@@ -188,5 +209,7 @@ export const createDeletedContentDecoration = ({
188
209
  // Widget decoration used for deletions as the content is not in the document
189
210
  // and we want to display the deleted content with a style.
190
211
  const safeInsertPos = findSafeInsertPos(newDoc, change.fromB, slice);
191
- return [Decoration.widget(safeInsertPos, dom)];
212
+ return [Decoration.widget(safeInsertPos, dom, {
213
+ key: 'diff-widget'
214
+ })];
192
215
  };
@@ -7,6 +7,10 @@ import { fg } from '@atlaskit/platform-feature-flags';
7
7
  import { calculateDiffDecorations } from './calculateDiffDecorations';
8
8
  import { NodeViewSerializer } from './NodeViewSerializer';
9
9
  export const showDiffPluginKey = new PluginKey('showDiffPlugin');
10
+ export const getScrollableDecorations = set => {
11
+ var _set$find;
12
+ return (_set$find = set === null || set === void 0 ? void 0 : set.find(undefined, undefined, spec => spec.key === 'diff-inline' || spec.key === 'diff-widget' || spec.key === 'diff-block')) !== null && _set$find !== void 0 ? _set$find : [];
13
+ };
10
14
  export const createPlugin = (config, getIntl) => {
11
15
  const nodeViewSerializer = new NodeViewSerializer({});
12
16
  const setNodeViewSerializer = editorView => {
@@ -33,7 +37,7 @@ export const createPlugin = (config, getIntl) => {
33
37
  if (!pluginState || pluginState.decorations.find().length === 0) {
34
38
  return;
35
39
  }
36
- const decorations = pluginState.decorations.find();
40
+ const decorations = getScrollableDecorations(pluginState.decorations);
37
41
  const decoration = decorations[(_pluginState$activeIn = pluginState.activeIndex) !== null && _pluginState$activeIn !== void 0 ? _pluginState$activeIn : 0];
38
42
  if (!decoration) {
39
43
  return;
@@ -95,7 +99,7 @@ export const createPlugin = (config, getIntl) => {
95
99
  };
96
100
  } else if (((meta === null || meta === void 0 ? void 0 : meta.action) === 'SCROLL_TO_NEXT' || (meta === null || meta === void 0 ? void 0 : meta.action) === 'SCROLL_TO_PREVIOUS') && fg('platform_editor_show_diff_scroll_navigation')) {
97
101
  // Update the active index in plugin state and recalculate decorations
98
- const decorations = currentPluginState.decorations.find();
102
+ const decorations = getScrollableDecorations(currentPluginState.decorations);
99
103
  if (decorations.length > 0) {
100
104
  var _currentPluginState$a;
101
105
  let nextIndex = (_currentPluginState$a = currentPluginState.activeIndex) !== null && _currentPluginState$a !== void 0 ? _currentPluginState$a : 0;
@@ -1,4 +1,5 @@
1
- import { createPlugin, showDiffPluginKey } from './pm-plugins/main';
1
+ import { fg } from '@atlaskit/platform-feature-flags';
2
+ import { createPlugin, showDiffPluginKey, getScrollableDecorations } from './pm-plugins/main';
2
3
  export const showDiffPlugin = ({
3
4
  api: _api,
4
5
  config
@@ -53,7 +54,7 @@ export const showDiffPlugin = ({
53
54
  };
54
55
  }
55
56
  const pluginState = showDiffPluginKey.getState(editorState);
56
- const decorationCount = (pluginState === null || pluginState === void 0 ? void 0 : (_pluginState$decorati = pluginState.decorations) === null || _pluginState$decorati === void 0 ? void 0 : _pluginState$decorati.find()) || [];
57
+ const decorationCount = fg('platform_editor_show_diff_scroll_navigation') ? getScrollableDecorations(pluginState === null || pluginState === void 0 ? void 0 : pluginState.decorations) : (pluginState === null || pluginState === void 0 ? void 0 : (_pluginState$decorati = pluginState.decorations) === null || _pluginState$decorati === void 0 ? void 0 : _pluginState$decorati.find()) || [];
57
58
  return {
58
59
  isDisplayingChanges: decorationCount.length > 0,
59
60
  activeIndex: pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex,
@@ -21,11 +21,14 @@ var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration
21
21
  // Iterate over the document nodes within the range
22
22
  doc.nodesBetween(from, to, function (node, pos) {
23
23
  if (node.isBlock) {
24
- decorations.push(createBlockChangedDecoration({
24
+ var decoration = createBlockChangedDecoration({
25
25
  from: pos,
26
26
  to: pos + node.nodeSize,
27
27
  name: node.type.name
28
- }, colourScheme));
28
+ }, colourScheme);
29
+ if (decoration) {
30
+ decorations.push(decoration);
31
+ }
29
32
  }
30
33
  });
31
34
  return decorations;
@@ -24,7 +24,9 @@ export var createInlineChangedDecoration = function createInlineChangedDecoratio
24
24
  return Decoration.inline(change.fromB, change.toB, {
25
25
  style: style,
26
26
  'data-testid': 'show-diff-changed-decoration'
27
- }, {});
27
+ }, {
28
+ key: 'diff-inline'
29
+ });
28
30
  };
29
31
  export var getDeletedContentStyleUnbounded = function getDeletedContentStyleUnbounded(colourScheme) {
30
32
  return colourScheme === 'traditional' ? deletedTraditionalContentStyleUnbounded : deletedContentStyleUnbounded;
@@ -58,11 +60,28 @@ var getBlockNodeStyle = function getBlockNodeStyle(name, colourScheme) {
58
60
  * @returns Prosemirror inline decoration
59
61
  */
60
62
  export var createBlockChangedDecoration = function createBlockChangedDecoration(change, colourScheme) {
61
- return Decoration.node(change.from, change.to, {
62
- style: getBlockNodeStyle(change.name, colourScheme),
63
- 'data-testid': 'show-diff-changed-decoration-node',
64
- class: getNodeClass(change.name)
65
- }, {});
63
+ if (fg('platform_editor_show_diff_scroll_navigation')) {
64
+ var style = getBlockNodeStyle(change.name, colourScheme);
65
+ var className = getNodeClass(change.name);
66
+ if (style || className) {
67
+ return Decoration.node(change.from, change.to, {
68
+ style: style,
69
+ 'data-testid': 'show-diff-changed-decoration-node',
70
+ class: className
71
+ }, {
72
+ key: 'diff-block'
73
+ });
74
+ }
75
+ return undefined;
76
+ } else {
77
+ return Decoration.node(change.from, change.to, {
78
+ style: getBlockNodeStyle(change.name, colourScheme),
79
+ 'data-testid': 'show-diff-changed-decoration-node',
80
+ class: getNodeClass(change.name)
81
+ }, {
82
+ key: 'diff-block'
83
+ });
84
+ }
66
85
  };
67
86
  var createContentWrapper = function createContentWrapper(colourScheme) {
68
87
  var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
@@ -206,5 +225,7 @@ export var createDeletedContentDecoration = function createDeletedContentDecorat
206
225
  // Widget decoration used for deletions as the content is not in the document
207
226
  // and we want to display the deleted content with a style.
208
227
  var safeInsertPos = findSafeInsertPos(newDoc, change.fromB, slice);
209
- return [Decoration.widget(safeInsertPos, dom)];
228
+ return [Decoration.widget(safeInsertPos, dom, {
229
+ key: 'diff-widget'
230
+ })];
210
231
  };
@@ -10,6 +10,12 @@ import { fg } from '@atlaskit/platform-feature-flags';
10
10
  import { calculateDiffDecorations } from './calculateDiffDecorations';
11
11
  import { NodeViewSerializer } from './NodeViewSerializer';
12
12
  export var showDiffPluginKey = new PluginKey('showDiffPlugin');
13
+ export var getScrollableDecorations = function getScrollableDecorations(set) {
14
+ var _set$find;
15
+ return (_set$find = set === null || set === void 0 ? void 0 : set.find(undefined, undefined, function (spec) {
16
+ return spec.key === 'diff-inline' || spec.key === 'diff-widget' || spec.key === 'diff-block';
17
+ })) !== null && _set$find !== void 0 ? _set$find : [];
18
+ };
13
19
  export var createPlugin = function createPlugin(config, getIntl) {
14
20
  var nodeViewSerializer = new NodeViewSerializer({});
15
21
  var setNodeViewSerializer = function setNodeViewSerializer(editorView) {
@@ -36,7 +42,7 @@ export var createPlugin = function createPlugin(config, getIntl) {
36
42
  if (!pluginState || pluginState.decorations.find().length === 0) {
37
43
  return;
38
44
  }
39
- var decorations = pluginState.decorations.find();
45
+ var decorations = getScrollableDecorations(pluginState.decorations);
40
46
  var decoration = decorations[(_pluginState$activeIn = pluginState.activeIndex) !== null && _pluginState$activeIn !== void 0 ? _pluginState$activeIn : 0];
41
47
  if (!decoration) {
42
48
  return;
@@ -92,7 +98,7 @@ export var createPlugin = function createPlugin(config, getIntl) {
92
98
  });
93
99
  } else if (((meta === null || meta === void 0 ? void 0 : meta.action) === 'SCROLL_TO_NEXT' || (meta === null || meta === void 0 ? void 0 : meta.action) === 'SCROLL_TO_PREVIOUS') && fg('platform_editor_show_diff_scroll_navigation')) {
94
100
  // Update the active index in plugin state and recalculate decorations
95
- var _decorations = currentPluginState.decorations.find();
101
+ var _decorations = getScrollableDecorations(currentPluginState.decorations);
96
102
  if (_decorations.length > 0) {
97
103
  var _currentPluginState$a;
98
104
  var nextIndex = (_currentPluginState$a = currentPluginState.activeIndex) !== null && _currentPluginState$a !== void 0 ? _currentPluginState$a : 0;
@@ -1,7 +1,8 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
- import { createPlugin, showDiffPluginKey } from './pm-plugins/main';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
5
+ import { createPlugin, showDiffPluginKey, getScrollableDecorations } from './pm-plugins/main';
5
6
  export var showDiffPlugin = function showDiffPlugin(_ref) {
6
7
  var _api = _ref.api,
7
8
  config = _ref.config;
@@ -54,7 +55,7 @@ export var showDiffPlugin = function showDiffPlugin(_ref) {
54
55
  };
55
56
  }
56
57
  var pluginState = showDiffPluginKey.getState(editorState);
57
- var decorationCount = (pluginState === null || pluginState === void 0 || (_pluginState$decorati = pluginState.decorations) === null || _pluginState$decorati === void 0 ? void 0 : _pluginState$decorati.find()) || [];
58
+ var decorationCount = fg('platform_editor_show_diff_scroll_navigation') ? getScrollableDecorations(pluginState === null || pluginState === void 0 ? void 0 : pluginState.decorations) : (pluginState === null || pluginState === void 0 || (_pluginState$decorati = pluginState.decorations) === null || _pluginState$decorati === void 0 ? void 0 : _pluginState$decorati.find()) || [];
58
59
  return {
59
60
  isDisplayingChanges: decorationCount.length > 0,
60
61
  activeIndex: pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex,
@@ -25,7 +25,7 @@ export declare const createBlockChangedDecoration: (change: {
25
25
  from: number;
26
26
  name: string;
27
27
  to: number;
28
- }, colourScheme?: "standard" | "traditional") => Decoration;
28
+ }, colourScheme?: "standard" | "traditional") => Decoration | undefined;
29
29
  interface DeletedContentDecorationProps {
30
30
  change: Pick<Change, 'fromA' | 'toA' | 'fromB' | 'deleted'>;
31
31
  colourScheme?: 'standard' | 'traditional';
@@ -3,6 +3,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
3
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
4
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
5
5
  import { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
6
+ import type { Decoration } from '@atlaskit/editor-prosemirror/view';
6
7
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
7
8
  import { type DiffParams } from '../showDiffPluginType';
8
9
  export declare const showDiffPluginKey: PluginKey<ShowDiffPluginState>;
@@ -17,4 +18,5 @@ export type ShowDiffPluginState = {
17
18
  originalDoc: PMNode | undefined;
18
19
  steps: ProseMirrorStep[];
19
20
  };
21
+ export declare const getScrollableDecorations: (set: DecorationSet | undefined) => Decoration[];
20
22
  export declare const createPlugin: (config: DiffParams | undefined, getIntl: () => IntlShape) => SafePlugin<ShowDiffPluginState>;
@@ -25,7 +25,7 @@ export declare const createBlockChangedDecoration: (change: {
25
25
  from: number;
26
26
  name: string;
27
27
  to: number;
28
- }, colourScheme?: "standard" | "traditional") => Decoration;
28
+ }, colourScheme?: "standard" | "traditional") => Decoration | undefined;
29
29
  interface DeletedContentDecorationProps {
30
30
  change: Pick<Change, 'fromA' | 'toA' | 'fromB' | 'deleted'>;
31
31
  colourScheme?: 'standard' | 'traditional';
@@ -3,6 +3,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
3
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
4
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
5
5
  import { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
6
+ import type { Decoration } from '@atlaskit/editor-prosemirror/view';
6
7
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
7
8
  import { type DiffParams } from '../showDiffPluginType';
8
9
  export declare const showDiffPluginKey: PluginKey<ShowDiffPluginState>;
@@ -17,4 +18,5 @@ export type ShowDiffPluginState = {
17
18
  originalDoc: PMNode | undefined;
18
19
  steps: ProseMirrorStep[];
19
20
  };
21
+ export declare const getScrollableDecorations: (set: DecorationSet | undefined) => Decoration[];
20
22
  export declare const createPlugin: (config: DiffParams | undefined, getIntl: () => IntlShape) => SafePlugin<ShowDiffPluginState>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-show-diff",
3
- "version": "4.1.3",
3
+ "version": "4.1.4",
4
4
  "description": "ShowDiff plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,7 +32,7 @@
32
32
  "@atlaskit/editor-prosemirror": "^7.3.0",
33
33
  "@atlaskit/editor-tables": "^2.9.0",
34
34
  "@atlaskit/platform-feature-flags": "^1.1.0",
35
- "@atlaskit/tmp-editor-statsig": "^32.10.0",
35
+ "@atlaskit/tmp-editor-statsig": "^32.11.0",
36
36
  "@atlaskit/tokens": "^11.0.0",
37
37
  "@babel/runtime": "^7.0.0",
38
38
  "lodash": "^4.17.21",