@atlaskit/editor-plugin-show-diff 6.3.1 → 6.4.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 (24) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +36 -23
  3. package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +21 -6
  4. package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +14 -1
  5. package/dist/cjs/pm-plugins/main.js +10 -5
  6. package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +35 -24
  7. package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +20 -6
  8. package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +13 -2
  9. package/dist/es2019/pm-plugins/main.js +10 -5
  10. package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +36 -23
  11. package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +21 -6
  12. package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +14 -2
  13. package/dist/esm/pm-plugins/main.js +10 -5
  14. package/dist/types/pm-plugins/calculateDiff/calculateDiffDecorations.d.ts +2 -1
  15. package/dist/types/pm-plugins/decorations/createBlockChangedDecoration.d.ts +2 -1
  16. package/dist/types/pm-plugins/decorations/createInlineChangedDecoration.d.ts +2 -1
  17. package/dist/types/pm-plugins/main.d.ts +1 -0
  18. package/dist/types/showDiffPluginType.d.ts +1 -0
  19. package/dist/types-ts4.5/pm-plugins/calculateDiff/calculateDiffDecorations.d.ts +2 -1
  20. package/dist/types-ts4.5/pm-plugins/decorations/createBlockChangedDecoration.d.ts +2 -1
  21. package/dist/types-ts4.5/pm-plugins/decorations/createInlineChangedDecoration.d.ts +2 -1
  22. package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -0
  23. package/dist/types-ts4.5/showDiffPluginType.d.ts +1 -0
  24. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/editor-plugin-show-diff
2
2
 
3
+ ## 6.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`7739efec523bc`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7739efec523bc) -
8
+ EDITOR-6371: Add toggle for showing / hiding deleted changes in the diff.
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+
14
+ ## 6.3.2
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies
19
+
3
20
  ## 6.3.1
4
21
 
5
22
  ### Patch Changes
@@ -56,7 +56,9 @@ var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration
56
56
  colorScheme = _ref2.colorScheme,
57
57
  _ref2$isInserted = _ref2.isInserted,
58
58
  isInserted = _ref2$isInserted === void 0 ? true : _ref2$isInserted,
59
- activeIndexPos = _ref2.activeIndexPos;
59
+ activeIndexPos = _ref2.activeIndexPos,
60
+ _ref2$shouldHideDelet = _ref2.shouldHideDeleted,
61
+ shouldHideDeleted = _ref2$shouldHideDelet === void 0 ? false : _ref2$shouldHideDelet;
60
62
  var decorations = [];
61
63
  // Iterate over the document nodes within the range
62
64
  doc.nodesBetween(from, to, function (node, pos) {
@@ -71,7 +73,8 @@ var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration
71
73
  },
72
74
  colorScheme: colorScheme,
73
75
  isInserted: isInserted,
74
- isActive: isActive
76
+ isActive: isActive,
77
+ shouldHideDeleted: shouldHideDeleted
75
78
  });
