@atlaskit/editor-plugin-mentions 14.5.12 → 14.5.14

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,18 @@
1
1
  # @atlaskit/editor-plugin-mentions
2
2
 
3
+ ## 14.5.14
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 14.5.13
10
+
11
+ ### Patch Changes
12
+
13
+ - [`d8df4ec19d384`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d8df4ec19d384) -
14
+ Suppresses nudge from agent mention when rovo chat is open
15
+
3
16
  ## 14.5.12
4
17
 
5
18
  ### Patch Changes
@@ -27,6 +27,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
27
27
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
28
28
  var ACTIONS = exports.ACTIONS = {
29
29
  COMMIT_PENDING_TYPED_AGENT_MENTION: 'COMMIT_PENDING_TYPED_AGENT_MENTION',
30
+ DISCARD_PENDING_TYPED_AGENT_MENTION: 'DISCARD_PENDING_TYPED_AGENT_MENTION',
30
31
  SET_PENDING_TYPED_AGENT_MENTION: 'SET_PENDING_TYPED_AGENT_MENTION',
31
32
  SET_PROVIDER: 'SET_PROVIDER'
32
33
  };
@@ -52,7 +53,7 @@ var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
52
53
  var AGENT_MENTION_INACTIVITY_MS = 3000;
53
54
  var MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
54
55
  var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
55
- var PACKAGE_VERSION = "14.5.11";
56
+ var PACKAGE_VERSION = "14.5.13";
56
57
  var setProvider = function setProvider(provider) {
57
58
  return function (state, dispatch) {
58
59
  if (dispatch) {
@@ -163,6 +164,7 @@ var getPendingTypedAgentMentionAfterDocChange = function getPendingTypedAgentMen
163
164
  localId: pendingTypedAgentMention.localId,
164
165
  name: pendingMentionDetails.name,
165
166
  nodeSize: pendingMentionDetails.nodeSize,
167
+ parentNodeType: pendingMentionDetails.parentNodeType,
166
168
  pos: pendingMentionDetails.pos,
167
169
  resetCount: resetCount
168
170
  } : null;
@@ -252,6 +254,10 @@ function createMentionPlugin(_ref2) {
252
254
  options = _ref2.options,
253
255
  api = _ref2.api;
254
256
  var mentionProvider;
257
+
258
+ // Injected by Rovo-aware consumers only. Non-Rovo consumers omit this field
259
+ // entirely so this plugin incurs zero bundle cost from rovo-experience-api.
260
+ var getIsRovoPanelOpen = options === null || options === void 0 ? void 0 : options.getIsRovoPanelOpen;
255
261
  var sendAnalytics = function sendAnalytics(event, actionSubject, action, attributes) {
256
262
  if (event === _resource.SLI_EVENT_TYPE || event === _resource.SMART_EVENT_TYPE) {
257
263
  fireEvent({
@@ -306,6 +312,19 @@ function createMentionPlugin(_ref2) {
306
312
  hasPublicPluginStateChanged = hasPublicPluginStateChanged || commitResult.hasPublicPluginStateChanged;
307
313
  break;
308
314
  }
315
+ case ACTIONS.DISCARD_PENDING_TYPED_AGENT_MENTION:
316
+ {
317
+ // Silently discard the pending typed agent mention without committing it.
318
+ var pendingTypedAgentMentionToDiscard = newPluginState.pendingTypedAgentMention;
319
+ if (!isAgentMentionsExperimentEnabled || !pendingTypedAgentMentionToDiscard || pendingTypedAgentMentionToDiscard.localId !== (params === null || params === void 0 ? void 0 : params.localId) || pendingTypedAgentMentionToDiscard.resetCount !== (params === null || params === void 0 ? void 0 : params.resetCount)) {
320
+ break;
321
+ }
322
+ newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
323
+ pendingTypedAgentMention: null
324
+ });
325
+ hasPublicPluginStateChanged = true;
326
+ break;
327
+ }
309
328
  case ACTIONS.SET_PROVIDER:
310
329
  newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
311
330
  mentionProvider: params.provider
@@ -549,6 +568,7 @@ function createMentionPlugin(_ref2) {
549
568
  localId: pendingTypedAgentMentionLocalId,
550
569
  name: pendingTypedAgentMentionDetailsForState.name,
551
570
  nodeSize: pendingTypedAgentMentionDetailsForState.nodeSize,
571
+ parentNodeType: pendingTypedAgentMentionDetailsForState.parentNodeType,
552
572
  pos: pendingTypedAgentMentionDetailsForState.pos,
553
573
  resetCount: 1
554
574
  }
@@ -569,17 +589,26 @@ function createMentionPlugin(_ref2) {
569
589
  } : {});
570
590
  hasPublicPluginStateChanged = true;
571
591
  } else if (agentMentionId !== ((_newPluginState$lastI2 = newPluginState.lastInsertedAgentMentionId) !== null && _newPluginState$lastI2 !== void 0 ? _newPluginState$lastI2 : null) || agentMentionLocalId !== ((_newPluginState$lastI3 = newPluginState.lastInsertedAgentMentionLocalId) !== null && _newPluginState$lastI3 !== void 0 ? _newPluginState$lastI3 : null) || agentMentionName !== ((_newPluginState$lastI4 = newPluginState.lastInsertedAgentMentionName) !== null && _newPluginState$lastI4 !== void 0 ? _newPluginState$lastI4 : null) || agentMentionPrompt !== ((_newPluginState$lastI5 = newPluginState.lastInsertedAgentMentionPrompt) !== null && _newPluginState$lastI5 !== void 0 ? _newPluginState$lastI5 : null) || agentMentionParentNodeType !== ((_newPluginState$lastI6 = newPluginState.lastInsertedAgentMentionParentNodeType) !== null && _newPluginState$lastI6 !== void 0 ? _newPluginState$lastI6 : null) || newInsertionCount !== undefined) {
572
- newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
573
- lastInsertedAgentMentionId: agentMentionId,
574
- lastInsertedAgentMentionLocalId: agentMentionLocalId,
575
- lastInsertedAgentMentionContext: agentMentionContext,
576
- lastInsertedAgentMentionName: agentMentionName,
577
- lastInsertedAgentMentionPrompt: agentMentionPrompt,
578
- lastInsertedAgentMentionParentNodeType: agentMentionParentNodeType
579
- }, newInsertionCount !== undefined ? {
580
- lastAgentMentionInsertionCount: newInsertionCount
581
- } : {});
582
- hasPublicPluginStateChanged = true;
592
+ // Suppress the nudge for pasted/non-typed agent mentions when Rovo is already
593
+ // open.
594
+ var isTaskItemMentionForPaste = agentMentionParentNodeType === 'taskItem';
595
+ if (!isTaskItemMentionForPaste && isNewInsertion && getIsRovoPanelOpen !== null && getIsRovoPanelOpen !== void 0 && getIsRovoPanelOpen()) {
596
+ // Rovo is already open — skip setting lastInsertedAgentMention* so the
597
+ // downstream nudge listener never fires.
598
+ } else {
599
+ // Not suppressed update state so the nudge fires normally.
600
+ newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
601
+ lastInsertedAgentMentionId: agentMentionId,
602
+ lastInsertedAgentMentionLocalId: agentMentionLocalId,
603
+ lastInsertedAgentMentionContext: agentMentionContext,
604
+ lastInsertedAgentMentionName: agentMentionName,
605
+ lastInsertedAgentMentionPrompt: agentMentionPrompt,
606
+ lastInsertedAgentMentionParentNodeType: agentMentionParentNodeType
607
+ }, newInsertionCount !== undefined ? {
608
+ lastAgentMentionInsertionCount: newInsertionCount
609
+ } : {});
610
+ hasPublicPluginStateChanged = true;
611
+ }
583
612
  }
