@atlaskit/editor-plugin-mentions 15.1.0 → 15.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/editor-plugin-mentions
2
2
 
3
+ ## 15.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`0adaa36b0a6bc`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0adaa36b0a6bc) -
8
+ Add InlineInvitePopup provider hook, replacing InlineInviteRecaptcha slot
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+
14
+ ## 15.1.1
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies
19
+
3
20
  ## 15.1.0
4
21
 
5
22
  ### Minor Changes
@@ -27,8 +27,7 @@ var _mentionNodeSpec = require("./nodeviews/mentionNodeSpec");
27
27
  var _agent = require("./pm-plugins/agent");
28
28
  var _key = require("./pm-plugins/key");
29
29
  var _main = require("./pm-plugins/main");
30
- var _mentionPlaceholder = require("./pm-plugins/mentionPlaceholder");
31
- var _InlineInviteRecaptchaContainer = require("./ui/InlineInviteRecaptchaContainer");
30
+ var _InlineInvitePopupContainer = require("./ui/InlineInvitePopupContainer");
32
31
  var _SecondaryToolbarComponent = require("./ui/SecondaryToolbarComponent");
33
32
  var _typeAhead = require("./ui/type-ahead");
34
33
  var _excluded2 = ["pendingPastedAgentMention"]; // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
@@ -145,14 +144,6 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref3) {
145
144
  }
146
145
  });
147
146
  }
148
- if ((0, _platformFeatureFlags.fg)('jira_invites_auto_tag_new_user_in_mentions_fg')) {
149
- plugins.push({
150
- name: 'mentionPlaceholder',
151
- plugin: function plugin() {
152
- return (0, _mentionPlaceholder.createMentionPlaceholderPlugin)();
153
- }
154
- });
155
- }
156
147
  return plugins;
157
148
  },
158
149
  contentComponent: function contentComponent(_ref4) {
@@ -173,9 +164,10 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref3) {
173
164
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(Component, {
174
165
  mentionProvider: mentionProvider,
175
166
  api: api
176
- }), (0, _platformFeatureFlags.fg)('jira_invites_auto_tag_new_user_in_mentions_fg') && /*#__PURE__*/_react.default.createElement(_InlineInviteRecaptchaContainer.InlineInviteRecaptchaContainer, {
167
+ }), (0, _platformFeatureFlags.fg)('inline_invite_from_mentions_kill_switch') && /*#__PURE__*/_react.default.createElement(_InlineInvitePopupContainer.InlineInvitePopupContainer, {
177
168
  mentionProvider: mentionProvider,
178
- api: api
169
+ api: api,
170
+ editorView: editorView
179
171
  }));
180
172
  }
181
173
  });
