@atlaskit/editor-plugin-show-diff 10.5.3 → 10.6.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @atlaskit/editor-plugin-show-diff
2
2
 
3
+ ## 10.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`0840aa4f6b2d0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0840aa4f6b2d0) -
8
+ Add a new `inlineDeletedDiffPlacement: 'before' | 'after'` option to `PMDiffParams` for the
9
+ `smart` diff type. When set to `'after'`, inline-level (and sentence-level) deleted content is
10
+ rendered after the added/updated content instead of before it. Defaults to `'before'` and is
11
+ independent of the existing node/paragraph-level `deletedDiffPlacement` option. Post Stream Review
12
+ now requests `'after'` so reviewers read the new text first.
13
+
3
14
  ## 10.5.3
4
15
 
5
16
  ### Patch Changes
@@ -151,7 +151,9 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
151
151
  showIndicators = _ref3$showIndicators === void 0 ? false : _ref3$showIndicators,
152
152
  smartThresholds = _ref3.smartThresholds,
153
153
  _ref3$deletedDiffPlac = _ref3.deletedDiffPlacement,
154
- deletedDiffPlacement = _ref3$deletedDiffPlac === void 0 ? 'top' : _ref3$deletedDiffPlac;
154
+ deletedDiffPlacement = _ref3$deletedDiffPlac === void 0 ? 'top' : _ref3$deletedDiffPlac,
155
+ _ref3$inlineDeletedDi = _ref3.inlineDeletedDiffPlacement,
156
+ inlineDeletedDiffPlacement = _ref3$inlineDeletedDi === void 0 ? 'before' : _ref3$inlineDeletedDi;
155
157
  var originalDoc = pluginState.originalDoc,
156
158
  steps = pluginState.steps,
157
159
  isDisplayingChanges = pluginState.isDisplayingChanges;
@@ -326,10 +328,19 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
326
328
  isInserted: !isInserted,
327
329
  diffType: diffType,
328
330
  hideAddedDiffsUnderline: hideAddedDiffsUnderline,
329
- // For `smart` node- and paragraph-level changes, optionally render the
330
- // deleted content below the new content (gray + strikethrough) instead
331
- // of above it. Controlled by `deletedDiffPlacement` (default `'top'`).
332
- placeBelow: deletedDiffPlacement === 'bottom' && diffType === 'smart' && (0, _platformFeatureFlags.fg)('platform_editor_ai_smart_diff') && ((0, _helpers.smartChangeLevel)(change) === 'node' || (0, _helpers.smartChangeLevel)(change) === 'paragraph')
331
+ // For `smart` changes, optionally render the deleted content after the new
332
+ // content (gray + strikethrough) instead of before it. Two independent
333
+ // controls, split by change level:
334
+ // - node/paragraph-level: `deletedDiffPlacement` (default `'top'`).
335
+ // - inline/sentence-level: `inlineDeletedDiffPlacement` (default `'before'`).
336
+ placeBelow: diffType === 'smart' && (0, _platformFeatureFlags.fg)('platform_editor_ai_smart_diff') && function () {
337
+ var level = (0, _helpers.smartChangeLevel)(change);
338
+ if (level === 'node' || level === 'paragraph') {
339
+ return deletedDiffPlacement === 'bottom';
340
+ }
341
+ // Inline-level (undefined) and sentence-level changes.
342
+ return inlineDeletedDiffPlacement === 'after';
343
+ }()
333
344
  }), {}, {
334
345
  showIndicators: showIndicators
335
346
  }))));
