@atlaskit/editor-plugin-show-diff 15.0.1 → 15.1.2

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 (62) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +131 -79
  3. package/dist/cjs/pm-plugins/decorations/colorSchemes/factory.js +32 -0
  4. package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +87 -25
  5. package/dist/cjs/pm-plugins/decorations/createContributorTagWidget.js +27 -4
  6. package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +17 -3
  7. package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +5 -3
  8. package/dist/cjs/pm-plugins/decorations/extractContributorTags.js +43 -14
  9. package/dist/cjs/pm-plugins/decorations/revealStyles.js +156 -0
  10. package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +25 -5
  11. package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +4 -2
  12. package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.legacy.js +2 -1
  13. package/dist/cjs/pm-plugins/main.js +28 -10
  14. package/dist/cjs/pm-plugins/resolveDiffContributors.js +16 -9
  15. package/dist/cjs/pm-plugins/revealAnimation.js +524 -0
  16. package/dist/cjs/showDiffPlugin.js +42 -7
  17. package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +59 -9
  18. package/dist/es2019/pm-plugins/decorations/colorSchemes/factory.js +30 -0
  19. package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +62 -4
  20. package/dist/es2019/pm-plugins/decorations/createContributorTagWidget.js +25 -3
  21. package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +18 -1
  22. package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +5 -3
  23. package/dist/es2019/pm-plugins/decorations/extractContributorTags.js +36 -9
  24. package/dist/es2019/pm-plugins/decorations/revealStyles.js +139 -0
  25. package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +25 -6
  26. package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +6 -3
  27. package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.legacy.js +5 -2
  28. package/dist/es2019/pm-plugins/main.js +28 -9
  29. package/dist/es2019/pm-plugins/resolveDiffContributors.js +16 -8
  30. package/dist/es2019/pm-plugins/revealAnimation.js +495 -0
  31. package/dist/es2019/showDiffPlugin.js +37 -7
  32. package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +131 -79
  33. package/dist/esm/pm-plugins/decorations/colorSchemes/factory.js +30 -0
  34. package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +87 -25
  35. package/dist/esm/pm-plugins/decorations/createContributorTagWidget.js +27 -4
  36. package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +17 -3
  37. package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +5 -3
  38. package/dist/esm/pm-plugins/decorations/extractContributorTags.js +43 -14
  39. package/dist/esm/pm-plugins/decorations/revealStyles.js +149 -0
  40. package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +25 -5
  41. package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +4 -2
  42. package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.legacy.js +2 -1
  43. package/dist/esm/pm-plugins/main.js +28 -10
  44. package/dist/esm/pm-plugins/resolveDiffContributors.js +16 -9
  45. package/dist/esm/pm-plugins/revealAnimation.js +518 -0
  46. package/dist/esm/showDiffPlugin.js +42 -7
  47. package/dist/types/entry-points/show-diff-plugin-type.d.ts +1 -1
  48. package/dist/types/pm-plugins/calculateDiff/calculateDiffDecorations.d.ts +2 -1
  49. package/dist/types/pm-plugins/decorations/colorSchemes/factory.d.ts +24 -0
  50. package/dist/types/pm-plugins/decorations/createBlockChangedDecoration.d.ts +5 -1
  51. package/dist/types/pm-plugins/decorations/createContributorTagWidget.d.ts +9 -3
  52. package/dist/types/pm-plugins/decorations/createInlineChangedDecoration.d.ts +3 -2
  53. package/dist/types/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +3 -2
  54. package/dist/types/pm-plugins/decorations/revealStyles.d.ts +49 -0
  55. package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +4 -3
  56. package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.d.ts +1 -1
  57. package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.legacy.d.ts +1 -1
  58. package/dist/types/pm-plugins/main.d.ts +6 -1
  59. package/dist/types/pm-plugins/resolveDiffContributors.d.ts +3 -2
  60. package/dist/types/pm-plugins/revealAnimation.d.ts +33 -0
  61. package/dist/types/showDiffPluginType.d.ts +29 -1
  62. package/package.json +9 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,46 @@
1
1
  # @atlaskit/editor-plugin-show-diff
2
2
 
3
+ ## 15.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`acf9db40862d2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/acf9db40862d2) -
8
+ Contributor tags no longer disappear for every actor when a single one cannot be named.
9
+ `resolveDiffContributors` now skips only the unresolvable actor — its changes keep their diff
10
+ colour and go untagged — instead of discarding the whole contributor list, and a user-invoked
11
+ agent is still credited (without the connection) when its invoking user has no profile. Behind the
12
+ `confluence_ncs_step_diffing_version_history` feature gate and the
13
+ `platform_editor_show_diff_color_scheme_refactor` experiment.
14
+
15
+ ## 15.1.1
16
+
17
+ ### Patch Changes
18
+
19
+ - [`857fbb1c07b89`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/857fbb1c07b89) -
20
+ [ux] Show a contributor tag at the top left of changed block nodes (panel, quote, expand, media,
21
+ rule, block card, embed card, code block, extension, bodied extension, multi bodied extension),
22
+ behind `confluence_ncs_step_diffing_version_history`. One tag per block: a highlight inside a
23
+ changed block folds into the block's tag, and a change confined to a code block is tagged outside
24
+ the block so it is not clipped. Tables are excluded.
25
+ - [`236af9e62ab32`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/236af9e62ab32) -
26
+ [ux] Suppress contributor tags when contributorProfiles is omitted, preserving attribution colours
27
+ behind confluence_ncs_step_diffing_version_history and
28
+ platform_editor_show_diff_color_scheme_refactor.
29
+ - Updated dependencies
30
+
31
+ ## 15.1.0
32
+
33
+ ### Minor Changes
34
+
35
+ - [`d678fef8a856c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d678fef8a856c) -
36
+ Hide pure deletions in the clean diff view behind platform_editor_diff_hide_pure_deletions
37
+ - [`d678fef8a856c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d678fef8a856c) -
38
+ Animate the transition into the diff view behind platform_editor_diff_reveal_animation
39
+
40
+ ### Patch Changes
41
+
42
+ - Updated dependencies
43
+
3
44
  ## 15.0.1
