@atlaskit/editor-plugin-mentions 15.0.2 → 15.0.3

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.
@@ -10,6 +10,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
10
10
  import { insm } from '@atlaskit/insm';
11
11
  import { isResolvingMentionProvider, MentionNameStatus, SLI_EVENT_TYPE, SMART_EVENT_TYPE } from '@atlaskit/mention/resource';
12
12
  import { ComponentNames } from '@atlaskit/mention/types';
13
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
13
14
  import { fg } from '@atlaskit/platform-feature-flags';
14
15
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
15
16
  import { MentionNodeView } from '../nodeviews/mentionNodeView';
@@ -57,7 +58,7 @@ var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
57
58
  var AGENT_MENTION_INACTIVITY_MS = 3000;
58
59
  var MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
59
60
  var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
60
- var PACKAGE_VERSION = "15.0.1";
61
+ var PACKAGE_VERSION = "15.0.2";
61
62
  var setProvider = function setProvider(provider) {
62
63
  return function (state, dispatch) {
63
64
  if (dispatch) {
@@ -343,10 +344,6 @@ export function createMentionPlugin(_ref2) {
343
344
  options = _ref2.options,
344
345
  api = _ref2.api;
345
346
  var mentionProvider;
346
-
347
- // Injected by Rovo-aware consumers only. Non-Rovo consumers omit this field
348
- // entirely so this plugin incurs zero bundle cost from rovo-experience-api.
349
- var getIsRovoPanelOpen = options === null || options === void 0 ? void 0 : options.getIsRovoPanelOpen;
350
347
  var sendAnalytics = function sendAnalytics(event, actionSubject, action, attributes) {
351
348
  if (event === SLI_EVENT_TYPE || event === SMART_EVENT_TYPE) {
352
349
  fireEvent({
@@ -379,7 +376,6 @@ export function createMentionPlugin(_ref2) {
379
376
  params = _ref3.params;
380
377
  var hasPublicPluginStateChanged = false;
381
378
  var newPluginState = pluginState;
382
- var isAgentMentionsExperimentEnabled = editorExperiment('platform_editor_agent_mentions', true);
383
379
  var hasPositionChanged = oldState.selection.from !== newState.selection.from || oldState.selection.to !== newState.selection.to;
384
380
  if (tr.docChanged || tr.selectionSet && hasPositionChanged) {
385
381
  newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
@@ -388,75 +384,79 @@ export function createMentionPlugin(_ref2) {
388
384
  hasPublicPluginStateChanged = true;
389
385
  }
390
386
  switch (action) {
391
- case ACTIONS.COMMIT_PENDING_TYPED_AGENT_MENTION:
392
- {
393
- var pendingTypedAgentMention = newPluginState.pendingTypedAgentMention;
394
- // Ignore stale timer callbacks. The localId and resetCount must still match the
395
- // current pending mention so older timers cannot publish after later user edits.
396
- if (!isAgentMentionsExperimentEnabled || !pendingTypedAgentMention || pendingTypedAgentMention.localId !== (params === null || params === void 0 ? void 0 : params.localId) || pendingTypedAgentMention.resetCount !== (params === null || params === void 0 ? void 0 : params.resetCount)) {
397
- break;
398
- }
399
- var commitResult = commitPendingTypedAgentMention(newState, newPluginState, pendingTypedAgentMention);
400
- newPluginState = commitResult.pluginState;
401
- hasPublicPluginStateChanged = hasPublicPluginStateChanged || commitResult.hasPublicPluginStateChanged;
402
- break;
403
- }
404
- case ACTIONS.DISCARD_PENDING_TYPED_AGENT_MENTION:
405
- {
406
- // Silently discard the pending typed agent mention without committing it.
407
- var pendingTypedAgentMentionToDiscard = newPluginState.pendingTypedAgentMention;
408
- 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)) {
409
- break;
410
- }
411
- newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
412
- pendingTypedAgentMention: null
413
- });
414
- hasPublicPluginStateChanged = true;
415
- break;
416
- }
417
387
  case ACTIONS.SET_PROVIDER:
418
388
  newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
419
389
  mentionProvider: params.provider
420
390
  });
421
391
  hasPublicPluginStateChanged = true;
422
392
  break;
423
- case ACTIONS.RESOLVE_PASTED_AGENT_MENTION_NAME:
424
- {
425
- var _newPluginState$pendi, _newPluginState$pendi2, _newPluginState$pendi3, _newPluginState$pendi4, _newPluginState$pendi5, _newPluginState$pendi6;
426
- // Guard: only apply if there is a matching pending pasted mention (staleness check).
427
- if (!isAgentMentionsExperimentEnabled || !(params !== null && params !== void 0 && params.id) || !(params !== null && params !== void 0 && params.name) || ((_newPluginState$pendi = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi === void 0 ? void 0 : _newPluginState$pendi.id) !== params.id || !fg('platform_editor_agent_mentions_drop_one_fixes')) {
393
+ }
394
+ if (!isExperimentEnabled('platform_editor_agent_mentions_separate_pm_plugin') && editorExperiment('platform_editor_agent_mentions', true)) {
395
+ switch (action) {
396
+ case ACTIONS.COMMIT_PENDING_TYPED_AGENT_MENTION:
397
+ {
398
+ var pendingTypedAgentMention = newPluginState.pendingTypedAgentMention;
399
+ // Ignore stale timer callbacks. The localId and resetCount must still match the
400
+ // current pending mention so older timers cannot publish after later user edits.
401
+ if (!pendingTypedAgentMention || pendingTypedAgentMention.localId !== (params === null || params === void 0 ? void 0 : params.localId) || pendingTypedAgentMention.resetCount !== (params === null || params === void 0 ? void 0 : params.resetCount)) {
402
+ break;
403
+ }
404
+ var commitResult = commitPendingTypedAgentMention(newState, newPluginState, pendingTypedAgentMention);
405
+ newPluginState = commitResult.pluginState;
406
+ hasPublicPluginStateChanged = hasPublicPluginStateChanged || commitResult.hasPublicPluginStateChanged;
428
407
  break;
429
408
  }
430
- newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
431
- pendingPastedAgentMention: null,
432
- lastInsertedAgentMentionId: (_newPluginState$pendi2 = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi2 === void 0 ? void 0 : _newPluginState$pendi2.id,
433
- lastInsertedAgentMentionLocalId: (_newPluginState$pendi3 = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi3 === void 0 ? void 0 : _newPluginState$pendi3.localId,
434
- lastInsertedAgentMentionContext: (_newPluginState$pendi4 = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi4 === void 0 ? void 0 : _newPluginState$pendi4.context,
435
- lastInsertedAgentMentionName: params.name,
436
- lastInsertedAgentMentionPrompt: (_newPluginState$pendi5 = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi5 === void 0 ? void 0 : _newPluginState$pendi5.prompt,
437
- lastInsertedAgentMentionParentNodeType: (_newPluginState$pendi6 = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi6 === void 0 ? void 0 : _newPluginState$pendi6.parentNodeType
438
- });
439
- hasPublicPluginStateChanged = true;
440
- break;
441
- }
442
- case ACTIONS.CLEAR_PENDING_PASTED_AGENT_MENTION:
443
- {
444
- var _newPluginState$pendi7;
445
- if (!isAgentMentionsExperimentEnabled || !(params !== null && params !== void 0 && params.id) || ((_newPluginState$pendi7 = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi7 === void 0 ? void 0 : _newPluginState$pendi7.id) !== params.id || !fg('platform_editor_agent_mentions_drop_one_fixes')) {
409
+ case ACTIONS.DISCARD_PENDING_TYPED_AGENT_MENTION:
410
+ {
411
+ // Silently discard the pending typed agent mention without committing it.
412
+ var pendingTypedAgentMentionToDiscard = newPluginState.pendingTypedAgentMention;
413
+ if (!pendingTypedAgentMentionToDiscard || pendingTypedAgentMentionToDiscard.localId !== (params === null || params === void 0 ? void 0 : params.localId) || pendingTypedAgentMentionToDiscard.resetCount !== (params === null || params === void 0 ? void 0 : params.resetCount)) {
414
+ break;
415
+ }
416
+ newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
417
+ pendingTypedAgentMention: null
418
+ });
419
+ hasPublicPluginStateChanged = true;
446
420
  break;
447
421
  }
448
- // resolveMentionName() returned a non-OK status — clear the pending state.
449
- newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
450
- pendingPastedAgentMention: null
451
- });
452
- break;
453
- }
422
+ case ACTIONS.RESOLVE_PASTED_AGENT_MENTION_NAME:
423
+ {
424
+ var _newPluginState$pendi, _newPluginState$pendi2, _newPluginState$pendi3, _newPluginState$pendi4, _newPluginState$pendi5, _newPluginState$pendi6;
425
+ // Guard: only apply if there is a matching pending pasted mention (staleness check).
426
+ if (!(params !== null && params !== void 0 && params.id) || !(params !== null && params !== void 0 && params.name) || ((_newPluginState$pendi = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi === void 0 ? void 0 : _newPluginState$pendi.id) !== params.id || !fg('platform_editor_agent_mentions_drop_one_fixes')) {
427
+ break;
428
+ }
429
+ newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
430
+ pendingPastedAgentMention: null,
431
+ lastInsertedAgentMentionId: (_newPluginState$pendi2 = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi2 === void 0 ? void 0 : _newPluginState$pendi2.id,
432
+ lastInsertedAgentMentionLocalId: (_newPluginState$pendi3 = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi3 === void 0 ? void 0 : _newPluginState$pendi3.localId,
433
+ lastInsertedAgentMentionContext: (_newPluginState$pendi4 = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi4 === void 0 ? void 0 : _newPluginState$pendi4.context,
434
+ lastInsertedAgentMentionName: params.name,
435
+ lastInsertedAgentMentionPrompt: (_newPluginState$pendi5 = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi5 === void 0 ? void 0 : _newPluginState$pendi5.prompt,
436
+ lastInsertedAgentMentionParentNodeType: (_newPluginState$pendi6 = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi6 === void 0 ? void 0 : _newPluginState$pendi6.parentNodeType
437
+ });
438
+ hasPublicPluginStateChanged = true;
439
+ break;
440
+ }
441
+ case ACTIONS.CLEAR_PENDING_PASTED_AGENT_MENTION:
442
+ {
443
+ var _newPluginState$pendi7;
444
+ if (!(params !== null && params !== void 0 && params.id) || ((_newPluginState$pendi7 = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi7 === void 0 ? void 0 : _newPluginState$pendi7.id) !== params.id || !fg('platform_editor_agent_mentions_drop_one_fixes')) {
445
+ break;
446
+ }
447
+ // resolveMentionName() returned a non-OK status — clear the pending state.
448
+ newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
449
+ pendingPastedAgentMention: null
450
+ });
451
+ break;
452
+ }
453
+ }
454
454
  }
455
455
 
456
456
  // When the agent mentions experiment is off, dispatch immediately (original behaviour).
457
457
  // When it's on, defer dispatch to after the agent tracking block below so that
458
458
  // agent-mention state changes are included in the notification.
459
- if (hasPublicPluginStateChanged && !isAgentMentionsExperimentEnabled) {
459
+ if (hasPublicPluginStateChanged && (isExperimentEnabled('platform_editor_agent_mentions_separate_pm_plugin') || !editorExperiment('platform_editor_agent_mentions', true))) {
460
460
  pmPluginFactoryParams.dispatch(mentionPluginKey, newPluginState);
461
461
  }
462
462
  if (options !== null && options !== void 0 && options.handleMentionsChanged && tr.docChanged) {
@@ -518,7 +518,7 @@ export function createMentionPlugin(_ref2) {
518
518
  }
519
519
  (_insm$session2 = insm.session) === null || _insm$session2 === void 0 || _insm$session2.endFeature('mentionDeletionDetection');
520
520
  }
521
- if (isAgentMentionsExperimentEnabled && isQualifyingLocalUserDocChange(tr)) {
521
+ if (!isExperimentEnabled('platform_editor_agent_mentions_separate_pm_plugin') && editorExperiment('platform_editor_agent_mentions', true) && isQualifyingLocalUserDocChange(tr)) {
522
522
  var _mentionSchema = newState.schema.nodes.mention;
523
523
  var newDocRanges = [];
524
524
  var oldDocRanges = [];
@@ -712,10 +712,11 @@ export function createMentionPlugin(_ref2) {
712
712
  } : {});
713
713
  hasPublicPluginStateChanged = true;
714
714
  } 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) {
715
+ var _options$getIsRovoPan;
715
716
  // Suppress the nudge for pasted/non-typed agent mentions when Rovo is already
716
717
  // open.
717
718
  var isTaskItemMentionForPaste = agentMentionParentNodeType === 'taskItem';
718
- if (!isTaskItemMentionForPaste && isNewInsertion && getIsRovoPanelOpen !== null && getIsRovoPanelOpen !== void 0 && getIsRovoPanelOpen()) {
719
+ if (!isTaskItemMentionForPaste && isNewInsertion && options !== null && options !== void 0 && (_options$getIsRovoPan = options.getIsRovoPanelOpen) !== null && _options$getIsRovoPan !== void 0 && _options$getIsRovoPan.call(options)) {
719
720
  // Rovo is already open — skip setting lastInsertedAgentMention* so the
720
721
  // downstream nudge listener never fires.
721
722
  } else if (agentMentionName === null && agentMentionId !== null && isResolvingMentionProvider(newPluginState.mentionProvider) && fg('platform_editor_agent_mentions_drop_one_fixes')) {
@@ -749,51 +750,53 @@ export function createMentionPlugin(_ref2) {
749
750
  }
750
751
  }
751
752
  }
752
- if (isAgentMentionsExperimentEnabled && tr.docChanged && tr.getMeta('replaceDocument') && hasTrackedAgentMentionState(newPluginState)) {
753
+ if (!isExperimentEnabled('platform_editor_agent_mentions_separate_pm_plugin') && editorExperiment('platform_editor_agent_mentions', true) && tr.docChanged && tr.getMeta('replaceDocument') && hasTrackedAgentMentionState(newPluginState)) {
753
754
  newPluginState = clearTrackedAgentMentionState(newPluginState);
754
755
  hasPublicPluginStateChanged = true;
755
756
  }
756
- if (isAgentMentionsExperimentEnabled && newPluginState.pendingTypedAgentMention && action !== ACTIONS.SET_PENDING_TYPED_AGENT_MENTION && action !== ACTIONS.COMMIT_PENDING_TYPED_AGENT_MENTION && tr.docChanged) {
757
+ if (!isExperimentEnabled('platform_editor_agent_mentions_separate_pm_plugin') && editorExperiment('platform_editor_agent_mentions', true) && newPluginState.pendingTypedAgentMention && action !== ACTIONS.SET_PENDING_TYPED_AGENT_MENTION && action !== ACTIONS.COMMIT_PENDING_TYPED_AGENT_MENTION && tr.docChanged) {
757
758
  newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
758
759
  pendingTypedAgentMention: getPendingTypedAgentMentionAfterDocChange(newState, tr, newPluginState.pendingTypedAgentMention, {
759
760
  resetTimer: isQualifyingLocalUserDocChange(tr)
760
761
  })
761
762
  });
762
763
  }
763
-
764
- // Typed agent mentions stay pending while the user is still editing around them,
765
- // but leaving the mention's direct parent means they have moved on from that
766
- // paragraph/block. Publish immediately in that case instead of waiting for the
767
- // inactivity timer.
768
- var shouldCheckPendingTypedAgentMentionParent = isLocalSelectionChange(tr, hasPositionChanged);
769
- if (isAgentMentionsExperimentEnabled && newPluginState.pendingTypedAgentMention && action !== ACTIONS.SET_PENDING_TYPED_AGENT_MENTION && action !== ACTIONS.COMMIT_PENDING_TYPED_AGENT_MENTION && shouldCheckPendingTypedAgentMentionParent) {
770
- var _pendingTypedAgentMention = newPluginState.pendingTypedAgentMention;
771
- var pendingMentionDetails = getAgentMentionDetailsAtPos(newState, _pendingTypedAgentMention.pos, function (attrs) {
772
- return attrs.localId === _pendingTypedAgentMention.localId;
773
- }, _pendingTypedAgentMention.name);
774
- if (!pendingMentionDetails) {
775
- newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
776
- pendingTypedAgentMention: null
777
- });
778
- } else if (hasPendingMentionMovedToNewParent(oldState, tr, pluginState.pendingTypedAgentMention, pendingMentionDetails) || isSelectionOutsideDirectParent(newState, pendingMentionDetails)) {
779
- // Suppress the nudge when Rovo chat is already open, mirroring the same
780
- // guard used in the inactivity-timer path. Task-item mentions are
781
- // exempt because they auto-fire the mini modal and never show a nudge.
782
- if (pendingMentionDetails.parentNodeType !== 'taskItem' && getIsRovoPanelOpen !== null && getIsRovoPanelOpen !== void 0 && getIsRovoPanelOpen()) {
783
- // Discard without committing so lastInsertedAgentMention* fields are
784
- // never set and the downstream nudge listener never fires.
764
+ if (!isExperimentEnabled('platform_editor_agent_mentions_separate_pm_plugin') && editorExperiment('platform_editor_agent_mentions', true)) {
765
+ // Typed agent mentions stay pending while the user is still editing around them,
766
+ // but leaving the mention's direct parent means they have moved on from that
767
+ // paragraph/block. Publish immediately in that case instead of waiting for the
768
+ // inactivity timer.
769
+ var shouldCheckPendingTypedAgentMentionParent = isLocalSelectionChange(tr, hasPositionChanged);
770
+ if (newPluginState.pendingTypedAgentMention && action !== ACTIONS.SET_PENDING_TYPED_AGENT_MENTION && action !== ACTIONS.COMMIT_PENDING_TYPED_AGENT_MENTION && shouldCheckPendingTypedAgentMentionParent) {
771
+ var _pendingTypedAgentMention = newPluginState.pendingTypedAgentMention;
772
+ var pendingMentionDetails = getAgentMentionDetailsAtPos(newState, _pendingTypedAgentMention.pos, function (attrs) {
773
+ return attrs.localId === _pendingTypedAgentMention.localId;
774
+ }, _pendingTypedAgentMention.name);
775
+ if (!pendingMentionDetails) {
785
776
  newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
786
777
  pendingTypedAgentMention: null
787
778
  });
788
- hasPublicPluginStateChanged = true;
789
- } else {
790
- var _commitResult = commitResolvedPendingTypedAgentMention(newPluginState, pendingMentionDetails);
791
- newPluginState = _commitResult.pluginState;
792
- hasPublicPluginStateChanged = hasPublicPluginStateChanged || _commitResult.hasPublicPluginStateChanged;
779
+ } else if (hasPendingMentionMovedToNewParent(oldState, tr, pluginState.pendingTypedAgentMention, pendingMentionDetails) || isSelectionOutsideDirectParent(newState, pendingMentionDetails)) {
780
+ var _options$getIsRovoPan2;
781
+ // Suppress the nudge when Rovo chat is already open, mirroring the same
782
+ // guard used in the inactivity-timer path. Task-item mentions are
783
+ // exempt because they auto-fire the mini modal and never show a nudge.
784
+ if (pendingMentionDetails.parentNodeType !== 'taskItem' && options !== null && options !== void 0 && (_options$getIsRovoPan2 = options.getIsRovoPanelOpen) !== null && _options$getIsRovoPan2 !== void 0 && _options$getIsRovoPan2.call(options)) {
785
+ // Discard without committing so lastInsertedAgentMention* fields are
786
+ // never set and the downstream nudge listener never fires.
787
+ newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
788
+ pendingTypedAgentMention: null
789
+ });
790
+ hasPublicPluginStateChanged = true;
791
+ } else {
792
+ var _commitResult = commitResolvedPendingTypedAgentMention(newPluginState, pendingMentionDetails);
793
+ newPluginState = _commitResult.pluginState;
794
+ hasPublicPluginStateChanged = hasPublicPluginStateChanged || _commitResult.hasPublicPluginStateChanged;
795
+ }
793
796
  }
794
797
  }
795
798
  }
796
- if (hasPublicPluginStateChanged && isAgentMentionsExperimentEnabled) {
799
+ if (hasPublicPluginStateChanged && !isExperimentEnabled('platform_editor_agent_mentions_separate_pm_plugin') && editorExperiment('platform_editor_agent_mentions', true)) {
797
800
  pmPluginFactoryParams.dispatch(mentionPluginKey, newPluginState);
798
801
  }
799
802
  return newPluginState;
@@ -812,7 +815,6 @@ export function createMentionPlugin(_ref2) {
812
815
  }
813
816
  },
814
817
  view: function view(editorView) {
815
- var isAgentMentionsEnabled = editorExperiment('platform_editor_agent_mentions', true);
816
818
  var pendingTypedAgentMentionTimer;
817
819
  var pendingTypedAgentMentionTimerKey = null;
818
820
  var pendingTypedAgentMentionFocusDeferCount = 0;
@@ -859,7 +861,7 @@ export function createMentionPlugin(_ref2) {
859
861
  var _ref5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
860
862
  _ref5$preserveFocusDe = _ref5.preserveFocusDeferCount,
861
863
  preserveFocusDeferCount = _ref5$preserveFocusDe === void 0 ? false : _ref5$preserveFocusDe;
862
- if (!isAgentMentionsEnabled) {
864
+ if (isExperimentEnabled('platform_editor_agent_mentions_separate_pm_plugin') || !editorExperiment('platform_editor_agent_mentions', true)) {
863
865
  clearPendingTypedAgentMentionTimer();
864
866
  return;
865
867
  }
@@ -879,10 +881,11 @@ export function createMentionPlugin(_ref2) {
879
881
  pendingTypedAgentMentionTimer = setTimeout(function () {
880
882
  var _mentionPluginKey$get;
881
883
  {
884
+ var _options$getIsRovoPan3;
882
885
  // Suppress the agent-mention nudge when the Rovo panel is already open,
883
886
  // but only for non-task-item mentions.
884
887
  var isTaskItemMention = pendingTypedAgentMention.parentNodeType === 'taskItem';
885
- if (!isTaskItemMention && getIsRovoPanelOpen !== null && getIsRovoPanelOpen !== void 0 && getIsRovoPanelOpen()) {
888
+ if (!isTaskItemMention && options !== null && options !== void 0 && (_options$getIsRovoPan3 = options.getIsRovoPanelOpen) !== null && _options$getIsRovoPan3 !== void 0 && _options$getIsRovoPan3.call(options)) {
886
889
  // Dispatch a discard so pendingTypedAgentMention is nulled out of plugin
887
890
  // state.
888
891
  editorView.dispatch(editorView.state.tr.setMeta(mentionPluginKey, {
@@ -963,18 +966,20 @@ export function createMentionPlugin(_ref2) {
963
966
  }
964
967
  return {
965
968
  update: function update(view, prevState) {
966
- var _mentionPluginState$p;
967
969
  var mentionPluginState = mentionPluginKey.getState(view.state);
968
970
  if (mentionPluginState === mentionPluginKey.getState(prevState)) {
969
971
  return;
970
972
  }
971
- _schedulePendingTypedAgentMentionTimer(mentionPluginState);
973
+ if (!isExperimentEnabled('platform_editor_agent_mentions_separate_pm_plugin')) {
974
+ var _mentionPluginState$p;
975
+ _schedulePendingTypedAgentMentionTimer(mentionPluginState);
972
976
 
973
- // If a pasted agent mention has no name (cache miss), resolve it async
974
- // via the mention provider and dispatch RESOLVE_PASTED_AGENT_MENTION_NAME
975
- // so the nudge displays the correct name.
976
- if (editorExperiment('platform_editor_agent_mentions', true) && (mentionPluginState === null || mentionPluginState === void 0 || (_mentionPluginState$p = mentionPluginState.pendingPastedAgentMention) === null || _mentionPluginState$p === void 0 ? void 0 : _mentionPluginState$p.id) != null && mentionPluginState !== null && mentionPluginState !== void 0 && mentionPluginState.mentionProvider && isResolvingMentionProvider(mentionPluginState.mentionProvider) && fg('platform_editor_agent_mentions_drop_one_fixes')) {
977
- resolveAndDispatchPastedAgentMentionName(mentionPluginState.pendingPastedAgentMention.id, mentionPluginState.mentionProvider, pendingResolveMentionIds, view);
977
+ // If a pasted agent mention has no name (cache miss), resolve it async
978
+ // via the mention provider and dispatch RESOLVE_PASTED_AGENT_MENTION_NAME
979
+ // so the nudge displays the correct name.
980
+ if (editorExperiment('platform_editor_agent_mentions', true) && (mentionPluginState === null || mentionPluginState === void 0 || (_mentionPluginState$p = mentionPluginState.pendingPastedAgentMention) === null || _mentionPluginState$p === void 0 ? void 0 : _mentionPluginState$p.id) != null && mentionPluginState !== null && mentionPluginState !== void 0 && mentionPluginState.mentionProvider && isResolvingMentionProvider(mentionPluginState.mentionProvider) && fg('platform_editor_agent_mentions_drop_one_fixes')) {
981
+ resolveAndDispatchPastedAgentMentionName(mentionPluginState.pendingPastedAgentMention.id, mentionPluginState.mentionProvider, pendingResolveMentionIds, view);
982
+ }
978
983
  }
979
984
  },
980
985
  destroy: function destroy() {
@@ -0,0 +1,40 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import type { PMPluginFactoryParams } from '@atlaskit/editor-common/types';
3
+ import type { EditorState, ReadonlyTransaction } from '@atlaskit/editor-prosemirror/state';
4
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
5
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { ResolvingMentionProvider } from '@atlaskit/mention/resource';
7
+ import type { MentionPluginOptions, MentionPluginState } from '../types';
8
+ /**
9
+ * Resolves the name of a pasted agent mention via the mention provider and
10
+ * dispatches the appropriate action to update plugin state.
11
+ */
12
+ export declare const resolveAndDispatchPastedAgentMentionName: (agentId: string, mentionProvider: ResolvingMentionProvider, pendingResolveMentionIds: Set<string>, view: EditorView) => void;
13
+ type ApplyAgentMentionStateParams = {
14
+ getIsRovoPanelOpen?: () => boolean;
15
+ newState: EditorState;
16
+ oldState: EditorState;
17
+ pluginState: MentionPluginState;
18
+ tr: ReadonlyTransaction;
19
+ };
20
+ export declare const applyAgentMentionState: ({ tr, pluginState, oldState, newState, getIsRovoPanelOpen, }: ApplyAgentMentionStateParams) => {
21
+ hasPublicPluginStateChanged: boolean;
22
+ pluginState: MentionPluginState;
23
+ };
24
+ type CreateAgentMentionPluginViewParams = {
25
+ editorView: EditorView;
26
+ getIsRovoPanelOpen?: () => boolean;
27
+ stateKey: PluginKey<MentionPluginState>;
28
+ };
29
+ type AgentMentionPluginView = {
30
+ destroy: () => void;
31
+ update: (view: EditorView, prevState: EditorState) => void;
32
+ };
33
+ export declare const createAgentMentionPluginView: ({ editorView, getIsRovoPanelOpen, stateKey, }: CreateAgentMentionPluginViewParams) => AgentMentionPluginView;
34
+ export declare const agentMentionPluginKey: PluginKey<MentionPluginState>;
35
+ type CreateAgentMentionPluginParams = {
36
+ options?: MentionPluginOptions;
37
+ pmPluginFactoryParams: PMPluginFactoryParams;
38
+ };
39
+ export declare const createAgentMentionPlugin: ({ options, pmPluginFactoryParams, }: CreateAgentMentionPluginParams) => SafePlugin<MentionPluginState>;
40
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-mentions",
3
- "version": "15.0.2",
3
+ "version": "15.0.3",
4
4
  "description": "Mentions plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -30,7 +30,7 @@
30
30
  "@atlaskit/editor-plugin-type-ahead": "^14.0.0",
31
31
  "@atlaskit/editor-prosemirror": "^8.0.0",
32
32
  "@atlaskit/feature-gate-js-client": "^6.0.0",
33
- "@atlaskit/icon": "^37.2.0",
33
+ "@atlaskit/icon": "^37.3.0",
34
34
  "@atlaskit/insm": "^1.2.0",
35
35
  "@atlaskit/link": "^5.0.0",
36
36
  "@atlaskit/lozenge": "^15.0.0",
@@ -38,10 +38,10 @@
38
38
  "@atlaskit/platform-feature-experiments": "^0.3.0",
39
39
  "@atlaskit/platform-feature-flags": "^2.1.0",
40
40
  "@atlaskit/popper": "^9.0.0",
41
- "@atlaskit/portal": "^6.1.0",
41
+ "@atlaskit/portal": "^6.2.0",
42
42
  "@atlaskit/primitives": "^22.2.0",
43
- "@atlaskit/profilecard": "^26.14.0",
44
- "@atlaskit/teams-app-config": "^2.1.0",
43
+ "@atlaskit/profilecard": "^26.15.0",
44
+ "@atlaskit/teams-app-config": "^2.2.0",
45
45
  "@atlaskit/theme": "^26.1.0",
46
46
  "@atlaskit/tmp-editor-statsig": "^139.0.0",
47
47
  "@atlaskit/tokens": "^16.3.0",
@@ -55,7 +55,7 @@
55
55
  "uuid": "^3.1.0"
56
56
  },
57
57
  "peerDependencies": {
58
- "@atlaskit/editor-common": "^117.0.0",
58
+ "@atlaskit/editor-common": "^117.2.0",
59
59
  "react": "^18.2.0 || ^19.2.0",
60
60
  "react-dom": "^18.2.0 || ^19.2.0",
61
61
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"