@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.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/mentionsPlugin.js +24 -1
- package/dist/cjs/pm-plugins/agent.js +763 -0
- package/dist/cjs/pm-plugins/main.js +107 -102
- package/dist/es2019/mentionsPlugin.js +22 -0
- package/dist/es2019/pm-plugins/agent.js +733 -0
- package/dist/es2019/pm-plugins/main.js +109 -104
- package/dist/esm/mentionsPlugin.js +24 -1
- package/dist/esm/pm-plugins/agent.js +757 -0
- package/dist/esm/pm-plugins/main.js +107 -102
- package/dist/types/pm-plugins/agent.d.ts +40 -0
- package/package.json +7 -7
|
@@ -3,6 +3,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
3
3
|
import { insm } from '@atlaskit/insm';
|
|
4
4
|
import { isResolvingMentionProvider, MentionNameStatus, SLI_EVENT_TYPE, SMART_EVENT_TYPE } from '@atlaskit/mention/resource';
|
|
5
5
|
import { ComponentNames } from '@atlaskit/mention/types';
|
|
6
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
6
7
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
8
9
|
import { MentionNodeView } from '../nodeviews/mentionNodeView';
|
|
@@ -50,7 +51,7 @@ const AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
|
|
|
50
51
|
const AGENT_MENTION_INACTIVITY_MS = 3000;
|
|
51
52
|
const MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
|
|
52
53
|
const PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
53
|
-
const PACKAGE_VERSION = "15.0.
|
|
54
|
+
const PACKAGE_VERSION = "15.0.3";
|
|
54
55
|
const setProvider = provider => (state, dispatch) => {
|
|
55
56
|
if (dispatch) {
|
|
56
57
|
dispatch(state.tr.setMeta(mentionPluginKey, {
|
|
@@ -329,10 +330,6 @@ export function createMentionPlugin({
|
|
|
329
330
|
api
|
|
330
331
|
}) {
|
|
331
332
|
let mentionProvider;
|
|
332
|
-
|
|
333
|
-
// Injected by Rovo-aware consumers only. Non-Rovo consumers omit this field
|
|
334
|
-
// entirely so this plugin incurs zero bundle cost from rovo-experience-api.
|
|
335
|
-
const getIsRovoPanelOpen = options === null || options === void 0 ? void 0 : options.getIsRovoPanelOpen;
|
|
336
333
|
const sendAnalytics = (event, actionSubject, action, attributes) => {
|
|
337
334
|
if (event === SLI_EVENT_TYPE || event === SMART_EVENT_TYPE) {
|
|
338
335
|
fireEvent({
|
|
@@ -367,7 +364,6 @@ export function createMentionPlugin({
|
|
|
367
364
|
};
|
|
368
365
|
let hasPublicPluginStateChanged = false;
|
|
369
366
|
let newPluginState = pluginState;
|
|
370
|
-
const isAgentMentionsExperimentEnabled = editorExperiment('platform_editor_agent_mentions', true);
|
|
371
367
|
const hasPositionChanged = oldState.selection.from !== newState.selection.from || oldState.selection.to !== newState.selection.to;
|
|
372
368
|
if (tr.docChanged || tr.selectionSet && hasPositionChanged) {
|
|
373
369
|
newPluginState = {
|
|
@@ -377,33 +373,6 @@ export function createMentionPlugin({
|
|
|
377
373
|
hasPublicPluginStateChanged = true;
|
|
378
374
|
}
|
|
379
375
|
switch (action) {
|
|
380
|
-
case ACTIONS.COMMIT_PENDING_TYPED_AGENT_MENTION:
|
|
381
|
-
{
|
|
382
|
-
const pendingTypedAgentMention = newPluginState.pendingTypedAgentMention;
|
|
383
|
-
// Ignore stale timer callbacks. The localId and resetCount must still match the
|
|
384
|
-
// current pending mention so older timers cannot publish after later user edits.
|
|
385
|
-
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)) {
|
|
386
|
-
break;
|
|
387
|
-
}
|
|
388
|
-
const commitResult = commitPendingTypedAgentMention(newState, newPluginState, pendingTypedAgentMention);
|
|
389
|
-
newPluginState = commitResult.pluginState;
|
|
390
|
-
hasPublicPluginStateChanged = hasPublicPluginStateChanged || commitResult.hasPublicPluginStateChanged;
|
|
391
|
-
break;
|
|
392
|
-
}
|
|
393
|
-
case ACTIONS.DISCARD_PENDING_TYPED_AGENT_MENTION:
|
|
394
|
-
{
|
|
395
|
-
// Silently discard the pending typed agent mention without committing it.
|
|
396
|
-
const pendingTypedAgentMentionToDiscard = newPluginState.pendingTypedAgentMention;
|
|
397
|
-
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)) {
|
|
398
|
-
break;
|
|
399
|
-
}
|
|
400
|
-
newPluginState = {
|
|
401
|
-
...newPluginState,
|
|
402
|
-
pendingTypedAgentMention: null
|
|
403
|
-
};
|
|
404
|
-
hasPublicPluginStateChanged = true;
|
|
405
|
-
break;
|
|
406
|
-
}
|
|
407
376
|
case ACTIONS.SET_PROVIDER:
|
|
408
377
|
newPluginState = {
|
|
409
378
|
...newPluginState,
|
|
@@ -411,45 +380,76 @@ export function createMentionPlugin({
|
|
|
411
380
|
};
|
|
412
381
|
hasPublicPluginStateChanged = true;
|
|
413
382
|
break;
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
383
|
+
}
|
|
384
|
+
if (!isExperimentEnabled('platform_editor_agent_mentions_separate_pm_plugin') && editorExperiment('platform_editor_agent_mentions', true)) {
|
|
385
|
+
switch (action) {
|
|
386
|
+
case ACTIONS.COMMIT_PENDING_TYPED_AGENT_MENTION:
|
|
387
|
+
{
|
|
388
|
+
const pendingTypedAgentMention = newPluginState.pendingTypedAgentMention;
|
|
389
|
+
// Ignore stale timer callbacks. The localId and resetCount must still match the
|
|
390
|
+
// current pending mention so older timers cannot publish after later user edits.
|
|
391
|
+
if (!pendingTypedAgentMention || pendingTypedAgentMention.localId !== (params === null || params === void 0 ? void 0 : params.localId) || pendingTypedAgentMention.resetCount !== (params === null || params === void 0 ? void 0 : params.resetCount)) {
|
|
392
|
+
break;
|
|
393
|
+
}
|
|
394
|
+
const commitResult = commitPendingTypedAgentMention(newState, newPluginState, pendingTypedAgentMention);
|
|
395
|
+
newPluginState = commitResult.pluginState;
|
|
396
|
+
hasPublicPluginStateChanged = hasPublicPluginStateChanged || commitResult.hasPublicPluginStateChanged;
|
|
419
397
|
break;
|
|
420
398
|
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
}
|
|
434
|
-
case ACTIONS.CLEAR_PENDING_PASTED_AGENT_MENTION:
|
|
435
|
-
{
|
|
436
|
-
var _newPluginState$pendi7;
|
|
437
|
-
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')) {
|
|
399
|
+
case ACTIONS.DISCARD_PENDING_TYPED_AGENT_MENTION:
|
|
400
|
+
{
|
|
401
|
+
// Silently discard the pending typed agent mention without committing it.
|
|
402
|
+
const pendingTypedAgentMentionToDiscard = newPluginState.pendingTypedAgentMention;
|
|
403
|
+
if (!pendingTypedAgentMentionToDiscard || pendingTypedAgentMentionToDiscard.localId !== (params === null || params === void 0 ? void 0 : params.localId) || pendingTypedAgentMentionToDiscard.resetCount !== (params === null || params === void 0 ? void 0 : params.resetCount)) {
|
|
404
|
+
break;
|
|
405
|
+
}
|
|
406
|
+
newPluginState = {
|
|
407
|
+
...newPluginState,
|
|
408
|
+
pendingTypedAgentMention: null
|
|
409
|
+
};
|
|
410
|
+
hasPublicPluginStateChanged = true;
|
|
438
411
|
break;
|
|
439
412
|
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
413
|
+
case ACTIONS.RESOLVE_PASTED_AGENT_MENTION_NAME:
|
|
414
|
+
{
|
|
415
|
+
var _newPluginState$pendi, _newPluginState$pendi2, _newPluginState$pendi3, _newPluginState$pendi4, _newPluginState$pendi5, _newPluginState$pendi6;
|
|
416
|
+
// Guard: only apply if there is a matching pending pasted mention (staleness check).
|
|
417
|
+
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')) {
|
|
418
|
+
break;
|
|
419
|
+
}
|
|
420
|
+
newPluginState = {
|
|
421
|
+
...newPluginState,
|
|
422
|
+
pendingPastedAgentMention: null,
|
|
423
|
+
lastInsertedAgentMentionId: (_newPluginState$pendi2 = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi2 === void 0 ? void 0 : _newPluginState$pendi2.id,
|
|
424
|
+
lastInsertedAgentMentionLocalId: (_newPluginState$pendi3 = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi3 === void 0 ? void 0 : _newPluginState$pendi3.localId,
|
|
425
|
+
lastInsertedAgentMentionContext: (_newPluginState$pendi4 = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi4 === void 0 ? void 0 : _newPluginState$pendi4.context,
|
|
426
|
+
lastInsertedAgentMentionName: params.name,
|
|
427
|
+
lastInsertedAgentMentionPrompt: (_newPluginState$pendi5 = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi5 === void 0 ? void 0 : _newPluginState$pendi5.prompt,
|
|
428
|
+
lastInsertedAgentMentionParentNodeType: (_newPluginState$pendi6 = newPluginState.pendingPastedAgentMention) === null || _newPluginState$pendi6 === void 0 ? void 0 : _newPluginState$pendi6.parentNodeType
|
|
429
|
+
};
|
|
430
|
+
hasPublicPluginStateChanged = true;
|
|
431
|
+
break;
|
|
432
|
+
}
|
|
433
|
+
case ACTIONS.CLEAR_PENDING_PASTED_AGENT_MENTION:
|
|
434
|
+
{
|
|
435
|
+
var _newPluginState$pendi7;
|
|
436
|
+
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')) {
|
|
437
|
+
break;
|
|
438
|
+
}
|
|
439
|
+
// resolveMentionName() returned a non-OK status — clear the pending state.
|
|
440
|
+
newPluginState = {
|
|
441
|
+
...newPluginState,
|
|
442
|
+
pendingPastedAgentMention: null
|
|
443
|
+
};
|
|
444
|
+
break;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
447
|
}
|
|
448
448
|
|
|
449
449
|
// When the agent mentions experiment is off, dispatch immediately (original behaviour).
|
|
450
450
|
// When it's on, defer dispatch to after the agent tracking block below so that
|
|
451
451
|
// agent-mention state changes are included in the notification.
|
|
452
|
-
if (hasPublicPluginStateChanged && !
|
|
452
|
+
if (hasPublicPluginStateChanged && (isExperimentEnabled('platform_editor_agent_mentions_separate_pm_plugin') || !editorExperiment('platform_editor_agent_mentions', true))) {
|
|
453
453
|
pmPluginFactoryParams.dispatch(mentionPluginKey, newPluginState);
|
|
454
454
|
}
|
|
455
455
|
if (options !== null && options !== void 0 && options.handleMentionsChanged && tr.docChanged) {
|
|
@@ -509,7 +509,7 @@ export function createMentionPlugin({
|
|
|
509
509
|
}
|
|
510
510
|
(_insm$session2 = insm.session) === null || _insm$session2 === void 0 ? void 0 : _insm$session2.endFeature('mentionDeletionDetection');
|
|
511
511
|
}
|
|
512
|
-
if (
|
|
512
|
+
if (!isExperimentEnabled('platform_editor_agent_mentions_separate_pm_plugin') && editorExperiment('platform_editor_agent_mentions', true) && isQualifyingLocalUserDocChange(tr)) {
|
|
513
513
|
const mentionSchema = newState.schema.nodes.mention;
|
|
514
514
|
const newDocRanges = [];
|
|
515
515
|
const oldDocRanges = [];
|
|
@@ -680,10 +680,11 @@ export function createMentionPlugin({
|
|
|
680
680
|
};
|
|
681
681
|
hasPublicPluginStateChanged = true;
|
|
682
682
|
} 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) {
|
|
683
|
+
var _options$getIsRovoPan;
|
|
683
684
|
// Suppress the nudge for pasted/non-typed agent mentions when Rovo is already
|
|
684
685
|
// open.
|
|
685
686
|
const isTaskItemMentionForPaste = agentMentionParentNodeType === 'taskItem';
|
|
686
|
-
if (!isTaskItemMentionForPaste && isNewInsertion &&
|
|
687
|
+
if (!isTaskItemMentionForPaste && isNewInsertion && options !== null && options !== void 0 && (_options$getIsRovoPan = options.getIsRovoPanelOpen) !== null && _options$getIsRovoPan !== void 0 && _options$getIsRovoPan.call(options)) {
|
|
687
688
|
// Rovo is already open — skip setting lastInsertedAgentMention* so the
|
|
688
689
|
// downstream nudge listener never fires.
|
|
689
690
|
} else if (agentMentionName === null && agentMentionId !== null && isResolvingMentionProvider(newPluginState.mentionProvider) && fg('platform_editor_agent_mentions_drop_one_fixes')) {
|
|
@@ -721,11 +722,11 @@ export function createMentionPlugin({
|
|
|
721
722
|
}
|
|
722
723
|
}
|
|
723
724
|
}
|
|
724
|
-
if (
|
|
725
|
+
if (!isExperimentEnabled('platform_editor_agent_mentions_separate_pm_plugin') && editorExperiment('platform_editor_agent_mentions', true) && tr.docChanged && tr.getMeta('replaceDocument') && hasTrackedAgentMentionState(newPluginState)) {
|
|
725
726
|
newPluginState = clearTrackedAgentMentionState(newPluginState);
|
|
726
727
|
hasPublicPluginStateChanged = true;
|
|
727
728
|
}
|
|
728
|
-
if (
|
|
729
|
+
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) {
|
|
729
730
|
newPluginState = {
|
|
730
731
|
...newPluginState,
|
|
731
732
|
pendingTypedAgentMention: getPendingTypedAgentMentionAfterDocChange(newState, tr, newPluginState.pendingTypedAgentMention, {
|
|
@@ -733,40 +734,42 @@ export function createMentionPlugin({
|
|
|
733
734
|
})
|
|
734
735
|
};
|
|
735
736
|
}
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
newPluginState = {
|
|
747
|
-
...newPluginState,
|
|
748
|
-
pendingTypedAgentMention: null
|
|
749
|
-
};
|
|
750
|
-
} else if (hasPendingMentionMovedToNewParent(oldState, tr, pluginState.pendingTypedAgentMention, pendingMentionDetails) || isSelectionOutsideDirectParent(newState, pendingMentionDetails)) {
|
|
751
|
-
// Suppress the nudge when Rovo chat is already open, mirroring the same
|
|
752
|
-
// guard used in the inactivity-timer path. Task-item mentions are
|
|
753
|
-
// exempt because they auto-fire the mini modal and never show a nudge.
|
|
754
|
-
if (pendingMentionDetails.parentNodeType !== 'taskItem' && getIsRovoPanelOpen !== null && getIsRovoPanelOpen !== void 0 && getIsRovoPanelOpen()) {
|
|
755
|
-
// Discard without committing so lastInsertedAgentMention* fields are
|
|
756
|
-
// never set and the downstream nudge listener never fires.
|
|
737
|
+
if (!isExperimentEnabled('platform_editor_agent_mentions_separate_pm_plugin') && editorExperiment('platform_editor_agent_mentions', true)) {
|
|
738
|
+
// Typed agent mentions stay pending while the user is still editing around them,
|
|
739
|
+
// but leaving the mention's direct parent means they have moved on from that
|
|
740
|
+
// paragraph/block. Publish immediately in that case instead of waiting for the
|
|
741
|
+
// inactivity timer.
|
|
742
|
+
const shouldCheckPendingTypedAgentMentionParent = isLocalSelectionChange(tr, hasPositionChanged);
|
|
743
|
+
if (newPluginState.pendingTypedAgentMention && action !== ACTIONS.SET_PENDING_TYPED_AGENT_MENTION && action !== ACTIONS.COMMIT_PENDING_TYPED_AGENT_MENTION && shouldCheckPendingTypedAgentMentionParent) {
|
|
744
|
+
const pendingTypedAgentMention = newPluginState.pendingTypedAgentMention;
|
|
745
|
+
const pendingMentionDetails = getAgentMentionDetailsAtPos(newState, pendingTypedAgentMention.pos, attrs => attrs.localId === pendingTypedAgentMention.localId, pendingTypedAgentMention.name);
|
|
746
|
+
if (!pendingMentionDetails) {
|
|
757
747
|
newPluginState = {
|
|
758
748
|
...newPluginState,
|
|
759
749
|
pendingTypedAgentMention: null
|
|
760
750
|
};
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
751
|
+
} else if (hasPendingMentionMovedToNewParent(oldState, tr, pluginState.pendingTypedAgentMention, pendingMentionDetails) || isSelectionOutsideDirectParent(newState, pendingMentionDetails)) {
|
|
752
|
+
var _options$getIsRovoPan2;
|
|
753
|
+
// Suppress the nudge when Rovo chat is already open, mirroring the same
|
|
754
|
+
// guard used in the inactivity-timer path. Task-item mentions are
|
|
755
|
+
// exempt because they auto-fire the mini modal and never show a nudge.
|
|
756
|
+
if (pendingMentionDetails.parentNodeType !== 'taskItem' && options !== null && options !== void 0 && (_options$getIsRovoPan2 = options.getIsRovoPanelOpen) !== null && _options$getIsRovoPan2 !== void 0 && _options$getIsRovoPan2.call(options)) {
|
|
757
|
+
// Discard without committing so lastInsertedAgentMention* fields are
|
|
758
|
+
// never set and the downstream nudge listener never fires.
|
|
759
|
+
newPluginState = {
|
|
760
|
+
...newPluginState,
|
|
761
|
+
pendingTypedAgentMention: null
|
|
762
|
+
};
|
|
763
|
+
hasPublicPluginStateChanged = true;
|
|
764
|
+
} else {
|
|
765
|
+
const commitResult = commitResolvedPendingTypedAgentMention(newPluginState, pendingMentionDetails);
|
|
766
|
+
newPluginState = commitResult.pluginState;
|
|
767
|
+
hasPublicPluginStateChanged = hasPublicPluginStateChanged || commitResult.hasPublicPluginStateChanged;
|
|
768
|
+
}
|
|
766
769
|
}
|
|
767
770
|
}
|
|
768
771
|
}
|
|
769
|
-
if (hasPublicPluginStateChanged &&
|
|
772
|
+
if (hasPublicPluginStateChanged && !isExperimentEnabled('platform_editor_agent_mentions_separate_pm_plugin') && editorExperiment('platform_editor_agent_mentions', true)) {
|
|
770
773
|
pmPluginFactoryParams.dispatch(mentionPluginKey, newPluginState);
|
|
771
774
|
}
|
|
772
775
|
return newPluginState;
|
|
@@ -785,7 +788,6 @@ export function createMentionPlugin({
|
|
|
785
788
|
}
|
|
786
789
|
},
|
|
787
790
|
view(editorView) {
|
|
788
|
-
const isAgentMentionsEnabled = editorExperiment('platform_editor_agent_mentions', true);
|
|
789
791
|
let pendingTypedAgentMentionTimer;
|
|
790
792
|
let pendingTypedAgentMentionTimerKey = null;
|
|
791
793
|
let pendingTypedAgentMentionFocusDeferCount = 0;
|
|
@@ -828,7 +830,7 @@ export function createMentionPlugin({
|
|
|
828
830
|
const schedulePendingTypedAgentMentionTimer = (mentionPluginState, {
|
|
829
831
|
preserveFocusDeferCount = false
|
|
830
832
|
} = {}) => {
|
|
831
|
-
if (!
|
|
833
|
+
if (isExperimentEnabled('platform_editor_agent_mentions_separate_pm_plugin') || !editorExperiment('platform_editor_agent_mentions', true)) {
|
|
832
834
|
clearPendingTypedAgentMentionTimer();
|
|
833
835
|
return;
|
|
834
836
|
}
|
|
@@ -848,10 +850,11 @@ export function createMentionPlugin({
|
|
|
848
850
|
pendingTypedAgentMentionTimer = setTimeout(() => {
|
|
849
851
|
var _mentionPluginKey$get;
|
|
850
852
|
{
|
|
853
|
+
var _options$getIsRovoPan3;
|
|
851
854
|
// Suppress the agent-mention nudge when the Rovo panel is already open,
|
|
852
855
|
// but only for non-task-item mentions.
|
|
853
856
|
const isTaskItemMention = pendingTypedAgentMention.parentNodeType === 'taskItem';
|
|
854
|
-
if (!isTaskItemMention &&
|
|
857
|
+
if (!isTaskItemMention && options !== null && options !== void 0 && (_options$getIsRovoPan3 = options.getIsRovoPanelOpen) !== null && _options$getIsRovoPan3 !== void 0 && _options$getIsRovoPan3.call(options)) {
|
|
855
858
|
// Dispatch a discard so pendingTypedAgentMention is nulled out of plugin
|
|
856
859
|
// state.
|
|
857
860
|
editorView.dispatch(editorView.state.tr.setMeta(mentionPluginKey, {
|
|
@@ -932,18 +935,20 @@ export function createMentionPlugin({
|
|
|
932
935
|
}
|
|
933
936
|
return {
|
|
934
937
|
update(view, prevState) {
|
|
935
|
-
var _mentionPluginState$p;
|
|
936
938
|
const mentionPluginState = mentionPluginKey.getState(view.state);
|
|
937
939
|
if (mentionPluginState === mentionPluginKey.getState(prevState)) {
|
|
938
940
|
return;
|
|
939
941
|
}
|
|
940
|
-
|
|
942
|
+
if (!isExperimentEnabled('platform_editor_agent_mentions_separate_pm_plugin')) {
|
|
943
|
+
var _mentionPluginState$p;
|
|
944
|
+
schedulePendingTypedAgentMentionTimer(mentionPluginState);
|
|
941
945
|
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
946
|
+
// If a pasted agent mention has no name (cache miss), resolve it async
|
|
947
|
+
// via the mention provider and dispatch RESOLVE_PASTED_AGENT_MENTION_NAME
|
|
948
|
+
// so the nudge displays the correct name.
|
|
949
|
+
if (editorExperiment('platform_editor_agent_mentions', true) && (mentionPluginState === null || mentionPluginState === void 0 ? 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')) {
|
|
950
|
+
resolveAndDispatchPastedAgentMentionName(mentionPluginState.pendingPastedAgentMention.id, mentionPluginState.mentionProvider, pendingResolveMentionIds, view);
|
|
951
|
+
}
|
|
947
952
|
}
|
|
948
953
|
},
|
|
949
954
|
destroy() {
|
|
@@ -15,9 +15,12 @@ import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
|
15
15
|
import { IconMention } from '@atlaskit/editor-common/quick-insert';
|
|
16
16
|
import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
|
|
17
17
|
import { MentionNameStatus, isPromise } from '@atlaskit/mention/types';
|
|
18
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
18
19
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
20
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
19
21
|
import { insertMention } from './editor-commands';
|
|
20
22
|
import { mentionNodeSpec } from './nodeviews/mentionNodeSpec';
|
|
23
|
+
import { agentMentionPluginKey, createAgentMentionPlugin } from './pm-plugins/agent';
|
|
21
24
|
import { mentionPluginKey } from './pm-plugins/key';
|
|
22
25
|
import { ACTIONS, createMentionPlugin } from './pm-plugins/main';
|
|
23
26
|
import { createMentionPlaceholderPlugin } from './pm-plugins/mentionPlaceholder';
|
|
@@ -123,6 +126,17 @@ var mentionsPlugin = function mentionsPlugin(_ref3) {
|
|
|
123
126
|
});
|
|
124
127
|
}
|
|
125
128
|
}];
|
|
129
|
+
if (editorExperiment('platform_editor_agent_mentions', true) && isExperimentEnabled('platform_editor_agent_mentions_separate_pm_plugin')) {
|
|
130
|
+
plugins.push({
|
|
131
|
+
name: 'agentMention',
|
|
132
|
+
plugin: function plugin(pmPluginFactoryParams) {
|
|
133
|
+
return createAgentMentionPlugin({
|
|
134
|
+
pmPluginFactoryParams: pmPluginFactoryParams,
|
|
135
|
+
options: options
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
126
140
|
if (fg('jira_invites_auto_tag_new_user_in_mentions_fg')) {
|
|
127
141
|
plugins.push({
|
|
128
142
|
name: 'mentionPlaceholder',
|
|
@@ -248,13 +262,22 @@ var mentionsPlugin = function mentionsPlugin(_ref3) {
|
|
|
248
262
|
return undefined;
|
|
249
263
|
}
|
|
250
264
|
var mentionPluginState = mentionPluginKey.getState(editorState);
|
|
265
|
+
var agentMentionPluginState = isExperimentEnabled('platform_editor_agent_mentions_separate_pm_plugin') ? agentMentionPluginKey.getState(editorState) : undefined;
|
|
251
266
|
// Exclude pendingPastedAgentMention — it is an @internal transient field and
|
|
252
267
|
// should not be part of the public shared state API. Exposing it would cause
|
|
253
268
|
// unnecessary re-renders in subscribers and leak implementation details.
|
|
254
269
|
var _ref8 = mentionPluginState !== null && mentionPluginState !== void 0 ? mentionPluginState : {},
|
|
255
270
|
_excluded = _ref8.pendingPastedAgentMention,
|
|
256
271
|
publicPluginState = _objectWithoutProperties(_ref8, _excluded2);
|
|
257
|
-
return _objectSpread(_objectSpread({}, publicPluginState),
|
|
272
|
+
return _objectSpread(_objectSpread(_objectSpread({}, publicPluginState), agentMentionPluginState ? {
|
|
273
|
+
lastAgentMentionInsertionCount: agentMentionPluginState.lastAgentMentionInsertionCount,
|
|
274
|
+
lastInsertedAgentMentionContext: agentMentionPluginState.lastInsertedAgentMentionContext,
|
|
275
|
+
lastInsertedAgentMentionId: agentMentionPluginState.lastInsertedAgentMentionId,
|
|
276
|
+
lastInsertedAgentMentionLocalId: agentMentionPluginState.lastInsertedAgentMentionLocalId,
|
|
277
|
+
lastInsertedAgentMentionName: agentMentionPluginState.lastInsertedAgentMentionName,
|
|
278
|
+
lastInsertedAgentMentionParentNodeType: agentMentionPluginState.lastInsertedAgentMentionParentNodeType,
|
|
279
|
+
lastInsertedAgentMentionPrompt: agentMentionPluginState.lastInsertedAgentMentionPrompt
|
|
280
|
+
} : {}), {}, {
|
|
258
281
|
typeAheadHandler: typeAhead
|
|
259
282
|
});
|
|
260
283
|
},
|