584
613
  }
585
614
  }
@@ -610,9 +639,21 @@ function createMentionPlugin(_ref2) {
610
639
  pendingTypedAgentMention: null
611
640
  });
612
641
  } else if (hasPendingMentionMovedToNewParent(oldState, tr, pluginState.pendingTypedAgentMention, pendingMentionDetails) || isSelectionOutsideDirectParent(newState, pendingMentionDetails)) {
613
- var _commitResult = commitResolvedPendingTypedAgentMention(newPluginState, pendingMentionDetails);
614
- newPluginState = _commitResult.pluginState;
615
- hasPublicPluginStateChanged = hasPublicPluginStateChanged || _commitResult.hasPublicPluginStateChanged;
642
+ // Suppress the nudge when Rovo chat is already open, mirroring the same
643
+ // guard used in the inactivity-timer path. Task-item mentions are
644
+ // exempt because they auto-fire the mini modal and never show a nudge.
645
+ if (pendingMentionDetails.parentNodeType !== 'taskItem' && getIsRovoPanelOpen !== null && getIsRovoPanelOpen !== void 0 && getIsRovoPanelOpen()) {
646
+ // Discard without committing so lastInsertedAgentMention* fields are
647
+ // never set and the downstream nudge listener never fires.
648
+ newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
649
+ pendingTypedAgentMention: null
650
+ });
651
+ hasPublicPluginStateChanged = true;
652
+ } else {
653
+ var _commitResult = commitResolvedPendingTypedAgentMention(newPluginState, pendingMentionDetails);
654
+ newPluginState = _commitResult.pluginState;
655
+ hasPublicPluginStateChanged = hasPublicPluginStateChanged || _commitResult.hasPublicPluginStateChanged;
656
+ }
616
657
  }