@@ -500,7 +511,8 @@ function (_ref5, _ref6) {
500
511
  hideAddedDiffsUnderline = _ref7$.hideAddedDiffsUnderline,
501
512
  showIndicators = _ref7$.showIndicators,
502
513
  smartThresholds = _ref7$.smartThresholds,
503
- deletedDiffPlacement = _ref7$.deletedDiffPlacement;
514
+ deletedDiffPlacement = _ref7$.deletedDiffPlacement,
515
+ inlineDeletedDiffPlacement = _ref7$.inlineDeletedDiffPlacement;
504
516
  var _ref8 = (0, _slicedToArray2.default)(_ref6, 1),
505
517
  _ref8$ = _ref8[0],
506
518
  lastPluginState = _ref8$.pluginState,
@@ -514,11 +526,12 @@ function (_ref5, _ref6) {
514
526
  lastHideAddedDiffsUnderline = _ref8$.hideAddedDiffsUnderline,
515
527
  lastShowIndicators = _ref8$.showIndicators,
516
528
  lastSmartThresholds = _ref8$.smartThresholds,
517
- lastDeletedDiffPlacement = _ref8$.deletedDiffPlacement;
529
+ lastDeletedDiffPlacement = _ref8$.deletedDiffPlacement,
530
+ lastInlineDeletedDiffPlacement = _ref8$.inlineDeletedDiffPlacement;
518
531
  var originalDocIsSame = lastPluginState.originalDoc && pluginState.originalDoc && pluginState.originalDoc.eq(lastPluginState.originalDoc);
519
532
  if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
520
533
  var _ref9;
521
- return (_ref9 = 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 && hideAddedDiffsUnderline === lastHideAddedDiffsUnderline && showIndicators === lastShowIndicators && (0, _isEqual.default)(smartThresholds, lastSmartThresholds) && deletedDiffPlacement === lastDeletedDiffPlacement) !== null && _ref9 !== void 0 ? _ref9 : false;
534
+ return (_ref9 = 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 && hideAddedDiffsUnderline === lastHideAddedDiffsUnderline && showIndicators === lastShowIndicators && (0, _isEqual.default)(smartThresholds, lastSmartThresholds) && deletedDiffPlacement === lastDeletedDiffPlacement && inlineDeletedDiffPlacement === lastInlineDeletedDiffPlacement) !== null && _ref9 !== void 0 ? _ref9 : false;
522
535
  }
523
536
  return (_ref0 = 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 && _ref0 !== void 0 ? _ref0 : false;
524
537
  });
@@ -52,7 +52,7 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
52
52
  var newPluginState = currentPluginState;
53
53
  if (meta) {
54
54
  if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'SHOW_DIFF') {
55
- var _newPluginState, _newPluginState2, _newPluginState3, _newPluginState4, _newPluginState5, _newPluginState6, _newPluginState7, _newPluginState8, _newPluginState9;
55
+ var _newPluginState, _newPluginState2, _newPluginState3, _newPluginState4, _newPluginState5, _newPluginState6, _newPluginState7, _newPluginState8, _newPluginState9, _newPluginState0;
56
56
  // Update the plugin state with the new metadata
57
57
  newPluginState = _objectSpread(_objectSpread(_objectSpread({}, currentPluginState), meta), {}, {
58
58
  isDisplayingChanges: true,
@@ -74,13 +74,14 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
74
74
  hideAddedDiffsUnderline: (_newPluginState5 = newPluginState) === null || _newPluginState5 === void 0 ? void 0 : _newPluginState5.hideAddedDiffsUnderline,
75
75
  showIndicators: (_newPluginState6 = newPluginState) === null || _newPluginState6 === void 0 ? void 0 : _newPluginState6.showIndicators,
76
76
  smartThresholds: (_newPluginState7 = newPluginState) === null || _newPluginState7 === void 0 ? void 0 : _newPluginState7.smartThresholds,
77
- deletedDiffPlacement: (_newPluginState8 = newPluginState) === null || _newPluginState8 === void 0 ? void 0 : _newPluginState8.deletedDiffPlacement
77
+ deletedDiffPlacement: (_newPluginState8 = newPluginState) === null || _newPluginState8 === void 0 ? void 0 : _newPluginState8.deletedDiffPlacement,
78
+ inlineDeletedDiffPlacement: (_newPluginState9 = newPluginState) === null || _newPluginState9 === void 0 ? void 0 : _newPluginState9.inlineDeletedDiffPlacement
78
79
  } : {})),
79
80
  decorations = _calculateDiffDecorat.decorations,
80
81
  diffDescriptors = _calculateDiffDecorat.diffDescriptors;
81
82
  // Update the decorations and their ids
82
83
  newPluginState.decorations = decorations;
