@atlaskit/editor-plugin-show-diff 14.5.2 → 15.0.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 (76) hide show
  1. package/CHANGELOG.md +34 -6
  2. package/afm-cc/tsconfig.json +0 -12
  3. package/afm-products/tsconfig.json +0 -12
  4. package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +3 -9
  5. package/dist/cjs/pm-plugins/calculateDiff/smart/classifySmartChanges.js +1 -2
  6. package/dist/cjs/pm-plugins/decorations/colorSchemes/attributions.js +21 -4
  7. package/dist/cjs/pm-plugins/decorations/colorSchemes/factory.js +6 -56
  8. package/dist/cjs/pm-plugins/decorations/colorSchemes/schemes.js +6 -20
  9. package/dist/cjs/pm-plugins/decorations/colorSchemes/types.js +4 -6
  10. package/dist/cjs/pm-plugins/decorations/createChangedRowDecorationWidgets.js +1 -2
  11. package/dist/cjs/pm-plugins/decorations/createContributorTagWidget.js +14 -29
  12. package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +1 -2
  13. package/dist/cjs/pm-plugins/decorations/utils/getAttrChangeRanges.js +2 -25
  14. package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +1 -2
  15. package/dist/cjs/pm-plugins/main.js +4 -4
  16. package/dist/cjs/showDiffPlugin.js +4 -5
  17. package/dist/cjs/ui/ContributorTag/buildContributorTagDom.js +122 -0
  18. package/dist/cjs/ui/ContributorTag/contributorAvatarRenderer.js +140 -0
  19. package/dist/cjs/ui/ContributorTag/contributorTagController.js +500 -0
  20. package/dist/cjs/ui/ContributorTag/contributorTagIcons.js +46 -0
  21. package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +3 -5
  22. package/dist/es2019/pm-plugins/calculateDiff/smart/classifySmartChanges.js +1 -2
  23. package/dist/es2019/pm-plugins/decorations/colorSchemes/attributions.js +20 -3
  24. package/dist/es2019/pm-plugins/decorations/colorSchemes/factory.js +6 -55
  25. package/dist/es2019/pm-plugins/decorations/colorSchemes/schemes.js +14 -26
  26. package/dist/es2019/pm-plugins/decorations/colorSchemes/types.js +4 -6
  27. package/dist/es2019/pm-plugins/decorations/createChangedRowDecorationWidgets.js +1 -2
  28. package/dist/es2019/pm-plugins/decorations/createContributorTagWidget.js +16 -30
  29. package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +1 -2
  30. package/dist/es2019/pm-plugins/decorations/utils/getAttrChangeRanges.js +2 -17
  31. package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +1 -2
  32. package/dist/es2019/pm-plugins/main.js +4 -4
  33. package/dist/es2019/showDiffPlugin.js +4 -5
  34. package/dist/es2019/ui/ContributorTag/buildContributorTagDom.js +110 -0
  35. package/dist/es2019/ui/ContributorTag/contributorAvatarRenderer.js +136 -0
  36. package/dist/es2019/ui/ContributorTag/contributorTagController.js +403 -0
  37. package/dist/es2019/ui/ContributorTag/contributorTagIcons.js +40 -0
  38. package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +3 -9
  39. package/dist/esm/pm-plugins/calculateDiff/smart/classifySmartChanges.js +1 -2
  40. package/dist/esm/pm-plugins/decorations/colorSchemes/attributions.js +21 -4
  41. package/dist/esm/pm-plugins/decorations/colorSchemes/factory.js +6 -57
  42. package/dist/esm/pm-plugins/decorations/colorSchemes/schemes.js +7 -20
  43. package/dist/esm/pm-plugins/decorations/colorSchemes/types.js +4 -6
  44. package/dist/esm/pm-plugins/decorations/createChangedRowDecorationWidgets.js +1 -2
  45. package/dist/esm/pm-plugins/decorations/createContributorTagWidget.js +15 -30
  46. package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +1 -2
  47. package/dist/esm/pm-plugins/decorations/utils/getAttrChangeRanges.js +2 -25
  48. package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +1 -2
  49. package/dist/esm/pm-plugins/main.js +4 -4
  50. package/dist/esm/showDiffPlugin.js +4 -5
  51. package/dist/esm/ui/ContributorTag/buildContributorTagDom.js +115 -0
  52. package/dist/esm/ui/ContributorTag/contributorAvatarRenderer.js +135 -0
  53. package/dist/esm/ui/ContributorTag/contributorTagController.js +493 -0
  54. package/dist/esm/ui/ContributorTag/contributorTagIcons.js +40 -0
  55. package/dist/types/pm-plugins/decorations/colorSchemes/attributions.d.ts +3 -3
  56. package/dist/types/pm-plugins/decorations/colorSchemes/factory.d.ts +2 -2
  57. package/dist/types/pm-plugins/decorations/colorSchemes/schemes.d.ts +1 -1
  58. package/dist/types/pm-plugins/decorations/colorSchemes/types.d.ts +13 -16
  59. package/dist/types/pm-plugins/decorations/createContributorTagWidget.d.ts +11 -9
  60. package/dist/types/pm-plugins/main.d.ts +1 -2
  61. package/dist/types/ui/ContributorTag/buildContributorTagDom.d.ts +25 -0
  62. package/dist/types/ui/ContributorTag/contributorAvatarRenderer.d.ts +22 -0
  63. package/dist/types/ui/ContributorTag/contributorTagController.d.ts +85 -0
  64. package/dist/types/ui/ContributorTag/contributorTagIcons.d.ts +12 -0
  65. package/package.json +9 -13
  66. package/dist/cjs/ui/ContributorTag/ContributorTag.compiled.css +0 -29
  67. package/dist/cjs/ui/ContributorTag/ContributorTag.js +0 -383
  68. package/dist/cjs/ui/ContributorTag/ContributorTagWidget.js +0 -50
  69. package/dist/es2019/ui/ContributorTag/ContributorTag.compiled.css +0 -29
  70. package/dist/es2019/ui/ContributorTag/ContributorTag.js +0 -312
  71. package/dist/es2019/ui/ContributorTag/ContributorTagWidget.js +0 -43
  72. package/dist/esm/ui/ContributorTag/ContributorTag.compiled.css +0 -29
  73. package/dist/esm/ui/ContributorTag/ContributorTag.js +0 -375
  74. package/dist/esm/ui/ContributorTag/ContributorTagWidget.js +0 -43
  75. package/dist/types/ui/ContributorTag/ContributorTag.d.ts +0 -37
  76. package/dist/types/ui/ContributorTag/ContributorTagWidget.d.ts +0 -22