617
658
  }
618
659
  if (hasPublicPluginStateChanged && isAgentMentionsExperimentEnabled) {
@@ -696,6 +737,23 @@ function createMentionPlugin(_ref2) {
696
737
  pendingTypedAgentMentionTimerKey = timerKey;
697
738
  pendingTypedAgentMentionTimer = setTimeout(function () {
698
739
  var _mentionPluginKey$get;
740
+ {
741
+ // Suppress the agent-mention nudge when the Rovo panel is already open,
742
+ // but only for non-task-item mentions.
743
+ var isTaskItemMention = pendingTypedAgentMention.parentNodeType === 'taskItem';
744
+ if (!isTaskItemMention && getIsRovoPanelOpen !== null && getIsRovoPanelOpen !== void 0 && getIsRovoPanelOpen()) {
745
+ // Dispatch a discard so pendingTypedAgentMention is nulled out of plugin
746
+ // state.
747
+ editorView.dispatch(editorView.state.tr.setMeta(_key.mentionPluginKey, {
748
+ action: ACTIONS.DISCARD_PENDING_TYPED_AGENT_MENTION,
749
+ params: {
750
+ localId: pendingTypedAgentMention.localId,
751
+ resetCount: pendingTypedAgentMention.resetCount
752
+ }
753
+ }));
754
+ return;
755
+ }
756
+ }
699
757
  var latestPendingTypedAgentMention = (_mentionPluginKey$get = _key.mentionPluginKey.getState(editorView.state)) === null || _mentionPluginKey$get === void 0 ? void 0 : _mentionPluginKey$get.pendingTypedAgentMention;
700
758
  if (!latestPendingTypedAgentMention || latestPendingTypedAgentMention.localId !== pendingTypedAgentMention.localId || latestPendingTypedAgentMention.resetCount !== pendingTypedAgentMention.resetCount) {
701
759
  return;
@@ -12,6 +12,7 @@ import { mentionPluginKey } from './key';
12
12
  import { canMentionBeCreatedInRange } from './utils';
13
13
  export const ACTIONS = {
14
14
  COMMIT_PENDING_TYPED_AGENT_MENTION: 'COMMIT_PENDING_TYPED_AGENT_MENTION',
15
+ DISCARD_PENDING_TYPED_AGENT_MENTION: 'DISCARD_PENDING_TYPED_AGENT_MENTION',
15
16
  SET_PENDING_TYPED_AGENT_MENTION: 'SET_PENDING_TYPED_AGENT_MENTION',
16
17
  SET_PROVIDER: 'SET_PROVIDER'
17
18
  };
@@ -37,7 +38,7 @@ const AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
37
38
  const AGENT_MENTION_INACTIVITY_MS = 3000;
38
39
  const MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
39
40
  const PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
40
- const PACKAGE_VERSION = "14.5.11";
41
+ const PACKAGE_VERSION = "14.5.13";
41
42
  const setProvider = provider => (state, dispatch) => {
42
43
  if (dispatch) {
43
44
  dispatch(state.tr.setMeta(mentionPluginKey, {
@@ -143,6 +144,7 @@ const getPendingTypedAgentMentionAfterDocChange = (state, tr, pendingTypedAgentM
143
144
  localId: pendingTypedAgentMention.localId,
144
145
  name: pendingMentionDetails.name,
145
146
  nodeSize: pendingMentionDetails.nodeSize,
147
+ parentNodeType: pendingMentionDetails.parentNodeType,
146
148
  pos: pendingMentionDetails.pos,
147
149
  resetCount
148
150
  } : null;
@@ -230,6 +232,10 @@ export function createMentionPlugin({
230
232
  api
231
233
  }) {
232
234
  let mentionProvider;
235
+
236
+ // Injected by Rovo-aware consumers only. Non-Rovo consumers omit this field
237
+ // entirely so this plugin incurs zero bundle cost from rovo-experience-api.
238
+ const getIsRovoPanelOpen = options === null || options === void 0 ? void 0 : options.getIsRovoPanelOpen;
233
239
  const sendAnalytics = (event, actionSubject, action, attributes) => {
234
240
  if (event === SLI_EVENT_TYPE || event === SMART_EVENT_TYPE) {
235
241
  fireEvent({
@@ -287,6 +293,20 @@ export function createMentionPlugin({
287
293
  hasPublicPluginStateChanged = hasPublicPluginStateChanged || commitResult.hasPublicPluginStateChanged;
288
294
  break;
289
295
  }
296
+ case ACTIONS.DISCARD_PENDING_TYPED_AGENT_MENTION:
297
+ {
298
+ // Silently discard the pending typed agent mention without committing it.
299
+ const pendingTypedAgentMentionToDiscard = newPluginState.pendingTypedAgentMention;
300
+ if (!isAgentMentionsExperimentEnabled || !pendingTypedAgentMentionToDiscard || pendingTypedAgentMentionToDiscard.localId !== (params === null || params === void 0 ? void 0 : params.localId) || pendingTypedAgentMentionToDiscard.resetCount !== (params === null || params === void 0 ? void 0 : params.resetCount)) {
301
+ break;
302
+ }
303
+ newPluginState = {
304
+ ...newPluginState,
305
+ pendingTypedAgentMention: null
306
+ };
307
+ hasPublicPluginStateChanged = true;
308
+ break;
309
+ }
290
310
  case ACTIONS.SET_PROVIDER:
291
311
  newPluginState = {
292
312
  ...newPluginState,
@@ -504,6 +524,7 @@ export function createMentionPlugin({
504
524
  localId: pendingTypedAgentMentionLocalId,
505
525
  name: pendingTypedAgentMentionDetailsForState.name,
506
526
  nodeSize: pendingTypedAgentMentionDetailsForState.nodeSize,
527
+ parentNodeType: pendingTypedAgentMentionDetailsForState.parentNodeType,
507
528
  pos: pendingTypedAgentMentionDetailsForState.pos,
508
529
  resetCount: 1
509
530
  }
@@ -526,19 +547,28 @@ export function createMentionPlugin({
526
547
  };
527
548
  hasPublicPluginStateChanged = true;
528
549
  } else if (agentMentionId !== ((_newPluginState$lastI2 = newPluginState.lastInsertedAgentMentionId) !== null && _newPluginState$lastI2 !== void 0 ? _newPluginState$lastI2 : null) || agentMentionLocalId !== ((_newPluginState$lastI3 = newPluginState.lastInsertedAgentMentionLocalId) !== null && _newPluginState$lastI3 !== void 0 ? _newPluginState$lastI3 : null) || agentMentionName !== ((_newPluginState$lastI4 = newPluginState.lastInsertedAgentMentionName) !== null && _newPluginState$lastI4 !== void 0 ? _newPluginState$lastI4 : null) || agentMentionPrompt !== ((_newPluginState$lastI5 = newPluginState.lastInsertedAgentMentionPrompt) !== null && _newPluginState$lastI5 !== void 0 ? _newPluginState$lastI5 : null) || agentMentionParentNodeType !== ((_newPluginState$lastI6 = newPluginState.lastInsertedAgentMentionParentNodeType) !== null && _newPluginState$lastI6 !== void 0 ? _newPluginState$lastI6 : null) || newInsertionCount !== undefined) {
529
- newPluginState = {
530
- ...newPluginState,
531
- lastInsertedAgentMentionId: agentMentionId,
532
- lastInsertedAgentMentionLocalId: agentMentionLocalId,
533
- lastInsertedAgentMentionContext: agentMentionContext,
534
- lastInsertedAgentMentionName: agentMentionName,
535
- lastInsertedAgentMentionPrompt: agentMentionPrompt,
536
- lastInsertedAgentMentionParentNodeType: agentMentionParentNodeType,
537
- ...(newInsertionCount !== undefined ? {
538
- lastAgentMentionInsertionCount: newInsertionCount
539
- } : {})
540
- };
541
- hasPublicPluginStateChanged = true;
550
+ // Suppress the nudge for pasted/non-typed agent mentions when Rovo is already
551
+ // open.
552
+ const isTaskItemMentionForPaste = agentMentionParentNodeType === 'taskItem';
553
+ if (!isTaskItemMentionForPaste && isNewInsertion && getIsRovoPanelOpen !== null && getIsRovoPanelOpen !== void 0 && getIsRovoPanelOpen()) {
554
+ // Rovo is already open — skip setting lastInsertedAgentMention* so the
555
+ // downstream nudge listener never fires.
556
+ } else {
557
+ // Not suppressed — update state so the nudge fires normally.
558
+ newPluginState = {
559
+ ...newPluginState,
560
+ lastInsertedAgentMentionId: agentMentionId,
561
+ lastInsertedAgentMentionLocalId: agentMentionLocalId,
562
+ lastInsertedAgentMentionContext: agentMentionContext,
563
+ lastInsertedAgentMentionName: agentMentionName,
564
+ lastInsertedAgentMentionPrompt: agentMentionPrompt,
565
+ lastInsertedAgentMentionParentNodeType: agentMentionParentNodeType,
566
+ ...(newInsertionCount !== undefined ? {
567
+ lastAgentMentionInsertionCount: newInsertionCount
568
+ } : {})
569
+ };
570
+ hasPublicPluginStateChanged = true;
571
+ }
542
572
  }
543
573
  }
544
574
  }
@@ -569,9 +599,22 @@ export function createMentionPlugin({
569
599
  pendingTypedAgentMention: null
570
600
  };
571
601
  } else if (hasPendingMentionMovedToNewParent(oldState, tr, pluginState.pendingTypedAgentMention, pendingMentionDetails) || isSelectionOutsideDirectParent(newState, pendingMentionDetails)) {
572
- const commitResult = commitResolvedPendingTypedAgentMention(newPluginState, pendingMentionDetails);
573
- newPluginState = commitResult.pluginState;
574
- hasPublicPluginStateChanged = hasPublicPluginStateChanged || commitResult.hasPublicPluginStateChanged;
602
+ // Suppress the nudge when Rovo chat is already open, mirroring the same
603
+ // guard used in the inactivity-timer path. Task-item mentions are
604
+ // exempt because they auto-fire the mini modal and never show a nudge.
605
+ if (pendingMentionDetails.parentNodeType !== 'taskItem' && getIsRovoPanelOpen !== null && getIsRovoPanelOpen !== void 0 && getIsRovoPanelOpen()) {
606
+ // Discard without committing so lastInsertedAgentMention* fields are
607
+ // never set and the downstream nudge listener never fires.
608
+ newPluginState = {
609
+ ...newPluginState,
610
+ pendingTypedAgentMention: null
611
+ };
612
+ hasPublicPluginStateChanged = true;
613
+ } else {
614
+ const commitResult = commitResolvedPendingTypedAgentMention(newPluginState, pendingMentionDetails);
615
+ newPluginState = commitResult.pluginState;
616
+ hasPublicPluginStateChanged = hasPublicPluginStateChanged || commitResult.hasPublicPluginStateChanged;
617
+ }
575
618
  }
576
619
  }
577
620
  if (hasPublicPluginStateChanged && isAgentMentionsExperimentEnabled) {
@@ -651,6 +694,23 @@ export function createMentionPlugin({
651
694
  pendingTypedAgentMentionTimerKey = timerKey;
652
695
  pendingTypedAgentMentionTimer = setTimeout(() => {
653
696
  var _mentionPluginKey$get;
697
+ {
698
+ // Suppress the agent-mention nudge when the Rovo panel is already open,
699
+ // but only for non-task-item mentions.
700
+ const isTaskItemMention = pendingTypedAgentMention.parentNodeType === 'taskItem';
701
+ if (!isTaskItemMention && getIsRovoPanelOpen !== null && getIsRovoPanelOpen !== void 0 && getIsRovoPanelOpen()) {
702
+ // Dispatch a discard so pendingTypedAgentMention is nulled out of plugin
703
+ // state.
704
+ editorView.dispatch(editorView.state.tr.setMeta(mentionPluginKey, {
705
+ action: ACTIONS.DISCARD_PENDING_TYPED_AGENT_MENTION,
706
+ params: {
707
+ localId: pendingTypedAgentMention.localId,
708
+ resetCount: pendingTypedAgentMention.resetCount
709
+ }
710
+ }));
711
+ return;
712
+ }
713
+ }
654
714
  const latestPendingTypedAgentMention = (_mentionPluginKey$get = mentionPluginKey.getState(editorView.state)) === null || _mentionPluginKey$get === void 0 ? void 0 : _mentionPluginKey$get.pendingTypedAgentMention;
655
715
  if (!latestPendingTypedAgentMention || latestPendingTypedAgentMention.localId !== pendingTypedAgentMention.localId || latestPendingTypedAgentMention.resetCount !== pendingTypedAgentMention.resetCount) {
656
716
  return;
@@ -19,6 +19,7 @@ import { mentionPluginKey } from './key';
19
19
  import { canMentionBeCreatedInRange } from './utils';
20
20
  export var ACTIONS = {
21
21
  COMMIT_PENDING_TYPED_AGENT_MENTION: 'COMMIT_PENDING_TYPED_AGENT_MENTION',
22
+ DISCARD_PENDING_TYPED_AGENT_MENTION: 'DISCARD_PENDING_TYPED_AGENT_MENTION',
22
23
  SET_PENDING_TYPED_AGENT_MENTION: 'SET_PENDING_TYPED_AGENT_MENTION',
23
24
  SET_PROVIDER: 'SET_PROVIDER'
24
25
  };
@@ -44,7 +45,7 @@ var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
44
45
  var AGENT_MENTION_INACTIVITY_MS = 3000;
45
46
  var MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
46
47
  var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
47
- var PACKAGE_VERSION = "14.5.11";
48
+ var PACKAGE_VERSION = "14.5.13";
48
49
  var setProvider = function setProvider(provider) {
49
50
  return function (state, dispatch) {
50
51
  if (dispatch) {
@@ -155,6 +156,7 @@ var getPendingTypedAgentMentionAfterDocChange = function getPendingTypedAgentMen
155
156
  localId: pendingTypedAgentMention.localId,
156
157
  name: pendingMentionDetails.name,
157
158
  nodeSize: pendingMentionDetails.nodeSize,
159
+ parentNodeType: pendingMentionDetails.parentNodeType,
158
160
  pos: pendingMentionDetails.pos,
159
161
  resetCount: resetCount
160
162
  } : null;
@@ -244,6 +246,10 @@ export function createMentionPlugin(_ref2) {
244
246
  options = _ref2.options,
245
247
  api = _ref2.api;
246
248
  var mentionProvider;
249
+
250
+ // Injected by Rovo-aware consumers only. Non-Rovo consumers omit this field
251
+ // entirely so this plugin incurs zero bundle cost from rovo-experience-api.
252
+ var getIsRovoPanelOpen = options === null || options === void 0 ? void 0 : options.getIsRovoPanelOpen;
247
253
  var sendAnalytics = function sendAnalytics(event, actionSubject, action, attributes) {
248
254
  if (event === SLI_EVENT_TYPE || event === SMART_EVENT_TYPE) {
249
255
  fireEvent({
@@ -298,6 +304,19 @@ export function createMentionPlugin(_ref2) {
298
304
  hasPublicPluginStateChanged = hasPublicPluginStateChanged || commitResult.hasPublicPluginStateChanged;
299
305
  break;
300
306
  }
307
+ case ACTIONS.DISCARD_PENDING_TYPED_AGENT_MENTION:
308
+ {
309
+ // Silently discard the pending typed agent mention without committing it.
310
+ var pendingTypedAgentMentionToDiscard = newPluginState.pendingTypedAgentMention;
311
+ if (!isAgentMentionsExperimentEnabled || !pendingTypedAgentMentionToDiscard || pendingTypedAgentMentionToDiscard.localId !== (params === null || params === void 0 ? void 0 : params.localId) || pendingTypedAgentMentionToDiscard.resetCount !== (params === null || params === void 0 ? void 0 : params.resetCount)) {
312
+ break;
313
+ }
314
+ newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
315
+ pendingTypedAgentMention: null
316
+ });
317
+ hasPublicPluginStateChanged = true;
318
+ break;
319
+ }
301
320
  case ACTIONS.SET_PROVIDER:
302
321
  newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
303
322
  mentionProvider: params.provider
@@ -541,6 +560,7 @@ export function createMentionPlugin(_ref2) {
541
560
  localId: pendingTypedAgentMentionLocalId,
542
561
  name: pendingTypedAgentMentionDetailsForState.name,
543
562
  nodeSize: pendingTypedAgentMentionDetailsForState.nodeSize,
563
+ parentNodeType: pendingTypedAgentMentionDetailsForState.parentNodeType,
544
564
  pos: pendingTypedAgentMentionDetailsForState.pos,
545
565
  resetCount: 1
546
566
  }
@@ -561,17 +581,26 @@ export function createMentionPlugin(_ref2) {
561
581
  } : {});
562
582
  hasPublicPluginStateChanged = true;
563
583
  } else if (agentMentionId !== ((_newPluginState$lastI2 = newPluginState.lastInsertedAgentMentionId) !== null && _newPluginState$lastI2 !== void 0 ? _newPluginState$lastI2 : null) || agentMentionLocalId !== ((_newPluginState$lastI3 = newPluginState.lastInsertedAgentMentionLocalId) !== null && _newPluginState$lastI3 !== void 0 ? _newPluginState$lastI3 : null) || agentMentionName !== ((_newPluginState$lastI4 = newPluginState.lastInsertedAgentMentionName) !== null && _newPluginState$lastI4 !== void 0 ? _newPluginState$lastI4 : null) || agentMentionPrompt !== ((_newPluginState$lastI5 = newPluginState.lastInsertedAgentMentionPrompt) !== null && _newPluginState$lastI5 !== void 0 ? _newPluginState$lastI5 : null) || agentMentionParentNodeType !== ((_newPluginState$lastI6 = newPluginState.lastInsertedAgentMentionParentNodeType) !== null && _newPluginState$lastI6 !== void 0 ? _newPluginState$lastI6 : null) || newInsertionCount !== undefined) {
564
- newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
565
- lastInsertedAgentMentionId: agentMentionId,
566
- lastInsertedAgentMentionLocalId: agentMentionLocalId,
567
- lastInsertedAgentMentionContext: agentMentionContext,
568
- lastInsertedAgentMentionName: agentMentionName,
569
- lastInsertedAgentMentionPrompt: agentMentionPrompt,
570
- lastInsertedAgentMentionParentNodeType: agentMentionParentNodeType
571
- }, newInsertionCount !== undefined ? {
572
- lastAgentMentionInsertionCount: newInsertionCount
573
- } : {});
574
- hasPublicPluginStateChanged = true;
584
+ // Suppress the nudge for pasted/non-typed agent mentions when Rovo is already
585
+ // open.
586
+ var isTaskItemMentionForPaste = agentMentionParentNodeType === 'taskItem';
587
+ if (!isTaskItemMentionForPaste && isNewInsertion && getIsRovoPanelOpen !== null && getIsRovoPanelOpen !== void 0 && getIsRovoPanelOpen()) {
588
+ // Rovo is already open — skip setting lastInsertedAgentMention* so the
589
+ // downstream nudge listener never fires.
590
+ } else {
591
+ // Not suppressed update state so the nudge fires normally.
592
+ newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
593
+ lastInsertedAgentMentionId: agentMentionId,
594
+ lastInsertedAgentMentionLocalId: agentMentionLocalId,
595
+ lastInsertedAgentMentionContext: agentMentionContext,
596
+ lastInsertedAgentMentionName: agentMentionName,
597
+ lastInsertedAgentMentionPrompt: agentMentionPrompt,
598
+ lastInsertedAgentMentionParentNodeType: agentMentionParentNodeType
599
+ }, newInsertionCount !== undefined ? {
600
+ lastAgentMentionInsertionCount: newInsertionCount
601
+ } : {});
602
+ hasPublicPluginStateChanged = true;
603
+ }
575
604
  }
576
605
  }
577
606
  }
@@ -602,9 +631,21 @@ export function createMentionPlugin(_ref2) {
602
631
  pendingTypedAgentMention: null
603
632
  });
604
633
  } else if (hasPendingMentionMovedToNewParent(oldState, tr, pluginState.pendingTypedAgentMention, pendingMentionDetails) || isSelectionOutsideDirectParent(newState, pendingMentionDetails)) {
605
- var _commitResult = commitResolvedPendingTypedAgentMention(newPluginState, pendingMentionDetails);
606
- newPluginState = _commitResult.pluginState;
607
- hasPublicPluginStateChanged = hasPublicPluginStateChanged || _commitResult.hasPublicPluginStateChanged;
634
+ // Suppress the nudge when Rovo chat is already open, mirroring the same
635
+ // guard used in the inactivity-timer path. Task-item mentions are
636
+ // exempt because they auto-fire the mini modal and never show a nudge.
637
+ if (pendingMentionDetails.parentNodeType !== 'taskItem' && getIsRovoPanelOpen !== null && getIsRovoPanelOpen !== void 0 && getIsRovoPanelOpen()) {
638
+ // Discard without committing so lastInsertedAgentMention* fields are
639
+ // never set and the downstream nudge listener never fires.
640
+ newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
641
+ pendingTypedAgentMention: null
642
+ });
643
+ hasPublicPluginStateChanged = true;
644
+ } else {
645
+ var _commitResult = commitResolvedPendingTypedAgentMention(newPluginState, pendingMentionDetails);
646
+ newPluginState = _commitResult.pluginState;
647
+ hasPublicPluginStateChanged = hasPublicPluginStateChanged || _commitResult.hasPublicPluginStateChanged;
648
+ }
608
649
  }
609
650
  }
610
651
  if (hasPublicPluginStateChanged && isAgentMentionsExperimentEnabled) {
@@ -688,6 +729,23 @@ export function createMentionPlugin(_ref2) {
688
729
  pendingTypedAgentMentionTimerKey = timerKey;
689
730
  pendingTypedAgentMentionTimer = setTimeout(function () {
690
731
  var _mentionPluginKey$get;
732
+ {
733
+ // Suppress the agent-mention nudge when the Rovo panel is already open,
734
+ // but only for non-task-item mentions.
735
+ var isTaskItemMention = pendingTypedAgentMention.parentNodeType === 'taskItem';
736
+ if (!isTaskItemMention && getIsRovoPanelOpen !== null && getIsRovoPanelOpen !== void 0 && getIsRovoPanelOpen()) {
737
+ // Dispatch a discard so pendingTypedAgentMention is nulled out of plugin
738
+ // state.
739
+ editorView.dispatch(editorView.state.tr.setMeta(mentionPluginKey, {
740
+ action: ACTIONS.DISCARD_PENDING_TYPED_AGENT_MENTION,
741
+ params: {
742
+ localId: pendingTypedAgentMention.localId,
743
+ resetCount: pendingTypedAgentMention.resetCount
744
+ }
745
+ }));
746
+ return;
747
+ }
748
+ }
691
749
  var latestPendingTypedAgentMention = (_mentionPluginKey$get = mentionPluginKey.getState(editorView.state)) === null || _mentionPluginKey$get === void 0 ? void 0 : _mentionPluginKey$get.pendingTypedAgentMention;
692
750
  if (!latestPendingTypedAgentMention || latestPendingTypedAgentMention.localId !== pendingTypedAgentMention.localId || latestPendingTypedAgentMention.resetCount !== pendingTypedAgentMention.resetCount) {
693
751
  return;
@@ -4,6 +4,7 @@ import type { MentionsPlugin } from '../mentionsPluginType';
4
4
  import type { FireElementsChannelEvent, MentionPluginOptions, MentionPluginState } from '../types';
5
5
  export declare const ACTIONS: {
6
6
  COMMIT_PENDING_TYPED_AGENT_MENTION: string;
7
+ DISCARD_PENDING_TYPED_AGENT_MENTION: string;
7
8
  SET_PENDING_TYPED_AGENT_MENTION: string;
8
9
  SET_PROVIDER: string;
9
10
  };
@@ -34,6 +34,12 @@ export interface MentionsPluginOptions extends MentionPluginConfig {
34
34
  * Takes priority over `MentionProvider.shouldHighlightMention()` if both are present.
35
35
  */
36
36
  currentUserId?: string;
37
+ /**
38
+ * Optional getter injected by Rovo-aware consumers to check whether the Rovo
39
+ * panel is currently open. When provided, the mentions plugin uses it to
40
+ * suppress the agent-mention nudge when Rovo is already visible.
41
+ */
42
+ getIsRovoPanelOpen?: () => boolean;
37
43
  handleMentionsChanged?: MentionsChangedHandler;
38
44
  mentionProvider?: Providers['mentionProvider'];
39
45
  sanitizePrivateContent?: boolean;
@@ -111,6 +117,12 @@ export type MentionPluginState = {
111
117
  localId: string;
112
118
  name: string | null;
113
119
  nodeSize: number;
120
+ /**
121
+ * ProseMirror node type of the direct parent of the pending agent mention
122
+ * (e.g. 'taskItem', 'paragraph'). Used in the inactivity timer to skip the
123
+ * getIsRovoPanelOpen() suppression check for task-item mentions.
124
+ */
125
+ parentNodeType: string | null;
114
126
  pos: number;
115
127
  /**
116
128
  * Generation value for the inactivity timer. This changes when local edits
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-mentions",
3
- "version": "14.5.12",
3
+ "version": "14.5.14",
4
4
  "description": "Mentions plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -29,7 +29,7 @@
29
29
  "@atlaskit/editor-plugin-selection": "^12.0.0",
30
30
  "@atlaskit/editor-plugin-type-ahead": "^12.1.0",
31
31
  "@atlaskit/editor-prosemirror": "^8.0.0",
32
- "@atlaskit/icon": "^36.1.0",
32
+ "@atlaskit/icon": "^36.2.0",
33
33
  "@atlaskit/insm": "^1.0.0",
34
34
  "@atlaskit/link": "^4.1.0",
35
35
  "@atlaskit/lozenge": "^14.1.0",
@@ -41,8 +41,8 @@
41
41
  "@atlaskit/profilecard": "^26.8.0",
42
42
  "@atlaskit/teams-app-config": "^2.1.0",
43
43
  "@atlaskit/theme": "^26.1.0",
44
- "@atlaskit/tmp-editor-statsig": "^120.1.0",
45
- "@atlaskit/tokens": "^15.3.0",
44
+ "@atlaskit/tmp-editor-statsig": "^121.0.0",
45
+ "@atlaskit/tokens": "^15.4.0",
46
46
  "@atlaskit/tooltip": "^23.1.0",
47
47
  "@atlaskit/user-picker": "^13.4.0",
48
48
  "@babel/runtime": "^7.0.0",
@@ -53,7 +53,7 @@
53
53
  "uuid": "^3.1.0"
54
54
  },
55
55
  "peerDependencies": {
56
- "@atlaskit/editor-common": "^116.21.0",
56
+ "@atlaskit/editor-common": "^116.22.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"
@@ -118,9 +118,6 @@
118
118
  "people-teams_migrate-user-profile-card": {
119
119
  "type": "boolean"
120
120
  },
121
- "platform_editor_agent_mentions": {
122
- "type": "boolean"
123
- },
124
121
  "rovo_chat_agent_selection": {
125
122
  "type": "boolean"
126
123
  },