@atlaskit/editor-plugin-show-diff 17.0.2 → 17.1.1

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 (53) hide show
  1. package/CHANGELOG.md +21 -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 +4 -4
  5. package/dist/cjs/pm-plugins/decorations/colorSchemes/attributions.js +14 -3
  6. package/dist/cjs/pm-plugins/decorations/createAnchorDecorationWidgets.js +28 -8
  7. package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +1 -1
  8. package/dist/cjs/pm-plugins/decorations/createChangedRowDecorationWidgets.js +1 -1
  9. package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +2 -2
  10. package/dist/cjs/pm-plugins/resolveDiffContributors.js +4 -3
  11. package/dist/cjs/showDiffPluginType.js +87 -1
  12. package/dist/cjs/ui/ContributorTag/contributorAvatarRenderer.js +22 -14
  13. package/dist/cjs/ui/ContributorTag/contributorTagIcons.js +4 -0
  14. package/dist/es2019/entry-points/calculate-diff.js +1 -0
  15. package/dist/es2019/entry-points/show-diff-plugin-type.js +3 -0
  16. package/dist/es2019/entry-points/show-diff-plugin.js +1 -0
  17. package/dist/es2019/pm-plugins/NodeViewSerializer.js +1 -1
  18. package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +4 -4
  19. package/dist/es2019/pm-plugins/decorations/colorSchemes/attributions.js +12 -3
  20. package/dist/es2019/pm-plugins/decorations/colorSchemes/factory.js +0 -1
  21. package/dist/es2019/pm-plugins/decorations/createAnchorDecorationWidgets.js +28 -8
  22. package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +1 -1
  23. package/dist/es2019/pm-plugins/decorations/createChangedRowDecorationWidgets.js +1 -1
  24. package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +2 -2
  25. package/dist/es2019/pm-plugins/resolveDiffContributors.js +3 -1
  26. package/dist/es2019/pm-plugins/scrollToDiff.js +1 -0
  27. package/dist/es2019/showDiffPluginType.js +85 -1
  28. package/dist/es2019/ui/ContributorTag/contributorAvatarRenderer.js +22 -14
  29. package/dist/es2019/ui/ContributorTag/contributorTagIcons.js +4 -0
  30. package/dist/esm/entry-points/calculate-diff.js +1 -0
  31. package/dist/esm/entry-points/show-diff-plugin-type.js +3 -0
  32. package/dist/esm/entry-points/show-diff-plugin.js +1 -0
  33. package/dist/esm/pm-plugins/NodeViewSerializer.js +1 -1
  34. package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +4 -4
  35. package/dist/esm/pm-plugins/decorations/colorSchemes/attributions.js +14 -3
  36. package/dist/esm/pm-plugins/decorations/colorSchemes/factory.js +0 -1
  37. package/dist/esm/pm-plugins/decorations/createAnchorDecorationWidgets.js +28 -8
  38. package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +1 -1
  39. package/dist/esm/pm-plugins/decorations/createChangedRowDecorationWidgets.js +1 -1
  40. package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +2 -2
  41. package/dist/esm/pm-plugins/resolveDiffContributors.js +4 -3
  42. package/dist/esm/pm-plugins/scrollToDiff.js +1 -0
  43. package/dist/esm/showDiffPluginType.js +85 -1
  44. package/dist/esm/ui/ContributorTag/contributorAvatarRenderer.js +22 -14
  45. package/dist/esm/ui/ContributorTag/contributorTagIcons.js +4 -0
  46. package/dist/types/entry-points/show-diff-plugin-type.d.ts +2 -1
  47. package/dist/types/pm-plugins/decorations/colorSchemes/attributions.d.ts +2 -2
  48. package/dist/types/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +1 -1
  49. package/dist/types/pm-plugins/decorations/utils/getAttrChangeRanges.d.ts +1 -1
  50. package/dist/types/pm-plugins/decorations/utils/getMarkChangeRanges.d.ts +1 -1
  51. package/dist/types/showDiffPluginType.d.ts +6 -1
  52. package/dist/types/ui/ContributorTag/contributorTagIcons.d.ts +1 -1
  53. package/package.json +5 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @atlaskit/editor-plugin-show-diff
