@atlaskit/editor-plugin-show-diff 17.0.1 → 17.1.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 (75) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/cjs/entry-points/show-diff-plugin-type.js +12 -1
  3. package/dist/cjs/pm-plugins/NodeViewSerializer.js +1 -1
  4. package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +128 -51
  5. package/dist/cjs/pm-plugins/calculateDiff/groupDeletedColumnChanges.js +265 -0
  6. package/dist/cjs/pm-plugins/decorations/colorSchemes/attributions.js +14 -3
  7. package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +1 -1
  8. package/dist/cjs/pm-plugins/decorations/createChangedRowDecorationWidgets.js +100 -34
  9. package/dist/cjs/pm-plugins/decorations/createContributorTagWidget.js +18 -13
  10. package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +82 -20
  11. package/dist/cjs/pm-plugins/decorations/utils/createDeletedLineBreakWidget.js +106 -0
  12. package/dist/cjs/pm-plugins/decorations/utils/tableDiffMode.js +36 -0
  13. package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +19 -8
  14. package/dist/cjs/pm-plugins/resolveDiffContributors.js +4 -3
  15. package/dist/cjs/pm-plugins/utils/emptyTextBlocks.js +66 -0
  16. package/dist/cjs/showDiffPluginType.js +87 -1
  17. package/dist/cjs/ui/ContributorTag/contributorAvatarRenderer.js +22 -14
  18. package/dist/cjs/ui/ContributorTag/contributorTagIcons.js +4 -0
  19. package/dist/es2019/entry-points/calculate-diff.js +1 -0
  20. package/dist/es2019/entry-points/show-diff-plugin-type.js +3 -0
  21. package/dist/es2019/entry-points/show-diff-plugin.js +1 -0
  22. package/dist/es2019/pm-plugins/NodeViewSerializer.js +1 -1
  23. package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +63 -3
  24. package/dist/es2019/pm-plugins/calculateDiff/groupDeletedColumnChanges.js +210 -0
  25. package/dist/es2019/pm-plugins/decorations/colorSchemes/attributions.js +12 -3
  26. package/dist/es2019/pm-plugins/decorations/colorSchemes/factory.js +0 -1
  27. package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +1 -1
  28. package/dist/es2019/pm-plugins/decorations/createChangedRowDecorationWidgets.js +79 -13
  29. package/dist/es2019/pm-plugins/decorations/createContributorTagWidget.js +8 -2
  30. package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +85 -15
  31. package/dist/es2019/pm-plugins/decorations/utils/createDeletedLineBreakWidget.js +100 -0
  32. package/dist/es2019/pm-plugins/decorations/utils/tableDiffMode.js +27 -0
  33. package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +17 -7
  34. package/dist/es2019/pm-plugins/resolveDiffContributors.js +3 -1
  35. package/dist/es2019/pm-plugins/scrollToDiff.js +1 -0
  36. package/dist/es2019/pm-plugins/utils/emptyTextBlocks.js +58 -0
  37. package/dist/es2019/showDiffPluginType.js +85 -1
  38. package/dist/es2019/ui/ContributorTag/contributorAvatarRenderer.js +22 -14
  39. package/dist/es2019/ui/ContributorTag/contributorTagIcons.js +4 -0
  40. package/dist/esm/entry-points/calculate-diff.js +1 -0
  41. package/dist/esm/entry-points/show-diff-plugin-type.js +3 -0
  42. package/dist/esm/entry-points/show-diff-plugin.js +1 -0
  43. package/dist/esm/pm-plugins/NodeViewSerializer.js +1 -1
  44. package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +129 -52
  45. package/dist/esm/pm-plugins/calculateDiff/groupDeletedColumnChanges.js +258 -0
  46. package/dist/esm/pm-plugins/decorations/colorSchemes/attributions.js +14 -3
  47. package/dist/esm/pm-plugins/decorations/colorSchemes/factory.js +0 -1
  48. package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +1 -1
  49. package/dist/esm/pm-plugins/decorations/createChangedRowDecorationWidgets.js +100 -34
  50. package/dist/esm/pm-plugins/decorations/createContributorTagWidget.js +18 -13
  51. package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +84 -22
  52. package/dist/esm/pm-plugins/decorations/utils/createDeletedLineBreakWidget.js +100 -0
  53. package/dist/esm/pm-plugins/decorations/utils/tableDiffMode.js +30 -0
  54. package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +18 -7
  55. package/dist/esm/pm-plugins/resolveDiffContributors.js +4 -3
  56. package/dist/esm/pm-plugins/scrollToDiff.js +1 -0
  57. package/dist/esm/pm-plugins/utils/emptyTextBlocks.js +60 -0
  58. package/dist/esm/showDiffPluginType.js +85 -1
  59. package/dist/esm/ui/ContributorTag/contributorAvatarRenderer.js +22 -14
  60. package/dist/esm/ui/ContributorTag/contributorTagIcons.js +4 -0
  61. package/dist/types/entry-points/show-diff-plugin-type.d.ts +2 -1
  62. package/dist/types/pm-plugins/calculateDiff/groupDeletedColumnChanges.d.ts +9 -0
  63. package/dist/types/pm-plugins/decorations/colorSchemes/attributions.d.ts +2 -2
  64. package/dist/types/pm-plugins/decorations/createChangedRowDecorationWidgets.d.ts +3 -1
  65. package/dist/types/pm-plugins/decorations/createContributorTagWidget.d.ts +5 -1
  66. package/dist/types/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +3 -2
  67. package/dist/types/pm-plugins/decorations/utils/createDeletedLineBreakWidget.d.ts +50 -0
  68. package/dist/types/pm-plugins/decorations/utils/getAttrChangeRanges.d.ts +1 -1
  69. package/dist/types/pm-plugins/decorations/utils/getMarkChangeRanges.d.ts +1 -1
  70. package/dist/types/pm-plugins/decorations/utils/tableDiffMode.d.ts +26 -0
  71. package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +4 -0
  72. package/dist/types/pm-plugins/utils/emptyTextBlocks.d.ts +16 -0
  73. package/dist/types/showDiffPluginType.d.ts +6 -1
  74. package/dist/types/ui/ContributorTag/contributorTagIcons.d.ts +1 -1
  75. package/package.json +4 -4
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.wrapBlockNodeView = exports.injectInnerWrapper = exports.createContentWrapper = void 0;
7
+ exports.wrapBlockNodeView = exports.injectInnerWrapper = exports.createRemovedLozenge = exports.createContentWrapper = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
9
  var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