package/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # @atlaskit/editor-plugin-show-diff
2
2
 
3
+ ## 15.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 15.0.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`d03fb7d6bfd0f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d03fb7d6bfd0f) -
14
+ Map attribution colour schemes onto ten ADS accent hues, render them with the bolder participant
15
+ treatment, and allocate the next available colour when participant hashes collide.
16
+ - [`1d5a7cbfd029e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1d5a7cbfd029e) -
17
+ The diff contributor tag is now drawn as plain DOM by its own widget decoration, following the
18
+ vanilla `@mention` node-view approach, so it needs no React portal into the editor. `react-dom`
19
+ stays a peer dependency for the rest of the plugin's React UI; `@atlaskit/tooltip`,
20
+ `@atlaskit/visually-hidden`, `@atlaskit/icon-lab` and `@atlaskit/logo` are no longer dependencies,
21
+ and only `@atlaskit/avatar`'s size constants are still used.
22
+
23
+ The tag's tooltip is now always the full "Changed by" label, rather than only appearing when the
24
+ name it draws is clipped.
25
+
26
+ ### Patch Changes
27
+
28
+ - [`35f8ff3c9ce4f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/35f8ff3c9ce4f) -
29
+ Clean up the released `platform_editor_improve_inline_diffs` experiment and remove the obsolete
30
+ editor experiment migration entry point.
31
+ - Updated dependencies
32
+
3
33
  ## 14.5.2
4
34
 
5
35
  ### Patch Changes
@@ -44,15 +74,13 @@
44
74
 
45
75
  ### Minor Changes
46
76
 
47
- - [`844f6fce7d9c4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/844f6fce7d9c4) -
48
- Render the diff contributor tag from its own widget decoration instead of positioning an overlay
49
- with CSS anchor positioning, and declare react-dom as a peer dependency for the portal into that
50
- widget. Behind the confluence_ncs_step_diffing_version_history gate.
51
77
  - [`844f6fce7d9c4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/844f6fce7d9c4) -
52
78
  [ux] Attributed diff changes now render a contributor tag naming who made the change, tinted to
53
79
  match the change's attribution colour, behind the `confluence_ncs_step_diffing_version_history`
54
- gate. Adds an optional `contributorProfiles` list to the attributed `showDiff` params, from which
55
- the plugin resolves the contributors it credits.
80
+ gate. The tag renders from its own widget decoration rather than a CSS-anchor-positioned overlay,
81
+ and `react-dom` is declared as a peer dependency for the portal into that widget. Adds an optional
82
+ `contributorProfiles` list to the attributed `showDiff` params, from which the plugin resolves the
83
+ contributors it credits.
56
84
 
57
85
  ### Patch Changes
58
86
 
@@ -41,12 +41,6 @@
41
41
  {
42
42
  "path": "../../editor-tables/afm-cc/tsconfig.json"
43
43
  },
44
- {
45
- "path": "../../../design-system/icon-lab/afm-cc/tsconfig.json"
46
- },
47
- {
48
- "path": "../../../design-system/logo/afm-cc/tsconfig.json"
49
- },
50
44
  {
51
45
  "path": "../../../platform/feature-experiments/afm-cc/tsconfig.json"
52
46
  },
@@ -62,12 +56,6 @@
62
56
  {
63
57
  "path": "../../../design-system/tokens/afm-cc/tsconfig.json"
64
58
  },
65
- {
66
- "path": "../../../design-system/tooltip/afm-cc/tsconfig.json"
67
- },
68
- {
69
- "path": "../../../design-system/visually-hidden/afm-cc/tsconfig.json"
70
- },
71
59
  {
72
60
  "path": "../../editor-common/afm-cc/tsconfig.json"
73
61
  }