76
79
  if (blockChangedDecorations.length) {
77
80
  decorations.push.apply(decorations, (0, _toConsumableArray2.default)(blockChangedDecorations));
@@ -91,7 +94,9 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
91
94
  _ref3$isInverted = _ref3.isInverted,
92
95
  isInverted = _ref3$isInverted === void 0 ? false : _ref3$isInverted,
93
96
  _ref3$diffType = _ref3.diffType,
94
- diffType = _ref3$diffType === void 0 ? 'inline' : _ref3$diffType;
97
+ diffType = _ref3$diffType === void 0 ? 'inline' : _ref3$diffType,
98
+ _ref3$hideDeletedDiff = _ref3.hideDeletedDiffs,
99
+ hideDeletedDiffs = _ref3$hideDeletedDiff === void 0 ? false : _ref3$hideDeletedDiff;
95
100
  var originalDoc = pluginState.originalDoc,
96
101
  steps = pluginState.steps;
97
102
  if (!originalDoc || !pluginState.isDisplayingChanges) {
@@ -162,12 +167,14 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
162
167
  // Our default operations are insertions, so it should match the opposite of isInverted.
163
168
  var isInserted = !isInverted;
164
169
  if (change.inserted.length > 0) {
170
+ var shouldHideDeleted = (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) ? isInverted && hideDeletedDiffs : false;
165
171
  decorations.push((0, _createInlineChangedDecoration.createInlineChangedDecoration)(_objectSpread({
166
172
  change: change,
167
173
  colorScheme: colorScheme,
168
174
  isActive: isActive
169
175
  }, (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
170
- isInserted: isInserted
176
+ isInserted: isInserted,
177
+ shouldHideDeleted: shouldHideDeleted
171
178
  })));
172
179
  decorations.push.apply(decorations, (0, _toConsumableArray2.default)(calculateNodesForBlockDecoration(_objectSpread(_objectSpread({
173
180
  doc: tr.doc,
@@ -175,27 +182,31 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
175
182
  to: change.toB,
176
183
  colorScheme: colorScheme
177
184
  }, (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
178
- isInserted: isInserted
185
+ isInserted: isInserted,
186
+ shouldHideDeleted: shouldHideDeleted
179
187
  }), {}, {
180
188
  activeIndexPos: activeIndexPos,
181
189
  intl: intl
182
190
  }))));
183
191
  }
184
192
  if (change.deleted.length > 0) {
185
- var decoration = (0, _createNodeChangedDecorationWidget.createNodeChangedDecorationWidget)(_objectSpread({
186
- change: change,
187
- doc: originalDoc,
188
- nodeViewSerializer: nodeViewSerializer,
189
- colorScheme: colorScheme,
190
- newDoc: tr.doc,
191
- intl: intl,
192
- activeIndexPos: activeIndexPos
193
- }, (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
194
- isInserted: !isInserted,
195
- diffType: diffType
196
- }));
197
- if (decoration) {
198
- decorations.push.apply(decorations, (0, _toConsumableArray2.default)(decoration));
193
+ var _shouldHideDeleted = (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) ? !isInverted && hideDeletedDiffs : false;
194
+ if (!_shouldHideDeleted) {
195
+ var decoration = (0, _createNodeChangedDecorationWidget.createNodeChangedDecorationWidget)(_objectSpread({
196
+ change: change,
197
+ doc: originalDoc,
198
+ nodeViewSerializer: nodeViewSerializer,
199
+ colorScheme: colorScheme,
200
+ newDoc: tr.doc,
201
+ intl: intl,
202
+ activeIndexPos: activeIndexPos
203
+ }, (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
204
+ isInserted: !isInserted,
205
+ diffType: diffType
206
+ }));
207
+ if (decoration) {
208
+ decorations.push.apply(decorations, (0, _toConsumableArray2.default)(decoration));
209
+ }
199
210
  }
200
211
  }
201
212
  });
@@ -233,7 +244,8 @@ function (_ref4, _ref5) {
233
244
  intl = _ref6$.intl,
234
245
  activeIndexPos = _ref6$.activeIndexPos,
235
246
  isInverted = _ref6$.isInverted,
236
- diffType = _ref6$.diffType;
247
+ diffType = _ref6$.diffType,
248
+ hideDeletedDiffs = _ref6$.hideDeletedDiffs;
237
249
  var _ref7 = (0, _slicedToArray2.default)(_ref5, 1),
238
250
  _ref7$ = _ref7[0],
239
251
  lastPluginState = _ref7$.pluginState,
@@ -242,11 +254,12 @@ function (_ref4, _ref5) {
242
254
  lastIntl = _ref7$.intl,
243
255
  lastActiveIndexPos = _ref7$.activeIndexPos,
244
256
  lastIsInverted = _ref7$.isInverted,
245
- lastDiffType = _ref7$.diffType;
257
+ lastDiffType = _ref7$.diffType,
258
+ lastHideDeletedDiffs = _ref7$.hideDeletedDiffs;
246
259
  var originalDocIsSame = lastPluginState.originalDoc && pluginState.originalDoc && pluginState.originalDoc.eq(lastPluginState.originalDoc);
247
260
  if ((0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
248
261
  var _ref8;
249
- return (_ref8 = colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isInverted === lastIsInverted && diffType === lastDiffType && (0, _isEqual.default)(activeIndexPos, lastActiveIndexPos) && originalDocIsSame && (0, _isEqual.default)(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc)) !== null && _ref8 !== void 0 ? _ref8 : false;
262
+ return (_ref8 = colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isInverted === lastIsInverted && diffType === lastDiffType && (0, _isEqual.default)(activeIndexPos, lastActiveIndexPos) && originalDocIsSame && (0, _isEqual.default)(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && hideDeletedDiffs === lastHideDeletedDiffs) !== null && _ref8 !== void 0 ? _ref8 : false;
250
263
  }
251
- return (_ref9 = 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 && _ref9 !== void 0 ? _ref9 : false;
264
+ return (_ref9 = originalDocIsSame && (0, _isEqual.default)(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && colorScheme === lastColorScheme && intl.locale === lastIntl.locale && (0, _isEqual.default)(activeIndexPos, lastActiveIndexPos) && hideDeletedDiffs === lastHideDeletedDiffs) !== null && _ref9 !== void 0 ? _ref9 : false;
252
265
  });
@@ -10,6 +10,9 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
10
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
11
11
  var _standard = require("./colorSchemes/standard");
12
12
  var _traditional = require("./colorSchemes/traditional");
13
+ var displayNoneStyle = (0, _lazyNodeView.convertToInlineCss)({
14
+ display: 'none'
15
+ });
13
16
  var getNodeClass = function getNodeClass(name) {
14
17
  switch (name) {
15
18
  case 'extension':
@@ -108,8 +111,19 @@ var createBlockChangedDecoration = exports.createBlockChangedDecoration = functi
108
111
  _ref2$isInserted = _ref2.isInserted,
109
112
  isInserted = _ref2$isInserted === void 0 ? true : _ref2$isInserted,
110
113
  _ref2$isActive = _ref2.isActive,
111
- isActive = _ref2$isActive === void 0 ? false : _ref2$isActive;
114
+ isActive = _ref2$isActive === void 0 ? false : _ref2$isActive,
115
+ _ref2$shouldHideDelet = _ref2.shouldHideDeleted,
116
+ shouldHideDeleted = _ref2$shouldHideDelet === void 0 ? false : _ref2$shouldHideDelet;
112
117
  var decorations = [];
118
+ if (shouldHideDeleted) {
119
+ return [_view.Decoration.node(change.from, change.to, {
120
+ style: displayNoneStyle
121
+ }, {
122
+ key: 'diff-block',
123
+ nodeName: change.name
124
+ })];
125
+ }
126
+ var style;
113
127
  if ((0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) && ['tableCell', 'tableHeader'].includes(change.name)) {
114
128
  var cellOverlay = document.createElement('div');
115
129
  var cellOverlayStyle = isInserted ? colorScheme === 'traditional' ? _traditional.traditionalAddedCellOverlayStyle : _standard.addedCellOverlayStyle : colorScheme === 'traditional' ? _traditional.deletedTraditionalCellOverlayStyle : _standard.deletedCellOverlayStyle;
@@ -120,11 +134,6 @@ var createBlockChangedDecoration = exports.createBlockChangedDecoration = functi
120
134
  key: "diff-widget-cell-overlay-".concat(change.to)
121
135
  }));
122
136
  }
123
- var style = getBlockNodeStyle({
124
- nodeName: change.name,
125
- colorScheme: colorScheme,
126
- isActive: isActive
127
- });
128
137
  if ((0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
129
138
  style = getBlockNodeStyle({
130
139
  nodeName: change.name,
@@ -132,6 +141,12 @@ var createBlockChangedDecoration = exports.createBlockChangedDecoration = functi
132
141
  isInserted: isInserted,
133
142
  isActive: isActive
134
143
  });
144
+ } else {
145
+ style = getBlockNodeStyle({
146
+ nodeName: change.name,
147
+ colorScheme: colorScheme,
148
+ isActive: isActive
149
+ });
135
150
  }
136
151
  var className = getNodeClass(change.name);
137
152
  if ((0, _platformFeatureFlags.fg)('platform_editor_show_diff_scroll_navigation')) {
@@ -4,10 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createInlineChangedDecoration = void 0;
7
+ var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
7
8
  var _view = require("@atlaskit/editor-prosemirror/view");
8
9
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
9
10
  var _standard = require("./colorSchemes/standard");
10
11
  var _traditional = require("./colorSchemes/traditional");
12
+ var displayNoneStyle = (0, _lazyNodeView.convertToInlineCss)({
13
+ display: 'none'
14
+ });
11
15
  /**
12
16
  * Inline decoration used for insertions as the content already exists in the document
13
17
  *
@@ -21,7 +25,16 @@ var createInlineChangedDecoration = exports.createInlineChangedDecoration = func
21
25
  _ref$isActive = _ref.isActive,
22
26
  isActive = _ref$isActive === void 0 ? false : _ref$isActive,
23
27
  _ref$isInserted = _ref.isInserted,
24
- isInserted = _ref$isInserted === void 0 ? true : _ref$isInserted;
28
+ isInserted = _ref$isInserted === void 0 ? true : _ref$isInserted,
29
+ _ref$shouldHideDelete = _ref.shouldHideDeleted,
30
+ shouldHideDeleted = _ref$shouldHideDelete === void 0 ? false : _ref$shouldHideDelete;
31
+ if (shouldHideDeleted) {
32
+ return _view.Decoration.inline(change.fromB, change.toB, {
33
+ style: displayNoneStyle
34
+ }, {
35
+ key: 'diff-inline'
36
+ });
37
+ }
25
38
  var style;
26
39
  if ((0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
27
40
  if (isInserted) {
@@ -43,7 +43,8 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
43
43
  isDisplayingChanges: false
44
44
  }, (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
45
45
  isInverted: false,
46
- diffType: 'inline'
46
+ diffType: 'inline',
47
+ hideDeletedDiffs: false
47
48
  } : {});
48
49
  },
49
50
  apply: function apply(tr, currentPluginState, oldState, newState) {
@@ -51,7 +52,7 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
51
52
  var newPluginState = currentPluginState;
52
53
  if (meta) {
53
54
  if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'SHOW_DIFF') {
54
- var _newPluginState, _newPluginState2;
55
+ var _newPluginState, _newPluginState2, _newPluginState3;
55
56
  // Update the plugin state with the new metadata
56
57
  newPluginState = _objectSpread(_objectSpread(_objectSpread({}, currentPluginState), meta), {}, {
57
58
  isDisplayingChanges: true,
@@ -68,7 +69,8 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
68
69
  api: api
69
70
  }, (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
70
71
  isInverted: (_newPluginState = newPluginState) === null || _newPluginState === void 0 ? void 0 : _newPluginState.isInverted,
71
- diffType: (_newPluginState2 = newPluginState) === null || _newPluginState2 === void 0 ? void 0 : _newPluginState2.diffType
72
+ diffType: (_newPluginState2 = newPluginState) === null || _newPluginState2 === void 0 ? void 0 : _newPluginState2.diffType,
73
+ hideDeletedDiffs: (_newPluginState3 = newPluginState) === null || _newPluginState3 === void 0 ? void 0 : _newPluginState3.hideDeletedDiffs
72
74
  } : {}));
73
75
  // Update the decorations
74
76
  newPluginState.decorations = decorations;
@@ -79,7 +81,8 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
79
81
  activeIndex: undefined
80
82
  }, (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
81
83
  isInverted: false,
82
- diffType: 'inline'
84
+ diffType: 'inline',
85
+ hideDeletedDiffs: false
83
86
  } : {});
84
87
  } 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')) {
85
88
  // Update the active index in plugin state and recalculate decorations
@@ -118,7 +121,9 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
118
121
  activeIndexPos: newPluginState.activeIndexPos,
119
122
  api: api
120
123
  }, (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
121
- isInverted: newPluginState.isInverted
124
+ isInverted: newPluginState.isInverted,
125
+ diffType: newPluginState.diffType,
126
+ hideDeletedDiffs: newPluginState.hideDeletedDiffs
122
127
  } : {}));
123
128
  newPluginState.decorations = updatedDecorations;
124
129
  }
@@ -42,7 +42,8 @@ const calculateNodesForBlockDecoration = ({
42
42
  to,
43
43
  colorScheme,
44
44
  isInserted = true,
45
- activeIndexPos
45
+ activeIndexPos,
46
+ shouldHideDeleted = false
46
47
  }) => {
47
48
  const decorations = [];
48
49
  // Iterate over the document nodes within the range
@@ -58,7 +59,8 @@ const calculateNodesForBlockDecoration = ({
58
59
  },
59
60
  colorScheme,
60
61
  isInserted,
61
- isActive
62
+ isActive,
63
+ shouldHideDeleted
62
64
  });
63
65
  if (blockChangedDecorations.length) {
64
66
  decorations.push(...blockChangedDecorations);
@@ -76,7 +78,8 @@ const calculateDiffDecorationsInner = ({
76
78
  activeIndexPos,
77
79
  api,
78
80
  isInverted = false,
79
- diffType = 'inline'
81
+ diffType = 'inline',
82
+ hideDeletedDiffs = false
80
83
  }) => {
81
84
  const {
82
85
  originalDoc,
@@ -143,12 +146,14 @@ const calculateDiffDecorationsInner = ({
143
146
  // Our default operations are insertions, so it should match the opposite of isInverted.
144
147
  const isInserted = !isInverted;
145
148
  if (change.inserted.length > 0) {
149
+ const shouldHideDeleted = expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? isInverted && hideDeletedDiffs : false;
146
150
  decorations.push(createInlineChangedDecoration({
147
151
  change,
148
152
  colorScheme,
149
153
  isActive,
150
154
  ...(expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
151
- isInserted
155
+ isInserted,
156
+ shouldHideDeleted
152
157
  })
153
158
  }));
154
159
  decorations.push(...calculateNodesForBlockDecoration({
@@ -157,28 +162,32 @@ const calculateDiffDecorationsInner = ({
157
162
  to: change.toB,
158
163
  colorScheme,
159
164
  ...(expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
160
- isInserted
165
+ isInserted,
166
+ shouldHideDeleted
161
167
  }),
162
168
  activeIndexPos,
163
169
  intl
164
170
  }));
165
171
  }
166
172
  if (change.deleted.length > 0) {
167
- const decoration = createNodeChangedDecorationWidget({
168
- change,
169
- doc: originalDoc,
170
- nodeViewSerializer,
171
- colorScheme,
172
- newDoc: tr.doc,
173
- intl,
174
- activeIndexPos,
175
- ...(expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
176
- isInserted: !isInserted,
177
- diffType
178
- })
179
- });
180
- if (decoration) {
181
- decorations.push(...decoration);
173
+ const shouldHideDeleted = expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? !isInverted && hideDeletedDiffs : false;
174
+ if (!shouldHideDeleted) {
175
+ const decoration = createNodeChangedDecorationWidget({
176
+ change,
177
+ doc: originalDoc,
178
+ nodeViewSerializer,
179
+ colorScheme,
180
+ newDoc: tr.doc,
181
+ intl,
182
+ activeIndexPos,
183
+ ...(expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
184
+ isInserted: !isInserted,
185
+ diffType
186
+ })
187
+ });
188
+ if (decoration) {
189
+ decorations.push(...decoration);
190
+ }
182
191
  }
183
192
  }
184
193
  });
@@ -213,7 +222,8 @@ export const calculateDiffDecorations = memoizeOne(calculateDiffDecorationsInner
213
222
  intl,
214
223
  activeIndexPos,
215
224
  isInverted,
216
- diffType
225
+ diffType,
226
+ hideDeletedDiffs
217
227
  }], [{
218
228
  pluginState: lastPluginState,
219
229
  state: lastState,
@@ -221,13 +231,14 @@ export const calculateDiffDecorations = memoizeOne(calculateDiffDecorationsInner
221
231
  intl: lastIntl,
222
232
  activeIndexPos: lastActiveIndexPos,
223
233
  isInverted: lastIsInverted,
224
- diffType: lastDiffType
234
+ diffType: lastDiffType,
235
+ hideDeletedDiffs: lastHideDeletedDiffs
225
236
  }]) => {
226
237
  var _ref2;
227
238
  const originalDocIsSame = lastPluginState.originalDoc && pluginState.originalDoc && pluginState.originalDoc.eq(lastPluginState.originalDoc);
228
239
  if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
229
240
  var _ref;
230
- return (_ref = colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isInverted === lastIsInverted && diffType === lastDiffType && isEqual(activeIndexPos, lastActiveIndexPos) && originalDocIsSame && isEqual(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc)) !== null && _ref !== void 0 ? _ref : false;
241
+ return (_ref = colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isInverted === lastIsInverted && diffType === lastDiffType && isEqual(activeIndexPos, lastActiveIndexPos) && originalDocIsSame && isEqual(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && hideDeletedDiffs === lastHideDeletedDiffs) !== null && _ref !== void 0 ? _ref : false;
231
242
  }
232
- return (_ref2 = originalDocIsSame && isEqual(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isEqual(activeIndexPos, lastActiveIndexPos)) !== null && _ref2 !== void 0 ? _ref2 : false;
243
+ return (_ref2 = originalDocIsSame && isEqual(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isEqual(activeIndexPos, lastActiveIndexPos) && hideDeletedDiffs === lastHideDeletedDiffs) !== null && _ref2 !== void 0 ? _ref2 : false;
233
244
  });
@@ -4,6 +4,9 @@ import { fg } from '@atlaskit/platform-feature-flags';
4
4
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
5
5
  import { standardDecorationMarkerVariable, editingStyleQuoteNode, editingStyleRuleNode, editingStyleCardBlockNode, editingStyleNode, deletedContentStyleNew, deletedStyleQuoteNode, addedCellOverlayStyle, deletedCellOverlayStyle } from './colorSchemes/standard';
6
6
  import { traditionalDecorationMarkerVariable, traditionalDecorationMarkerVariableActive, traditionalDecorationMarkerVariableNew, traditionalDeletedDecorationMarkerVariable, traditionalDeletedDecorationMarkerVariableActive, traditionalDeletedDecorationMarkerVariableNew, traditionalStyleQuoteNode, traditionalStyleQuoteNodeActive, traditionalStyleQuoteNodeNew, traditionalStyleRuleNode, traditionalStyleRuleNodeActive, traditionalStyleRuleNodeNew, traditionalStyleCardBlockNode, traditionalStyleCardBlockNodeActive, traditionalStyleCardBlockNodeNew, traditionalStyleNode, traditionalStyleNodeActive, traditionalStyleNodeNew, getDeletedTraditionalInlineStyle, deletedTraditionalStyleQuoteNode, traditionalAddedCellOverlayStyle, deletedTraditionalCellOverlayStyle } from './colorSchemes/traditional';
7
+ const displayNoneStyle = convertToInlineCss({
8
+ display: 'none'
9
+ });
7
10
  const getNodeClass = name => {
8
11
  switch (name) {
9
12
  case 'extension':
@@ -99,9 +102,19 @@ export const createBlockChangedDecoration = ({
99
102
  change,
100
103
  colorScheme,
101
104
  isInserted = true,
102
- isActive = false
105
+ isActive = false,
106
+ shouldHideDeleted = false
103
107
  }) => {
104
108
  const decorations = [];
109
+ if (shouldHideDeleted) {
110
+ return [Decoration.node(change.from, change.to, {
111
+ style: displayNoneStyle
112
+ }, {
113
+ key: 'diff-block',
114
+ nodeName: change.name
115
+ })];
116
+ }
117
+ let style;
105
118
  if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && ['tableCell', 'tableHeader'].includes(change.name)) {
106
119
  const cellOverlay = document.createElement('div');
107
120
  const cellOverlayStyle = isInserted ? colorScheme === 'traditional' ? traditionalAddedCellOverlayStyle : addedCellOverlayStyle : colorScheme === 'traditional' ? deletedTraditionalCellOverlayStyle : deletedCellOverlayStyle;
@@ -112,11 +125,6 @@ export const createBlockChangedDecoration = ({
112
125
  key: `diff-widget-cell-overlay-${change.to}`
113
126
  }));
114
127
  }
115
- let style = getBlockNodeStyle({
116
- nodeName: change.name,
117
- colorScheme,
118
- isActive
119
- });
120
128
  if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
121
129
  style = getBlockNodeStyle({
122
130
  nodeName: change.name,
@@ -124,6 +132,12 @@ export const createBlockChangedDecoration = ({
124
132
  isInserted,
125
133
  isActive
126
134
  });
135
+ } else {
136
+ style = getBlockNodeStyle({
137
+ nodeName: change.name,
138
+ colorScheme,
139
+ isActive
140
+ });
127
141
  }
128
142
  const className = getNodeClass(change.name);
129
143
  if (fg('platform_editor_show_diff_scroll_navigation')) {
@@ -1,8 +1,11 @@
1
+ import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
1
2
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
2
3
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
4
  import { editingStyle, editingStyleActive, deletedContentStyle, deletedContentStyleActive } from './colorSchemes/standard';
4
5
  import { traditionalInsertStyle, traditionalInsertStyleActive, getDeletedTraditionalInlineStyle } from './colorSchemes/traditional';
5
-
6
+ const displayNoneStyle = convertToInlineCss({
7
+ display: 'none'
8
+ });
6
9
  /**
7
10
  * Inline decoration used for insertions as the content already exists in the document
8
11
  *
@@ -14,8 +17,16 @@ export const createInlineChangedDecoration = ({
14
17
  change,
15
18
  colorScheme,
16
19
  isActive = false,
17
- isInserted = true
20
+ isInserted = true,
21
+ shouldHideDeleted = false
18
22
  }) => {
23
+ if (shouldHideDeleted) {
24
+ return Decoration.inline(change.fromB, change.toB, {
25
+ style: displayNoneStyle
26
+ }, {
27
+ key: 'diff-inline'
28
+ });
29
+ }
19
30
  let style;
20
31
  if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
21
32
  if (isInserted) {
@@ -33,7 +33,8 @@ export const createPlugin = (config, getIntl, api) => {
33
33
  isDisplayingChanges: false,
34
34
  ...(expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
35
35
  isInverted: false,
36
- diffType: 'inline'
36
+ diffType: 'inline',
37
+ hideDeletedDiffs: false
37
38
  } : {})
38
39
  };
39
40
  },
@@ -42,7 +43,7 @@ export const createPlugin = (config, getIntl, api) => {
42
43
  let newPluginState = currentPluginState;
43
44
  if (meta) {
44
45
  if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'SHOW_DIFF') {
45
- var _newPluginState, _newPluginState2;
46
+ var _newPluginState, _newPluginState2, _newPluginState3;
46
47
  // Update the plugin state with the new metadata
47
48
  newPluginState = {
48
49
  ...currentPluginState,
@@ -61,7 +62,8 @@ export const createPlugin = (config, getIntl, api) => {
61
62
  api,
62
63
  ...(expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
63
64
  isInverted: (_newPluginState = newPluginState) === null || _newPluginState === void 0 ? void 0 : _newPluginState.isInverted,
64
- diffType: (_newPluginState2 = newPluginState) === null || _newPluginState2 === void 0 ? void 0 : _newPluginState2.diffType
65
+ diffType: (_newPluginState2 = newPluginState) === null || _newPluginState2 === void 0 ? void 0 : _newPluginState2.diffType,
66
+ hideDeletedDiffs: (_newPluginState3 = newPluginState) === null || _newPluginState3 === void 0 ? void 0 : _newPluginState3.hideDeletedDiffs
65
67
  } : {})
66
68
  });
67
69
  // Update the decorations
@@ -79,7 +81,8 @@ export const createPlugin = (config, getIntl, api) => {
79
81
  */
80
82
  ...(expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
81
83
  isInverted: false,
82
- diffType: 'inline'
84
+ diffType: 'inline',
85
+ hideDeletedDiffs: false
83
86
  } : {})
84
87
  };
85
88
  } 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')) {
@@ -120,7 +123,9 @@ export const createPlugin = (config, getIntl, api) => {
120
123
  activeIndexPos: newPluginState.activeIndexPos,
121
124
  api,
122
125
  ...(expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
123
- isInverted: newPluginState.isInverted
126
+ isInverted: newPluginState.isInverted,
127
+ diffType: newPluginState.diffType,
128
+ hideDeletedDiffs: newPluginState.hideDeletedDiffs
124
129
  } : {})
125
130
  });
126
131
  newPluginState.decorations = updatedDecorations;
@@ -50,7 +50,9 @@ var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration
50
50
  colorScheme = _ref2.colorScheme,
51
51
  _ref2$isInserted = _ref2.isInserted,
52
52
  isInserted = _ref2$isInserted === void 0 ? true : _ref2$isInserted,
53
- activeIndexPos = _ref2.activeIndexPos;
53
+ activeIndexPos = _ref2.activeIndexPos,
54
+ _ref2$shouldHideDelet = _ref2.shouldHideDeleted,
55
+ shouldHideDeleted = _ref2$shouldHideDelet === void 0 ? false : _ref2$shouldHideDelet;
54
56
  var decorations = [];
55
57
  // Iterate over the document nodes within the range
56
58
  doc.nodesBetween(from, to, function (node, pos) {
@@ -65,7 +67,8 @@ var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration
65
67
  },
66
68
  colorScheme: colorScheme,
67
69
  isInserted: isInserted,
68
- isActive: isActive
70
+ isActive: isActive,
71
+ shouldHideDeleted: shouldHideDeleted
69
72
  });
