@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
@@ -27,13 +27,8 @@ import { getMentionPluginState } from '../../pm-plugins/utils';
27
27
  import InviteItem, { INVITE_ITEM_DESCRIPTION } from '../InviteItem';
28
28
  import InviteItemWithEmailDomain from '../InviteItem/InviteItemWithEmailDomain';
29
29
  import { buildTypeAheadCancelPayload, buildTypeAheadInsertedPayload, buildTypeAheadInviteItemClickedPayload, buildTypeAheadInviteItemViewedPayload, buildTypeAheadRenderedPayload } from './analytics';
30
- import { isInviteItem, isTeamStats, isTeamType, shouldKeepInviteItem } from './utils';
31
- var isAgentUserType = function isAgentUserType(userType) {
32
- return userType === 'APP' || userType === 'AGENT';
33
- };
34
- var isAgentMention = function isAgentMention(mention) {
35
- return isAgentUserType(mention.userType) || mention.appType === 'agent';
36
- };
30
+ import { MentionItemWithProfileCard } from './MentionItemWithProfileCard';
31
+ import { isAgentMention, isInviteItem, isTeamStats, isTeamType, shouldKeepInviteItem } from './utils';
37
32
  var isAgentTypeAheadItem = function isAgentTypeAheadItem(item) {
38
33
  return item.mention ? isAgentMention(item.mention) : false;
39
34
  };
@@ -100,16 +95,24 @@ var withInviteItem = function withInviteItem(_ref3) {
100
95
  inviteItem]);
101
96
  };
102
97
  };