4
45
 
5
46
  ### Patch Changes
@@ -177,7 +177,8 @@ var isInsideTable = function isInsideTable(tables, pos) {
177
177
  });
178
178
  };
179
179
  var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration(_ref5) {
180
- var doc = _ref5.doc,
180
+ var attributionKey = _ref5.attributionKey,
181
+ doc = _ref5.doc,
181
182
  from = _ref5.from,
182
183
  to = _ref5.to,
183
184
  colorScheme = _ref5.colorScheme,
@@ -186,11 +187,14 @@ var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration
186
187
  activeIndexPos = _ref5.activeIndexPos,
187
188
  _ref5$shouldHideDelet = _ref5.shouldHideDeleted,
188
189
  shouldHideDeleted = _ref5$shouldHideDelet === void 0 ? false : _ref5$shouldHideDelet,
190
+ _ref5$showContributor = _ref5.showContributorTags,
191
+ showContributorTags = _ref5$showContributor === void 0 ? false : _ref5$showContributor,
189
192
  _ref5$showIndicators = _ref5.showIndicators,
190
193
  showIndicators = _ref5$showIndicators === void 0 ? false : _ref5$showIndicators,
191
194
  diffType = _ref5.diffType,
192
195
  _ref5$coarseTableCell = _ref5.coarseTableCellsOnly,
193
- coarseTableCellsOnly = _ref5$coarseTableCell === void 0 ? false : _ref5$coarseTableCell;
196
+ coarseTableCellsOnly = _ref5$coarseTableCell === void 0 ? false : _ref5$coarseTableCell,
197
+ tagMountContext = _ref5.tagMountContext;
194
198
  var decorations = [];
195
199
  // Coarse path: inside the large table, only cell/header overlays are kept — the
196
200
  // table/row/paragraph decorations there are redundant and cause expensive per-cell
@@ -208,6 +212,7 @@ var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration
208
212
  var nodeEnd = pos + node.nodeSize;
209
213
  var isActive = isRangeActive(activeIndexPos, pos, nodeEnd);
210
214
  decorations.push.apply(decorations, (0, _toConsumableArray2.default)((0, _createBlockChangedDecoration.createBlockChangedDecoration)({
215
+ attributionKey: attributionKey,
211
216
  change: {
212
217
  from: pos,
213
218
  to: nodeEnd,
@@ -217,9 +222,11 @@ var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration
217
222
  isInserted: isInserted,
218
223
  isActive: isActive,
219
224
  shouldHideDeleted: shouldHideDeleted,
225
+ showContributorTags: showContributorTags,
220
226
  showIndicators: showIndicators,
221
227
  doc: doc,
222
- diffType: diffType
228
+ diffType: diffType,
229
+ tagMountContext: tagMountContext
223
230
  })));
224
231
  }
225
232
  });
@@ -248,30 +255,51 @@ var isDeletedContentPlacedBelow = exports.isDeletedContentPlacedBelow = function
248
255
  // Inline-level (undefined) and sentence-level changes.
249
256
  return inlineDeletedDiffPlacement === 'after';
250
257
  };
