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

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.
Files changed (32) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/cjs/pm-plugins/calculateDiffDecorations.js +15 -12
  3. package/dist/cjs/pm-plugins/decorations.js +47 -26
  4. package/dist/cjs/pm-plugins/deletedBlocksHandler.js +22 -22
  5. package/dist/cjs/pm-plugins/deletedRowsHandler.js +7 -7
  6. package/dist/cjs/pm-plugins/main.js +11 -5
  7. package/dist/cjs/showDiffPlugin.js +2 -1
  8. package/dist/es2019/pm-plugins/calculateDiffDecorations.js +15 -12
  9. package/dist/es2019/pm-plugins/decorations.js +47 -24
  10. package/dist/es2019/pm-plugins/deletedBlocksHandler.js +22 -22
  11. package/dist/es2019/pm-plugins/deletedRowsHandler.js +7 -7
  12. package/dist/es2019/pm-plugins/main.js +8 -4
  13. package/dist/es2019/showDiffPlugin.js +3 -2
  14. package/dist/esm/pm-plugins/calculateDiffDecorations.js +15 -12
  15. package/dist/esm/pm-plugins/decorations.js +47 -26
  16. package/dist/esm/pm-plugins/deletedBlocksHandler.js +22 -22
  17. package/dist/esm/pm-plugins/deletedRowsHandler.js +7 -7
  18. package/dist/esm/pm-plugins/main.js +10 -4
  19. package/dist/esm/showDiffPlugin.js +3 -2
  20. package/dist/types/pm-plugins/calculateDiffDecorations.d.ts +2 -2
  21. package/dist/types/pm-plugins/decorations.d.ts +6 -6
  22. package/dist/types/pm-plugins/deletedBlocksHandler.d.ts +8 -8
  23. package/dist/types/pm-plugins/deletedRowsHandler.d.ts +3 -3
  24. package/dist/types/pm-plugins/main.d.ts +2 -0
  25. package/dist/types/showDiffPluginType.d.ts +2 -1
  26. package/dist/types-ts4.5/pm-plugins/calculateDiffDecorations.d.ts +2 -2
  27. package/dist/types-ts4.5/pm-plugins/decorations.d.ts +6 -6
  28. package/dist/types-ts4.5/pm-plugins/deletedBlocksHandler.d.ts +8 -8
  29. package/dist/types-ts4.5/pm-plugins/deletedRowsHandler.d.ts +3 -3
  30. package/dist/types-ts4.5/pm-plugins/main.d.ts +2 -0
  31. package/dist/types-ts4.5/showDiffPluginType.d.ts +2 -1
  32. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @atlaskit/editor-plugin-show-diff
2
2
 
