@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
@@ -2,6 +2,7 @@ import { tableMarginTop } from '@atlaskit/editor-common/styles';
2
2
  import { getStickyHeaderHeight } from '@atlaskit/editor-common/table/get-sticky-header-height';
3
3
  import { fg } from '@atlaskit/platform-feature-flags/fg';
4
4
  import { isDiffDecoration, SCROLL_TARGET_MARGIN_CSS_PROPERTY } from './decorations/decorationKeys';
5
+
5
6
  /**
6
7
  * Extra space above the scrolled-to element so it does not sit flush under the
7
8
  * viewport edge (helps with sticky table headers, toolbars, etc.).
@@ -0,0 +1,60 @@
1
+ /**
2
+ * The textblock types whose empty form is a blank line the author put there deliberately, and so
3
+ * worth marking when a change removes it.
4
+ *
5
+ * Deliberately not every textblock: an empty `codeBlock` is an empty code block, which renders as a
6
+ * visible box of its own and needs no stand-in.
7
+ */
8
+ var BLANK_LINE_NODE_NAMES = new Set(['paragraph', 'heading']);
9
+
10
+ /**
11
+ * Structurally empty: no children at all, not merely no measurable content. The two coincide for a
12
+ * real node, and testing both keeps a node whose children report no size from passing as blank.
13
+ */
14
+ var isEmptyTextBlock = function isEmptyTextBlock(node) {
15
+ return BLANK_LINE_NODE_NAMES.has(node.type.name) && node.content.childCount === 0 && node.content.size === 0;
16
+ };
17
+
18
+ /**
19
+ * How many empty textblocks a slice holds, or 0 unless that is *all* it holds.
20
+ *
21
+ * Counted rather than tested for one, because a run of adjacent blank lines is reported as a single
22
+ * change covering all of them — the case that made a single-block test miss.
23
+ */
24
+ export var countEmptyTextBlockOnlySlice = function countEmptyTextBlockOnlySlice(slice) {
25
+ var _slice$content$childC;
26
+ 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;
27
+ if (!slice || childCount === 0) {
28
+ return 0;
29
+ }
30
+ for (var index = 0; index < childCount; index++) {
31
+ if (!isEmptyTextBlock(slice.content.child(index))) {
32
+ return 0;
33
+ }
34
+ }
35
+ return childCount;
36
+ };
37
+
38
+ /**
39
+ * The content position of every empty textblock lying wholly within `[from, to]`.
40
+ *
41
+ * Used to place a marker on each blank line a change removes. Partially covered blocks are skipped:
42
+ * the change only took part of one, so it still has text of its own, which the inline decoration
43
+ * already marks.
44
+ */
45
+ export var emptyTextBlockContentPositions = function emptyTextBlockContentPositions(doc, from, to) {
46
+ var positions = [];
47
+ doc.nodesBetween(from, to, function (node, pos) {
48
+ if (node.isTextblock) {
49
+ if (isEmptyTextBlock(node) && pos >= from && pos + node.nodeSize <= to) {
50
+ // +1 steps over the block's own open token, into its (empty) content.
51
+ positions.push(pos + 1);
52
+ }
53
+ // A textblock holds inline content only, so there is nothing below it to visit.
54
+ return false;
55
+ }
56
+ // Keep descending: blank lines nest inside cells, columns and panels.
57
+ return true;
58
+ });
59
+ return positions;
60
+ };
@@ -1 +1,85 @@
1
- export {};
1
+ /**
2
+ * `'standard'` (purple insertions, default) and `'traditional'` (green/red) are the two
3
+ * plugin-configured schemes. The remaining accent names are the attribution palette used for
4
+ * per-contributor colouring (`stepsWithAttribution`) — callers of the imperative `showDiff`
5
+ * command (see `PMDiffParams.colorScheme`) can also pass one of these directly to match a
6
+ * specific contributor's colour outside of attribution mode, for example matching a Review
7
+ * moment diff to the streaming highlight of the agent that produced it.
8
+ */
9
+
10
+ /**
11
+ * Attribution for a ProseMirror step.
12
+ *
13
+ * `userId` is the primary actor identity. `agentId` distinguishes multiple agents (or an agent
14
+ * from its user) when they share that user ID, with `agentType` used as a fallback when `agentId`
15
+ * is empty. `wasOffline` preserves additional provenance without affecting identity.
16
+ */
17
+
18
+ /** Keeps a step and its attribution coupled through mapping and filtering. */
19
+
20
+ /** Branded agent presentations supported by contributor tags. */
21
+
22
+ export var DIFF_AGENT_BRANDS = new Set(['rovo', 'claude', 'chatgpt']);
23
+
24
+ /** A complete identity for one of the accounts named by a step attribution. */
25
+
26
+ /** Agent presentation: branded, identified by profile, or a generic external agent. */
27
+
28
+ /**
29
+ * A contributor the plugin has resolved from a step attribution and a supplied profile. Internal:
30
+ * never re-exported from an entry point and not reachable from any public type. Same for
31
+ * `DiffContributors`.
32
+ */
33
+
34
+ /** Where two contributors share an identity, the last wins. */
35
+
36
+ /** A contributor stripped of its attributions, as a tag presents it. Internal. */
37
+
38
+ /**
39
+ * Everything a contributor tag renders, resolved by the plugin so the tag UI does no lookups.
40
+ * Declared here rather than beside `extractContributorTags` so the shared state below can name it
41
+ * without importing back out of this file. Internal, like `TagContributor`.
42
+ */
43
+
44
+ /**
45
+ * Where node/paragraph-level deleted content is rendered relative to the new (replacement)
46
+ * content in the `smart` diffType:
47
+ * - `'top'` (default): the deleted content is anchored above the new content.
48
+ * - `'bottom'`: the deleted content is anchored below the new content.
49
+ */
50
+
51
+ /**
52
+ * Where inline-level (and sentence-level) deleted content is rendered relative to the new
53
+ * (replacement) content in the `smart` diffType. This is independent of the node/paragraph-level
54
+ * `deletedDiffPlacement` option:
55
+ * - `'before'` (default): the deleted content is anchored before the new content.
56
+ * - `'after'`: the deleted content is anchored after the new content.
57
+ */
58
+
59
+ /**
60
+ * A rendered deleted-content widget: the DOM element show-diff renders for a piece of deleted
61
+ * content, together with the document position it is anchored at. Deleted content is rendered as
62
+ * widget decorations rather than document nodes, so this is how consumers recover the element and
63
+ * its position — via the `getDeletedWidgets` action — without reaching into the plugin's internal
64
+ * state.
65
+ */
66
+
67
+ // Re-export the canonical `SmartDiffThresholds` declaration (single source of truth) so the
68
+ // public plugin types stay in sync with the smart-diff implementation.
69
+
70
+ /**
71
+ * How the diff is revealed when it is painted.
72
+ *
73
+ * - `phased` — the two-phase choreography used when opening the diff from a clean "new state":
74
+ * the outgoing state cross-fades to the incoming one while the agent highlight wipes out to the
75
+ * right, then every highlight wipes back in from the left.
76
+ *
77
+ * Deliberately separate from {@link DiffType}: that describes how changes are computed and grouped,
78
+ * this describes how the result is presented over time. Folding one into the other would make every
79
+ * `DiffType` consumer — version history, track-changes, publish diff — care about presentation.
80
+ */
81
+
82
+ /**
83
+ * Attributed alternative to `PMDiffParams`. When agent colouring is enabled, changes are grouped
84
+ * by `userId`, with `agentId` used as a tie-breaker.
85
+ */
@@ -7,6 +7,7 @@ import { getContributorTagIcon } from './contributorTagIcons';
7
7
  /** Agent kinds with a custom contributor-tag icon. */