251
- var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7) {
252
- var state = _ref7.state,
253
- pluginState = _ref7.pluginState,
254
- nodeViewSerializer = _ref7.nodeViewSerializer,
255
- colorScheme = _ref7.colorScheme,
256
- intl = _ref7.intl,
257
- activeIndexPos = _ref7.activeIndexPos,
258
- api = _ref7.api,
259
- _ref7$isInverted = _ref7.isInverted,
260
- isInverted = _ref7$isInverted === void 0 ? false : _ref7$isInverted,
261
- _ref7$diffType = _ref7.diffType,
262
- diffType = _ref7$diffType === void 0 ? (0, _isExtendedEnabled.getDefaultDiffType)() : _ref7$diffType,
263
- _ref7$hideDeletedDiff = _ref7.hideDeletedDiffs,
264
- hideDeletedDiffs = _ref7$hideDeletedDiff === void 0 ? false : _ref7$hideDeletedDiff,
265
- _ref7$hideAddedDiffsU = _ref7.hideAddedDiffsUnderline,
266
- hideAddedDiffsUnderlineParam = _ref7$hideAddedDiffsU === void 0 ? false : _ref7$hideAddedDiffsU,
267
- _ref7$showIndicators = _ref7.showIndicators,
268
- showIndicators = _ref7$showIndicators === void 0 ? false : _ref7$showIndicators,
269
- smartThresholds = _ref7.smartThresholds,
270
- _ref7$deletedDiffPlac = _ref7.deletedDiffPlacement,
271
- deletedDiffPlacement = _ref7$deletedDiffPlac === void 0 ? 'top' : _ref7$deletedDiffPlac,
272
- _ref7$inlineDeletedDi = _ref7.inlineDeletedDiffPlacement,
273
- inlineDeletedDiffPlacement = _ref7$inlineDeletedDi === void 0 ? 'before' : _ref7$inlineDeletedDi,
274
- tagMountContext = _ref7.tagMountContext;
258
+
259
+ /**
260
+ * Single place `platform_editor_diff_hide_pure_deletions` is read, shared by the widget-anchor
261
+ * calculation and the decoration push below so the two cannot drift.
262
+ *
263
+ * The clean view ("new state") historically only suppressed a deleted side when the same change
264
+ * also carried an insertion. A PURE deletion — text removed with nothing put in its place — fell
265
+ * through and leaked struck-through text into a view that is supposed to show none. `smart` never
266
+ * showed this because it pairs a rewrite into a single change that always carries an insertion;
267
+ * `inline` emits delete-only changes, so it did.
268
+ *
269
+ * With the gate off this returns exactly what both callers computed before it existed.
270
+ */
271
+ var shouldHideDeletedSide = function shouldHideDeletedSide(_ref7) {
272
+ var change = _ref7.change,
273
+ diffType = _ref7.diffType,
274
+ hideDeletedDiffs = _ref7.hideDeletedDiffs,
275
+ isInverted = _ref7.isInverted;
276
+ return (0, _isExtendedEnabled.isExtendedEnabled)(diffType) && !isInverted && !!hideDeletedDiffs && (change.inserted.length > 0 || (0, _fg.fg)('platform_editor_diff_hide_pure_deletions'));
277
+ };
278
+ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref8) {
279
+ var state = _ref8.state,
280
+ pluginState = _ref8.pluginState,
281
+ nodeViewSerializer = _ref8.nodeViewSerializer,
282
+ colorScheme = _ref8.colorScheme,
283
+ intl = _ref8.intl,
284
+ activeIndexPos = _ref8.activeIndexPos,
285
+ api = _ref8.api,
286
+ _ref8$isInverted = _ref8.isInverted,
287
+ isInverted = _ref8$isInverted === void 0 ? false : _ref8$isInverted,
288
+ _ref8$diffType = _ref8.diffType,
289
+ diffType = _ref8$diffType === void 0 ? (0, _isExtendedEnabled.getDefaultDiffType)() : _ref8$diffType,
290
+ _ref8$hideDeletedDiff = _ref8.hideDeletedDiffs,
291
+ hideDeletedDiffs = _ref8$hideDeletedDiff === void 0 ? false : _ref8$hideDeletedDiff,
292
+ _ref8$hideAddedDiffsU = _ref8.hideAddedDiffsUnderline,
293
+ hideAddedDiffsUnderlineParam = _ref8$hideAddedDiffsU === void 0 ? false : _ref8$hideAddedDiffsU,
294
+ _ref8$showIndicators = _ref8.showIndicators,
295
+ showIndicators = _ref8$showIndicators === void 0 ? false : _ref8$showIndicators,
296
+ smartThresholds = _ref8.smartThresholds,
297
+ _ref8$deletedDiffPlac = _ref8.deletedDiffPlacement,
298
+ deletedDiffPlacement = _ref8$deletedDiffPlac === void 0 ? 'top' : _ref8$deletedDiffPlac,
299
+ _ref8$inlineDeletedDi = _ref8.inlineDeletedDiffPlacement,
300
+ inlineDeletedDiffPlacement = _ref8$inlineDeletedDi === void 0 ? 'before' : _ref8$inlineDeletedDi,
301
+ reveal = _ref8.reveal,
302
+ tagMountContext = _ref8.tagMountContext;
275
303
  var originalDoc = pluginState.originalDoc,
276
304
  steps = pluginState.steps,
277
305
  stepAttributions = pluginState.stepAttributions,
@@ -298,12 +326,12 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
298
326
  var simplifiedStepAttributions = [];
299
327
  if (attributedChangesetEnabled) {
300
328
  var simplifiedStepsWithAttribution = (0, _simplifySteps.simplifyStepsWithAttribution)(steps, stepAttributions !== null && stepAttributions !== void 0 ? stepAttributions : [], originalDoc);
301
- simplifiedSteps = simplifiedStepsWithAttribution.map(function (_ref8) {
302
- var step = _ref8.step;
329
+ simplifiedSteps = simplifiedStepsWithAttribution.map(function (_ref9) {
330
+ var step = _ref9.step;
303
331
  return step;
304
332
  });
305
- simplifiedStepAttributions = simplifiedStepsWithAttribution.map(function (_ref9) {
306
- var stepAttribution = _ref9.stepAttribution;
333
+ simplifiedStepAttributions = simplifiedStepsWithAttribution.map(function (_ref0) {
334
+ var stepAttribution = _ref0.stepAttribution;
307
335
  return stepAttribution;
308
336
  });
309
337
  } else {
@@ -337,11 +365,11 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
337
365
  } finally {
338
366
  _iterator.f();
339
367
  }
340
- var attrStepContexts = (0, _fg.fg)('platform_editor_reduce_diff_attr_sensitivity') ? pendingAttrSteps.flatMap(function (_ref0) {
341
- var afterNode = _ref0.afterNode,
342
- beforeNode = _ref0.beforeNode,
343
- mapIndex = _ref0.mapIndex,
344
- step = _ref0.step;
368
+ var attrStepContexts = (0, _fg.fg)('platform_editor_reduce_diff_attr_sensitivity') ? pendingAttrSteps.flatMap(function (_ref1) {
369
+ var afterNode = _ref1.afterNode,
370
+ beforeNode = _ref1.beforeNode,
371
+ mapIndex = _ref1.mapIndex,
372
+ step = _ref1.step;
345
373
  var finalPosition = new _transform.Mapping(stepMaps.slice(mapIndex + 1)).mapResult(step.pos);
346
374
  if (finalPosition.deleted) {
347
375
  return [];
@@ -356,8 +384,8 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
356
384
  }), {}, {
357
385
  step: step
358
386
  })];
359
- }) : pendingAttrSteps.map(function (_ref1) {
360
- var step = _ref1.step;
387
+ }) : pendingAttrSteps.map(function (_ref10) {
388
+ var step = _ref10.step;
361
389
  return {
362
390
  afterNode: tr.doc.nodeAt(step.pos),
363
391
  beforeNode: originalDoc.nodeAt(step.pos),
@@ -494,7 +522,12 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
494
522
  // change. Used to decide if indicator anchor positions should be adjusted
495
523
  // inward — when the widget is present the anchor must stay at the block
496
524
  // boundary to keep the indicator bar continuous with the deleted content.
497
- var willRenderDeletedWidget = change.deleted.length > 0 && !isMarkOnly && !((0, _isExtendedEnabled.isExtendedEnabled)(diffType) && !isInverted && hideDeletedDiffs && change.inserted.length > 0);
525
+ var willRenderDeletedWidget = change.deleted.length > 0 && !isMarkOnly && !shouldHideDeletedSide({
526
+ change: change,
527
+ diffType: diffType,
528
+ hideDeletedDiffs: hideDeletedDiffs,
529
+ isInverted: isInverted
530
+ });
498
531
  if (isSmartNodeLevel) {
499
532
  // For a large inserted table, skip the O(cells) inline decorations inside the
500
533
  // table (the cell overlays added below provide the highlight without the
@@ -528,6 +561,7 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
528
561
  hideAddedDiffsUnderline: hideAddedDiffsUnderline,
529
562
  hasDeletedWidget: willRenderDeletedWidget,
530
563
  isDeletedWidgetBelow: isDeletedWidgetBelow,
564
+ reveal: reveal,
531
565
  tagMountContext: tagMountContext
532
566
  }))));
533
567
  }
@@ -552,10 +586,12 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
552
586
  hideAddedDiffsUnderline: hideAddedDiffsUnderline,
553
587
  hasDeletedWidget: willRenderDeletedWidget,
554
588
  isDeletedWidgetBelow: isDeletedWidgetBelow,
589
+ reveal: reveal,
555
590
  tagMountContext: tagMountContext
556
591
  }))));