83
- if ((0, _isExtendedEnabled.isExtendedEnabled)((_newPluginState9 = newPluginState) === null || _newPluginState9 === void 0 ? void 0 : _newPluginState9.diffType)) {
84
+ if ((0, _isExtendedEnabled.isExtendedEnabled)((_newPluginState0 = newPluginState) === null || _newPluginState0 === void 0 ? void 0 : _newPluginState0.diffType)) {
84
85
  newPluginState.diffDescriptors = diffDescriptors;
85
86
  }
86
87
  } else if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'HIDE_DIFF') {
@@ -96,9 +97,9 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
96
97
  diffDescriptors: []
97
98
  } : {});
98
99
  } else if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'SCROLL_TO_NEXT' || (meta === null || meta === void 0 ? void 0 : meta.action) === 'SCROLL_TO_PREVIOUS') {
99
- var _newPluginState0;
100
+ var _newPluginState1;
100
101
  // Update the active index in plugin state and recalculate decorations
101
- var _decorations = (0, _getScrollableDecorations.getScrollableDecorations)(currentPluginState.decorations, newState.doc, (_newPluginState0 = newPluginState) === null || _newPluginState0 === void 0 ? void 0 : _newPluginState0.diffType);
102
+ var _decorations = (0, _getScrollableDecorations.getScrollableDecorations)(currentPluginState.decorations, newState.doc, (_newPluginState1 = newPluginState) === null || _newPluginState1 === void 0 ? void 0 : _newPluginState1.diffType);
102
103
  if (_decorations.length > 0) {
103
104
  var _currentPluginState$a;
104
105
  // Initialize to -1 if undefined so that the first "next" scroll takes us to index 0 (first change).
@@ -139,7 +140,8 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
139
140
  hideAddedDiffsUnderline: newPluginState.hideAddedDiffsUnderline,
140
141
  showIndicators: newPluginState.showIndicators,
141
142
  smartThresholds: newPluginState.smartThresholds,
142
- deletedDiffPlacement: newPluginState.deletedDiffPlacement
143
+ deletedDiffPlacement: newPluginState.deletedDiffPlacement,
144
+ inlineDeletedDiffPlacement: newPluginState.inlineDeletedDiffPlacement
143
145
  } : {})),
144
146
  updatedDecorations = _calculateDiffDecorat2.decorations,
145
147
  updatedDiffDescriptors = _calculateDiffDecorat2.diffDescriptors;
@@ -130,7 +130,8 @@ const calculateDiffDecorationsInner = ({
130
130
  hideAddedDiffsUnderline: hideAddedDiffsUnderlineParam = false,
131
131
  showIndicators = false,
132
132
  smartThresholds,
133
- deletedDiffPlacement = 'top'
133
+ deletedDiffPlacement = 'top',
134
+ inlineDeletedDiffPlacement = 'before'
134
135
  }) => {
135
136
  const {
136
137
  originalDoc,
@@ -292,10 +293,19 @@ const calculateDiffDecorationsInner = ({
292
293
  isInserted: !isInserted,
293
294
  diffType,
294
295
  hideAddedDiffsUnderline,
295
- // For `smart` node- and paragraph-level changes, optionally render the
296
- // deleted content below the new content (gray + strikethrough) instead
297
- // of above it. Controlled by `deletedDiffPlacement` (default `'top'`).
298
- placeBelow: deletedDiffPlacement === 'bottom' && diffType === 'smart' && fg('platform_editor_ai_smart_diff') && (smartChangeLevel(change) === 'node' || smartChangeLevel(change) === 'paragraph')
296
+ // For `smart` changes, optionally render the deleted content after the new
297
+ // content (gray + strikethrough) instead of before it. Two independent
298
+ // controls, split by change level:
299
+ // - node/paragraph-level: `deletedDiffPlacement` (default `'top'`).
300
+ // - inline/sentence-level: `inlineDeletedDiffPlacement` (default `'before'`).
301
+ placeBelow: diffType === 'smart' && fg('platform_editor_ai_smart_diff') && (() => {
302
+ const level = smartChangeLevel(change);
303
+ if (level === 'node' || level === 'paragraph') {
304
+ return deletedDiffPlacement === 'bottom';
305
+ }
306
+ // Inline-level (undefined) and sentence-level changes.
307
+ return inlineDeletedDiffPlacement === 'after';
308
+ })()
299
309
  }),
300
310
  showIndicators
301
311
  }));