70
73
  if (blockChangedDecorations.length) {
71
74
  decorations.push.apply(decorations, _toConsumableArray(blockChangedDecorations));
@@ -85,7 +88,9 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
85
88
  _ref3$isInverted = _ref3.isInverted,
86
89
  isInverted = _ref3$isInverted === void 0 ? false : _ref3$isInverted,
87
90
  _ref3$diffType = _ref3.diffType,
88
- diffType = _ref3$diffType === void 0 ? 'inline' : _ref3$diffType;
91
+ diffType = _ref3$diffType === void 0 ? 'inline' : _ref3$diffType,
92
+ _ref3$hideDeletedDiff = _ref3.hideDeletedDiffs,
93
+ hideDeletedDiffs = _ref3$hideDeletedDiff === void 0 ? false : _ref3$hideDeletedDiff;
89
94
  var originalDoc = pluginState.originalDoc,
90
95
  steps = pluginState.steps;
91
96
  if (!originalDoc || !pluginState.isDisplayingChanges) {
@@ -156,12 +161,14 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
156
161
  // Our default operations are insertions, so it should match the opposite of isInverted.
157
162
  var isInserted = !isInverted;
158
163
  if (change.inserted.length > 0) {
164
+ var shouldHideDeleted = expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? isInverted && hideDeletedDiffs : false;
159
165
  decorations.push(createInlineChangedDecoration(_objectSpread({
160
166
  change: change,
161
167
  colorScheme: colorScheme,
162
168
  isActive: isActive
163
169
  }, expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
164
- isInserted: isInserted
170
+ isInserted: isInserted,
171
+ shouldHideDeleted: shouldHideDeleted
165
172
  })));
166
173
  decorations.push.apply(decorations, _toConsumableArray(calculateNodesForBlockDecoration(_objectSpread(_objectSpread({
167
174
  doc: tr.doc,
@@ -169,27 +176,31 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
169
176
  to: change.toB,
170
177
  colorScheme: colorScheme
171
178
  }, expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
172
- isInserted: isInserted
179
+ isInserted: isInserted,
180
+ shouldHideDeleted: shouldHideDeleted
173
181
  }), {}, {
174
182
  activeIndexPos: activeIndexPos,
175
183
  intl: intl
176
184
  }))));
177
185
  }
