@atlaskit/editor-plugin-mentions 14.5.10 → 14.5.11

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/editor-plugin-mentions
2
2
 
3
+ ## 14.5.11
4
+
5
+ ### Patch Changes
6
+
7
+ - [`48dd7ce8c1cb2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/48dd7ce8c1cb2) -
8
+ EDITOR-7322 - fix mention pill getting overwritten with aaid
9
+ - Updated dependencies
10
+
3
11
  ## 14.5.10
4
12
 
5
13
  ### Patch Changes
@@ -23,11 +23,36 @@ var _profileCardRenderer2 = require("./profileCardRenderer");
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 primitiveClassName = 'editor-mention-primitive';
26
- // @ts-ignore - TS1501 TypeScript 5.9.2 upgrade
26
+ // eslint-disable-next-line require-unicode-regexp
27
27
  var AT_PREFIX_REGEX = /^@/;
28
28
  var getAccessibilityLabelFromName = function getAccessibilityLabelFromName(name) {
29
29
  return name.replace(AT_PREFIX_REGEX, '');
30
30
  };
31
+
32
+ // Workaround: AI-rewritten pages may store the raw AAID (e.g. '@712020:uuid') in attrs.text for
33
+ // APP/AGENT mentions instead of the display name. Detect this so we can fall through to provider
34
+ // resolution. Pattern: '@digits:uuid' — distinct from plain-UUID human AAIDs (no numeric prefix).
35
+ var AAID_MENTION_TEXT_PATTERN =
36
+ // eslint-disable-next-line require-unicode-regexp
37
+ /^@\d+:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
38
+
39
+ /** Returns true if `text` looks like a raw AAID rather than a display name. */
40
+ var isMentionTextAnAaid = function isMentionTextAnAaid(text) {
41
+ return AAID_MENTION_TEXT_PATTERN.test(text);
42
+ };
43
+ var isAgentMentionsExperimentEnabled = function isAgentMentionsExperimentEnabled() {
44
+ return (0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false);
45
+ };
46
+
47
+ /**
48
+ * Returns true if the node is an APP/AGENT mention whose stored text is a raw
49
+ * AAID (e.g. '@712020:uuid') rather than a resolved display name.
50
+ * All AAID-workaround guards should go through this helper so the checks stay
51
+ * consistent and can't drift apart.
52
+ */
53
+ var isAgentAaidText = function isAgentAaidText(node, isAgentMentionsEnabled) {
54
+ return isAgentMentionsEnabled && (node.attrs.userType === 'APP' || node.attrs.userType === 'AGENT') && !!node.attrs.text && isMentionTextAnAaid(node.attrs.text);
55
+ };
31
56
  var toDOM = function toDOM(node) {
32
57
  // packages/elements/mention/src/components/Mention/index.tsx
33
58
  var mentionAttrs = {
@@ -45,12 +70,14 @@ var toDOM = function toDOM(node) {
45
70
  'data-local-id': node.attrs.localId
46
71
  });
47
72
  }
48
- if ((0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false) && node.attrs.userType) {
73
+ var isAgentMentionsEnabled = isAgentMentionsExperimentEnabled();
74
+ if (isAgentMentionsEnabled && node.attrs.userType) {
49
75
  mentionAttrs = _objectSpread(_objectSpread({}, mentionAttrs), {}, {
50
76
  'data-user-type': node.attrs.userType
51
77
  });
52
78
  }
53
79
  var browser = (0, _browser.getBrowserInfo)();
80
+ var hasAgentAaidText = isAgentAaidText(node, isAgentMentionsEnabled);
54
81
  return ['span', mentionAttrs, ['span', {
55
82
  class: 'zeroWidthSpaceContainer'
56
83
  }, ['span', {
@@ -58,7 +85,7 @@ var toDOM = function toDOM(node) {
58
85
  }, _whitespace.ZERO_WIDTH_SPACE]], ['span', {
59
86
  spellcheck: 'false',
60
87
  class: primitiveClassName
61
- }, node.attrs.text || '@…'], browser.android ? ['span', {
88
+ }, node.attrs.text && !hasAgentAaidText ? node.attrs.text : '@…'], browser.android ? ['span', {
62
89
  class: 'zeroWidthSpaceContainer',
63
90
  contenteditable: 'false'
64
91
  }, ['span', {
@@ -71,12 +98,14 @@ var processName = function processName(name) {
71
98
  return name.status === _resource.MentionNameStatus.OK ? "@".concat(name.name || '') : "@_|unknown|_";
72
99
  };
73
100
  var handleProviderName = /*#__PURE__*/function () {
74
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(mentionProvider, node) {
75
- var nameDetail, resolvedNameDetail;
101
+ var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(mentionProvider, node, isAgentMentionsEnabled) {
102
+ var textIsAaid, nameDetail, resolvedNameDetail;
76
103
  return _regenerator.default.wrap(function (_context) {
77
104
  while (1) switch (_context.prev = _context.next) {
78
105
  case 0:
79
- if (!((0, _resource.isResolvingMentionProvider)(mentionProvider) && node.attrs.id && !node.attrs.text)) {
106
+ // Also resolve when text is a raw AAID — provider will return the real display name.
107
+ textIsAaid = isAgentAaidText(node, isAgentMentionsEnabled);
108
+ if (!((0, _resource.isResolvingMentionProvider)(mentionProvider) && node.attrs.id && (!node.attrs.text || textIsAaid))) {
80
109
  _context.next = 2;
81
110
  break;
82
111
  }
@@ -92,7 +121,7 @@ var handleProviderName = /*#__PURE__*/function () {
92
121
  }
93
122
  }, _callee);
94
123
  }));
95
- return function handleProviderName(_x, _x2) {
124
+ return function handleProviderName(_x, _x2, _x3) {
96
125
  return _ref.apply(this, arguments);
97
126
  };
98
127
  }();
@@ -147,7 +176,8 @@ var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
147
176
  updateNode = _profileCardRenderer.updateNode;
148
177
  // Accessibility attributes - based on `packages/people-and-teams/profilecard/src/components/User/ProfileCardTrigger.tsx`
149
178
  if (this.domElement && options !== null && options !== void 0 && options.profilecardProvider) {
150
- if (node.attrs.text) {
179
+ var isAgentMentionsEnabled = isAgentMentionsExperimentEnabled();
180
+ if (node.attrs.text && !isAgentAaidText(node, isAgentMentionsEnabled)) {
151
181
  this.domElement.setAttribute('aria-label', getAccessibilityLabelFromName(node.attrs.text));
152
182
  }
153
183
  this.domElement.setAttribute('aria-expanded', 'false');
@@ -252,8 +282,10 @@ var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
252
282
  }
253
283
  }, {
254
284
  key: "setTextContent",
255
- value: function setTextContent(name) {
256
- if (name && !this.node.attrs.text && this.mentionPrimitiveElement) {
285
+ value: function setTextContent(name, isAgentMentionsEnabled) {
286
+ // Also overwrite when text is a raw AAID so the resolved name takes precedence.
287
+ var textIsAaid = isAgentAaidText(this.node, isAgentMentionsEnabled);
288
+ if (name && (!this.node.attrs.text || textIsAaid) && this.mentionPrimitiveElement) {
257
289
  this.mentionPrimitiveElement.textContent = name;
258
290
  }
259
291
  }
@@ -278,10 +310,11 @@ var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
278
310
  value: function () {
279
311
  var _updateState = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(mentionProvider) {
280
312
  var _mentionProvider$shou2, _this$config$options2;
281
- var isHighlighted, disabledState, isDisabled, newState, disabledTooltip, name;
313
+ var isAgentMentionsEnabled, isHighlighted, disabledState, isDisabled, newState, disabledTooltip, name, text;
282
314
  return _regenerator.default.wrap(function (_context2) {
283
315
  while (1) switch (_context2.prev = _context2.next) {
284
316
  case 0:
317
+ isAgentMentionsEnabled = isAgentMentionsExperimentEnabled();
285
318
  isHighlighted = (0, _expValEquals.expValEquals)('platform_editor_vc90_transition_mentions', 'isEnabled', true) ? this.shouldHighlightMention(mentionProvider) : (_mentionProvider$shou2 = mentionProvider === null || mentionProvider === void 0 ? void 0 : mentionProvider.shouldHighlightMention({
286
319
  id: this.node.attrs.id
287
320
  })) !== null && _mentionProvider$shou2 !== void 0 ? _mentionProvider$shou2 : false;
@@ -298,15 +331,18 @@ var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
298
331
  // the chip is already disabled.
299
332
  this.syncDisabledTooltip(disabledState);
300
333
  _context2.next = 1;
301
- return handleProviderName(mentionProvider, this.node);
334
+ return handleProviderName(mentionProvider, this.node, isAgentMentionsEnabled);
302
335
  case 1:
303
336
  name = _context2.sent;
304
- this.setTextContent(name);
337
+ this.setTextContent(name, isAgentMentionsEnabled);
305
338
  // Only overwrite the disabled-state aria-label with the name-based one
306
339
  // when the chip is NOT disabled; otherwise the disabled reason set in
307
340
  // `setClassList` would be silently clobbered, regressing a11y.
308
- if (name && this.domElement && (_this$config$options2 = this.config.options) !== null && _this$config$options2 !== void 0 && _this$config$options2.profilecardProvider && newState !== 'disabled') {
309
- this.domElement.setAttribute('aria-label', getAccessibilityLabelFromName(name));
341
+ if (this.domElement && (_this$config$options2 = this.config.options) !== null && _this$config$options2 !== void 0 && _this$config$options2.profilecardProvider && newState !== 'disabled') {
342
+ text = name !== null && name !== void 0 ? name : this.node.attrs.text;
343
+ if (text && !isAgentAaidText(this.node, isAgentMentionsEnabled)) {
344
+ this.domElement.setAttribute('aria-label', getAccessibilityLabelFromName(text));
345
+ }
310
346
  }
311
347
  case 2:
312
348
  case "end":
@@ -314,7 +350,7 @@ var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
314
350
  }
315
351
  }, _callee2, this);
316
352
  }));
317
- function updateState(_x3) {
353
+ function updateState(_x4) {
318
354
  return _updateState.apply(this, arguments);
319
355
  }
320
356
  return updateState;
@@ -52,7 +52,7 @@ var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
52
52
  var AGENT_MENTION_INACTIVITY_MS = 3000;
53
53
  var MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
54
54
  var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
55
- var PACKAGE_VERSION = "14.5.9";
55
+ var PACKAGE_VERSION = "14.5.10";
56
56
  var setProvider = function setProvider(provider) {
57
57
  return function (state, dispatch) {
58
58
  if (dispatch) {
@@ -9,9 +9,28 @@ import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
9
9
  import { disabledTooltipRenderer } from './disabledTooltipRenderer';
10
10
  import { profileCardRenderer } from './profileCardRenderer';
11
11
  const primitiveClassName = 'editor-mention-primitive';
12
- // @ts-ignore - TS1501 TypeScript 5.9.2 upgrade
13
- const AT_PREFIX_REGEX = /^@/u;
12
+ // eslint-disable-next-line require-unicode-regexp
13
+ const AT_PREFIX_REGEX = /^@/;
14
14
  const getAccessibilityLabelFromName = name => name.replace(AT_PREFIX_REGEX, '');
15
+
16
+ // Workaround: AI-rewritten pages may store the raw AAID (e.g. '@712020:uuid') in attrs.text for
17
+ // APP/AGENT mentions instead of the display name. Detect this so we can fall through to provider
18
+ // resolution. Pattern: '@digits:uuid' — distinct from plain-UUID human AAIDs (no numeric prefix).
19
+ const AAID_MENTION_TEXT_PATTERN =
20
+ // eslint-disable-next-line require-unicode-regexp
21
+ /^@\d+:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
22
+
23
+ /** Returns true if `text` looks like a raw AAID rather than a display name. */
24
+ const isMentionTextAnAaid = text => AAID_MENTION_TEXT_PATTERN.test(text);
25
+ const isAgentMentionsExperimentEnabled = () => expVal('platform_editor_agent_mentions', 'isEnabled', false);
26
+
27
+ /**
28
+ * Returns true if the node is an APP/AGENT mention whose stored text is a raw
29
+ * AAID (e.g. '@712020:uuid') rather than a resolved display name.
30
+ * All AAID-workaround guards should go through this helper so the checks stay
31
+ * consistent and can't drift apart.
32
+ */
33
+ const isAgentAaidText = (node, isAgentMentionsEnabled) => isAgentMentionsEnabled && (node.attrs.userType === 'APP' || node.attrs.userType === 'AGENT') && !!node.attrs.text && isMentionTextAnAaid(node.attrs.text);
15
34
  const toDOM = node => {
16
35
  // packages/elements/mention/src/components/Mention/index.tsx
17
36
  let mentionAttrs = {
@@ -30,13 +49,15 @@ const toDOM = node => {
30
49
  'data-local-id': node.attrs.localId
31
50
  };
32
51
  }
33
- if (expVal('platform_editor_agent_mentions', 'isEnabled', false) && node.attrs.userType) {
52
+ const isAgentMentionsEnabled = isAgentMentionsExperimentEnabled();
53
+ if (isAgentMentionsEnabled && node.attrs.userType) {
34
54
  mentionAttrs = {
35
55
  ...mentionAttrs,
36
56
  'data-user-type': node.attrs.userType
37
57
  };
38
58
  }
39
59
  const browser = getBrowserInfo();
60
+ const hasAgentAaidText = isAgentAaidText(node, isAgentMentionsEnabled);
40
61
  return ['span', mentionAttrs, ['span', {
41
62
  class: 'zeroWidthSpaceContainer'
42
63
  }, ['span', {
@@ -44,7 +65,7 @@ const toDOM = node => {
44
65
  }, ZERO_WIDTH_SPACE]], ['span', {
45
66
  spellcheck: 'false',
46
67
  class: primitiveClassName
47
- }, node.attrs.text || '@…'], browser.android ? ['span', {
68
+ }, node.attrs.text && !hasAgentAaidText ? node.attrs.text : '@…'], browser.android ? ['span', {
48
69
  class: 'zeroWidthSpaceContainer',
49
70
  contenteditable: 'false'
50
71
  }, ['span', {
@@ -56,8 +77,10 @@ const toDOM = node => {
56
77
  const processName = name => {
57
78
  return name.status === MentionNameStatus.OK ? `@${name.name || ''}` : `@_|unknown|_`;
58
79
  };
59
- const handleProviderName = async (mentionProvider, node) => {
60
- if (isResolvingMentionProvider(mentionProvider) && node.attrs.id && !node.attrs.text) {
80
+ const handleProviderName = async (mentionProvider, node, isAgentMentionsEnabled) => {
81
+ // Also resolve when text is a raw AAID — provider will return the real display name.
82
+ const textIsAaid = isAgentAaidText(node, isAgentMentionsEnabled);
83
+ if (isResolvingMentionProvider(mentionProvider) && node.attrs.id && (!node.attrs.text || textIsAaid)) {
61
84
  const nameDetail = mentionProvider === null || mentionProvider === void 0 ? void 0 : mentionProvider.resolveMentionName(node.attrs.id);
62
85
  const resolvedNameDetail = await nameDetail;
63
86
  return processName(resolvedNameDetail);
@@ -117,7 +140,8 @@ export class MentionNodeView {
117
140
  });
118
141
  // Accessibility attributes - based on `packages/people-and-teams/profilecard/src/components/User/ProfileCardTrigger.tsx`
119
142
  if (this.domElement && options !== null && options !== void 0 && options.profilecardProvider) {
120
- if (node.attrs.text) {
143
+ const isAgentMentionsEnabled = isAgentMentionsExperimentEnabled();
144
+ if (node.attrs.text && !isAgentAaidText(node, isAgentMentionsEnabled)) {
121
145
  this.domElement.setAttribute('aria-label', getAccessibilityLabelFromName(node.attrs.text));
122
146
  }
123
147
  this.domElement.setAttribute('aria-expanded', 'false');
@@ -213,8 +237,10 @@ export class MentionNodeView {
213
237
  this.disabledTooltip = undefined;
214
238
  }
215
239
  }
216
- setTextContent(name) {
217
- if (name && !this.node.attrs.text && this.mentionPrimitiveElement) {
240
+ setTextContent(name, isAgentMentionsEnabled) {
241
+ // Also overwrite when text is a raw AAID so the resolved name takes precedence.
242
+ const textIsAaid = isAgentAaidText(this.node, isAgentMentionsEnabled);
243
+ if (name && (!this.node.attrs.text || textIsAaid) && this.mentionPrimitiveElement) {
218
244
  this.mentionPrimitiveElement.textContent = name;
219
245
  }
220
246
  }
@@ -235,6 +261,7 @@ export class MentionNodeView {
235
261
  }
236
262
  async updateState(mentionProvider) {
237
263
  var _mentionProvider$shou2, _this$config$options2;
264
+ const isAgentMentionsEnabled = isAgentMentionsExperimentEnabled();
238
265
  const isHighlighted = expValEquals('platform_editor_vc90_transition_mentions', 'isEnabled', true) ? this.shouldHighlightMention(mentionProvider) : (_mentionProvider$shou2 = mentionProvider === null || mentionProvider === void 0 ? void 0 : mentionProvider.shouldHighlightMention({
239
266
  id: this.node.attrs.id
240
267
  })) !== null && _mentionProvider$shou2 !== void 0 ? _mentionProvider$shou2 : false;
@@ -251,13 +278,16 @@ export class MentionNodeView {
251
278
  // the tooltip text stays in sync if the disabled reason changes while
252
279
  // the chip is already disabled.
253
280
  this.syncDisabledTooltip(disabledState);
254
- const name = await handleProviderName(mentionProvider, this.node);
255
- this.setTextContent(name);
281
+ const name = await handleProviderName(mentionProvider, this.node, isAgentMentionsEnabled);
282
+ this.setTextContent(name, isAgentMentionsEnabled);
256
283
  // Only overwrite the disabled-state aria-label with the name-based one
257
284
  // when the chip is NOT disabled; otherwise the disabled reason set in
258
285
  // `setClassList` would be silently clobbered, regressing a11y.
259
- if (name && this.domElement && (_this$config$options2 = this.config.options) !== null && _this$config$options2 !== void 0 && _this$config$options2.profilecardProvider && newState !== 'disabled') {
260
- this.domElement.setAttribute('aria-label', getAccessibilityLabelFromName(name));
286
+ if (this.domElement && (_this$config$options2 = this.config.options) !== null && _this$config$options2 !== void 0 && _this$config$options2.profilecardProvider && newState !== 'disabled') {
287
+ const text = name !== null && name !== void 0 ? name : this.node.attrs.text;
288
+ if (text && !isAgentAaidText(this.node, isAgentMentionsEnabled)) {
289
+ this.domElement.setAttribute('aria-label', getAccessibilityLabelFromName(text));
290
+ }
261
291
  }
262
292
  }
263
293
  nodeIsEqual(nextNode) {
@@ -37,7 +37,7 @@ const AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
37
37
  const AGENT_MENTION_INACTIVITY_MS = 3000;
38
38
  const MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
39
39
  const PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
40
- const PACKAGE_VERSION = "14.5.9";
40
+ const PACKAGE_VERSION = "14.5.10";
41
41
  const setProvider = provider => (state, dispatch) => {
42
42
  if (dispatch) {
43
43
  dispatch(state.tr.setMeta(mentionPluginKey, {
@@ -16,11 +16,36 @@ import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
16
16
  import { disabledTooltipRenderer } from './disabledTooltipRenderer';
17
17
  import { profileCardRenderer } from './profileCardRenderer';
18
18
  var primitiveClassName = 'editor-mention-primitive';
19
- // @ts-ignore - TS1501 TypeScript 5.9.2 upgrade
19
+ // eslint-disable-next-line require-unicode-regexp
20
20
  var AT_PREFIX_REGEX = /^@/;
21
21
  var getAccessibilityLabelFromName = function getAccessibilityLabelFromName(name) {
22
22
  return name.replace(AT_PREFIX_REGEX, '');
23
23
  };
24
+
25
+ // Workaround: AI-rewritten pages may store the raw AAID (e.g. '@712020:uuid') in attrs.text for
26
+ // APP/AGENT mentions instead of the display name. Detect this so we can fall through to provider
27
+ // resolution. Pattern: '@digits:uuid' — distinct from plain-UUID human AAIDs (no numeric prefix).
28
+ var AAID_MENTION_TEXT_PATTERN =
29
+ // eslint-disable-next-line require-unicode-regexp
30
+ /^@\d+:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
31
+
32
+ /** Returns true if `text` looks like a raw AAID rather than a display name. */
33
+ var isMentionTextAnAaid = function isMentionTextAnAaid(text) {
34
+ return AAID_MENTION_TEXT_PATTERN.test(text);
35
+ };
36
+ var isAgentMentionsExperimentEnabled = function isAgentMentionsExperimentEnabled() {
37
+ return expVal('platform_editor_agent_mentions', 'isEnabled', false);
38
+ };
39
+
40
+ /**
41
+ * Returns true if the node is an APP/AGENT mention whose stored text is a raw
42
+ * AAID (e.g. '@712020:uuid') rather than a resolved display name.
43
+ * All AAID-workaround guards should go through this helper so the checks stay
44
+ * consistent and can't drift apart.
45
+ */
46
+ var isAgentAaidText = function isAgentAaidText(node, isAgentMentionsEnabled) {
47
+ return isAgentMentionsEnabled && (node.attrs.userType === 'APP' || node.attrs.userType === 'AGENT') && !!node.attrs.text && isMentionTextAnAaid(node.attrs.text);
48
+ };
24
49
  var toDOM = function toDOM(node) {
25
50
  // packages/elements/mention/src/components/Mention/index.tsx
26
51
  var mentionAttrs = {
@@ -38,12 +63,14 @@ var toDOM = function toDOM(node) {
38
63
  'data-local-id': node.attrs.localId
39
64
  });
40
65
  }
41
- if (expVal('platform_editor_agent_mentions', 'isEnabled', false) && node.attrs.userType) {
66
+ var isAgentMentionsEnabled = isAgentMentionsExperimentEnabled();
67
+ if (isAgentMentionsEnabled && node.attrs.userType) {
42
68
  mentionAttrs = _objectSpread(_objectSpread({}, mentionAttrs), {}, {
43
69
  'data-user-type': node.attrs.userType
44
70
  });
45
71
  }
46
72
  var browser = getBrowserInfo();
73
+ var hasAgentAaidText = isAgentAaidText(node, isAgentMentionsEnabled);
47
74
  return ['span', mentionAttrs, ['span', {
48
75
  class: 'zeroWidthSpaceContainer'
49
76
  }, ['span', {
@@ -51,7 +78,7 @@ var toDOM = function toDOM(node) {
51
78
  }, ZERO_WIDTH_SPACE]], ['span', {
52
79
  spellcheck: 'false',
53
80
  class: primitiveClassName
54
- }, node.attrs.text || '@…'], browser.android ? ['span', {
81
+ }, node.attrs.text && !hasAgentAaidText ? node.attrs.text : '@…'], browser.android ? ['span', {
55
82
  class: 'zeroWidthSpaceContainer',
56
83
  contenteditable: 'false'
57
84
  }, ['span', {
@@ -64,12 +91,14 @@ var processName = function processName(name) {
64
91
  return name.status === MentionNameStatus.OK ? "@".concat(name.name || '') : "@_|unknown|_";
65
92
  };
66
93
  var handleProviderName = /*#__PURE__*/function () {
67
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(mentionProvider, node) {
68
- var nameDetail, resolvedNameDetail;
94
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(mentionProvider, node, isAgentMentionsEnabled) {
95
+ var textIsAaid, nameDetail, resolvedNameDetail;
69
96
  return _regeneratorRuntime.wrap(function (_context) {
70
97
  while (1) switch (_context.prev = _context.next) {
71
98
  case 0:
72
- if (!(isResolvingMentionProvider(mentionProvider) && node.attrs.id && !node.attrs.text)) {
99
+ // Also resolve when text is a raw AAID — provider will return the real display name.
100
+ textIsAaid = isAgentAaidText(node, isAgentMentionsEnabled);
101
+ if (!(isResolvingMentionProvider(mentionProvider) && node.attrs.id && (!node.attrs.text || textIsAaid))) {
73
102
  _context.next = 2;
74
103
  break;
75
104
  }
@@ -85,7 +114,7 @@ var handleProviderName = /*#__PURE__*/function () {
85
114
  }
86
115
  }, _callee);
87
116
  }));
88
- return function handleProviderName(_x, _x2) {
117
+ return function handleProviderName(_x, _x2, _x3) {
89
118
  return _ref.apply(this, arguments);
90
119
  };
91
120
  }();
@@ -140,7 +169,8 @@ export var MentionNodeView = /*#__PURE__*/function () {
140
169
  updateNode = _profileCardRenderer.updateNode;
141
170
  // Accessibility attributes - based on `packages/people-and-teams/profilecard/src/components/User/ProfileCardTrigger.tsx`
142
171
  if (this.domElement && options !== null && options !== void 0 && options.profilecardProvider) {
143
- if (node.attrs.text) {
172
+ var isAgentMentionsEnabled = isAgentMentionsExperimentEnabled();
173
+ if (node.attrs.text && !isAgentAaidText(node, isAgentMentionsEnabled)) {
144
174
  this.domElement.setAttribute('aria-label', getAccessibilityLabelFromName(node.attrs.text));
145
175
  }
146
176
  this.domElement.setAttribute('aria-expanded', 'false');
@@ -245,8 +275,10 @@ export var MentionNodeView = /*#__PURE__*/function () {
245
275
  }
246
276
  }, {
247
277
  key: "setTextContent",
248
- value: function setTextContent(name) {
249
- if (name && !this.node.attrs.text && this.mentionPrimitiveElement) {
278
+ value: function setTextContent(name, isAgentMentionsEnabled) {
279
+ // Also overwrite when text is a raw AAID so the resolved name takes precedence.
280
+ var textIsAaid = isAgentAaidText(this.node, isAgentMentionsEnabled);
281
+ if (name && (!this.node.attrs.text || textIsAaid) && this.mentionPrimitiveElement) {
250
282
  this.mentionPrimitiveElement.textContent = name;
251
283
  }
252
284
  }
@@ -271,10 +303,11 @@ export var MentionNodeView = /*#__PURE__*/function () {
271
303
  value: function () {
272
304
  var _updateState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(mentionProvider) {
273
305
  var _mentionProvider$shou2, _this$config$options2;
274
- var isHighlighted, disabledState, isDisabled, newState, disabledTooltip, name;
306
+ var isAgentMentionsEnabled, isHighlighted, disabledState, isDisabled, newState, disabledTooltip, name, text;
275
307
  return _regeneratorRuntime.wrap(function (_context2) {
276
308
  while (1) switch (_context2.prev = _context2.next) {
277
309
  case 0:
310
+ isAgentMentionsEnabled = isAgentMentionsExperimentEnabled();
278
311
  isHighlighted = expValEquals('platform_editor_vc90_transition_mentions', 'isEnabled', true) ? this.shouldHighlightMention(mentionProvider) : (_mentionProvider$shou2 = mentionProvider === null || mentionProvider === void 0 ? void 0 : mentionProvider.shouldHighlightMention({
279
312
  id: this.node.attrs.id
280
313
  })) !== null && _mentionProvider$shou2 !== void 0 ? _mentionProvider$shou2 : false;
@@ -291,15 +324,18 @@ export var MentionNodeView = /*#__PURE__*/function () {
291
324
  // the chip is already disabled.
292
325
  this.syncDisabledTooltip(disabledState);
293
326
  _context2.next = 1;
294
- return handleProviderName(mentionProvider, this.node);
327
+ return handleProviderName(mentionProvider, this.node, isAgentMentionsEnabled);
295
328
  case 1:
296
329
  name = _context2.sent;
297
- this.setTextContent(name);
330
+ this.setTextContent(name, isAgentMentionsEnabled);
298
331
  // Only overwrite the disabled-state aria-label with the name-based one
299
332
  // when the chip is NOT disabled; otherwise the disabled reason set in
300
333
  // `setClassList` would be silently clobbered, regressing a11y.
301
- if (name && this.domElement && (_this$config$options2 = this.config.options) !== null && _this$config$options2 !== void 0 && _this$config$options2.profilecardProvider && newState !== 'disabled') {
302
- this.domElement.setAttribute('aria-label', getAccessibilityLabelFromName(name));
334
+ if (this.domElement && (_this$config$options2 = this.config.options) !== null && _this$config$options2 !== void 0 && _this$config$options2.profilecardProvider && newState !== 'disabled') {
335
+ text = name !== null && name !== void 0 ? name : this.node.attrs.text;
336
+ if (text && !isAgentAaidText(this.node, isAgentMentionsEnabled)) {
337
+ this.domElement.setAttribute('aria-label', getAccessibilityLabelFromName(text));
338
+ }
303
339
  }
304
340
  case 2:
305
341
  case "end":
@@ -307,7 +343,7 @@ export var MentionNodeView = /*#__PURE__*/function () {
307
343
  }
308
344
  }, _callee2, this);
309
345
  }));
310
- function updateState(_x3) {
346
+ function updateState(_x4) {
311
347
  return _updateState.apply(this, arguments);
312
348
  }
313
349
  return updateState;
@@ -44,7 +44,7 @@ var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
44
44
  var AGENT_MENTION_INACTIVITY_MS = 3000;
45
45
  var MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
46
46
  var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
47
- var PACKAGE_VERSION = "14.5.9";
47
+ var PACKAGE_VERSION = "14.5.10";
48
48
  var setProvider = function setProvider(provider) {
49
49
  return function (state, dispatch) {
50
50
  if (dispatch) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-mentions",
3
- "version": "14.5.10",
3
+ "version": "14.5.11",
4
4
  "description": "Mentions plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -38,10 +38,10 @@
38
38
  "@atlaskit/popper": "^8.2.0",
39
39
  "@atlaskit/portal": "^6.1.0",
40
40
  "@atlaskit/primitives": "^20.3.0",
41
- "@atlaskit/profilecard": "^26.5.0",
41
+ "@atlaskit/profilecard": "^26.8.0",
42
42
  "@atlaskit/teams-app-config": "^2.1.0",
43
43
  "@atlaskit/theme": "^26.1.0",
44
- "@atlaskit/tmp-editor-statsig": "^120.0.0",
44
+ "@atlaskit/tmp-editor-statsig": "^120.1.0",
45
45
  "@atlaskit/tokens": "^15.3.0",
46
46
  "@atlaskit/tooltip": "^23.1.0",
47
47
  "@atlaskit/user-picker": "^13.4.0",
@@ -53,7 +53,7 @@
53
53
  "uuid": "^3.1.0"
54
54
  },
55
55
  "peerDependencies": {
56
- "@atlaskit/editor-common": "^116.20.0",
56
+ "@atlaskit/editor-common": "^116.21.0",
57
57
  "react": "^18.2.0",
58
58
  "react-dom": "^18.2.0",
59
59
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"