@@ -460,7 +470,8 @@ export const calculateDiffDecorations = memoizeOne(calculateDiffDecorationsInner
460
470
  hideAddedDiffsUnderline,
461
471
  showIndicators,
462
472
  smartThresholds,
463
- deletedDiffPlacement
473
+ deletedDiffPlacement,
474
+ inlineDeletedDiffPlacement
464
475
  }], [{
465
476
  pluginState: lastPluginState,
466
477
  state: lastState,
@@ -473,13 +484,14 @@ export const calculateDiffDecorations = memoizeOne(calculateDiffDecorationsInner
473
484
  hideAddedDiffsUnderline: lastHideAddedDiffsUnderline,
474
485
  showIndicators: lastShowIndicators,
475
486
  smartThresholds: lastSmartThresholds,
476
- deletedDiffPlacement: lastDeletedDiffPlacement
487
+ deletedDiffPlacement: lastDeletedDiffPlacement,
488
+ inlineDeletedDiffPlacement: lastInlineDeletedDiffPlacement
477
489
  }]) => {
478
490
  var _ref2;
479
491
  const originalDocIsSame = lastPluginState.originalDoc && pluginState.originalDoc && pluginState.originalDoc.eq(lastPluginState.originalDoc);
480
492
  if (isExtendedEnabled(diffType)) {
481
493
  var _ref;
482
- 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 && hideAddedDiffsUnderline === lastHideAddedDiffsUnderline && showIndicators === lastShowIndicators && isEqual(smartThresholds, lastSmartThresholds) && deletedDiffPlacement === lastDeletedDiffPlacement) !== null && _ref !== void 0 ? _ref : false;
494
+ 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 && hideAddedDiffsUnderline === lastHideAddedDiffsUnderline && showIndicators === lastShowIndicators && isEqual(smartThresholds, lastSmartThresholds) && deletedDiffPlacement === lastDeletedDiffPlacement && inlineDeletedDiffPlacement === lastInlineDeletedDiffPlacement) !== null && _ref !== void 0 ? _ref : false;
483
495
  }
484
496
  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;
485
497
  });
@@ -43,7 +43,7 @@ export const createPlugin = (config, getIntl, api) => {
43
43
  let newPluginState = currentPluginState;
44
44
  if (meta) {
45
45
  if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'SHOW_DIFF') {
46
- var _newPluginState, _newPluginState2, _newPluginState3, _newPluginState4, _newPluginState5, _newPluginState6, _newPluginState7, _newPluginState8, _newPluginState9;
46
+ var _newPluginState, _newPluginState2, _newPluginState3, _newPluginState4, _newPluginState5, _newPluginState6, _newPluginState7, _newPluginState8, _newPluginState9, _newPluginState0;
47
47
  // Update the plugin state with the new metadata
48
48
  newPluginState = {
49
49
  ...currentPluginState,
@@ -70,12 +70,13 @@ export const createPlugin = (config, getIntl, api) => {
70
70
  hideAddedDiffsUnderline: (_newPluginState5 = newPluginState) === null || _newPluginState5 === void 0 ? void 0 : _newPluginState5.hideAddedDiffsUnderline,
71
71
  showIndicators: (_newPluginState6 = newPluginState) === null || _newPluginState6 === void 0 ? void 0 : _newPluginState6.showIndicators,
72
72
  smartThresholds: (_newPluginState7 = newPluginState) === null || _newPluginState7 === void 0 ? void 0 : _newPluginState7.smartThresholds,
73
- deletedDiffPlacement: (_newPluginState8 = newPluginState) === null || _newPluginState8 === void 0 ? void 0 : _newPluginState8.deletedDiffPlacement
73
+ deletedDiffPlacement: (_newPluginState8 = newPluginState) === null || _newPluginState8 === void 0 ? void 0 : _newPluginState8.deletedDiffPlacement,
74
+ inlineDeletedDiffPlacement: (_newPluginState9 = newPluginState) === null || _newPluginState9 === void 0 ? void 0 : _newPluginState9.inlineDeletedDiffPlacement
74
75
  } : {})
75
76
  });
76
77
  // Update the decorations and their ids
77
78
  newPluginState.decorations = decorations;