178
186
  if (change.deleted.length > 0) {
179
- var decoration = createNodeChangedDecorationWidget(_objectSpread({
180
- change: change,
181
- doc: originalDoc,
182
- nodeViewSerializer: nodeViewSerializer,
183
- colorScheme: colorScheme,
184
- newDoc: tr.doc,
185
- intl: intl,
186
- activeIndexPos: activeIndexPos
187
- }, expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
188
- isInserted: !isInserted,
189
- diffType: diffType
190
- }));
191
- if (decoration) {
192
- decorations.push.apply(decorations, _toConsumableArray(decoration));
187
+ var _shouldHideDeleted = expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? !isInverted && hideDeletedDiffs : false;
188
+ if (!_shouldHideDeleted) {
189
+ var decoration = createNodeChangedDecorationWidget(_objectSpread({
190
+ change: change,
191
+ doc: originalDoc,
192
+ nodeViewSerializer: nodeViewSerializer,
193
+ colorScheme: colorScheme,
194
+ newDoc: tr.doc,
195
+ intl: intl,
196
+ activeIndexPos: activeIndexPos
197
+ }, expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
198
+ isInserted: !isInserted,
199
+ diffType: diffType
200
+ }));
201
+ if (decoration) {
202
+ decorations.push.apply(decorations, _toConsumableArray(decoration));
203
+ }
193
204
  }
