@atlaskit/editor-plugin-mentions 17.0.0 → 17.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/cjs/mentionsPlugin.js +16 -6
  3. package/dist/cjs/pm-plugins/main.js +1 -1
  4. package/dist/cjs/ui/AnchoredPopup.js +5 -0
  5. package/dist/cjs/ui/InlineInvitePopupContainer.js +1 -2
  6. package/dist/cjs/ui/PopperWrapper.js +14 -9
  7. package/dist/cjs/ui/ProfileCardComponent.js +36 -11
  8. package/dist/cjs/ui/quick-insert/MentionQuickInsertMenuItem.js +41 -0
  9. package/dist/cjs/ui/quick-insert/getMentionQuickInsertComponents.js +41 -0
  10. package/dist/cjs/ui/type-ahead/MentionItemWithProfileCard.js +106 -0
  11. package/dist/cjs/ui/type-ahead/index.js +80 -71
  12. package/dist/cjs/ui/type-ahead/utils.js +7 -1
  13. package/dist/cjs/ui/useFocusTrap.js +5 -3
  14. package/dist/es2019/mentionsPlugin.js +13 -3
  15. package/dist/es2019/pm-plugins/main.js +1 -1
  16. package/dist/es2019/ui/AnchoredPopup.js +5 -0
  17. package/dist/es2019/ui/InlineInvitePopupContainer.js +1 -2
  18. package/dist/es2019/ui/PopperWrapper.js +10 -8
  19. package/dist/es2019/ui/ProfileCardComponent.js +35 -10
  20. package/dist/es2019/ui/quick-insert/MentionQuickInsertMenuItem.js +36 -0
  21. package/dist/es2019/ui/quick-insert/getMentionQuickInsertComponents.js +30 -0
  22. package/dist/es2019/ui/type-ahead/MentionItemWithProfileCard.js +91 -0
  23. package/dist/es2019/ui/type-ahead/index.js +22 -8
  24. package/dist/es2019/ui/type-ahead/utils.js +2 -0
  25. package/dist/es2019/ui/useFocusTrap.js +4 -3
  26. package/dist/esm/mentionsPlugin.js +13 -3
  27. package/dist/esm/pm-plugins/main.js +1 -1
  28. package/dist/esm/ui/AnchoredPopup.js +5 -0
  29. package/dist/esm/ui/InlineInvitePopupContainer.js +1 -2
  30. package/dist/esm/ui/PopperWrapper.js +13 -8
  31. package/dist/esm/ui/ProfileCardComponent.js +36 -11
  32. package/dist/esm/ui/quick-insert/MentionQuickInsertMenuItem.js +33 -0
  33. package/dist/esm/ui/quick-insert/getMentionQuickInsertComponents.js +34 -0
  34. package/dist/esm/ui/type-ahead/MentionItemWithProfileCard.js +98 -0
  35. package/dist/esm/ui/type-ahead/index.js +78 -69
  36. package/dist/esm/ui/type-ahead/utils.js +6 -0
  37. package/dist/esm/ui/useFocusTrap.js +5 -3
  38. package/dist/types/mentionsPluginType.d.ts +3 -1
  39. package/dist/types/ui/PopperWrapper.d.ts +15 -2
  40. package/dist/types/ui/ProfileCardComponent.d.ts +6 -1
  41. package/dist/types/ui/quick-insert/MentionQuickInsertMenuItem.d.ts +10 -0
  42. package/dist/types/ui/quick-insert/getMentionQuickInsertComponents.d.ts +8 -0
  43. package/dist/types/ui/type-ahead/MentionItemWithProfileCard.d.ts +15 -0
  44. package/dist/types/ui/type-ahead/index.d.ts +3 -1
  45. package/dist/types/ui/type-ahead/utils.d.ts +2 -0
  46. package/dist/types/ui/useFocusTrap.d.ts +2 -1
  47. package/package.json +9 -6
@@ -30,6 +30,7 @@ var _utils2 = require("../../pm-plugins/utils");
30
30
  var _InviteItem = _interopRequireWildcard(require("../InviteItem"));
31
31
  var _InviteItemWithEmailDomain = _interopRequireDefault(require("../InviteItem/InviteItemWithEmailDomain"));
32
32
  var _analytics = require("./analytics");
33
+ var _MentionItemWithProfileCard = require("./MentionItemWithProfileCard");
33
34
  var _utils3 = require("./utils");
34
35
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
35
36
  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; } } }; }
@@ -37,14 +38,8 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
37
38
  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; }
38
39
  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; }
39
40
  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; } // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