78
- if (isExtendedEnabled((_newPluginState9 = newPluginState) === null || _newPluginState9 === void 0 ? void 0 : _newPluginState9.diffType)) {
79
+ if (isExtendedEnabled((_newPluginState0 = newPluginState) === null || _newPluginState0 === void 0 ? void 0 : _newPluginState0.diffType)) {
79
80
  newPluginState.diffDescriptors = diffDescriptors;
80
81
  }
81
82
  } else if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'HIDE_DIFF') {
@@ -98,9 +99,9 @@ export const createPlugin = (config, getIntl, api) => {
98
99
  } : {})
99
100
  };
100
101
  } 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') {
101
- var _newPluginState0;
102
+ var _newPluginState1;
102
103
  // Update the active index in plugin state and recalculate decorations
103
- const decorations = getScrollableDecorations(currentPluginState.decorations, newState.doc, (_newPluginState0 = newPluginState) === null || _newPluginState0 === void 0 ? void 0 : _newPluginState0.diffType);
104
+ const decorations = getScrollableDecorations(currentPluginState.decorations, newState.doc, (_newPluginState1 = newPluginState) === null || _newPluginState1 === void 0 ? void 0 : _newPluginState1.diffType);
104
105
  if (decorations.length > 0) {
105
106
  var _currentPluginState$a;
106
107
  // Initialize to -1 if undefined so that the first "next" scroll takes us to index 0 (first change).
@@ -145,7 +146,8 @@ export const createPlugin = (config, getIntl, api) => {
145
146
  hideAddedDiffsUnderline: newPluginState.hideAddedDiffsUnderline,
146
147
  showIndicators: newPluginState.showIndicators,
147
148
  smartThresholds: newPluginState.smartThresholds,
148
- deletedDiffPlacement: newPluginState.deletedDiffPlacement
149
+ deletedDiffPlacement: newPluginState.deletedDiffPlacement,
150
+ inlineDeletedDiffPlacement: newPluginState.inlineDeletedDiffPlacement
149
151
  } : {})
150
152
  });
151
153
  newPluginState.decorations = updatedDecorations;
@@ -145,7 +145,9 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
145
145
  showIndicators = _ref3$showIndicators === void 0 ? false : _ref3$showIndicators,
146
146
  smartThresholds = _ref3.smartThresholds,
147
147
  _ref3$deletedDiffPlac = _ref3.deletedDiffPlacement,
148
- deletedDiffPlacement = _ref3$deletedDiffPlac === void 0 ? 'top' : _ref3$deletedDiffPlac;
148
+ deletedDiffPlacement = _ref3$deletedDiffPlac === void 0 ? 'top' : _ref3$deletedDiffPlac,
149
+ _ref3$inlineDeletedDi = _ref3.inlineDeletedDiffPlacement,
150
+ inlineDeletedDiffPlacement = _ref3$inlineDeletedDi === void 0 ? 'before' : _ref3$inlineDeletedDi;
149
151
  var originalDoc = pluginState.originalDoc,
150
152
  steps = pluginState.steps,
151
153
  isDisplayingChanges = pluginState.isDisplayingChanges;
@@ -320,10 +322,19 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
320
322
  isInserted: !isInserted,
321
323
  diffType: diffType,
322
324
  hideAddedDiffsUnderline: hideAddedDiffsUnderline,
323
- // For `smart` node- and paragraph-level changes, optionally render the
324
- // deleted content below the new content (gray + strikethrough) instead
325
- // of above it. Controlled by `deletedDiffPlacement` (default `'top'`).
326
- placeBelow: deletedDiffPlacement === 'bottom' && diffType === 'smart' && fg('platform_editor_ai_smart_diff') && (smartChangeLevel(change) === 'node' || smartChangeLevel(change) === 'paragraph')
325
+ // For `smart` changes, optionally render the deleted content after the new
326
+ // content (gray + strikethrough) instead of before it. Two independent
327
+ // controls, split by change level:
328
+ // - node/paragraph-level: `deletedDiffPlacement` (default `'top'`).
329
+ // - inline/sentence-level: `inlineDeletedDiffPlacement` (default `'before'`).
330
+ placeBelow: diffType === 'smart' && fg('platform_editor_ai_smart_diff') && function () {
331
+ var level = smartChangeLevel(change);
332
+ if (level === 'node' || level === 'paragraph') {
333
+ return deletedDiffPlacement === 'bottom';
334
+ }
335
+ // Inline-level (undefined) and sentence-level changes.
336
+ return inlineDeletedDiffPlacement === 'after';
337
+ }()
327
338
  }), {}, {
328
339
  showIndicators: showIndicators
329
340
  }))));