@@ -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 = "15.0.5";
70
+ var PACKAGE_VERSION = "15.1.1";
71
71
  var setProvider = function setProvider(provider) {
72
72
  return function (state, dispatch) {
73
73
  if (dispatch) {
@@ -0,0 +1,148 @@
1
+ /* InlineInvitePopupContainer.tsx generated by @compiled/babel-plugin v2.0.0 */
2
+ "use strict";
3
+
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ exports.InlineInvitePopupContainer = void 0;
10
+ var _runtime = require("@compiled/react/runtime");
11
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
+ var _react = _interopRequireWildcard(require("react"));
13
+ 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); }
14
+ var findMentionRange = function findMentionRange(doc, localId) {
15
+ var range = null;
16
+ doc.descendants(function (node, pos) {
17
+ if (range) {
18
+ return false;
19
+ }
20
+ if (node.type.name === 'mention' && node.attrs.localId === localId) {
21
+ range = {
22
+ from: pos,
23
+ to: pos + node.nodeSize
24
+ };
25
+ return false;
26
+ }
27
+ return true;
28
+ });
29
+ return range;
30
+ };
31
+ var InlineInvitePopupContainer = exports.InlineInvitePopupContainer = function InlineInvitePopupContainer(_ref) {
32
+ var _api$mention2, _api$core3;
33
+ var mentionProvider = _ref.mentionProvider,
34
+ api = _ref.api,
35
+ editorView = _ref.editorView;
36
+ var _useState = (0, _react.useState)(null),
37
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
38
+ provider = _useState2[0],
39
+ setProvider = _useState2[1];
40
+ var _useState3 = (0, _react.useState)(null),
41
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
42
+ anchorElement = _useState4[0],
43
+ setAnchorElement = _useState4[1];
44
+ var pendingMentionRef = (0, _react.useRef)(null);
45
+ (0, _react.useEffect)(function () {
46
+ if (!mentionProvider) {
47
+ return;
48
+ }
49
+ var isMounted = true;
50
+ mentionProvider.then(function (resolvedProvider) {
51
+ var _providerWithPopup$ge;
52
+ if (!isMounted) {
53
+ return;
54
+ }
55
+ var providerWithPopup = resolvedProvider;
56
+ var originalGetMentionDisabledState = (_providerWithPopup$ge = providerWithPopup.getMentionDisabledState) === null || _providerWithPopup$ge === void 0 ? void 0 : _providerWithPopup$ge.bind(providerWithPopup);
57
+ providerWithPopup.getMentionDisabledState = function (mention) {
58
+ var _pendingMentionRef$cu;
59
+ if (((_pendingMentionRef$cu = pendingMentionRef.current) === null || _pendingMentionRef$cu === void 0 ? void 0 : _pendingMentionRef$cu.localId) === mention.id) {
60
+ return {
61
+ disabled: true
62
+ };
63
+ }
64
+ return originalGetMentionDisabledState === null || originalGetMentionDisabledState === void 0 ? void 0 : originalGetMentionDisabledState(mention);
65
+ };
66
+ setProvider(providerWithPopup);
67
+ }).catch(function () {});
68
+ return function () {
69
+ isMounted = false;
70
+ setProvider(null);
71
+ };
72
+ }, [mentionProvider]);
73
+ var removePendingMention = (0, _react.useCallback)(function () {
74
+ var _api$core;
75
+ var pending = pendingMentionRef.current;
76
+ if (pending && api !== null && api !== void 0 && (_api$core = api.core) !== null && _api$core !== void 0 && (_api$core = _api$core.actions) !== null && _api$core !== void 0 && _api$core.execute) {
77
+ api.core.actions.execute(function (_ref2) {
78
+ var tr = _ref2.tr;
79
+ var range = findMentionRange(tr.doc, pending.localId);
80
+ return range ? tr.delete(range.from, range.to) : null;
81
+ });
82
+ }
83
+ pendingMentionRef.current = null;
84
+ setAnchorElement(null);
85
+ }, [api]);
86
+ var handleDismiss = (0, _react.useCallback)(function () {
87
+ removePendingMention();
88
+ }, [removePendingMention]);
89
+ var handleInviteComplete = (0, _react.useCallback)(function (result) {
90
+ var _result$invited$, _api$core2, _api$mention;
91
+ var pending = pendingMentionRef.current;
92
+ if (!pending) {
93
+ return;
94
+ }
95
+ var invitedUser = (_result$invited$ = result.invited[0]) !== null && _result$invited$ !== void 0 ? _result$invited$ : result.requested[0];
96
+ 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)) {
97
+ removePendingMention();
98
+ return;
99
+ }
100
+ var userId = invitedUser.id,
101
+ email = invitedUser.email;
102
+ var name = email.split('@')[0] || email;
103
+ api.core.actions.execute(function (_ref3) {
104
+ var tr = _ref3.tr;
105
+ var range = findMentionRange(tr.doc, pending.localId);
106
+ return range ? tr.delete(range.from, range.to) : null;
107
+ });
108
+ api.core.actions.execute(api.mention.commands.insertMention({
109
+ id: userId,
110
+ name: name,
111
+ userType: 'DEFAULT',
112
+ accessLevel: 'CONTAINER'
113
+ }));
114
+ pendingMentionRef.current = null;
115
+ setAnchorElement(null);
116
+ }, [api, removePendingMention]);
117
+ var handleReady = (0, _react.useCallback)(function (show) {
118
+ if (!provider) {
119
+ return;
120
+ }
121
+ if (show) {
122
+ provider.showInlineInvitePopup = function (email, localId) {
123
+ pendingMentionRef.current = {
124
+ email: email,
125
+ localId: localId
126
+ };
127
+ setTimeout(function () {
128
+ var range = findMentionRange(editorView.state.doc, localId);
129
+ var dom = range ? editorView.nodeDOM(range.from) : null;
130
+ setAnchorElement(dom instanceof HTMLElement ? dom : null);
131
+ show(email);
132
+ }, 0);
133
+ };
134
+ } else {
135
+ delete provider.showInlineInvitePopup;
136
+ }
137
+ }, [provider, editorView]);
138
+ if (!(provider !== null && provider !== void 0 && provider.InlineInvitePopup) || !(api !== null && api !== void 0 && (_api$mention2 = api.mention) !== null && _api$mention2 !== void 0 && (_api$mention2 = _api$mention2.commands) !== null && _api$mention2 !== void 0 && _api$mention2.insertMention) || !(api !== null && api !== void 0 && (_api$core3 = api.core) !== null && _api$core3 !== void 0 && (_api$core3 = _api$core3.actions) !== null && _api$core3 !== void 0 && _api$core3.execute)) {
139
+ return null;
140
+ }
141
+ var PopupComponent = provider.InlineInvitePopup;
142
+ return /*#__PURE__*/_react.default.createElement(PopupComponent, {
143
+ anchorElement: anchorElement,
144
+ onInviteComplete: handleInviteComplete,
145
+ onDismiss: handleDismiss,
146
+ onReady: handleReady
147
+ });
148
+ };
@@ -26,7 +26,6 @@ var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
26
26
  var _editorCommands = require("../../editor-commands");