40
- var isAgentUserType = function isAgentUserType(userType) {
41
- return userType === 'APP' || userType === 'AGENT';
42
- };
43
- var isAgentMention = function isAgentMention(mention) {
44
- return isAgentUserType(mention.userType) || mention.appType === 'agent';
45
- };
46
41
  var isAgentTypeAheadItem = function isAgentTypeAheadItem(item) {
47
- return item.mention ? isAgentMention(item.mention) : false;
42
+ return item.mention ? (0, _utils3.isAgentMention)(item.mention) : false;
48
43
  };
49
44
 
50
45
  // A non-selectable loading placeholder injected by the provider (e.g.
@@ -109,16 +104,24 @@ var withInviteItem = function withInviteItem(_ref3) {
109
104
  inviteItem]);
110
105
  };
111
106
  };
112
- var makeMentionToTypeaheadItem = function makeMentionToTypeaheadItem(useRefreshedItemHeight) {
107
+ var makeMentionToTypeaheadItem = function makeMentionToTypeaheadItem(_ref4) {
108
+ var useRefreshedItemHeight = _ref4.useRefreshedItemHeight,
109
+ profilecardProvider = _ref4.profilecardProvider;
113
110
  return function (mention) {
114
111
  var itemHeight = useRefreshedItemHeight ? _item.MENTION_ITEM_HEIGHT_REFRESHED : _item.MENTION_ITEM_HEIGHT;
115
112
  return {
116
113
  title: mention.id,
117
- render: function render(_ref4) {
118
- var isSelected = _ref4.isSelected,
119
- onClick = _ref4.onClick,
120
- onHover = _ref4.onHover;
121
- return /*#__PURE__*/_react.default.createElement(_item.MentionItem, {
114
+ render: function render(_ref5) {
115
+ var isSelected = _ref5.isSelected,
116
+ onClick = _ref5.onClick,
117
+ onHover = _ref5.onHover;
118
+ return (0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false) && (0, _platformFeatureFlags.fg)('platform_editor_mention_typeahead_profilecard') ? /*#__PURE__*/_react.default.createElement(_MentionItemWithProfileCard.MentionItemWithProfileCard, {
119
+ mention: mention,
120
+ selected: isSelected,
121
+ onSelection: onClick,
122
+ height: itemHeight,
123
+ profilecardProvider: profilecardProvider
124
+ }) : /*#__PURE__*/_react.default.createElement(_item.MentionItem, {
122
125
  mention: mention,
123
126
  selected: isSelected,
124
127
  onMouseEnter: onHover,
@@ -134,7 +137,9 @@ var makeMentionToTypeaheadItem = function makeMentionToTypeaheadItem(useRefreshe
134
137
  };
135
138
  };
136
139
  var mentionToTypeaheadItem = exports.mentionToTypeaheadItem = function mentionToTypeaheadItem(mention) {
137
- return makeMentionToTypeaheadItem((0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false))(mention);
140
+ return makeMentionToTypeaheadItem({
141
+ useRefreshedItemHeight: (0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false)
142
+ })(mention);
138
143
  };
139
144
 
140
145
  /**
@@ -163,12 +168,12 @@ function memoize(fn
163
168
  };
164
169
  }
165
170
  var buildAndSendElementsTypeAheadAnalytics = function buildAndSendElementsTypeAheadAnalytics(fireEvent) {
166
- return function (_ref5) {
167
- var query = _ref5.query,
168
- mentions = _ref5.mentions,
169
- stats = _ref5.stats,
170
- mentionTypeaheadSessionId = _ref5.mentionTypeaheadSessionId,
171
- agentAnalytics = _ref5.agentAnalytics;
171
+ return function (_ref6) {
172
+ var query = _ref6.query,
173
+ mentions = _ref6.mentions,
174
+ stats = _ref6.stats,
175
+ mentionTypeaheadSessionId = _ref6.mentionTypeaheadSessionId,
176
+ agentAnalytics = _ref6.agentAnalytics;
172
177
  var duration = 0;
173
178
  var userOrTeamIds = null;
174
179
  var teams = null;
@@ -270,19 +275,19 @@ var buildNodesForTeamMention = function buildNodesForTeamMention(schema, selecte
270
275
  * `createTypeAheadConfig` and intentionally mutated here as a
271
276
  * side-effect — preserves the existing single-shot semantics.
272
277
  */
273
- var makeTransformMentionsToTypeAheadItems = function makeTransformMentionsToTypeAheadItems(_ref6) {
274
- var fireEvent = _ref6.fireEvent,
275
- getFirstQueryWithoutResults = _ref6.getFirstQueryWithoutResults,
276
- setFirstQueryWithoutResults = _ref6.setFirstQueryWithoutResults,
277
- toItem = _ref6.toItem,
278
- enableAgentSectioning = _ref6.enableAgentSectioning;
279
- return function (_ref7) {
280
- var mentions = _ref7.mentions,
281
- query = _ref7.query,
282
- stats = _ref7.stats,
283
- mentionProvider = _ref7.mentionProvider,
284
- contextIdentifierProvider = _ref7.contextIdentifierProvider,
285
- sessionId = _ref7.sessionId;
278
+ var makeTransformMentionsToTypeAheadItems = function makeTransformMentionsToTypeAheadItems(_ref7) {
279
+ var fireEvent = _ref7.fireEvent,
280
+ getFirstQueryWithoutResults = _ref7.getFirstQueryWithoutResults,
281
+ setFirstQueryWithoutResults = _ref7.setFirstQueryWithoutResults,
282
+ toItem = _ref7.toItem,
283
+ enableAgentSectioning = _ref7.enableAgentSectioning;
284
+ return function (_ref8) {
285
+ var mentions = _ref8.mentions,
286
+ query = _ref8.query,
287
+ stats = _ref8.stats,
288
+ mentionProvider = _ref8.mentionProvider,
289
+ contextIdentifierProvider = _ref8.contextIdentifierProvider,
290
+ sessionId = _ref8.sessionId;
286
291
  var mentionItems = mentions.map(function (mention) {
287
292
  return toItem(mention);
288
293
  });
@@ -292,7 +297,7 @@ var makeTransformMentionsToTypeAheadItems = function makeTransformMentionsToType
292
297
  var realMentions = mentions.filter(function (mention) {
293
298
  return !isLoadingPlaceholder(mention);
294
299
  });
295
- var agentCount = realMentions.filter(isAgentMention).length;
300
+ var agentCount = realMentions.filter(_utils3.isAgentMention).length;
296
301
  var agentAnalytics = {
297
302
  agentCount: agentCount,
298
303
  agentSectioningEnabled: enableAgentSectioning
@@ -329,17 +334,18 @@ var makeTransformMentionsToTypeAheadItems = function makeTransformMentionsToType
329
334
  })(mentionItems);
330
335
  };
331
336
  };
332
- var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeAheadConfig(_ref8) {
333
- var sanitizePrivateContent = _ref8.sanitizePrivateContent,
334
- mentionInsertDisplayName = _ref8.mentionInsertDisplayName,
335
- fireEvent = _ref8.fireEvent,
336
- HighlightComponent = _ref8.HighlightComponent,
337
- api = _ref8.api,
338
- handleMentionsChanged = _ref8.handleMentionsChanged,
339
- _ref8$enableAgentSect = _ref8.enableAgentSectioning,
340
- enableAgentSectioning = _ref8$enableAgentSect === void 0 ? false : _ref8$enableAgentSect,
341
- _ref8$showAgentMentio = _ref8.showAgentMentionsLabsLozenge,
342
- showAgentMentionsLabsLozenge = _ref8$showAgentMentio === void 0 ? false : _ref8$showAgentMentio;
337
+ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeAheadConfig(_ref9) {
338
+ var sanitizePrivateContent = _ref9.sanitizePrivateContent,
339
+ mentionInsertDisplayName = _ref9.mentionInsertDisplayName,
340
+ fireEvent = _ref9.fireEvent,
341
+ HighlightComponent = _ref9.HighlightComponent,
342
+ api = _ref9.api,
343
+ handleMentionsChanged = _ref9.handleMentionsChanged,
344
+ _ref9$enableAgentSect = _ref9.enableAgentSectioning,
345
+ enableAgentSectioning = _ref9$enableAgentSect === void 0 ? false : _ref9$enableAgentSect,
346
+ _ref9$showAgentMentio = _ref9.showAgentMentionsLabsLozenge,
347
+ showAgentMentionsLabsLozenge = _ref9$showAgentMentio === void 0 ? false : _ref9$showAgentMentio,
348
+ profilecardProvider = _ref9.profilecardProvider;
343
349
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
344
350
  var sessionId = (0, _uuid.default)();
345
351
  var firstQueryWithoutResults = null;
@@ -353,7 +359,10 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
353
359
  setFirstQueryWithoutResults: function setFirstQueryWithoutResults(query) {
354
360
  firstQueryWithoutResults = query;
355
361
  },
356
- toItem: memoize(makeMentionToTypeaheadItem(enableAgentSectioning)).call
362
+ toItem: memoize(makeMentionToTypeaheadItem({
363
+ useRefreshedItemHeight: enableAgentSectioning,
364
+ profilecardProvider: profilecardProvider
365
+ })).call
357
366
  });
358
367
  var typeAhead = {
359
368
  id: _typeAhead.TypeAheadAvailableNodes.MENTION,
@@ -368,17 +377,17 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
368
377
  }
369
378
  return null;
370
379
  },
371
- getItems: function getItems(_ref9) {
380
+ getItems: function getItems(_ref0) {
372
381
  var _api$contextIdentifie, _api$contextIdentifie2;
373
- var query = _ref9.query,
374
- editorState = _ref9.editorState;
382
+ var query = _ref0.query,
383
+ editorState = _ref0.editorState;
375
384
  var pluginState = (0, _utils2.getMentionPluginState)(editorState);
376
385
  if (!(pluginState !== null && pluginState !== void 0 && pluginState.mentionProvider)) {
377
386
  return Promise.resolve([]);
378
387
  }
379
388
  var mentionProvider = pluginState.mentionProvider;
380
- var _ref0 = (_api$contextIdentifie = api === null || api === void 0 || (_api$contextIdentifie2 = api.contextIdentifier) === null || _api$contextIdentifie2 === void 0 ? void 0 : _api$contextIdentifie2.sharedState.currentState()) !== null && _api$contextIdentifie !== void 0 ? _api$contextIdentifie : {},
381
- contextIdentifierProvider = _ref0.contextIdentifierProvider;
389
+ var _ref1 = (_api$contextIdentifie = api === null || api === void 0 || (_api$contextIdentifie2 = api.contextIdentifier) === null || _api$contextIdentifie2 === void 0 ? void 0 : _api$contextIdentifie2.sharedState.currentState()) !== null && _api$contextIdentifie !== void 0 ? _api$contextIdentifie : {},
390
+ contextIdentifierProvider = _ref1.contextIdentifierProvider;
382
391
  return new Promise(function (resolve, reject) {
383
392
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
384
393
  var key = "loadingMentionsForTypeAhead_".concat((0, _uuid.default)());
@@ -413,8 +422,8 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
413
422
  }));
414
423
  });
415
424
  },
416
- getSections: function getSections(_ref1) {
417
- var intl = _ref1.intl;
425
+ getSections: function getSections(_ref10) {
426
+ var intl = _ref10.intl;
418
427
  if (!enableAgentSectioning) {
419
428
  return [];
420
429
  }
@@ -448,12 +457,12 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
448
457
  onOpen: function onOpen() {
449
458
  firstQueryWithoutResults = null;
450
459
  },
451
- selectItem: function selectItem(state, item, insert, _ref10) {
460
+ selectItem: function selectItem(state, item, insert, _ref11) {
452
461
  var _api$contextIdentifie3, _api$contextIdentifie4;
453
- var mode = _ref10.mode,
454
- stats = _ref10.stats,
455
- query = _ref10.query,
456
- sourceListItem = _ref10.sourceListItem;
462
+ var mode = _ref11.mode,
463
+ stats = _ref11.stats,
464
+ query = _ref11.query,
465
+ sourceListItem = _ref11.sourceListItem;
457
466
  var schema = state.schema;
458
467
 
459
468
  // Placeholder isn't selectable. Return `false` (not a transaction) so
@@ -470,12 +479,12 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
470
479
  accessLevel = _item$mention.accessLevel,
471
480
  userType = _item$mention.userType,
472
481
  isXProductUser = _item$mention.isXProductUser;
473
- var _ref11 = (_api$contextIdentifie3 = api === null || api === void 0 || (_api$contextIdentifie4 = api.contextIdentifier) === null || _api$contextIdentifie4 === void 0 ? void 0 : _api$contextIdentifie4.sharedState.currentState()) !== null && _api$contextIdentifie3 !== void 0 ? _api$contextIdentifie3 : {},
474
- contextIdentifierProvider = _ref11.contextIdentifierProvider;
482
+ var _ref12 = (_api$contextIdentifie3 = api === null || api === void 0 || (_api$contextIdentifie4 = api.contextIdentifier) === null || _api$contextIdentifie4 === void 0 ? void 0 : _api$contextIdentifie4.sharedState.currentState()) !== null && _api$contextIdentifie3 !== void 0 ? _api$contextIdentifie3 : {},
483
+ contextIdentifierProvider = _ref12.contextIdentifierProvider;
475
484
  var mentionContext = _objectSpread(_objectSpread({}, contextIdentifierProvider), {}, {
476
485
  sessionId: sessionId
477
486
  });
478
- var isAgentMentionSelection = isAgentMention(item.mention);
487
+ var isAgentMentionSelection = (0, _utils3.isAgentMention)(item.mention);
479
488
  var isAgentMentionInsertion = isAgentMentionSelection && (0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false);
480
489
  // userType can be missing for provider-only agent mentions. Copy/paste cannot
481
490
  // see appType, so persist APP only when there is no explicit userType.
@@ -598,11 +607,11 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
598
607
  }
599
608
  return tr;
600
609
  },
601
- dismiss: function dismiss(_ref12) {
602
- var editorState = _ref12.editorState,
603
- query = _ref12.query,
604
- stats = _ref12.stats,
605
- wasItemInserted = _ref12.wasItemInserted;
610
+ dismiss: function dismiss(_ref13) {
611
+ var editorState = _ref13.editorState,
612
+ query = _ref13.query,
613
+ stats = _ref13.stats,
614
+ wasItemInserted = _ref13.wasItemInserted;
606
615
  firstQueryWithoutResults = null;
607
616
  var pickerElapsedTime = stats.startedAt ? performance.now() - stats.startedAt : 0;
608
617
  if (!wasItemInserted) {
@@ -646,10 +655,10 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
646
655
  * so we only attach it when the gate is on — otherwise the proven
647
656
  * single-shot `getItems` path continues to drive every consumer.
648
657
  */
649
- var subscribeToItemsUpdates = function subscribeToItemsUpdates(_ref13) {
658
+ var subscribeToItemsUpdates = function subscribeToItemsUpdates(_ref14) {
650
659
  var _api$contextIdentifie5, _api$contextIdentifie6;
651
- var query = _ref13.query,
652
- editorState = _ref13.editorState;
660
+ var query = _ref14.query,
661
+ editorState = _ref14.editorState;
653
662
  var pluginState = (0, _utils2.getMentionPluginState)(editorState);
654
663
  if (!(pluginState !== null && pluginState !== void 0 && pluginState.mentionProvider)) {
655
664
  return {
@@ -660,8 +669,8 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
660
669
  };
661
670
  }
662
671
  var mentionProvider = pluginState.mentionProvider;
663
- var _ref14 = (_api$contextIdentifie5 = api === null || api === void 0 || (_api$contextIdentifie6 = api.contextIdentifier) === null || _api$contextIdentifie6 === void 0 ? void 0 : _api$contextIdentifie6.sharedState.currentState()) !== null && _api$contextIdentifie5 !== void 0 ? _api$contextIdentifie5 : {},
664
- contextIdentifierProvider = _ref14.contextIdentifierProvider;
672
+ var _ref15 = (_api$contextIdentifie5 = api === null || api === void 0 || (_api$contextIdentifie6 = api.contextIdentifier) === null || _api$contextIdentifie6 === void 0 ? void 0 : _api$contextIdentifie6.sharedState.currentState()) !== null && _api$contextIdentifie5 !== void 0 ? _api$contextIdentifie5 : {},
673
+ contextIdentifierProvider = _ref15.contextIdentifierProvider;
665
674
 
666
675
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
667
676
  var key = "loadingMentionsForTypeAhead_".concat((0, _uuid.default)());
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.shouldKeepInviteItem = exports.isTeamType = exports.isTeamStats = exports.isInviteItem = void 0;
6
+ exports.shouldKeepInviteItem = exports.isTeamType = exports.isTeamStats = exports.isInviteItem = exports.isAgentUserType = exports.isAgentMention = void 0;
7
7
  var _InviteItem = require("../InviteItem");
8
8
  // Ignored via go/ees005
9
9
  // eslint-disable-next-line require-unicode-regexp
@@ -23,6 +23,12 @@ var isTeamStats = exports.isTeamStats = function isTeamStats(stat) {
23
23
  var isInviteItem = exports.isInviteItem = function isInviteItem(mention) {
24
24
  return mention && mention.id === _InviteItem.INVITE_ITEM_DESCRIPTION.id;
25
25
  };
26
+ var isAgentUserType = exports.isAgentUserType = function isAgentUserType(userType) {
27
+ return userType === 'APP' || userType === 'AGENT';
28
+ };
29
+ var isAgentMention = exports.isAgentMention = function isAgentMention(mention) {
30
+ return isAgentUserType(mention.userType) || mention.appType === 'agent';
31
+ };
26
32
 
27
33
  /**
28
34
  * Actions
@@ -14,9 +14,11 @@ var _focusTrap = _interopRequireDefault(require("focus-trap"));
14
14
  */
15
15
 
16
16
  var useFocusTrap = exports.useFocusTrap = function useFocusTrap(_ref) {
17
- var targetRef = _ref.targetRef;
17
+ var targetRef = _ref.targetRef,
18
+ _ref$enabled = _ref.enabled,
19
+ enabled = _ref$enabled === void 0 ? true : _ref$enabled;
18
20
  (0, _react.useEffect)(function () {
19
- if (!targetRef) {
21
+ if (!targetRef || !enabled) {
20
22
  return;
21
23
  }
22
24
  var trapConfig = {
@@ -40,5 +42,5 @@ var useFocusTrap = exports.useFocusTrap = function useFocusTrap(_ref) {
40
42
  }
41
43
  focusTrap.deactivate();
42
44
  };
43
- }, [targetRef]);
45
+ }, [targetRef, enabled]);
44
46
  };
@@ -5,11 +5,11 @@ import uuid from 'uuid';
5
5
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
6
6
  import { toolbarInsertBlockMessages as messages, mentionMessages } from '@atlaskit/editor-common/messages';
7
7
  import { WithProviders } from '@atlaskit/editor-common/provider-factory';
8
- import { IconMention } from '@atlaskit/editor-common/quick-insert';
8
+ import { IconMention } from '@atlaskit/editor-common/assets';
9
9
  import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
10
10
  import { MentionNameStatus, isPromise } from '@atlaskit/mention/types';
11
11
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
12
- import { fg } from '@atlaskit/platform-feature-flags';
12
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
13
13
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
14
14
  import { insertMention } from './editor-commands';
15
15
  import { mentionNodeSpec } from './nodeviews/mentionNodeSpec';
@@ -19,6 +19,7 @@ import { ACTIONS, createMentionPlugin } from './pm-plugins/main';
19
19
  import { InlineInvitePopupContainer } from './ui/InlineInvitePopupContainer';
20
20
  import { SecondaryToolbarComponent } from './ui/SecondaryToolbarComponent';
21
21
  import { createTypeAheadConfig } from './ui/type-ahead';
22
+ import { getMentionQuickInsertComponents } from './ui/quick-insert/getMentionQuickInsertComponents';
22
23
  const processName = (name, intl) => {
23
24
  const unknownLabel = intl.formatMessage(mentionMessages.unknownLabel);
24
25
  if (name.status === MentionNameStatus.OK) {
@@ -106,9 +107,18 @@ const mentionsPlugin = ({
106
107
  handleMentionsChanged: options === null || options === void 0 ? void 0 : options.handleMentionsChanged,
107
108
  enableAgentSectioning: options === null || options === void 0 ? void 0 : options.enableAgentSectioning,
108
109
  showAgentMentionsLabsLozenge: options === null || options === void 0 ? void 0 : options.showAgentMentionsLabsLozenge,
110
+ profilecardProvider: options === null || options === void 0 ? void 0 : options.profilecardProvider,
109
111
  fireEvent,
110
112
  api
111
113
  });
114
+ const isRegisteredSlashCommandEnabled = isExperimentEnabled('platform_editor_slash_command');
115
+ if (isRegisteredSlashCommandEnabled) {
116
+ var _api$uiControlRegistr;
117
+ api === null || api === void 0 ? void 0 : (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 ? void 0 : _api$uiControlRegistr.actions.register(getMentionQuickInsertComponents({
118
+ api,
119
+ typeAhead
120
+ }));
121
+ }
112
122
  return {
113
123
  name: 'mention',
114
124
  nodes() {
@@ -256,7 +266,7 @@ const mentionsPlugin = ({
256
266
  };
257
267
  },
258
268
  pluginsOptions: {
259
- quickInsert: ({
269
+ quickInsert: isRegisteredSlashCommandEnabled ? undefined : ({
260
270
  formatMessage
261
271
  }) => [{
262
272
  id: 'mention',
@@ -51,7 +51,7 @@ const AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
51
51
  const AGENT_MENTION_INACTIVITY_MS = 3000;
52
52
  const MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
53
53
  const PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
54
- const PACKAGE_VERSION = "16.2.0";
54
+ const PACKAGE_VERSION = "17.0.1";
55
55
  const setProvider = provider => (state, dispatch) => {
56
56
  if (dispatch) {
57
57
  dispatch(state.tr.setMeta(mentionPluginKey, {
@@ -24,5 +24,10 @@ export function AnchoredPopup({
24
24
  placement: "bottom-start",
25
25
  content: renderContent,
26
26
  trigger: renderTrigger
27
+ // Drops this popup's own `overflow: auto`, which otherwise clips the role picker's
28
+ // menu — it renders as a normal DOM child here (not a body portal) so it stays inside
29
+ // this popup's focus trap.
30
+ ,
31
+ shouldRenderToParent: true
27
32
  });
28
33
  }
@@ -90,7 +90,6 @@ export const InlineInvitePopupContainer = ({
90
90
  }
91
91
  const invitedUser = (_result$invited$ = result.invited[0]) !== null && _result$invited$ !== void 0 ? _result$invited$ : result.requested[0];
92
92
  if (!invitedUser || !(api !== null && api !== void 0 && (_api$core2 = api.core) !== null && _api$core2 !== void 0 && (_api$core2$actions = _api$core2.actions) !== null && _api$core2$actions !== void 0 && _api$core2$actions.execute) || !(api !== null && api !== void 0 && (_api$mention = api.mention) !== null && _api$mention !== void 0 && (_api$mention$commands = _api$mention.commands) !== null && _api$mention$commands !== void 0 && _api$mention$commands.insertMention)) {
93
- removePendingMention();
94
93
  return;
95
94
  }
96
95
  const {
@@ -111,7 +110,7 @@ export const InlineInvitePopupContainer = ({
111
110
  }));
112
111
  pendingMentionRef.current = null;
113
112
  setAnchorElement(null);
114
- }, [api, removePendingMention]);
113
+ }, [api]);
115
114
  const handleReady = useCallback(show => {
116
115
  if (!provider) {
117
116
  return;
@@ -1,6 +1,6 @@
1
1
  import React, { useRef, useLayoutEffect, useEffect, Suspense } from 'react';
2
2
  import { fg } from '@atlaskit/platform-feature-flags';
3
- import { Popper as ReactPopper } from '@atlaskit/popper';
3
+ import { Popper as ReactPopper } from '@atlaskit/popper/main';
4
4
  import Portal from '@atlaskit/portal';
5
5
  import { layers } from '@atlaskit/theme/constants';
6
6
  import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
@@ -73,20 +73,22 @@ function useResizeAwarePopper({
73
73
  */
74
74
  export function Popup({
75
75
  referenceElement,
76
- children
76
+ children,
77
+ placement = 'bottom-end',
78
+ offset = [0, 8],
79
+ disableFocusTrap = false
77
80
  }) {
78
81
  const [targetRef, setPopupRef] = React.useState(null);
79
82
  useFocusTrap({
80
- targetRef: targetRef
83
+ targetRef: targetRef,
84
+ enabled: !disableFocusTrap
81
85
  });
82
86
  return /*#__PURE__*/React.createElement(Suspense, null, /*#__PURE__*/React.createElement(Portal, {
83
87
  zIndex: layers.modal()
84
88
  }, /*#__PURE__*/React.createElement(ReactPopper, {
85
- referenceElement: referenceElement
86
- // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
87
- ,
88
- offset: [0, 8],
89
- placement: "bottom-end",
89
+ referenceElement: referenceElement,
90
+ offset: offset,
91
+ placement: placement,
90
92
  strategy: "fixed"
91
93
  // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
92
94
  ,
@@ -84,7 +84,11 @@ export function ProfileCardComponent({
84
84
  activeMention,
85
85
  dom,
86
86
  closeComponent,
87
- onAgentMentionChatClick
87
+ onAgentMentionChatClick,
88
+ placement,
89
+ offset,
90
+ disableFocusTrap,
91
+ hideActions
88
92
  }) {
89
93
  var _ref;
90
94
  const [provider, setProvider] = useState(undefined);
@@ -111,20 +115,28 @@ export function ProfileCardComponent({
111
115
  });
112
116
  if (!expVal('platform_editor_agent_mentions', 'isEnabled', false)) {
113
117
  return /*#__PURE__*/React.createElement(Popup, {
114
- referenceElement: dom
118
+ referenceElement: dom,
119
+ placement: placement,
120
+ offset: offset,
121
+ disableFocusTrap: disableFocusTrap
115
122
  }, /*#__PURE__*/React.createElement(UserProfileCardContent, {
116
123
  accessLevel: accessLevel,
117
124
  id: id,
118
125
  provider: provider,
119
- text: text
126
+ text: text,
127
+ hideActions: hideActions
120
128
  }));
121
129
  }
122
130
  const isAgentMention = isAgentMentionType(userType);
123
131
  return /*#__PURE__*/React.createElement(Popup, {
124
- referenceElement: dom
132
+ referenceElement: dom,
133
+ placement: placement,
134
+ offset: offset,
135
+ disableFocusTrap: disableFocusTrap
125
136
  }, isAgentMention && provider && id ? /*#__PURE__*/React.createElement(AgentProfileCardContent, {
126
137
  accountId: id,
127
138
  provider: provider,
139
+ hideActions: hideActions,
128
140
  text: expVal('platform_editor_reduced_agent_profile_cards', 'isEnabled', false) ? text : undefined,
129
141
  onChatClick: onAgentMentionChatClick && fg('platform_editor_agent_mentions_drop_one_fixes') ? (event, agentStudioId) =>
130
142
  // agentMentionContext is already captured in the onAgentMentionChatClick
@@ -134,16 +146,18 @@ export function ProfileCardComponent({
134
146
  accessLevel: accessLevel,
135
147
  id: id,
136
148
  provider: provider,
137
- text: text
149
+ text: text,
150
+ hideActions: hideActions
138
151
  }));
139
152
  }
140
153
  const UserProfileCardContent = ({
141
154
  accessLevel,
142
155
  id,
143
156
  provider,
144
- text
157
+ text,
158
+ hideActions
145
159
  }) => {
146
- const actions = useMemo(() => provider === null || provider === void 0 ? void 0 : provider.getActions(id, text !== null && text !== void 0 ? text : '', accessLevel), [accessLevel, id, provider, text]);
160
+ const actions = useMemo(() => hideActions ? [] : provider === null || provider === void 0 ? void 0 : provider.getActions(id, text !== null && text !== void 0 ? text : '', accessLevel), [hideActions, accessLevel, id, provider, text]);
147
161
  const {
148
162
  data,
149
163
  reportingLinesData,
@@ -186,7 +200,8 @@ const AgentProfileCardContent = ({
186
200
  accountId,
187
201
  provider,
188
202
  text,
189
- onChatClick
203
+ onChatClick,
204
+ hideActions
190
205
  }) => {
191
206
  const agentName = (text !== null && text !== void 0 ? text : '').replace(LEADING_AT_SIGN_RE, '');
192
207
  return expVal('platform_editor_reduced_agent_profile_cards', 'isEnabled', false) ? /*#__PURE__*/React.createElement(AgentProfileCardResourcedLazy, {
@@ -194,11 +209,21 @@ const AgentProfileCardContent = ({
194
209
  cloudId: provider.cloudId,
195
210
  resourceClient: provider.resourceClient,
196
211
  agentName: agentName,
197
- onChatClick: onChatClick
212
+ onChatClick: onChatClick,
213
+ hideAgentActions: hideActions,
214
+ hideConversationStarters: hideActions,
215
+ hideStarButton: hideActions,
216
+ hideAiDisclaimer: hideActions,
217
+ showCreatorNameWithoutLink: hideActions
198
218
  }) : /*#__PURE__*/React.createElement(AgentProfileCardResourcedLazy, {
199
219
  accountId: accountId,
200
220
  cloudId: provider.cloudId,
201
221
  resourceClient: provider.resourceClient,
202
- onChatClick: onChatClick
222
+ onChatClick: onChatClick,
223
+ hideAgentActions: hideActions,
224
+ hideConversationStarters: hideActions,
225
+ hideStarButton: hideActions,
226
+ hideAiDisclaimer: hideActions,
227
+ showCreatorNameWithoutLink: hideActions
203
228
  });
204
229
  };
@@ -0,0 +1,36 @@
1
+ import React, { useCallback } from 'react';
2
+ import { useIntl } from 'react-intl';
3
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
+ import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
5
+ import { IconMention } from '@atlaskit/editor-common/assets';
6
+ import { QuickInsertMenuItem } from '@atlaskit/editor-common/quick-insert/menu-item';
7
+ import { mentionPluginKey } from '../../pm-plugins/key';
8
+ export const MentionQuickInsertMenuItem = ({
9
+ api,
10
+ typeAhead
11
+ }) => {
12
+ const {
13
+ formatMessage
14
+ } = useIntl();
15
+ const onSelect = useCallback(({
16
+ editorView,
17
+ insert
18
+ }) => {
19
+ var _mentionPluginKey$get, _api$typeAhead;
20
+ if (((_mentionPluginKey$get = mentionPluginKey.getState(editorView.state)) === null || _mentionPluginKey$get === void 0 ? void 0 : _mentionPluginKey$get.canInsertMention) === false) {
21
+ return false;
22
+ }
23
+ const tr = insert(undefined);
24
+ api === null || api === void 0 ? void 0 : (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 ? void 0 : _api$typeAhead.actions.openAtTransaction({
25
+ triggerHandler: typeAhead,
26
+ inputMethod: INPUT_METHOD.QUICK_INSERT
27
+ })(tr);
28
+ return tr;
29
+ }, [api, typeAhead]);
30
+ return /*#__PURE__*/React.createElement(QuickInsertMenuItem, {
31
+ iconBefore: /*#__PURE__*/React.createElement(IconMention, null),
32
+ onSelect: onSelect,
33
+ shortcut: "@",
34
+ title: formatMessage(messages.mention)
35
+ });
36
+ };
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
3
+ import { createQuickInsertMatcher } from '@atlaskit/editor-common/quick-insert/create-quick-insert-matcher';
4
+ import { MEDIA_SECTION, MENTION_MENU_ITEM } from '@atlaskit/editor-common/quick-insert/keys';
5
+ import { MEDIA_SECTION_RANK } from '@atlaskit/editor-common/quick-insert/rank';
6
+ import { MentionQuickInsertMenuItem } from './MentionQuickInsertMenuItem';
7
+ export const getMentionQuickInsertComponents = ({
8
+ api,
9
+ typeAhead
10
+ }) => [{
11
+ key: MENTION_MENU_ITEM.key,
12
+ type: MENTION_MENU_ITEM.type,
13
+ parents: [{
14
+ key: MEDIA_SECTION.key,
15
+ type: MEDIA_SECTION.type,
16
+ rank: MEDIA_SECTION_RANK[MENTION_MENU_ITEM.key]
17
+ }],
18
+ match: createQuickInsertMatcher(({
19
+ formatMessage
20
+ }) => ({
21
+ description: formatMessage(messages.mentionDescription),
22
+ keywords: ['team', 'user'],
23
+ shortcut: '@',
24
+ title: formatMessage(messages.mention)
25
+ })),
26
+ component: () => /*#__PURE__*/React.createElement(MentionQuickInsertMenuItem, {
27
+ api: api,
28
+ typeAhead: typeAhead
29
+ })
30
+ }];