@@ -41,12 +41,6 @@
41
41
  {
42
42
  "path": "../../editor-tables/afm-products/tsconfig.json"
43
43
  },
44
- {
45
- "path": "../../../design-system/icon-lab/afm-products/tsconfig.json"
46
- },
47
- {
48
- "path": "../../../design-system/logo/afm-products/tsconfig.json"
49
- },
50
44
  {
51
45
  "path": "../../../platform/feature-experiments/afm-products/tsconfig.json"
52
46
  },
@@ -62,12 +56,6 @@
62
56
  {
63
57
  "path": "../../../design-system/tokens/afm-products/tsconfig.json"
64
58
  },
65
- {
66
- "path": "../../../design-system/tooltip/afm-products/tsconfig.json"
67
- },
68
- {
69
- "path": "../../../design-system/visually-hidden/afm-products/tsconfig.json"
70
- },
71
59
  {
72
60
  "path": "../../editor-common/afm-products/tsconfig.json"
73
61
  }
@@ -11,7 +11,6 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
11
11
  var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
12
12
  var _memoizeOne = _interopRequireDefault(require("memoize-one"));
13
13
  var _prosemirrorChangeset = require("prosemirror-changeset");
14
- var _deprecatedPlatformFeatureExperiments = require("@atlaskit/editor-common/deprecated-platform-feature-experiments");
15
14
  var _document = require("@atlaskit/editor-common/utils/document");
16
15
  var _transform = require("@atlaskit/editor-prosemirror/transform");
17
16
  var _view = require("@atlaskit/editor-prosemirror/view");