27
27
  var _key = require("../../pm-plugins/key");
28
28
  var _main = require("../../pm-plugins/main");
29
- var _mentionPlaceholder = require("../../pm-plugins/mentionPlaceholder");
30
29
  var _utils2 = require("../../pm-plugins/utils");
31
30
  var _InviteItem = _interopRequireWildcard(require("../InviteItem"));
32
31
  var _InviteItemWithEmailDomain = _interopRequireDefault(require("../InviteItem/InviteItemWithEmailDomain"));
@@ -67,7 +66,7 @@ var createInviteItem = function createInviteItem(_ref) {
67
66
  var isSelected = _ref2.isSelected,
68
67
  onClick = _ref2.onClick,
69
68
  onHover = _ref2.onHover;
70
- return emailDomain && (_mentionProvider$getS = mentionProvider.getShouldEnableInlineInvite) !== null && _mentionProvider$getS !== void 0 && _mentionProvider$getS.call(mentionProvider) && (0, _platformFeatureFlags.fg)('jira_invites_auto_tag_new_user_in_mentions_fg') ? /*#__PURE__*/_react.default.createElement(_InviteItemWithEmailDomain.default, {
69
+ return emailDomain && (_mentionProvider$getS = mentionProvider.getShouldEnableInlineInvite) !== null && _mentionProvider$getS !== void 0 && _mentionProvider$getS.call(mentionProvider) && (0, _platformFeatureFlags.fg)('inline_invite_from_mentions_kill_switch') ? /*#__PURE__*/_react.default.createElement(_InviteItemWithEmailDomain.default, {
71
70
  productName: mentionProvider ? mentionProvider.productName : undefined,
72
71
  selected: isSelected,
73
72
  onMount: onInviteItemMount,
@@ -490,10 +489,10 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
490
489
  // Don't fire event and the callback with selection by space press
491
490
  if (mode !== 'space') {
492
491
  var _mentionProvider$getS3, _mentionProvider$getS4;
493
- fireEvent((0, _analytics.buildTypeAheadInviteItemClickedPayload)(pickerElapsedTime, stats.keyCount.arrowUp, stats.keyCount.arrowDown, sessionId, mode, query, contextIdentifierProvider, mentionProvider.userRole, (0, _platformFeatureFlags.fg)('jira_invites_auto_tag_new_user_in_mentions_fg') ? {
492
+ fireEvent((0, _analytics.buildTypeAheadInviteItemClickedPayload)(pickerElapsedTime, stats.keyCount.arrowUp, stats.keyCount.arrowDown, sessionId, mode, query, contextIdentifierProvider, mentionProvider.userRole, (0, _platformFeatureFlags.fg)('inline_invite_from_mentions_kill_switch') ? {
494
493
  isInlineInviteMentionsEnabled: (_mentionProvider$getS3 = mentionProvider.getShouldEnableInlineInvite) === null || _mentionProvider$getS3 === void 0 ? void 0 : _mentionProvider$getS3.call(mentionProvider)
495
494
  } : {}));
496
- if ((_mentionProvider$getS4 = mentionProvider.getShouldEnableInlineInvite) !== null && _mentionProvider$getS4 !== void 0 && _mentionProvider$getS4.call(mentionProvider) && (0, _platformFeatureFlags.fg)('jira_invites_auto_tag_new_user_in_mentions_fg')) {
495
+ if ((_mentionProvider$getS4 = mentionProvider.getShouldEnableInlineInvite) !== null && _mentionProvider$getS4 !== void 0 && _mentionProvider$getS4.call(mentionProvider) && (0, _platformFeatureFlags.fg)('inline_invite_from_mentions_kill_switch')) {
497
496
  // Get the email from query, using the same logic as InviteItemWithEmailDomain
498
497
  var emailDomain = mentionProvider.userEmailDomain;
499
498
  var email = query || '';
@@ -502,13 +501,23 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
502
501
  email = "".concat(email.toLowerCase(), "@").concat(emailDomain);
503
502
  }
504
503
  // If query already includes @, use it as is
505
- if (email && mentionProvider.showInlineInviteRecaptcha) {
506
- mentionProvider.showInlineInviteRecaptcha(email);
507
- var _tr = state.tr;
508
- _tr.setMeta(_mentionPlaceholder.mentionPlaceholderPluginKey, {
509
- action: _mentionPlaceholder.MENTION_PLACEHOLDER_ACTIONS.SHOW_PLACEHOLDER,
510
- placeholder: "@".concat(query)
511
- });
504
+ if (email && mentionProvider.showInlineInvitePopup) {
505
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
506
+ var pendingLocalId = (0, _uuid.default)();
507
+ var pendingName = email.split('@')[0] || email;
508
+ var _tr = insert((0, _editorCommands.createSingleMentionFragment)({
509
+ mentionProvider: mentionProvider,
510
+ mentionInsertDisplayName: mentionInsertDisplayName,
511
+ tr: state.tr,
512
+ sanitizePrivateContent: sanitizePrivateContent
513
+ })({
514
+ name: pendingName,
515
+ id: pendingLocalId,
516
+ userType: 'DEFAULT',
517
+ localId: pendingLocalId,
518
+ accessLevel: 'CONTAINER'
519
+ }));
520
+ mentionProvider.showInlineInvitePopup(email, pendingLocalId);
512
521
  return _tr;
513
522
  }
514
523
  } else if (mentionProvider.onInviteItemClick) {
@@ -16,8 +16,7 @@ import { mentionNodeSpec } from './nodeviews/mentionNodeSpec';
16
16
  import { agentMentionPluginKey, createAgentMentionPlugin } from './pm-plugins/agent';
17
17
  import { mentionPluginKey } from './pm-plugins/key';
18
18
  import { ACTIONS, createMentionPlugin } from './pm-plugins/main';
19
- import { createMentionPlaceholderPlugin } from './pm-plugins/mentionPlaceholder';
20
- import { InlineInviteRecaptchaContainer } from './ui/InlineInviteRecaptchaContainer';
19
+ import { InlineInvitePopupContainer } from './ui/InlineInvitePopupContainer';
21
20
  import { SecondaryToolbarComponent } from './ui/SecondaryToolbarComponent';
22
21
  import { createTypeAheadConfig } from './ui/type-ahead';
23
22
  const processName = (name, intl) => {
@@ -137,12 +136,6 @@ const mentionsPlugin = ({
137
136
  })
138
137
  });
139
138
  }
140
- if (fg('jira_invites_auto_tag_new_user_in_mentions_fg')) {
141
- plugins.push({
142
- name: 'mentionPlaceholder',
143
- plugin: () => createMentionPlaceholderPlugin()
144
- });
145
- }
146
139
  return plugins;
147
140
  },
148
141
  contentComponent({
@@ -165,9 +158,10 @@ const mentionsPlugin = ({
165
158
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Component, {
166
159
  mentionProvider: mentionProvider,
167
160
  api: api
168
- }), fg('jira_invites_auto_tag_new_user_in_mentions_fg') && /*#__PURE__*/React.createElement(InlineInviteRecaptchaContainer, {
161
+ }), fg('inline_invite_from_mentions_kill_switch') && /*#__PURE__*/React.createElement(InlineInvitePopupContainer, {
169
162
  mentionProvider: mentionProvider,
170
- api: api
163
+ api: api,
164
+ editorView: editorView
171
165
  }));
172
166
  }
173
167
  });
@@ -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 = "15.0.5";
54
+ const PACKAGE_VERSION = "15.1.1";
55
55
  const setProvider = provider => (state, dispatch) => {
56
56
  if (dispatch) {
57
57
  dispatch(state.tr.setMeta(mentionPluginKey, {
@@ -0,0 +1,137 @@
1
+ /* InlineInvitePopupContainer.tsx generated by @compiled/babel-plugin v2.0.0 */
2
+ import { ax, ix } from "@compiled/react/runtime";
3
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
4
+ const findMentionRange = (doc, localId) => {
5
+ let range = null;
6
+ doc.descendants((node, pos) => {
7
+ if (range) {
8
+ return false;
9
+ }
10
+ if (node.type.name === 'mention' && node.attrs.localId === localId) {
11
+ range = {
12
+ from: pos,
13
+ to: pos + node.nodeSize
14
+ };
15
+ return false;
16
+ }
17
+ return true;
18
+ });
19
+ return range;
20
+ };
21
+ export const InlineInvitePopupContainer = ({
22
+ mentionProvider,
23
+ api,
24
+ editorView
25
+ }) => {
26
+ var _api$mention2, _api$mention2$command, _api$core3, _api$core3$actions;
27
+ const [provider, setProvider] = useState(null);
28
+ const [anchorElement, setAnchorElement] = useState(null);
29
+ const pendingMentionRef = useRef(null);
30
+ useEffect(() => {
31
+ if (!mentionProvider) {
32
+ return;
33
+ }
34
+ let isMounted = true;
35
+ mentionProvider.then(resolvedProvider => {
36
+ var _providerWithPopup$ge;
37
+ if (!isMounted) {
38
+ return;
39
+ }
40
+ const providerWithPopup = resolvedProvider;
41
+ const originalGetMentionDisabledState = (_providerWithPopup$ge = providerWithPopup.getMentionDisabledState) === null || _providerWithPopup$ge === void 0 ? void 0 : _providerWithPopup$ge.bind(providerWithPopup);
42
+ providerWithPopup.getMentionDisabledState = mention => {
43
+ var _pendingMentionRef$cu;
44
+ if (((_pendingMentionRef$cu = pendingMentionRef.current) === null || _pendingMentionRef$cu === void 0 ? void 0 : _pendingMentionRef$cu.localId) === mention.id) {
45
+ return {
46
+ disabled: true
47
+ };
48
+ }
49
+ return originalGetMentionDisabledState === null || originalGetMentionDisabledState === void 0 ? void 0 : originalGetMentionDisabledState(mention);
50
+ };
51
+ setProvider(providerWithPopup);
52
+ }).catch(() => {});
53
+ return () => {
54
+ isMounted = false;
55
+ setProvider(null);
56
+ };
57
+ }, [mentionProvider]);
58
+ const removePendingMention = useCallback(() => {
59
+ var _api$core, _api$core$actions;
60
+ const pending = pendingMentionRef.current;
61
+ if (pending && api !== null && api !== void 0 && (_api$core = api.core) !== null && _api$core !== void 0 && (_api$core$actions = _api$core.actions) !== null && _api$core$actions !== void 0 && _api$core$actions.execute) {
62
+ api.core.actions.execute(({
63
+ tr
64
+ }) => {
65
+ const range = findMentionRange(tr.doc, pending.localId);
66
+ return range ? tr.delete(range.from, range.to) : null;
67
+ });
68
+ }
69
+ pendingMentionRef.current = null;
70
+ setAnchorElement(null);
71
+ }, [api]);
72
+ const handleDismiss = useCallback(() => {
73
+ removePendingMention();
74
+ }, [removePendingMention]);
75
+ const handleInviteComplete = useCallback(result => {
76
+ var _result$invited$, _api$core2, _api$core2$actions, _api$mention, _api$mention$commands;
77
+ const pending = pendingMentionRef.current;
78
+ if (!pending) {
79
+ return;
80
+ }
81
+ const invitedUser = (_result$invited$ = result.invited[0]) !== null && _result$invited$ !== void 0 ? _result$invited$ : result.requested[0];
82
+ 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)) {
83
+ removePendingMention();
84
+ return;
85
+ }
86
+ const {
87
+ id: userId,
88
+ email
89
+ } = invitedUser;
90
+ const name = email.split('@')[0] || email;
91
+ api.core.actions.execute(({
92
+ tr
93
+ }) => {
94
+ const range = findMentionRange(tr.doc, pending.localId);
95
+ return range ? tr.delete(range.from, range.to) : null;
96
+ });
97
+ api.core.actions.execute(api.mention.commands.insertMention({
98
+ id: userId,
99
+ name,
100
+ userType: 'DEFAULT',
101
+ accessLevel: 'CONTAINER'
102
+ }));
103
+ pendingMentionRef.current = null;
104
+ setAnchorElement(null);
105
+ }, [api, removePendingMention]);
106
+ const handleReady = useCallback(show => {
107
+ if (!provider) {
108
+ return;
109
+ }
110
+ if (show) {
111
+ provider.showInlineInvitePopup = (email, localId) => {
112
+ pendingMentionRef.current = {
113
+ email,
114
+ localId
115
+ };
116
+ setTimeout(() => {
117
+ const range = findMentionRange(editorView.state.doc, localId);
118
+ const dom = range ? editorView.nodeDOM(range.from) : null;
119
+ setAnchorElement(dom instanceof HTMLElement ? dom : null);
120
+ show(email);
121
+ }, 0);
122
+ };
123
+ } else {
124
+ delete provider.showInlineInvitePopup;
125
+ }
126
+ }, [provider, editorView]);
127
+ if (!(provider !== null && provider !== void 0 && provider.InlineInvitePopup) || !(api !== null && api !== void 0 && (_api$mention2 = api.mention) !== null && _api$mention2 !== void 0 && (_api$mention2$command = _api$mention2.commands) !== null && _api$mention2$command !== void 0 && _api$mention2$command.insertMention) || !(api !== null && api !== void 0 && (_api$core3 = api.core) !== null && _api$core3 !== void 0 && (_api$core3$actions = _api$core3.actions) !== null && _api$core3$actions !== void 0 && _api$core3$actions.execute)) {
128
+ return null;
129
+ }
130
+ const PopupComponent = provider.InlineInvitePopup;
131
+ return /*#__PURE__*/React.createElement(PopupComponent, {
132
+ anchorElement: anchorElement,
133
+ onInviteComplete: handleInviteComplete,
134
+ onDismiss: handleDismiss,
135
+ onReady: handleReady
136
+ });
137
+ };
@@ -16,7 +16,6 @@ import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
16
16
  import { createSingleMentionFragment } from '../../editor-commands';
17
17
  import { mentionPluginKey } from '../../pm-plugins/key';
18
18
  import { ACTIONS } from '../../pm-plugins/main';
19
- import { mentionPlaceholderPluginKey, MENTION_PLACEHOLDER_ACTIONS } from '../../pm-plugins/mentionPlaceholder';
20
19
  import { getMentionPluginState } from '../../pm-plugins/utils';
21
20
  import InviteItem, { INVITE_ITEM_DESCRIPTION } from '../InviteItem';
22
21
  import InviteItemWithEmailDomain from '../InviteItem/InviteItemWithEmailDomain';
@@ -44,7 +43,7 @@ const createInviteItem = ({
44
43
  onHover
45
44
  }) => {
46
45
  var _mentionProvider$getS;
47
- return emailDomain && (_mentionProvider$getS = mentionProvider.getShouldEnableInlineInvite) !== null && _mentionProvider$getS !== void 0 && _mentionProvider$getS.call(mentionProvider) && fg('jira_invites_auto_tag_new_user_in_mentions_fg') ? /*#__PURE__*/React.createElement(InviteItemWithEmailDomain, {
46
+ return emailDomain && (_mentionProvider$getS = mentionProvider.getShouldEnableInlineInvite) !== null && _mentionProvider$getS !== void 0 && _mentionProvider$getS.call(mentionProvider) && fg('inline_invite_from_mentions_kill_switch') ? /*#__PURE__*/React.createElement(InviteItemWithEmailDomain, {
48
47
  productName: mentionProvider ? mentionProvider.productName : undefined,
49
48
  selected: isSelected,
50
49
  onMount: onInviteItemMount,
@@ -460,10 +459,10 @@ export const createTypeAheadConfig = ({
460
459
  // Don't fire event and the callback with selection by space press
461
460
  if (mode !== 'space') {
462
461
  var _mentionProvider$getS3, _mentionProvider$getS4;
463
- fireEvent(buildTypeAheadInviteItemClickedPayload(pickerElapsedTime, stats.keyCount.arrowUp, stats.keyCount.arrowDown, sessionId, mode, query, contextIdentifierProvider, mentionProvider.userRole, fg('jira_invites_auto_tag_new_user_in_mentions_fg') ? {
462
+ fireEvent(buildTypeAheadInviteItemClickedPayload(pickerElapsedTime, stats.keyCount.arrowUp, stats.keyCount.arrowDown, sessionId, mode, query, contextIdentifierProvider, mentionProvider.userRole, fg('inline_invite_from_mentions_kill_switch') ? {
464
463
  isInlineInviteMentionsEnabled: (_mentionProvider$getS3 = mentionProvider.getShouldEnableInlineInvite) === null || _mentionProvider$getS3 === void 0 ? void 0 : _mentionProvider$getS3.call(mentionProvider)
465
464
  } : {}));
466
- if ((_mentionProvider$getS4 = mentionProvider.getShouldEnableInlineInvite) !== null && _mentionProvider$getS4 !== void 0 && _mentionProvider$getS4.call(mentionProvider) && fg('jira_invites_auto_tag_new_user_in_mentions_fg')) {
465
+ if ((_mentionProvider$getS4 = mentionProvider.getShouldEnableInlineInvite) !== null && _mentionProvider$getS4 !== void 0 && _mentionProvider$getS4.call(mentionProvider) && fg('inline_invite_from_mentions_kill_switch')) {
467
466
  // Get the email from query, using the same logic as InviteItemWithEmailDomain
468
467
  const emailDomain = mentionProvider.userEmailDomain;
469
468
  let email = query || '';
@@ -472,15 +471,23 @@ export const createTypeAheadConfig = ({
472
471
  email = `${email.toLowerCase()}@${emailDomain}`;
473
472
  }
474
473
  // If query already includes @, use it as is
475
- if (email && mentionProvider.showInlineInviteRecaptcha) {
476
- mentionProvider.showInlineInviteRecaptcha(email);
477
- const {
478
- tr
479
- } = state;
480
- tr.setMeta(mentionPlaceholderPluginKey, {
481
- action: MENTION_PLACEHOLDER_ACTIONS.SHOW_PLACEHOLDER,
482
- placeholder: `@${query}`
483
- });
474
+ if (email && mentionProvider.showInlineInvitePopup) {
475
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
476
+ const pendingLocalId = uuid();
477
+ const pendingName = email.split('@')[0] || email;
478
+ const tr = insert(createSingleMentionFragment({
479
+ mentionProvider,
480
+ mentionInsertDisplayName,
481
+ tr: state.tr,
482
+ sanitizePrivateContent
483
+ })({
484
+ name: pendingName,
485
+ id: pendingLocalId,
486
+ userType: 'DEFAULT',
487
+ localId: pendingLocalId,
488
+ accessLevel: 'CONTAINER'
489
+ }));
490
+ mentionProvider.showInlineInvitePopup(email, pendingLocalId);
484
491
  return tr;
485
492
  }
486
493
  } else if (mentionProvider.onInviteItemClick) {
@@ -23,8 +23,7 @@ import { mentionNodeSpec } from './nodeviews/mentionNodeSpec';
23
23
  import { agentMentionPluginKey, createAgentMentionPlugin } from './pm-plugins/agent';
24
24
  import { mentionPluginKey } from './pm-plugins/key';
25
25
  import { ACTIONS, createMentionPlugin } from './pm-plugins/main';
26
- import { createMentionPlaceholderPlugin } from './pm-plugins/mentionPlaceholder';
27
- import { InlineInviteRecaptchaContainer } from './ui/InlineInviteRecaptchaContainer';
26
+ import { InlineInvitePopupContainer } from './ui/InlineInvitePopupContainer';
28
27
  import { SecondaryToolbarComponent } from './ui/SecondaryToolbarComponent';
29
28
  import { createTypeAheadConfig } from './ui/type-ahead';
30
29
  var processName = function processName(name, intl) {
@@ -137,14 +136,6 @@ var mentionsPlugin = function mentionsPlugin(_ref3) {
137
136
  }
138
137
  });
139
138
  }
140
- if (fg('jira_invites_auto_tag_new_user_in_mentions_fg')) {
141
- plugins.push({
142
- name: 'mentionPlaceholder',
143
- plugin: function plugin() {
144
- return createMentionPlaceholderPlugin();
145
- }
146
- });
147
- }
148
139
  return plugins;
149
140
  },
150
141
  contentComponent: function contentComponent(_ref4) {
@@ -165,9 +156,10 @@ var mentionsPlugin = function mentionsPlugin(_ref3) {
165
156
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Component, {
166
157
  mentionProvider: mentionProvider,
167
158
  api: api
168
- }), fg('jira_invites_auto_tag_new_user_in_mentions_fg') && /*#__PURE__*/React.createElement(InlineInviteRecaptchaContainer, {
159
+ }), fg('inline_invite_from_mentions_kill_switch') && /*#__PURE__*/React.createElement(InlineInvitePopupContainer, {
169
160
  mentionProvider: mentionProvider,
170
- api: api
161
+ api: api,
162
+ editorView: editorView
171
163
  }));
172
164
  }
173
165
  });
@@ -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 = "15.0.5";
61
+ var PACKAGE_VERSION = "15.1.1";
62
62
  var setProvider = function setProvider(provider) {
63
63
  return function (state, dispatch) {
64
64
  if (dispatch) {