@atlaskit/editor-plugin-mentions 17.0.0 → 17.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/editor-plugin-mentions
2
2
 
3
+ ## 17.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`4273da2e1a648`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4273da2e1a648) -
8
+ Register native Quick Insert items behind `platform_editor_slash_command`.
9
+ - [`fa754a973daeb`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/fa754a973daeb) -
10
+ Keep the pending mention chip visible until the invite popup is dismissed on failure, instead of
11
+ removing it immediately, and fix keyboard navigation in the project role picker rendered inside
12
+ the popup.
13
+ - Updated dependencies
14
+
3
15
  ## 17.0.0
4
16
 
5
17
  ### Patch Changes
@@ -16,11 +16,11 @@ var _uuid = _interopRequireDefault(require("uuid"));
16
16
  var _analytics = require("@atlaskit/editor-common/analytics");
17
17
  var _messages = require("@atlaskit/editor-common/messages");
18
18
  var _providerFactory = require("@atlaskit/editor-common/provider-factory");
19
- var _quickInsert = require("@atlaskit/editor-common/quick-insert");
19
+ var _assets = require("@atlaskit/editor-common/assets");
20
20
  var _resource = require("@atlaskit/mention/resource");
21
21
  var _types = require("@atlaskit/mention/types");
22
22
  var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
23
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
23
+ var _fg = require("@atlaskit/platform-feature-flags/fg");
24
24
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
25
25
  var _editorCommands = require("./editor-commands");
26
26
  var _mentionNodeSpec = require("./nodeviews/mentionNodeSpec");
@@ -30,6 +30,7 @@ var _main = require("./pm-plugins/main");
30
30
  var _InlineInvitePopupContainer = require("./ui/InlineInvitePopupContainer");
31
31
  var _SecondaryToolbarComponent = require("./ui/SecondaryToolbarComponent");
32
32
  var _typeAhead = require("./ui/type-ahead");
33
+ var _getMentionQuickInsertComponents = require("./ui/quick-insert/getMentionQuickInsertComponents");
33
34
  var _excluded2 = ["pendingPastedAgentMention"]; // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
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 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; }
@@ -113,6 +114,14 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref3) {
113
114
  fireEvent: fireEvent,
114
115
  api: api
115
116
  });
