@atlaskit/editor-plugin-mentions 15.0.2 → 15.0.4

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.
@@ -14,6 +14,7 @@ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
14
14
  var _insm = require("@atlaskit/insm");
15
15
  var _resource = require("@atlaskit/mention/resource");
16
16
  var _types = require("@atlaskit/mention/types");
17
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
17
18
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
18
19
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
19
20
  var _mentionNodeView = require("../nodeviews/mentionNodeView");
@@ -66,7 +67,7 @@ var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
66
67
  var AGENT_MENTION_INACTIVITY_MS = 3000;
67
68
  var MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
68
69
  var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
69
- var PACKAGE_VERSION = "15.0.1";
70
+ var PACKAGE_VERSION = "15.0.3";
70
71
  var setProvider = function setProvider(provider) {
71
72
  return function (state, dispatch) {
72
73
  if (dispatch) {
@@ -352,10 +353,6 @@ function createMentionPlugin(_ref2) {
352
353
  options = _ref2.options,
353
354
  api = _ref2.api;
354
355
  var mentionProvider;
355
-
356
- // Injected by Rovo-aware consumers only. Non-Rovo consumers omit this field
357
- // entirely so this plugin incurs zero bundle cost from rovo-experience-api.
358
- var getIsRovoPanelOpen = options === null || options === void 0 ? void 0 : options.getIsRovoPanelOpen;
359
356
  var sendAnalytics = function sendAnalytics(event, actionSubject, action, attributes) {
360
357
  if (event === _resource.SLI_EVENT_TYPE || event === _resource.SMART_EVENT_TYPE) {
361
358
  fireEvent({
@@ -388,7 +385,6 @@ function createMentionPlugin(_ref2) {
388
385
  params = _ref3.params;
389
386
  var hasPublicPluginStateChanged = false;
390
387
  var newPluginState = pluginState;
391
- var isAgentMentionsExperimentEnabled = (0, _experiments.editorExperiment)('platform_editor_agent_mentions', true);
392
388
  var hasPositionChanged = oldState.selection.from !== newState.selection.from || oldState.selection.to !== newState.selection.to;
393
389
  if (tr.docChanged || tr.selectionSet && hasPositionChanged) {
394
390
  newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
@@ -397,75 +393,79 @@ function createMentionPlugin(_ref2) {
397
393
  hasPublicPluginStateChanged = true;
398
394
  }
399
395
  switch (action) {
400
- case ACTIONS.COMMIT_PENDING_TYPED_AGENT_MENTION:
401
- {
402
- var pendingTypedAgentMention = newPluginState.pendingTypedAgentMention;
403
- // Ignore stale timer callbacks. The localId and resetCount must still match the
404
- // current pending mention so older timers cannot publish after later user edits.
405
- 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)) {
406
- break;
407
- }
408
- var commitResult = commitPendingTypedAgentMention(newState, newPluginState, pendingTypedAgentMention);
409
- newPluginState = commitResult.pluginState;
410
- hasPublicPluginStateChanged = hasPublicPluginStateChanged || commitResult.hasPublicPluginStateChanged;
411
- break;
412
- }
413
- case ACTIONS.DISCARD_PENDING_TYPED_AGENT_MENTION:
414
- {
415
- // Silently discard the pending typed agent mention without committing it.
416
- var pendingTypedAgentMentionToDiscard = newPluginState.pendingTypedAgentMention;
417
- 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)) {
418
- break;
419
- }
420
- newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
421
- pendingTypedAgentMention: null
422
- });
423
- hasPublicPluginStateChanged = true;
424
- break;
425
- }
426
396
  case ACTIONS.SET_PROVIDER:
427
397
  newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
428
398
  mentionProvider: params.provider
429
399
  });
430
400
  hasPublicPluginStateChanged = true;
431
401
  break;
432
- case ACTIONS.RESOLVE_PASTED_AGENT_MENTION_NAME:
433
- {
434
- var _newPluginState$pendi, _newPluginState$pendi2, _newPluginState$pendi3, _newPluginState$pendi4, _newPluginState$pendi5, _newPluginState$pendi6;
435
- // Guard: only apply if there is a matching pending pasted mention (staleness check).
436
- 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 || !(0, _platformFeatureFlags.fg)('platform_editor_agent_mentions_drop_one_fixes')) {
402
+ }
403
+ if (!(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_agent_mentions_separate_pm_plugin') && (0, _experiments.editorExperiment)('platform_editor_agent_mentions', true)) {
404
+ switch (action) {
405
+ case ACTIONS.COMMIT_PENDING_TYPED_AGENT_MENTION:
406
+ {
407
+ var pendingTypedAgentMention = newPluginState.pendingTypedAgentMention;
408
+ // Ignore stale timer callbacks. The localId and resetCount must still match the
409
+ // current pending mention so older timers cannot publish after later user edits.
410
+ if (!pendingTypedAgentMention || pendingTypedAgentMention.localId !== (params === null || params === void 0 ? void 0 : params.localId) || pendingTypedAgentMention.resetCount !== (params === null || params === void 0 ? void 0 : params.resetCount)) {
411
+ break;
412
+ }
413
+ var commitResult = commitPendingTypedAgentMention(newState, newPluginState, pendingTypedAgentMention);
414
+ newPluginState = commitResult.pluginState;
415
+ hasPublicPluginStateChanged = hasPublicPluginStateChanged || commitResult.hasPublicPluginStateChanged;
437
416
  break;
438
417
  }
439
- newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
440
- pendingPastedAgentMention: null,
441
- lastInsertedAgentMentionId: (_newPluginState$pendi2 = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi2 === void 0 ? void 0 : _newPluginState$pendi2.id,
442
- lastInsertedAgentMentionLocalId: (_newPluginState$pendi3 = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi3 === void 0 ? void 0 : _newPluginState$pendi3.localId,
443
- lastInsertedAgentMentionContext: (_newPluginState$pendi4 = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi4 === void 0 ? void 0 : _newPluginState$pendi4.context,
444
- lastInsertedAgentMentionName: params.name,
445
- lastInsertedAgentMentionPrompt: (_newPluginState$pendi5 = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi5 === void 0 ? void 0 : _newPluginState$pendi5.prompt,
446
- lastInsertedAgentMentionParentNodeType: (_newPluginState$pendi6 = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi6 === void 0 ? void 0 : _newPluginState$pendi6.parentNodeType
447
- });
448
- hasPublicPluginStateChanged = true;
449
- break;
450
- }
451
- case ACTIONS.CLEAR_PENDING_PASTED_AGENT_MENTION:
452
- {
453
- var _newPluginState$pendi7;
454
- 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 || !(0, _platformFeatureFlags.fg)('platform_editor_agent_mentions_drop_one_fixes')) {
418
+ case ACTIONS.DISCARD_PENDING_TYPED_AGENT_MENTION:
419
+ {
420
+ // Silently discard the pending typed agent mention without committing it.
421
+ var pendingTypedAgentMentionToDiscard = newPluginState.pendingTypedAgentMention;
422
+ if (!pendingTypedAgentMentionToDiscard || pendingTypedAgentMentionToDiscard.localId !== (params === null || params === void 0 ? void 0 : params.localId) || pendingTypedAgentMentionToDiscard.resetCount !== (params === null || params === void 0 ? void 0 : params.resetCount)) {
423
+ break;
424
+ }
425
+ newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
426
+ pendingTypedAgentMention: null
427
+ });
428
+ hasPublicPluginStateChanged = true;
455
429
  break;
456
430
  }
457
- // resolveMentionName() returned a non-OK status — clear the pending state.
458
- newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
459
- pendingPastedAgentMention: null
460
- });
461
- break;
462
- }
431
+ case ACTIONS.RESOLVE_PASTED_AGENT_MENTION_NAME:
432
+ {
433
+ var _newPluginState$pendi, _newPluginState$pendi2, _newPluginState$pendi3, _newPluginState$pendi4, _newPluginState$pendi5, _newPluginState$pendi6;
434
+ // Guard: only apply if there is a matching pending pasted mention (staleness check).
435
+ 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 || !(0, _platformFeatureFlags.fg)('platform_editor_agent_mentions_drop_one_fixes')) {
436
+ break;
437
+ }
438
+ newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
439
+ pendingPastedAgentMention: null,
440
+ lastInsertedAgentMentionId: (_newPluginState$pendi2 = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi2 === void 0 ? void 0 : _newPluginState$pendi2.id,
441
+ lastInsertedAgentMentionLocalId: (_newPluginState$pendi3 = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi3 === void 0 ? void 0 : _newPluginState$pendi3.localId,
442
+ lastInsertedAgentMentionContext: (_newPluginState$pendi4 = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi4 === void 0 ? void 0 : _newPluginState$pendi4.context,
443
+ lastInsertedAgentMentionName: params.name,
444
+ lastInsertedAgentMentionPrompt: (_newPluginState$pendi5 = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi5 === void 0 ? void 0 : _newPluginState$pendi5.prompt,
445
+ lastInsertedAgentMentionParentNodeType: (_newPluginState$pendi6 = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi6 === void 0 ? void 0 : _newPluginState$pendi6.parentNodeType
446
+ });
447
+ hasPublicPluginStateChanged = true;
448
+ break;
449
+ }
450
+ case ACTIONS.CLEAR_PENDING_PASTED_AGENT_MENTION:
451
+ {
452
+ var _newPluginState$pendi7;
453
+ if (!(params !== null && params !== void 0 && params.id) || ((_newPluginState$pendi7 = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi7 === void 0 ? void 0 : _newPluginState$pendi7.id) !== params.id || !(0, _platformFeatureFlags.fg)('platform_editor_agent_mentions_drop_one_fixes')) {
454
+ break;
455
+ }
456
+ // resolveMentionName() returned a non-OK status — clear the pending state.
457
+ newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
458
+ pendingPastedAgentMention: null
459
+ });
460
+ break;
461
+ }
462
+ }
463
463
  }
464
464
 
465
465
  // When the agent mentions experiment is off, dispatch immediately (original behaviour).
466
466
  // When it's on, defer dispatch to after the agent tracking block below so that
467
467
  // agent-mention state changes are included in the notification.
468
- if (hasPublicPluginStateChanged && !isAgentMentionsExperimentEnabled) {
468
+ if (hasPublicPluginStateChanged && ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_agent_mentions_separate_pm_plugin') || !(0, _experiments.editorExperiment)('platform_editor_agent_mentions', true))) {
469
469
  pmPluginFactoryParams.dispatch(_key.mentionPluginKey, newPluginState);
470
470
  }
471
471
  if (options !== null && options !== void 0 && options.handleMentionsChanged && tr.docChanged) {
@@ -527,7 +527,7 @@ function createMentionPlugin(_ref2) {
527
527
  }
528
528
  (_insm$session2 = _insm.insm.session) === null || _insm$session2 === void 0 || _insm$session2.endFeature('mentionDeletionDetection');
529
529
  }
530
- if (isAgentMentionsExperimentEnabled && isQualifyingLocalUserDocChange(tr)) {
530
+ if (!(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_agent_mentions_separate_pm_plugin') && (0, _experiments.editorExperiment)('platform_editor_agent_mentions', true) && isQualifyingLocalUserDocChange(tr)) {
531
531
  var _mentionSchema = newState.schema.nodes.mention;
532
532
  var newDocRanges = [];
533
533
  var oldDocRanges = [];
@@ -721,10 +721,11 @@ function createMentionPlugin(_ref2) {
721
721
  } : {});
722
722
  hasPublicPluginStateChanged = true;
723
723
  } 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) {
724
+ var _options$getIsRovoPan;
724
725
  // Suppress the nudge for pasted/non-typed agent mentions when Rovo is already
725
726
  // open.
726
727
  var isTaskItemMentionForPaste = agentMentionParentNodeType === 'taskItem';
727
- if (!isTaskItemMentionForPaste && isNewInsertion && getIsRovoPanelOpen !== null && getIsRovoPanelOpen !== void 0 && getIsRovoPanelOpen()) {
728
+ if (!isTaskItemMentionForPaste && isNewInsertion && options !== null && options !== void 0 && (_options$getIsRovoPan = options.getIsRovoPanelOpen) !== null && _options$getIsRovoPan !== void 0 && _options$getIsRovoPan.call(options)) {
728
729
  // Rovo is already open — skip setting lastInsertedAgentMention* so the
729
730
  // downstream nudge listener never fires.
730
731
  } else if (agentMentionName === null && agentMentionId !== null && (0, _resource.isResolvingMentionProvider)(newPluginState.mentionProvider) && (0, _platformFeatureFlags.fg)('platform_editor_agent_mentions_drop_one_fixes')) {
@@ -758,51 +759,53 @@ function createMentionPlugin(_ref2) {
758
759
  }
759
760
  }
760
761
  }
761
- if (isAgentMentionsExperimentEnabled && tr.docChanged && tr.getMeta('replaceDocument') && hasTrackedAgentMentionState(newPluginState)) {
762
+ if (!(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_agent_mentions_separate_pm_plugin') && (0, _experiments.editorExperiment)('platform_editor_agent_mentions', true) && tr.docChanged && tr.getMeta('replaceDocument') && hasTrackedAgentMentionState(newPluginState)) {
762
763
  newPluginState = clearTrackedAgentMentionState(newPluginState);
763
764
  hasPublicPluginStateChanged = true;
764
765
  }
765
- if (isAgentMentionsExperimentEnabled && newPluginState.pendingTypedAgentMention && action !== ACTIONS.SET_PENDING_TYPED_AGENT_MENTION && action !== ACTIONS.COMMIT_PENDING_TYPED_AGENT_MENTION && tr.docChanged) {
766
+ if (!(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_agent_mentions_separate_pm_plugin') && (0, _experiments.editorExperiment)('platform_editor_agent_mentions', true) && newPluginState.pendingTypedAgentMention && action !== ACTIONS.SET_PENDING_TYPED_AGENT_MENTION && action !== ACTIONS.COMMIT_PENDING_TYPED_AGENT_MENTION && tr.docChanged) {
766
767
  newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
767
768
  pendingTypedAgentMention: getPendingTypedAgentMentionAfterDocChange(newState, tr, newPluginState.pendingTypedAgentMention, {
768
769
  resetTimer: isQualifyingLocalUserDocChange(tr)
769
770
  })
770
771
  });
771
772
  }
772
-
773
- // Typed agent mentions stay pending while the user is still editing around them,
774
- // but leaving the mention's direct parent means they have moved on from that
775
- // paragraph/block. Publish immediately in that case instead of waiting for the
776
- // inactivity timer.
777
- var shouldCheckPendingTypedAgentMentionParent = isLocalSelectionChange(tr, hasPositionChanged);
778
- if (isAgentMentionsExperimentEnabled && newPluginState.pendingTypedAgentMention && action !== ACTIONS.SET_PENDING_TYPED_AGENT_MENTION && action !== ACTIONS.COMMIT_PENDING_TYPED_AGENT_MENTION && shouldCheckPendingTypedAgentMentionParent) {
779
- var _pendingTypedAgentMention = newPluginState.pendingTypedAgentMention;
780
- var pendingMentionDetails = getAgentMentionDetailsAtPos(newState, _pendingTypedAgentMention.pos, function (attrs) {
781
- return attrs.localId === _pendingTypedAgentMention.localId;
782
- }, _pendingTypedAgentMention.name);
783
- if (!pendingMentionDetails) {
784
- newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
785
- pendingTypedAgentMention: null
786
- });
787
- } else if (hasPendingMentionMovedToNewParent(oldState, tr, pluginState.pendingTypedAgentMention, pendingMentionDetails) || isSelectionOutsideDirectParent(newState, pendingMentionDetails)) {
788
- // Suppress the nudge when Rovo chat is already open, mirroring the same
789
- // guard used in the inactivity-timer path. Task-item mentions are
790
- // exempt because they auto-fire the mini modal and never show a nudge.
791
- if (pendingMentionDetails.parentNodeType !== 'taskItem' && getIsRovoPanelOpen !== null && getIsRovoPanelOpen !== void 0 && getIsRovoPanelOpen()) {
792
- // Discard without committing so lastInsertedAgentMention* fields are
793
- // never set and the downstream nudge listener never fires.
773
+ if (!(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_agent_mentions_separate_pm_plugin') && (0, _experiments.editorExperiment)('platform_editor_agent_mentions', true)) {
774
+ // Typed agent mentions stay pending while the user is still editing around them,
775
+ // but leaving the mention's direct parent means they have moved on from that
776
+ // paragraph/block. Publish immediately in that case instead of waiting for the
777
+ // inactivity timer.
778
+ var shouldCheckPendingTypedAgentMentionParent = isLocalSelectionChange(tr, hasPositionChanged);
779
+ if (newPluginState.pendingTypedAgentMention && action !== ACTIONS.SET_PENDING_TYPED_AGENT_MENTION && action !== ACTIONS.COMMIT_PENDING_TYPED_AGENT_MENTION && shouldCheckPendingTypedAgentMentionParent) {
780
+ var _pendingTypedAgentMention = newPluginState.pendingTypedAgentMention;
781
+ var pendingMentionDetails = getAgentMentionDetailsAtPos(newState, _pendingTypedAgentMention.pos, function (attrs) {
782
+ return attrs.localId === _pendingTypedAgentMention.localId;
783
+ }, _pendingTypedAgentMention.name);
784
+ if (!pendingMentionDetails) {
794
785
  newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
795
786
  pendingTypedAgentMention: null
796
787
  });
797
- hasPublicPluginStateChanged = true;
798
- } else {
799
- var _commitResult = commitResolvedPendingTypedAgentMention(newPluginState, pendingMentionDetails);
800
- newPluginState = _commitResult.pluginState;
801
- hasPublicPluginStateChanged = hasPublicPluginStateChanged || _commitResult.hasPublicPluginStateChanged;
788
+ } else if (hasPendingMentionMovedToNewParent(oldState, tr, pluginState.pendingTypedAgentMention, pendingMentionDetails) || isSelectionOutsideDirectParent(newState, pendingMentionDetails)) {
789
+ var _options$getIsRovoPan2;
790
+ // Suppress the nudge when Rovo chat is already open, mirroring the same
791
+ // guard used in the inactivity-timer path. Task-item mentions are
792
+ // exempt because they auto-fire the mini modal and never show a nudge.
793
+ if (pendingMentionDetails.parentNodeType !== 'taskItem' && options !== null && options !== void 0 && (_options$getIsRovoPan2 = options.getIsRovoPanelOpen) !== null && _options$getIsRovoPan2 !== void 0 && _options$getIsRovoPan2.call(options)) {
794
+ // Discard without committing so lastInsertedAgentMention* fields are
795
+ // never set and the downstream nudge listener never fires.
796
+ newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
797
+ pendingTypedAgentMention: null
798
+ });
799
+ hasPublicPluginStateChanged = true;
800
+ } else {
801
+ var _commitResult = commitResolvedPendingTypedAgentMention(newPluginState, pendingMentionDetails);
802
+ newPluginState = _commitResult.pluginState;
803
+ hasPublicPluginStateChanged = hasPublicPluginStateChanged || _commitResult.hasPublicPluginStateChanged;
804
+ }
802
805
  }
803
806
  }
804
807
  }
805
- if (hasPublicPluginStateChanged && isAgentMentionsExperimentEnabled) {
808
+ if (hasPublicPluginStateChanged && !(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_agent_mentions_separate_pm_plugin') && (0, _experiments.editorExperiment)('platform_editor_agent_mentions', true)) {
806
809
  pmPluginFactoryParams.dispatch(_key.mentionPluginKey, newPluginState);
807
810
  }
808
811
  return newPluginState;
@@ -821,7 +824,6 @@ function createMentionPlugin(_ref2) {
821
824
  }
822
825
  },
823
826
  view: function view(editorView) {
824
- var isAgentMentionsEnabled = (0, _experiments.editorExperiment)('platform_editor_agent_mentions', true);
825
827
  var pendingTypedAgentMentionTimer;
826
828
  var pendingTypedAgentMentionTimerKey = null;
827
829
  var pendingTypedAgentMentionFocusDeferCount = 0;
@@ -868,7 +870,7 @@ function createMentionPlugin(_ref2) {
868
870
  var _ref5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
869
871
  _ref5$preserveFocusDe = _ref5.preserveFocusDeferCount,
870
872
  preserveFocusDeferCount = _ref5$preserveFocusDe === void 0 ? false : _ref5$preserveFocusDe;
871
- if (!isAgentMentionsEnabled) {
873
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_agent_mentions_separate_pm_plugin') || !(0, _experiments.editorExperiment)('platform_editor_agent_mentions', true)) {
872
874
  clearPendingTypedAgentMentionTimer();
873
875
  return;
874
876
  }
@@ -888,10 +890,11 @@ function createMentionPlugin(_ref2) {
888
890
  pendingTypedAgentMentionTimer = setTimeout(function () {
889
891
  var _mentionPluginKey$get;
890
892
  {
893
+ var _options$getIsRovoPan3;
891
894
  // Suppress the agent-mention nudge when the Rovo panel is already open,
892
895
  // but only for non-task-item mentions.
893
896
  var isTaskItemMention = pendingTypedAgentMention.parentNodeType === 'taskItem';
894
- if (!isTaskItemMention && getIsRovoPanelOpen !== null && getIsRovoPanelOpen !== void 0 && getIsRovoPanelOpen()) {
897
+ if (!isTaskItemMention && options !== null && options !== void 0 && (_options$getIsRovoPan3 = options.getIsRovoPanelOpen) !== null && _options$getIsRovoPan3 !== void 0 && _options$getIsRovoPan3.call(options)) {
895
898
  // Dispatch a discard so pendingTypedAgentMention is nulled out of plugin
896
899
  // state.
897
900
  editorView.dispatch(editorView.state.tr.setMeta(_key.mentionPluginKey, {
@@ -972,18 +975,20 @@ function createMentionPlugin(_ref2) {
972
975
  }
973
976
  return {
974
977
  update: function update(view, prevState) {
975
- var _mentionPluginState$p;
976
978
  var mentionPluginState = _key.mentionPluginKey.getState(view.state);
977
979
  if (mentionPluginState === _key.mentionPluginKey.getState(prevState)) {
978
980
  return;
979
981
  }
980
- _schedulePendingTypedAgentMentionTimer(mentionPluginState);
982
+ if (!(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_agent_mentions_separate_pm_plugin')) {
983
+ var _mentionPluginState$p;
984
+ _schedulePendingTypedAgentMentionTimer(mentionPluginState);
981
985
 
982
- // If a pasted agent mention has no name (cache miss), resolve it async
983
- // via the mention provider and dispatch RESOLVE_PASTED_AGENT_MENTION_NAME
984
- // so the nudge displays the correct name.
985
- if ((0, _experiments.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 && (0, _resource.isResolvingMentionProvider)(mentionPluginState.mentionProvider) && (0, _platformFeatureFlags.fg)('platform_editor_agent_mentions_drop_one_fixes')) {
986
- resolveAndDispatchPastedAgentMentionName(mentionPluginState.pendingPastedAgentMention.id, mentionPluginState.mentionProvider, pendingResolveMentionIds, view);
986
+ // If a pasted agent mention has no name (cache miss), resolve it async
987
+ // via the mention provider and dispatch RESOLVE_PASTED_AGENT_MENTION_NAME
988
+ // so the nudge displays the correct name.
989
+ if ((0, _experiments.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 && (0, _resource.isResolvingMentionProvider)(mentionPluginState.mentionProvider) && (0, _platformFeatureFlags.fg)('platform_editor_agent_mentions_drop_one_fixes')) {
990
+ resolveAndDispatchPastedAgentMentionName(mentionPluginState.pendingPastedAgentMention.id, mentionPluginState.mentionProvider, pendingResolveMentionIds, view);
991
+ }
987
992
  }
988
993
  },
989
994
  destroy: function destroy() {
@@ -8,9 +8,12 @@ import { WithProviders } from '@atlaskit/editor-common/provider-factory';
8
8
  import { IconMention } from '@atlaskit/editor-common/quick-insert';
9
9
  import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
10
10
  import { MentionNameStatus, isPromise } from '@atlaskit/mention/types';
11
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
11
12
  import { fg } from '@atlaskit/platform-feature-flags';
13
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
12
14
  import { insertMention } from './editor-commands';
13
15
  import { mentionNodeSpec } from './nodeviews/mentionNodeSpec';
16
+ import { agentMentionPluginKey, createAgentMentionPlugin } from './pm-plugins/agent';
14
17
  import { mentionPluginKey } from './pm-plugins/key';
15
18
  import { ACTIONS, createMentionPlugin } from './pm-plugins/main';
16
19
  import { createMentionPlaceholderPlugin } from './pm-plugins/mentionPlaceholder';
@@ -125,6 +128,15 @@ const mentionsPlugin = ({
125
128
  api
126
129
  })
127
130
  }];
131
+ if (editorExperiment('platform_editor_agent_mentions', true) && isExperimentEnabled('platform_editor_agent_mentions_separate_pm_plugin')) {
132
+ plugins.push({
133
+ name: 'agentMention',
134
+ plugin: pmPluginFactoryParams => createAgentMentionPlugin({
135
+ pmPluginFactoryParams,
136
+ options
137
+ })
138
+ });
139
+ }
128
140
  if (fg('jira_invites_auto_tag_new_user_in_mentions_fg')) {
129
141
  plugins.push({
130
142
  name: 'mentionPlaceholder',
@@ -227,6 +239,7 @@ const mentionsPlugin = ({
227
239
  return undefined;
228
240
  }
229
241
  const mentionPluginState = mentionPluginKey.getState(editorState);
242
+ const agentMentionPluginState = isExperimentEnabled('platform_editor_agent_mentions_separate_pm_plugin') ? agentMentionPluginKey.getState(editorState) : undefined;
230
243
  // Exclude pendingPastedAgentMention — it is an @internal transient field and
231
244
  // should not be part of the public shared state API. Exposing it would cause
232
245
  // unnecessary re-renders in subscribers and leak implementation details.
@@ -236,6 +249,15 @@ const mentionsPlugin = ({
236
249
  } = mentionPluginState !== null && mentionPluginState !== void 0 ? mentionPluginState : {};
237
250
  return {
238
251
  ...publicPluginState,
252
+ ...(agentMentionPluginState ? {
253
+ lastAgentMentionInsertionCount: agentMentionPluginState.lastAgentMentionInsertionCount,
254
+ lastInsertedAgentMentionContext: agentMentionPluginState.lastInsertedAgentMentionContext,
255
+ lastInsertedAgentMentionId: agentMentionPluginState.lastInsertedAgentMentionId,
256
+ lastInsertedAgentMentionLocalId: agentMentionPluginState.lastInsertedAgentMentionLocalId,
257
+ lastInsertedAgentMentionName: agentMentionPluginState.lastInsertedAgentMentionName,
258
+ lastInsertedAgentMentionParentNodeType: agentMentionPluginState.lastInsertedAgentMentionParentNodeType,
259
+ lastInsertedAgentMentionPrompt: agentMentionPluginState.lastInsertedAgentMentionPrompt
260
+ } : {}),
239
261
  typeAheadHandler: typeAhead
240
262
  };
241
263
  },