10
10
  var _messages = require("@atlaskit/editor-common/messages");
@@ -13,10 +13,10 @@ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-ex
13
13
  var _fg = require("@atlaskit/platform-feature-flags/fg");
14
14
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
15
15
  var _isExtendedEnabled = require("../../isExtendedEnabled");
16
- var _revealStyles = require("../revealStyles");
17
16
  var _createInlineChangedDecoration = require("../createInlineChangedDecoration");
18
- var _tableCellEdgeAttrs = require("./tableCellEdgeAttrs");
17
+ var _revealStyles = require("../revealStyles");
19
18
  var _getAttrChangeRanges = require("./getAttrChangeRanges");
19
+ var _tableCellEdgeAttrs = require("./tableCellEdgeAttrs");
20
20
  var _wrapBlockNodeViewStyles = require("./wrapBlockNodeViewStyles");
21
21
  var shouldShowRemovedLozenge = function shouldShowRemovedLozenge(nodeName) {
22
22
  switch (nodeName) {
@@ -148,26 +148,37 @@ var applyCellOverlayStyles = function applyCellOverlayStyles(_ref4) {
148
148
  /**
149
149
  * Creates a "Removed" lozenge to be displayed at the top right corner of deleted block nodes
150
150
  */
151
- var createRemovedLozenge = function createRemovedLozenge(intl) {
151
+ var createRemovedLozenge = exports.createRemovedLozenge = function createRemovedLozenge(intl) {
152
152
  var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
153
153
  var colorScheme = arguments.length > 2 ? arguments[2] : undefined;
154
+ var inCell = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
154
155
  var container = document.createElement('span');
155
156
  var containerStyle = (0, _lazyNodeView.convertToInlineCss)({
156
157
  position: 'absolute',
157
158
  top: "var(--ds-space-075, 6px)",
158
159
  right: "var(--ds-space-075, 6px)",
159
- zIndex: 2,
160
+ // Rounded table-cell overlays use z-index 2 and are appended after the cell content.
161
+ // Keep the lozenge above them so the overlay cannot tint or obscure it.
162
+ zIndex: 3,
160
163
  pointerEvents: 'none',
161
164
  display: 'flex'
162
165
  });
163
- container.setAttribute('style', containerStyle);
164
- container.setAttribute('data-testid', 'show-diff-removed-lozenge');
165
166
 
166
167
  // Create vanilla HTML lozenge element with Atlaskit Lozenge styling (visual refresh)
167
168
  var lozengeElement = document.createElement('span');
168
- var lozengeInnerStyle = (0, _wrapBlockNodeViewStyles.resolveRemovedLozengeStyle)(colorScheme, isActive);
169
+
170
+ // A column label sits over an already-grey deleted cell, so use the red Removed treatment.
171
+ var lozengeInnerStyle = (0, _wrapBlockNodeViewStyles.resolveRemovedLozengeStyle)(colorScheme, inCell || isActive);
169
172
  lozengeElement.setAttribute('style', lozengeInnerStyle);
170
173
  lozengeElement.textContent = intl.formatMessage(_messages.trackChangesMessages.removed).toUpperCase();
174
+ if (inCell) {
175
+ lozengeElement.setAttribute('style', "".concat(lozengeInnerStyle, ";").concat(containerStyle));
176
+ lozengeElement.setAttribute('data-testid', 'show-diff-removed-lozenge');
177
+ lozengeElement.contentEditable = 'false';
178
+ return lozengeElement;
179
+ }
180
+ container.setAttribute('style', containerStyle);
181
+ container.setAttribute('data-testid', 'show-diff-removed-lozenge');
171
182
  container.appendChild(lozengeElement);
172
183
  return container;
173
184
  };
@@ -97,12 +97,13 @@ var resolveAgent = function resolveAgent(attribution, profilesByAccountId) {
97
97
  var agentId = (_attribution$agentId2 = attribution.agentId) === null || _attribution$agentId2 === void 0 ? void 0 : _attribution$agentId2.trim();
98
98
  var agentProfile = agentId ? profilesByAccountId.get(agentId) : undefined;
99
99
  if (agentProfile) {
100
- return {
101
- agentKind: 'identified',
100
+ return _objectSpread(_objectSpread({}, agentProfile.agentBrand ? {
101
+ agentKind: agentProfile.agentBrand
102
+ } : {}), {}, {
102
103
  avatarUrl: agentProfile.avatarUrl,
103
104
  kind: 'agent',
104
105
  name: agentProfile.name
105
- };
106
+ });
106
107
  }
107
108
 
108
109
  // Unknown types keep an empty name for the tag's localised "External agent" label.
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.emptyTextBlockContentPositions = exports.countEmptyTextBlockOnlySlice = void 0;
7
+ /**
8
+ * The textblock types whose empty form is a blank line the author put there deliberately, and so
9
+ * worth marking when a change removes it.
10
+ *
11
+ * Deliberately not every textblock: an empty `codeBlock` is an empty code block, which renders as a
12
+ * visible box of its own and needs no stand-in.
13
+ */
14
+ var BLANK_LINE_NODE_NAMES = new Set(['paragraph', 'heading']);
15
+
16
+ /**
17
+ * Structurally empty: no children at all, not merely no measurable content. The two coincide for a
18
+ * real node, and testing both keeps a node whose children report no size from passing as blank.
19
+ */
20
+ var isEmptyTextBlock = function isEmptyTextBlock(node) {
21
+ return BLANK_LINE_NODE_NAMES.has(node.type.name) && node.content.childCount === 0 && node.content.size === 0;
22
+ };
23
+
24
+ /**
25
+ * How many empty textblocks a slice holds, or 0 unless that is *all* it holds.
26
+ *
27
+ * Counted rather than tested for one, because a run of adjacent blank lines is reported as a single
28
+ * change covering all of them — the case that made a single-block test miss.
29
+ */
30
+ var countEmptyTextBlockOnlySlice = exports.countEmptyTextBlockOnlySlice = function countEmptyTextBlockOnlySlice(slice) {
31
+ var _slice$content$childC;
32
+ var childCount = (_slice$content$childC = slice === null || slice === void 0 ? void 0 : slice.content.childCount) !== null && _slice$content$childC !== void 0 ? _slice$content$childC : 0;
33
+ if (!slice || childCount === 0) {
34
+ return 0;
35
+ }
36
+ for (var index = 0; index < childCount; index++) {
37
+ if (!isEmptyTextBlock(slice.content.child(index))) {
38
+ return 0;
39
+ }
40
+ }
41
+ return childCount;
42
+ };
43
+
44
+ /**
45
+ * The content position of every empty textblock lying wholly within `[from, to]`.
46
+ *
47
+ * Used to place a marker on each blank line a change removes. Partially covered blocks are skipped:
48
+ * the change only took part of one, so it still has text of its own, which the inline decoration
49
+ * already marks.
50
+ */
51
+ var emptyTextBlockContentPositions = exports.emptyTextBlockContentPositions = function emptyTextBlockContentPositions(doc, from, to) {
52
+ var positions = [];
53
+ doc.nodesBetween(from, to, function (node, pos) {
54
+ if (node.isTextblock) {
55
+ if (isEmptyTextBlock(node) && pos >= from && pos + node.nodeSize <= to) {
56
+ // +1 steps over the block's own open token, into its (empty) content.
57
+ positions.push(pos + 1);
58
+ }
59
+ // A textblock holds inline content only, so there is nothing below it to visit.
60
+ return false;
61
+ }
62
+ // Keep descending: blank lines nest inside cells, columns and panels.
63
+ return true;
64
+ });
65
+ return positions;
66
+ };
@@ -2,4 +2,90 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
- });
5
+ });
6
+ exports.DIFF_AGENT_BRANDS = void 0;
7
+ /**
8
+ * `'standard'` (purple insertions, default) and `'traditional'` (green/red) are the two
9
+ * plugin-configured schemes. The remaining accent names are the attribution palette used for
10
+ * per-contributor colouring (`stepsWithAttribution`) — callers of the imperative `showDiff`
11
+ * command (see `PMDiffParams.colorScheme`) can also pass one of these directly to match a
12
+ * specific contributor's colour outside of attribution mode, for example matching a Review
13
+ * moment diff to the streaming highlight of the agent that produced it.
14
+ */
15
+
16
+ /**
17
+ * Attribution for a ProseMirror step.
18
+ *
19
+ * `userId` is the primary actor identity. `agentId` distinguishes multiple agents (or an agent
20
+ * from its user) when they share that user ID, with `agentType` used as a fallback when `agentId`
21
+ * is empty. `wasOffline` preserves additional provenance without affecting identity.
22
+ */
23
+
24
+ /** Keeps a step and its attribution coupled through mapping and filtering. */
25
+
26
+ /** Branded agent presentations supported by contributor tags. */
27
+
28
+ var DIFF_AGENT_BRANDS = exports.DIFF_AGENT_BRANDS = new Set(['rovo', 'claude', 'chatgpt']);
29
+
30
+ /** A complete identity for one of the accounts named by a step attribution. */
31
+
32
+ /** Agent presentation: branded, identified by profile, or a generic external agent. */
33
+
34
+ /**
35
+ * A contributor the plugin has resolved from a step attribution and a supplied profile. Internal:
36
+ * never re-exported from an entry point and not reachable from any public type. Same for
37
+ * `DiffContributors`.
38
+ */
39
+
40
+ /** Where two contributors share an identity, the last wins. */
41
+
42
+ /** A contributor stripped of its attributions, as a tag presents it. Internal. */
43
+
44
+ /**
45
+ * Everything a contributor tag renders, resolved by the plugin so the tag UI does no lookups.
46
+ * Declared here rather than beside `extractContributorTags` so the shared state below can name it
47
+ * without importing back out of this file. Internal, like `TagContributor`.
48
+ */
49
+
50
+ /**
51
+ * Where node/paragraph-level deleted content is rendered relative to the new (replacement)
52
+ * content in the `smart` diffType:
53
+ * - `'top'` (default): the deleted content is anchored above the new content.
54
+ * - `'bottom'`: the deleted content is anchored below the new content.
55
+ */
56
+
57
+ /**
58
+ * Where inline-level (and sentence-level) deleted content is rendered relative to the new
59
+ * (replacement) content in the `smart` diffType. This is independent of the node/paragraph-level
60
+ * `deletedDiffPlacement` option:
61
+ * - `'before'` (default): the deleted content is anchored before the new content.
62
+ * - `'after'`: the deleted content is anchored after the new content.
63
+ */
64
+
65
+ /**
66
+ * A rendered deleted-content widget: the DOM element show-diff renders for a piece of deleted
67
+ * content, together with the document position it is anchored at. Deleted content is rendered as
68
+ * widget decorations rather than document nodes, so this is how consumers recover the element and
69
+ * its position — via the `getDeletedWidgets` action — without reaching into the plugin's internal
70
+ * state.
71
+ */
72
+
73
+ // Re-export the canonical `SmartDiffThresholds` declaration (single source of truth) so the
74
+ // public plugin types stay in sync with the smart-diff implementation.
75
+
76
+ /**
77
+ * How the diff is revealed when it is painted.
78
+ *
79
+ * - `phased` — the two-phase choreography used when opening the diff from a clean "new state":
80
+ * the outgoing state cross-fades to the incoming one while the agent highlight wipes out to the
81
+ * right, then every highlight wipes back in from the left.
82
+ *
83
+ * Deliberately separate from {@link DiffType}: that describes how changes are computed and grouped,
84
+ * this describes how the result is presented over time. Folding one into the other would make every
85
+ * `DiffType` consumer — version history, track-changes, publish diff — care about presentation.
86
+ */
87
+
88
+ /**
89
+ * Attributed alternative to `PMDiffParams`. When agent colouring is enabled, changes are grouped
90
+ * by `userId`, with `agentId` used as a tie-breaker.
91
+ */
@@ -12,6 +12,7 @@ var _contributorTagIcons = require("./contributorTagIcons");
12
12
  /** Agent kinds with a custom contributor-tag icon. */
13
13
  var AGENT_KIND_ICONS = {
14
14
  claude: 'claude',
15
+ chatgpt: 'chatgpt',
15
16
  rovo: 'rovoHex'
16
17
  };
17
18
 
@@ -91,7 +92,7 @@ var contributorAvatarRenderer = exports.contributorAvatarRenderer = function con
91
92
  }