117
+ var isRegisteredSlashCommandEnabled = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_slash_command');
118
+ if (isRegisteredSlashCommandEnabled) {
119
+ var _api$uiControlRegistr;
120
+ api === null || api === void 0 || (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 || _api$uiControlRegistr.actions.register((0, _getMentionQuickInsertComponents.getMentionQuickInsertComponents)({
121
+ api: api,
122
+ typeAhead: typeAhead
123
+ }));
124
+ }
116
125
  return {
117
126
  name: 'mention',
118
127
  nodes: function nodes() {
@@ -164,7 +173,7 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref3) {
164
173
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(Component, {
165
174
  mentionProvider: mentionProvider,
166
175
  api: api
167
- }), (0, _platformFeatureFlags.fg)('inline_invite_from_mentions_kill_switch') && /*#__PURE__*/_react.default.createElement(_InlineInvitePopupContainer.InlineInvitePopupContainer, {
176
+ }), (0, _fg.fg)('inline_invite_from_mentions_kill_switch') && /*#__PURE__*/_react.default.createElement(_InlineInvitePopupContainer.InlineInvitePopupContainer, {
168
177
  mentionProvider: mentionProvider,
169
178
  api: api,
170
179
  editorView: editorView
@@ -219,7 +228,7 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref3) {
219
228
  return _regenerator.default.wrap(function (_context) {
220
229
  while (1) switch (_context.prev = _context.next) {
221
230
  case 0:
222
- if ((0, _platformFeatureFlags.fg)('platform_editor_mention_provider_via_plugin_config')) {
231
+ if ((0, _fg.fg)('platform_editor_mention_provider_via_plugin_config')) {
223
232
  _context.next = 1;
224
233
  break;
225
234
  }
@@ -282,7 +291,7 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref3) {
282
291
  });
283
292
  },
284
293
  pluginsOptions: {
285
- quickInsert: function quickInsert(_ref9) {
294
+ quickInsert: isRegisteredSlashCommandEnabled ? undefined : function (_ref9) {
286
295
  var formatMessage = _ref9.formatMessage;
287
296
  return [{
288
297
  id: 'mention',
@@ -292,7 +301,7 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref3) {
292
301
  priority: 400,
293
302
  keyshortcut: '@',
294
303
  icon: function icon() {
295
- return /*#__PURE__*/_react.default.createElement(_quickInsert.IconMention, null);
304
+ return /*#__PURE__*/_react.default.createElement(_assets.IconMention, null);
296
305
  },
297
306
  action: function action(insert, state) {
298
307
  var _api$typeAhead3;
@@ -67,7 +67,7 @@ var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
67
67
  var AGENT_MENTION_INACTIVITY_MS = 3000;
68
68
  var MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
69
69
  var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
70
- var PACKAGE_VERSION = "16.2.0";
70
+ var PACKAGE_VERSION = "17.0.0";
71
71
  var setProvider = function setProvider(provider) {
72
72
  return function (state, dispatch) {
73
73
  if (dispatch) {
@@ -33,5 +33,10 @@ function AnchoredPopup(_ref) {
33
33
  placement: "bottom-start",
34
34
  content: renderContent,
35
35
  trigger: renderTrigger
36
+ // Drops this popup's own `overflow: auto`, which otherwise clips the role picker's
37
+ // menu — it renders as a normal DOM child here (not a body portal) so it stays inside
38
+ // this popup's focus trap.
39
+ ,
40
+ shouldRenderToParent: true
36
41
  });
37
42
  }
@@ -104,7 +104,6 @@ var InlineInvitePopupContainer = exports.InlineInvitePopupContainer = function I
104
104
  }
105
105
  var invitedUser = (_result$invited$ = result.invited[0]) !== null && _result$invited$ !== void 0 ? _result$invited$ : result.requested[0];
106
106
  if (!invitedUser || !(api !== null && api !== void 0 && (_api$core2 = api.core) !== null && _api$core2 !== void 0 && (_api$core2 = _api$core2.actions) !== null && _api$core2 !== void 0 && _api$core2.execute) || !(api !== null && api !== void 0 && (_api$mention = api.mention) !== null && _api$mention !== void 0 && (_api$mention = _api$mention.commands) !== null && _api$mention !== void 0 && _api$mention.insertMention)) {
107
- removePendingMention();
108
107
  return;
109
108
  }
110
109
  var userId = invitedUser.id,
@@ -122,7 +121,7 @@ var InlineInvitePopupContainer = exports.InlineInvitePopupContainer = function I
122
121
  }));
123
122
  pendingMentionRef.current = null;
124
123
  setAnchorElement(null);
125
- }, [api, removePendingMention]);
124
+ }, [api]);
126
125
  var handleReady = (0, _react.useCallback)(function (show) {
127
126
  if (!provider) {
128
127
  return;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.MentionQuickInsertMenuItem = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _reactIntl = require("react-intl");
10
+ var _analytics = require("@atlaskit/editor-common/analytics");
11
+ var _messages = require("@atlaskit/editor-common/messages");
12
+ var _assets = require("@atlaskit/editor-common/assets");
13
+ var _menuItem = require("@atlaskit/editor-common/quick-insert/menu-item");
14
+ var _key = require("../../pm-plugins/key");
15
+ 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); }
16
+ var MentionQuickInsertMenuItem = exports.MentionQuickInsertMenuItem = function MentionQuickInsertMenuItem(_ref) {
17
+ var api = _ref.api,
18
+ typeAhead = _ref.typeAhead;
19
+ var _useIntl = (0, _reactIntl.useIntl)(),
20
+ formatMessage = _useIntl.formatMessage;
21
+ var onSelect = (0, _react.useCallback)(function (_ref2) {
22
+ var _mentionPluginKey$get, _api$typeAhead;
23
+ var editorView = _ref2.editorView,
24
+ insert = _ref2.insert;
25
+ if (((_mentionPluginKey$get = _key.mentionPluginKey.getState(editorView.state)) === null || _mentionPluginKey$get === void 0 ? void 0 : _mentionPluginKey$get.canInsertMention) === false) {
26
+ return false;
27
+ }
28
+ var tr = insert(undefined);
29
+ api === null || api === void 0 || (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 || _api$typeAhead.actions.openAtTransaction({
30
+ triggerHandler: typeAhead,
31
+ inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT
32
+ })(tr);
33
+ return tr;
34
+ }, [api, typeAhead]);
35
+ return /*#__PURE__*/_react.default.createElement(_menuItem.QuickInsertMenuItem, {
36
+ iconBefore: /*#__PURE__*/_react.default.createElement(_assets.IconMention, null),
37
+ onSelect: onSelect,
38
+ shortcut: "@",
39
+ title: formatMessage(_messages.toolbarInsertBlockMessages.mention)
40
+ });
41
+ };
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getMentionQuickInsertComponents = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _messages = require("@atlaskit/editor-common/messages");
10
+ var _createQuickInsertMatcher = require("@atlaskit/editor-common/quick-insert/create-quick-insert-matcher");
11
+ var _keys = require("@atlaskit/editor-common/quick-insert/keys");
12
+ var _rank = require("@atlaskit/editor-common/quick-insert/rank");
13
+ var _MentionQuickInsertMenuItem = require("./MentionQuickInsertMenuItem");
14
+ var getMentionQuickInsertComponents = exports.getMentionQuickInsertComponents = function getMentionQuickInsertComponents(_ref) {
15
+ var api = _ref.api,
16
+ typeAhead = _ref.typeAhead;
17
+ return [{
18
+ key: _keys.MENTION_MENU_ITEM.key,
19
+ type: _keys.MENTION_MENU_ITEM.type,
20
+ parents: [{
21
+ key: _keys.MEDIA_SECTION.key,
22
+ type: _keys.MEDIA_SECTION.type,
23
+ rank: _rank.MEDIA_SECTION_RANK[_keys.MENTION_MENU_ITEM.key]
24
+ }],
25
+ match: (0, _createQuickInsertMatcher.createQuickInsertMatcher)(function (_ref2) {
26
+ var formatMessage = _ref2.formatMessage;
27
+ return {
28
+ description: formatMessage(_messages.toolbarInsertBlockMessages.mentionDescription),
29
+ keywords: ['team', 'user'],
30
+ shortcut: '@',
31
+ title: formatMessage(_messages.toolbarInsertBlockMessages.mention)
32
+ };
33
+ }),
34
+ component: function component() {
35
+ return /*#__PURE__*/_react.default.createElement(_MentionQuickInsertMenuItem.MentionQuickInsertMenuItem, {
36
+ api: api,
37
+ typeAhead: typeAhead
38
+ });
39
+ }
40
+ }];
41
+ };
@@ -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) {
@@ -109,6 +110,14 @@ const mentionsPlugin = ({
109
110
  fireEvent,
110
111
  api
111
112
  });
113
+ const isRegisteredSlashCommandEnabled = isExperimentEnabled('platform_editor_slash_command');
114
+ if (isRegisteredSlashCommandEnabled) {
115
+ var _api$uiControlRegistr;
116
+ api === null || api === void 0 ? void 0 : (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 ? void 0 : _api$uiControlRegistr.actions.register(getMentionQuickInsertComponents({
117
+ api,
118
+ typeAhead
119
+ }));
120
+ }
112
121
  return {
113
122
  name: 'mention',
114
123
  nodes() {
@@ -256,7 +265,7 @@ const mentionsPlugin = ({
256
265
  };
257
266
  },
258
267
  pluginsOptions: {
259
- quickInsert: ({
268
+ quickInsert: isRegisteredSlashCommandEnabled ? undefined : ({
260
269
  formatMessage
261
270
  }) => [{
262
271
  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.0";
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;
@@ -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
+ }];
@@ -12,11 +12,11 @@ import uuid from 'uuid';
12
12
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
13
13
  import { toolbarInsertBlockMessages as messages, mentionMessages } from '@atlaskit/editor-common/messages';
14
14
  import { WithProviders } from '@atlaskit/editor-common/provider-factory';
15
- import { IconMention } from '@atlaskit/editor-common/quick-insert';
15
+ import { IconMention } from '@atlaskit/editor-common/assets';
16
16
  import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
17
17
  import { MentionNameStatus, isPromise } from '@atlaskit/mention/types';
18
18
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
19
- import { fg } from '@atlaskit/platform-feature-flags';
19
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
20
20
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
21
21
  import { insertMention } from './editor-commands';
22
22
  import { mentionNodeSpec } from './nodeviews/mentionNodeSpec';
@@ -26,6 +26,7 @@ import { ACTIONS, createMentionPlugin } from './pm-plugins/main';
26
26
  import { InlineInvitePopupContainer } from './ui/InlineInvitePopupContainer';
27
27
  import { SecondaryToolbarComponent } from './ui/SecondaryToolbarComponent';
28
28
  import { createTypeAheadConfig } from './ui/type-ahead';
29
+ import { getMentionQuickInsertComponents } from './ui/quick-insert/getMentionQuickInsertComponents';
29
30
  var processName = function processName(name, intl) {
30
31
  var unknownLabel = intl.formatMessage(mentionMessages.unknownLabel);
31
32
  if (name.status === MentionNameStatus.OK) {
@@ -105,6 +106,14 @@ var mentionsPlugin = function mentionsPlugin(_ref3) {
105
106
  fireEvent: fireEvent,
106
107
  api: api
107
108
  });
109
+ var isRegisteredSlashCommandEnabled = isExperimentEnabled('platform_editor_slash_command');
110
+ if (isRegisteredSlashCommandEnabled) {
111
+ var _api$uiControlRegistr;
112
+ api === null || api === void 0 || (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 || _api$uiControlRegistr.actions.register(getMentionQuickInsertComponents({
113
+ api: api,
114
+ typeAhead: typeAhead
115
+ }));
116
+ }
108
117
  return {
109
118
  name: 'mention',
110
119
  nodes: function nodes() {
@@ -274,7 +283,7 @@ var mentionsPlugin = function mentionsPlugin(_ref3) {
274
283
  });
275
284
  },
276
285
  pluginsOptions: {
277
- quickInsert: function quickInsert(_ref9) {
286
+ quickInsert: isRegisteredSlashCommandEnabled ? undefined : function (_ref9) {
278
287
  var formatMessage = _ref9.formatMessage;
279
288
  return [{
280
289
  id: 'mention',
@@ -58,7 +58,7 @@ var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
58
58
  var AGENT_MENTION_INACTIVITY_MS = 3000;
59
59
  var MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
60
60
  var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
61
- var PACKAGE_VERSION = "16.2.0";
61
+ var PACKAGE_VERSION = "17.0.0";
62
62
  var setProvider = function setProvider(provider) {
63
63
  return function (state, dispatch) {
64
64
  if (dispatch) {
@@ -25,5 +25,10 @@ export function AnchoredPopup(_ref) {
25
25
  placement: "bottom-start",
26
26
  content: renderContent,
27
27
  trigger: renderTrigger
28
+ // Drops this popup's own `overflow: auto`, which otherwise clips the role picker's
29
+ // menu — it renders as a normal DOM child here (not a body portal) so it stays inside
30
+ // this popup's focus trap.
31
+ ,
32
+ shouldRenderToParent: true
28
33
  });
29
34
  }
@@ -95,7 +95,6 @@ export var InlineInvitePopupContainer = function InlineInvitePopupContainer(_ref
95
95
  }
96
96
  var invitedUser = (_result$invited$ = result.invited[0]) !== null && _result$invited$ !== void 0 ? _result$invited$ : result.requested[0];
97
97
  if (!invitedUser || !(api !== null && api !== void 0 && (_api$core2 = api.core) !== null && _api$core2 !== void 0 && (_api$core2 = _api$core2.actions) !== null && _api$core2 !== void 0 && _api$core2.execute) || !(api !== null && api !== void 0 && (_api$mention = api.mention) !== null && _api$mention !== void 0 && (_api$mention = _api$mention.commands) !== null && _api$mention !== void 0 && _api$mention.insertMention)) {
98
- removePendingMention();
99
98
  return;
100
99
  }
101
100
  var userId = invitedUser.id,
@@ -113,7 +112,7 @@ export var InlineInvitePopupContainer = function InlineInvitePopupContainer(_ref
113
112
  }));
114
113
  pendingMentionRef.current = null;
115
114
  setAnchorElement(null);
116
- }, [api, removePendingMention]);
115
+ }, [api]);
117
116
  var handleReady = useCallback(function (show) {
118
117
  if (!provider) {
119
118
  return;
@@ -0,0 +1,33 @@
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 var MentionQuickInsertMenuItem = function MentionQuickInsertMenuItem(_ref) {
9
+ var api = _ref.api,
10
+ typeAhead = _ref.typeAhead;
11
+ var _useIntl = useIntl(),
12
+ formatMessage = _useIntl.formatMessage;
13
+ var onSelect = useCallback(function (_ref2) {
14
+ var _mentionPluginKey$get, _api$typeAhead;
15
+ var editorView = _ref2.editorView,
16
+ insert = _ref2.insert;
17
+ if (((_mentionPluginKey$get = mentionPluginKey.getState(editorView.state)) === null || _mentionPluginKey$get === void 0 ? void 0 : _mentionPluginKey$get.canInsertMention) === false) {
18
+ return false;
19
+ }
20
+ var tr = insert(undefined);
21
+ api === null || api === void 0 || (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 || _api$typeAhead.actions.openAtTransaction({
22
+ triggerHandler: typeAhead,
23
+ inputMethod: INPUT_METHOD.QUICK_INSERT
24
+ })(tr);
25
+ return tr;
26
+ }, [api, typeAhead]);
27
+ return /*#__PURE__*/React.createElement(QuickInsertMenuItem, {
28
+ iconBefore: /*#__PURE__*/React.createElement(IconMention, null),
29
+ onSelect: onSelect,
30
+ shortcut: "@",
31
+ title: formatMessage(messages.mention)
32
+ });
33
+ };
@@ -0,0 +1,34 @@
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 var getMentionQuickInsertComponents = function getMentionQuickInsertComponents(_ref) {
8
+ var api = _ref.api,
9
+ typeAhead = _ref.typeAhead;
10
+ return [{
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(function (_ref2) {
19
+ var formatMessage = _ref2.formatMessage;
20
+ return {
21
+ description: formatMessage(messages.mentionDescription),
22
+ keywords: ['team', 'user'],
23
+ shortcut: '@',
24
+ title: formatMessage(messages.mention)
25
+ };
26
+ }),
27
+ component: function component() {
28
+ return /*#__PURE__*/React.createElement(MentionQuickInsertMenuItem, {
29
+ api: api,
30
+ typeAhead: typeAhead
31
+ });
32
+ }
33
+ }];
34
+ };
@@ -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;
@@ -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[];
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.0.1",
4
4
  "description": "Mentions plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -49,7 +49,7 @@
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.1.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"