8
8
  var AGENT_KIND_ICONS = {
9
9
  claude: 'claude',
10
+ chatgpt: 'chatgpt',
10
11
  rovo: 'rovoHex'
11
12
  };
12
13
 
@@ -86,7 +87,7 @@ export var contributorAvatarRenderer = function contributorAvatarRenderer(_ref)
86
87
  }
87
88
  var image;
88
89
  var unbindImageError;
89
- var showFallback = function showFallback() {
90
+ var showContributorIcon = function showContributorIcon() {
90
91
  var _unbindImageError, _image, _AGENT_KIND_ICONS, _contributor$agentKin;
91
92
  (_unbindImageError = unbindImageError) === null || _unbindImageError === void 0 || _unbindImageError();
92
93
  unbindImageError = undefined;
@@ -102,20 +103,27 @@ export var contributorAvatarRenderer = function contributorAvatarRenderer(_ref)
102
103
  shape.appendChild(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));
103
104
  };
104
105
  if (contributor.avatarUrl) {
105
- image = doc.createElement('img');
106
- image.alt = '';
107
- image.decoding = 'async';
108
- image.draggable = false;
109
- image.loading = 'lazy';
110
- image.setAttribute('style', imageStyle);
111
- unbindImageError = bind(image, {
112
- type: 'error',
113
- listener: showFallback
114
- });
115
- shape.appendChild(image);
116
- image.src = contributor.avatarUrl;
106
+ var _contributor$agentKin2;
107
+ // Known brands use their fixed glyph even when the profile also has an avatar URL.
108
+ var brandedAgentIcon = isAgent ? AGENT_KIND_ICONS[(_contributor$agentKin2 = contributor.agentKind) !== null && _contributor$agentKin2 !== void 0 ? _contributor$agentKin2 : 'external'] : undefined;
109
+ if (brandedAgentIcon) {
110
+ showContributorIcon();
111
+ } else {
112
+ image = doc.createElement('img');
113
+ image.alt = '';
114
+ image.decoding = 'async';
115
+ image.draggable = false;
116
+ image.loading = 'lazy';
117
+ image.setAttribute('style', imageStyle);
118
+ unbindImageError = bind(image, {
119
+ type: 'error',
120
+ listener: showContributorIcon
121
+ });
122
+ shape.appendChild(image);
123
+ image.src = contributor.avatarUrl;
124
+ }
117
125
  } else {
118
- showFallback();
126
+ showContributorIcon();
119
127
  }