@@ -494,7 +505,8 @@ function (_ref5, _ref6) {
494
505
  hideAddedDiffsUnderline = _ref7$.hideAddedDiffsUnderline,
495
506
  showIndicators = _ref7$.showIndicators,
496
507
  smartThresholds = _ref7$.smartThresholds,
497
- deletedDiffPlacement = _ref7$.deletedDiffPlacement;
508
+ deletedDiffPlacement = _ref7$.deletedDiffPlacement,
509
+ inlineDeletedDiffPlacement = _ref7$.inlineDeletedDiffPlacement;
498
510
  var _ref8 = _slicedToArray(_ref6, 1),
499
511
  _ref8$ = _ref8[0],
500
512
  lastPluginState = _ref8$.pluginState,
@@ -508,11 +520,12 @@ function (_ref5, _ref6) {
508
520
  lastHideAddedDiffsUnderline = _ref8$.hideAddedDiffsUnderline,
509
521
  lastShowIndicators = _ref8$.showIndicators,
510
522
  lastSmartThresholds = _ref8$.smartThresholds,
511
- lastDeletedDiffPlacement = _ref8$.deletedDiffPlacement;
523
+ lastDeletedDiffPlacement = _ref8$.deletedDiffPlacement,
524
+ lastInlineDeletedDiffPlacement = _ref8$.inlineDeletedDiffPlacement;
512
525
  var originalDocIsSame = lastPluginState.originalDoc && pluginState.originalDoc && pluginState.originalDoc.eq(lastPluginState.originalDoc);
513
526
  if (isExtendedEnabled(diffType)) {
514
527
  var _ref9;
515
- return (_ref9 = 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 && hideAddedDiffsUnderline === lastHideAddedDiffsUnderline && showIndicators === lastShowIndicators && isEqual(smartThresholds, lastSmartThresholds) && deletedDiffPlacement === lastDeletedDiffPlacement) !== null && _ref9 !== void 0 ? _ref9 : false;
528
+ return (_ref9 = 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 && hideAddedDiffsUnderline === lastHideAddedDiffsUnderline && showIndicators === lastShowIndicators && isEqual(smartThresholds, lastSmartThresholds) && deletedDiffPlacement === lastDeletedDiffPlacement && inlineDeletedDiffPlacement === lastInlineDeletedDiffPlacement) !== null && _ref9 !== void 0 ? _ref9 : false;
516
529
  }
517
530
  return (_ref0 = originalDocIsSame && isEqual(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isEqual(activeIndexPos, lastActiveIndexPos) && hideDeletedDiffs === lastHideDeletedDiffs) !== null && _ref0 !== void 0 ? _ref0 : false;
518
531
  });
@@ -45,7 +45,7 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
45
45
  var newPluginState = currentPluginState;
46
46
  if (meta) {
47
47
  if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'SHOW_DIFF') {
48
- var _newPluginState, _newPluginState2, _newPluginState3, _newPluginState4, _newPluginState5, _newPluginState6, _newPluginState7, _newPluginState8, _newPluginState9;
48
+ var _newPluginState, _newPluginState2, _newPluginState3, _newPluginState4, _newPluginState5, _newPluginState6, _newPluginState7, _newPluginState8, _newPluginState9, _newPluginState0;
49
49
  // Update the plugin state with the new metadata
50
50
  newPluginState = _objectSpread(_objectSpread(_objectSpread({}, currentPluginState), meta), {}, {
51
51
  isDisplayingChanges: true,
@@ -67,13 +67,14 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
67
67
  hideAddedDiffsUnderline: (_newPluginState5 = newPluginState) === null || _newPluginState5 === void 0 ? void 0 : _newPluginState5.hideAddedDiffsUnderline,
68
68
  showIndicators: (_newPluginState6 = newPluginState) === null || _newPluginState6 === void 0 ? void 0 : _newPluginState6.showIndicators,
69
69
  smartThresholds: (_newPluginState7 = newPluginState) === null || _newPluginState7 === void 0 ? void 0 : _newPluginState7.smartThresholds,
70
- deletedDiffPlacement: (_newPluginState8 = newPluginState) === null || _newPluginState8 === void 0 ? void 0 : _newPluginState8.deletedDiffPlacement
70
+ deletedDiffPlacement: (_newPluginState8 = newPluginState) === null || _newPluginState8 === void 0 ? void 0 : _newPluginState8.deletedDiffPlacement,
71
+ inlineDeletedDiffPlacement: (_newPluginState9 = newPluginState) === null || _newPluginState9 === void 0 ? void 0 : _newPluginState9.inlineDeletedDiffPlacement
71
72
  } : {})),
72
73
  decorations = _calculateDiffDecorat.decorations,
73
74
  diffDescriptors = _calculateDiffDecorat.diffDescriptors;
74
75
  // Update the decorations and their ids
75
76
  newPluginState.decorations = decorations;
76
- if (isExtendedEnabled((_newPluginState9 = newPluginState) === null || _newPluginState9 === void 0 ? void 0 : _newPluginState9.diffType)) {
77
+ if (isExtendedEnabled((_newPluginState0 = newPluginState) === null || _newPluginState0 === void 0 ? void 0 : _newPluginState0.diffType)) {
77
78
  newPluginState.diffDescriptors = diffDescriptors;
78
79
  }
79
80
  } else if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'HIDE_DIFF') {
@@ -89,9 +90,9 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
89
90
  diffDescriptors: []
90
91
  } : {});
