@atlaskit/editor-plugin-mentions 14.7.0 → 14.8.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,19 @@
1
1
  # @atlaskit/editor-plugin-mentions
2
2
 
3
+ ## 14.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`d6596dc895420`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d6596dc895420) -
8
+ Show a loading shimmer in the mention typeahead Agents section while the (slower) agent source
9
+ resolves. The Rovo chat mention provider now emits a non-selectable loading placeholder in the
10
+ agents slot until agents arrive (gated by rovo_chat_agent_selection); @atlaskit/mention renders it
11
+ as a skeleton row, and the editor mention plugin guards it from selection/analytics.
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies
16
+
3
17
  ## 14.7.0
4
18
 
5
19
  ### Minor Changes
@@ -66,7 +66,7 @@ var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
66
66
  var AGENT_MENTION_INACTIVITY_MS = 3000;
67
67
  var MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
68
68
  var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
69
- var PACKAGE_VERSION = "14.6.6";
69
+ var PACKAGE_VERSION = "14.7.0";
70
70
  var setProvider = function setProvider(provider) {
71
71
  return function (state, dispatch) {
72
72
  if (dispatch) {
@@ -46,6 +46,14 @@ var isAgentMention = function isAgentMention(mention) {
46
46
  var isAgentTypeAheadItem = function isAgentTypeAheadItem(item) {
47
47
  return item.mention ? isAgentMention(item.mention) : false;
48
48
  };
49
+
50
+ // A non-selectable loading placeholder injected by the provider (e.g.
51
+ // `RovoChatMentionResource`) while the slower agent source resolves. It
52
+ // renders as a skeleton row via `@atlaskit/mention`'s `MentionItem` and
53
+ // must never be inserted or counted in rendered-mention analytics.
54
+ var isLoadingPlaceholder = function isLoadingPlaceholder(mention) {
55
+ return !!(mention !== null && mention !== void 0 && mention.isPlaceholder);
56
+ };
49
57
  var createInviteItem = function createInviteItem(_ref) {
50
58
  var mentionProvider = _ref.mentionProvider,
51
59
  onInviteItemMount = _ref.onInviteItemMount,
@@ -282,13 +290,24 @@ var makeTransformMentionsToTypeAheadItems = function makeTransformMentionsToType
282
290
  agentCount: agentCount,
283
291
  agentSectioningEnabled: enableAgentSectioning
284
292
  };
293
+
294
+ // The loading placeholder is a rendered-only row — keep it in
295
+ // `mentionItems` so the shimmer shows, but exclude it from analytics
296
+ // and no-results bookkeeping so it isn't counted as a real result.
297
+ var realMentions = mentions.filter(function (mention) {
298
+ return !isLoadingPlaceholder(mention);
299
+ });
285
300
  buildAndSendElementsTypeAheadAnalytics(fireEvent)({
286
301
  query: query,
287
- mentions: mentions,
302
+ mentions: realMentions,
288
303
  stats: stats,
289
304
  agentAnalytics: agentAnalytics
290
305
  });
291
- if (mentions.length === 0 && getFirstQueryWithoutResults() === null) {
306
+
307
+ // While a loading placeholder is present the result set isn't settled yet
308
+ // (e.g. agents still resolving) — don't record this query as "no results",
309
+ // or a later emission that arrives with results would be ignored.
310
+ if (realMentions.length === 0 && !mentions.some(isLoadingPlaceholder) && getFirstQueryWithoutResults() === null) {
292
311
  setFirstQueryWithoutResults(query);
293
312
  }
294
313
  if (!mentionProvider.shouldEnableInvite || mentionItems.length > 2) {
@@ -433,6 +452,12 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
433
452
  query = _ref10.query,
434
453
  sourceListItem = _ref10.sourceListItem;
435
454
  var schema = state.schema;
455
+
456
+ // Placeholder isn't selectable. Return `false` (not a transaction) so
457
+ // the runtime keeps the dropdown open; a transaction would close it.
458
+ if (isLoadingPlaceholder(item.mention)) {
459
+ return false;
460
+ }
436
461
  var pluginState = (0, _utils2.getMentionPluginState)(state);
437
462
  var mentionProvider = pluginState.mentionProvider;
438
463
  var _item$mention = item.mention,
@@ -50,7 +50,7 @@ const AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
50
50
  const AGENT_MENTION_INACTIVITY_MS = 3000;
51
51
  const MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
52
52
  const PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
53
- const PACKAGE_VERSION = "14.6.6";
53
+ const PACKAGE_VERSION = "14.7.0";
54
54
  const setProvider = provider => (state, dispatch) => {
55
55
  if (dispatch) {
56
56
  dispatch(state.tr.setMeta(mentionPluginKey, {
@@ -24,6 +24,12 @@ import { isInviteItem, isTeamStats, isTeamType, shouldKeepInviteItem } from './u
24
24
  const isAgentUserType = userType => userType === 'APP' || userType === 'AGENT';
25
25
  const isAgentMention = mention => isAgentUserType(mention.userType) || mention.appType === 'agent';
26
26
  const isAgentTypeAheadItem = item => item.mention ? isAgentMention(item.mention) : false;
27
+
28
+ // A non-selectable loading placeholder injected by the provider (e.g.
29
+ // `RovoChatMentionResource`) while the slower agent source resolves. It
30
+ // renders as a skeleton row via `@atlaskit/mention`'s `MentionItem` and
31
+ // must never be inserted or counted in rendered-mention analytics.
32
+ const isLoadingPlaceholder = mention => !!(mention !== null && mention !== void 0 && mention.isPlaceholder);
27
33
  const createInviteItem = ({
28
34
  mentionProvider,
29
35
  onInviteItemMount,
@@ -251,13 +257,22 @@ const makeTransformMentionsToTypeAheadItems = ({
251
257
  agentCount,
252
258
  agentSectioningEnabled: enableAgentSectioning
253
259
  };
260
+
261
+ // The loading placeholder is a rendered-only row — keep it in
262
+ // `mentionItems` so the shimmer shows, but exclude it from analytics
263
+ // and no-results bookkeeping so it isn't counted as a real result.
264
+ const realMentions = mentions.filter(mention => !isLoadingPlaceholder(mention));
254
265
  buildAndSendElementsTypeAheadAnalytics(fireEvent)({
255
266
  query,
256
- mentions,
267
+ mentions: realMentions,
257
268
  stats,
258
269
  agentAnalytics
259
270
  });
260
- if (mentions.length === 0 && getFirstQueryWithoutResults() === null) {
271
+
272
+ // While a loading placeholder is present the result set isn't settled yet
273
+ // (e.g. agents still resolving) — don't record this query as "no results",
274
+ // or a later emission that arrives with results would be ignored.
275
+ if (realMentions.length === 0 && !mentions.some(isLoadingPlaceholder) && getFirstQueryWithoutResults() === null) {
261
276
  setFirstQueryWithoutResults(query);
262
277
  }
263
278
  if (!mentionProvider.shouldEnableInvite || mentionItems.length > 2) {
@@ -403,6 +418,12 @@ export const createTypeAheadConfig = ({
403
418
  const {
404
419
  schema
405
420
  } = state;
421
+
422
+ // Placeholder isn't selectable. Return `false` (not a transaction) so
423
+ // the runtime keeps the dropdown open; a transaction would close it.
424
+ if (isLoadingPlaceholder(item.mention)) {
425
+ return false;
426
+ }
406
427
  const pluginState = getMentionPluginState(state);
407
428
  const {
408
429
  mentionProvider
@@ -57,7 +57,7 @@ var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
57
57
  var AGENT_MENTION_INACTIVITY_MS = 3000;
58
58
  var MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
59
59
  var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
60
- var PACKAGE_VERSION = "14.6.6";
60
+ var PACKAGE_VERSION = "14.7.0";
61
61
  var setProvider = function setProvider(provider) {
62
62
  return function (state, dispatch) {
63
63
  if (dispatch) {
@@ -37,6 +37,14 @@ var isAgentMention = function isAgentMention(mention) {
37
37
  var isAgentTypeAheadItem = function isAgentTypeAheadItem(item) {
38
38
  return item.mention ? isAgentMention(item.mention) : false;
39
39
  };
40
+
41
+ // A non-selectable loading placeholder injected by the provider (e.g.
42
+ // `RovoChatMentionResource`) while the slower agent source resolves. It
43
+ // renders as a skeleton row via `@atlaskit/mention`'s `MentionItem` and
44
+ // must never be inserted or counted in rendered-mention analytics.
45
+ var isLoadingPlaceholder = function isLoadingPlaceholder(mention) {
46
+ return !!(mention !== null && mention !== void 0 && mention.isPlaceholder);
47
+ };
40
48
  var createInviteItem = function createInviteItem(_ref) {
41
49
  var mentionProvider = _ref.mentionProvider,
42
50
  onInviteItemMount = _ref.onInviteItemMount,
@@ -273,13 +281,24 @@ var makeTransformMentionsToTypeAheadItems = function makeTransformMentionsToType
273
281
  agentCount: agentCount,
274
282
  agentSectioningEnabled: enableAgentSectioning
275
283
  };
284
+
285
+ // The loading placeholder is a rendered-only row — keep it in
286
+ // `mentionItems` so the shimmer shows, but exclude it from analytics
287
+ // and no-results bookkeeping so it isn't counted as a real result.
288
+ var realMentions = mentions.filter(function (mention) {
289
+ return !isLoadingPlaceholder(mention);
290
+ });
276
291
  buildAndSendElementsTypeAheadAnalytics(fireEvent)({
277
292
  query: query,
278
- mentions: mentions,
293
+ mentions: realMentions,
279
294
  stats: stats,
280
295
  agentAnalytics: agentAnalytics
281
296
  });
282
- if (mentions.length === 0 && getFirstQueryWithoutResults() === null) {
297
+
298
+ // While a loading placeholder is present the result set isn't settled yet
299
+ // (e.g. agents still resolving) — don't record this query as "no results",
300
+ // or a later emission that arrives with results would be ignored.
301
+ if (realMentions.length === 0 && !mentions.some(isLoadingPlaceholder) && getFirstQueryWithoutResults() === null) {
283
302
  setFirstQueryWithoutResults(query);
284
303
  }
285
304
  if (!mentionProvider.shouldEnableInvite || mentionItems.length > 2) {
@@ -424,6 +443,12 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref8) {
424
443
  query = _ref10.query,
425
444
  sourceListItem = _ref10.sourceListItem;
426
445
  var schema = state.schema;
446
+
447
+ // Placeholder isn't selectable. Return `false` (not a transaction) so
448
+ // the runtime keeps the dropdown open; a transaction would close it.
449
+ if (isLoadingPlaceholder(item.mention)) {
450
+ return false;
451
+ }
427
452
  var pluginState = getMentionPluginState(state);
428
453
  var mentionProvider = pluginState.mentionProvider;
429
454
  var _item$mention = item.mention,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-mentions",
3
- "version": "14.7.0",
3
+ "version": "14.8.0",
4
4
  "description": "Mentions plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,7 +33,7 @@
33
33
  "@atlaskit/insm": "^1.0.0",
34
34
  "@atlaskit/link": "^4.3.0",
35
35
  "@atlaskit/lozenge": "^14.1.0",
36
- "@atlaskit/mention": "^27.6.0",
36
+ "@atlaskit/mention": "^27.7.0",
37
37
  "@atlaskit/platform-feature-flags": "^2.0.0",
38
38
  "@atlaskit/popper": "^8.3.0",
39
39
  "@atlaskit/portal": "^6.1.0",
@@ -53,7 +53,7 @@
53
53
  "uuid": "^3.1.0"
54
54
  },
55
55
  "peerDependencies": {
56
- "@atlaskit/editor-common": "^116.31.0",
56
+ "@atlaskit/editor-common": "^116.32.0",
57
57
  "react": "^18.2.0",
58
58
  "react-dom": "^18.2.0",
59
59
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"