@atlaskit/editor-plugin-mentions 16.0.3 → 16.1.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/anchored-popup/package.json +10 -0
  3. package/dist/cjs/entry-points/anchored-popup.js +12 -0
  4. package/dist/cjs/mentionsPlugin.js +4 -12
  5. package/dist/cjs/pm-plugins/main.js +1 -1
  6. package/dist/cjs/ui/AnchoredPopup.js +37 -0
  7. package/dist/cjs/ui/InlineInvitePopupContainer.js +157 -0
  8. package/dist/cjs/ui/type-ahead/analytics.js +2 -1
  9. package/dist/cjs/ui/type-ahead/index.js +26 -18
  10. package/dist/es2019/entry-points/anchored-popup.js +2 -0
  11. package/dist/es2019/mentionsPlugin.js +4 -10
  12. package/dist/es2019/pm-plugins/main.js +1 -1
  13. package/dist/es2019/ui/AnchoredPopup.js +28 -0
  14. package/dist/es2019/ui/InlineInvitePopupContainer.js +146 -0
  15. package/dist/es2019/ui/type-ahead/analytics.js +2 -1
  16. package/dist/es2019/ui/type-ahead/index.js +26 -20
  17. package/dist/esm/entry-points/anchored-popup.js +2 -0
  18. package/dist/esm/mentionsPlugin.js +4 -12
  19. package/dist/esm/pm-plugins/main.js +1 -1
  20. package/dist/esm/ui/AnchoredPopup.js +29 -0
  21. package/dist/esm/ui/InlineInvitePopupContainer.js +148 -0
  22. package/dist/esm/ui/type-ahead/analytics.js +2 -1
  23. package/dist/esm/ui/type-ahead/index.js +26 -18
  24. package/dist/types/entry-points/anchored-popup.d.ts +2 -0
  25. package/dist/types/ui/AnchoredPopup.d.ts +13 -0
  26. package/dist/types/ui/InlineInvitePopupContainer.d.ts +11 -0
  27. package/dist/types/ui/type-ahead/analytics.d.ts +1 -1
  28. package/package.json +11 -5
  29. package/dist/cjs/pm-plugins/mentionPlaceholder.js +0 -52
  30. package/dist/cjs/ui/InlineInviteRecaptchaContainer.js +0 -100
  31. package/dist/es2019/pm-plugins/mentionPlaceholder.js +0 -44
  32. package/dist/es2019/ui/InlineInviteRecaptchaContainer.js +0 -90
  33. package/dist/esm/pm-plugins/mentionPlaceholder.js +0 -44
  34. package/dist/esm/ui/InlineInviteRecaptchaContainer.js +0 -91
  35. package/dist/types/pm-plugins/mentionPlaceholder.d.ts +0 -11
  36. package/dist/types/ui/InlineInviteRecaptchaContainer.d.ts +0 -15
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @atlaskit/editor-plugin-mentions
2
2
 
3
+ ## 16.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`716685b30ef93`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/716685b30ef93) -
8
+ Correlate rendered agent mention results with picker selection sessions.
9
+ - Updated dependencies
10
+
11
+ ## 16.1.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [`50992b74009d1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/50992b74009d1) -
16
+ Add InlineInvitePopup provider hook, replacing InlineInviteRecaptcha slot
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies
21
+
3
22
  ## 16.0.3
4
23
 