92
93
  var image;
93
94
  var unbindImageError;
94
- var showFallback = function showFallback() {
95
+ var showContributorIcon = function showContributorIcon() {
95
96
  var _unbindImageError, _image, _AGENT_KIND_ICONS, _contributor$agentKin;
96
97
  (_unbindImageError = unbindImageError) === null || _unbindImageError === void 0 || _unbindImageError();
97
98
  unbindImageError = undefined;
@@ -107,20 +108,27 @@ var contributorAvatarRenderer = exports.contributorAvatarRenderer = function con
107
108
  shape.appendChild((0, _contributorTagIcons.getContributorTagIcon)((_AGENT_KIND_ICONS = AGENT_KIND_ICONS[(_contributor$agentKin = contributor.agentKind) !== null && _contributor$agentKin !== void 0 ? _contributor$agentKin : 'external']) !== null && _AGENT_KIND_ICONS !== void 0 ? _AGENT_KIND_ICONS : 'aiAgent', doc));
108
109
  };
109
110
  if (contributor.avatarUrl) {
110
- image = doc.createElement('img');
111
- image.alt = '';
112
- image.decoding = 'async';
113
- image.draggable = false;
114
- image.loading = 'lazy';
115
- image.setAttribute('style', imageStyle);
116
- unbindImageError = (0, _bindEventListener.bind)(image, {
117
- type: 'error',
118
- listener: showFallback
119
- });
120
- shape.appendChild(image);
121
- image.src = contributor.avatarUrl;
111
+ var _contributor$agentKin2;
112
+ // Known brands use their fixed glyph even when the profile also has an avatar URL.
113
+ var brandedAgentIcon = isAgent ? AGENT_KIND_ICONS[(_contributor$agentKin2 = contributor.agentKind) !== null && _contributor$agentKin2 !== void 0 ? _contributor$agentKin2 : 'external'] : undefined;
114
+ if (brandedAgentIcon) {
115
+ showContributorIcon();
116
+ } else {
117
+ image = doc.createElement('img');
118
+ image.alt = '';
119
+ image.decoding = 'async';
120
+ image.draggable = false;
121
+ image.loading = 'lazy';
122
+ image.setAttribute('style', imageStyle);
123
+ unbindImageError = (0, _bindEventListener.bind)(image, {
124
+ type: 'error',
125
+ listener: showContributorIcon
126
+ });
127
+ shape.appendChild(image);
128
+ image.src = contributor.avatarUrl;
129
+ }
122
130
  } else {
123
- showFallback();
131
+ showContributorIcon();
124
132
  }
125
133
  var setRingColor = function setRingColor(nextRingColor) {
126
134
  if (isAgent) {
@@ -33,9 +33,13 @@ var ROVO_HEX_ICON_SVG = "<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" r
33
33
 
34
34
  /** ClaudeLogo from ai-mate/studio-browse-kit, inset to fit the agent hexagon. */
35
35
  var CLAUDE_ICON_SVG = "<svg width=\"12\" height=\"12\" viewBox=\"8 8 32 32\" role=\"presentation\" style=\"display:block\"><path fill=\"#FFFFFF\" d=\"M14.2785 29.274L20.5732 25.7445L20.6785 25.4369L20.5732 25.2669H20.2653L19.2122 25.2021L15.6152 25.105L12.4962 24.9755L9.47443 24.8136L8.71291 24.6517L8 23.7126L8.07291 23.2431L8.71291 22.8141L9.62835 22.895L11.6537 23.0326L14.6916 23.2431L16.8952 23.3726L20.16 23.7126H20.6785L20.7514 23.5022L20.5732 23.3726L20.4354 23.2431L17.2922 21.1141L13.8896 18.8636L12.1073 17.5684L11.1433 16.9127L10.6572 16.2975L10.4466 14.9537L11.3215 13.9904L12.4962 14.0713L12.7959 14.1523L13.9868 15.067L16.5306 17.0342L19.8522 19.4789L20.3382 19.8836L20.5327 19.746L20.557 19.6489L20.3382 19.2846L18.5316 16.0223L16.6035 12.7033L15.7448 11.3271L15.518 10.5014C15.437 10.1614 15.3803 9.87807 15.3803 9.52998L16.3767 8.17809L16.9276 8L18.2562 8.17809L18.8152 8.6638L19.6415 10.55L20.9782 13.5209L23.0522 17.5603L23.6597 18.7584L23.9838 19.8674L24.1053 20.2074H24.3159V20.0132L24.4861 17.7384L24.802 14.9456L25.1099 11.3514L25.2152 10.3395L25.7175 9.12522L26.7139 8.46952L27.4916 8.84189L28.1316 9.75664L28.0425 10.3476L27.6618 12.8166L26.9165 16.6861L26.4304 19.2765H26.7139L27.038 18.9527L28.3504 17.2122L30.5539 14.4599L31.5261 13.3671L32.6603 12.1609L33.3894 11.5861H34.7666L35.7792 13.0918L35.3256 14.6461L33.9079 16.4432L32.7332 17.9651L31.0481 20.2317L29.9949 22.045L30.0922 22.1907L30.3433 22.1665L34.1509 21.3569L36.2086 20.9846L38.6633 20.5636L39.7732 21.0817L39.8947 21.6079L39.4572 22.6845L36.8324 23.3322L33.7539 23.9474L29.1686 25.0321L29.1119 25.0726L29.1767 25.1536L31.2425 25.3478L32.1256 25.3964H34.2886L38.3149 25.6959L39.3681 26.3921L40 27.2421L39.8947 27.8897L38.2744 28.7154L36.0871 28.1973L30.9833 26.9831L29.2334 26.5459H28.9904V26.6916L30.4486 28.1164L33.122 30.5287L36.4678 33.6372L36.638 34.4063L36.2086 35.0134L35.7549 34.9486L32.8142 32.7387L31.68 31.743L29.1119 29.5816H28.9418V29.8082L29.5332 30.6744L32.6603 35.3696L32.8223 36.8105L32.5954 37.28L31.7853 37.5634L30.8942 37.4015L29.0633 34.8353L27.1757 31.9454L25.6527 29.3549L25.4663 29.4602L24.5671 39.1338L24.1458 39.6276L23.1737 40L22.3635 39.3848L21.9342 38.3891L22.3635 36.422L22.882 33.8558L23.3033 31.8158L23.6841 29.2821L23.9109 28.4402L23.8947 28.3835L23.7084 28.4078L21.7965 31.0306L18.8881 34.9567L16.5873 37.4177L16.0365 37.6362L15.0805 37.1424L15.1696 36.2601L15.7043 35.4748L18.8881 31.4273L20.8081 28.9178L22.0476 27.4688L22.0395 27.2583H21.9666L13.5089 32.7468L12.002 32.9411L11.3539 32.3339L11.4349 31.3382L11.7428 31.0144L14.2866 29.2659L14.2785 29.274Z\"/></svg>";
36
+
37
+ /** ChatGPT Presence avatar from Confluence's `ChatGptPresenceIcon`, at 16px. */
38
+ var CHATGPT_ICON_SVG = '<svg width="16" height="16" viewBox="1 1.5328 16 16" overflow="visible" fill="none" role="presentation" style="display:block"><path d="M7.24707 0.973022C8.33116 0.344106 9.66865 0.342238 10.7539 0.969116L15.751 3.85583C16.8334 4.48117 17.5 5.63699 17.5 6.88708V12.1801C17.5 13.4301 16.8334 14.586 15.751 15.2113L10.751 18.1C9.66769 18.7258 8.33231 18.7258 7.24902 18.1L2.24902 15.2113C1.16658 14.586 0.5 13.4301 0.5 12.1801V6.90271C0.5 5.65489 1.1648 4.50153 2.24414 3.87537L7.24707 0.973022Z" fill="#14120B" stroke="#FFFFFF" stroke-width="1"/><svg x="4" y="4.53355" width="10" height="10" viewBox="10 12.0281 24 24" overflow="visible"><path d="M32.2119 21.2917C32.7552 19.256 32.2283 16.9938 30.6312 15.3967C29.0342 13.7997 26.7722 13.2728 24.7362 13.8161C23.2447 12.3277 21.0224 11.6529 18.8407 12.2376C16.6589 12.8221 15.0717 14.5177 14.5243 16.5524C12.4896 17.0999 10.794 18.6873 10.2094 20.8688C9.62493 23.0506 10.2996 25.2728 11.7881 26.7644C11.2448 28.8002 11.7718 31.0623 13.3688 32.6594C14.9658 34.2564 17.2278 34.7834 19.2638 34.2401C20.7553 35.7284 22.9778 36.4032 25.1593 35.8187C27.3411 35.2342 28.9283 33.5386 29.4757 31.5039C31.5105 30.9564 33.206 29.3691 33.7905 27.1874C34.3751 25.0058 33.7005 22.7834 32.2119 21.2919V21.2917ZM29.6507 16.3775C30.7329 17.4598 31.1792 18.937 30.9897 20.3453L25.9072 17.4108C25.6929 17.2871 25.4289 17.2871 25.2148 17.4108L19.2638 20.8466V18.5936C19.2638 18.4356 19.3485 18.2877 19.4854 18.2087L24.017 15.5924C25.8125 14.5895 28.1246 14.8514 29.6508 16.3775H29.6507ZM22 20.8685L24.7364 22.4483V25.608L22 27.1878L19.2636 25.608V22.4483L22 20.8685ZM15.7028 18.0636C15.732 16.0073 17.1149 14.1359 19.1997 13.5772C20.678 13.1811 22.1806 13.5333 23.3053 14.4014L18.2226 17.3357C18.0084 17.4594 17.8764 17.6881 17.8764 17.9353V24.8069L15.9253 23.6804C15.7885 23.6014 15.7028 23.454 15.7028 23.2959V18.0634V18.0636ZM11.549 21.2278C11.9451 19.7495 13.0014 18.6242 14.3156 18.0843V23.9532C14.3156 24.2004 14.4476 24.4291 14.6618 24.5528L20.6128 27.9886L18.6617 29.1151C18.5249 29.1941 18.3544 29.1946 18.2175 29.1156L13.6859 26.4993C11.9196 25.4459 10.9905 23.3124 11.549 21.2278ZM14.3494 31.6788C13.2671 30.5965 12.8208 29.1193 13.0103 27.7111L18.0928 30.6455C18.3071 30.7692 18.5711 30.7692 18.7852 30.6455L24.7362 27.2098V29.4626C24.7362 29.6207 24.6516 29.7682 24.5146 29.8477L19.983 32.4639C18.1875 33.4667 15.8754 33.2049 14.3492 31.6788H14.3494ZM28.2972 29.9927C28.268 32.049 26.8851 33.9205 24.8003 34.4791C23.322 34.8752 21.8194 34.523 20.6947 33.6549L25.7774 30.7205C25.9917 30.5969 26.1236 30.3682 26.1236 30.1209V23.2494L28.0747 24.3759C28.2115 24.4549 28.2972 24.6023 28.2972 24.7604V29.9929V29.9927ZM32.451 26.8285C32.0549 28.3068 30.9986 29.4321 29.6844 29.972V24.1031C29.6844 23.8559 29.5525 23.6272 29.3382 23.5035L23.3872 20.0678L25.3383 18.9412C25.4751 18.8622 25.6456 18.8617 25.7825 18.9407L30.314 21.5569C32.0804 22.6105 33.0095 24.7439 32.451 26.8285Z" fill="#FFFFFF"/></svg></svg>';
36
39
  var markup = {
37
40
  aiAgent: AI_AGENT_ICON_SVG,
38
41
  aiBot: AI_BOT_ICON_SVG,
42
+ chatgpt: CHATGPT_ICON_SVG,
39
43
  claude: CLAUDE_ICON_SVG,
40
44
  person: PERSON_ICON_SVG,
41
45
  rovoHex: ROVO_HEX_ICON_SVG
@@ -1,2 +1,3 @@
1
1
  /* eslint-disable @atlaskit/editor/no-re-export */
2
+
2
3
  export { computeDiffChanges } from '../pm-plugins/calculateDiff/computeDiffChanges';
@@ -0,0 +1,3 @@
1
+ /* eslint-disable @atlaskit/editor/no-re-export */
2
+
3
+ export { DIFF_AGENT_BRANDS } from '../showDiffPluginType';
@@ -1,2 +1,3 @@
1
1
  /* eslint-disable @atlaskit/editor/no-re-export */
2
+
2
3
  export { showDiffPlugin } from '../showDiffPlugin';
@@ -1,5 +1,5 @@
1
- import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
2
1
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
2
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
3
3
 
4
4
  /**
5
5
  * Utilities for working with ProseMirror node views and DOM serialization within the
@@ -4,23 +4,28 @@ import { ChangeSet, simplifyChanges } from 'prosemirror-changeset';
4
4
  import { areDocsEqualByBlockStructureAndText } from '@atlaskit/editor-common/utils/areDocsEqualByBlockStructureAndText';
5
5
  import { areNodesEqualIgnoreAttrs } from '@atlaskit/editor-common/utils/document';
6
6
  import { Mapping } from '@atlaskit/editor-prosemirror/transform';
7
- import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
7
+ import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
8
+ import { TableMap } from '@atlaskit/editor-tables/table-map';
8
9
  import { UNSAFE_expValNoExposure } from '@atlaskit/platform-feature-experiments/unsafe-exp-val-no-exposure';
9
10
  import { fg } from '@atlaskit/platform-feature-flags/fg';
10
11
  import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
12
+ import { createAttributionColorMap, getAttributionKey, getAttributionKeyForChange, getColorSchemeForChange, isAttributionColoringEnabled, isContributorTagsEnabled } from '../decorations/colorSchemes/attributions';
11
13
  import { createDocMarginAnchorWidget } from '../decorations/createAnchorDecorationWidgets';
12
14
  import { createBlockChangedDecoration } from '../decorations/createBlockChangedDecoration';
13
15
  import { createInlineChangedDecoration } from '../decorations/createInlineChangedDecoration';
14
16
  import { createNodeChangedDecorationWidget } from '../decorations/createNodeChangedDecorationWidget';
15
- import { createAttributionColorMap, getAttributionKey, getAttributionKeyForChange, getColorSchemeForChange, isAttributionColoringEnabled, isContributorTagsEnabled } from '../decorations/colorSchemes/attributions';
16
17
  import { extractDiffDescriptors } from '../decorations/decorationKeys';
17
18
  import { extractContributorTags } from '../decorations/extractContributorTags';
19
+ import { createDeletedLineBreakDecoration } from '../decorations/utils/createDeletedLineBreakWidget';
18
20
  import { getAttrChangeRanges, stepIsValidAttrChange } from '../decorations/utils/getAttrChangeRanges';
19
21
  import { getMarkChangeRanges } from '../decorations/utils/getMarkChangeRanges';
22
+ import { createRemovedLozenge } from '../decorations/utils/wrapBlockNodeView';
20
23
  import { getScrollableDecorations } from '../getScrollableDecorations';
21
24
  import { getDefaultDiffType, isExtendedEnabled } from '../isExtendedEnabled';
25
+ import { emptyTextBlockContentPositions } from '../utils/emptyTextBlocks';
22
26
  import { diffBySteps } from './diffBySteps';
23
27
  import { groupChangesByBlock } from './groupChangesByBlock';
28
+ import { CELL_CONTENT_OFFSET, groupDeletedColumnChanges } from './groupDeletedColumnChanges';
24
29
  import { isMarkOnlyChange } from './isMarkOnlyChange';
25
30
  import { isOpenTokenOnlyChange } from './isOpenTokenOnlyChange';
26
31
  import { optimizeChanges } from './optimizeChanges';
@@ -459,7 +464,7 @@ const calculateDiffDecorationsInner = ({
459
464
 
460
465
  // Still colours-only: a tags-only diff keeps the plain colour scheme.
461
466
  if (attributionColoringEnabled) {
462
- attributionColors = createAttributionColorMap(simplifiedStepAttributions);
467
+ attributionColors = createAttributionColorMap(simplifiedStepAttributions, contributors);
463
468
  }
464
469
  } else {
465
470
  const changeset = ChangeSet.create(originalDoc, undefined, tokenEncoder).addSteps(steppedDoc, stepMaps, tr.doc);
@@ -485,10 +490,32 @@ const calculateDiffDecorationsInner = ({
485
490
 
486
491
  // Our default operations are insertions, so it should match the opposite of isInverted.
487
492
  const isInserted = !isInverted;
493
+ if (isExtendedEnabled(diffType)) {
494
+ changes = groupDeletedColumnChanges(changes, originalDoc, tr.doc, new Mapping(stepMaps), isInverted);
495
+ }
496
+ // A whole-table change owns every mark and attribute range inside its bounds, so those ranges
497
+ // do not also get their own decoration.
498
+ const tableChanges = changes.filter(change => change.deletedColumns !== undefined);
499
+ const isHandledByTable = (from, to) => tableChanges.some(change => from >= change.fromB && to <= change.toB);
488
500
  const createDecorationsForChange = change => {
489
501
  const changeColorScheme = attributionColors ? getColorSchemeForChange(change, attributedChanges, attributionColors, colorScheme) : colorScheme;
490
502
  const attributionKey = showContributorTags ? getAttributionKeyForChange(change, attributedChanges) : undefined;
491
503
  const isActive = isRangeActive(activeIndexPos, change.fromB, change.toB);
504
+ const {
505
+ deletedColumns
506
+ } = change;
507
+ // On an inverted diff the table that lost columns is the one in `tr.doc`, so the column
508
+ // indices address it directly and each label anchors inside its own cell.
509
+ const table = tr.doc.nodeAt(change.fromB);
510
+ if (isInverted && !hideDeletedDiffs && deletedColumns !== null && deletedColumns !== void 0 && deletedColumns.length && (table === null || table === void 0 ? void 0 : table.type.name) === 'table') {
511
+ const tableMap = TableMap.get(table);
512
+ deletedColumns.forEach(column => {
513
+ const offset = tableMap.positionAt(0, column, table);
514
+ decorations.push(Decoration.widget(change.fromB + CELL_CONTENT_OFFSET + offset, () => createRemovedLozenge(intl, isActive, changeColorScheme, true), {
515
+ side: -1
516
+ }));
517
+ });
518
+ }
492
519
 
493
520
  // The deleted side of a mark-only change is a byte-identical copy of the new text, so it is
494
521
  // suppressed in the clean view. `hideDeletedDiffs` is load-bearing: when false the reviewer
@@ -522,6 +549,32 @@ const calculateDiffDecorationsInner = ({
522
549
  // On an inverted diff the inserted side is visually the deleted side.
523
550
  const shouldHideDeleted = isExtendedEnabled(diffType) ? isInverted && hideDeletedDiffs : false;
524
551
 
552
+ // A removed blank line — an empty paragraph or heading — has nothing to mark up. On an
553
+ // inverted diff, the shape AI suggested edits renders, the block is still in the displayed
554
+ // document, so the removal lands here on the inserted side rather than on the deleted side,
555
+ // and both the inline and the block decoration paint nothing: an empty textblock has no
556
+ // inline content to cover, and block decorations return no style for a paragraph or heading.
557
+ // The reviewer sees an unmarked blank line. Stand the struck-through return glyph in for each
558
+ // one, anchored inside the block so it renders on the blank line itself.
559
+ //
560
+ // One decoration per blank line rather than one per change: a run of adjacent blank lines is
561
+ // reported as a single change spanning all of them.
562
+ //
563
+ // Withheld in the clean view, where removals are hidden rather than struck through.
564
+ if (fg('platform_editor_ai_show_diff_patch_2') && !isInserted && !shouldHideDeleted) {
565
+ for (const pos of emptyTextBlockContentPositions(tr.doc, change.fromB, change.toB)) {
566
+ decorations.push(createDeletedLineBreakDecoration({
567
+ attributionKey,
568
+ colorScheme: changeColorScheme,
569
+ diffType,
570
+ isActive,
571
+ pos,
572
+ reveal,
573
+ side: -1
574
+ }));
575
+ }
576
+ }
577
+
525
578
  // For `smart` NODE-level promotions the change range spans a whole container
526
579
  // (e.g. an entire list/table/layout, using outer node bounds). Applying a SINGLE
527
580
  // inline decoration across that whole range would paint the inserted style across
@@ -630,6 +683,7 @@ const calculateDiffDecorationsInner = ({
630
683
  });
631
684
  if (!shouldHideDeleted) {
632
685
  decorations.push(...createNodeChangedDecorationWidget({
686
+ deletedColumns,
633
687
  // The deleted side has no inline decoration, so the widget carries the actor.
634
688
  attributionKey,
635
689
  // Extended pipeline only, matching the inline path: the non-extended styles have no
@@ -665,6 +719,9 @@ const calculateDiffDecorationsInner = ({
665
719
  getMarkChangeRanges(simplifiedSteps, simplifiedStepAttributions, fg('confluence_ncs_step_diffing_version_history') ? stepMaps : undefined).filter(({
666
720
  fromB,
667
721
  toB
722
+ }) => !isHandledByTable(fromB, toB)).filter(({
723
+ fromB,
724
+ toB
668
725
  }) => !fg('confluence_ncs_step_diffing_version_history') || !changes.some(change => change.fromB === fromB && change.toB === toB)).forEach(change => {
669
726
  var _attributionColors$ge, _attributionColors;
670
727
  const changeColorScheme = change.attributionKey ? (_attributionColors$ge = (_attributionColors = attributionColors) === null || _attributionColors === void 0 ? void 0 : _attributionColors.get(change.attributionKey)) !== null && _attributionColors$ge !== void 0 ? _attributionColors$ge : colorScheme : colorScheme;
@@ -686,6 +743,9 @@ const calculateDiffDecorationsInner = ({
686
743
  getAttrChangeRanges(tr.doc, attrStepContexts, originalDoc).filter(({
687
744
  fromB,
688
745
  toB
746
+ }) => !isHandledByTable(fromB, toB)).filter(({
747
+ fromB,
748
+ toB
689
749
  }) => !fg('confluence_ncs_step_diffing_version_history') || !changes.some(change => change.fromB === fromB && change.toB === toB)).forEach(change => {
690
750
  var _attributionColors$ge2, _attributionColors2;
691
751
  const changeColorScheme = change.attributionKey ? (_attributionColors$ge2 = (_attributionColors2 = attributionColors) === null || _attributionColors2 === void 0 ? void 0 : _attributionColors2.get(change.attributionKey)) !== null && _attributionColors$ge2 !== void 0 ? _attributionColors$ge2 : colorScheme : colorScheme;