2
2
 
3
+ ## 17.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`296193f8a499b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/296193f8a499b) -
8
+ Keep table diff indicators aligned with the visible table edge when the viewport narrows and the
9
+ table scrolls horizontally, behind platform_editor_ai_show_diff_patch_2.
10
+ - Updated dependencies
11
+
12
+ ## 17.1.0
13
+
14
+ ### Minor Changes
15
+
16
+ - [`1351b0fb49e7d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1351b0fb49e7d) -
17
+ Support branded Claude and ChatGPT contributor tags, use the ChatGPT Presence artwork, and assign
18
+ Claude and ChatGPT their fixed orange and gray diff colours.
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies
23
+
3
24
  ## 17.0.2
4
25
 
5
26
  ### Patch Changes
@@ -1 +1,12 @@
1
- "use strict";
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "DIFF_AGENT_BRANDS", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _showDiffPluginType.DIFF_AGENT_BRANDS;
10
+ }
11
+ });
12
+ var _showDiffPluginType = require("../showDiffPluginType");
@@ -8,8 +8,8 @@ exports.NodeViewSerializer = void 0;
8
8
  exports.isEditorViewWithNodeViews = isEditorViewWithNodeViews;
9
9
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
10
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
- var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
12
11
  var _model = require("@atlaskit/editor-prosemirror/model");
12
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
13
13
  /**
14
14
  * Utilities for working with ProseMirror node views and DOM serialization within the
15
15
  * Show Diff editor plugin.
@@ -19,26 +19,26 @@ var _tableMap = require("@atlaskit/editor-tables/table-map");
19
19
  var _unsafeExpValNoExposure = require("@atlaskit/platform-feature-experiments/unsafe-exp-val-no-exposure");
20
20
  var _fg = require("@atlaskit/platform-feature-flags/fg");
21
21
  var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
22
+ var _attributions = require("../decorations/colorSchemes/attributions");
22
23
  var _createAnchorDecorationWidgets = require("../decorations/createAnchorDecorationWidgets");
23
24
  var _createBlockChangedDecoration = require("../decorations/createBlockChangedDecoration");
24
25
  var _createInlineChangedDecoration = require("../decorations/createInlineChangedDecoration");
25
26
  var _createNodeChangedDecorationWidget = require("../decorations/createNodeChangedDecorationWidget");
26
- var _attributions = require("../decorations/colorSchemes/attributions");
27
27
  var _decorationKeys = require("../decorations/decorationKeys");
28
28
  var _extractContributorTags = require("../decorations/extractContributorTags");
29
29
  var _createDeletedLineBreakWidget = require("../decorations/utils/createDeletedLineBreakWidget");
30
30
  var _getAttrChangeRanges = require("../decorations/utils/getAttrChangeRanges");
31
- var _wrapBlockNodeView = require("../decorations/utils/wrapBlockNodeView");
32
31
  var _getMarkChangeRanges = require("../decorations/utils/getMarkChangeRanges");
32
+ var _wrapBlockNodeView = require("../decorations/utils/wrapBlockNodeView");
33
33
  var _getScrollableDecorations = require("../getScrollableDecorations");
34
34
  var _isExtendedEnabled = require("../isExtendedEnabled");
35
35
  var _emptyTextBlocks = require("../utils/emptyTextBlocks");
36
36
  var _diffBySteps = require("./diffBySteps");
37
37
  var _groupChangesByBlock = require("./groupChangesByBlock");
38
+ var _groupDeletedColumnChanges = require("./groupDeletedColumnChanges");
38
39
  var _isMarkOnlyChange = require("./isMarkOnlyChange");
39
40
  var _isOpenTokenOnlyChange = require("./isOpenTokenOnlyChange");
40
41
  var _optimizeChanges = require("./optimizeChanges");
41
- var _groupDeletedColumnChanges = require("./groupDeletedColumnChanges");
42
42
  var _selectTokenEncoder2 = require("./selectTokenEncoder");
43
43
  var _simplifyChangesWithAttribution = require("./simplifyChangesWithAttribution");
44
44
  var _simplifySteps = require("./simplifySteps");
@@ -513,7 +513,7 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref8
513
513
 
514
514
  // Still colours-only: a tags-only diff keeps the plain colour scheme.
515
515
  if (attributionColoringEnabled) {
516
- attributionColors = (0, _attributions.createAttributionColorMap)(simplifiedStepAttributions);
516
+ attributionColors = (0, _attributions.createAttributionColorMap)(simplifiedStepAttributions, contributors);
517
517
  }
518
518
  } else {
519
519
  var _changeset = _prosemirrorChangeset.ChangeSet.create(originalDoc, undefined, tokenEncoder).addSteps(steppedDoc, stepMaps, tr.doc);
@@ -12,6 +12,7 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
12
12
  var _utils = require("@atlaskit/editor-shared-styles/utils");
13
13
  var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
14
14
  var _fg = require("@atlaskit/platform-feature-flags/fg");
15
+ var _showDiffPluginType = require("../../../showDiffPluginType");
15
16
  var _types = require("./types");
16
17
  var _excluded = ["attribution", "connectedTo"];
17
18
  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; }
@@ -95,6 +96,16 @@ var getAttributionKey = exports.getAttributionKey = function getAttributionKey(a
95
96
  var _getAttributionIdenti;
96
97
  return (_getAttributionIdenti = getAttributionIdentity(attribution)) === null || _getAttributionIdenti === void 0 ? void 0 : _getAttributionIdenti.key;
97
98
  };
99
+ var isDiffAgentBrand = function isDiffAgentBrand(agentBrand) {
100
+ return agentBrand !== undefined && _showDiffPluginType.DIFF_AGENT_BRANDS.has(agentBrand);
101
+ };
102
+
103
+ /** Prefers the resolved branded profile over the raw attribution agent type. */
104
+ var getAgentBrandForColor = function getAgentBrandForColor(attribution, contributors) {
105
+ var _contributors, _getAttributionKey;
106
+ var agentBrand = contributors === null || contributors === void 0 || (_contributors = contributors[(_getAttributionKey = getAttributionKey(attribution)) !== null && _getAttributionKey !== void 0 ? _getAttributionKey : '']) === null || _contributors === void 0 ? void 0 : _contributors.agentKind;
107
+ return isDiffAgentBrand(agentBrand) ? agentBrand : attribution === null || attribution === void 0 ? void 0 : attribution.agentType;
108
+ };
98
109
 
99
110
  /**
100
111
  * Public contributor list to internal key-addressed record. A contributor whose attribution carries
@@ -154,7 +165,7 @@ var isContributorTagsEnabled = exports.isContributorTagsEnabled = function isCon
154
165
  return getAttributionKey(attribution) !== undefined;
155
166
  })) && contributors !== undefined && Object.keys(contributors).length > 0;
156
167
  };
157
- var createAttributionColorMap = exports.createAttributionColorMap = function createAttributionColorMap(stepAttributions) {
168
+ var createAttributionColorMap = exports.createAttributionColorMap = function createAttributionColorMap(stepAttributions, contributors) {
158
169
  var colors = new Map();
159
170
  var allocatedColors = new Set();
160
171
 
@@ -169,7 +180,7 @@ var createAttributionColorMap = exports.createAttributionColorMap = function cre
169
180
  if (!identity) {
170
181
  continue;
171
182
  }
172
- var _getParticipantColor = (0, _utils.getParticipantColor)(identity.colorSeed, attribution === null || attribution === void 0 ? void 0 : attribution.agentType),
183
+ var _getParticipantColor = (0, _utils.getParticipantColor)(identity.colorSeed, getAgentBrandForColor(attribution, contributors)),
173
184
  index = _getParticipantColor.index,
174
185
  isFixed = _getParticipantColor.isFixed;
175
186
  var color = HASHED_PARTICIPANT_COLOR_SCHEMES[index];
@@ -192,7 +203,7 @@ var createAttributionColorMap = exports.createAttributionColorMap = function cre
192
203
  if (!_identity || colors.has(_identity.key)) {
193
204
  continue;
194
205
  }
195
- var _getParticipantColor2 = (0, _utils.getParticipantColor)(_identity.colorSeed, _attribution === null || _attribution === void 0 ? void 0 : _attribution.agentType),
206
+ var _getParticipantColor2 = (0, _utils.getParticipantColor)(_identity.colorSeed, getAgentBrandForColor(_attribution, contributors)),
196
207
  _index = _getParticipantColor2.index;
197
208
  var hashedColor = getSlotColor(_index);
198
209
  if (!hashedColor) {
@@ -88,6 +88,17 @@ var edgeCases = function edgeCases(doc, from) {
88
88
  if (!node.firstChild) {
89
89
  return undefined;
90
90
  }
91
+ if ((0, _fg.fg)('platform_editor_ai_show_diff_patch_2')) {
92
+ // The row retains its full width when the table scrolls. Centering that
93
+ // width against the editor would push the anchor off-screen. Measure the
94
+ // visible container's edge instead, including start-aligned tables.
95
+ return {
96
+ beforePos: beforePos,
97
+ measurePos: beforePos,
98
+ measureSelector: '.pm-table-container',
99
+ measureLeft: true
100
+ };
101
+ }
91
102
 
92
103
  // Measure the first row (`nodeStart` is just inside the table, i.e. the
93
104
  // position of the first row): its width matches the table's.
@@ -175,19 +186,28 @@ var createLeftAnchorWidget = exports.createLeftAnchorWidget = function createLef
175
186
  var nodeDOM = view.nodeDOM(edgeCase.measurePos);
176
187
  var dom = edgeCase.measureSelector && nodeDOM instanceof HTMLElement ? (_nodeDOM$querySelecto = nodeDOM.querySelector(edgeCase.measureSelector)) !== null && _nodeDOM$querySelecto !== void 0 ? _nodeDOM$querySelecto : nodeDOM : nodeDOM;
177
188
  if (dom instanceof HTMLElement) {
178
- // The left anchor only needs the container width so the
179
- // IndicatorBar can align against the block's horizontal extent.
180
- anchor.style.setProperty('width', "".concat(dom.offsetWidth, "px"));
189
+ var updateAnchor = function updateAnchor() {
190
+ if (getPos() === undefined) {
191
+ return;
192
+ }
193
+ if (edgeCase.measureLeft) {
194
+ var left = dom.getBoundingClientRect().left - wrapper.getBoundingClientRect().left;
195
+ anchor.style.setProperty('left', "".concat(left, "px"));
196
+ anchor.style.setProperty('transform', 'none');
197
+ }
198
+ anchor.style.setProperty('width', "".concat(dom.offsetWidth, "px"));
199
+ };
200
+ // Align against the block's horizontal extent.
201
+ updateAnchor();
181
202
 
182
203
  // Observe the measured element for size changes (e.g. page
183
204
  // resize) so the indicator stays aligned. CCI-17981
184
205
  if (!leftResizeObserver) {
185
- leftResizeObserver = new ResizeObserver(function () {
186
- if (getPos() !== undefined) {
187
- anchor.style.setProperty('width', "".concat(dom.offsetWidth, "px"));
188
- }
189
- });
206
+ leftResizeObserver = new ResizeObserver(updateAnchor);
190
207
  leftResizeObserver.observe(dom);
208
+ if (edgeCase.measureLeft) {
209
+ leftResizeObserver.observe(wrapper);
210
+ }
191
211
  }
192
212
  }
193
213
  };
@@ -17,9 +17,9 @@ var _taggableBlockNodes = require("../utils/taggableBlockNodes");
17
17
  var _factory = require("./colorSchemes/factory");
18
18
  var _schemes = require("./colorSchemes/schemes");
19
19
  var _createAnchorDecorationWidgets = require("./createAnchorDecorationWidgets");
20
+ var _createBlockChangedDecorationStyles = require("./createBlockChangedDecoration.styles.legacy");
20
21
  var _createContributorTagWidget = require("./createContributorTagWidget");
21
22
  var _decorationKeys = require("./decorationKeys");
22
- var _createBlockChangedDecorationStyles = require("./createBlockChangedDecoration.styles.legacy");
23
23
  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; }
24
24
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
25
25
  var displayNoneStyle = (0, _lazyNodeView.convertToInlineCss)({
@@ -22,8 +22,8 @@ var _createChangedRowDecorationWidgetsStyles = require("./createChangedRowDecora
22
22
  var _createContributorTagWidget = require("./createContributorTagWidget");
23
23
  var _decorationKeys = require("./decorationKeys");
24
24
  var _findSafeInsertPos = require("./utils/findSafeInsertPos");
25
- var _wrapBlockNodeView = require("./utils/wrapBlockNodeView");
26
25
  var _tableCellEdgeAttrs = require("./utils/tableCellEdgeAttrs");
26
+ var _wrapBlockNodeView = require("./utils/wrapBlockNodeView");
27
27
  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; }
28
28
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
29
29
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
@@ -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) {
@@ -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.
@@ -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
@@ -9,26 +9,26 @@ import { TableMap } from '@atlaskit/editor-tables/table-map';
9
9
  import { UNSAFE_expValNoExposure } from '@atlaskit/platform-feature-experiments/unsafe-exp-val-no-exposure';
10
10
  import { fg } from '@atlaskit/platform-feature-flags/fg';
11
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';
12
13
  import { createDocMarginAnchorWidget } from '../decorations/createAnchorDecorationWidgets';
13
14
  import { createBlockChangedDecoration } from '../decorations/createBlockChangedDecoration';
14
15
  import { createInlineChangedDecoration } from '../decorations/createInlineChangedDecoration';
15
16
  import { createNodeChangedDecorationWidget } from '../decorations/createNodeChangedDecorationWidget';
16
- import { createAttributionColorMap, getAttributionKey, getAttributionKeyForChange, getColorSchemeForChange, isAttributionColoringEnabled, isContributorTagsEnabled } from '../decorations/colorSchemes/attributions';
17
17
  import { extractDiffDescriptors } from '../decorations/decorationKeys';
18
18
  import { extractContributorTags } from '../decorations/extractContributorTags';
19
19
  import { createDeletedLineBreakDecoration } from '../decorations/utils/createDeletedLineBreakWidget';
20
20
  import { getAttrChangeRanges, stepIsValidAttrChange } from '../decorations/utils/getAttrChangeRanges';
21
- import { createRemovedLozenge } from '../decorations/utils/wrapBlockNodeView';
22
21
  import { getMarkChangeRanges } from '../decorations/utils/getMarkChangeRanges';
22
+ import { createRemovedLozenge } from '../decorations/utils/wrapBlockNodeView';
23
23
  import { getScrollableDecorations } from '../getScrollableDecorations';
24
24
  import { getDefaultDiffType, isExtendedEnabled } from '../isExtendedEnabled';
25
25
  import { emptyTextBlockContentPositions } from '../utils/emptyTextBlocks';
26
26
  import { diffBySteps } from './diffBySteps';
27
27
  import { groupChangesByBlock } from './groupChangesByBlock';
28
+ import { CELL_CONTENT_OFFSET, groupDeletedColumnChanges } from './groupDeletedColumnChanges';
28
29
  import { isMarkOnlyChange } from './isMarkOnlyChange';
29
30
  import { isOpenTokenOnlyChange } from './isOpenTokenOnlyChange';
30
31
  import { optimizeChanges } from './optimizeChanges';
31
- import { CELL_CONTENT_OFFSET, groupDeletedColumnChanges } from './groupDeletedColumnChanges';
32
32
  import { selectTokenEncoder } from './selectTokenEncoder';
33
33
  import { collapseOverlappingChanges, simplifyChangesWithAttribution } from './simplifyChangesWithAttribution';
34
34
  import { simplifySteps, simplifyStepsWithAttribution } from './simplifySteps';
@@ -464,7 +464,7 @@ const calculateDiffDecorationsInner = ({
464
464
 
465
465
  // Still colours-only: a tags-only diff keeps the plain colour scheme.
466
466
  if (attributionColoringEnabled) {
467
- attributionColors = createAttributionColorMap(simplifiedStepAttributions);
467
+ attributionColors = createAttributionColorMap(simplifiedStepAttributions, contributors);
468
468
  }
469
469
  } else {
470
470
  const changeset = ChangeSet.create(originalDoc, undefined, tokenEncoder).addSteps(steppedDoc, stepMaps, tr.doc);
@@ -1,6 +1,7 @@
1
1
  import { getParticipantColor } from '@atlaskit/editor-shared-styles/utils';
2
2
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
3
3
  import { fg } from '@atlaskit/platform-feature-flags/fg';
4
+ import { DIFF_AGENT_BRANDS } from '../../../showDiffPluginType';
4
5
  import { PARTICIPANT_COLOR_SCHEMES } from './types';
5
6
 
6
7
  /** A contributor with both of its identities collapsed to internal attribution keys. */
@@ -77,6 +78,14 @@ export const getAttributionKey = attribution => {
77
78
  var _getAttributionIdenti;
78
79
  return (_getAttributionIdenti = getAttributionIdentity(attribution)) === null || _getAttributionIdenti === void 0 ? void 0 : _getAttributionIdenti.key;
79
80
  };
81
+ const isDiffAgentBrand = agentBrand => agentBrand !== undefined && DIFF_AGENT_BRANDS.has(agentBrand);
82
+
83
+ /** Prefers the resolved branded profile over the raw attribution agent type. */
84
+ const getAgentBrandForColor = (attribution, contributors) => {
85
+ var _contributors, _getAttributionKey;
86
+ const agentBrand = contributors === null || contributors === void 0 ? void 0 : (_contributors = contributors[(_getAttributionKey = getAttributionKey(attribution)) !== null && _getAttributionKey !== void 0 ? _getAttributionKey : '']) === null || _contributors === void 0 ? void 0 : _contributors.agentKind;
87
+ return isDiffAgentBrand(agentBrand) ? agentBrand : attribution === null || attribution === void 0 ? void 0 : attribution.agentType;
88
+ };
80
89
 
81
90
  /**
82
91
  * Public contributor list to internal key-addressed record. A contributor whose attribution carries
@@ -123,7 +132,7 @@ export const isAttributionColoringEnabled = stepAttributions => {
123
132
  * a tag only has to name one.
124
133
  */
125
134
  export const isContributorTagsEnabled = (stepAttributions, contributors) => areAttributionColorGatesEnabled() && Boolean(stepAttributions === null || stepAttributions === void 0 ? void 0 : stepAttributions.some(attribution => getAttributionKey(attribution) !== undefined)) && contributors !== undefined && Object.keys(contributors).length > 0;
126
- export const createAttributionColorMap = stepAttributions => {
135
+ export const createAttributionColorMap = (stepAttributions, contributors) => {
127
136
  const colors = new Map();
128
137
  const allocatedColors = new Set();
129
138
 
@@ -137,7 +146,7 @@ export const createAttributionColorMap = stepAttributions => {
137
146
  const {
138
147
  index,
139
148
  isFixed
140
- } = getParticipantColor(identity.colorSeed, attribution === null || attribution === void 0 ? void 0 : attribution.agentType);
149
+ } = getParticipantColor(identity.colorSeed, getAgentBrandForColor(attribution, contributors));
141
150
  const color = HASHED_PARTICIPANT_COLOR_SCHEMES[index];
142
151
  if (isFixed && color) {
143
152
  colors.set(identity.key, color);
@@ -151,7 +160,7 @@ export const createAttributionColorMap = stepAttributions => {
151
160
  }
152
161
  const {
153
162
  index
154
- } = getParticipantColor(identity.colorSeed, attribution === null || attribution === void 0 ? void 0 : attribution.agentType);
163
+ } = getParticipantColor(identity.colorSeed, getAgentBrandForColor(attribution, contributors));
155
164
  const hashedColor = getSlotColor(index);
156
165
  if (!hashedColor) {
157
166
  continue;
@@ -1,7 +1,6 @@
1
1
  import { agentBrandColorSchemes } from '@atlaskit/agent-color/agent-brand-color-schemes';
2
2
  import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
3
3
  import { getStandardDeletedTextDecorationStyle } from './getStandardDeletedTextDecorationStyle';
4
-
5
4
  /**
6
5
  * Hover highlight for deleted text under an 'onEmphasis' scheme. Inline styles cannot express
7
6
  * `:hover`, so the resting style resolves its background from this property and
@@ -79,6 +79,17 @@ const edgeCases = (doc, from) => {
79
79
  if (!node.firstChild) {
80
80
  return undefined;
81
81
  }
82
+ if (fg('platform_editor_ai_show_diff_patch_2')) {
83
+ // The row retains its full width when the table scrolls. Centering that
84
+ // width against the editor would push the anchor off-screen. Measure the
85
+ // visible container's edge instead, including start-aligned tables.
86
+ return {
87
+ beforePos,
88
+ measurePos: beforePos,
89
+ measureSelector: '.pm-table-container',
90
+ measureLeft: true
91
+ };
92
+ }
82
93
 
83
94
  // Measure the first row (`nodeStart` is just inside the table, i.e. the
84
95
  // position of the first row): its width matches the table's.
@@ -169,19 +180,28 @@ export const createLeftAnchorWidget = ({
169
180
  const nodeDOM = view.nodeDOM(edgeCase.measurePos);
170
181
  const dom = edgeCase.measureSelector && nodeDOM instanceof HTMLElement ? (_nodeDOM$querySelecto = nodeDOM.querySelector(edgeCase.measureSelector)) !== null && _nodeDOM$querySelecto !== void 0 ? _nodeDOM$querySelecto : nodeDOM : nodeDOM;
171
182
  if (dom instanceof HTMLElement) {
172
- // The left anchor only needs the container width so the
173
- // IndicatorBar can align against the block's horizontal extent.
174
- anchor.style.setProperty('width', `${dom.offsetWidth}px`);
183
+ const updateAnchor = () => {
184
+ if (getPos() === undefined) {
185
+ return;
186
+ }
187
+ if (edgeCase.measureLeft) {
188
+ const left = dom.getBoundingClientRect().left - wrapper.getBoundingClientRect().left;
189
+ anchor.style.setProperty('left', `${left}px`);
190
+ anchor.style.setProperty('transform', 'none');
191
+ }
192
+ anchor.style.setProperty('width', `${dom.offsetWidth}px`);
193
+ };
194
+ // Align against the block's horizontal extent.
195
+ updateAnchor();
175
196
 
176
197
  // Observe the measured element for size changes (e.g. page
177
198
  // resize) so the indicator stays aligned. CCI-17981
178
199
  if (!leftResizeObserver) {
179
- leftResizeObserver = new ResizeObserver(() => {
180
- if (getPos() !== undefined) {
181
- anchor.style.setProperty('width', `${dom.offsetWidth}px`);
182
- }
183
- });
200
+ leftResizeObserver = new ResizeObserver(updateAnchor);
184
201
  leftResizeObserver.observe(dom);
202
+ if (edgeCase.measureLeft) {
203
+ leftResizeObserver.observe(wrapper);
204
+ }
185
205
  }
186
206
  }
187
207
  };
@@ -8,9 +8,9 @@ import { isTaggableBlockNode } from '../utils/taggableBlockNodes';
8
8
  import { buildAddedCellOverlayRoundedStyle, buildAddedCellOverlayStyle, buildDeletedBlockNodeStyle, buildDeletedCellOverlayRoundedStyle, buildDeletedCellOverlayStyle, buildInsertedBlockNodeStyle } from './colorSchemes/factory';
9
9
  import { colorSchemeRegistry, getLegacyColorScheme } from './colorSchemes/schemes';
10
10
  import { createBlockIndicatorAnchorWidgets } from './createAnchorDecorationWidgets';
11
+ import { getBlockNodeStyleLegacy, resolveCellOverlayStyleLegacy } from './createBlockChangedDecoration.styles.legacy';
11
12
  import { createContributorTagWidget, isContributorTagWidgetEnabled } from './createContributorTagWidget';
12
13
  import { AnchorTypeKey, buildDiffDecorationSpec, buildAnchorDecorationKey, scrollMarginTopStyle } from './decorationKeys';
13
- import { getBlockNodeStyleLegacy, resolveCellOverlayStyleLegacy } from './createBlockChangedDecoration.styles.legacy';
14
14
  const displayNoneStyle = convertToInlineCss({
15
15
  display: 'none'
16
16
  });