@atlaskit/editor-plugin-show-diff 5.0.8 → 5.0.10

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,20 @@
1
1
  # @atlaskit/editor-plugin-show-diff
2
2
 
3
+ ## 5.0.10
4
+
5
+ ### Patch Changes
6
+
7
+ - [`8acefc80a7a89`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8acefc80a7a89) -
8
+ Fixed initial activeIndex to be undefined instead of 0, preventing auto-selection on diff
9
+ initialization. Also update tests accordingly
10
+
11
+ ## 5.0.9
12
+
13
+ ### Patch Changes
14
+
15
+ - [`db37927f35395`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/db37927f35395) -
16
+ Cleanup platform_editor_ai_aifc_patch_ga_blockers flag.
17
+
3
18
  ## 5.0.8
4
19
 
5
20
  ### Patch Changes
@@ -1,19 +1,14 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.wrapBlockNodeView = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
7
  var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
10
8
  var _messages = require("@atlaskit/editor-common/messages");
11
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
9
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
13
10
  var _standard = require("../colorSchemes/standard");
14
11
  var _traditional = require("../colorSchemes/traditional");
15
- 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; }
16
- 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; }
17
12
  var lozengeStyle = (0, _lazyNodeView.convertToInlineCss)({
18
13
  display: 'inline-flex',
19
14
  boxSizing: 'border-box',
@@ -44,13 +39,13 @@ var getDeletedStyleNode = function getDeletedStyleNode(nodeName, colorScheme) {
44
39
  var isTraditional = colorScheme === 'traditional';
45
40
  switch (nodeName) {
46
41
  case 'blockquote':
47
- return (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers') ? isTraditional ? _traditional.deletedTraditionalStyleQuoteNode : _standard.deletedStyleQuoteNodeWithLozenge : _standard.deletedStyleQuoteNode;
42
+ return isTraditional ? _traditional.deletedTraditionalStyleQuoteNode : _standard.deletedStyleQuoteNodeWithLozenge;
48
43
  case 'expand':
49
44
  case 'decisionList':
50
- return isTraditional && (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers') ? _traditional.deletedTraditionalBlockOutline : _standard.deletedBlockOutline;
45
+ return isTraditional ? _traditional.deletedTraditionalBlockOutline : _standard.deletedBlockOutline;
51
46
  case 'panel':
52
47
  case 'codeBlock':
53
- return isTraditional && (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers') ? _traditional.deletedTraditionalBlockOutlineRounded : _standard.deletedBlockOutlineRounded;
48
+ return isTraditional ? _traditional.deletedTraditionalBlockOutlineRounded : _standard.deletedBlockOutlineRounded;
54
49
  default:
55
50
  return undefined;
56
51
  }
@@ -65,7 +60,7 @@ var shouldShowRemovedLozenge = function shouldShowRemovedLozenge(nodeName) {
65
60
  return true;
66
61
  case 'embedCard':
67
62
  case 'blockquote':
68
- return (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers');
63
+ return true;
69
64
  default:
70
65
  return false;
71
66
  }
@@ -76,7 +71,7 @@ var shouldAddShowDiffDeletedNodeClass = function shouldAddShowDiffDeletedNodeCla
76
71
  case 'embedCard':
77
72
  return true;
78
73
  case 'blockquote':
79
- return (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers');
74
+ return true;
80
75
  default:
81
76
  return false;
82
77
  }
@@ -87,31 +82,22 @@ var shouldAddShowDiffDeletedNodeClass = function shouldAddShowDiffDeletedNodeCla
87
82
  * to preserve natural block-level margins
88
83
  */
89
84
  var shouldApplyStylesDirectly = function shouldApplyStylesDirectly(nodeName) {
90
- return nodeName === 'heading' || nodeName === 'blockquote' && !(0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers');
85
+ return nodeName === 'heading';
91
86
  };
92
87
 
93
88
  /**
94
89
  * Creates a "Removed" lozenge to be displayed at the top right corner of deleted block nodes
95
90
  */
96
- var createRemovedLozenge = function createRemovedLozenge(intl, nodeName) {
91
+ var createRemovedLozenge = function createRemovedLozenge(intl) {
97
92
  var container = document.createElement('span');
98
- var borderTopRightRadius;
99
- if (['expand', 'decisionList'].includes(nodeName || '')) {
100
- borderTopRightRadius = "var(--ds-radius-small, 4px)";
101
- } else if (['panel', 'codeBlock', 'mediaSingle'].includes(nodeName || '')) {
102
- borderTopRightRadius = "calc(".concat("var(--ds-radius-xsmall, 2px)", " + 1px)");
103
- }
104
- var containerStyle = (0, _lazyNodeView.convertToInlineCss)(_objectSpread({
93
+ var containerStyle = (0, _lazyNodeView.convertToInlineCss)({
105
94
  position: 'absolute',
106
- top: (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers') ? "var(--ds-space-075, 6px)" : "var(--ds-space-0, 0px)",
107
- right: (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers') ? "var(--ds-space-075, 6px)" : "var(--ds-space-0, 0px)",
95
+ top: "var(--ds-space-075, 6px)",
96
+ right: "var(--ds-space-075, 6px)",
108
97
  zIndex: 2,
109
98
  pointerEvents: 'none',
110
99
  display: 'flex'
111
- }, !(0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers') ? {
112
- overflow: 'hidden',
113
- borderTopRightRadius: borderTopRightRadius
114
- } : {}));
100
+ });
115
101
  container.setAttribute('style', containerStyle);
116
102
  container.setAttribute('data-testid', 'show-diff-removed-lozenge');
117
103
 
@@ -231,7 +217,7 @@ var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(_ref4)
231
217
 
232
218
  // Add deleted node class if needed
233
219
  if (shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
234
- var showDiffDeletedNodeClass = colorScheme === 'traditional' && (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers') ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
220
+ var showDiffDeletedNodeClass = colorScheme === 'traditional' ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
235
221
  nodeView.classList.add(showDiffDeletedNodeClass);
236
222
  }
237
223
  dom.append(nodeView);
@@ -256,7 +242,7 @@ var wrapBlockNode = function wrapBlockNode(_ref5) {
256
242
  targetNode: targetNode,
257
243
  lozenge: lozenge,
258
244
  colorScheme: colorScheme
259
- }) && (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers')) {
245
+ })) {
260
246
  return;
261
247
  }
262
248
  if (handleMediaSingleWithLozenge({
@@ -277,7 +263,7 @@ var wrapBlockNode = function wrapBlockNode(_ref5) {
277
263
  });
278
264
  blockWrapper.append(contentWrapper);
279
265
  if (nodeView instanceof HTMLElement && shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
280
- var showDiffDeletedNodeClass = colorScheme === 'traditional' && (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers') ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
266
+ var showDiffDeletedNodeClass = colorScheme === 'traditional' ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
281
267
  nodeView.classList.add(showDiffDeletedNodeClass);
282
268
  }
283
269
  dom.append(blockWrapper);
@@ -51,7 +51,7 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
51
51
  // Update the plugin state with the new metadata
52
52
  newPluginState = _objectSpread(_objectSpread(_objectSpread({}, currentPluginState), meta), {}, {
53
53
  isDisplayingChanges: true,
54
- activeIndex: 0
54
+ activeIndex: undefined
55
55
  });
56
56
  // Calculate and store decorations in state
57
57
  var decorations = (0, _calculateDiffDecorations.calculateDiffDecorations)({
@@ -76,11 +76,19 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
76
76
  var _decorations = getScrollableDecorations(currentPluginState.decorations);
77
77
  if (_decorations.length > 0) {
78
78
  var _currentPluginState$a;
79
- var nextIndex = (_currentPluginState$a = currentPluginState.activeIndex) !== null && _currentPluginState$a !== void 0 ? _currentPluginState$a : 0;
79
+ // Initialize to -1 if undefined so that the first "next" scroll takes us to index 0 (first change).
80
+ // This allows the UI to start with no selection and only highlight on first user interaction.
81
+ var nextIndex = (_currentPluginState$a = currentPluginState.activeIndex) !== null && _currentPluginState$a !== void 0 ? _currentPluginState$a : -1;
80
82
  if (meta.action === 'SCROLL_TO_NEXT') {
81
83
  nextIndex = (nextIndex + 1) % _decorations.length;
82
84
  } else {
83
- nextIndex = (nextIndex - 1 + _decorations.length) % _decorations.length;
85
+ // Handle scrolling backwards from the uninitialized state.
86
+ // If at -1 (no selection), wrap to the last decoration.
87
+ if (nextIndex === -1) {
88
+ nextIndex = _decorations.length - 1;
89
+ } else {
90
+ nextIndex = (nextIndex - 1 + _decorations.length) % _decorations.length;
91
+ }
84
92
  }
85
93
  var activeDecoration = _decorations[nextIndex];
86
94
  newPluginState = _objectSpread(_objectSpread({}, currentPluginState), {}, {
@@ -134,7 +142,7 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
134
142
  var pluginState = showDiffPluginKey.getState(view.state);
135
143
  var activeIndexChanged = (pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex) !== undefined && pluginState.activeIndex !== previousActiveIndex;
136
144
  previousActiveIndex = pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex;
137
- if (pluginState !== null && pluginState !== void 0 && pluginState.activeIndex && activeIndexChanged) {
145
+ if ((pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex) !== undefined && activeIndexChanged) {
138
146
  (0, _scrollToActiveDecoration.scrollToActiveDecoration)(view, getScrollableDecorations(pluginState.decorations), pluginState.activeIndex);
139
147
  }
140
148
  }
@@ -1,9 +1,8 @@
1
1
  import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
2
2
  import { trackChangesMessages } from '@atlaskit/editor-common/messages';
3
- import { fg } from '@atlaskit/platform-feature-flags';
4
3
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
5
- import { deletedStyleQuoteNode, deletedStyleQuoteNodeWithLozenge, deletedBlockOutline, deletedBlockOutlineRounded, deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedContentStyleNewActive } from '../colorSchemes/standard';
6
- import { deletedTraditionalStyleQuoteNode, deletedTraditionalBlockOutline, deletedTraditionalBlockOutlineRounded, deletedTraditionalContentStyle } from '../colorSchemes/traditional';
4
+ import { deletedBlockOutline, deletedBlockOutlineRounded, deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedContentStyleNewActive, deletedStyleQuoteNodeWithLozenge } from '../colorSchemes/standard';
5
+ import { deletedTraditionalBlockOutline, deletedTraditionalBlockOutlineRounded, deletedTraditionalContentStyle, deletedTraditionalStyleQuoteNode } from '../colorSchemes/traditional';
7
6
  const lozengeStyle = convertToInlineCss({
8
7
  display: 'inline-flex',
9
8
  boxSizing: 'border-box',
@@ -33,13 +32,13 @@ const getDeletedStyleNode = (nodeName, colorScheme) => {
33
32
  const isTraditional = colorScheme === 'traditional';
34
33
  switch (nodeName) {
35
34
  case 'blockquote':
36
- return fg('platform_editor_ai_aifc_patch_ga_blockers') ? isTraditional ? deletedTraditionalStyleQuoteNode : deletedStyleQuoteNodeWithLozenge : deletedStyleQuoteNode;
35
+ return isTraditional ? deletedTraditionalStyleQuoteNode : deletedStyleQuoteNodeWithLozenge;
37
36
  case 'expand':
38
37
  case 'decisionList':
39
- return isTraditional && fg('platform_editor_ai_aifc_patch_ga_blockers') ? deletedTraditionalBlockOutline : deletedBlockOutline;
38
+ return isTraditional ? deletedTraditionalBlockOutline : deletedBlockOutline;
40
39
  case 'panel':
41
40
  case 'codeBlock':
42
- return isTraditional && fg('platform_editor_ai_aifc_patch_ga_blockers') ? deletedTraditionalBlockOutlineRounded : deletedBlockOutlineRounded;
41
+ return isTraditional ? deletedTraditionalBlockOutlineRounded : deletedBlockOutlineRounded;
43
42
  default:
44
43
  return undefined;
45
44
  }
@@ -54,7 +53,7 @@ const shouldShowRemovedLozenge = nodeName => {
54
53
  return true;
55
54
  case 'embedCard':
56
55
  case 'blockquote':
57
- return fg('platform_editor_ai_aifc_patch_ga_blockers');
56
+ return true;
58
57
  default:
59
58
  return false;
60
59
  }
@@ -65,7 +64,7 @@ const shouldAddShowDiffDeletedNodeClass = nodeName => {
65
64
  case 'embedCard':
66
65
  return true;
67
66
  case 'blockquote':
68
- return fg('platform_editor_ai_aifc_patch_ga_blockers');
67
+ return true;
69
68
  default:
70
69
  return false;
71
70
  }
@@ -76,31 +75,21 @@ const shouldAddShowDiffDeletedNodeClass = nodeName => {
76
75
  * to preserve natural block-level margins
77
76
  */
78
77
  const shouldApplyStylesDirectly = nodeName => {
79
- return nodeName === 'heading' || nodeName === 'blockquote' && !fg('platform_editor_ai_aifc_patch_ga_blockers');
78
+ return nodeName === 'heading';
80
79
  };
81
80
 
82
81
  /**
83
82
  * Creates a "Removed" lozenge to be displayed at the top right corner of deleted block nodes
84
83
  */
85
- const createRemovedLozenge = (intl, nodeName) => {
84
+ const createRemovedLozenge = intl => {
86
85
  const container = document.createElement('span');
87
- let borderTopRightRadius;
88
- if (['expand', 'decisionList'].includes(nodeName || '')) {
89
- borderTopRightRadius = "var(--ds-radius-small, 4px)";
90
- } else if (['panel', 'codeBlock', 'mediaSingle'].includes(nodeName || '')) {
91
- borderTopRightRadius = `calc(${"var(--ds-radius-xsmall, 2px)"} + 1px)`;
92
- }
93
86
  const containerStyle = convertToInlineCss({
94
87
  position: 'absolute',
95
- top: fg('platform_editor_ai_aifc_patch_ga_blockers') ? "var(--ds-space-075, 6px)" : "var(--ds-space-0, 0px)",
96
- right: fg('platform_editor_ai_aifc_patch_ga_blockers') ? "var(--ds-space-075, 6px)" : "var(--ds-space-0, 0px)",
88
+ top: "var(--ds-space-075, 6px)",
89
+ right: "var(--ds-space-075, 6px)",
97
90
  zIndex: 2,
98
91
  pointerEvents: 'none',
99
- display: 'flex',
100
- ...(!fg('platform_editor_ai_aifc_patch_ga_blockers') ? {
101
- overflow: 'hidden',
102
- borderTopRightRadius
103
- } : {})
92
+ display: 'flex'
104
93
  });
105
94
  container.setAttribute('style', containerStyle);
106
95
  container.setAttribute('data-testid', 'show-diff-removed-lozenge');
@@ -225,7 +214,7 @@ const handleMediaSingleWithLozenge = ({
225
214
 
226
215
  // Add deleted node class if needed
227
216
  if (shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
228
- const showDiffDeletedNodeClass = colorScheme === 'traditional' && fg('platform_editor_ai_aifc_patch_ga_blockers') ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
217
+ const showDiffDeletedNodeClass = colorScheme === 'traditional' ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
229
218
  nodeView.classList.add(showDiffDeletedNodeClass);
230
219
  }
231
220
  dom.append(nodeView);
@@ -251,7 +240,7 @@ const wrapBlockNode = ({
251
240
  targetNode,
252
241
  lozenge,
253
242
  colorScheme
254
- }) && fg('platform_editor_ai_aifc_patch_ga_blockers')) {
243
+ })) {
255
244
  return;
256
245
  }
257
246
  if (handleMediaSingleWithLozenge({
@@ -272,7 +261,7 @@ const wrapBlockNode = ({
272
261
  });
273
262
  blockWrapper.append(contentWrapper);
274
263
  if (nodeView instanceof HTMLElement && shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
275
- const showDiffDeletedNodeClass = colorScheme === 'traditional' && fg('platform_editor_ai_aifc_patch_ga_blockers') ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
264
+ const showDiffDeletedNodeClass = colorScheme === 'traditional' ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
276
265
  nodeView.classList.add(showDiffDeletedNodeClass);
277
266
  }
278
267
  dom.append(blockWrapper);
@@ -41,7 +41,7 @@ export const createPlugin = (config, getIntl, api) => {
41
41
  ...currentPluginState,
42
42
  ...meta,
43
43
  isDisplayingChanges: true,
44
- activeIndex: 0
44
+ activeIndex: undefined
45
45
  };
46
46
  // Calculate and store decorations in state
47
47
  const decorations = calculateDiffDecorations({
@@ -68,11 +68,19 @@ export const createPlugin = (config, getIntl, api) => {
68
68
  const decorations = getScrollableDecorations(currentPluginState.decorations);
69
69
  if (decorations.length > 0) {
70
70
  var _currentPluginState$a;
71
- let nextIndex = (_currentPluginState$a = currentPluginState.activeIndex) !== null && _currentPluginState$a !== void 0 ? _currentPluginState$a : 0;
71
+ // Initialize to -1 if undefined so that the first "next" scroll takes us to index 0 (first change).
72
+ // This allows the UI to start with no selection and only highlight on first user interaction.
73
+ let nextIndex = (_currentPluginState$a = currentPluginState.activeIndex) !== null && _currentPluginState$a !== void 0 ? _currentPluginState$a : -1;
72
74
  if (meta.action === 'SCROLL_TO_NEXT') {
73
75
  nextIndex = (nextIndex + 1) % decorations.length;
74
76
  } else {
75
- nextIndex = (nextIndex - 1 + decorations.length) % decorations.length;
77
+ // Handle scrolling backwards from the uninitialized state.
78
+ // If at -1 (no selection), wrap to the last decoration.
79
+ if (nextIndex === -1) {
80
+ nextIndex = decorations.length - 1;
81
+ } else {
82
+ nextIndex = (nextIndex - 1 + decorations.length) % decorations.length;
83
+ }
76
84
  }
77
85
  const activeDecoration = decorations[nextIndex];
78
86
  newPluginState = {
@@ -129,7 +137,7 @@ export const createPlugin = (config, getIntl, api) => {
129
137
  const pluginState = showDiffPluginKey.getState(view.state);
130
138
  const activeIndexChanged = (pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex) !== undefined && pluginState.activeIndex !== previousActiveIndex;
131
139
  previousActiveIndex = pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex;
132
- if (pluginState !== null && pluginState !== void 0 && pluginState.activeIndex && activeIndexChanged) {
140
+ if ((pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex) !== undefined && activeIndexChanged) {
133
141
  scrollToActiveDecoration(view, getScrollableDecorations(pluginState.decorations), pluginState.activeIndex);
134
142
  }
135
143
  }
@@ -1,12 +1,8 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
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
- 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
1
  import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
5
2
  import { trackChangesMessages } from '@atlaskit/editor-common/messages';
6
- import { fg } from '@atlaskit/platform-feature-flags';
7
3
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
8
- import { deletedStyleQuoteNode, deletedStyleQuoteNodeWithLozenge, deletedBlockOutline, deletedBlockOutlineRounded, deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedContentStyleNewActive } from '../colorSchemes/standard';
9
- import { deletedTraditionalStyleQuoteNode, deletedTraditionalBlockOutline, deletedTraditionalBlockOutlineRounded, deletedTraditionalContentStyle } from '../colorSchemes/traditional';
4
+ import { deletedBlockOutline, deletedBlockOutlineRounded, deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedContentStyleNewActive, deletedStyleQuoteNodeWithLozenge } from '../colorSchemes/standard';
5
+ import { deletedTraditionalBlockOutline, deletedTraditionalBlockOutlineRounded, deletedTraditionalContentStyle, deletedTraditionalStyleQuoteNode } from '../colorSchemes/traditional';
10
6
  var lozengeStyle = convertToInlineCss({
11
7
  display: 'inline-flex',
12
8
  boxSizing: 'border-box',
@@ -37,13 +33,13 @@ var getDeletedStyleNode = function getDeletedStyleNode(nodeName, colorScheme) {
37
33
  var isTraditional = colorScheme === 'traditional';
38
34
  switch (nodeName) {
39
35
  case 'blockquote':
40
- return fg('platform_editor_ai_aifc_patch_ga_blockers') ? isTraditional ? deletedTraditionalStyleQuoteNode : deletedStyleQuoteNodeWithLozenge : deletedStyleQuoteNode;
36
+ return isTraditional ? deletedTraditionalStyleQuoteNode : deletedStyleQuoteNodeWithLozenge;
41
37
  case 'expand':
42
38
  case 'decisionList':
43
- return isTraditional && fg('platform_editor_ai_aifc_patch_ga_blockers') ? deletedTraditionalBlockOutline : deletedBlockOutline;
39
+ return isTraditional ? deletedTraditionalBlockOutline : deletedBlockOutline;
44
40
  case 'panel':
45
41
  case 'codeBlock':
46
- return isTraditional && fg('platform_editor_ai_aifc_patch_ga_blockers') ? deletedTraditionalBlockOutlineRounded : deletedBlockOutlineRounded;
42
+ return isTraditional ? deletedTraditionalBlockOutlineRounded : deletedBlockOutlineRounded;
47
43
  default:
48
44
  return undefined;
49
45
  }
@@ -58,7 +54,7 @@ var shouldShowRemovedLozenge = function shouldShowRemovedLozenge(nodeName) {
58
54
  return true;
59
55
  case 'embedCard':
60
56
  case 'blockquote':
61
- return fg('platform_editor_ai_aifc_patch_ga_blockers');
57
+ return true;
62
58
  default:
63
59
  return false;
64
60
  }
@@ -69,7 +65,7 @@ var shouldAddShowDiffDeletedNodeClass = function shouldAddShowDiffDeletedNodeCla
69
65
  case 'embedCard':
70
66
  return true;
71
67
  case 'blockquote':
72
- return fg('platform_editor_ai_aifc_patch_ga_blockers');
68
+ return true;
73
69
  default:
74
70
  return false;
75
71
  }
@@ -80,31 +76,22 @@ var shouldAddShowDiffDeletedNodeClass = function shouldAddShowDiffDeletedNodeCla
80
76
  * to preserve natural block-level margins
81
77
  */
82
78
  var shouldApplyStylesDirectly = function shouldApplyStylesDirectly(nodeName) {
83
- return nodeName === 'heading' || nodeName === 'blockquote' && !fg('platform_editor_ai_aifc_patch_ga_blockers');
79
+ return nodeName === 'heading';
84
80
  };
85
81
 
86
82
  /**
87
83
  * Creates a "Removed" lozenge to be displayed at the top right corner of deleted block nodes
88
84
  */
89
- var createRemovedLozenge = function createRemovedLozenge(intl, nodeName) {
85
+ var createRemovedLozenge = function createRemovedLozenge(intl) {
90
86
  var container = document.createElement('span');
91
- var borderTopRightRadius;
92
- if (['expand', 'decisionList'].includes(nodeName || '')) {
93
- borderTopRightRadius = "var(--ds-radius-small, 4px)";
94
- } else if (['panel', 'codeBlock', 'mediaSingle'].includes(nodeName || '')) {
95
- borderTopRightRadius = "calc(".concat("var(--ds-radius-xsmall, 2px)", " + 1px)");
96
- }
97
- var containerStyle = convertToInlineCss(_objectSpread({
87
+ var containerStyle = convertToInlineCss({
98
88
  position: 'absolute',
99
- top: fg('platform_editor_ai_aifc_patch_ga_blockers') ? "var(--ds-space-075, 6px)" : "var(--ds-space-0, 0px)",
100
- right: fg('platform_editor_ai_aifc_patch_ga_blockers') ? "var(--ds-space-075, 6px)" : "var(--ds-space-0, 0px)",
89
+ top: "var(--ds-space-075, 6px)",
90
+ right: "var(--ds-space-075, 6px)",
101
91
  zIndex: 2,
102
92
  pointerEvents: 'none',
103
93
  display: 'flex'
104
- }, !fg('platform_editor_ai_aifc_patch_ga_blockers') ? {
105
- overflow: 'hidden',
106
- borderTopRightRadius: borderTopRightRadius
107
- } : {}));
94
+ });
108
95
  container.setAttribute('style', containerStyle);
109
96
  container.setAttribute('data-testid', 'show-diff-removed-lozenge');
110
97
 
@@ -224,7 +211,7 @@ var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(_ref4)
224
211
 
225
212
  // Add deleted node class if needed
226
213
  if (shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
227
- var showDiffDeletedNodeClass = colorScheme === 'traditional' && fg('platform_editor_ai_aifc_patch_ga_blockers') ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
214
+ var showDiffDeletedNodeClass = colorScheme === 'traditional' ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
228
215
  nodeView.classList.add(showDiffDeletedNodeClass);
229
216
  }
230
217
  dom.append(nodeView);
@@ -249,7 +236,7 @@ var wrapBlockNode = function wrapBlockNode(_ref5) {
249
236
  targetNode: targetNode,
250
237
  lozenge: lozenge,
251
238
  colorScheme: colorScheme
252
- }) && fg('platform_editor_ai_aifc_patch_ga_blockers')) {
239
+ })) {
253
240
  return;
254
241
  }
255
242
  if (handleMediaSingleWithLozenge({
@@ -270,7 +257,7 @@ var wrapBlockNode = function wrapBlockNode(_ref5) {
270
257
  });
271
258
  blockWrapper.append(contentWrapper);
272
259
  if (nodeView instanceof HTMLElement && shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
273
- var showDiffDeletedNodeClass = colorScheme === 'traditional' && fg('platform_editor_ai_aifc_patch_ga_blockers') ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
260
+ var showDiffDeletedNodeClass = colorScheme === 'traditional' ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
274
261
  nodeView.classList.add(showDiffDeletedNodeClass);
275
262
  }
276
263
  dom.append(blockWrapper);
@@ -44,7 +44,7 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
44
44
  // Update the plugin state with the new metadata
45
45
  newPluginState = _objectSpread(_objectSpread(_objectSpread({}, currentPluginState), meta), {}, {
46
46
  isDisplayingChanges: true,
47
- activeIndex: 0
47
+ activeIndex: undefined
48
48
  });
49
49
  // Calculate and store decorations in state
50
50
  var decorations = calculateDiffDecorations({
@@ -69,11 +69,19 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
69
69
  var _decorations = getScrollableDecorations(currentPluginState.decorations);
70
70
  if (_decorations.length > 0) {
71
71
  var _currentPluginState$a;
72
- var nextIndex = (_currentPluginState$a = currentPluginState.activeIndex) !== null && _currentPluginState$a !== void 0 ? _currentPluginState$a : 0;
72
+ // Initialize to -1 if undefined so that the first "next" scroll takes us to index 0 (first change).
73
+ // This allows the UI to start with no selection and only highlight on first user interaction.
74
+ var nextIndex = (_currentPluginState$a = currentPluginState.activeIndex) !== null && _currentPluginState$a !== void 0 ? _currentPluginState$a : -1;
73
75
  if (meta.action === 'SCROLL_TO_NEXT') {
74
76
  nextIndex = (nextIndex + 1) % _decorations.length;
75
77
  } else {
76
- nextIndex = (nextIndex - 1 + _decorations.length) % _decorations.length;
78
+ // Handle scrolling backwards from the uninitialized state.
79
+ // If at -1 (no selection), wrap to the last decoration.
80
+ if (nextIndex === -1) {
81
+ nextIndex = _decorations.length - 1;
82
+ } else {
83
+ nextIndex = (nextIndex - 1 + _decorations.length) % _decorations.length;
84
+ }
77
85
  }
78
86
  var activeDecoration = _decorations[nextIndex];
79
87
  newPluginState = _objectSpread(_objectSpread({}, currentPluginState), {}, {
@@ -127,7 +135,7 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
127
135
  var pluginState = showDiffPluginKey.getState(view.state);
128
136
  var activeIndexChanged = (pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex) !== undefined && pluginState.activeIndex !== previousActiveIndex;
129
137
  previousActiveIndex = pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex;
130
- if (pluginState !== null && pluginState !== void 0 && pluginState.activeIndex && activeIndexChanged) {
138
+ if ((pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex) !== undefined && activeIndexChanged) {
131
139
  scrollToActiveDecoration(view, getScrollableDecorations(pluginState.decorations), pluginState.activeIndex);
132
140
  }
133
141
  }
@@ -1,2 +1,2 @@
1
1
  export { showDiffPlugin } from './showDiffPlugin';
2
- export type { ShowDiffPlugin, DiffParams, PMDiffParams } from './showDiffPluginType';
2
+ export type { DiffParams, PMDiffParams, ShowDiffPlugin } from './showDiffPluginType';
@@ -1,2 +1,2 @@
1
1
  export { showDiffPlugin } from './showDiffPlugin';
2
- export type { ShowDiffPlugin, DiffParams, PMDiffParams } from './showDiffPluginType';
2
+ export type { DiffParams, PMDiffParams, ShowDiffPlugin } from './showDiffPluginType';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-show-diff",
3
- "version": "5.0.8",
3
+ "version": "5.0.10",
4
4
  "description": "ShowDiff plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,7 +33,7 @@
33
33
  "@atlaskit/editor-prosemirror": "^7.3.0",
34
34
  "@atlaskit/editor-tables": "^2.9.0",
35
35
  "@atlaskit/platform-feature-flags": "^1.1.0",
36
- "@atlaskit/tmp-editor-statsig": "^35.6.0",
36
+ "@atlaskit/tmp-editor-statsig": "^35.9.0",
37
37
  "@atlaskit/tokens": "^11.1.0",
38
38
  "@babel/runtime": "^7.0.0",
39
39
  "lodash": "^4.17.21",
@@ -44,7 +44,7 @@
44
44
  "@atlassian/content-reconciliation": "^0.1.3506"
45
45
  },
46
46
  "peerDependencies": {
47
- "@atlaskit/editor-common": "^111.33.0",
47
+ "@atlaskit/editor-common": "^111.35.0",
48
48
  "react": "^18.2.0"
49
49
  },
50
50
  "techstack": {
@@ -86,9 +86,6 @@
86
86
  "platform-feature-flags": {
87
87
  "platform_editor_show_diff_scroll_navigation": {
88
88
  "type": "boolean"
89
- },
90
- "platform_editor_ai_aifc_patch_ga_blockers": {
91
- "type": "boolean"
92
89
  }
93
90
  }
94
91
  }