194
205
  }
195
206
  });
@@ -227,7 +238,8 @@ function (_ref4, _ref5) {
227
238
  intl = _ref6$.intl,
228
239
  activeIndexPos = _ref6$.activeIndexPos,
229
240
  isInverted = _ref6$.isInverted,
230
- diffType = _ref6$.diffType;
241
+ diffType = _ref6$.diffType,
242
+ hideDeletedDiffs = _ref6$.hideDeletedDiffs;
231
243
  var _ref7 = _slicedToArray(_ref5, 1),
232
244
  _ref7$ = _ref7[0],
233
245
  lastPluginState = _ref7$.pluginState,
@@ -236,11 +248,12 @@ function (_ref4, _ref5) {
236
248
  lastIntl = _ref7$.intl,
237
249
  lastActiveIndexPos = _ref7$.activeIndexPos,
238
250
  lastIsInverted = _ref7$.isInverted,
239
- lastDiffType = _ref7$.diffType;
251
+ lastDiffType = _ref7$.diffType,
252
+ lastHideDeletedDiffs = _ref7$.hideDeletedDiffs;
240
253
  var originalDocIsSame = lastPluginState.originalDoc && pluginState.originalDoc && pluginState.originalDoc.eq(lastPluginState.originalDoc);
241
254
  if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
242
255
  var _ref8;
243
- return (_ref8 = colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isInverted === lastIsInverted && diffType === lastDiffType && isEqual(activeIndexPos, lastActiveIndexPos) && originalDocIsSame && isEqual(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc)) !== null && _ref8 !== void 0 ? _ref8 : false;
256
+ return (_ref8 = colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isInverted === lastIsInverted && diffType === lastDiffType && isEqual(activeIndexPos, lastActiveIndexPos) && originalDocIsSame && isEqual(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && hideDeletedDiffs === lastHideDeletedDiffs) !== null && _ref8 !== void 0 ? _ref8 : false;
244
257
  }
245
- return (_ref9 = originalDocIsSame && isEqual(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isEqual(activeIndexPos, lastActiveIndexPos)) !== null && _ref9 !== void 0 ? _ref9 : false;
258
+ return (_ref9 = originalDocIsSame && isEqual(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isEqual(activeIndexPos, lastActiveIndexPos) && hideDeletedDiffs === lastHideDeletedDiffs) !== null && _ref9 !== void 0 ? _ref9 : false;
246
259
  });
@@ -4,6 +4,9 @@ import { fg } from '@atlaskit/platform-feature-flags';
4
4
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
5
5
  import { standardDecorationMarkerVariable, editingStyleQuoteNode, editingStyleRuleNode, editingStyleCardBlockNode, editingStyleNode, deletedContentStyleNew, deletedStyleQuoteNode, addedCellOverlayStyle, deletedCellOverlayStyle } from './colorSchemes/standard';
6
6
  import { traditionalDecorationMarkerVariable, traditionalDecorationMarkerVariableActive, traditionalDecorationMarkerVariableNew, traditionalDeletedDecorationMarkerVariable, traditionalDeletedDecorationMarkerVariableActive, traditionalDeletedDecorationMarkerVariableNew, traditionalStyleQuoteNode, traditionalStyleQuoteNodeActive, traditionalStyleQuoteNodeNew, traditionalStyleRuleNode, traditionalStyleRuleNodeActive, traditionalStyleRuleNodeNew, traditionalStyleCardBlockNode, traditionalStyleCardBlockNodeActive, traditionalStyleCardBlockNodeNew, traditionalStyleNode, traditionalStyleNodeActive, traditionalStyleNodeNew, getDeletedTraditionalInlineStyle, deletedTraditionalStyleQuoteNode, traditionalAddedCellOverlayStyle, deletedTraditionalCellOverlayStyle } from './colorSchemes/traditional';
7
+ var displayNoneStyle = convertToInlineCss({
8
+ display: 'none'
9
+ });
7
10
  var getNodeClass = function getNodeClass(name) {
8
11
  switch (name) {
9
12
  case 'extension':
@@ -102,8 +105,19 @@ export var createBlockChangedDecoration = function createBlockChangedDecoration(
102
105
  _ref2$isInserted = _ref2.isInserted,
103
106
  isInserted = _ref2$isInserted === void 0 ? true : _ref2$isInserted,
104
107
  _ref2$isActive = _ref2.isActive,
105
- isActive = _ref2$isActive === void 0 ? false : _ref2$isActive;
108
+ isActive = _ref2$isActive === void 0 ? false : _ref2$isActive,
109
+ _ref2$shouldHideDelet = _ref2.shouldHideDeleted,
110
+ shouldHideDeleted = _ref2$shouldHideDelet === void 0 ? false : _ref2$shouldHideDelet;
106
111
  var decorations = [];
112
+ if (shouldHideDeleted) {
113
+ return [Decoration.node(change.from, change.to, {
114
+ style: displayNoneStyle
115
+ }, {
116
+ key: 'diff-block',
117
+ nodeName: change.name
118
+ })];
119
+ }
120
+ var style;
107
121
  if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && ['tableCell', 'tableHeader'].includes(change.name)) {
108
122
  var cellOverlay = document.createElement('div');
109
123
  var cellOverlayStyle = isInserted ? colorScheme === 'traditional' ? traditionalAddedCellOverlayStyle : addedCellOverlayStyle : colorScheme === 'traditional' ? deletedTraditionalCellOverlayStyle : deletedCellOverlayStyle;
@@ -114,11 +128,6 @@ export var createBlockChangedDecoration = function createBlockChangedDecoration(
114
128
  key: "diff-widget-cell-overlay-".concat(change.to)
115
129
  }));
116
130
  }
117
- var style = getBlockNodeStyle({
118
- nodeName: change.name,
119
- colorScheme: colorScheme,
120
- isActive: isActive
121
- });
122
131
  if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
123
132
  style = getBlockNodeStyle({
124
133
  nodeName: change.name,
@@ -126,6 +135,12 @@ export var createBlockChangedDecoration = function createBlockChangedDecoration(
126
135
  isInserted: isInserted,
127
136
  isActive: isActive
128
137
  });
138
+ } else {
139
+ style = getBlockNodeStyle({
140
+ nodeName: change.name,
141
+ colorScheme: colorScheme,
142
+ isActive: isActive
143
+ });
129
144
  }
130
145
  var className = getNodeClass(change.name);
131
146
  if (fg('platform_editor_show_diff_scroll_navigation')) {
@@ -1,8 +1,11 @@
1
+ import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
1
2
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
2
3
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
4
  import { editingStyle, editingStyleActive, deletedContentStyle, deletedContentStyleActive } from './colorSchemes/standard';
4
5
  import { traditionalInsertStyle, traditionalInsertStyleActive, getDeletedTraditionalInlineStyle } from './colorSchemes/traditional';
5
-
6
+ var displayNoneStyle = convertToInlineCss({
7
+ display: 'none'
8
+ });
6
9
  /**
7
10
  * Inline decoration used for insertions as the content already exists in the document
8
11
  *
@@ -16,7 +19,16 @@ export var createInlineChangedDecoration = function createInlineChangedDecoratio
16
19
  _ref$isActive = _ref.isActive,
17
20
  isActive = _ref$isActive === void 0 ? false : _ref$isActive,
18
21
  _ref$isInserted = _ref.isInserted,
19
- isInserted = _ref$isInserted === void 0 ? true : _ref$isInserted;
22
+ isInserted = _ref$isInserted === void 0 ? true : _ref$isInserted,
23
+ _ref$shouldHideDelete = _ref.shouldHideDeleted,
24
+ shouldHideDeleted = _ref$shouldHideDelete === void 0 ? false : _ref$shouldHideDelete;
25
+ if (shouldHideDeleted) {
26
+ return Decoration.inline(change.fromB, change.toB, {
27
+ style: displayNoneStyle
28
+ }, {
29
+ key: 'diff-inline'
30
+ });
31
+ }
20
32
  var style;
21
33
  if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
22
34
  if (isInserted) {
@@ -36,7 +36,8 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
36
36
  isDisplayingChanges: false
37
37
  }, expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
38
38
  isInverted: false,
39
- diffType: 'inline'
39
+ diffType: 'inline',
40
+ hideDeletedDiffs: false
40
41
  } : {});
41
42
  },
42
43
  apply: function apply(tr, currentPluginState, oldState, newState) {
@@ -44,7 +45,7 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
44
45
  var newPluginState = currentPluginState;
45
46
  if (meta) {
46
47
  if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'SHOW_DIFF') {
47
- var _newPluginState, _newPluginState2;
48
+ var _newPluginState, _newPluginState2, _newPluginState3;
48
49
  // Update the plugin state with the new metadata
49
50
  newPluginState = _objectSpread(_objectSpread(_objectSpread({}, currentPluginState), meta), {}, {
50
51
  isDisplayingChanges: true,
@@ -61,7 +62,8 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
61
62
  api: api
62
63
  }, expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
63
64
  isInverted: (_newPluginState = newPluginState) === null || _newPluginState === void 0 ? void 0 : _newPluginState.isInverted,
64
- diffType: (_newPluginState2 = newPluginState) === null || _newPluginState2 === void 0 ? void 0 : _newPluginState2.diffType
65
+ diffType: (_newPluginState2 = newPluginState) === null || _newPluginState2 === void 0 ? void 0 : _newPluginState2.diffType,
66
+ hideDeletedDiffs: (_newPluginState3 = newPluginState) === null || _newPluginState3 === void 0 ? void 0 : _newPluginState3.hideDeletedDiffs
65
67
  } : {}));
66
68
  // Update the decorations
67
69
  newPluginState.decorations = decorations;
@@ -72,7 +74,8 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
72
74
  activeIndex: undefined
73
75
  }, expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
74
76
  isInverted: false,
75
- diffType: 'inline'
77
+ diffType: 'inline',
78
+ hideDeletedDiffs: false
76
79
  } : {});
77
80
  } 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')) {
78
81
  // Update the active index in plugin state and recalculate decorations
@@ -111,7 +114,9 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
111
114
  activeIndexPos: newPluginState.activeIndexPos,
112
115
  api: api
113
116
  }, expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
114
- isInverted: newPluginState.isInverted
117
+ isInverted: newPluginState.isInverted,
118
+ diffType: newPluginState.diffType,
119
+ hideDeletedDiffs: newPluginState.hideDeletedDiffs
115
120
  } : {}));
116
121
  newPluginState.decorations = updatedDecorations;
117
122
  }
@@ -6,13 +6,14 @@ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
6
6
  import type { ColorScheme, ShowDiffPlugin } from '../../showDiffPluginType';
7
7
  import type { ShowDiffPluginState } from '../main';
8
8
  import type { NodeViewSerializer } from '../NodeViewSerializer';
9
- export declare const calculateDiffDecorations: MemoizedFn<({ state, pluginState, nodeViewSerializer, colorScheme, intl, activeIndexPos, api, }: {
9
+ export declare const calculateDiffDecorations: MemoizedFn<({ state, pluginState, nodeViewSerializer, colorScheme, intl, activeIndexPos, api, hideDeletedDiffs, }: {
10
10
  activeIndexPos?: {
11
11
  from: number;
12
12
  to: number;
13
13
  };
14
14
  api: ExtractInjectionAPI<ShowDiffPlugin> | undefined;
15
15
  colorScheme?: ColorScheme;
16
+ hideDeletedDiffs?: boolean;
16
17
  intl: IntlShape;
17
18
  nodeViewSerializer: NodeViewSerializer;
18
19
  pluginState: Omit<ShowDiffPluginState, 'decorations'>;
@@ -8,7 +8,7 @@ import type { ColorScheme } from '../../showDiffPluginType';
8
8
  * @param isActive Whether this node is part of the currently active/focused change
9
9
  * @returns Prosemirror node decoration or undefined
10
10
  */
11
- export declare const createBlockChangedDecoration: ({ change, colorScheme, isInserted, isActive, }: {
11
+ export declare const createBlockChangedDecoration: ({ change, colorScheme, isInserted, isActive, shouldHideDeleted, }: {
12
12
  change: {
13
13
  from: number;
14
14
  name: string;
@@ -17,4 +17,5 @@ export declare const createBlockChangedDecoration: ({ change, colorScheme, isIns
17
17
  colorScheme?: ColorScheme;
18
18
  isActive?: boolean;
19
19
  isInserted?: boolean;
20
+ shouldHideDeleted?: boolean;
20
21
  }) => Decoration[];
@@ -6,7 +6,7 @@ import type { ColorScheme } from '../../showDiffPluginType';
6
6
  * @param change Changeset "change" containing information about the change content + range
7
7
  * @returns Prosemirror inline decoration
8
8
  */
9
- export declare const createInlineChangedDecoration: ({ change, colorScheme, isActive, isInserted, }: {
9
+ export declare const createInlineChangedDecoration: ({ change, colorScheme, isActive, isInserted, shouldHideDeleted, }: {
10
10
  change: {
11
11
  fromB: number;
12
12
  toB: number;
@@ -14,4 +14,5 @@ export declare const createInlineChangedDecoration: ({ change, colorScheme, isAc
14
14
  colorScheme?: ColorScheme;
15
15
  isActive?: boolean;
16
16
  isInserted?: boolean;
17
+ shouldHideDeleted?: boolean;
17
18
  }) => Decoration;
@@ -15,6 +15,7 @@ export type ShowDiffPluginState = {
15
15
  };
16
16
  decorations: DecorationSet;
17
17
  diffType?: DiffType;
18
+ hideDeletedDiffs?: boolean;
18
19
  isDisplayingChanges: boolean;
19
20
  isInverted?: boolean;
20
21
  originalDoc: PMNode | undefined;
@@ -21,6 +21,7 @@ export type DiffParams = {
21
21
  };
22
22
  export type PMDiffParams = {
23
23
  diffType?: DiffType;
24
+ hideDeletedDiffs?: boolean;
24
25
  isInverted?: boolean;
25
26
  originalDoc: Node;
26
27
  /**
@@ -6,13 +6,14 @@ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
6
6
  import type { ColorScheme, ShowDiffPlugin } from '../../showDiffPluginType';
7
7
  import type { ShowDiffPluginState } from '../main';
8
8
  import type { NodeViewSerializer } from '../NodeViewSerializer';
9
- export declare const calculateDiffDecorations: MemoizedFn<({ state, pluginState, nodeViewSerializer, colorScheme, intl, activeIndexPos, api, }: {
9
+ export declare const calculateDiffDecorations: MemoizedFn<({ state, pluginState, nodeViewSerializer, colorScheme, intl, activeIndexPos, api, hideDeletedDiffs, }: {
10
10
  activeIndexPos?: {
11
11
  from: number;
12
12
  to: number;
13
13
  };
14
14
  api: ExtractInjectionAPI<ShowDiffPlugin> | undefined;
15
15
  colorScheme?: ColorScheme;
16
+ hideDeletedDiffs?: boolean;
16
17
  intl: IntlShape;
17
18
  nodeViewSerializer: NodeViewSerializer;
18
19
  pluginState: Omit<ShowDiffPluginState, 'decorations'>;
@@ -8,7 +8,7 @@ import type { ColorScheme } from '../../showDiffPluginType';
8
8
  * @param isActive Whether this node is part of the currently active/focused change
9
9
  * @returns Prosemirror node decoration or undefined
10
10
  */
11
- export declare const createBlockChangedDecoration: ({ change, colorScheme, isInserted, isActive, }: {
11
+ export declare const createBlockChangedDecoration: ({ change, colorScheme, isInserted, isActive, shouldHideDeleted, }: {
12
12
  change: {
13
13
  from: number;
14
14
  name: string;
@@ -17,4 +17,5 @@ export declare const createBlockChangedDecoration: ({ change, colorScheme, isIns
17
17
  colorScheme?: ColorScheme;
18
18
  isActive?: boolean;
19
19
  isInserted?: boolean;
20
+ shouldHideDeleted?: boolean;
20
21
  }) => Decoration[];
@@ -6,7 +6,7 @@ import type { ColorScheme } from '../../showDiffPluginType';
6
6
  * @param change Changeset "change" containing information about the change content + range
7
7
  * @returns Prosemirror inline decoration
8
8
  */
9
- export declare const createInlineChangedDecoration: ({ change, colorScheme, isActive, isInserted, }: {
9
+ export declare const createInlineChangedDecoration: ({ change, colorScheme, isActive, isInserted, shouldHideDeleted, }: {
10
10
  change: {
11
11
  fromB: number;
12
12
  toB: number;
@@ -14,4 +14,5 @@ export declare const createInlineChangedDecoration: ({ change, colorScheme, isAc
14
14
  colorScheme?: ColorScheme;
15
15
  isActive?: boolean;
16
16
  isInserted?: boolean;
17
+ shouldHideDeleted?: boolean;
17
18
  }) => Decoration;
@@ -15,6 +15,7 @@ export type ShowDiffPluginState = {
15
15
  };
16
16
  decorations: DecorationSet;
17
17
  diffType?: DiffType;
18
+ hideDeletedDiffs?: boolean;
18
19
  isDisplayingChanges: boolean;
19
20
  isInverted?: boolean;
20
21
  originalDoc: PMNode | undefined;
@@ -21,6 +21,7 @@ export type DiffParams = {
21
21
  };
22
22
  export type PMDiffParams = {
23
23
  diffType?: DiffType;
24
+ hideDeletedDiffs?: boolean;
24
25
  isInverted?: boolean;
25
26
  originalDoc: Node;
26
27
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-show-diff",
3
- "version": "6.3.1",
3
+ "version": "6.4.0",
4
4
  "description": "ShowDiff plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,7 +34,7 @@
34
34
  "@atlaskit/editor-prosemirror": "^7.3.0",
35
35
  "@atlaskit/editor-tables": "^2.9.0",
36
36
  "@atlaskit/platform-feature-flags": "^1.1.0",
37
- "@atlaskit/tmp-editor-statsig": "^61.0.0",
37
+ "@atlaskit/tmp-editor-statsig": "^62.3.0",
38
38
  "@atlaskit/tokens": "^13.0.0",
39
39
  "@babel/runtime": "^7.0.0",
40
40
  "lodash": "^4.17.21",
@@ -56,7 +56,7 @@
56
56
  "react-intl-next": "npm:react-intl@^5.18.1"
57
57
  },
58
58
  "peerDependencies": {
59
- "@atlaskit/editor-common": "^112.20.0",
59
+ "@atlaskit/editor-common": "^112.22.0",
60
60
  "react": "^18.2.0"
61
61
  },
62
62
  "techstack": {