3
+ ## 5.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [`b5af20d6e019c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b5af20d6e019c) -
8
+ EDITOR-5632: Change colourScheme param to colorScheme for standardisation.
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+
14
+ ## 4.1.4
15
+
16
+ ### Patch Changes
17
+
18
+ - [`4031146a0af6d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4031146a0af6d) -
19
+ Updating the PR to calculate the correct number of decorations for display.
20
+ - Updated dependencies
21
+
3
22
  ## 4.1.3
4
23
 
5
24
  ### Patch Changes
@@ -22,16 +22,19 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
22
22
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
23
23
  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; }
24
24
  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; } // eslint-disable-next-line @atlassian/tangerine/import/entry-points
25
- var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration(doc, from, to, colourScheme) {
25
+ var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration(doc, from, to, colorScheme) {
26
26
  var decorations = [];
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
+ }, colorScheme);
35
+ if (decoration) {
36
+ decorations.push(decoration);
37
+ }
35
38
  }
36
39
  });
37
40
  return decorations;
@@ -73,7 +76,7 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref)
73
76
  var state = _ref.state,
74
77
  pluginState = _ref.pluginState,
75
78
  nodeViewSerializer = _ref.nodeViewSerializer,
76
- colourScheme = _ref.colourScheme,
79
+ colorScheme = _ref.colorScheme,
77
80
  intl = _ref.intl,
78
81
  activeIndexPos = _ref.activeIndexPos;
79
82
  var originalDoc = pluginState.originalDoc,
@@ -118,8 +121,8 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref)
118
121
  optimizedChanges.forEach(function (change) {
119
122
  var isActive = activeIndexPos && change.fromB >= activeIndexPos.from && change.toB <= activeIndexPos.to;
120
123
  if (change.inserted.length > 0) {
121
- decorations.push((0, _decorations.createInlineChangedDecoration)(change, colourScheme, isActive));
122
- decorations.push.apply(decorations, (0, _toConsumableArray2.default)(calculateNodesForBlockDecoration(tr.doc, change.fromB, change.toB, colourScheme)));
124
+ decorations.push((0, _decorations.createInlineChangedDecoration)(change, colorScheme, isActive));
125
+ decorations.push.apply(decorations, (0, _toConsumableArray2.default)(calculateNodesForBlockDecoration(tr.doc, change.fromB, change.toB, colorScheme)));
123
126
  }
124
127
  if (change.deleted.length > 0) {
125
128
  var _isActive = activeIndexPos && change.fromB >= activeIndexPos.from && change.toB <= activeIndexPos.to;
@@ -127,7 +130,7 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref)
127
130
  change: change,
128
131
  doc: originalDoc,
129
132
  nodeViewSerializer: nodeViewSerializer,
130
- colourScheme: colourScheme,
133
+ colorScheme: colorScheme,
131
134
  newDoc: tr.doc,
132
135
  intl: intl,
133
136
  isActive: _isActive
@@ -139,10 +142,10 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref)
139
142
  });
140
143
  (0, _markDecorations.getMarkChangeRanges)(steps).forEach(function (change) {
141
144
  var isActive = activeIndexPos && change.fromB >= activeIndexPos.from && change.toB <= activeIndexPos.to;
142
- decorations.push((0, _decorations.createInlineChangedDecoration)(change, colourScheme, isActive));
145
+ decorations.push((0, _decorations.createInlineChangedDecoration)(change, colorScheme, isActive));
143
146
  });
144
147
  (0, _attributeDecorations.getAttrChangeRanges)(tr.doc, attrSteps).forEach(function (change) {
145
- decorations.push.apply(decorations, (0, _toConsumableArray2.default)(calculateNodesForBlockDecoration(tr.doc, change.fromB, change.toB, colourScheme)));
148
+ decorations.push.apply(decorations, (0, _toConsumableArray2.default)(calculateNodesForBlockDecoration(tr.doc, change.fromB, change.toB, colorScheme)));
146
149
  });
147
150
  return _view.DecorationSet.empty.add(tr.doc, decorations);
148
151
  };
@@ -154,16 +157,16 @@ function (_ref2, _ref3) {
154
157
  _ref4$ = _ref4[0],
155
158
  pluginState = _ref4$.pluginState,
156
159
  state = _ref4$.state,
157
- colourScheme = _ref4$.colourScheme,
160
+ colorScheme = _ref4$.colorScheme,
158
161
  intl = _ref4$.intl,
159
162
  activeIndexPos = _ref4$.activeIndexPos;
160
163
  var _ref5 = (0, _slicedToArray2.default)(_ref3, 1),
161
164
  _ref5$ = _ref5[0],
162
165
  lastPluginState = _ref5$.pluginState,
163
166
  lastState = _ref5$.state,
164
- lastColourScheme = _ref5$.colourScheme,
167
+ lastColorScheme = _ref5$.colorScheme,
165
168
  lastIntl = _ref5$.intl,
166
169
  lastActiveIndexPos = _ref5$.activeIndexPos;
167
170
  var originalDocIsSame = lastPluginState.originalDoc && pluginState.originalDoc && pluginState.originalDoc.eq(lastPluginState.originalDoc);
168
- return (_ref6 = originalDocIsSame && (0, _isEqual.default)(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && colourScheme === lastColourScheme && intl.locale === lastIntl.locale && (0, _isEqual.default)(activeIndexPos, lastActiveIndexPos)) !== null && _ref6 !== void 0 ? _ref6 : false;
171
+ return (_ref6 = originalDocIsSame && (0, _isEqual.default)(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && colorScheme === lastColorScheme && intl.locale === lastIntl.locale && (0, _isEqual.default)(activeIndexPos, lastActiveIndexPos)) !== null && _ref6 !== void 0 ? _ref6 : false;
169
172
  });
@@ -19,10 +19,10 @@ var _findSafeInsertPos = require("./findSafeInsertPos");
19
19
  * @param change Changeset "change" containing information about the change content + range
20
20
  * @returns Prosemirror inline decoration
21
21
  */
22
- var createInlineChangedDecoration = exports.createInlineChangedDecoration = function createInlineChangedDecoration(change, colourScheme) {
22
+ var createInlineChangedDecoration = exports.createInlineChangedDecoration = function createInlineChangedDecoration(change, colorScheme) {
23
23
  var isActive = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
24
24
  var style;
25
- if (colourScheme === 'traditional') {
25
+ if (colorScheme === 'traditional') {
26
26
  style = isActive ? _traditional.traditionalInsertStyleActive : _traditional.traditionalInsertStyle;
27
27
  } else {
28
28
  style = isActive ? _standard.editingStyleActive : _standard.editingStyle;
@@ -30,14 +30,16 @@ 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
- var getDeletedContentStyleUnbounded = exports.getDeletedContentStyleUnbounded = function getDeletedContentStyleUnbounded(colourScheme) {
36
- return colourScheme === 'traditional' ? _traditional.deletedTraditionalContentStyleUnbounded : _standard.deletedContentStyleUnbounded;
37
+ var getDeletedContentStyleUnbounded = exports.getDeletedContentStyleUnbounded = function getDeletedContentStyleUnbounded(colorScheme) {
38
+ return colorScheme === 'traditional' ? _traditional.deletedTraditionalContentStyleUnbounded : _standard.deletedContentStyleUnbounded;
37
39
  };
38
- var getDeletedContentStyle = exports.getDeletedContentStyle = function getDeletedContentStyle(colourScheme) {
40
+ var getDeletedContentStyle = exports.getDeletedContentStyle = function getDeletedContentStyle(colorScheme) {
39
41
  var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
40
- if (colourScheme === 'traditional') {
42
+ if (colorScheme === 'traditional') {
41
43
  return _traditional.deletedTraditionalContentStyle;
42
44
  }
43
45
  if (isActive) {
@@ -53,8 +55,8 @@ var getNodeClass = function getNodeClass(name) {
53
55
  return undefined;
54
56
  }
55
57
  };
56
- var getBlockNodeStyle = function getBlockNodeStyle(name, colourScheme) {
57
- return colourScheme === 'traditional' ? (0, _traditional.getTraditionalNodeStyle)(name) : (0, _standard.getStandardNodeStyle)(name);
58
+ var getBlockNodeStyle = function getBlockNodeStyle(name, colorScheme) {
59
+ return colorScheme === 'traditional' ? (0, _traditional.getTraditionalNodeStyle)(name) : (0, _standard.getStandardNodeStyle)(name);
58
60
  };
59
61
 
60
62
  /**
@@ -63,23 +65,40 @@ var getBlockNodeStyle = function getBlockNodeStyle(name, colourScheme) {
63
65
  * @param change Changeset "change" containing information about the change content + range
64
66
  * @returns Prosemirror inline decoration
65
67
  */
66
- 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
- }, {});
68
+ var createBlockChangedDecoration = exports.createBlockChangedDecoration = function createBlockChangedDecoration(change, colorScheme) {
69
+ if ((0, _platformFeatureFlags.fg)('platform_editor_show_diff_scroll_navigation')) {
70
+ var style = getBlockNodeStyle(change.name, colorScheme);
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, colorScheme),
85
+ 'data-testid': 'show-diff-changed-decoration-node',
86
+ class: getNodeClass(change.name)
87
+ }, {
88
+ key: 'diff-block'
89
+ });
90
+ }
72
91
  };
73
- var createContentWrapper = function createContentWrapper(colourScheme) {
92
+ var createContentWrapper = function createContentWrapper(colorScheme) {
74
93
  var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
75
94
  var wrapper = document.createElement('span');
76
95
  var baseStyle = (0, _lazyNodeView.convertToInlineCss)({
77
96
  position: 'relative',
78
97
  width: 'fit-content'
79
98
  });
80
- wrapper.setAttribute('style', "".concat(baseStyle).concat(getDeletedContentStyle(colourScheme, isActive)));
99
+ wrapper.setAttribute('style', "".concat(baseStyle).concat(getDeletedContentStyle(colorScheme, isActive)));
81
100
  var strikethrough = document.createElement('span');
82
- strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colourScheme));
101
+ strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colorScheme));
83
102
  wrapper.append(strikethrough);
84
103
  return wrapper;
85
104
  };
@@ -87,7 +106,7 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
87
106
  var change = _ref.change,
88
107
  doc = _ref.doc,
89
108
  nodeViewSerializer = _ref.nodeViewSerializer,
90
- colourScheme = _ref.colourScheme,
109
+ colorScheme = _ref.colorScheme,
91
110
  newDoc = _ref.newDoc,
92
111
  intl = _ref.intl,
93
112
  _ref$isActive = _ref.isActive,
@@ -113,7 +132,7 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
113
132
  if (!(0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga')) {
114
133
  return;
115
134
  }
116
- var _handleDeletedRows = (0, _deletedRowsHandler.handleDeletedRows)([change], doc, newDoc, nodeViewSerializer, colourScheme),
135
+ var _handleDeletedRows = (0, _deletedRowsHandler.handleDeletedRows)([change], doc, newDoc, nodeViewSerializer, colorScheme),
117
136
  decorations = _handleDeletedRows.decorations;
118
137
  return decorations;
119
138
  }
@@ -136,14 +155,14 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
136
155
  if (childNodeView) {
137
156
  var lineBreak = document.createElement('br');
138
157
  dom.append(lineBreak);
139
- var wrapper = createContentWrapper(colourScheme, isActive);
158
+ var wrapper = createContentWrapper(colorScheme, isActive);
140
159
  wrapper.append(childNodeView);
141
160
  dom.append(wrapper);
142
161
  } else {
143
162
  // Fallback to serializing the individual child node
144
163
  var serializedChild = serializer.serializeNode(childNode);
145
164
  if (serializedChild) {
146
- var _wrapper = createContentWrapper(colourScheme, isActive);
165
+ var _wrapper = createContentWrapper(colorScheme, isActive);
147
166
  _wrapper.append(serializedChild);
148
167
  dom.append(_wrapper);
149
168
  }
@@ -188,12 +207,12 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
188
207
  var nodeView = serializer.tryCreateNodeView(node);
189
208
  if (nodeView) {
190
209
  if (node.isInline) {
191
- var wrapper = createContentWrapper(colourScheme, isActive);
210
+ var wrapper = createContentWrapper(colorScheme, isActive);
192
211
  wrapper.append(nodeView);
193
212
  dom.append(wrapper);
194
213
  } else {
195
214
  // Handle all block nodes with unified function
196
- (0, _deletedBlocksHandler.handleBlockNodeView)(dom, nodeView, node, colourScheme, intl);
215
+ (0, _deletedBlocksHandler.handleBlockNodeView)(dom, nodeView, node, colorScheme, intl);
197
216
  }
198
217
  } else if (nodeViewSerializer.getFilteredNodeViewBlocklist(['paragraph', 'tableRow']).has(node.type.name)) {
199
218
  // Skip the case where the node is a paragraph or table row that way it can still be rendered and delete the entire table
@@ -201,7 +220,7 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
201
220
  } else {
202
221
  var fallbackNode = fallbackSerialization();
203
222
  if (fallbackNode) {
204
- var _wrapper2 = (0, _deletedBlocksHandler.createDeletedStyleWrapperWithoutOpacity)(colourScheme, isActive);
223
+ var _wrapper2 = (0, _deletedBlocksHandler.createDeletedStyleWrapperWithoutOpacity)(colorScheme, isActive);
205
224
  _wrapper2.append(fallbackNode);
206
225
  dom.append(_wrapper2);
207
226
  }
@@ -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
  };
@@ -63,8 +63,8 @@ var lozengeStyle = (0, _lazyNodeView.convertToInlineCss)({
63
63
  whiteSpace: 'nowrap',
64
64
  color: "var(--ds-text-warning-inverse, #292A2E)"
65
65
  });
66
- var getDeletedStyleNode = exports.getDeletedStyleNode = function getDeletedStyleNode(nodeName, colourScheme) {
67
- var isTraditional = colourScheme === 'traditional';
66
+ var getDeletedStyleNode = exports.getDeletedStyleNode = function getDeletedStyleNode(nodeName, colorScheme) {
67
+ var isTraditional = colorScheme === 'traditional';
68
68
  switch (nodeName) {
69
69
  case 'blockquote':
70
70
  return (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers') ? isTraditional ? deletedTraditionalStyleQuoteNode : deletedStyleQuoteNodeWithLozenge : deletedStyleQuoteNode;
@@ -163,29 +163,29 @@ var createBlockNodeWrapper = exports.createBlockNodeWrapper = function createBlo
163
163
  /**
164
164
  * Wraps content with deleted styling without opacity (for use when content is a direct child of dom)
165
165
  */
166
- var createDeletedStyleWrapperWithoutOpacity = exports.createDeletedStyleWrapperWithoutOpacity = function createDeletedStyleWrapperWithoutOpacity(colourScheme, isActive) {
166
+ var createDeletedStyleWrapperWithoutOpacity = exports.createDeletedStyleWrapperWithoutOpacity = function createDeletedStyleWrapperWithoutOpacity(colorScheme, isActive) {
167
167
  var wrapper = document.createElement('span');
168
- wrapper.setAttribute('style', (0, _decorations.getDeletedContentStyle)(colourScheme, isActive));
168
+ wrapper.setAttribute('style', (0, _decorations.getDeletedContentStyle)(colorScheme, isActive));
169
169
  return wrapper;
170
170
  };
171
171
 
172
172
  /**
173
173
  * Applies deleted styles directly to an HTML element by merging with existing styles
174
174
  */
175
- var applyDeletedStylesToElement = exports.applyDeletedStylesToElement = function applyDeletedStylesToElement(element, targetNode, colourScheme) {
175
+ var applyDeletedStylesToElement = exports.applyDeletedStylesToElement = function applyDeletedStylesToElement(element, targetNode, colorScheme) {
176
176
  var currentStyle = element.getAttribute('style') || '';
177
- var deletedContentStyle = (0, _decorations.getDeletedContentStyle)(colourScheme);
178
- var nodeSpecificStyle = getDeletedStyleNode(targetNode.type.name, colourScheme) || '';
177
+ var deletedContentStyle = (0, _decorations.getDeletedContentStyle)(colorScheme);
178
+ var nodeSpecificStyle = getDeletedStyleNode(targetNode.type.name, colorScheme) || '';
179
179
  element.setAttribute('style', "".concat(currentStyle).concat(deletedContentStyle).concat(nodeSpecificStyle));
180
180
  };
181
181
 
182
182
  /**
183
183
  * Creates a content wrapper with deleted styles for a block node
184
184
  */
185
- var createBlockNodeContentWrapper = exports.createBlockNodeContentWrapper = function createBlockNodeContentWrapper(nodeView, targetNode, colourScheme) {
185
+ var createBlockNodeContentWrapper = exports.createBlockNodeContentWrapper = function createBlockNodeContentWrapper(nodeView, targetNode, colorScheme) {
186
186
  var contentWrapper = document.createElement('div');
187
- var nodeStyle = getDeletedStyleNode(targetNode.type.name, colourScheme);
188
- contentWrapper.setAttribute('style', "".concat((0, _decorations.getDeletedContentStyle)(colourScheme)).concat(nodeStyle || ''));
187
+ var nodeStyle = getDeletedStyleNode(targetNode.type.name, colorScheme);
188
+ contentWrapper.setAttribute('style', "".concat((0, _decorations.getDeletedContentStyle)(colorScheme)).concat(nodeStyle || ''));
189
189
  contentWrapper.append(nodeView);
190
190
  return contentWrapper;
191
191
  };
@@ -196,7 +196,7 @@ var createBlockNodeContentWrapper = exports.createBlockNodeContentWrapper = func
196
196
  * to wait for the rich-media-item to appear before attaching the lozenge.
197
197
  * @returns true if embedCard was handled
198
198
  */
199
- var handleEmbedCardWithLozenge = exports.handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(dom, nodeView, targetNode, lozenge, colourScheme) {
199
+ var handleEmbedCardWithLozenge = exports.handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(dom, nodeView, targetNode, lozenge, colorScheme) {
200
200
  if (targetNode.type.name !== 'embedCard' || !(nodeView instanceof HTMLElement)) {
201
201
  return false;
202
202
  }
@@ -217,7 +217,7 @@ var handleEmbedCardWithLozenge = exports.handleEmbedCardWithLozenge = function h
217
217
  });
218
218
  }
219
219
  if (shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
220
- var showDiffDeletedNodeClass = colourScheme === 'traditional' ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
220
+ var showDiffDeletedNodeClass = colorScheme === 'traditional' ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
221
221
  nodeView.classList.add(showDiffDeletedNodeClass);
222
222
  }
223
223
  dom.append(nodeView);
@@ -228,7 +228,7 @@ var handleEmbedCardWithLozenge = exports.handleEmbedCardWithLozenge = function h
228
228
  * Handles special mediaSingle node rendering with lozenge on child media element
229
229
  * @returns true if mediaSingle was handled, false otherwise
230
230
  */
231
- var handleMediaSingleWithLozenge = exports.handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(dom, nodeView, targetNode, lozenge, colourScheme) {
231
+ var handleMediaSingleWithLozenge = exports.handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(dom, nodeView, targetNode, lozenge, colorScheme) {
232
232
  if (targetNode.type.name !== 'mediaSingle' || !(nodeView instanceof HTMLElement)) {
233
233
  return false;
234
234
  }
@@ -247,7 +247,7 @@ var handleMediaSingleWithLozenge = exports.handleMediaSingleWithLozenge = functi
247
247
 
248
248
  // Add deleted node class if needed
249
249
  if (shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
250
- var showDiffDeletedNodeClass = colourScheme === 'traditional' && (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers') ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
250
+ var showDiffDeletedNodeClass = colorScheme === 'traditional' && (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers') ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
251
251
  nodeView.classList.add(showDiffDeletedNodeClass);
252
252
  }
253
253
  dom.append(nodeView);
@@ -257,22 +257,22 @@ var handleMediaSingleWithLozenge = exports.handleMediaSingleWithLozenge = functi
257
257
  /**
258
258
  * Appends a block node with wrapper, lozenge, and appropriate styling
259
259
  */
260
- var appendBlockNodeWithWrapper = exports.appendBlockNodeWithWrapper = function appendBlockNodeWithWrapper(dom, nodeView, targetNode, colourScheme, intl) {
260
+ var appendBlockNodeWithWrapper = exports.appendBlockNodeWithWrapper = function appendBlockNodeWithWrapper(dom, nodeView, targetNode, colorScheme, intl) {
261
261
  var blockWrapper = createBlockNodeWrapper();
262
262
  if (shouldShowRemovedLozenge(targetNode.type.name)) {
263
263
  var lozenge = createRemovedLozenge(intl);
264
- if (handleEmbedCardWithLozenge(dom, nodeView, targetNode, lozenge, colourScheme) && (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers')) {
264
+ if (handleEmbedCardWithLozenge(dom, nodeView, targetNode, lozenge, colorScheme) && (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers')) {
265
265
  return;
266
266
  }
267
- if (handleMediaSingleWithLozenge(dom, nodeView, targetNode, lozenge, colourScheme)) {
267
+ if (handleMediaSingleWithLozenge(dom, nodeView, targetNode, lozenge, colorScheme)) {
268
268
  return;
269
269
  }
270
270
  blockWrapper.append(lozenge);
271
271
  }
272
- var contentWrapper = createBlockNodeContentWrapper(nodeView, targetNode, colourScheme);
272
+ var contentWrapper = createBlockNodeContentWrapper(nodeView, targetNode, colorScheme);
273
273
  blockWrapper.append(contentWrapper);
274
274
  if (nodeView instanceof HTMLElement && shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
275
- var showDiffDeletedNodeClass = colourScheme === 'traditional' && (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers') ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
275
+ var showDiffDeletedNodeClass = colorScheme === 'traditional' && (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers') ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
276
276
  nodeView.classList.add(showDiffDeletedNodeClass);
277
277
  }
278
278
  dom.append(blockWrapper);
@@ -283,13 +283,13 @@ var appendBlockNodeWithWrapper = exports.appendBlockNodeWithWrapper = function a
283
283
  * For heading nodes, applies styles directly to preserve natural margins.
284
284
  * For other block nodes, uses wrapper approach with optional lozenge.
285
285
  */
286
- var handleBlockNodeView = exports.handleBlockNodeView = function handleBlockNodeView(dom, nodeView, targetNode, colourScheme, intl) {
286
+ var handleBlockNodeView = exports.handleBlockNodeView = function handleBlockNodeView(dom, nodeView, targetNode, colorScheme, intl) {
287
287
  if (shouldApplyDeletedStylesDirectly(targetNode.type.name) && nodeView instanceof HTMLElement) {
288
288
  // Apply deleted styles directly to preserve natural block-level margins
289
- applyDeletedStylesToElement(nodeView, targetNode, colourScheme);
289
+ applyDeletedStylesToElement(nodeView, targetNode, colorScheme);
290
290
  dom.append(nodeView);
291
291
  } else {
292
292
  // Use wrapper approach for other block nodes
293
- appendBlockNodeWithWrapper(dom, nodeView, targetNode, colourScheme, intl);
293
+ appendBlockNodeWithWrapper(dom, nodeView, targetNode, colorScheme, intl);
294
294
  }
295
295
  };
@@ -65,7 +65,7 @@ var extractDeletedRows = function extractDeletedRows(change, originalDoc, newDoc
65
65
  var changeEndInTable = change.toA - tableOld.pos - 1;
66
66
  var currentOffset = 0;
67
67
  var rowIndex = 0;
68
- tableOld.node.content.forEach(function (rowNode, index) {
68
+ tableOld.node.content.forEach(function (rowNode) {
69
69
  var rowStart = currentOffset;
70
70
  var rowEnd = currentOffset + rowNode.nodeSize;
71
71
 
@@ -126,9 +126,9 @@ var isEmptyRow = function isEmptyRow(rowNode) {
126
126
  /**
127
127
  * Creates a DOM representation of a deleted table row
128
128
  */
129
- var createDeletedRowDOM = function createDeletedRowDOM(rowNode, nodeViewSerializer, colourScheme) {
129
+ var createDeletedRowDOM = function createDeletedRowDOM(rowNode, nodeViewSerializer, colorScheme) {
130
130
  var tr = document.createElement('tr');
131
- tr.setAttribute('style', colourScheme === 'traditional' ? deletedTraditionalRowStyle : deletedRowStyle);
131
+ tr.setAttribute('style', colorScheme === 'traditional' ? deletedTraditionalRowStyle : deletedRowStyle);
132
132
  tr.setAttribute('data-testid', 'show-diff-deleted-row');
133
133
 
134
134
  // Serialize each cell in the row
@@ -181,9 +181,9 @@ var createDeletedRowsDecorations = exports.createDeletedRowsDecorations = functi
181
181
  originalDoc = _ref.originalDoc,
182
182
  newDoc = _ref.newDoc,
183
183
  nodeViewSerializer = _ref.nodeViewSerializer,
184
- colourScheme = _ref.colourScheme;
184
+ colorScheme = _ref.colorScheme;
185
185
  return deletedRows.map(function (deletedRow) {
186
- var rowDOM = createDeletedRowDOM(deletedRow.rowNode, nodeViewSerializer, colourScheme);
186
+ var rowDOM = createDeletedRowDOM(deletedRow.rowNode, nodeViewSerializer, colorScheme);
187
187
 
188
188
  // Find safe insertion position for the deleted row
189
189
  var safeInsertPos = (0, _findSafeInsertPos.findSafeInsertPos)(newDoc, deletedRow.fromB - 1,
@@ -196,7 +196,7 @@ var createDeletedRowsDecorations = exports.createDeletedRowsDecorations = functi
196
196
  /**
197
197
  * Main function to handle deleted rows - computes diff and creates decorations
198
198
  */
199
- var handleDeletedRows = exports.handleDeletedRows = function handleDeletedRows(changes, originalDoc, newDoc, nodeViewSerializer, colourScheme) {
199
+ var handleDeletedRows = exports.handleDeletedRows = function handleDeletedRows(changes, originalDoc, newDoc, nodeViewSerializer, colorScheme) {
200
200
  // First, expand the changes to include complete deleted rows
201
201
  var deletedRows = expandDiffForDeletedRows(changes.filter(function (change) {
202
202
  return change.deleted.length > 0;
@@ -206,7 +206,7 @@ var handleDeletedRows = exports.handleDeletedRows = function handleDeletedRows(c
206
206
  originalDoc: originalDoc,
207
207
  newDoc: newDoc,
208
208
  nodeViewSerializer: nodeViewSerializer,
209
- colourScheme: colourScheme
209
+ colorScheme: colorScheme
210
210
  });
211
211
  return {
212
212
  decorations: allDecorations
@@ -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;
@@ -85,7 +91,7 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl)
85
91
  state: newState,
86
92
  pluginState: newPluginState,
87
93
  nodeViewSerializer: nodeViewSerializer,
88
- colourScheme: config === null || config === void 0 ? void 0 : config.colourScheme,
94
+ colorScheme: config === null || config === void 0 ? void 0 : config.colorScheme,
89
95
  intl: getIntl(),
90
96
  activeIndexPos: (0, _platformFeatureFlags.fg)('platform_editor_show_diff_scroll_navigation') ? newPluginState.activeIndexPos : undefined
91
97
  });
@@ -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;
@@ -121,7 +127,7 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl)
121
127
  state: newState,
122
128
  pluginState: newPluginState,
123
129
  nodeViewSerializer: nodeViewSerializer,
124
- colourScheme: config === null || config === void 0 ? void 0 : config.colourScheme,
130
+ colorScheme: config === null || config === void 0 ? void 0 : config.colorScheme,
125
131
  intl: getIntl(),
126
132
  activeIndexPos: newPluginState.activeIndexPos
127
133
  });
@@ -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,
@@ -8,16 +8,19 @@ import { getAttrChangeRanges, stepIsValidAttrChange } from './attributeDecoratio
8
8
  import { createInlineChangedDecoration, createDeletedContentDecoration, createBlockChangedDecoration } from './decorations';
9
9
  import { getMarkChangeRanges } from './markDecorations';
10
10
  import { simplifySteps } from './simplifyChanges';
11
- const calculateNodesForBlockDecoration = (doc, from, to, colourScheme) => {
11
+ const calculateNodesForBlockDecoration = (doc, from, to, colorScheme) => {
12
12
  const decorations = [];
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
+ }, colorScheme);
21
+ if (decoration) {
22
+ decorations.push(decoration);
23
+ }
21
24
  }
22
25
  });
23
26
  return decorations;
@@ -63,7 +66,7 @@ const calculateDiffDecorationsInner = ({
63
66
  state,
64
67
  pluginState,
65
68
  nodeViewSerializer,
66
- colourScheme,
69
+ colorScheme,
67
70
  intl,
68
71
  activeIndexPos
69
72
  }) => {
@@ -104,8 +107,8 @@ const calculateDiffDecorationsInner = ({
104
107
  optimizedChanges.forEach(change => {
105
108
  const isActive = activeIndexPos && change.fromB >= activeIndexPos.from && change.toB <= activeIndexPos.to;
106
109
  if (change.inserted.length > 0) {
107
- decorations.push(createInlineChangedDecoration(change, colourScheme, isActive));
108
- decorations.push(...calculateNodesForBlockDecoration(tr.doc, change.fromB, change.toB, colourScheme));
110
+ decorations.push(createInlineChangedDecoration(change, colorScheme, isActive));
111
+ decorations.push(...calculateNodesForBlockDecoration(tr.doc, change.fromB, change.toB, colorScheme));
109
112
  }
110
113
  if (change.deleted.length > 0) {
111
114
  const isActive = activeIndexPos && change.fromB >= activeIndexPos.from && change.toB <= activeIndexPos.to;
@@ -113,7 +116,7 @@ const calculateDiffDecorationsInner = ({
113
116
  change,
114
117
  doc: originalDoc,
115
118
  nodeViewSerializer,
116
- colourScheme,
119
+ colorScheme,
117
120
  newDoc: tr.doc,
118
121
  intl,
119
122
  isActive
@@ -125,10 +128,10 @@ const calculateDiffDecorationsInner = ({
125
128
  });
126
129
  getMarkChangeRanges(steps).forEach(change => {
127
130
  const isActive = activeIndexPos && change.fromB >= activeIndexPos.from && change.toB <= activeIndexPos.to;
128
- decorations.push(createInlineChangedDecoration(change, colourScheme, isActive));
131
+ decorations.push(createInlineChangedDecoration(change, colorScheme, isActive));
129
132
  });
130
133
  getAttrChangeRanges(tr.doc, attrSteps).forEach(change => {
131
- decorations.push(...calculateNodesForBlockDecoration(tr.doc, change.fromB, change.toB, colourScheme));
134
+ decorations.push(...calculateNodesForBlockDecoration(tr.doc, change.fromB, change.toB, colorScheme));
132
135
  });
133
136
  return DecorationSet.empty.add(tr.doc, decorations);
134
137
  };
@@ -137,17 +140,17 @@ export const calculateDiffDecorations = memoizeOne(calculateDiffDecorationsInner
137
140
  ([{
138
141
  pluginState,
139
142
  state,
140
- colourScheme,
143
+ colorScheme,
141
144
  intl,
142
145
  activeIndexPos
143
146
  }], [{
144
147
  pluginState: lastPluginState,
145
148
  state: lastState,
146
- colourScheme: lastColourScheme,
149
+ colorScheme: lastColorScheme,
147
150
  intl: lastIntl,
148
151
  activeIndexPos: lastActiveIndexPos
149
152
  }]) => {
150
153
  var _ref;
151
154
  const originalDocIsSame = lastPluginState.originalDoc && pluginState.originalDoc && pluginState.originalDoc.eq(lastPluginState.originalDoc);
152
- return (_ref = originalDocIsSame && isEqual(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && colourScheme === lastColourScheme && intl.locale === lastIntl.locale && isEqual(activeIndexPos, lastActiveIndexPos)) !== null && _ref !== void 0 ? _ref : false;
155
+ return (_ref = originalDocIsSame && isEqual(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isEqual(activeIndexPos, lastActiveIndexPos)) !== null && _ref !== void 0 ? _ref : false;
153
156
  });