91
92
  } 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') {
92
- var _newPluginState0;
93
+ var _newPluginState1;
93
94
  // Update the active index in plugin state and recalculate decorations
94
- var _decorations = getScrollableDecorations(currentPluginState.decorations, newState.doc, (_newPluginState0 = newPluginState) === null || _newPluginState0 === void 0 ? void 0 : _newPluginState0.diffType);
95
+ var _decorations = getScrollableDecorations(currentPluginState.decorations, newState.doc, (_newPluginState1 = newPluginState) === null || _newPluginState1 === void 0 ? void 0 : _newPluginState1.diffType);
95
96
  if (_decorations.length > 0) {
96
97
  var _currentPluginState$a;
97
98
  // Initialize to -1 if undefined so that the first "next" scroll takes us to index 0 (first change).
@@ -132,7 +133,8 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
132
133
  hideAddedDiffsUnderline: newPluginState.hideAddedDiffsUnderline,
133
134
  showIndicators: newPluginState.showIndicators,
134
135
  smartThresholds: newPluginState.smartThresholds,
135
- deletedDiffPlacement: newPluginState.deletedDiffPlacement
136
+ deletedDiffPlacement: newPluginState.deletedDiffPlacement,
137
+ inlineDeletedDiffPlacement: newPluginState.inlineDeletedDiffPlacement
136
138
  } : {})),
137
139
  updatedDecorations = _calculateDiffDecorat2.decorations,
138
140
  updatedDiffDescriptors = _calculateDiffDecorat2.diffDescriptors;
@@ -3,7 +3,7 @@ import type { IntlShape } from 'react-intl';
3
3
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
4
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
5
5
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
6
- import type { ColorScheme, DeletedDiffPlacement, DiffDescriptor, ShowDiffPlugin, SmartDiffThresholds } from '../../showDiffPluginType';
6
+ import type { ColorScheme, DeletedDiffPlacement, DiffDescriptor, InlineDeletedDiffPlacement, ShowDiffPlugin, SmartDiffThresholds } from '../../showDiffPluginType';
7
7
  import type { ShowDiffPluginState } from '../main';
8
8
  import type { NodeViewSerializer } from '../NodeViewSerializer';
