@atlaskit/editor-plugin-mentions 14.5.5 → 14.5.6
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 +7 -0
- package/dist/cjs/pm-plugins/main.js +49 -27
- package/dist/es2019/pm-plugins/main.js +48 -26
- package/dist/esm/pm-plugins/main.js +49 -27
- package/dist/types/types/index.d.ts +6 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-mentions
|
|
2
2
|
|
|
3
|
+
## 14.5.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`8d0225546ac2c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8d0225546ac2c) -
|
|
8
|
+
Track agent mention prompt context by mention localId and keep context updates synced to Rovo.
|
|
9
|
+
|
|
3
10
|
## 14.5.5
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -50,7 +50,7 @@ var getAgentMentionName = function getAgentMentionName(text, fallbackName) {
|
|
|
50
50
|
var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
|
|
51
51
|
var AGENT_MENTION_INACTIVITY_MS = 3000;
|
|
52
52
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
53
|
-
var PACKAGE_VERSION = "14.5.
|
|
53
|
+
var PACKAGE_VERSION = "14.5.5";
|
|
54
54
|
var setProvider = function setProvider(provider) {
|
|
55
55
|
return function (state, dispatch) {
|
|
56
56
|
if (dispatch) {
|
|
@@ -97,13 +97,14 @@ var getAgentMentionDetailsAtPos = function getAgentMentionDetailsAtPos(state, po
|
|
|
97
97
|
}
|
|
98
98
|
var node = state.doc.nodeAt(pos);
|
|
99
99
|
var mentionSchema = state.schema.nodes.mention;
|
|
100
|
-
if ((node === null || node === void 0 ? void 0 : node.type) !== mentionSchema || !isAgentUserType(node.attrs.userType) || !matchesMention(node.attrs) || !node.attrs.id) {
|
|
100
|
+
if ((node === null || node === void 0 ? void 0 : node.type) !== mentionSchema || !isAgentUserType(node.attrs.userType) || !matchesMention(node.attrs) || !node.attrs.id || !node.attrs.localId) {
|
|
101
101
|
return null;
|
|
102
102
|
}
|
|
103
103
|
var $mentionPos = state.doc.resolve(Math.min(pos + node.nodeSize, state.doc.content.size));
|
|
104
104
|
var parentNode = $mentionPos.node($mentionPos.depth);
|
|
105
105
|
return {
|
|
106
106
|
id: node.attrs.id,
|
|
107
|
+
localId: node.attrs.localId,
|
|
107
108
|
context: parentNode.textContent.trim() || null,
|
|
108
109
|
name: getAgentMentionName(node.attrs.text, fallbackName),
|
|
109
110
|
nodeSize: node.nodeSize,
|
|
@@ -116,24 +117,23 @@ var getAgentMentionDetailsAtPos = function getAgentMentionDetailsAtPos(state, po
|
|
|
116
117
|
|
|
117
118
|
/**
|
|
118
119
|
* Finds an agent mention that survived a document change when the changed-range
|
|
119
|
-
* scan did not find one.
|
|
120
|
-
*
|
|
120
|
+
* scan did not find one. Uses the tracked localId as the mention instance identity
|
|
121
|
+
* so same-agent mentions elsewhere in the document cannot be selected as fallback.
|
|
121
122
|
*/
|
|
122
|
-
var getSurvivingAgentMentionDetails = function getSurvivingAgentMentionDetails(state,
|
|
123
|
+
var getSurvivingAgentMentionDetails = function getSurvivingAgentMentionDetails(state, preferredLocalId, preferredName) {
|
|
123
124
|
var mentionSchema = state.schema.nodes.mention;
|
|
124
125
|
var result = null;
|
|
125
126
|
state.doc.descendants(function (node, pos) {
|
|
126
|
-
|
|
127
|
-
if (((_result = result) === null || _result === void 0 ? void 0 : _result.id) === preferredId) {
|
|
127
|
+
if (result) {
|
|
128
128
|
return false;
|
|
129
129
|
}
|
|
130
|
-
if (node.type !== mentionSchema || !isAgentUserType(node.attrs.userType) ||
|
|
130
|
+
if (node.type !== mentionSchema || !isAgentUserType(node.attrs.userType) || node.attrs.localId !== preferredLocalId) {
|
|
131
131
|
return true;
|
|
132
132
|
}
|
|
133
133
|
result = getAgentMentionDetailsAtPos(state, pos, function (attrs) {
|
|
134
|
-
return attrs.
|
|
135
|
-
},
|
|
136
|
-
return
|
|
134
|
+
return attrs.localId === preferredLocalId;
|
|
135
|
+
}, preferredName);
|
|
136
|
+
return !result;
|
|
137
137
|
});
|
|
138
138
|
return result;
|
|
139
139
|
};
|
|
@@ -192,6 +192,7 @@ var commitResolvedPendingTypedAgentMention = function commitResolvedPendingTyped
|
|
|
192
192
|
pluginState: _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
193
193
|
pendingTypedAgentMention: null,
|
|
194
194
|
lastInsertedAgentMentionId: pendingMentionDetails.id,
|
|
195
|
+
lastInsertedAgentMentionLocalId: pendingMentionDetails.localId,
|
|
195
196
|
lastInsertedAgentMentionContext: pendingMentionDetails.context,
|
|
196
197
|
lastInsertedAgentMentionName: pendingMentionDetails.name,
|
|
197
198
|
lastInsertedAgentMentionParentNodeType: pendingMentionDetails.parentNodeType,
|
|
@@ -220,7 +221,7 @@ var commitPendingTypedAgentMention = function commitPendingTypedAgentMention(sta
|
|
|
220
221
|
return commitResolvedPendingTypedAgentMention(pluginState, pendingMentionDetails);
|
|
221
222
|
};
|
|
222
223
|
var hasTrackedAgentMentionState = function hasTrackedAgentMentionState(pluginState) {
|
|
223
|
-
return Boolean(pluginState.pendingTypedAgentMention) || pluginState.lastInsertedAgentMentionId != null || pluginState.lastInsertedAgentMentionContext != null || pluginState.lastInsertedAgentMentionName != null || pluginState.lastInsertedAgentMentionParentNodeType != null;
|
|
224
|
+
return Boolean(pluginState.pendingTypedAgentMention) || pluginState.lastInsertedAgentMentionId != null || pluginState.lastInsertedAgentMentionLocalId != null || pluginState.lastInsertedAgentMentionContext != null || pluginState.lastInsertedAgentMentionName != null || pluginState.lastInsertedAgentMentionParentNodeType != null;
|
|
224
225
|
};
|
|
225
226
|
|
|
226
227
|
/**
|
|
@@ -232,6 +233,7 @@ var clearTrackedAgentMentionState = function clearTrackedAgentMentionState(plugi
|
|
|
232
233
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
233
234
|
pendingTypedAgentMention: null,
|
|
234
235
|
lastInsertedAgentMentionId: null,
|
|
236
|
+
lastInsertedAgentMentionLocalId: null,
|
|
235
237
|
lastInsertedAgentMentionContext: null,
|
|
236
238
|
lastInsertedAgentMentionName: null,
|
|
237
239
|
lastInsertedAgentMentionParentNodeType: null
|
|
@@ -416,16 +418,15 @@ function createMentionPlugin(_ref2) {
|
|
|
416
418
|
oldDocRanges.push.apply(oldDocRanges, stepOldRanges);
|
|
417
419
|
}
|
|
418
420
|
});
|
|
419
|
-
var shouldResolveAgentMentionState = stepsTouchMentions || Boolean(newPluginState.
|
|
421
|
+
var shouldResolveAgentMentionState = stepsTouchMentions || Boolean(newPluginState.lastInsertedAgentMentionLocalId);
|
|
420
422
|
if (shouldResolveAgentMentionState) {
|
|
421
|
-
var _newPluginState$
|
|
423
|
+
var _newPluginState$lastI, _newPluginState$lastA, _newPluginState$lastI2, _newPluginState$lastI3, _newPluginState$lastI4, _newPluginState$lastI5, _newPluginState$lastI6;
|
|
422
424
|
var agentMentionId = null;
|
|
425
|
+
var agentMentionLocalId = null;
|
|
423
426
|
var agentMentionContext = null;
|
|
424
427
|
var agentMentionName = null;
|
|
425
428
|
var agentMentionParentNodeType = null;
|
|
426
|
-
var
|
|
427
|
-
var oldAgentMentionId = null;
|
|
428
|
-
var oldCount = 0;
|
|
429
|
+
var existingAgentMentionLocalIdsInChangedRanges = new Set();
|
|
429
430
|
var pendingTypedAgentMentionDetails = null;
|
|
430
431
|
if (stepsTouchMentions) {
|
|
431
432
|
var _iterator = _createForOfIteratorHelper(newDocRanges),
|
|
@@ -441,18 +442,18 @@ function createMentionPlugin(_ref2) {
|
|
|
441
442
|
if (node.type !== _mentionSchema || !isAgentUserType(node.attrs.userType)) {
|
|
442
443
|
return true;
|
|
443
444
|
}
|
|
444
|
-
newCount++;
|
|
445
445
|
if (pendingTypedAgentMentionDetails === null && action === ACTIONS.SET_PENDING_TYPED_AGENT_MENTION && node.attrs.localId === (params === null || params === void 0 ? void 0 : params.localId)) {
|
|
446
446
|
pendingTypedAgentMentionDetails = getAgentMentionDetailsAtPos(newState, pos, function (attrs) {
|
|
447
447
|
return attrs.localId === params.localId;
|
|
448
448
|
}, params.name);
|
|
449
449
|
}
|
|
450
|
-
if (
|
|
450
|
+
if (agentMentionLocalId === null && node.attrs.localId) {
|
|
451
451
|
var agentMentionDetails = getAgentMentionDetailsAtPos(newState, pos, function (attrs) {
|
|
452
|
-
return attrs.
|
|
452
|
+
return attrs.localId === node.attrs.localId;
|
|
453
453
|
}, params === null || params === void 0 ? void 0 : params.name);
|
|
454
454
|
if (agentMentionDetails) {
|
|
455
455
|
agentMentionId = agentMentionDetails.id;
|
|
456
|
+
agentMentionLocalId = agentMentionDetails.localId;
|
|
456
457
|
agentMentionContext = agentMentionDetails.context;
|
|
457
458
|
agentMentionName = agentMentionDetails.name;
|
|
458
459
|
agentMentionParentNodeType = agentMentionDetails.parentNodeType;
|
|
@@ -479,9 +480,8 @@ function createMentionPlugin(_ref2) {
|
|
|
479
480
|
if (node.type !== _mentionSchema || !isAgentUserType(node.attrs.userType)) {
|
|
480
481
|
return true;
|
|
481
482
|
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
oldAgentMentionId = node.attrs.id;
|
|
483
|
+
if (node.attrs.localId) {
|
|
484
|
+
existingAgentMentionLocalIdsInChangedRanges.add(node.attrs.localId);
|
|
485
485
|
}
|
|
486
486
|
return true;
|
|
487
487
|
});
|
|
@@ -497,17 +497,37 @@ function createMentionPlugin(_ref2) {
|
|
|
497
497
|
// the doc changed but no step covered the tracked mention, the new-doc scan
|
|
498
498
|
// above finds nothing. Check whether any agent mention survived in the document.
|
|
499
499
|
var resolvedFromFullDocFallback = false;
|
|
500
|
-
if (agentMentionId === null && newPluginState.
|
|
501
|
-
var survivorDetails = getSurvivingAgentMentionDetails(newState, newPluginState.
|
|
500
|
+
if (agentMentionId === null && newPluginState.lastInsertedAgentMentionLocalId) {
|
|
501
|
+
var survivorDetails = getSurvivingAgentMentionDetails(newState, newPluginState.lastInsertedAgentMentionLocalId, newPluginState.lastInsertedAgentMentionName);
|
|
502
502
|
if (survivorDetails) {
|
|
503
503
|
agentMentionId = survivorDetails.id;
|
|
504
|
+
agentMentionLocalId = survivorDetails.localId;
|
|
504
505
|
agentMentionContext = survivorDetails.context;
|
|
505
506
|
agentMentionName = survivorDetails.name;
|
|
506
507
|
agentMentionParentNodeType = survivorDetails.parentNodeType;
|
|
507
508
|
resolvedFromFullDocFallback = true;
|
|
508
509
|
}
|
|
509
510
|
}
|
|
510
|
-
var
|
|
511
|
+
var trackedAgentMentionLocalId = (_newPluginState$lastI = newPluginState.lastInsertedAgentMentionLocalId) !== null && _newPluginState$lastI !== void 0 ? _newPluginState$lastI : null;
|
|
512
|
+
var changedRangeMentionIsNew = agentMentionLocalId !== null && !existingAgentMentionLocalIdsInChangedRanges.has(agentMentionLocalId);
|
|
513
|
+
if (agentMentionLocalId !== null && !changedRangeMentionIsNew && agentMentionLocalId !== trackedAgentMentionLocalId) {
|
|
514
|
+
var _survivorDetails = trackedAgentMentionLocalId ? getSurvivingAgentMentionDetails(newState, trackedAgentMentionLocalId, newPluginState.lastInsertedAgentMentionName) : null;
|
|
515
|
+
if (_survivorDetails) {
|
|
516
|
+
agentMentionId = _survivorDetails.id;
|
|
517
|
+
agentMentionLocalId = _survivorDetails.localId;
|
|
518
|
+
agentMentionContext = _survivorDetails.context;
|
|
519
|
+
agentMentionName = _survivorDetails.name;
|
|
520
|
+
agentMentionParentNodeType = _survivorDetails.parentNodeType;
|
|
521
|
+
resolvedFromFullDocFallback = true;
|
|
522
|
+
} else {
|
|
523
|
+
agentMentionId = null;
|
|
524
|
+
agentMentionLocalId = null;
|
|
525
|
+
agentMentionContext = null;
|
|
526
|
+
agentMentionName = null;
|
|
527
|
+
agentMentionParentNodeType = null;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
var isNewInsertion = agentMentionId !== null && !resolvedFromFullDocFallback && changedRangeMentionIsNew;
|
|
511
531
|
var isPendingTypedAgentMentionInsertion = isNewInsertion && action === ACTIONS.SET_PENDING_TYPED_AGENT_MENTION && typeof (params === null || params === void 0 ? void 0 : params.localId) === 'string';
|
|
512
532
|
var newInsertionCount = isNewInsertion ? ((_newPluginState$lastA = newPluginState.lastAgentMentionInsertionCount) !== null && _newPluginState$lastA !== void 0 ? _newPluginState$lastA : 0) + 1 : undefined;
|
|
513
533
|
var pendingTypedAgentMentionDetailsForState = pendingTypedAgentMentionDetails;
|
|
@@ -529,6 +549,7 @@ function createMentionPlugin(_ref2) {
|
|
|
529
549
|
newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
|
|
530
550
|
pendingTypedAgentMention: null,
|
|
531
551
|
lastInsertedAgentMentionId: agentMentionId,
|
|
552
|
+
lastInsertedAgentMentionLocalId: agentMentionLocalId,
|
|
532
553
|
lastInsertedAgentMentionContext: agentMentionContext,
|
|
533
554
|
lastInsertedAgentMentionName: agentMentionName,
|
|
534
555
|
lastInsertedAgentMentionParentNodeType: agentMentionParentNodeType
|
|
@@ -536,9 +557,10 @@ function createMentionPlugin(_ref2) {
|
|
|
536
557
|
lastAgentMentionInsertionCount: newInsertionCount
|
|
537
558
|
} : {});
|
|
538
559
|
hasPublicPluginStateChanged = true;
|
|
539
|
-
} else if (agentMentionId !== ((_newPluginState$
|
|
560
|
+
} 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) || agentMentionContext !== ((_newPluginState$lastI4 = newPluginState.lastInsertedAgentMentionContext) !== null && _newPluginState$lastI4 !== void 0 ? _newPluginState$lastI4 : null) || agentMentionName !== ((_newPluginState$lastI5 = newPluginState.lastInsertedAgentMentionName) !== null && _newPluginState$lastI5 !== void 0 ? _newPluginState$lastI5 : null) || agentMentionParentNodeType !== ((_newPluginState$lastI6 = newPluginState.lastInsertedAgentMentionParentNodeType) !== null && _newPluginState$lastI6 !== void 0 ? _newPluginState$lastI6 : null) || newInsertionCount !== undefined) {
|
|
540
561
|
newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
|
|
541
562
|
lastInsertedAgentMentionId: agentMentionId,
|
|
563
|
+
lastInsertedAgentMentionLocalId: agentMentionLocalId,
|
|
542
564
|
lastInsertedAgentMentionContext: agentMentionContext,
|
|
543
565
|
lastInsertedAgentMentionName: agentMentionName,
|
|
544
566
|
lastInsertedAgentMentionParentNodeType: agentMentionParentNodeType
|
|
@@ -35,7 +35,7 @@ const getAgentMentionName = (text, fallbackName) => {
|
|
|
35
35
|
const AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
|
|
36
36
|
const AGENT_MENTION_INACTIVITY_MS = 3000;
|
|
37
37
|
const PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
38
|
-
const PACKAGE_VERSION = "14.5.
|
|
38
|
+
const PACKAGE_VERSION = "14.5.5";
|
|
39
39
|
const setProvider = provider => (state, dispatch) => {
|
|
40
40
|
if (dispatch) {
|
|
41
41
|
dispatch(state.tr.setMeta(mentionPluginKey, {
|
|
@@ -80,13 +80,14 @@ const getAgentMentionDetailsAtPos = (state, pos, matchesMention, fallbackName) =
|
|
|
80
80
|
}
|
|
81
81
|
const node = state.doc.nodeAt(pos);
|
|
82
82
|
const mentionSchema = state.schema.nodes.mention;
|
|
83
|
-
if ((node === null || node === void 0 ? void 0 : node.type) !== mentionSchema || !isAgentUserType(node.attrs.userType) || !matchesMention(node.attrs) || !node.attrs.id) {
|
|
83
|
+
if ((node === null || node === void 0 ? void 0 : node.type) !== mentionSchema || !isAgentUserType(node.attrs.userType) || !matchesMention(node.attrs) || !node.attrs.id || !node.attrs.localId) {
|
|
84
84
|
return null;
|
|
85
85
|
}
|
|
86
86
|
const $mentionPos = state.doc.resolve(Math.min(pos + node.nodeSize, state.doc.content.size));
|
|
87
87
|
const parentNode = $mentionPos.node($mentionPos.depth);
|
|
88
88
|
return {
|
|
89
89
|
id: node.attrs.id,
|
|
90
|
+
localId: node.attrs.localId,
|
|
90
91
|
context: parentNode.textContent.trim() || null,
|
|
91
92
|
name: getAgentMentionName(node.attrs.text, fallbackName),
|
|
92
93
|
nodeSize: node.nodeSize,
|
|
@@ -99,22 +100,21 @@ const getAgentMentionDetailsAtPos = (state, pos, matchesMention, fallbackName) =
|
|
|
99
100
|
|
|
100
101
|
/**
|
|
101
102
|
* Finds an agent mention that survived a document change when the changed-range
|
|
102
|
-
* scan did not find one.
|
|
103
|
-
*
|
|
103
|
+
* scan did not find one. Uses the tracked localId as the mention instance identity
|
|
104
|
+
* so same-agent mentions elsewhere in the document cannot be selected as fallback.
|
|
104
105
|
*/
|
|
105
|
-
const getSurvivingAgentMentionDetails = (state,
|
|
106
|
+
const getSurvivingAgentMentionDetails = (state, preferredLocalId, preferredName) => {
|
|
106
107
|
const mentionSchema = state.schema.nodes.mention;
|
|
107
108
|
let result = null;
|
|
108
109
|
state.doc.descendants((node, pos) => {
|
|
109
|
-
|
|
110
|
-
if (((_result = result) === null || _result === void 0 ? void 0 : _result.id) === preferredId) {
|
|
110
|
+
if (result) {
|
|
111
111
|
return false;
|
|
112
112
|
}
|
|
113
|
-
if (node.type !== mentionSchema || !isAgentUserType(node.attrs.userType) ||
|
|
113
|
+
if (node.type !== mentionSchema || !isAgentUserType(node.attrs.userType) || node.attrs.localId !== preferredLocalId) {
|
|
114
114
|
return true;
|
|
115
115
|
}
|
|
116
|
-
result = getAgentMentionDetailsAtPos(state, pos, attrs => attrs.
|
|
117
|
-
return
|
|
116
|
+
result = getAgentMentionDetailsAtPos(state, pos, attrs => attrs.localId === preferredLocalId, preferredName);
|
|
117
|
+
return !result;
|
|
118
118
|
});
|
|
119
119
|
return result;
|
|
120
120
|
};
|
|
@@ -171,6 +171,7 @@ const commitResolvedPendingTypedAgentMention = (pluginState, pendingMentionDetai
|
|
|
171
171
|
...pluginState,
|
|
172
172
|
pendingTypedAgentMention: null,
|
|
173
173
|
lastInsertedAgentMentionId: pendingMentionDetails.id,
|
|
174
|
+
lastInsertedAgentMentionLocalId: pendingMentionDetails.localId,
|
|
174
175
|
lastInsertedAgentMentionContext: pendingMentionDetails.context,
|
|
175
176
|
lastInsertedAgentMentionName: pendingMentionDetails.name,
|
|
176
177
|
lastInsertedAgentMentionParentNodeType: pendingMentionDetails.parentNodeType,
|
|
@@ -197,7 +198,7 @@ const commitPendingTypedAgentMention = (state, pluginState, pendingTypedAgentMen
|
|
|
197
198
|
}
|
|
198
199
|
return commitResolvedPendingTypedAgentMention(pluginState, pendingMentionDetails);
|
|
199
200
|
};
|
|
200
|
-
const hasTrackedAgentMentionState = pluginState => Boolean(pluginState.pendingTypedAgentMention) || pluginState.lastInsertedAgentMentionId != null || pluginState.lastInsertedAgentMentionContext != null || pluginState.lastInsertedAgentMentionName != null || pluginState.lastInsertedAgentMentionParentNodeType != null;
|
|
201
|
+
const hasTrackedAgentMentionState = pluginState => Boolean(pluginState.pendingTypedAgentMention) || pluginState.lastInsertedAgentMentionId != null || pluginState.lastInsertedAgentMentionLocalId != null || pluginState.lastInsertedAgentMentionContext != null || pluginState.lastInsertedAgentMentionName != null || pluginState.lastInsertedAgentMentionParentNodeType != null;
|
|
201
202
|
|
|
202
203
|
/**
|
|
203
204
|
* Clears agent mention state that points at a specific document snapshot.
|
|
@@ -209,6 +210,7 @@ const clearTrackedAgentMentionState = pluginState => {
|
|
|
209
210
|
...pluginState,
|
|
210
211
|
pendingTypedAgentMention: null,
|
|
211
212
|
lastInsertedAgentMentionId: null,
|
|
213
|
+
lastInsertedAgentMentionLocalId: null,
|
|
212
214
|
lastInsertedAgentMentionContext: null,
|
|
213
215
|
lastInsertedAgentMentionName: null,
|
|
214
216
|
lastInsertedAgentMentionParentNodeType: null
|
|
@@ -396,16 +398,15 @@ export function createMentionPlugin({
|
|
|
396
398
|
oldDocRanges.push(...stepOldRanges);
|
|
397
399
|
}
|
|
398
400
|
});
|
|
399
|
-
const shouldResolveAgentMentionState = stepsTouchMentions || Boolean(newPluginState.
|
|
401
|
+
const shouldResolveAgentMentionState = stepsTouchMentions || Boolean(newPluginState.lastInsertedAgentMentionLocalId);
|
|
400
402
|
if (shouldResolveAgentMentionState) {
|
|
401
|
-
var _newPluginState$
|
|
403
|
+
var _newPluginState$lastI, _newPluginState$lastA, _newPluginState$lastI2, _newPluginState$lastI3, _newPluginState$lastI4, _newPluginState$lastI5, _newPluginState$lastI6;
|
|
402
404
|
let agentMentionId = null;
|
|
405
|
+
let agentMentionLocalId = null;
|
|
403
406
|
let agentMentionContext = null;
|
|
404
407
|
let agentMentionName = null;
|
|
405
408
|
let agentMentionParentNodeType = null;
|
|
406
|
-
|
|
407
|
-
let oldAgentMentionId = null;
|
|
408
|
-
let oldCount = 0;
|
|
409
|
+
const existingAgentMentionLocalIdsInChangedRanges = new Set();
|
|
409
410
|
let pendingTypedAgentMentionDetails = null;
|
|
410
411
|
if (stepsTouchMentions) {
|
|
411
412
|
for (const [from, to] of newDocRanges) {
|
|
@@ -415,14 +416,14 @@ export function createMentionPlugin({
|
|
|
415
416
|
if (node.type !== mentionSchema || !isAgentUserType(node.attrs.userType)) {
|
|
416
417
|
return true;
|
|
417
418
|
}
|
|
418
|
-
newCount++;
|
|
419
419
|
if (pendingTypedAgentMentionDetails === null && action === ACTIONS.SET_PENDING_TYPED_AGENT_MENTION && node.attrs.localId === (params === null || params === void 0 ? void 0 : params.localId)) {
|
|
420
420
|
pendingTypedAgentMentionDetails = getAgentMentionDetailsAtPos(newState, pos, attrs => attrs.localId === params.localId, params.name);
|
|
421
421
|
}
|
|
422
|
-
if (
|
|
423
|
-
const agentMentionDetails = getAgentMentionDetailsAtPos(newState, pos, attrs => attrs.
|
|
422
|
+
if (agentMentionLocalId === null && node.attrs.localId) {
|
|
423
|
+
const agentMentionDetails = getAgentMentionDetailsAtPos(newState, pos, attrs => attrs.localId === node.attrs.localId, params === null || params === void 0 ? void 0 : params.name);
|
|
424
424
|
if (agentMentionDetails) {
|
|
425
425
|
agentMentionId = agentMentionDetails.id;
|
|
426
|
+
agentMentionLocalId = agentMentionDetails.localId;
|
|
426
427
|
agentMentionContext = agentMentionDetails.context;
|
|
427
428
|
agentMentionName = agentMentionDetails.name;
|
|
428
429
|
agentMentionParentNodeType = agentMentionDetails.parentNodeType;
|
|
@@ -438,9 +439,8 @@ export function createMentionPlugin({
|
|
|
438
439
|
if (node.type !== mentionSchema || !isAgentUserType(node.attrs.userType)) {
|
|
439
440
|
return true;
|
|
440
441
|
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
oldAgentMentionId = node.attrs.id;
|
|
442
|
+
if (node.attrs.localId) {
|
|
443
|
+
existingAgentMentionLocalIdsInChangedRanges.add(node.attrs.localId);
|
|
444
444
|
}
|
|
445
445
|
return true;
|
|
446
446
|
});
|
|
@@ -451,17 +451,37 @@ export function createMentionPlugin({
|
|
|
451
451
|
// the doc changed but no step covered the tracked mention, the new-doc scan
|
|
452
452
|
// above finds nothing. Check whether any agent mention survived in the document.
|
|
453
453
|
let resolvedFromFullDocFallback = false;
|
|
454
|
-
if (agentMentionId === null && newPluginState.
|
|
455
|
-
const survivorDetails = getSurvivingAgentMentionDetails(newState, newPluginState.
|
|
454
|
+
if (agentMentionId === null && newPluginState.lastInsertedAgentMentionLocalId) {
|
|
455
|
+
const survivorDetails = getSurvivingAgentMentionDetails(newState, newPluginState.lastInsertedAgentMentionLocalId, newPluginState.lastInsertedAgentMentionName);
|
|
456
456
|
if (survivorDetails) {
|
|
457
457
|
agentMentionId = survivorDetails.id;
|
|
458
|
+
agentMentionLocalId = survivorDetails.localId;
|
|
458
459
|
agentMentionContext = survivorDetails.context;
|
|
459
460
|
agentMentionName = survivorDetails.name;
|
|
460
461
|
agentMentionParentNodeType = survivorDetails.parentNodeType;
|
|
461
462
|
resolvedFromFullDocFallback = true;
|
|
462
463
|
}
|
|
463
464
|
}
|
|
464
|
-
const
|
|
465
|
+
const trackedAgentMentionLocalId = (_newPluginState$lastI = newPluginState.lastInsertedAgentMentionLocalId) !== null && _newPluginState$lastI !== void 0 ? _newPluginState$lastI : null;
|
|
466
|
+
const changedRangeMentionIsNew = agentMentionLocalId !== null && !existingAgentMentionLocalIdsInChangedRanges.has(agentMentionLocalId);
|
|
467
|
+
if (agentMentionLocalId !== null && !changedRangeMentionIsNew && agentMentionLocalId !== trackedAgentMentionLocalId) {
|
|
468
|
+
const survivorDetails = trackedAgentMentionLocalId ? getSurvivingAgentMentionDetails(newState, trackedAgentMentionLocalId, newPluginState.lastInsertedAgentMentionName) : null;
|
|
469
|
+
if (survivorDetails) {
|
|
470
|
+
agentMentionId = survivorDetails.id;
|
|
471
|
+
agentMentionLocalId = survivorDetails.localId;
|
|
472
|
+
agentMentionContext = survivorDetails.context;
|
|
473
|
+
agentMentionName = survivorDetails.name;
|
|
474
|
+
agentMentionParentNodeType = survivorDetails.parentNodeType;
|
|
475
|
+
resolvedFromFullDocFallback = true;
|
|
476
|
+
} else {
|
|
477
|
+
agentMentionId = null;
|
|
478
|
+
agentMentionLocalId = null;
|
|
479
|
+
agentMentionContext = null;
|
|
480
|
+
agentMentionName = null;
|
|
481
|
+
agentMentionParentNodeType = null;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
const isNewInsertion = agentMentionId !== null && !resolvedFromFullDocFallback && changedRangeMentionIsNew;
|
|
465
485
|
const isPendingTypedAgentMentionInsertion = isNewInsertion && action === ACTIONS.SET_PENDING_TYPED_AGENT_MENTION && typeof (params === null || params === void 0 ? void 0 : params.localId) === 'string';
|
|
466
486
|
const newInsertionCount = isNewInsertion ? ((_newPluginState$lastA = newPluginState.lastAgentMentionInsertionCount) !== null && _newPluginState$lastA !== void 0 ? _newPluginState$lastA : 0) + 1 : undefined;
|
|
467
487
|
const pendingTypedAgentMentionDetailsForState = pendingTypedAgentMentionDetails;
|
|
@@ -485,6 +505,7 @@ export function createMentionPlugin({
|
|
|
485
505
|
...newPluginState,
|
|
486
506
|
pendingTypedAgentMention: null,
|
|
487
507
|
lastInsertedAgentMentionId: agentMentionId,
|
|
508
|
+
lastInsertedAgentMentionLocalId: agentMentionLocalId,
|
|
488
509
|
lastInsertedAgentMentionContext: agentMentionContext,
|
|
489
510
|
lastInsertedAgentMentionName: agentMentionName,
|
|
490
511
|
lastInsertedAgentMentionParentNodeType: agentMentionParentNodeType,
|
|
@@ -493,10 +514,11 @@ export function createMentionPlugin({
|
|
|
493
514
|
} : {})
|
|
494
515
|
};
|
|
495
516
|
hasPublicPluginStateChanged = true;
|
|
496
|
-
} else if (agentMentionId !== ((_newPluginState$
|
|
517
|
+
} 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) || agentMentionContext !== ((_newPluginState$lastI4 = newPluginState.lastInsertedAgentMentionContext) !== null && _newPluginState$lastI4 !== void 0 ? _newPluginState$lastI4 : null) || agentMentionName !== ((_newPluginState$lastI5 = newPluginState.lastInsertedAgentMentionName) !== null && _newPluginState$lastI5 !== void 0 ? _newPluginState$lastI5 : null) || agentMentionParentNodeType !== ((_newPluginState$lastI6 = newPluginState.lastInsertedAgentMentionParentNodeType) !== null && _newPluginState$lastI6 !== void 0 ? _newPluginState$lastI6 : null) || newInsertionCount !== undefined) {
|
|
497
518
|
newPluginState = {
|
|
498
519
|
...newPluginState,
|
|
499
520
|
lastInsertedAgentMentionId: agentMentionId,
|
|
521
|
+
lastInsertedAgentMentionLocalId: agentMentionLocalId,
|
|
500
522
|
lastInsertedAgentMentionContext: agentMentionContext,
|
|
501
523
|
lastInsertedAgentMentionName: agentMentionName,
|
|
502
524
|
lastInsertedAgentMentionParentNodeType: agentMentionParentNodeType,
|
|
@@ -42,7 +42,7 @@ var getAgentMentionName = function getAgentMentionName(text, fallbackName) {
|
|
|
42
42
|
var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
|
|
43
43
|
var AGENT_MENTION_INACTIVITY_MS = 3000;
|
|
44
44
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
45
|
-
var PACKAGE_VERSION = "14.5.
|
|
45
|
+
var PACKAGE_VERSION = "14.5.5";
|
|
46
46
|
var setProvider = function setProvider(provider) {
|
|
47
47
|
return function (state, dispatch) {
|
|
48
48
|
if (dispatch) {
|
|
@@ -89,13 +89,14 @@ var getAgentMentionDetailsAtPos = function getAgentMentionDetailsAtPos(state, po
|
|
|
89
89
|
}
|
|
90
90
|
var node = state.doc.nodeAt(pos);
|
|
91
91
|
var mentionSchema = state.schema.nodes.mention;
|
|
92
|
-
if ((node === null || node === void 0 ? void 0 : node.type) !== mentionSchema || !isAgentUserType(node.attrs.userType) || !matchesMention(node.attrs) || !node.attrs.id) {
|
|
92
|
+
if ((node === null || node === void 0 ? void 0 : node.type) !== mentionSchema || !isAgentUserType(node.attrs.userType) || !matchesMention(node.attrs) || !node.attrs.id || !node.attrs.localId) {
|
|
93
93
|
return null;
|
|
94
94
|
}
|
|
95
95
|
var $mentionPos = state.doc.resolve(Math.min(pos + node.nodeSize, state.doc.content.size));
|
|
96
96
|
var parentNode = $mentionPos.node($mentionPos.depth);
|
|
97
97
|
return {
|
|
98
98
|
id: node.attrs.id,
|
|
99
|
+
localId: node.attrs.localId,
|
|
99
100
|
context: parentNode.textContent.trim() || null,
|
|
100
101
|
name: getAgentMentionName(node.attrs.text, fallbackName),
|
|
101
102
|
nodeSize: node.nodeSize,
|
|
@@ -108,24 +109,23 @@ var getAgentMentionDetailsAtPos = function getAgentMentionDetailsAtPos(state, po
|
|
|
108
109
|
|
|
109
110
|
/**
|
|
110
111
|
* Finds an agent mention that survived a document change when the changed-range
|
|
111
|
-
* scan did not find one.
|
|
112
|
-
*
|
|
112
|
+
* scan did not find one. Uses the tracked localId as the mention instance identity
|
|
113
|
+
* so same-agent mentions elsewhere in the document cannot be selected as fallback.
|
|
113
114
|
*/
|
|
114
|
-
var getSurvivingAgentMentionDetails = function getSurvivingAgentMentionDetails(state,
|
|
115
|
+
var getSurvivingAgentMentionDetails = function getSurvivingAgentMentionDetails(state, preferredLocalId, preferredName) {
|
|
115
116
|
var mentionSchema = state.schema.nodes.mention;
|
|
116
117
|
var result = null;
|
|
117
118
|
state.doc.descendants(function (node, pos) {
|
|
118
|
-
|
|
119
|
-
if (((_result = result) === null || _result === void 0 ? void 0 : _result.id) === preferredId) {
|
|
119
|
+
if (result) {
|
|
120
120
|
return false;
|
|
121
121
|
}
|
|
122
|
-
if (node.type !== mentionSchema || !isAgentUserType(node.attrs.userType) ||
|
|
122
|
+
if (node.type !== mentionSchema || !isAgentUserType(node.attrs.userType) || node.attrs.localId !== preferredLocalId) {
|
|
123
123
|
return true;
|
|
124
124
|
}
|
|
125
125
|
result = getAgentMentionDetailsAtPos(state, pos, function (attrs) {
|
|
126
|
-
return attrs.
|
|
127
|
-
},
|
|
128
|
-
return
|
|
126
|
+
return attrs.localId === preferredLocalId;
|
|
127
|
+
}, preferredName);
|
|
128
|
+
return !result;
|
|
129
129
|
});
|
|
130
130
|
return result;
|
|
131
131
|
};
|
|
@@ -184,6 +184,7 @@ var commitResolvedPendingTypedAgentMention = function commitResolvedPendingTyped
|
|
|
184
184
|
pluginState: _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
185
185
|
pendingTypedAgentMention: null,
|
|
186
186
|
lastInsertedAgentMentionId: pendingMentionDetails.id,
|
|
187
|
+
lastInsertedAgentMentionLocalId: pendingMentionDetails.localId,
|
|
187
188
|
lastInsertedAgentMentionContext: pendingMentionDetails.context,
|
|
188
189
|
lastInsertedAgentMentionName: pendingMentionDetails.name,
|
|
189
190
|
lastInsertedAgentMentionParentNodeType: pendingMentionDetails.parentNodeType,
|
|
@@ -212,7 +213,7 @@ var commitPendingTypedAgentMention = function commitPendingTypedAgentMention(sta
|
|
|
212
213
|
return commitResolvedPendingTypedAgentMention(pluginState, pendingMentionDetails);
|
|
213
214
|
};
|
|
214
215
|
var hasTrackedAgentMentionState = function hasTrackedAgentMentionState(pluginState) {
|
|
215
|
-
return Boolean(pluginState.pendingTypedAgentMention) || pluginState.lastInsertedAgentMentionId != null || pluginState.lastInsertedAgentMentionContext != null || pluginState.lastInsertedAgentMentionName != null || pluginState.lastInsertedAgentMentionParentNodeType != null;
|
|
216
|
+
return Boolean(pluginState.pendingTypedAgentMention) || pluginState.lastInsertedAgentMentionId != null || pluginState.lastInsertedAgentMentionLocalId != null || pluginState.lastInsertedAgentMentionContext != null || pluginState.lastInsertedAgentMentionName != null || pluginState.lastInsertedAgentMentionParentNodeType != null;
|
|
216
217
|
};
|
|
217
218
|
|
|
218
219
|
/**
|
|
@@ -224,6 +225,7 @@ var clearTrackedAgentMentionState = function clearTrackedAgentMentionState(plugi
|
|
|
224
225
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
225
226
|
pendingTypedAgentMention: null,
|
|
226
227
|
lastInsertedAgentMentionId: null,
|
|
228
|
+
lastInsertedAgentMentionLocalId: null,
|
|
227
229
|
lastInsertedAgentMentionContext: null,
|
|
228
230
|
lastInsertedAgentMentionName: null,
|
|
229
231
|
lastInsertedAgentMentionParentNodeType: null
|
|
@@ -408,16 +410,15 @@ export function createMentionPlugin(_ref2) {
|
|
|
408
410
|
oldDocRanges.push.apply(oldDocRanges, stepOldRanges);
|
|
409
411
|
}
|
|
410
412
|
});
|
|
411
|
-
var shouldResolveAgentMentionState = stepsTouchMentions || Boolean(newPluginState.
|
|
413
|
+
var shouldResolveAgentMentionState = stepsTouchMentions || Boolean(newPluginState.lastInsertedAgentMentionLocalId);
|
|
412
414
|
if (shouldResolveAgentMentionState) {
|
|
413
|
-
var _newPluginState$
|
|
415
|
+
var _newPluginState$lastI, _newPluginState$lastA, _newPluginState$lastI2, _newPluginState$lastI3, _newPluginState$lastI4, _newPluginState$lastI5, _newPluginState$lastI6;
|
|
414
416
|
var agentMentionId = null;
|
|
417
|
+
var agentMentionLocalId = null;
|
|
415
418
|
var agentMentionContext = null;
|
|
416
419
|
var agentMentionName = null;
|
|
417
420
|
var agentMentionParentNodeType = null;
|
|
418
|
-
var
|
|
419
|
-
var oldAgentMentionId = null;
|
|
420
|
-
var oldCount = 0;
|
|
421
|
+
var existingAgentMentionLocalIdsInChangedRanges = new Set();
|
|
421
422
|
var pendingTypedAgentMentionDetails = null;
|
|
422
423
|
if (stepsTouchMentions) {
|
|
423
424
|
var _iterator = _createForOfIteratorHelper(newDocRanges),
|
|
@@ -433,18 +434,18 @@ export function createMentionPlugin(_ref2) {
|
|
|
433
434
|
if (node.type !== _mentionSchema || !isAgentUserType(node.attrs.userType)) {
|
|
434
435
|
return true;
|
|
435
436
|
}
|
|
436
|
-
newCount++;
|
|
437
437
|
if (pendingTypedAgentMentionDetails === null && action === ACTIONS.SET_PENDING_TYPED_AGENT_MENTION && node.attrs.localId === (params === null || params === void 0 ? void 0 : params.localId)) {
|
|
438
438
|
pendingTypedAgentMentionDetails = getAgentMentionDetailsAtPos(newState, pos, function (attrs) {
|
|
439
439
|
return attrs.localId === params.localId;
|
|
440
440
|
}, params.name);
|
|
441
441
|
}
|
|
442
|
-
if (
|
|
442
|
+
if (agentMentionLocalId === null && node.attrs.localId) {
|
|
443
443
|
var agentMentionDetails = getAgentMentionDetailsAtPos(newState, pos, function (attrs) {
|
|
444
|
-
return attrs.
|
|
444
|
+
return attrs.localId === node.attrs.localId;
|
|
445
445
|
}, params === null || params === void 0 ? void 0 : params.name);
|
|
446
446
|
if (agentMentionDetails) {
|
|
447
447
|
agentMentionId = agentMentionDetails.id;
|
|
448
|
+
agentMentionLocalId = agentMentionDetails.localId;
|
|
448
449
|
agentMentionContext = agentMentionDetails.context;
|
|
449
450
|
agentMentionName = agentMentionDetails.name;
|
|
450
451
|
agentMentionParentNodeType = agentMentionDetails.parentNodeType;
|
|
@@ -471,9 +472,8 @@ export function createMentionPlugin(_ref2) {
|
|
|
471
472
|
if (node.type !== _mentionSchema || !isAgentUserType(node.attrs.userType)) {
|
|
472
473
|
return true;
|
|
473
474
|
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
oldAgentMentionId = node.attrs.id;
|
|
475
|
+
if (node.attrs.localId) {
|
|
476
|
+
existingAgentMentionLocalIdsInChangedRanges.add(node.attrs.localId);
|
|
477
477
|
}
|
|
478
478
|
return true;
|
|
479
479
|
});
|
|
@@ -489,17 +489,37 @@ export function createMentionPlugin(_ref2) {
|
|
|
489
489
|
// the doc changed but no step covered the tracked mention, the new-doc scan
|
|
490
490
|
// above finds nothing. Check whether any agent mention survived in the document.
|
|
491
491
|
var resolvedFromFullDocFallback = false;
|
|
492
|
-
if (agentMentionId === null && newPluginState.
|
|
493
|
-
var survivorDetails = getSurvivingAgentMentionDetails(newState, newPluginState.
|
|
492
|
+
if (agentMentionId === null && newPluginState.lastInsertedAgentMentionLocalId) {
|
|
493
|
+
var survivorDetails = getSurvivingAgentMentionDetails(newState, newPluginState.lastInsertedAgentMentionLocalId, newPluginState.lastInsertedAgentMentionName);
|
|
494
494
|
if (survivorDetails) {
|
|
495
495
|
agentMentionId = survivorDetails.id;
|
|
496
|
+
agentMentionLocalId = survivorDetails.localId;
|
|
496
497
|
agentMentionContext = survivorDetails.context;
|
|
497
498
|
agentMentionName = survivorDetails.name;
|
|
498
499
|
agentMentionParentNodeType = survivorDetails.parentNodeType;
|
|
499
500
|
resolvedFromFullDocFallback = true;
|
|
500
501
|
}
|
|
501
502
|
}
|
|
502
|
-
var
|
|
503
|
+
var trackedAgentMentionLocalId = (_newPluginState$lastI = newPluginState.lastInsertedAgentMentionLocalId) !== null && _newPluginState$lastI !== void 0 ? _newPluginState$lastI : null;
|
|
504
|
+
var changedRangeMentionIsNew = agentMentionLocalId !== null && !existingAgentMentionLocalIdsInChangedRanges.has(agentMentionLocalId);
|
|
505
|
+
if (agentMentionLocalId !== null && !changedRangeMentionIsNew && agentMentionLocalId !== trackedAgentMentionLocalId) {
|
|
506
|
+
var _survivorDetails = trackedAgentMentionLocalId ? getSurvivingAgentMentionDetails(newState, trackedAgentMentionLocalId, newPluginState.lastInsertedAgentMentionName) : null;
|
|
507
|
+
if (_survivorDetails) {
|
|
508
|
+
agentMentionId = _survivorDetails.id;
|
|
509
|
+
agentMentionLocalId = _survivorDetails.localId;
|
|
510
|
+
agentMentionContext = _survivorDetails.context;
|
|
511
|
+
agentMentionName = _survivorDetails.name;
|
|
512
|
+
agentMentionParentNodeType = _survivorDetails.parentNodeType;
|
|
513
|
+
resolvedFromFullDocFallback = true;
|
|
514
|
+
} else {
|
|
515
|
+
agentMentionId = null;
|
|
516
|
+
agentMentionLocalId = null;
|
|
517
|
+
agentMentionContext = null;
|
|
518
|
+
agentMentionName = null;
|
|
519
|
+
agentMentionParentNodeType = null;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
var isNewInsertion = agentMentionId !== null && !resolvedFromFullDocFallback && changedRangeMentionIsNew;
|
|
503
523
|
var isPendingTypedAgentMentionInsertion = isNewInsertion && action === ACTIONS.SET_PENDING_TYPED_AGENT_MENTION && typeof (params === null || params === void 0 ? void 0 : params.localId) === 'string';
|
|
504
524
|
var newInsertionCount = isNewInsertion ? ((_newPluginState$lastA = newPluginState.lastAgentMentionInsertionCount) !== null && _newPluginState$lastA !== void 0 ? _newPluginState$lastA : 0) + 1 : undefined;
|
|
505
525
|
var pendingTypedAgentMentionDetailsForState = pendingTypedAgentMentionDetails;
|
|
@@ -521,6 +541,7 @@ export function createMentionPlugin(_ref2) {
|
|
|
521
541
|
newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
|
|
522
542
|
pendingTypedAgentMention: null,
|
|
523
543
|
lastInsertedAgentMentionId: agentMentionId,
|
|
544
|
+
lastInsertedAgentMentionLocalId: agentMentionLocalId,
|
|
524
545
|
lastInsertedAgentMentionContext: agentMentionContext,
|
|
525
546
|
lastInsertedAgentMentionName: agentMentionName,
|
|
526
547
|
lastInsertedAgentMentionParentNodeType: agentMentionParentNodeType
|
|
@@ -528,9 +549,10 @@ export function createMentionPlugin(_ref2) {
|
|
|
528
549
|
lastAgentMentionInsertionCount: newInsertionCount
|
|
529
550
|
} : {});
|
|
530
551
|
hasPublicPluginStateChanged = true;
|
|
531
|
-
} else if (agentMentionId !== ((_newPluginState$
|
|
552
|
+
} 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) || agentMentionContext !== ((_newPluginState$lastI4 = newPluginState.lastInsertedAgentMentionContext) !== null && _newPluginState$lastI4 !== void 0 ? _newPluginState$lastI4 : null) || agentMentionName !== ((_newPluginState$lastI5 = newPluginState.lastInsertedAgentMentionName) !== null && _newPluginState$lastI5 !== void 0 ? _newPluginState$lastI5 : null) || agentMentionParentNodeType !== ((_newPluginState$lastI6 = newPluginState.lastInsertedAgentMentionParentNodeType) !== null && _newPluginState$lastI6 !== void 0 ? _newPluginState$lastI6 : null) || newInsertionCount !== undefined) {
|
|
532
553
|
newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
|
|
533
554
|
lastInsertedAgentMentionId: agentMentionId,
|
|
555
|
+
lastInsertedAgentMentionLocalId: agentMentionLocalId,
|
|
534
556
|
lastInsertedAgentMentionContext: agentMentionContext,
|
|
535
557
|
lastInsertedAgentMentionName: agentMentionName,
|
|
536
558
|
lastInsertedAgentMentionParentNodeType: agentMentionParentNodeType
|
|
@@ -46,6 +46,7 @@ export type MentionPluginOptions = MentionsPluginOptions;
|
|
|
46
46
|
export type AgentMentionDetails = {
|
|
47
47
|
context: string | null;
|
|
48
48
|
id: string;
|
|
49
|
+
localId: string;
|
|
49
50
|
name: string | null;
|
|
50
51
|
nodeSize: number;
|
|
51
52
|
/**
|
|
@@ -76,6 +77,11 @@ export type MentionPluginState = {
|
|
|
76
77
|
* Null when no agent mention is present in the document.
|
|
77
78
|
*/
|
|
78
79
|
lastInsertedAgentMentionId?: string | null;
|
|
80
|
+
/**
|
|
81
|
+
* The local document-instance ID of the most recently inserted agent mention.
|
|
82
|
+
* Used to distinguish multiple mentions of the same agent AAID.
|
|
83
|
+
*/
|
|
84
|
+
lastInsertedAgentMentionLocalId?: string | null;
|
|
79
85
|
/**
|
|
80
86
|
* Display name of the most recently inserted agent mention.
|
|
81
87
|
* Derived from the mention node text and used for Rovo nudge copy.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-mentions",
|
|
3
|
-
"version": "14.5.
|
|
3
|
+
"version": "14.5.6",
|
|
4
4
|
"description": "Mentions plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"uuid": "^3.1.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@atlaskit/editor-common": "^116.
|
|
56
|
+
"@atlaskit/editor-common": "^116.19.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"
|