120
128
  var setRingColor = function setRingColor(nextRingColor) {
121
129
  if (isAgent) {
@@ -27,9 +27,13 @@ var ROVO_HEX_ICON_SVG = "<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" r
27
27
 
28
28
  /** ClaudeLogo from ai-mate/studio-browse-kit, inset to fit the agent hexagon. */
29
29
  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>";
30
+
31
+ /** ChatGPT Presence avatar from Confluence's `ChatGptPresenceIcon`, at 16px. */
32
+ 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>';
30
33
  var markup = {
31
34
  aiAgent: AI_AGENT_ICON_SVG,
32
35
  aiBot: AI_BOT_ICON_SVG,
36
+ chatgpt: CHATGPT_ICON_SVG,
33
37
  claude: CLAUDE_ICON_SVG,
34
38
  person: PERSON_ICON_SVG,
35
39
  rovoHex: ROVO_HEX_ICON_SVG
@@ -1 +1,2 @@
1
- export type { ColorScheme, DeletedDiffPlacement, DeletedDiffWidget, DiffContributorProfile, DiffParams, DiffStepAttribution, DiffType, PMDiffParams, RevealMode, RevealOptions, ShowDiffParams, ShowDiffPlugin, SmartDiffThresholds, StepWithAttribution, } from '../showDiffPluginType';
1
+ export type { ColorScheme, DeletedDiffPlacement, DeletedDiffWidget, DiffAgentBrand, DiffContributorProfile, DiffParams, DiffStepAttribution, DiffType, PMDiffParams, RevealMode, RevealOptions, ShowDiffParams, ShowDiffPlugin, SmartDiffThresholds, StepWithAttribution, } from '../showDiffPluginType';
2
+ export { DIFF_AGENT_BRANDS } from '../showDiffPluginType';
@@ -0,0 +1,9 @@
1
+ import type { Change } from 'prosemirror-changeset';
2
+ import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
+ import type { Mapping } from '@atlaskit/editor-prosemirror/transform';
4
+ export type ColumnAwareChange = Change & {
5
+ deletedColumns?: number[];
6
+ };
7
+ export declare const CELL_CONTENT_OFFSET = 2;
8
+ /** Groups a deleted column's cell changes into one whole-table change. */
9
+ export declare const groupDeletedColumnChanges: (changes: readonly Change[], originalDoc: PMNode, newDoc: PMNode, mapping: Mapping, isInverted: boolean) => ColumnAwareChange[];
@@ -1,5 +1,5 @@
1
1
  import type { Change } from 'prosemirror-changeset';
2
- import type { DiffContributors, DiffStepAttribution, TagContributor } from '../../../showDiffPluginType';
2
+ import { type DiffContributors, type DiffStepAttribution, type TagContributor } from '../../../showDiffPluginType';
3
3
  import { type AdsAccentColor, type ColorScheme } from './types';
4
4
  export type DiffAttributionSpanData = DiffStepAttribution & {
5
5
  stepIndex: number;
@@ -24,7 +24,7 @@ export declare const isAttributionColoringEnabled: (stepAttributions: Array<Diff
24
24
  * a tag only has to name one.
25
25
  */
26
26
  export declare const isContributorTagsEnabled: (stepAttributions: Array<DiffStepAttribution | undefined> | undefined, contributors: ResolvedDiffContributors | undefined) => boolean;
27
- export declare const createAttributionColorMap: (stepAttributions: Array<DiffStepAttribution | undefined>) => Map<string, AdsAccentColor>;
27
+ export declare const createAttributionColorMap: (stepAttributions: Array<DiffStepAttribution | undefined>, contributors?: ResolvedDiffContributors) => Map<string, AdsAccentColor>;
28
28
  /**
29
29
  * The attribution key owning a change. Inline and step changes retain direct attribution spans, so
30
30
  * resolve those first. Grouped and smart-classified changes can lose that data; for those, fall
@@ -1,4 +1,5 @@
1
1
  import type { Change } from 'prosemirror-changeset';
2
+ import type { IntlShape } from 'react-intl';
2
3
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
4
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
4
5
  import type { DiffType } from '../../showDiffPluginType';
@@ -9,11 +10,12 @@ type SimpleChange = Pick<Change, 'fromA' | 'toA' | 'fromB' | 'deleted'>;
9
10
  /**
10
11
  * Main function to handle deleted rows - computes diff and creates decorations
11
12
  */
12
- export declare const createChangedRowDecorationWidgets: ({ attributionKey, changes, originalDoc, newDoc, nodeViewSerializer, colorScheme, isActive, isInserted, diffType, showIndicators, showContributorTags, tagMountContext, }: {
13
+ export declare const createChangedRowDecorationWidgets: ({ attributionKey, changes, originalDoc, newDoc, nodeViewSerializer, colorScheme, isActive, isInserted, diffType, intl, showIndicators, showContributorTags, tagMountContext, }: {
13
14
  attributionKey?: string;
14
15
  changes: SimpleChange[];
15
16
  colorScheme?: ColorScheme;
16
17
  diffType?: DiffType;
18
+ intl?: IntlShape;
17
19
  isActive?: boolean;
18
20
  isInserted?: boolean;
19
21
  newDoc: PMNode;
@@ -39,7 +39,11 @@ export declare const unmountContributorTag: (mount: ContributorTagMount | undefi
39
39
  * The host for a tag on deleted content, which renders inside its own widget decoration rather than
40
40
  * needing one of its own. Unmount with `unmountContributorTag` from that widget's `destroy`.
41
41
  */
42
- export declare const createContributorTagHost: (diffId: string, mountContext?: ContributorTagMountContext) => {
42
+ export declare const createContributorTagHost: ({ anchorName, diffId, mountContext, }: {
43
+ anchorName?: string;
44
+ diffId: string;
45
+ mountContext?: ContributorTagMountContext;
46
+ }) => {
43
47
  host: HTMLSpanElement;
44
48
  mount: ContributorTagMount | undefined;
45
49
  } | undefined;
@@ -4,13 +4,13 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
4
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
5
5
  import type { DiffType, RevealOptions } from '../../showDiffPluginType';
6
6
  import type { NodeViewSerializer } from '../NodeViewSerializer';
7
- import { type ContributorTagMountContext } from './createContributorTagWidget';
8
7
  import type { ColorScheme } from './colorSchemes/types';
8
+ import { type ContributorTagMountContext } from './createContributorTagWidget';
9
9
  /**
10
10
  * This function is used to create a decoration widget to show content
11
11
  * that is not in the current document.
12
12
  */
13
- export declare const createNodeChangedDecorationWidget: ({ attributionKey, change, doc, nodeViewSerializer, colorScheme, newDoc, intl, activeIndexPos, isInserted, showContributorTags, showIndicators, placeBelow, diffType, hideAddedDiffsUnderline, reveal, tagMountContext, }: {
13
+ export declare const createNodeChangedDecorationWidget: ({ attributionKey, change, doc, nodeViewSerializer, colorScheme, newDoc, intl, activeIndexPos, isInserted, showContributorTags, showIndicators, placeBelow, diffType, hideAddedDiffsUnderline, reveal, tagMountContext, deletedColumns, }: {
14
14
  activeIndexPos?: {
15
15
  from: number;
16
16
  to: number;
@@ -18,6 +18,7 @@ export declare const createNodeChangedDecorationWidget: ({ attributionKey, chang
18
18
  attributionKey?: string;
19
19
  change: Pick<Change, 'fromA' | 'toA' | 'fromB' | 'deleted' | 'toB'>;
20
20
  colorScheme?: ColorScheme;
21
+ deletedColumns?: readonly number[];
21
22
  diffType?: DiffType;
22
23
  doc: PMNode;
23
24
  hideAddedDiffsUnderline?: boolean;
@@ -0,0 +1,50 @@
1
+ import { Decoration } from '@atlaskit/editor-prosemirror/view';
2
+ import type { DiffType, RevealOptions } from '../../../showDiffPluginType';
3
+ import type { ColorScheme } from '../colorSchemes/types';
4
+ /**
5
+ * U+2936 ARROW POINTING DOWNWARDS THEN CURVING LEFTWARDS — the return-key glyph.
6
+ *
7
+ * Exported so tests assert against the glyph actually rendered rather than a copy of it.
8
+ */
9
+ export declare const RETURN_GLYPH = "\u2936";
10
+ /**
11
+ * The DOM for a removed blank line: the return glyph, struck through in the deleted colours.
12
+ *
13
+ * An empty paragraph or heading is a line the author deliberately added, but it has no content for
14
+ * the deleted-content widget to serialize, so a deletion of one used to render nothing at all — the
15
+ * reviewer saw the surrounding text close up with no sign of what was removed. Standing the glyph
16
+ * in for the absent content keeps the deletion visible without inventing content that was not there.
17
+ *
18
+ * `createContentWrapper` supplies the highlight and the strikethrough line, so the glyph is styled
19
+ * exactly like any other run of deleted inline content, including the active and reveal states.
20
+ *
21
+ * Hidden from assistive technology: the glyph is a picture of a key, and read out it is announced as
22
+ * its Unicode name rather than as a removed line.
23
+ */
24
+ export declare const createDeletedLineBreakWidget: ({ colorScheme, count, diffType, isActive, reveal, }: {
25
+ colorScheme?: ColorScheme;
26
+ /** One glyph per removed blank line, for a run of adjacent ones. */
27
+ count?: number;
28
+ diffType?: DiffType;
29
+ isActive?: boolean;
30
+ reveal?: RevealOptions;
31
+ }) => HTMLElement;
32
+ /**
33
+ * The glyph as a widget decoration anchored at `pos`.
34
+ *
35
+ * Shared by the two shapes a blank-line removal arrives in. On a forward diff the block is gone from
36
+ * the new document, so the change lands on the deleted side and the glyph is anchored where the
37
+ * block used to be. On an inverted diff — what AI suggested edits renders — the block is still in
38
+ * the displayed document and the change lands on the *inserted* side, so the glyph is anchored
39
+ * inside the surviving block, on the blank line itself.
40
+ */
41
+ export declare const createDeletedLineBreakDecoration: ({ attributionKey, colorScheme, count, diffType, isActive, pos, reveal, side, }: {
42
+ attributionKey?: string;
43
+ colorScheme?: ColorScheme;
44
+ count?: number;
45
+ diffType?: DiffType;
46
+ isActive?: boolean;
47
+ pos: number;
48
+ reveal?: RevealOptions;
49
+ side?: number;
50
+ }) => Decoration;
@@ -1,7 +1,7 @@
1
1
  import { SetAttrsStep } from '@atlaskit/adf-schema/steps/set-attrs';
2
2
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
- import type { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform-override';
4
3
  import { AttrStep } from '@atlaskit/editor-prosemirror/transform';
4
+ import type { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform-override';
5
5
  export type InlineAttrChangeNodeName = 'date' | 'emoji' | 'mention' | 'status';
6
6
  type AttrChangeStep = AttrStep | SetAttrsStep;
7
7
  export type AttrStepContext = {
@@ -1,5 +1,5 @@
1
- import type { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform-override';
2
1
  import { type StepMap } from '@atlaskit/editor-prosemirror/transform';
2
+ import type { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform-override';
3
3
  import type { DiffStepAttribution } from '../../../showDiffPluginType';
4
4
  type StepRange = {
5
5
  attributionKey?: string;
@@ -0,0 +1,26 @@
1
+ import type { Slice } from '@atlaskit/editor-prosemirror/model';
2
+ export type TableDiffMode =
3
+ /** Add table headers, or replace whole cells. Draws one content widget per cell. */
4
+ {
5
+ kind: 'cells';
6
+ }
7
+ /** Delete a row, or replace a whole row. Draws a row copy inside the table. */
8
+ | {
9
+ kind: 'rows';
10
+ }
11
+ /** Delete a column, or replace a whole table. Draws a table copy next to the live table. */
12
+ | {
13
+ kind: 'wholeTable';
14
+ }
15
+ /** Delete cells with no replacement. The new document has no cell to anchor to, so nothing draws. */
16
+ | {
17
+ kind: 'none';
18
+ }
19
+ /** Any change outside a table, such as a paragraph edit. Draws the generic block widget. */
20
+ | {
21
+ kind: 'generic';
22
+ };
23
+ export declare const getTableDiffMode: ({ slice, isInserted, }: {
24
+ isInserted: boolean;
25
+ slice: Slice;
26
+ }) => TableDiffMode;
@@ -2,6 +2,10 @@ import type { IntlShape } from 'react-intl';
2
2
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
3
  import type { DiffType, RevealOptions } from '../../../showDiffPluginType';
4
4
  import type { ColorScheme } from '../colorSchemes/types';
5
+ /**
6
+ * Creates a "Removed" lozenge to be displayed at the top right corner of deleted block nodes
7
+ */
8
+ export declare const createRemovedLozenge: (intl: IntlShape, isActive?: boolean, colorScheme?: ColorScheme, inCell?: boolean) => HTMLElement;
5
9
  /**
6
10
  * Handles all block node rendering with appropriate deleted styling.
7
11
  * For heading nodes, applies styles directly to preserve natural margins.
@@ -0,0 +1,16 @@
1
+ import type { Node as PMNode, Slice } from '@atlaskit/editor-prosemirror/model';
2
+ /**
3
+ * How many empty textblocks a slice holds, or 0 unless that is *all* it holds.
4
+ *
5
+ * Counted rather than tested for one, because a run of adjacent blank lines is reported as a single
6
+ * change covering all of them — the case that made a single-block test miss.
7
+ */
8
+ export declare const countEmptyTextBlockOnlySlice: (slice: Slice | undefined) => number;
9
+ /**
10
+ * The content position of every empty textblock lying wholly within `[from, to]`.
11
+ *
12
+ * Used to place a marker on each blank line a change removes. Partially covered blocks are skipped:
13
+ * the change only took part of one, so it still has text of its own, which the inline decoration
14
+ * already marks.
15
+ */
16
+ export declare const emptyTextBlockContentPositions: (doc: PMNode, from: number, to: number) => number[];
@@ -37,16 +37,21 @@ export type StepWithAttribution<TStep> = {
37
37
  step: TStep;
38
38
  stepAttribution?: DiffStepAttribution;
39
39
  };
40
+ /** Branded agent presentations supported by contributor tags. */
41
+ export type DiffAgentBrand = 'rovo' | 'claude' | 'chatgpt';
42
+ export declare const DIFF_AGENT_BRANDS: ReadonlySet<DiffAgentBrand>;
40
43
  /** A complete identity for one of the accounts named by a step attribution. */
41
44
  export type DiffContributorProfile = {
42
45
  /** Matched against the `userId` and `agentId` on step attributions. */
43
46
  accountId: string;
47
+ /** Optional brand for an agent profile, supplied by the host product. */
48
+ agentBrand?: DiffAgentBrand;
44
49
  avatarUrl?: string;
45
50
  name: string;
46
51
  };
47
52
  type DiffContributorKind = 'user' | 'agent';
48
53
  /** Agent presentation: branded, identified by profile, or a generic external agent. */
49
- type DiffAgentKind = 'rovo' | 'claude' | 'identified' | 'external';
54
+ type DiffAgentKind = DiffAgentBrand | 'identified' | 'external';
50
55
  /**
51
56
  * A contributor the plugin has resolved from a step attribution and a supplied profile. Internal:
52
57
  * never re-exported from an entry point and not reachable from any public type. Same for
@@ -8,5 +8,5 @@
8
8
  * The Rovo hex is the `brand` appearance, whose `--rovo-*-color` variables resolve to `initial` in
9
9
  * both themes — the fallbacks below are the rendered colours, so no theme observer is needed.
10
10
  */
11
- export type ContributorTagIcon = 'aiAgent' | 'aiBot' | 'claude' | 'person' | 'rovoHex';
11
+ export type ContributorTagIcon = 'aiAgent' | 'aiBot' | 'chatgpt' | 'claude' | 'person' | 'rovoHex';
12
12
  export declare const getContributorTagIcon: (icon: ContributorTagIcon, doc: Document) => DocumentFragment;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-show-diff",
3
- "version": "17.0.1",
3
+ "version": "17.1.0",
4
4
  "description": "ShowDiff plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -53,7 +53,7 @@
53
53
  "@atlaskit/button": "^25.3.0",
54
54
  "@atlaskit/css": "^1.1.0",
55
55
  "@atlaskit/dropdown-menu": "^18.3.0",
56
- "@atlaskit/editor-core": "^229.0.0",
56
+ "@atlaskit/editor-core": "^229.1.0",
57
57
  "@atlaskit/editor-json-transformer": "^9.8.0",
58
58
  "@atlaskit/editor-plugins": "^16.1.0",
59
59
  "@atlaskit/form": "^17.2.0",
@@ -64,14 +64,14 @@
64
64
  "@atlassian/confluence-presets": "workspace:^",
65
65
  "@atlassian/content-reconciliation": "^0.1.3506",
66
66
  "@atlassian/editor-ai-injected-editors": "^33.0.0",
67
- "@atlassian/editor-plugin-ai": "^73.2.0",
67
+ "@atlassian/editor-plugin-ai": "^73.3.0",
68
68
  "@atlassian/structured-docs-types": "workspace:^",
69
69
  "react": "^19.2.0",
70
70
  "react-dom": "^19.2.0",
71
71
  "react-intl": "^7.0.0"
72
72
  },
73
73
  "peerDependencies": {
74
- "@atlaskit/editor-common": "^123.0.0",
74
+ "@atlaskit/editor-common": "^123.2.0",
75
75
  "react": "^18.2.0 || ^19.2.0",
76
76
  "react-dom": "^18.2.0 || ^19.2.0",
77
77
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"