@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
@@ -1,375 +0,0 @@
1
- /* ContributorTag.tsx generated by @compiled/babel-plugin v2.0.0 */
2
- import _extends from "@babel/runtime/helpers/extends";
3
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
4
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
5
- import "./ContributorTag.compiled.css";
6
- import * as React from 'react';
7
- import { ax, ix } from "@compiled/react/runtime";
8
- 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; } } }; }
9
- 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; } }
10
- 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; }
11
- import { useCallback, useEffect, useRef, useState } from 'react';
12
- import { bindAll } from 'bind-event-listener';
13
- import { useIntl } from 'react-intl';
14
- import Avatar from '@atlaskit/avatar/avatar';
15
- import { AvatarContent } from '@atlaskit/avatar/avatar-content';
16
- import AiBotIcon from '@atlaskit/icon-lab/core/ai-bot';
17
- import { RovoHexIcon } from '@atlaskit/logo/rovo-hex/icon';
18
- import Tooltip from '@atlaskit/tooltip/Tooltip';
19
- import VisuallyHidden from '@atlaskit/visually-hidden/visually-hidden';
20
- import { getAccentTokens } from '../../pm-plugins/decorations/colorSchemes/factory';
21
- import { colorSchemeRegistry } from '../../pm-plugins/decorations/colorSchemes/schemes';
22
- import { contributorTagMessages } from './messages';
23
-
24
- // Floor for the tag width (~one 16px avatar plus padding), so the highlight-width clamp below
25
- // cannot collapse the box on a very short highlight.
26
- var MIN_TAG_WIDTH = '28px';
27
- var styles = {
28
- constraint: "_1e0c1ule _kqswstnw _94n51osq _1e02idpf _1ul9idpf _1pbykb7n _uiztglyw",
29
- tag: "_zulp1b66 _1reo15vq _18m915vq _2rko12b0 _11c8wadc _18zr1b66 _1rjcv77o _1e0c116y _4cvr1h6o _p12f1osq _1ul9idpf _1il9nqa1 _1doc1dm9 _16qs130s _o5721q9c _vchhusvi",
30
- hidden: "_tzy4idpf _lcxvglyw",
31
- visible: "_tzy4kb7n _lcxv1wug",
32
- avatars: "_1e0c116y _4cvr1h6o _1o9zidpf",
33
- leadingAvatar: "_1e0c116y _12l2r5cr",
34
- name: "_1reo15vq _18m915vq _1e0c1ule _1ul9idpf _1bto1l2s _o5721q9c"
35
- };
36
- var getContributorName = function getContributorName(contributor, formatMessage) {
37
- var _contributor$name, _contributor$agentKin;
38
- var name = (_contributor$name = contributor.name) === null || _contributor$name === void 0 ? void 0 : _contributor$name.trim();
39
- if (name) {
40
- return name;
41
- }
42
-
43
- // `agentKind` defaults to `'external'` per the plugin type contract; an unidentified external
44
- // agent falls back to a generic label rather than rendering a nameless tag.
45
- if (contributor.kind === 'agent' && ((_contributor$agentKin = contributor.agentKind) !== null && _contributor$agentKin !== void 0 ? _contributor$agentKin : 'external') === 'external') {
46
- return formatMessage(contributorTagMessages.externalAgentName);
47
- }
48
- return '';
49
- };
50
- var ContributorAvatar = function ContributorAvatar(_ref) {
51
- var contributor = _ref.contributor,
52
- name = _ref.name,
53
- ringColor = _ref.ringColor,
54
- stackIndex = _ref.stackIndex;
55
- if (contributor.kind === 'user') {
56
- return /*#__PURE__*/React.createElement(Avatar, {
57
- appearance: "circle",
58
- size: "xxsmall",
59
- src: contributor.avatarUrl,
60
- name: name,
61
- stackIndex: stackIndex,
62
- borderColor: ringColor
63
- });
64
- }
65
- return /*#__PURE__*/React.createElement(Avatar, {
66
- appearance: "hexagon",
67
- size: "xxsmall",
68
- src: contributor.avatarUrl,
69
- name: name,
70
- stackIndex: stackIndex,
71
- borderColor: ringColor
72
- }, contributor.avatarUrl ? undefined : /*#__PURE__*/React.createElement(AvatarContent, null, contributor.agentKind === 'rovo' ? /*#__PURE__*/React.createElement(RovoHexIcon, {
73
- size: "xxsmall",
74
- label: ""
75
- }) :
76
- /*#__PURE__*/
77
- // `small` (12px) fits inside the 16px hexagon.
78
- React.createElement(AiBotIcon, {
79
- label: "",
80
- size: "small"
81
- })));
82
- };
83
- /**
84
- * Resolves the tag's accent from the same scheme value and token maps the highlight used, so the two
85
- * can never drift.
86
- */
87
- var getTagAccent = function getTagAccent(_ref2) {
88
- var colorScheme = _ref2.colorScheme,
89
- isActive = _ref2.isActive,
90
- isInserted = _ref2.isInserted;
91
- var colors = colorSchemeRegistry[colorScheme !== null && colorScheme !== void 0 ? colorScheme : 'standard'];
92
- var accent = isInserted ? isActive ? colors.insertActiveColor : colors.insertColor : isActive ? colors.deleteActiveColor : colors.deleteColor;
93
- return getAccentTokens(accent);
94
- };
95
-
96
- /** The line the change starts on: topmost of its fragments, leftmost among those. */
97
- var findChangeStartLine = function findChangeStartLine(highlights) {
98
- var start;
99
- var _iterator = _createForOfIteratorHelper(highlights),
100
- _step;
101
- try {
102
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
103
- var highlight = _step.value;
104
- var _iterator2 = _createForOfIteratorHelper(highlight.getClientRects()),
105
- _step2;
106
- try {
107
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
108
- var rect = _step2.value;
109
- if (!start || rect.top < start.top - 1 || Math.abs(rect.top - start.top) <= 1 && rect.left < start.left) {
110
- start = rect;
111
- }
112
- }
113
- } catch (err) {
114
- _iterator2.e(err);
115
- } finally {
116
- _iterator2.f();
117
- }
118
- }
119
- } catch (err) {
120
- _iterator.e(err);
121
- } finally {
122
- _iterator.f();
123
- }
124
- return start;
125
- };
126
-
127
- /**
128
- * Observes the highlight this tag describes, for what CSS here cannot see: its hover state (the
129
- * highlight is a ProseMirror decoration in a different DOM subtree, so listeners are bound
130
- * imperatively via `data-diff-id`) and the width the tag is clamped to.
131
- *
132
- * Deliberately not routed through plugin state: a transaction per pointer move would re-run the
133
- * memoised decoration calculation.
134
- */
135
- var useHighlightState = function useHighlightState(diffId, highlightSelector, getEditorRoot) {
136
- var _useState = useState(false),
137
- _useState2 = _slicedToArray(_useState, 2),
138
- isHovered = _useState2[0],
139
- setIsHovered = _useState2[1];
140
- var _useState3 = useState(undefined),
141
- _useState4 = _slicedToArray(_useState3, 2),
142
- maxWidthPx = _useState4[0],
143
- setMaxWidthPx = _useState4[1];
144
- useEffect(function () {
145
- // Both queries are scoped to this editor's content root, so a tag can only ever bind to the
146
- // decorations its own plugin instance rendered — another editor on the page, or one nested
147
- // inside this one, cannot supply the geometry.
148
- var editorRoot = getEditorRoot();
149
- var highlights = editorRoot === null || editorRoot === void 0 ? void 0 : editorRoot.querySelectorAll(highlightSelector);
150
- if (!editorRoot || !(highlights !== null && highlights !== void 0 && highlights.length)) {
151
- return;
152
- }
153
- var elements = Array.from(highlights);
154
- // The width comes from this tag's OWN decoration; sibling halves of the change are here for
155
- // hover only.
156
- var ownElements = Array.from(editorRoot.querySelectorAll("[data-diff-id=\"".concat(diffId, "\"]")));
157
- var measure = function measure() {
158
- var _findChangeStartLine;
159
- // Counted by distinct line box, not by client rect: an inline node inside the change (a
160
- // mention, emoji, date) splits the highlight into several rects on the same line, and
161
- // treating that as a wrap would drop the width clamp on changes that never wrapped.
162
- var lineTops = new Set();
163
- for (var _i = 0, _ownElements = ownElements; _i < _ownElements.length; _i++) {
164
- var highlight = _ownElements[_i];
165
- var _iterator3 = _createForOfIteratorHelper(highlight.getClientRects()),
166
- _step3;
167
- try {
168
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
169
- var rect = _step3.value;
170
- lineTops.add(Math.round(rect.top));
171
- }
172
- } catch (err) {
173
- _iterator3.e(err);
174
- } finally {
175
- _iterator3.f();
176
- }
177
- }
178
-
179
- // A wrapped change's first line says nothing useful about how wide the tag may be.
180
- var width = lineTops.size > 1 ? undefined : (_findChangeStartLine = findChangeStartLine(ownElements)) === null || _findChangeStartLine === void 0 ? void 0 : _findChangeStartLine.width;
181
- setMaxWidthPx(width);
182
- };
183
- measure();
184
-
185
- // An inline element cannot be observed itself (ResizeObserver skips boxes with no principal
186
- // box), so the block it sits in is observed instead.
187
- var resizeObserver = new ResizeObserver(measure);
188
- var _iterator4 = _createForOfIteratorHelper(new Set(ownElements.map(function (_ref3) {
189
- var parentElement = _ref3.parentElement;
190
- return parentElement;
191
- }))),
192
- _step4;
193
- try {
194
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
195
- var parent = _step4.value;
196
- if (parent) {
197
- resizeObserver.observe(parent);
198
- }
199
- }
200
-
201
- // `bindAll` takes a single target, and a change can render more than one highlight.
202
- } catch (err) {
203
- _iterator4.e(err);
204
- } finally {
205
- _iterator4.f();
206
- }
207
- var unbinds = elements.map(function (highlight) {
208
- return bindAll(highlight, [{
209
- type: 'mouseenter',
210
- listener: function listener() {
211
- return setIsHovered(true);
212
- }
213
- }, {
214
- type: 'mouseleave',
215
- listener: function listener() {
216
- return setIsHovered(false);
217
- }
218
- }]);
219
- });
220
- return function () {
221
- resizeObserver.disconnect();
222
- unbinds.forEach(function (unbind) {
223
- return unbind();
224
- });
225
- };
226
- }, [diffId, getEditorRoot, highlightSelector]);
227
- return {
228
- isHovered: isHovered,
229
- maxWidthPx: maxWidthPx
230
- };
231
- };
232
-
233
- /**
234
- * A small tag naming who made one diff, rendered into the host widget its decoration places on the
235
- * change's first character and positioned above it.
236
- */
237
- export function ContributorTag(_ref4) {
238
- var colorScheme = _ref4.colorScheme,
239
- connectedContributor = _ref4.connectedContributor,
240
- contributor = _ref4.contributor,
241
- diffId = _ref4.diffId,
242
- getEditorRoot = _ref4.getEditorRoot,
243
- isActive = _ref4.isActive,
244
- _ref4$isInserted = _ref4.isInserted,
245
- isInserted = _ref4$isInserted === void 0 ? true : _ref4$isInserted,
246
- linkedDiffIds = _ref4.linkedDiffIds;
247
- var _useIntl = useIntl(),
248
- formatMessage = _useIntl.formatMessage;
249
- // A plain string, so the hook's effect is not re-run by a fresh array on every render.
250
- var highlightSelector = [diffId].concat(_toConsumableArray(linkedDiffIds !== null && linkedDiffIds !== void 0 ? linkedDiffIds : [])).map(function (id) {
251
- return "[data-diff-id=\"".concat(id, "\"]");
252
- }).join(', ');
253
- var _useHighlightState = useHighlightState(diffId, highlightSelector, getEditorRoot),
254
- isHighlightHovered = _useHighlightState.isHovered,
255
- maxWidthPx = _useHighlightState.maxWidthPx;
256
- var accent = getTagAccent({
257
- colorScheme: colorScheme,
258
- isActive: Boolean(isActive),
259
- isInserted: isInserted
260
- });
261
- var nameRef = useRef(null);
262
- var _useState5 = useState(false),
263
- _useState6 = _slicedToArray(_useState5, 2),
264
- isTruncated = _useState6[0],
265
- setIsTruncated = _useState6[1];
266
- var _useState7 = useState(false),
267
- _useState8 = _slicedToArray(_useState7, 2),
268
- isHoveredOrFocused = _useState8[0],
269
- setIsHoveredOrFocused = _useState8[1];
270
- var isConnectedPair = Boolean(connectedContributor);
271
- var isPrimaryAgent = contributor.kind === 'agent';
272
- var primaryName = getContributorName(contributor, formatMessage);
273
- var secondaryName = connectedContributor ? getContributorName(connectedContributor, formatMessage) : '';
274
-
275
- // Resolved by `kind` so a reverse `connectedTo` (an attributed user pointing at its agent)
276
- // renders identically.
277
- var agentName = isPrimaryAgent ? primaryName : secondaryName;
278
- var userName = isPrimaryAgent ? secondaryName : primaryName;
279
- var userContributor = isPrimaryAgent ? connectedContributor : contributor;
280
- var agentContributor = isPrimaryAgent ? contributor : connectedContributor;
281
- var displayName = isConnectedPair ? agentName || primaryName : primaryName;
282
- var fullLabel = isConnectedPair ? formatMessage(contributorTagMessages.changedByConnected, {
283
- agentName: agentName,
284
- userName: userName
285
- }) : formatMessage(contributorTagMessages.changedBy, {
286
- name: primaryName
287
- });
288
- var measureTruncation = useCallback(function () {
289
- var element = nameRef.current;
290
- if (element) {
291
- setIsTruncated(element.scrollWidth > element.clientWidth);
292
- }
293
- }, []);
294
- var isVisible = Boolean(isActive) || isHighlightHovered || isHoveredOrFocused;
295
-
296
- // A connected pair only ever renders the agent name, so it always gets a tooltip; a single
297
- // contributor only when its name is clipped.
298
- var tooltipContent = isTruncated || isConnectedPair ? fullLabel : null;
299
- return /*#__PURE__*/React.createElement("span", {
300
- style: {
301
- // Clamped to the highlight's own width, floored at `MIN_TAG_WIDTH` so a one-character
302
- // change still shows an avatar.
303
- maxWidth: maxWidthPx === undefined ? undefined : "max(".concat(Math.round(maxWidthPx), "px, ").concat(MIN_TAG_WIDTH, ")")
304
- },
305
- className: ax([styles.constraint])
306
- }, /*#__PURE__*/React.createElement(Tooltip, {
307
- content: tooltipContent
308
- // A tooltip below would cover the highlighted text the tag describes.
309
- ,
310
- position: "top"
311
- // The label is already exposed by the visually hidden text below.
312
- ,
313
- isScreenReaderAnnouncementDisabled: true
314
- }, function (tooltipProps) {
315
- return /*#__PURE__*/React.createElement("span", _extends({}, tooltipProps, {
316
- "data-testid": "diff-contributor-tag"
317
- // Deliberately no `aria-label`: it would be announced ahead of the element's
318
- // contents, but design requires the contributor *after* the change — hence the
319
- // visually hidden last child.
320
- ,
321
- role: "note"
322
- // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex, @atlassian/a11y/no-noninteractive-tabindex
323
- ,
324
- tabIndex: 0,
325
- style: {
326
- backgroundColor: accent.background,
327
- borderBottomColor: accent.border
328
- },
329
- onMouseOver: function onMouseOver(event) {
330
- tooltipProps.onMouseOver(event);
331
- measureTruncation();
332
- setIsHoveredOrFocused(true);
333
- },
334
- onMouseOut: function onMouseOut(event) {
335
- tooltipProps.onMouseOut(event);
336
- setIsHoveredOrFocused(false);
337
- },
338
- onFocus: function onFocus(event) {
339
- tooltipProps.onFocus(event);
340
- measureTruncation();
341
- setIsHoveredOrFocused(true);
342
- },
343
- onBlur: function onBlur(event) {
344
- tooltipProps.onBlur(event);
345
- setIsHoveredOrFocused(false);
346
- },
347
- className: ax([styles.tag, isVisible ? styles.visible : styles.hidden])
348
- }), /*#__PURE__*/React.createElement("span", {
349
- className: ax([styles.avatars])
350
- }, isConnectedPair && userContributor ? /*#__PURE__*/React.createElement("span", {
351
- className: ax([styles.leadingAvatar])
352
- }, /*#__PURE__*/React.createElement(ContributorAvatar, {
353
- contributor: userContributor,
354
- name: userName,
355
- ringColor: accent.background,
356
- stackIndex: 1
357
- })) : null, isConnectedPair && agentContributor ? /*#__PURE__*/React.createElement(ContributorAvatar, {
358
- contributor: agentContributor,
359
- name: agentName,
360
- ringColor: accent.background,
361
- stackIndex: 0
362
- }) : null, !isConnectedPair ? /*#__PURE__*/React.createElement(ContributorAvatar, {
363
- contributor: contributor,
364
- name: primaryName,
365
- ringColor: accent.background
366
- }) : null), /*#__PURE__*/React.createElement("span", {
367
- "data-testid": "diff-contributor-tag-name",
368
- ref: nameRef,
369
- style: {
370
- color: accent.text
371
- },
372
- className: ax([styles.name])
373
- }, displayName), /*#__PURE__*/React.createElement(VisuallyHidden, null, fullLabel));
374
- }));
375
- }
@@ -1,43 +0,0 @@
1
- /* ContributorTagWidget.tsx generated by @compiled/babel-plugin v2.0.0 */
2
- import * as React from 'react';
3
- import { ax, ix } from "@compiled/react/runtime";
4
- import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
5
- import { ContributorTag } from './ContributorTag';
6
-
7
- /**
8
- * One contributor tag, mounted by its diff decoration into the host element that decoration draws
9
- * (see `mountContributorTag`).
10
- *
11
- * The model is read from plugin state here rather than passed in, because ProseMirror skips `toDOM`
12
- * for a widget it reuses: stepping to the next change republishes the tags without redrawing their
13
- * hosts, so anything the tag needs to react to — `isActive` above all — has to arrive through a
14
- * subscription of its own. Renders nothing when this diff has no tag, which is the case for the
15
- * deleted half of a replacement: that half is folded into the inline tag.
16
- */
17
- export var ContributorTagWidget = function ContributorTagWidget(_ref) {
18
- var api = _ref.api,
19
- diffId = _ref.diffId,
20
- getEditorRoot = _ref.getEditorRoot;
21
- var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['showDiff'], function (state) {
22
- var _state$showDiffState;
23
- return {
24
- model: (_state$showDiffState = state.showDiffState) === null || _state$showDiffState === void 0 || (_state$showDiffState = _state$showDiffState.contributorTags) === null || _state$showDiffState === void 0 ? void 0 : _state$showDiffState.find(function (tag) {
25
- return tag.diffId === diffId;
26
- })
27
- };
28
- }),
29
- model = _useSharedPluginState.model;
30
- if (!model) {
31
- return null;
32
- }
33
- return /*#__PURE__*/React.createElement(ContributorTag, {
34
- colorScheme: model.colorScheme,
35
- connectedContributor: model.connectedContributor,
36
- contributor: model.contributor,
37
- diffId: model.diffId,
38
- getEditorRoot: getEditorRoot,
39
- isActive: model.isActive,
40
- isInserted: model.isInserted,
41
- linkedDiffIds: model.linkedDiffIds
42
- });
43
- };
@@ -1,37 +0,0 @@
1
- /**
2
- * @jsxRuntime classic
3
- * @jsx jsx
4
- */
5
- import type { ColorScheme } from '../../pm-plugins/decorations/colorSchemes/types';
6
- import type { TagContributor } from '../../showDiffPluginType';
7
- type ContributorTagProps = {
8
- colorScheme?: ColorScheme;
9
- connectedContributor?: TagContributor;
10
- contributor: TagContributor;
11
- diffId: string;
12
- /**
13
- * This editor's own content root (`editorView.dom`), read through the plugin's captured view.
14
- *
15
- * Every DOM lookup the tag makes is scoped to it, rather than resolved by class name from a
16
- * highlight element: `.ProseMirror` is not this package's to rename, and with nested editors the
17
- * nearest one is not necessarily the editor whose plugin rendered this tag.
18
- *
19
- * A getter rather than the element itself because the view arrives with the ProseMirror view
20
- * lifecycle, which the plugin does not re-render for: reading it inside the effect means it is
21
- * always the current one.
22
- */
23
- getEditorRoot: () => HTMLElement | null;
24
- isActive?: boolean;
25
- isInserted?: boolean;
26
- /**
27
- * Other decorations of the same change this one tag captions — the deleted half of a replacement.
28
- * Hovering any of them reveals the tag; only `diffId` is measured against.
29
- */
30
- linkedDiffIds?: string[];
31
- };
32
- /**
33
- * A small tag naming who made one diff, rendered into the host widget its decoration places on the
34
- * change's first character and positioned above it.
35
- */
36
- export declare function ContributorTag({ colorScheme, connectedContributor, contributor, diffId, getEditorRoot, isActive, isInserted, linkedDiffIds, }: ContributorTagProps): JSX.Element;
37
- export {};
@@ -1,22 +0,0 @@
1
- /**
2
- * @jsxRuntime classic
3
- * @jsx jsx
4
- */
5
- import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
6
- import type { ShowDiffPlugin } from '../../showDiffPluginType';
7
- /**
8
- * One contributor tag, mounted by its diff decoration into the host element that decoration draws
9
- * (see `mountContributorTag`).
10
- *
11
- * The model is read from plugin state here rather than passed in, because ProseMirror skips `toDOM`
12
- * for a widget it reuses: stepping to the next change republishes the tags without redrawing their
13
- * hosts, so anything the tag needs to react to — `isActive` above all — has to arrive through a
14
- * subscription of its own. Renders nothing when this diff has no tag, which is the case for the
15
- * deleted half of a replacement: that half is folded into the inline tag.
16
- */
17
- export declare const ContributorTagWidget: ({ api, diffId, getEditorRoot, }: {
18
- api?: ExtractInjectionAPI<ShowDiffPlugin>;
19
- diffId: string;
20
- /** This editor's own content root — see `ContributorTagProps.getEditorRoot`. */
21
- getEditorRoot: () => HTMLElement | null;
22
- }) => JSX.Element | null;