@@ -625,26 +624,21 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
625
624
  if (change.isInline) {
626
625
  // Inline nodes (e.g. date, emoji, mention, status) need an inline decoration rather than a block decoration
627
626
  var isActive = isRangeActive(activeIndexPos, change.fromB, change.toB);
628
- var isAtomicInlineNodeFlag = (0, _deprecatedPlatformFeatureExperiments.isExperimentEnabled)('platform_editor_improve_inline_diffs', function () {
629
- return (0, _expValEquals.expValEquals)('platform_editor_improve_inline_diffs', 'isEnabled', true);
630
- });
631
627
  decorations.push.apply(decorations, (0, _toConsumableArray2.default)((0, _createInlineChangedDecoration.createInlineChangedDecoration)({
632
628
  change: change,
633
629
  colorScheme: colorScheme,
634
630
  isActive: isActive,
635
631
  isInserted: true,
636
- isAtomicInlineNode: isAtomicInlineNodeFlag,
632
+ isAtomicInlineNode: true,
637
633
  inlineNodeName: change.inlineNodeName,
638
634
  // Suppress the border-bottom underline for atomic inline nodeviews —
639
635
  // it doesn't render on custom nodeview DOM elements and is unnecessary noise.
640
- hideAddedDiffsUnderline: isAtomicInlineNodeFlag,
636
+ hideAddedDiffsUnderline: true,
641
637
  diffType: diffType
642
638
  })));
643
639
  // If we have the original node position, also render the old node as a "deleted" widget
644
640
  // so the user can see what it looked like before the change.
645
- if (change.fromA !== undefined && change.toA !== undefined && (0, _deprecatedPlatformFeatureExperiments.isExperimentEnabled)('platform_editor_improve_inline_diffs', function () {
646
- return (0, _expValEquals.expValEquals)('platform_editor_improve_inline_diffs', 'isEnabled', true);
647
- })) {
641
+ if (change.fromA !== undefined && change.toA !== undefined) {
648
642
  decorations.push.apply(decorations, (0, _toConsumableArray2.default)((0, _createNodeChangedDecorationWidget.createNodeChangedDecorationWidget)({
649
643
  change: {
650
644
  fromA: change.fromA,
@@ -219,7 +219,6 @@ var TEXT_BLOCK_TYPES = new Set(['paragraph', 'heading']);
219
219
  * layoutColumn → layoutSection, tableCell/tableHeader → tableRow → table.
220
220
  */
221
221
  var RIGID_CHILD_TYPES = new Set(['layoutColumn', 'tableCell', 'tableHeader']);
222
- var TABLE_TYPE = 'table';
223
222
 
224
223
  /**
225
224
  * Emit a single whole-block (node-level) change covering both sides of a group. Used for
@@ -546,7 +545,7 @@ var classifyContainer = function classifyContainer(blockA, blockB, changes, orig
546
545
  var typeName = blockB.node.type.name;
547
546
 
548
547
  // Tables need cell-level counting across rows; handle them specially.
549
- if (typeName === TABLE_TYPE) {
548
+ if (typeName === 'table') {
550
549
  return classifyTable(blockA, blockB, changes, originalDoc, newDoc, locale, thresholds);
551
550
  }
552
551
 
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.resolveContributors = exports.isContributorTagsEnabled = exports.isAttributionColoringEnabled = exports.getColorSchemeForChange = exports.getAttributionKeyForChange = exports.getAttributionKey = exports.createAttributionColorMap = exports.areAttributionColorGatesEnabled = void 0;
8
8
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
9
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
10
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
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");
@@ -23,6 +23,19 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
23
23
 
24
24
  /** Contributors addressed by attribution key. The key format is internal. */
25
25
 
26
+ /** Maps the shared 18-slot telepointer palette onto the ten bolder diff colours. */
27
+ var HASHED_PARTICIPANT_COLOR_SCHEMES = [].concat((0, _toConsumableArray2.default)(_types.PARTICIPANT_COLOR_SCHEMES), ['blue', 'red', 'orange', 'yellow', 'green', 'teal', 'purple', 'magenta']);
28
+ var getAvailableColor = function getAvailableColor(hashedColor, allocatedColors) {
29
+ var startIndex = _types.PARTICIPANT_COLOR_SCHEMES.indexOf(hashedColor);
30
+ for (var offset = 0; offset < _types.PARTICIPANT_COLOR_SCHEMES.length; offset++) {
31
+ var color = _types.PARTICIPANT_COLOR_SCHEMES[(startIndex + offset) % _types.PARTICIPANT_COLOR_SCHEMES.length];
32
+ if (color && !allocatedColors.has(color)) {
33
+ return color;
34
+ }
35
+ }
36
+ return hashedColor;
37
+ };
38
+
26
39
  /**
27
40
  * Normalise the attribution identity once so a valid lookup key always has a valid participant
28
41
  * colour seed. `userId` is primary; `agentId`, or `agentType` as its fallback, separates shared
@@ -118,6 +131,7 @@ var isContributorTagsEnabled = exports.isContributorTagsEnabled = function isCon
118
131
  };
119
132
  var createAttributionColorMap = exports.createAttributionColorMap = function createAttributionColorMap(stepAttributions) {
120
133
  var colors = new Map();
134
+ var allocatedColors = new Set();
121
135
  var _iterator2 = _createForOfIteratorHelper(stepAttributions),
122
136
  _step2;
123
137
  try {
@@ -129,10 +143,13 @@ var createAttributionColorMap = exports.createAttributionColorMap = function cre
129
143
  }
130
144
  var _getParticipantColor = (0, _utils.getParticipantColor)(identity.colorSeed),
131
145
  index = _getParticipantColor.index;
132
- var participantColorScheme = _types.PARTICIPANT_COLOR_SCHEMES[index];
133
- if (participantColorScheme) {
134
- colors.set(identity.key, participantColorScheme);
146
+ var hashedColor = HASHED_PARTICIPANT_COLOR_SCHEMES[index];
147
+ if (!hashedColor) {
148
+ continue;
135
149
  }
150
+ var participantColorScheme = getAvailableColor(hashedColor, allocatedColors);
151
+ colors.set(identity.key, participantColorScheme);
152
+ allocatedColors.add(participantColorScheme);
136
153
  }
137
154
  } catch (err) {
138
155
  _iterator2.e(err);
@@ -68,8 +68,6 @@ exports.buildInsertedInlineStyle = buildInsertedInlineStyle;
68
68
  exports.getAccentTokens = getAccentTokens;
69
69
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
70
70
  var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
71
- var _constants = require("@atlaskit/editor-shared-styles/constants");
72
- var _types = require("./types");
73
71
  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; }
74
72
  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; }
75
73
  // token() is a build-time transform needing static literals, so pre-compute every colour's
@@ -147,71 +145,23 @@ var textAccentMap = {
147
145
  gray: "var(--ds-text-accent-gray, #505258)",
148
146
  lime: "var(--ds-text-accent-lime, #4C6B1F)"
149
147
  };
150
-
151
- /** Pressed counterpart of each participant's diff-safe SVG background tint. */
152
- var participantPressedBackgroundMap = {
153
- 'red-bolder': bgSubtlerPressedMap.red,
154
- 'blue-bolder': bgSubtlerPressedMap.blue,
155
- 'green-bolder': bgSubtlerPressedMap.green,
156
- 'yellow-bolder': bgSubtlerPressedMap.yellow,
157
- 'purple-bolder': bgSubtlerPressedMap.purple,
158
- 'magenta-bolder': bgSubtlerPressedMap.magenta,
159
- 'teal-bolder': bgSubtlerPressedMap.teal,
160
- 'orange-bolder': bgSubtlerPressedMap.orange,
161
- 'lime-bolder': bgSubtlerPressedMap.lime,
162
- 'gray-bolder': bgSubtlerPressedMap.gray,
163
- 'blue-subtle': bgSubtlestPressedMap.blue,
164
- 'red-subtle': bgSubtlestPressedMap.red,
165
- 'orange-subtle': bgSubtlestPressedMap.orange,
166
- 'yellow-subtle': bgSubtlestPressedMap.yellow,
167
- 'green-subtle': bgSubtlestPressedMap.green,
168
- 'teal-subtle': bgSubtlestPressedMap.teal,
169
- 'purple-subtle': bgSubtlestPressedMap.purple,
170
- 'magenta-subtle': bgSubtlestPressedMap.magenta
171
- };
172
- /**
173
- * Telepointers can put inverse text directly on their bolder colour. Diff colours sit behind
174
- * arbitrary document content, so use the participant SVG tint and its matching pressed token for
175
- * diff backgrounds. Borders and rings use the exact participant colour, preserving all 18
176
- * bolder/subtle slots while keeping every value in the shared ADS participant palette.
177
- */
178
- var participantColorTokenSets = Object.fromEntries(_types.PARTICIPANT_COLOR_SCHEMES.map(function (scheme, index) {
179
- var participantColor = _constants.participantColors[index];
180
- if (!participantColor) {
181
- throw new Error("Missing shared participant colour for show-diff slot ".concat(index));
182
- }
183
- return [scheme, {
184
- backgroundSubtlest: participantColor.svgBackgroundColor,
185
- backgroundSubtlestPressed: participantPressedBackgroundMap[scheme],
186
- backgroundSubtler: participantColor.svgBackgroundColor,
187
- backgroundSubtlerPressed: participantPressedBackgroundMap[scheme],
188
- borderAccent: participantColor.backgroundColor,
189
- // The first ten bolder colours are safe as accents on the editor surface. The
190
- // remaining subtle colours use their paired dark participant text colour.
191
- textAccent: index < 10 ? participantColor.backgroundColor : participantColor.textColor
192
- }];
193
- }));
194
- var participantColorSchemeSet = new Set(_types.PARTICIPANT_COLOR_SCHEMES);
195
- var isParticipantColorScheme = function isParticipantColorScheme(color) {
196
- return participantColorSchemeSet.has(color);
197
- };
198
148
  function bgSubtlest(color) {
199
- return isParticipantColorScheme(color) ? participantColorTokenSets[color].backgroundSubtlest : bgSubtlestMap[color];
149
+ return bgSubtlestMap[color];
200
150
  }
201
151
  function bgSubtlestPressed(color) {
202
- return isParticipantColorScheme(color) ? participantColorTokenSets[color].backgroundSubtlestPressed : bgSubtlestPressedMap[color];
152
+ return bgSubtlestPressedMap[color];
203
153
  }
204
154
  function bgSubtler(color) {
205
- return isParticipantColorScheme(color) ? participantColorTokenSets[color].backgroundSubtler : bgSubtlerMap[color];
155
+ return bgSubtlerMap[color];
206
156
  }
207
157
  function bgSubtlerPressed(color) {
208
- return isParticipantColorScheme(color) ? participantColorTokenSets[color].backgroundSubtlerPressed : bgSubtlerPressedMap[color];
158
+ return bgSubtlerPressedMap[color];
209
159
  }
210
160
  function borderAccent(color) {
211
- return isParticipantColorScheme(color) ? participantColorTokenSets[color].borderAccent : borderAccentMap[color];
161
+ return borderAccentMap[color];
212
162
  }
213
163
  function textAccent(color) {
214
- return isParticipantColorScheme(color) ? participantColorTokenSets[color].textAccent : textAccentMap[color];
164
+ return textAccentMap[color];
215
165
  }
216
166
 
217
167
  /** Presentation tokens for one diff colour, shared by highlights and contributor tags. */
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.traditionalScheme = exports.standardScheme = exports.getLegacyColorScheme = exports.colorSchemeRegistry = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _types = require("./types");
9
10
  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; }
10
11
  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; }
11
12
  /** Green insertions, red deletions. */
@@ -71,30 +72,15 @@ var createAttributionScheme = function createAttributionScheme(color) {
71
72
  deletedCellColor: color
72
73
  });
73
74
  };
75
+ var attributionColorSchemes = Object.fromEntries(_types.PARTICIPANT_COLOR_SCHEMES.map(function (color) {
76
+ return [color, createAttributionScheme(color)];
77
+ }));
74
78
 
75
79
  /** Maps public schemes and attribution-only participant slots to their data objects. */
76
- var colorSchemeRegistry = exports.colorSchemeRegistry = {
77
- 'red-bolder': createAttributionScheme('red-bolder'),
78
- 'blue-bolder': createAttributionScheme('blue-bolder'),
79
- 'green-bolder': createAttributionScheme('green-bolder'),
80
- 'yellow-bolder': createAttributionScheme('yellow-bolder'),
81
- 'purple-bolder': createAttributionScheme('purple-bolder'),
82
- 'magenta-bolder': createAttributionScheme('magenta-bolder'),
83
- 'teal-bolder': createAttributionScheme('teal-bolder'),
84
- 'orange-bolder': createAttributionScheme('orange-bolder'),
85
- 'lime-bolder': createAttributionScheme('lime-bolder'),
86
- 'gray-bolder': createAttributionScheme('gray-bolder'),
87
- 'blue-subtle': createAttributionScheme('blue-subtle'),
88
- 'red-subtle': createAttributionScheme('red-subtle'),
89
- 'orange-subtle': createAttributionScheme('orange-subtle'),
90
- 'yellow-subtle': createAttributionScheme('yellow-subtle'),
91
- 'green-subtle': createAttributionScheme('green-subtle'),
92
- 'teal-subtle': createAttributionScheme('teal-subtle'),
93
- 'purple-subtle': createAttributionScheme('purple-subtle'),
94
- 'magenta-subtle': createAttributionScheme('magenta-subtle'),
80
+ var colorSchemeRegistry = exports.colorSchemeRegistry = _objectSpread(_objectSpread({}, attributionColorSchemes), {}, {
95
81
  traditional: traditionalScheme,
96
82
  standard: standardScheme
97
- };
83
+ });
98
84
 
99
85
  /** Attribution accents are impossible in the refactor-off cohort; fall back defensively. */
100
86
  var getLegacyColorScheme = exports.getLegacyColorScheme = function getLegacyColorScheme(colorScheme) {
@@ -7,16 +7,14 @@ exports.PARTICIPANT_COLOR_SCHEMES = void 0;
7
7
  /** Schemes consumers may explicitly request through the show-diff API. */
8
8
 
9
9
  /** Attribution-only participant slots selected by the plugin, never by consumers. */
10
- var PARTICIPANT_COLOR_SCHEMES = exports.PARTICIPANT_COLOR_SCHEMES = ['red-bolder', 'blue-bolder', 'green-bolder', 'yellow-bolder', 'purple-bolder', 'magenta-bolder', 'teal-bolder', 'orange-bolder', 'lime-bolder', 'gray-bolder', 'blue-subtle', 'red-subtle', 'orange-subtle', 'yellow-subtle', 'green-subtle', 'teal-subtle', 'purple-subtle', 'magenta-subtle'];
10
+ var PARTICIPANT_COLOR_SCHEMES = exports.PARTICIPANT_COLOR_SCHEMES = ['red', 'blue', 'green', 'yellow', 'purple', 'magenta', 'teal', 'orange', 'lime', 'gray'];
11
11
 
12
12
  /** ADS accent hues used by the public and participant colour schemes. */
13
13
 
14
14
  /** A public scheme or an attribution participant slot resolved internally for one change. */
15
15
 
16
- /** A colour value that the factory expands into a complete set of diff-safe ADS tokens. */
17
-
18
16
  /**
19
- * A show-diff colour scheme. Colour fields are ADS hues or shared participant slots that
20
- * `factory.ts` expands into token paths; the rest encode structural differences no colour can
21
- * express. Ring widths, padding, radius and pointer-events are fixed in the factory, not per scheme.
17
+ * A show-diff colour scheme. Colour fields are ADS hues that `factory.ts` expands into token paths;
18
+ * the rest encode structural differences no colour can express. Ring widths, padding, radius and
19
+ * pointer-events are fixed in the factory, not per scheme.
22
20
  */
@@ -25,7 +25,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
25
25
  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; } } }; }
26
26
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
27
27
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
28
- var DEFAULT_COLOR_SCHEME = 'standard';
29
28
  /**
30
29
  * Extracts information about deleted table rows from a change
31
30
  */
@@ -137,7 +136,7 @@ var isEmptyRow = function isEmptyRow(rowNode) {
137
136
  */
138
137
  var createChangedRowDOM = function createChangedRowDOM(rowNode, cellEdgeAttrs, nodeViewSerializer, colorScheme, isInserted, diffType) {
139
138
  var tr = document.createElement('tr');
140
- var colors = _schemes.colorSchemeRegistry[colorScheme !== null && colorScheme !== void 0 ? colorScheme : DEFAULT_COLOR_SCHEME];
139
+ var colors = _schemes.colorSchemeRegistry[colorScheme !== null && colorScheme !== void 0 ? colorScheme : 'standard'];
141
140
 
142
141
  // Inserted rows keep their natural styling; the row strikethrough is deletions only.
143
142
  if (!(0, _isExtendedEnabled.isExtendedEnabled)(diffType) || !isInserted) {
@@ -6,10 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.unmountContributorTag = exports.mountContributorTag = exports.createContributorTagWidget = exports.createContributorTagHost = exports.CONTRIBUTOR_TAG_HOST_ATTRIBUTE = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _react = require("react");
10
9
  var _view = require("@atlaskit/editor-prosemirror/view");
11
10
  var _fg = require("@atlaskit/platform-feature-flags/fg");
12
- var _ContributorTagWidget = require("../../ui/ContributorTag/ContributorTagWidget");
11
+ var _contributorTagController = require("../../ui/ContributorTag/contributorTagController");
13
12
  var _createAnchorDecorationWidgets = require("./createAnchorDecorationWidgets");
14
13
  var _decorationKeys = require("./decorationKeys");
15
14
  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; }
@@ -23,23 +22,19 @@ var isContributorTagWidgetEnabled = function isContributorTagWidgetEnabled() {
23
22
  };
24
23
 
25
24
  /**
26
- * Everything a tag needs to mount itself into the document, plumbed down from the plugin. Absent in
25
+ * Everything a tag needs to draw itself into the document, plumbed down from the plugin. Absent in
27
26
  * unit tests that build decorations directly: the hosts are still emitted, they just stay empty.
28
27
  */
29
28
 
30
29
  /** A mounted tag, so whoever emitted the host can take it down again. */
31
30
 
32
31
  /**
33
- * Unique per mount rather than per diff, because ProseMirror draws a replacement widget before it
34
- * destroys the widget being replaced: on a shared key the outgoing widget's `destroy` would
35
- * unregister the incoming widget's portal.
36
- */
37
- var nextContributorTagPortalId = 0;
38
-
39
- /**
40
- * Renders the tag into `host` through the editor's portal provider, the way the rest of the editor
41
- * mounts React into decorations. The tag resolves its own model from plugin state, so a redraw of
42
- * the host re-parents the tag instead of stranding it, and `isActive` changes arrive as a re-render.
32
+ * Draws the tag into `host`. The tag resolves its own model from plugin state, so a redraw of the
33
+ * host re-parents the tag instead of stranding it, and `isActive` changes arrive as an update.
34
+ *
35
+ * Each mount owns its own controller and DOM, so when ProseMirror draws a replacement widget before
36
+ * destroying the one it replaces, the outgoing `destroy` cannot take the incoming tag down with it
37
+ * (EDITOR-8702).
43
38
  */
44
39
  var mountContributorTag = exports.mountContributorTag = function mountContributorTag(_ref) {
45
40
  var diffId = _ref.diffId,
@@ -48,24 +43,14 @@ var mountContributorTag = exports.mountContributorTag = function mountContributo
48
43
  if (!mountContext) {
49
44
  return undefined;
50
45
  }
51
- var api = mountContext.api,
52
- getEditorRoot = mountContext.getEditorRoot,
53
- portalProviderAPI = mountContext.portalProviderAPI;
54
- var key = "".concat(_decorationKeys.DecorationFamily.contributorTag, "-").concat(diffId, "-").concat(nextContributorTagPortalId++);
55
- portalProviderAPI.render(function () {
56
- return /*#__PURE__*/(0, _react.createElement)(_ContributorTagWidget.ContributorTagWidget, {
57
- api: api,
58
- diffId: diffId,
59
- getEditorRoot: getEditorRoot
60
- });
61
- }, host, key);
62
- return {
63
- key: key,
64
- portalProviderAPI: portalProviderAPI
65
- };
46
+ var controller = new _contributorTagController.ContributorTagController(_objectSpread(_objectSpread({}, mountContext), {}, {
47
+ diffId: diffId
48
+ }));
49
+ controller.mount(host);
50
+ return controller;
66
51
  };
67
52
  var unmountContributorTag = exports.unmountContributorTag = function unmountContributorTag(mount) {
68
- mount === null || mount === void 0 || mount.portalProviderAPI.remove(mount.key);
53
+ mount === null || mount === void 0 || mount.destroy();
69
54
  };
70
55
 
71
56
  /**
@@ -22,9 +22,8 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
22
22
  var displayNoneStyle = (0, _lazyNodeView.convertToInlineCss)({
23
23
  display: 'none'
24
24
  });
25
- var DEFAULT_COLOR_SCHEME = 'standard';
26
25
  var getColorScheme = function getColorScheme(colorScheme) {
27
- return _schemes.colorSchemeRegistry[colorScheme !== null && colorScheme !== void 0 ? colorScheme : DEFAULT_COLOR_SCHEME];
26
+ return _schemes.colorSchemeRegistry[colorScheme !== null && colorScheme !== void 0 ? colorScheme : 'standard'];
28
27
  };
29
28
 
30
29
  /**
@@ -9,11 +9,9 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
9
9
  var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
10
10
  var _omit = _interopRequireDefault(require("lodash/omit"));
11
11
  var _setAttrs = require("@atlaskit/adf-schema/steps/set-attrs");
12
- var _deprecatedPlatformFeatureExperiments = require("@atlaskit/editor-common/deprecated-platform-feature-experiments");
13
12
  var _nodeTypeUtils = require("@atlaskit/editor-common/utils/node-type-utils");
14
13
  var _transform = require("@atlaskit/editor-prosemirror/transform");
15
14
  var _fg = require("@atlaskit/platform-feature-flags/fg");
16
- var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
17
15
  var _diffableAttrs = require("./diffableAttrs");
18
16
  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; }
19
17
  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; }
@@ -86,26 +84,9 @@ var getAttrChangeRanges = exports.getAttrChangeRanges = function getAttrChangeRa
86
84
  var nodeAtPos = doc.nodeAt(finalPos);
87
85
  var originalNodeAtPos = originalPos === undefined ? null : originalDoc.nodeAt(originalPos);
88
86
 
89
- // date node: timestamp attribute change — highlight the date node itself (inline)
90
- if (attrsToCheck.some(function (v) {
91
- return dateAttrs.includes(v);
92
- }) && (nodeAtPos === null || nodeAtPos === void 0 ? void 0 : nodeAtPos.type.name) === 'date' && !(0, _deprecatedPlatformFeatureExperiments.isExperimentEnabled)('platform_editor_improve_inline_diffs', function () {
93
- return (0, _expValEquals.expValEquals)('platform_editor_improve_inline_diffs', 'isEnabled', true);
94
- })) {
95
- return {
96
- fromB: finalPos,
97
- toB: finalPos + nodeAtPos.nodeSize,
98
- isInline: true,
99
- inlineNodeName: 'date'
100
- };
101
- }
102
-
103
- // The following inline node attr changes are gated behind platform_editor_improve_inline_diffs.
104
87
  // The changeset path (createDecorationsForChange) handles the deletion widget via
105
88
  // prosemirror-changeset; we only need to add the inline insertion highlight here.
106
- if ((0, _deprecatedPlatformFeatureExperiments.isExperimentEnabled)('platform_editor_improve_inline_diffs', function () {
107
- return (0, _expValEquals.expValEquals)('platform_editor_improve_inline_diffs', 'isEnabled', true);
108
- }) && nodeAtPos) {
89
+ if (nodeAtPos) {
109
90
  var nodeName = nodeAtPos.type.name;
110
91
  if (isInlineAttrChangeNodeName(nodeName)) {
111
92
  var watchedAttrs = inlineNodeAttrMap[nodeName];
@@ -182,12 +163,8 @@ var getAttrChangeRanges = exports.getAttrChangeRanges = function getAttrChangeRa
182
163
  // Deduplicate by node position: multiple AttrSteps on the same node
183
164
  // (e.g. setNodeAttribute(pos, 'text', ...) + setNodeAttribute(pos, 'color', ...))
184
165
  // should produce only one decoration, not one per step.
185
- // Gated behind the same experiment as the inline node attr changes that introduced
186
- // the possibility of multiple ranges for the same node position.
187
166
  .filter(function (range, i, arr) {
188
- return !(0, _deprecatedPlatformFeatureExperiments.isExperimentEnabled)('platform_editor_improve_inline_diffs', function () {
189
- return (0, _expValEquals.expValEquals)('platform_editor_improve_inline_diffs', 'isEnabled', true);
190
- }) || arr.findIndex(function (r) {
167
+ return arr.findIndex(function (r) {
191
168
  return r.fromB === range.fromB;
192
169
  }) === i;
193
170
  });
@@ -25,9 +25,8 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
25
25
  * On cleanup (EDITOR-8281): drop the `isExperimentEnabled` dispatch and the `*Legacy` imports,
26
26
  * keeping the `*Next` bodies.
27
27
  */
28
- var DEFAULT_COLOR_SCHEME = 'standard';
29
28
  var getColorScheme = function getColorScheme(colorScheme) {
30
- return _schemes.colorSchemeRegistry[colorScheme !== null && colorScheme !== void 0 ? colorScheme : DEFAULT_COLOR_SCHEME];
29
+ return _schemes.colorSchemeRegistry[colorScheme !== null && colorScheme !== void 0 ? colorScheme : 'standard'];
31
30
  };
32
31
 
33
32
  /**
@@ -41,7 +41,7 @@ var dropOrphanedContributorTags = function dropOrphanedContributorTags(contribut
41
41
  });
42
42
  return liveTags.length === contributorTags.length ? contributorTags : liveTags;
43
43
  };
44
- var createPlugin = exports.createPlugin = function createPlugin(config, getIntl, api, portalProviderAPI, onEditorView) {
44
+ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl, api, onEditorView) {
45
45
  (0, _enforceCustomStepRegisters.enforceCustomStepRegisters)();
46
46
  var nodeViewSerializer = new _NodeViewSerializer.NodeViewSerializer({});
47
47
  var setNodeViewSerializer = function setNodeViewSerializer(editorView) {
@@ -58,14 +58,14 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
58
58
  * lifecycle, which decorations are calculated independently of.
59
59
  */
60
60
  var currentEditorView;
61
- var tagMountContext = portalProviderAPI ? {
61
+ var tagMountContext = {
62
62
  api: api,
63
63
  getEditorRoot: function getEditorRoot() {
64
64
  var _currentEditorView$do, _currentEditorView;
65
65
  return (_currentEditorView$do = (_currentEditorView = currentEditorView) === null || _currentEditorView === void 0 ? void 0 : _currentEditorView.dom) !== null && _currentEditorView$do !== void 0 ? _currentEditorView$do : null;
66
66
  },
67
- portalProviderAPI: portalProviderAPI
68
- } : undefined;
67
+ getIntl: getIntl
68
+ };
69
69
  return new _safePlugin.SafePlugin({
70
70
  key: showDiffPluginKey,
71
71
  state: {
@@ -105,12 +105,11 @@ var showDiffPlugin = exports.showDiffPlugin = function showDiffPlugin(_ref3) {
105
105
  pmPlugins: function pmPlugins() {
106
106
  return [{
107
107
  name: 'showDiffPlugin',
108
- // Contributor tags mount into their own decoration widgets through the portal
109
- // provider, the way the rest of the editor renders React into decorations.
108
+ // Contributor tags draw themselves into their own decoration widgets — plain DOM, so
109
+ // no portal provider is needed here.
110
110
  plugin: function plugin(_ref8) {
111
- var getIntl = _ref8.getIntl,
112
- nodeViewPortalProviderAPI = _ref8.nodeViewPortalProviderAPI;
113
- return (0, _main.createPlugin)(config, getIntl, api, nodeViewPortalProviderAPI, setEditorView);
111
+ var getIntl = _ref8.getIntl;
112
+ return (0, _main.createPlugin)(config, getIntl, api, setEditorView);
114
113
  }
115
114
  }];
116
115
  },