9
9
  type CalculatedDiffs = {
@@ -20,6 +20,7 @@ export declare const calculateDiffDecorations: MemoizedFn<({ state, pluginState,
20
20
  deletedDiffPlacement?: DeletedDiffPlacement;
21
21
  hideAddedDiffsUnderline?: boolean;
22
22
  hideDeletedDiffs?: boolean;
23
+ inlineDeletedDiffPlacement?: InlineDeletedDiffPlacement;
23
24
  intl: IntlShape;
24
25
  nodeViewSerializer: NodeViewSerializer;
25
26
  pluginState: Omit<ShowDiffPluginState, 'decorations'>;
@@ -5,7 +5,7 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
5
5
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
6
6
  import { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
7
7
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
8
- import type { DeletedDiffPlacement, DiffDescriptor, DiffParams, DiffType, ShowDiffPlugin, SmartDiffThresholds } from '../showDiffPluginType';
8
+ import type { DeletedDiffPlacement, DiffDescriptor, DiffParams, DiffType, InlineDeletedDiffPlacement, ShowDiffPlugin, SmartDiffThresholds } from '../showDiffPluginType';
9
9
  export declare const showDiffPluginKey: PluginKey<ShowDiffPluginState>;
10
10
  export type ShowDiffPluginState = {
11
11
  activeIndex?: number;
@@ -25,8 +25,14 @@ export type ShowDiffPluginState = {
25
25
  */
26
26
  diffDescriptors?: DiffDescriptor[];
27
27
  diffType?: DiffType;
28
- hideDeletedDiffs?: boolean;
29
28
  hideAddedDiffsUnderline?: boolean;
29
+ hideDeletedDiffs?: boolean;
30
+ /**
31
+ * For the `smart` diffType, where inline-level (and sentence-level) deleted content is rendered
32
+ * relative to the new content. Set via SHOW_DIFF meta. Defaults to `'before'`. Independent of
33
+ * `deletedDiffPlacement`.
34
+ */
35
+ inlineDeletedDiffPlacement?: InlineDeletedDiffPlacement;
30
36
  isDisplayingChanges: boolean;
31
37
  isInverted?: boolean;
32
38
  originalDoc: PMNode | undefined;
@@ -16,6 +16,14 @@ export type DiffType = 'inline' | 'block' | 'step' | 'smart';
16
16
  * - `'bottom'`: the deleted content is anchored below the new content.
17
17
  */
18
18
  export type DeletedDiffPlacement = 'top' | 'bottom';
19
+ /**
20
+ * Where inline-level (and sentence-level) deleted content is rendered relative to the new
21
+ * (replacement) content in the `smart` diffType. This is independent of the node/paragraph-level
22
+ * `deletedDiffPlacement` option:
23
+ * - `'before'` (default): the deleted content is anchored before the new content.
24
+ * - `'after'`: the deleted content is anchored after the new content.
25
+ */
26
+ export type InlineDeletedDiffPlacement = 'before' | 'after';
19
27
  export type SmartDiffThresholds = SmartDiffThresholdsInternal;
20
28
  export type DiffDescriptor = {
21
29
  id: string;
@@ -49,6 +57,13 @@ export type PMDiffParams = {
49
57
  */
50
58
  hideAddedDiffsUnderline?: boolean;
51
59
  hideDeletedDiffs?: boolean;
60
+ /**
61
+ * For the `smart` diffType, where inline-level (and sentence-level) deleted content is rendered
62
+ * relative to the new content. Defaults to `'before'`. Independent of `deletedDiffPlacement`
63
+ * (which controls node/paragraph-level placement). Ignored for other diff types, and a no-op
64
+ * unless the relevant gate is enabled.
65
+ */
66
+ inlineDeletedDiffPlacement?: InlineDeletedDiffPlacement;
52
67
  isInverted?: boolean;
53
68
  originalDoc: Node;
54
69
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-show-diff",
3
- "version": "10.5.3",
3
+ "version": "10.6.0",
4
4
  "description": "ShowDiff plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -28,7 +28,7 @@
28
28
  "@atlaskit/editor-prosemirror": "^8.0.0",
29
29
  "@atlaskit/editor-tables": "^3.0.0",
30
30
  "@atlaskit/platform-feature-flags": "^2.1.0",
31
- "@atlaskit/tmp-editor-statsig": "^132.1.0",
31
+ "@atlaskit/tmp-editor-statsig": "^132.2.0",
32
32
  "@atlaskit/tokens": "^16.2.0",
33
33
  "@babel/runtime": "^7.0.0",
34
34
  "@compiled/react": "^1.0.0",