5
24
  ### Patch Changes
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "@atlaskit/editor-plugin-mentions/anchored-popup",
3
+ "main": "../dist/cjs/entry-points/anchored-popup.js",
4
+ "module": "../dist/esm/entry-points/anchored-popup.js",
5
+ "module:es2019": "../dist/es2019/entry-points/anchored-popup.js",
6
+ "sideEffects": [
7
+ "**/*.compiled.css"
8
+ ],
9
+ "types": "../dist/types/entry-points/anchored-popup.d.ts"
10
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "AnchoredPopup", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _AnchoredPopup.AnchoredPopup;
10
+ }
11
+ });
12
+ var _AnchoredPopup = require("../ui/AnchoredPopup");
@@ -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 = "16.0.2";
70
+ var PACKAGE_VERSION = "16.1.0";
71
71
  var setProvider = function setProvider(provider) {
72
72
  return function (state, dispatch) {
73
73
  if (dispatch) {
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.AnchoredPopup = AnchoredPopup;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _popup = require("@atlaskit/popup/popup");
10
+ 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); }
11
+ /**
12
+ * A `<Popup>` anchored to an externally-supplied DOM node. Unlike `PopupTrigger`, it has no
13
+ * clickable trigger of its own — it opens whenever `isOpen` becomes true, so callers can drive
14
+ * it from any external signal.
15
+ */
16
+ function AnchoredPopup(_ref) {
17
+ var anchorElement = _ref.anchorElement,
18
+ content = _ref.content,
19
+ isOpen = _ref.isOpen,
20
+ onClose = _ref.onClose;
21
+ var renderContent = (0, _react.useCallback)(function () {
22
+ return isOpen ? content : null;
23
+ }, [isOpen, content]);
24
+ var renderTrigger = (0, _react.useCallback)(function (triggerProps) {
25
+ if (anchorElement && typeof triggerProps.ref === 'function') {
26
+ triggerProps.ref(anchorElement);
27
+ }
28
+ return null;
29
+ }, [anchorElement]);
30
+ return /*#__PURE__*/_react.default.createElement(_popup.Popup, {
31
+ isOpen: isOpen,
32
+ onClose: onClose,
33
+ placement: "bottom-start",
34
+ content: renderContent,
35
+ trigger: renderTrigger
36
+ });
37
+ }
@@ -0,0 +1,157 @@
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
+ var cleanupProvider;
51
+ mentionProvider.then(function (resolvedProvider) {
52
+ var _providerWithPopup$ge;
53
+ if (!isMounted) {
54
+ return;
55
+ }
56
+ var providerWithPopup = resolvedProvider;
57
+ var originalGetMentionDisabledState = (_providerWithPopup$ge = providerWithPopup.getMentionDisabledState) === null || _providerWithPopup$ge === void 0 ? void 0 : _providerWithPopup$ge.bind(providerWithPopup);
58
+ providerWithPopup.getMentionDisabledState = function (mention) {
59
+ var _pendingMentionRef$cu;
60
+ if (((_pendingMentionRef$cu = pendingMentionRef.current) === null || _pendingMentionRef$cu === void 0 ? void 0 : _pendingMentionRef$cu.localId) === mention.id) {
61
+ return {
62
+ disabled: true
63
+ };
64
+ }
65
+ return originalGetMentionDisabledState === null || originalGetMentionDisabledState === void 0 ? void 0 : originalGetMentionDisabledState(mention);
66
+ };
67
+ cleanupProvider = function cleanupProvider() {
68
+ if (originalGetMentionDisabledState) {
69
+ providerWithPopup.getMentionDisabledState = originalGetMentionDisabledState;
70
+ } else {
71
+ delete providerWithPopup.getMentionDisabledState;
72
+ }
73
+ };
74
+ setProvider(providerWithPopup);
75
+ }).catch(function () {});
76
+ return function () {
77
+ var _cleanupProvider;
78
+ isMounted = false;
79
+ (_cleanupProvider = cleanupProvider) === null || _cleanupProvider === void 0 || _cleanupProvider();
80
+ setProvider(null);
81
+ };
82
+ }, [mentionProvider]);
83
+ var removePendingMention = (0, _react.useCallback)(function () {
84
+ var _api$core;
85
+ var pending = pendingMentionRef.current;
86
+ 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) {
87
+ api.core.actions.execute(function (_ref2) {
88
+ var tr = _ref2.tr;
89
+ var range = findMentionRange(tr.doc, pending.localId);
90
+ return range ? tr.delete(range.from, range.to) : null;
91
+ });
92
+ }
93
+ pendingMentionRef.current = null;
94
+ setAnchorElement(null);
95
+ }, [api]);
96
+ var handleDismiss = (0, _react.useCallback)(function () {
97
+ removePendingMention();
98
+ }, [removePendingMention]);
99
+ var handleInviteComplete = (0, _react.useCallback)(function (result) {
100
+ var _result$invited$, _api$core2, _api$mention;
101
+ var pending = pendingMentionRef.current;
102
+ if (!pending) {
103
+ return;
104
+ }
105
+ var invitedUser = (_result$invited$ = result.invited[0]) !== null && _result$invited$ !== void 0 ? _result$invited$ : result.requested[0];
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
+ return;
109
+ }
110
+ var userId = invitedUser.id,
111
+ email = invitedUser.email;
112
+ api.core.actions.execute(function (_ref3) {
113
+ var tr = _ref3.tr;
114
+ var range = findMentionRange(tr.doc, pending.localId);
115
+ return range ? tr.delete(range.from, range.to) : null;
116
+ });
117
+ api.core.actions.execute(api.mention.commands.insertMention({
118
+ id: userId,
119
+ name: email,
120
+ userType: 'DEFAULT',
121
+ accessLevel: 'CONTAINER'
122
+ }));
123
+ pendingMentionRef.current = null;
124
+ setAnchorElement(null);
125
+ }, [api, removePendingMention]);
126
+ var handleReady = (0, _react.useCallback)(function (show) {
127
+ if (!provider) {
128
+ return;
129
+ }
130
+ if (show) {
131
+ provider.showInlineInvitePopup = function (email, localId) {
132
+ pendingMentionRef.current = {
133
+ email: email,
134
+ localId: localId
135
+ };
136
+ setTimeout(function () {
137
+ var range = findMentionRange(editorView.state.doc, localId);
138
+ var dom = range ? editorView.nodeDOM(range.from) : null;
139
+ setAnchorElement(dom instanceof HTMLElement ? dom : null);
140
+ show(email);
141
+ }, 0);
142
+ };
143
+ } else {
144
+ delete provider.showInlineInvitePopup;
145
+ }
146
+ }, [provider, editorView]);
147
+ 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)) {
148
+ return null;
149
+ }
150
+ var PopupComponent = provider.InlineInvitePopup;
151
+ return /*#__PURE__*/_react.default.createElement(PopupComponent, {
152
+ anchorElement: anchorElement,
153
+ onInviteComplete: handleInviteComplete,
154
+ onDismiss: handleDismiss,
155
+ onReady: handleReady
156
+ });
157
+ };
@@ -153,7 +153,7 @@ var buildTypeAheadInsertedPayload = exports.buildTypeAheadInsertedPayload = func
153
153
  })