103
- var makeMentionToTypeaheadItem = function makeMentionToTypeaheadItem(useRefreshedItemHeight) {
98
+ var makeMentionToTypeaheadItem = function makeMentionToTypeaheadItem(_ref4) {
99
+ var useRefreshedItemHeight = _ref4.useRefreshedItemHeight,
100
+ profilecardProvider = _ref4.profilecardProvider;
104
101
  return function (mention) {
105
102
  var itemHeight = useRefreshedItemHeight ? MENTION_ITEM_HEIGHT_REFRESHED : MENTION_ITEM_HEIGHT;
106
103
  return {
107
104
  title: mention.id,
108
- render: function render(_ref4) {
109
- var isSelected = _ref4.isSelected,
110
- onClick = _ref4.onClick,
111
- onHover = _ref4.onHover;
112
- return /*#__PURE__*/React.createElement(MentionItem, {
105
+ render: function render(_ref5) {
106
+ var isSelected = _ref5.isSelected,
107
+ onClick = _ref5.onClick,
108
+ onHover = _ref5.onHover;
109
+ return expVal('platform_editor_agent_mentions', 'isEnabled', false) && fg('platform_editor_mention_typeahead_profilecard') ? /*#__PURE__*/React.createElement(MentionItemWithProfileCard, {
110
+ mention: mention,
111
+ selected: isSelected,
112
+ onSelection: onClick,
113
+ height: itemHeight,
114
+ profilecardProvider: profilecardProvider
115
+ }) : /*#__PURE__*/React.createElement(MentionItem, {
113
116
  mention: mention,
114
117
  selected: isSelected,
115
118
  onMouseEnter: onHover,
@@ -125,7 +128,9 @@ var makeMentionToTypeaheadItem = function makeMentionToTypeaheadItem(useRefreshe
125
128
  };
126
129
  };
127
130
  export var mentionToTypeaheadItem = function mentionToTypeaheadItem(mention) {
128
- return makeMentionToTypeaheadItem(expVal('platform_editor_agent_mentions', 'isEnabled', false))(mention);
131
+ return makeMentionToTypeaheadItem({
132
+ useRefreshedItemHeight: expVal('platform_editor_agent_mentions', 'isEnabled', false)
133
+ })(mention);
129
134
  };
130
135
 
131
136
  /**
@@ -154,12 +159,12 @@ export function memoize(fn
154
159
  };
155
160
  }
156
161
  var buildAndSendElementsTypeAheadAnalytics = function buildAndSendElementsTypeAheadAnalytics(fireEvent) {
157
- return function (_ref5) {
158
- var query = _ref5.query,
159
- mentions = _ref5.mentions,
160
- stats = _ref5.stats,
161
- mentionTypeaheadSessionId = _ref5.mentionTypeaheadSessionId,
162
- agentAnalytics = _ref5.agentAnalytics;
162
+ return function (_ref6) {
163
+ var query = _ref6.query,
164
+ mentions = _ref6.mentions,
165
+ stats = _ref6.stats,
166
+ mentionTypeaheadSessionId = _ref6.mentionTypeaheadSessionId,
167
+ agentAnalytics = _ref6.agentAnalytics;
163
168
  var duration = 0;
164
169
  var userOrTeamIds = null;
165
170
  var teams = null;
@@ -261,19 +266,19 @@ var buildNodesForTeamMention = function buildNodesForTeamMention(schema, selecte
261
266
  * `createTypeAheadConfig` and intentionally mutated here as a
262
267
  * side-effect — preserves the existing single-shot semantics.
263
268
  */
264
- var makeTransformMentionsToTypeAheadItems = function makeTransformMentionsToTypeAheadItems(_ref6) {
265
- var fireEvent = _ref6.fireEvent,
266
- getFirstQueryWithoutResults = _ref6.getFirstQueryWithoutResults,
267
- setFirstQueryWithoutResults = _ref6.setFirstQueryWithoutResults,
268
- toItem = _ref6.toItem,
269
- enableAgentSectioning = _ref6.enableAgentSectioning;
270
- return function (_ref7) {
271
- var mentions = _ref7.mentions,
272
- query = _ref7.query,
273
- stats = _ref7.stats,
274
- mentionProvider = _ref7.mentionProvider,
275
- contextIdentifierProvider = _ref7.contextIdentifierProvider,
276
- sessionId = _ref7.sessionId;
269
+ var makeTransformMentionsToTypeAheadItems = function makeTransformMentionsToTypeAheadItems(_ref7) {
270
+ var fireEvent = _ref7.fireEvent,
271
+ getFirstQueryWithoutResults = _ref7.getFirstQueryWithoutResults,
272
+ setFirstQueryWithoutResults = _ref7.setFirstQueryWithoutResults,
273
+ toItem = _ref7.toItem,
274
+ enableAgentSectioning = _ref7.enableAgentSectioning;
275
+ return function (_ref8) {
276
+ var mentions = _ref8.mentions,
277
+ query = _ref8.query,
278
+ stats = _ref8.stats,
279
+ mentionProvider = _ref8.mentionProvider,
280
+ contextIdentifierProvider = _ref8.contextIdentifierProvider,
281
+ sessionId = _ref8.sessionId;
277
282
  var mentionItems = mentions.map(function (mention) {
278
283
  return toItem(mention);
279
284
  });
@@ -320,17 +325,18 @@ var makeTransformMentionsToTypeAheadItems = function makeTransformMentionsToType
320
325
  })(mentionItems);
321
326
  };
322
327
  };
323
- export var createTypeAheadConfig = function createTypeAheadConfig(_ref8) {
324
- var sanitizePrivateContent = _ref8.sanitizePrivateContent,
325
- mentionInsertDisplayName = _ref8.mentionInsertDisplayName,
326
- fireEvent = _ref8.fireEvent,
327
- HighlightComponent = _ref8.HighlightComponent,
328
- api = _ref8.api,
329
- handleMentionsChanged = _ref8.handleMentionsChanged,
330
- _ref8$enableAgentSect = _ref8.enableAgentSectioning,
331
- enableAgentSectioning = _ref8$enableAgentSect === void 0 ? false : _ref8$enableAgentSect,
332
- _ref8$showAgentMentio = _ref8.showAgentMentionsLabsLozenge,
333
- showAgentMentionsLabsLozenge = _ref8$showAgentMentio === void 0 ? false : _ref8$showAgentMentio;
328
+ export var createTypeAheadConfig = function createTypeAheadConfig(_ref9) {
329
+ var sanitizePrivateContent = _ref9.sanitizePrivateContent,
330
+ mentionInsertDisplayName = _ref9.mentionInsertDisplayName,
331
+ fireEvent = _ref9.fireEvent,
332
+ HighlightComponent = _ref9.HighlightComponent,
333
+ api = _ref9.api,
334
+ handleMentionsChanged = _ref9.handleMentionsChanged,
335
+ _ref9$enableAgentSect = _ref9.enableAgentSectioning,
336
+ enableAgentSectioning = _ref9$enableAgentSect === void 0 ? false : _ref9$enableAgentSect,
337
+ _ref9$showAgentMentio = _ref9.showAgentMentionsLabsLozenge,
338
+ showAgentMentionsLabsLozenge = _ref9$showAgentMentio === void 0 ? false : _ref9$showAgentMentio,
339
+ profilecardProvider = _ref9.profilecardProvider;
334
340
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
335
341
  var sessionId = uuid();
336
342
  var firstQueryWithoutResults = null;
@@ -344,7 +350,10 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref8) {
344
350
  setFirstQueryWithoutResults: function setFirstQueryWithoutResults(query) {
345
351
  firstQueryWithoutResults = query;
346
352
  },
347
- toItem: memoize(makeMentionToTypeaheadItem(enableAgentSectioning)).call
353
+ toItem: memoize(makeMentionToTypeaheadItem({
354
+ useRefreshedItemHeight: enableAgentSectioning,
355
+ profilecardProvider: profilecardProvider
356
+ })).call
348
357
  });
349
358
  var typeAhead = {
350
359
  id: TypeAheadAvailableNodes.MENTION,
@@ -359,17 +368,17 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref8) {
359
368
  }
360
369
  return null;
361
370
  },
362
- getItems: function getItems(_ref9) {
371
+ getItems: function getItems(_ref0) {
363
372
  var _api$contextIdentifie, _api$contextIdentifie2;
364
- var query = _ref9.query,
365
- editorState = _ref9.editorState;
373
+ var query = _ref0.query,
374
+ editorState = _ref0.editorState;
366
375
  var pluginState = getMentionPluginState(editorState);
367
376
  if (!(pluginState !== null && pluginState !== void 0 && pluginState.mentionProvider)) {
368
377
  return Promise.resolve([]);
369
378
  }
370
379
  var mentionProvider = pluginState.mentionProvider;
371
- 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 : {},
372
- contextIdentifierProvider = _ref0.contextIdentifierProvider;
380
+ 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 : {},
381
+ contextIdentifierProvider = _ref1.contextIdentifierProvider;
373
382
  return new Promise(function (resolve, reject) {
374
383
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
375
384
  var key = "loadingMentionsForTypeAhead_".concat(uuid());
@@ -404,8 +413,8 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref8) {
404
413
  }));
405
414
  });
406
415
  },
407
- getSections: function getSections(_ref1) {
408
- var intl = _ref1.intl;
416
+ getSections: function getSections(_ref10) {
417
+ var intl = _ref10.intl;
409
418
  if (!enableAgentSectioning) {
410
419
  return [];
411
420
  }
@@ -439,12 +448,12 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref8) {
439
448
  onOpen: function onOpen() {
440
449
  firstQueryWithoutResults = null;
441
450
  },
442
- selectItem: function selectItem(state, item, insert, _ref10) {
451
+ selectItem: function selectItem(state, item, insert, _ref11) {
443
452
  var _api$contextIdentifie3, _api$contextIdentifie4;
444
- var mode = _ref10.mode,
445
- stats = _ref10.stats,
446
- query = _ref10.query,
447
- sourceListItem = _ref10.sourceListItem;
453
+ var mode = _ref11.mode,
454
+ stats = _ref11.stats,
455
+ query = _ref11.query,
456
+ sourceListItem = _ref11.sourceListItem;
448
457
  var schema = state.schema;
449
458
 
450
459
  // Placeholder isn't selectable. Return `false` (not a transaction) so
@@ -461,8 +470,8 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref8) {
461
470
  accessLevel = _item$mention.accessLevel,
462
471
  userType = _item$mention.userType,
463
472
  isXProductUser = _item$mention.isXProductUser;
464
- 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 : {},
465
- contextIdentifierProvider = _ref11.contextIdentifierProvider;
473
+ 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 : {},
474
+ contextIdentifierProvider = _ref12.contextIdentifierProvider;
466
475
  var mentionContext = _objectSpread(_objectSpread({}, contextIdentifierProvider), {}, {
467
476
  sessionId: sessionId
468
477
  });
@@ -589,11 +598,11 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref8) {
589
598
  }
590
599
  return tr;
591
600
  },
592
- dismiss: function dismiss(_ref12) {
593
- var editorState = _ref12.editorState,
594
- query = _ref12.query,
595
- stats = _ref12.stats,
596
- wasItemInserted = _ref12.wasItemInserted;
601
+ dismiss: function dismiss(_ref13) {
602
+ var editorState = _ref13.editorState,
603
+ query = _ref13.query,
604
+ stats = _ref13.stats,
605
+ wasItemInserted = _ref13.wasItemInserted;
597
606
  firstQueryWithoutResults = null;
598
607
  var pickerElapsedTime = stats.startedAt ? performance.now() - stats.startedAt : 0;
599
608
  if (!wasItemInserted) {
@@ -637,10 +646,10 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref8) {
637
646
  * so we only attach it when the gate is on — otherwise the proven
638
647
  * single-shot `getItems` path continues to drive every consumer.
639
648
  */
640
- var subscribeToItemsUpdates = function subscribeToItemsUpdates(_ref13) {
649
+ var subscribeToItemsUpdates = function subscribeToItemsUpdates(_ref14) {
641
650
  var _api$contextIdentifie5, _api$contextIdentifie6;
642
- var query = _ref13.query,
643
- editorState = _ref13.editorState;
651
+ var query = _ref14.query,
652
+ editorState = _ref14.editorState;
644
653
  var pluginState = getMentionPluginState(editorState);
645
654
  if (!(pluginState !== null && pluginState !== void 0 && pluginState.mentionProvider)) {
646
655
  return {
@@ -651,8 +660,8 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref8) {
651
660
  };
652
661
  }
653
662
  var mentionProvider = pluginState.mentionProvider;
654
- 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 : {},
655
- contextIdentifierProvider = _ref14.contextIdentifierProvider;
663
+ 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 : {},
664
+ contextIdentifierProvider = _ref15.contextIdentifierProvider;
656
665
 
657
666
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
658
667
  var key = "loadingMentionsForTypeAhead_".concat(uuid());
@@ -18,6 +18,12 @@ export var isTeamStats = function isTeamStats(stat) {
18
18
  export var isInviteItem = function isInviteItem(mention) {
19
19
  return mention && mention.id === INVITE_ITEM_DESCRIPTION.id;
20
20
  };
21
+ export var isAgentUserType = function isAgentUserType(userType) {
22
+ return userType === 'APP' || userType === 'AGENT';
23
+ };
24
+ export var isAgentMention = function isAgentMention(mention) {
25
+ return isAgentUserType(mention.userType) || mention.appType === 'agent';
26
+ };
21
27
 
22
28
  /**
23
29
  * Actions
@@ -6,9 +6,11 @@
6
6
  import { useEffect } from 'react';
7
7
  import createFocusTrap from 'focus-trap';
8
8
  export var useFocusTrap = function useFocusTrap(_ref) {
9
- var targetRef = _ref.targetRef;
9
+ var targetRef = _ref.targetRef,
10
+ _ref$enabled = _ref.enabled,
11
+ enabled = _ref$enabled === void 0 ? true : _ref$enabled;
10
12
  useEffect(function () {
11
- if (!targetRef) {
13
+ if (!targetRef || !enabled) {
12
14
  return;
13
15
  }
14
16
  var trapConfig = {
@@ -32,5 +34,5 @@ export var useFocusTrap = function useFocusTrap(_ref) {
32
34
  }
33
35
  focusTrap.deactivate();
34
36
  };
35
- }, [targetRef]);
37
+ }, [targetRef, enabled]);
36
38
  };
@@ -3,6 +3,7 @@ import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
3
  import type { BasePlugin } from '@atlaskit/editor-plugin-base';
4
4
  import type { ContextIdentifierPlugin } from '@atlaskit/editor-plugin-context-identifier';
5
5
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
6
+ import type { UiControlRegistryPlugin } from '@atlaskit/editor-plugin-ui-control-registry';
6
7
  import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead/type-ahead-plugin-type';
7
8
  import type { TypeAheadInputMethod } from '@atlaskit/editor-plugin-type-ahead/types';
8
9
  import type { MentionProvider } from '@atlaskit/mention/resource';
@@ -23,7 +24,8 @@ export type MentionPluginDependencies = [
23
24
  TypeAheadPlugin,
24
25
  OptionalPlugin<ContextIdentifierPlugin>,
25
26
  OptionalPlugin<BasePlugin>,
26
- OptionalPlugin<SelectionPlugin>
27
+ OptionalPlugin<SelectionPlugin>,
28
+ OptionalPlugin<UiControlRegistryPlugin>
27
29
  ];
28
30
  export type MentionsPlugin = NextEditorPlugin<'mention', {
29
31
  actions: MentionActions;
@@ -1,11 +1,24 @@
1
1
  import React from 'react';
2
2
  import type { PropsWithChildren } from 'react';
3
- import type { PopperChildrenProps } from '@atlaskit/popper';
3
+ import type { PopperChildrenProps, Placement } from '@atlaskit/popper/main';
4
4
  interface Props {
5
5
  /**
6
6
  * Returns the element to be positioned.
7
7
  */
8
8
  children: React.ReactNode;
9
+ /**
10
+ * When true, the popup does not trap focus.
11
+ */
12
+ disableFocusTrap?: boolean;
13
+ /**
14
+ * Popper offset. Defaults to `[0, 8]`.
15
+ */
16
+ offset?: [number, number];
17
+ /**
18
+ * Where to place the popup relative to the reference element.
19
+ * Defaults to `bottom-end`.
20
+ */
21
+ placement?: Placement;
9
22
  /**
10
23
  * Replacement reference element to position popper relative to.
11
24
  */
@@ -25,5 +38,5 @@ export declare const RepositionOnUpdate: ({ children, update, }: PropsWithChildr
25
38
  * @param children React.ReactNode - Returns the element to be positioned.
26
39
  * @returns React popper component
27
40
  */
28
- export declare function Popup({ referenceElement, children }: Props): React.JSX.Element;
41
+ export declare function Popup({ referenceElement, children, placement, offset, disableFocusTrap, }: Props): React.JSX.Element;
29
42
  export {};
@@ -1,6 +1,7 @@
1
1
  import type { MentionAttributes } from '@atlaskit/adf-schema/mention';
2
2
  import type { DocNode } from '@atlaskit/adf-schema/schema';
3
3
  import type { ProfilecardProvider } from '@atlaskit/editor-common/provider-factory';
4
+ import type { Placement } from '@atlaskit/popper/main';
4
5
  import type { ProfileCardClientData, TeamCentralReportingLinesData } from '@atlaskit/profilecard/types';
5
6
  interface ProfileCardStateProps {
6
7
  id: string | undefined;
@@ -18,13 +19,17 @@ export declare const useProfileCardState: ({ id, provider, }: ProfileCardStatePr
18
19
  /**
19
20
  * Renders the profile card popup for an editor mention node.
20
21
  */
21
- export declare function ProfileCardComponent({ profilecardProvider, activeMention, dom, closeComponent, onAgentMentionChatClick, }: {
22
+ export declare function ProfileCardComponent({ profilecardProvider, activeMention, dom, closeComponent, onAgentMentionChatClick, placement, offset, disableFocusTrap, hideActions, }: {
22
23
  activeMention: {
23
24
  attrs: MentionAttributes;
24
25
  };
25
26
  closeComponent: () => void;
27
+ disableFocusTrap?: boolean;
26
28
  dom: HTMLElement;
29
+ hideActions?: boolean;
30
+ offset?: [number, number];
27
31
  onAgentMentionChatClick?: (agentId: string, agentMentionContext?: DocNode) => void;
32
+ placement?: Placement;
28
33
  profilecardProvider?: Promise<ProfilecardProvider> | undefined;
29
34
  }): JSX.Element;
30
35
  export {};
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { TypeAheadHandler } from '@atlaskit/editor-plugin-type-ahead';
4
+ import type { MentionsPlugin } from '../../mentionsPluginType';
5
+ type Props = {
6
+ api: ExtractInjectionAPI<MentionsPlugin> | undefined;
7
+ typeAhead: TypeAheadHandler;
8
+ };
9
+ export declare const MentionQuickInsertMenuItem: ({ api, typeAhead }: Props) => React.JSX.Element;
10
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import type { TypeAheadHandler } from '@atlaskit/editor-plugin-type-ahead';
3
+ import type { RegisterMenuItem } from '@atlaskit/editor-ui-control-model/types';
4
+ import type { MentionsPlugin } from '../../mentionsPluginType';
5
+ export declare const getMentionQuickInsertComponents: ({ api, typeAhead, }: {
6
+ api: ExtractInjectionAPI<MentionsPlugin> | undefined;
7
+ typeAhead: TypeAheadHandler;
8
+ }) => RegisterMenuItem[];
@@ -0,0 +1,15 @@
1
+ import type { ProfilecardProvider } from '@atlaskit/editor-common/provider-factory';
2
+ import type { MentionDescription } from '@atlaskit/mention/resource';
3
+ type Props = {
4
+ height?: number;
5
+ mention: MentionDescription;
6
+ onSelection: () => void;
7
+ profilecardProvider?: Promise<ProfilecardProvider>;
8
+ selected?: boolean;
9
+ };
10
+ /**
11
+ * Renders a mentions typeahead row that shows a (reduced) profile card
12
+ * when hovered
13
+ */
14
+ export declare function MentionItemWithProfileCard({ mention, selected, onSelection, height, profilecardProvider, }: Props): JSX.Element;
15
+ export {};
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import type { ProfilecardProvider } from '@atlaskit/editor-common/provider-factory';
2
3
  import type { ExtractInjectionAPI, TypeAheadHandler, TypeAheadItem } from '@atlaskit/editor-common/types';
3
4
  import type { MentionDescription } from '@atlaskit/mention/resource';
4
5
  import type { MentionsPlugin } from '../../mentionsPluginType';
@@ -18,8 +19,9 @@ type Props = {
18
19
  handleMentionsChanged?: (mentionChanges: MentionChange[]) => void;
19
20
  HighlightComponent?: React.ComponentType<React.PropsWithChildren<unknown>>;
20
21
  mentionInsertDisplayName?: boolean;
22
+ profilecardProvider?: Promise<ProfilecardProvider>;
21
23
  sanitizePrivateContent?: boolean;
22
24
  showAgentMentionsLabsLozenge?: boolean;
23
25
  };
24
- export declare const createTypeAheadConfig: ({ sanitizePrivateContent, mentionInsertDisplayName, fireEvent, HighlightComponent, api, handleMentionsChanged, enableAgentSectioning, showAgentMentionsLabsLozenge, }: Props) => TypeAheadHandler;
26
+ export declare const createTypeAheadConfig: ({ sanitizePrivateContent, mentionInsertDisplayName, fireEvent, HighlightComponent, api, handleMentionsChanged, enableAgentSectioning, showAgentMentionsLabsLozenge, profilecardProvider, }: Props) => TypeAheadHandler;
25
27
  export {};
@@ -2,6 +2,8 @@ import type { MentionDescription } from '@atlaskit/mention';
2
2
  export declare const isTeamType: (userType: any) => boolean;
3
3
  export declare const isTeamStats: (stat: any) => boolean;
4
4
  export declare const isInviteItem: (mention: MentionDescription) => boolean;
5
+ export declare const isAgentUserType: (userType: string | undefined) => boolean;
6
+ export declare const isAgentMention: (mention: Pick<MentionDescription, 'appType' | 'userType'>) => boolean;
5
7
  /**
6
8
  * Actions
7
9
  */
@@ -1,4 +1,5 @@
1
1
  export type FocusManagerHook = {
2
+ enabled?: boolean;
2
3
  targetRef: HTMLDivElement | null;
3
4
  };
4
- export declare const useFocusTrap: ({ targetRef }: FocusManagerHook) => void;
5
+ export declare const useFocusTrap: ({ targetRef, enabled }: FocusManagerHook) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-mentions",
3
- "version": "17.0.0",
3
+ "version": "17.1.0",
4
4
  "description": "Mentions plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -28,14 +28,14 @@
28
28
  "@atlaskit/editor-plugin-base": "^16.0.0",
29
29
  "@atlaskit/editor-plugin-context-identifier": "^15.0.0",
30
30
  "@atlaskit/editor-plugin-selection": "^15.0.0",
31
- "@atlaskit/editor-plugin-type-ahead": "^16.0.0",
31
+ "@atlaskit/editor-plugin-type-ahead": "^16.1.0",
32
32
  "@atlaskit/editor-prosemirror": "^8.0.0",
33
33
  "@atlaskit/feature-gate-js-client": "^6.0.0",
34
34
  "@atlaskit/icon": "^37.3.0",
35
35
  "@atlaskit/insm": "^2.0.0",
36
36
  "@atlaskit/link": "^5.0.0",
37
37
  "@atlaskit/lozenge": "^15.0.0",
38
- "@atlaskit/mention": "^27.16.0",
38
+ "@atlaskit/mention": "^27.17.0",
39
39
  "@atlaskit/node-data-provider": "^16.0.0",
40
40
  "@atlaskit/platform-feature-experiments": "^0.3.0",
41
41
  "@atlaskit/platform-feature-flags": "^2.1.0",
@@ -43,13 +43,13 @@
43
43
  "@atlaskit/popup": "^6.0.0",
44
44
  "@atlaskit/portal": "^6.2.0",
45
45
  "@atlaskit/primitives": "^22.2.0",
46
- "@atlaskit/profilecard": "^26.17.0",
46
+ "@atlaskit/profilecard": "^26.18.0",
47
47
  "@atlaskit/teams-app-config": "^2.2.0",
48
48
  "@atlaskit/theme": "^28.0.0",
49
49
  "@atlaskit/tmp-editor-statsig": "^147.1.0",
50
50
  "@atlaskit/tokens": "^16.7.0",
51
51
  "@atlaskit/tooltip": "^24.0.0",
52
- "@atlaskit/user-picker": "^13.8.0",
52
+ "@atlaskit/user-picker": "^13.9.0",
53
53
  "@babel/runtime": "^7.0.0",
54
54
  "@compiled/react": "^1.0.2",
55
55
  "bind-event-listener": "^3.0.0",
@@ -58,7 +58,7 @@
58
58
  "uuid": "^3.1.0"
59
59
  },
60
60
  "peerDependencies": {
61
- "@atlaskit/editor-common": "^119.0.0",
61
+ "@atlaskit/editor-common": "^119.2.0",
62
62
  "react": "^18.2.0 || ^19.2.0",
63
63
  "react-dom": "^18.2.0 || ^19.2.0",
64
64
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
@@ -127,6 +127,9 @@
127
127
  },
128
128
  "platform_editor_agent_mentions_drop_one_fixes": {
129
129
  "type": "boolean"
130
+ },
131
+ "platform_editor_mention_typeahead_profilecard": {
132
+ "type": "boolean"
130
133
  }
131
134
  },
132
135
  "platform-experiments": {