557
592
  }
558
593
  decorations.push.apply(decorations, (0, _toConsumableArray2.default)(calculateNodesForBlockDecoration(_objectSpread(_objectSpread({
594
+ attributionKey: attributionKey,
559
595
  doc: tr.doc,
560
596
  from: change.fromB,
561
597
  to: change.toB,
@@ -563,7 +599,9 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
563
599
  }, (0, _isExtendedEnabled.isExtendedEnabled)(diffType) && {
564
600
  isInserted: isInserted,
565
601
  shouldHideDeleted: shouldHideDeleted,
566
- showIndicators: showIndicators
602
+ showContributorTags: showContributorTags,
603
+ showIndicators: showIndicators,
604
+ tagMountContext: tagMountContext
567
605
  }), {}, {
568
606
  activeIndexPos: activeIndexPos,
569
607
  intl: intl,
@@ -572,11 +610,19 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
572
610
  }))));
573
611
  }
574
612
  if (change.deleted.length > 0 && !isMarkOnly) {
575
- var _shouldHideDeleted = (0, _isExtendedEnabled.isExtendedEnabled)(diffType) ? !isInverted && hideDeletedDiffs && change.inserted.length > 0 : false;
613
+ var _shouldHideDeleted = shouldHideDeletedSide({
614
+ change: change,
615
+ diffType: diffType,
616
+ hideDeletedDiffs: hideDeletedDiffs,
617
+ isInverted: isInverted
618
+ });
576
619
  if (!_shouldHideDeleted) {
577
620
  decorations.push.apply(decorations, (0, _toConsumableArray2.default)((0, _createNodeChangedDecorationWidget.createNodeChangedDecorationWidget)(_objectSpread(_objectSpread({
578
621
  // The deleted side has no inline decoration, so the widget carries the actor.
579
622
  attributionKey: attributionKey,
623
+ // Extended pipeline only, matching the inline path: the non-extended styles have no
624
+ // background for the wipe to act on.
625
+ reveal: (0, _isExtendedEnabled.isExtendedEnabled)(diffType) ? reveal : undefined,
580
626
  change: change,
581
627
  doc: originalDoc,
582
628
  nodeViewSerializer: nodeViewSerializer,
@@ -604,9 +650,9 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
604
650
  // smart path. Only add the legacy step-range decoration when no equivalent changeset range was
605
651
  // produced; otherwise the same content receives two inline decorations (and two navigation
606
652
  // changes), usually one attribution colour and one default purple decoration.
607
- (0, _getMarkChangeRanges.getMarkChangeRanges)(steps).filter(function (_ref10) {
608
- var fromB = _ref10.fromB,
609
- toB = _ref10.toB;
653
+ (0, _getMarkChangeRanges.getMarkChangeRanges)(steps).filter(function (_ref11) {
654
+ var fromB = _ref11.fromB,
655
+ toB = _ref11.toB;
610
656
  return !(0, _fg.fg)('confluence_ncs_step_diffing_version_history') || !changes.some(function (change) {
611
657
  return change.fromB === fromB && change.toB === toB;
612
658
  });
@@ -617,7 +663,8 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
617
663
  colorScheme: colorScheme,
618
664
  diffType: diffType,
619
665
  isActive: isActive,
620
- isInserted: true
666
+ isInserted: true,
667
+ reveal: reveal
621
668
  })));
622
669
  });
623
670
  (0, _getAttrChangeRanges.getAttrChangeRanges)(tr.doc, attrStepContexts, originalDoc).forEach(function (change) {
@@ -707,44 +754,49 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
707
754
  var calculateDiffDecorations = exports.calculateDiffDecorations = (0, _memoizeOne.default)(calculateDiffDecorationsInner,
708
755
  // Cache results unless relevant inputs change. `tagMountContext` is deliberately absent: it is
709
756
  // built once per plugin instance, so it can never be the reason a diff needs recalculating.
710
- function (_ref11, _ref12) {
711
- var _ref16;
712
- var _ref13 = (0, _slicedToArray2.default)(_ref11, 1),
713
- _ref13$ = _ref13[0],
714
- pluginState = _ref13$.pluginState,
715
- state = _ref13$.state,
716
- colorScheme = _ref13$.colorScheme,
717
- intl = _ref13$.intl,
718
- activeIndexPos = _ref13$.activeIndexPos,
719
- isInverted = _ref13$.isInverted,
720
- diffType = _ref13$.diffType,
721
- hideDeletedDiffs = _ref13$.hideDeletedDiffs,
722
- hideAddedDiffsUnderline = _ref13$.hideAddedDiffsUnderline,
723
- showIndicators = _ref13$.showIndicators,
724
- smartThresholds = _ref13$.smartThresholds,
725
- deletedDiffPlacement = _ref13$.deletedDiffPlacement,
726
- inlineDeletedDiffPlacement = _ref13$.inlineDeletedDiffPlacement;
757
+ function (_ref12, _ref13) {
758
+ var _ref17;
727
759
  var _ref14 = (0, _slicedToArray2.default)(_ref12, 1),
728
760
  _ref14$ = _ref14[0],
729
- lastPluginState = _ref14$.pluginState,
730
- lastState = _ref14$.state,
731
- lastColorScheme = _ref14$.colorScheme,
732
- lastIntl = _ref14$.intl,
733
- lastActiveIndexPos = _ref14$.activeIndexPos,
734
- lastIsInverted = _ref14$.isInverted,
735
- lastDiffType = _ref14$.diffType,
736
- lastHideDeletedDiffs = _ref14$.hideDeletedDiffs,
737
- lastHideAddedDiffsUnderline = _ref14$.hideAddedDiffsUnderline,
738
- lastShowIndicators = _ref14$.showIndicators,
739
- lastSmartThresholds = _ref14$.smartThresholds,
740
- lastDeletedDiffPlacement = _ref14$.deletedDiffPlacement,
741
- lastInlineDeletedDiffPlacement = _ref14$.inlineDeletedDiffPlacement;
761
+ pluginState = _ref14$.pluginState,
762
+ state = _ref14$.state,
763
+ colorScheme = _ref14$.colorScheme,
764
+ intl = _ref14$.intl,
765
+ activeIndexPos = _ref14$.activeIndexPos,
766
+ isInverted = _ref14$.isInverted,
767
+ diffType = _ref14$.diffType,
768
+ hideDeletedDiffs = _ref14$.hideDeletedDiffs,
769
+ hideAddedDiffsUnderline = _ref14$.hideAddedDiffsUnderline,
770
+ showIndicators = _ref14$.showIndicators,
771
+ smartThresholds = _ref14$.smartThresholds,
772
+ deletedDiffPlacement = _ref14$.deletedDiffPlacement,
773
+ inlineDeletedDiffPlacement = _ref14$.inlineDeletedDiffPlacement,
774
+ reveal = _ref14$.reveal;
775
+ var _ref15 = (0, _slicedToArray2.default)(_ref13, 1),
776
+ _ref15$ = _ref15[0],
777
+ lastPluginState = _ref15$.pluginState,
778
+ lastState = _ref15$.state,
779
+ lastColorScheme = _ref15$.colorScheme,
780
+ lastIntl = _ref15$.intl,
781
+ lastActiveIndexPos = _ref15$.activeIndexPos,
782
+ lastIsInverted = _ref15$.isInverted,
783
+ lastDiffType = _ref15$.diffType,
784
+ lastHideDeletedDiffs = _ref15$.hideDeletedDiffs,
785
+ lastHideAddedDiffsUnderline = _ref15$.hideAddedDiffsUnderline,
786
+ lastShowIndicators = _ref15$.showIndicators,
787
+ lastSmartThresholds = _ref15$.smartThresholds,
788
+ lastDeletedDiffPlacement = _ref15$.deletedDiffPlacement,
789
+ lastInlineDeletedDiffPlacement = _ref15$.inlineDeletedDiffPlacement,
790
+ lastReveal = _ref15$.reveal;
742
791
  var originalDocIsSame = lastPluginState.originalDoc && pluginState.originalDoc && pluginState.originalDoc.eq(lastPluginState.originalDoc);
743
792
  if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
744
- var _ref15;
745
- return (_ref15 = colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isInverted === lastIsInverted && diffType === lastDiffType && (0, _isEqual.default)(activeIndexPos, lastActiveIndexPos) && originalDocIsSame && (0, _isEqual.default)(pluginState.steps, lastPluginState.steps) && (0, _isEqual.default)(pluginState.stepAttributions, lastPluginState.stepAttributions) &&
793
+ var _ref16;
794
+ return (_ref16 = colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isInverted === lastIsInverted && diffType === lastDiffType && (0, _isEqual.default)(activeIndexPos, lastActiveIndexPos) && originalDocIsSame && (0, _isEqual.default)(pluginState.steps, lastPluginState.steps) && (0, _isEqual.default)(pluginState.stepAttributions, lastPluginState.stepAttributions) &&
746
795
  // Contributors can arrive after the first calculation; without this, tags never appear.
747
- (0, _isEqual.default)(pluginState.contributors, lastPluginState.contributors) && state.doc.eq(lastState.doc) && hideDeletedDiffs === lastHideDeletedDiffs && hideAddedDiffsUnderline === lastHideAddedDiffsUnderline && showIndicators === lastShowIndicators && (0, _isEqual.default)(smartThresholds, lastSmartThresholds) && deletedDiffPlacement === lastDeletedDiffPlacement && inlineDeletedDiffPlacement === lastInlineDeletedDiffPlacement) !== null && _ref15 !== void 0 ? _ref15 : false;
796
+ (0, _isEqual.default)(pluginState.contributors, lastPluginState.contributors) && state.doc.eq(lastState.doc) && hideDeletedDiffs === lastHideDeletedDiffs && hideAddedDiffsUnderline === lastHideAddedDiffsUnderline && showIndicators === lastShowIndicators && (0, _isEqual.default)(smartThresholds, lastSmartThresholds) && deletedDiffPlacement === lastDeletedDiffPlacement && inlineDeletedDiffPlacement === lastInlineDeletedDiffPlacement &&
797
+ // Turning the reveal on or off changes the emitted styles, so a cached result from the
798
+ // other setting would leave the diff painted in the wrong resting state.
799
+ (0, _isEqual.default)(reveal, lastReveal)) !== null && _ref16 !== void 0 ? _ref16 : false;
748
800
  }
749
- return (_ref16 = originalDocIsSame && (0, _isEqual.default)(pluginState.steps, lastPluginState.steps) && (0, _isEqual.default)(pluginState.stepAttributions, lastPluginState.stepAttributions) && (0, _isEqual.default)(pluginState.contributors, lastPluginState.contributors) && state.doc.eq(lastState.doc) && colorScheme === lastColorScheme && intl.locale === lastIntl.locale && (0, _isEqual.default)(activeIndexPos, lastActiveIndexPos) && hideDeletedDiffs === lastHideDeletedDiffs) !== null && _ref16 !== void 0 ? _ref16 : false;
801
+ return (_ref17 = originalDocIsSame && (0, _isEqual.default)(pluginState.steps, lastPluginState.steps) && (0, _isEqual.default)(pluginState.stepAttributions, lastPluginState.stepAttributions) && (0, _isEqual.default)(pluginState.contributors, lastPluginState.contributors) && state.doc.eq(lastState.doc) && colorScheme === lastColorScheme && intl.locale === lastIntl.locale && (0, _isEqual.default)(activeIndexPos, lastActiveIndexPos) && hideDeletedDiffs === lastHideDeletedDiffs) !== null && _ref17 !== void 0 ? _ref17 : false;
750
802
  });
@@ -66,6 +66,8 @@ exports.buildInsertStyleRuleNodeNew = buildInsertStyleRuleNodeNew;
66
66
  exports.buildInsertedBlockNodeStyle = buildInsertedBlockNodeStyle;
67
67
  exports.buildInsertedInlineStyle = buildInsertedInlineStyle;
68
68
  exports.getAccentTokens = getAccentTokens;
69
+ exports.getDeletedInlineRevealColors = getDeletedInlineRevealColors;
70
+ exports.getInsertedInlineRevealColors = getInsertedInlineRevealColors;
69
71
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
70
72
  var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
71
73
  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; }
@@ -750,6 +752,36 @@ function buildInsertedInlineStyle(colors, isActive, hideAddedDiffsUnderline) {
750
752
  return hideAddedDiffsUnderline ? buildInsertStyleExtendedNoUnderline(colors) : buildInsertStyleExtended(colors);
751
753
  }
752
754
 
755
+ /**
756
+ * The colours `buildInsertedInlineStyle()` above would paint, for the reveal to animate towards.
757
+ *
758
+ * MUST mirror that function: the reveal replaces the flat highlight with a sized gradient, so a
759
+ * divergence here means the animation settles on a different colour than a static render produces.
760
+ * `revealStyles.ts` in the test package asserts the two agree across the isActive /
761
+ * hideAddedDiffsUnderline matrix.
762
+ *
763
+ * A transparent border is how "no underline" is expressed: the box still reserves the 2px so the
764
+ * text does not shift when the underline arrives.
765
+ */
766
+ function getInsertedInlineRevealColors(colors, isActive, hideAddedDiffsUnderline) {
767
+ return {
768
+ background: isActive ? bgSubtlerPressed(colors.insertActiveColor) : bgSubtlest(colors.insertColor),
769
+ border: hideAddedDiffsUnderline ? 'transparent' : borderAccent(colors.insertColor)
770
+ };
771
+ }
772
+
773
+ /**
774
+ * The colours `buildDeletedInlineContentStyleExtended()` paints, for the reveal to animate towards.
775
+ * Deleted content's highlight does not vary with the active state — only its text does, which the
776
+ * reveal keeps as-is.
777
+ */
778
+ function getDeletedInlineRevealColors(colors) {
779
+ return {
780
+ background: bgSubtlest(colors.deleteColor),
781
+ border: borderAccent(colors.deleteColor)
782
+ };
783
+ }
784
+
753
785
  /** The three visual states deleted inline content can be in. */
754
786
 
755
787
  /**
@@ -8,12 +8,14 @@ exports.createBlockChangedDecoration = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
10
  var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
11
+ var _utils = require("@atlaskit/editor-prosemirror/utils");
11
12
  var _view = require("@atlaskit/editor-prosemirror/view");
12
13
  var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
13
14
  var _isExtendedEnabled = require("../isExtendedEnabled");
14
15
  var _factory = require("./colorSchemes/factory");
15
16
  var _schemes = require("./colorSchemes/schemes");
16
17
  var _createAnchorDecorationWidgets = require("./createAnchorDecorationWidgets");
18
+ var _createContributorTagWidget = require("./createContributorTagWidget");
17
19
  var _decorationKeys = require("./decorationKeys");
18
20
  var _createBlockChangedDecorationStyles = require("./createBlockChangedDecoration.styles.legacy");
19
21
  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; }
@@ -31,6 +33,29 @@ var UNSTYLED_NODES = ['mediaSingle', 'mediaGroup', 'table',
31
33
  'heading', 'hardBreak', 'decisionList', 'taskList', 'bulletList', 'orderedList', 'layoutSection'];
32
34
  var CELL_NODES = ['tableCell', 'tableHeader'];
33
35
 
36
+ /**
37
+ * Block nodes that host a contributor tag of their own — those whose whole box reads as one change.
38
+ * Lists and tables are excluded: they decorate per item and per cell, with no one-tag-per-block
39
+ * design yet. `blockCard` covers the datasource variant, which is the same node type.
40
+ */
41
+ var TAGGABLE_BLOCK_NODES = new Set(['blockCard', 'blockquote', 'bodiedExtension', 'codeBlock', 'embedCard', 'expand', 'extension', 'media', 'multiBodiedExtension', 'panel', 'rule']);
42
+
43
+ /** Panels, rules and media can also sit in a table cell, which is out of scope for block tags. */
44
+ var isInsideTable = function isInsideTable(doc, pos) {
45
+ return (0, _utils.findParentNodeClosestToPos)(doc.resolve(pos), function (node) {
46
+ return node.type.name === 'table';
47
+ }) !== undefined;
48
+ };
49
+
50
+ /** Whether this block can host a contributor tag of its own. */
51
+ var canTagBlock = function canTagBlock(_ref) {
52
+ var diffType = _ref.diffType,
53
+ doc = _ref.doc,
54
+ from = _ref.from,
55
+ name = _ref.name;
56
+ return doc !== undefined && (0, _isExtendedEnabled.isExtendedEnabled)(diffType) && TAGGABLE_BLOCK_NODES.has(name) && !isInsideTable(doc, from);
57
+ };
58
+
34
59
  /** Positioning context for the cell overlay widget decorations. */
35
60
  var cellPositionStyle = (0, _lazyNodeView.convertToInlineCss)({
36
61
  position: 'relative'
@@ -77,14 +102,14 @@ var getNodeClass = function getNodeClass(name) {
77
102
  return undefined;
78
103
  }
79
104
  };
80
- var getBlockNodeStyleNext = function getBlockNodeStyleNext(_ref) {
81
- var nodeName = _ref.nodeName,
82
- colorScheme = _ref.colorScheme,
83
- _ref$isInserted = _ref.isInserted,
84
- isInserted = _ref$isInserted === void 0 ? true : _ref$isInserted,
85
- _ref$isActive = _ref.isActive,
86
- isActive = _ref$isActive === void 0 ? false : _ref$isActive,
87
- diffType = _ref.diffType;
105
+ var getBlockNodeStyleNext = function getBlockNodeStyleNext(_ref2) {
106
+ var nodeName = _ref2.nodeName,
107
+ colorScheme = _ref2.colorScheme,
108
+ _ref2$isInserted = _ref2.isInserted,
109
+ isInserted = _ref2$isInserted === void 0 ? true : _ref2$isInserted,
110
+ _ref2$isActive = _ref2.isActive,
111
+ isActive = _ref2$isActive === void 0 ? false : _ref2$isActive,
112
+ diffType = _ref2.diffType;
88
113
  if (UNSTYLED_NODES.includes(nodeName)) {
89
114
  return undefined;
90
115
  }
@@ -146,21 +171,33 @@ var isCellEmpty = function isCellEmpty(cellNode) {
146
171
  * @param isActive Whether this node is part of the currently active/focused change
147
172
  * @returns Prosemirror node decoration or undefined
148
173
  */
149
- var createBlockChangedDecoration = exports.createBlockChangedDecoration = function createBlockChangedDecoration(_ref2) {
150
- var change = _ref2.change,
151
- colorScheme = _ref2.colorScheme,
152
- _ref2$isInserted = _ref2.isInserted,
153
- isInserted = _ref2$isInserted === void 0 ? true : _ref2$isInserted,
154
- _ref2$isActive = _ref2.isActive,
155
- isActive = _ref2$isActive === void 0 ? false : _ref2$isActive,
156
- _ref2$shouldHideDelet = _ref2.shouldHideDeleted,
157
- shouldHideDeleted = _ref2$shouldHideDelet === void 0 ? false : _ref2$shouldHideDelet,
158
- _ref2$showIndicators = _ref2.showIndicators,
159
- showIndicators = _ref2$showIndicators === void 0 ? false : _ref2$showIndicators,
160
- doc = _ref2.doc,
161
- diffType = _ref2.diffType;
174
+ var createBlockChangedDecoration = exports.createBlockChangedDecoration = function createBlockChangedDecoration(_ref3) {
175
+ var attributionKey = _ref3.attributionKey,
176
+ change = _ref3.change,
177
+ colorScheme = _ref3.colorScheme,
178
+ _ref3$isInserted = _ref3.isInserted,
179
+ isInserted = _ref3$isInserted === void 0 ? true : _ref3$isInserted,
180
+ _ref3$isActive = _ref3.isActive,
181
+ isActive = _ref3$isActive === void 0 ? false : _ref3$isActive,
182
+ _ref3$shouldHideDelet = _ref3.shouldHideDeleted,
183
+ shouldHideDeleted = _ref3$shouldHideDelet === void 0 ? false : _ref3$shouldHideDelet,
184
+ _ref3$showContributor = _ref3.showContributorTags,
185
+ showContributorTags = _ref3$showContributor === void 0 ? false : _ref3$showContributor,
186
+ _ref3$showIndicators = _ref3.showIndicators,
187
+ showIndicators = _ref3$showIndicators === void 0 ? false : _ref3$showIndicators,
188
+ doc = _ref3.doc,
189
+ diffType = _ref3.diffType,
190
+ tagMountContext = _ref3.tagMountContext;
162
191
  var decorations = [];
163
- var diffId = crypto.randomUUID();
192
+ // Derived from the node range so it survives a recalculation, as in
193
+ // `createInlineChangedDecoration`. Changes are disjoint, so no two of them decorate one node.
194
+ var diffId = showContributorTags ? "block-".concat(change.from, "-").concat(change.to) : crypto.randomUUID();
195
+ var shouldTagBlock = showContributorTags && canTagBlock({
196
+ diffType: diffType,
197
+ doc: doc,
198
+ from: change.from,
199
+ name: change.name
200
+ });
164
201
  if (shouldHideDeleted) {
165
202
  return [_view.Decoration.node(change.from, change.to, {
166
203
  style: displayNoneStyle
@@ -206,19 +243,27 @@ var createBlockChangedDecoration = exports.createBlockChangedDecoration = functi
206
243
  });
207
244
  var className = getNodeClass(change.name);
208
245
  if (style || className) {
209
- decorations.push(_view.Decoration.node(change.from, change.to, {
246
+ decorations.push(_view.Decoration.node(change.from, change.to, _objectSpread({
210
247
  style: style,
211
248
  'data-testid': 'show-diff-changed-decoration-node',
212
249
  class: className
213
- }, (0, _decorationKeys.buildDiffDecorationSpec)({
250
+ }, shouldTagBlock && {
251
+ 'data-diff-id': diffId
252
+ }), (0, _decorationKeys.buildDiffDecorationSpec)({
253
+ attributionKey: shouldTagBlock ? attributionKey : undefined,
254
+ colorScheme: colorScheme,
214
255
  decorationType: 'block',
215
256
  diffId: diffId,
216
257
  isActive: isActive,
258
+ isInserted: isInserted,
217
259
  nodeName: change.name,
218
260
  diffType: diffType
219
261
  })));
220
262
  }
221
- if (decorations.length > 0 && showIndicators && doc && (0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
263
+ if (decorations.length === 0) {
264
+ return decorations;
265
+ }
266
+ if (showIndicators && doc && (0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
222
267
  decorations.push.apply(decorations, (0, _toConsumableArray2.default)((0, _createAnchorDecorationWidgets.createBlockIndicatorAnchorWidgets)({
223
268
  doc: doc,
224
269
  from: change.from,
@@ -226,5 +271,22 @@ var createBlockChangedDecoration = exports.createBlockChangedDecoration = functi
226
271
  diffId: diffId
227
272
  })));
228
273
  }
274
+
275
+ // `change.from` is just before the node, so the host sits outside it and the tag renders on the
276
+ // block's own top-left corner. Resolving inline content instead would put the host inside a
277
+ // container block's content DOM (panel, expand, blockquote).
278
+ if (shouldTagBlock && doc) {
279
+ var tagWidget = (0, _createContributorTagWidget.createContributorTagWidget)({
280
+ anchorAtRangeStart: true,
281
+ doc: doc,
282
+ from: change.from,
283
+ to: change.to,
284
+ diffId: diffId,
285
+ mountContext: tagMountContext
286
+ });
287
+ if (tagWidget) {
288
+ decorations.push(tagWidget);
289
+ }
290
+ }
229
291
  return decorations;
230
292
  };