154
154
  };
155
155
  };
156
- var buildTypeAheadRenderedPayload = exports.buildTypeAheadRenderedPayload = function buildTypeAheadRenderedPayload(duration, userIds, query, teams, xProductMentionsLength, agentAnalytics) {
156
+ var buildTypeAheadRenderedPayload = exports.buildTypeAheadRenderedPayload = function buildTypeAheadRenderedPayload(duration, userIds, query, teams, xProductMentionsLength, mentionTypeaheadSessionId, agentAnalytics) {
157
157
  var _extractAttributesFro4 = extractAttributesFromQuery(query),
158
158
  queryLength = _extractAttributesFro4.queryLength,
159
159
  spaceInQuery = _extractAttributesFro4.spaceInQuery;
@@ -170,6 +170,7 @@ var buildTypeAheadRenderedPayload = exports.buildTypeAheadRenderedPayload = func
170
170
  attributes: _objectSpread({
171
171
  componentName: componentName,
172
172
  duration: duration,
173
+ mentionTypeaheadSessionId: mentionTypeaheadSessionId,
173
174
  userIds: userIds,
174
175
  teams: teams,
175
176
  queryLength: queryLength,
@@ -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,
@@ -168,6 +167,7 @@ var buildAndSendElementsTypeAheadAnalytics = function buildAndSendElementsTypeAh
168
167
  var query = _ref5.query,
169
168
  mentions = _ref5.mentions,
170
169
  stats = _ref5.stats,
170
+ mentionTypeaheadSessionId = _ref5.mentionTypeaheadSessionId,
171
171
  agentAnalytics = _ref5.agentAnalytics;
172
172
  var duration = 0;
173
173
  var userOrTeamIds = null;
@@ -201,7 +201,7 @@ var buildAndSendElementsTypeAheadAnalytics = function buildAndSendElementsTypeAh
201
201
  return !!m;
202
202
  });
203
203
  }
204
- var payload = (0, _analytics.buildTypeAheadRenderedPayload)(duration, userOrTeamIds, query, teams, xProductMentionsLength, agentAnalytics);
204
+ var payload = (0, _analytics.buildTypeAheadRenderedPayload)(duration, userOrTeamIds, query, teams, xProductMentionsLength, mentionTypeaheadSessionId, agentAnalytics);
205
205
  fireEvent(payload, 'fabric-elements');
206
206
  };
207
207
  };
@@ -286,22 +286,22 @@ var makeTransformMentionsToTypeAheadItems = function makeTransformMentionsToType
286
286
  var mentionItems = mentions.map(function (mention) {
287
287
  return toItem(mention);
288
288
  });
289
- var agentCount = mentions.filter(isAgentMention).length;
290
- var agentAnalytics = {
291
- agentCount: agentCount,
292
- agentSectioningEnabled: enableAgentSectioning
293
- };
294
-
295
289
  // The loading placeholder is a rendered-only row — keep it in
296
290
  // `mentionItems` so the shimmer shows, but exclude it from analytics
297
291
  // and no-results bookkeeping so it isn't counted as a real result.
298
292
  var realMentions = mentions.filter(function (mention) {
299
293
  return !isLoadingPlaceholder(mention);
300
294
  });
295
+ var agentCount = realMentions.filter(isAgentMention).length;
296
+ var agentAnalytics = {
297
+ agentCount: agentCount,
298
+ agentSectioningEnabled: enableAgentSectioning
299
+ };
301
300
  buildAndSendElementsTypeAheadAnalytics(fireEvent)({
302
301
  query: query,
303
302
  mentions: realMentions,
304
303
  stats: stats,
304
+ mentionTypeaheadSessionId: sessionId,
305
305
  agentAnalytics: agentAnalytics
306
306
  });
307
307
 
@@ -490,10 +490,10 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
490
490
  // Don't fire event and the callback with selection by space press
491
491
  if (mode !== 'space') {
492
492
  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') ? {
493
+ 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
494
  isInlineInviteMentionsEnabled: (_mentionProvider$getS3 = mentionProvider.getShouldEnableInlineInvite) === null || _mentionProvider$getS3 === void 0 ? void 0 : _mentionProvider$getS3.call(mentionProvider)
495
495
  } : {}));
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')) {
496
+ if ((_mentionProvider$getS4 = mentionProvider.getShouldEnableInlineInvite) !== null && _mentionProvider$getS4 !== void 0 && _mentionProvider$getS4.call(mentionProvider) && (0, _platformFeatureFlags.fg)('inline_invite_from_mentions_kill_switch')) {
497
497
  // Get the email from query, using the same logic as InviteItemWithEmailDomain
498
498
  var emailDomain = mentionProvider.userEmailDomain;
499
499
  var email = query || '';
@@ -502,13 +502,21 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
502
502
  email = "".concat(email.toLowerCase(), "@").concat(emailDomain);
503
503
  }
504
504
  // 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
- });
505
+ if (email && mentionProvider.showInlineInvitePopup) {
506
+ var pendingLocalId = crypto.randomUUID();
507
+ var _tr = insert((0, _editorCommands.createSingleMentionFragment)({
508
+ mentionProvider: mentionProvider,
509
+ mentionInsertDisplayName: mentionInsertDisplayName,
510
+ tr: state.tr,
511
+ sanitizePrivateContent: sanitizePrivateContent
512
+ })({
513
+ name: email,
514
+ id: pendingLocalId,
515
+ userType: 'DEFAULT',
516
+ localId: pendingLocalId,
517
+ accessLevel: 'CONTAINER'
518
+ }));
519
+ mentionProvider.showInlineInvitePopup(email, pendingLocalId);
512
520
  return _tr;
513
521
  }
514
522
  } else if (mentionProvider.onInviteItemClick) {
@@ -0,0 +1,2 @@
1
+ /* eslint-disable @atlaskit/editor/no-re-export */
2
+ export { AnchoredPopup } from '../ui/AnchoredPopup';
@@ -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 = "16.0.2";
54
+ const PACKAGE_VERSION = "16.1.0";
55
55
  const setProvider = provider => (state, dispatch) => {
56
56
  if (dispatch) {
57
57
  dispatch(state.tr.setMeta(mentionPluginKey, {
@@ -0,0 +1,28 @@
1
+ import React, { useCallback } from 'react';
2
+ import { Popup } from '@atlaskit/popup/popup';
3
+ /**
4
+ * A `<Popup>` anchored to an externally-supplied DOM node. Unlike `PopupTrigger`, it has no
5
+ * clickable trigger of its own — it opens whenever `isOpen` becomes true, so callers can drive
6
+ * it from any external signal.
7
+ */
8
+ export function AnchoredPopup({
9
+ anchorElement,
10
+ content,
11
+ isOpen,
12
+ onClose
13
+ }) {
14
+ const renderContent = useCallback(() => isOpen ? content : null, [isOpen, content]);
15
+ const renderTrigger = useCallback(triggerProps => {
16
+ if (anchorElement && typeof triggerProps.ref === 'function') {
17
+ triggerProps.ref(anchorElement);
18
+ }
19
+ return null;
20
+ }, [anchorElement]);
21
+ return /*#__PURE__*/React.createElement(Popup, {
22
+ isOpen: isOpen,
23
+ onClose: onClose,
24
+ placement: "bottom-start",
25
+ content: renderContent,
26
+ trigger: renderTrigger
27
+ });
28
+ }
@@ -0,0 +1,146 @@
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
+ let cleanupProvider;
36
+ mentionProvider.then(resolvedProvider => {
37
+ var _providerWithPopup$ge;
38
+ if (!isMounted) {
39
+ return;
40
+ }
41
+ const providerWithPopup = resolvedProvider;
42
+ const originalGetMentionDisabledState = (_providerWithPopup$ge = providerWithPopup.getMentionDisabledState) === null || _providerWithPopup$ge === void 0 ? void 0 : _providerWithPopup$ge.bind(providerWithPopup);
43
+ providerWithPopup.getMentionDisabledState = mention => {
44
+ var _pendingMentionRef$cu;
45
+ if (((_pendingMentionRef$cu = pendingMentionRef.current) === null || _pendingMentionRef$cu === void 0 ? void 0 : _pendingMentionRef$cu.localId) === mention.id) {
46
+ return {
47
+ disabled: true
48
+ };
49
+ }
50
+ return originalGetMentionDisabledState === null || originalGetMentionDisabledState === void 0 ? void 0 : originalGetMentionDisabledState(mention);
51
+ };
52
+ cleanupProvider = () => {
53
+ if (originalGetMentionDisabledState) {
54
+ providerWithPopup.getMentionDisabledState = originalGetMentionDisabledState;
55
+ } else {
56
+ delete providerWithPopup.getMentionDisabledState;
57
+ }
58
+ };
59
+ setProvider(providerWithPopup);
60
+ }).catch(() => {});
61
+ return () => {
62
+ var _cleanupProvider;
63
+ isMounted = false;
64
+ (_cleanupProvider = cleanupProvider) === null || _cleanupProvider === void 0 ? void 0 : _cleanupProvider();
65
+ setProvider(null);
66
+ };
67
+ }, [mentionProvider]);
68
+ const removePendingMention = useCallback(() => {
69
+ var _api$core, _api$core$actions;
70
+ const pending = pendingMentionRef.current;
71
+ 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) {
72
+ api.core.actions.execute(({
73
+ tr
74
+ }) => {
75
+ const range = findMentionRange(tr.doc, pending.localId);
76
+ return range ? tr.delete(range.from, range.to) : null;
77
+ });
78
+ }
79
+ pendingMentionRef.current = null;
80
+ setAnchorElement(null);
81
+ }, [api]);
82
+ const handleDismiss = useCallback(() => {
83
+ removePendingMention();
84
+ }, [removePendingMention]);
85
+ const handleInviteComplete = useCallback(result => {
86
+ var _result$invited$, _api$core2, _api$core2$actions, _api$mention, _api$mention$commands;
87
+ const pending = pendingMentionRef.current;
88
+ if (!pending) {
89
+ return;
90
+ }
91
+ const invitedUser = (_result$invited$ = result.invited[0]) !== null && _result$invited$ !== void 0 ? _result$invited$ : result.requested[0];
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
+ return;
95
+ }
96
+ const {
97
+ id: userId,
98
+ email
99
+ } = invitedUser;
100
+ api.core.actions.execute(({
101
+ tr
102
+ }) => {
103
+ const range = findMentionRange(tr.doc, pending.localId);
104
+ return range ? tr.delete(range.from, range.to) : null;
105
+ });
106
+ api.core.actions.execute(api.mention.commands.insertMention({
107
+ id: userId,
108
+ name: email,
109
+ userType: 'DEFAULT',
110
+ accessLevel: 'CONTAINER'
111
+ }));
112
+ pendingMentionRef.current = null;
113
+ setAnchorElement(null);
114
+ }, [api, removePendingMention]);
115
+ const handleReady = useCallback(show => {
116
+ if (!provider) {
117
+ return;
118
+ }
119
+ if (show) {
120
+ provider.showInlineInvitePopup = (email, localId) => {
121
+ pendingMentionRef.current = {
122
+ email,
123
+ localId
124
+ };
125
+ setTimeout(() => {
126
+ const range = findMentionRange(editorView.state.doc, localId);
127
+ const dom = range ? editorView.nodeDOM(range.from) : null;
128
+ setAnchorElement(dom instanceof HTMLElement ? dom : null);
129
+ show(email);
130
+ }, 0);
131
+ };
132
+ } else {
133
+ delete provider.showInlineInvitePopup;
134
+ }
135
+ }, [provider, editorView]);
136
+ 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)) {
137
+ return null;
138
+ }
139
+ const PopupComponent = provider.InlineInvitePopup;
140
+ return /*#__PURE__*/React.createElement(PopupComponent, {
141
+ anchorElement: anchorElement,
142
+ onInviteComplete: handleInviteComplete,
143
+ onDismiss: handleDismiss,
144
+ onReady: handleReady
145
+ });
146
+ };
@@ -146,7 +146,7 @@ export const buildTypeAheadInsertedPayload = (duration, upKeyCount, downKeyCount
146
146
  }
147
147
  };
148
148
  };
149
- export const buildTypeAheadRenderedPayload = (duration, userIds, query, teams, xProductMentionsLength, agentAnalytics) => {
149
+ export const buildTypeAheadRenderedPayload = (duration, userIds, query, teams, xProductMentionsLength, mentionTypeaheadSessionId, agentAnalytics) => {
150
150
  const {
151
151
  queryLength,
152
152
  spaceInQuery
@@ -164,6 +164,7 @@ export const buildTypeAheadRenderedPayload = (duration, userIds, query, teams, x
164
164
  attributes: {
165
165
  componentName,
166
166
  duration,
167
+ mentionTypeaheadSessionId,
167
168
  userIds,
168
169
  teams,
169
170
  queryLength,