@atlaskit/editor-plugin-mentions 14.4.1 → 14.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/pm-plugins/main.js +34 -13
- package/dist/cjs/ui/type-ahead/index.js +2 -1
- package/dist/es2019/pm-plugins/main.js +43 -20
- package/dist/es2019/ui/type-ahead/index.js +2 -1
- package/dist/esm/pm-plugins/main.js +34 -13
- package/dist/esm/ui/type-ahead/index.js +2 -1
- package/dist/types/types/index.d.ts +7 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-mentions
|
|
2
2
|
|
|
3
|
+
## 14.4.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 14.4.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`484e372703a0e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/484e372703a0e) -
|
|
14
|
+
[ux] EDITOR-7822: add agent name to nudge
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 14.4.1
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -36,10 +36,21 @@ var AGENT_USER_TYPES = new Set(['APP', 'AGENT']);
|
|
|
36
36
|
var isAgentUserType = function isAgentUserType(userType) {
|
|
37
37
|
return typeof userType === 'string' && AGENT_USER_TYPES.has(userType);
|
|
38
38
|
};
|
|
39
|
+
var getAgentMentionName = function getAgentMentionName(text, fallbackName) {
|
|
40
|
+
var trimmedFallbackName = typeof fallbackName === 'string' ? fallbackName.trim() : '';
|
|
41
|
+
var normalizedFallbackName = (trimmedFallbackName.startsWith('@') ? trimmedFallbackName.slice(1).trim() : trimmedFallbackName) || null;
|
|
42
|
+
if (typeof text !== 'string') {
|
|
43
|
+
return normalizedFallbackName;
|
|
44
|
+
}
|
|
45
|
+
var trimmedText = text.trim();
|
|
46
|
+
var displayName = trimmedText.startsWith('@') ? trimmedText.slice(1).trim() : trimmedText;
|
|
47
|
+
var normalizedName = displayName || normalizedFallbackName;
|
|
48
|
+
return normalizedName;
|
|
49
|
+
};
|
|
39
50
|
var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
|
|
40
51
|
var AGENT_MENTION_INACTIVITY_MS = 3000;
|
|
41
52
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
42
|
-
var PACKAGE_VERSION = "14.4.
|
|
53
|
+
var PACKAGE_VERSION = "14.4.2";
|
|
43
54
|
var setProvider = function setProvider(provider) {
|
|
44
55
|
return function (state, dispatch) {
|
|
45
56
|
if (dispatch) {
|
|
@@ -79,7 +90,7 @@ var isLocalSelectionChange = function isLocalSelectionChange(tr, hasPositionChan
|
|
|
79
90
|
* the document. Callers pass a matcher so mapped positions are only accepted
|
|
80
91
|
* when they still point at the same pending/tracked mention.
|
|
81
92
|
*/
|
|
82
|
-
var getAgentMentionDetailsAtPos = function getAgentMentionDetailsAtPos(state, pos, matchesMention) {
|
|
93
|
+
var getAgentMentionDetailsAtPos = function getAgentMentionDetailsAtPos(state, pos, matchesMention, fallbackName) {
|
|
83
94
|
var _parentNode$type$name;
|
|
84
95
|
if (pos < 0 || pos > state.doc.content.size) {
|
|
85
96
|
return null;
|
|
@@ -94,6 +105,7 @@ var getAgentMentionDetailsAtPos = function getAgentMentionDetailsAtPos(state, po
|
|
|
94
105
|
return {
|
|
95
106
|
id: node.attrs.id,
|
|
96
107
|
context: parentNode.textContent.trim() || null,
|
|
108
|
+
name: getAgentMentionName(node.attrs.text, fallbackName),
|
|
97
109
|
nodeSize: node.nodeSize,
|
|
98
110
|
parentEnd: $mentionPos.end($mentionPos.depth),
|
|
99
111
|
parentNodeType: (_parentNode$type$name = parentNode.type.name) !== null && _parentNode$type$name !== void 0 ? _parentNode$type$name : null,
|
|
@@ -107,7 +119,7 @@ var getAgentMentionDetailsAtPos = function getAgentMentionDetailsAtPos(state, po
|
|
|
107
119
|
* scan did not find one. Prefers the previously tracked mention ID when present;
|
|
108
120
|
* otherwise returns a surviving agent mention using the existing traversal order.
|
|
109
121
|
*/
|
|
110
|
-
var getSurvivingAgentMentionDetails = function getSurvivingAgentMentionDetails(state, preferredId) {
|
|
122
|
+
var getSurvivingAgentMentionDetails = function getSurvivingAgentMentionDetails(state, preferredId, preferredName) {
|
|
111
123
|
var mentionSchema = state.schema.nodes.mention;
|
|
112
124
|
var result = null;
|
|
113
125
|
state.doc.descendants(function (node, pos) {
|
|
@@ -120,7 +132,7 @@ var getSurvivingAgentMentionDetails = function getSurvivingAgentMentionDetails(s
|
|
|
120
132
|
}
|
|
121
133
|
result = getAgentMentionDetailsAtPos(state, pos, function (attrs) {
|
|
122
134
|
return attrs.id === node.attrs.id;
|
|
123
|
-
});
|
|
135
|
+
}, node.attrs.id === preferredId ? preferredName : undefined);
|
|
124
136
|
return ((_result2 = result) === null || _result2 === void 0 ? void 0 : _result2.id) !== preferredId;
|
|
125
137
|
});
|
|
126
138
|
return result;
|
|
@@ -140,10 +152,11 @@ var getPendingTypedAgentMentionAfterDocChange = function getPendingTypedAgentMen
|
|
|
140
152
|
}
|
|
141
153
|
var pendingMentionDetails = getAgentMentionDetailsAtPos(state, mappedPos.pos, function (attrs) {
|
|
142
154
|
return attrs.localId === pendingTypedAgentMention.localId;
|
|
143
|
-
});
|
|
155
|
+
}, pendingTypedAgentMention.name);
|
|
144
156
|
return pendingMentionDetails ? {
|
|
145
157
|
id: pendingMentionDetails.id,
|
|
146
158
|
localId: pendingTypedAgentMention.localId,
|
|
159
|
+
name: pendingMentionDetails.name,
|
|
147
160
|
nodeSize: pendingMentionDetails.nodeSize,
|
|
148
161
|
pos: pendingMentionDetails.pos,
|
|
149
162
|
resetCount: resetCount
|
|
@@ -180,6 +193,7 @@ var commitResolvedPendingTypedAgentMention = function commitResolvedPendingTyped
|
|
|
180
193
|
pendingTypedAgentMention: null,
|
|
181
194
|
lastInsertedAgentMentionId: pendingMentionDetails.id,
|
|
182
195
|
lastInsertedAgentMentionContext: pendingMentionDetails.context,
|
|
196
|
+
lastInsertedAgentMentionName: pendingMentionDetails.name,
|
|
183
197
|
lastInsertedAgentMentionParentNodeType: pendingMentionDetails.parentNodeType,
|
|
184
198
|
lastAgentMentionInsertionCount: ((_pluginState$lastAgen = pluginState.lastAgentMentionInsertionCount) !== null && _pluginState$lastAgen !== void 0 ? _pluginState$lastAgen : 0) + 1
|
|
185
199
|
})
|
|
@@ -194,7 +208,7 @@ var commitResolvedPendingTypedAgentMention = function commitResolvedPendingTyped
|
|
|
194
208
|
var commitPendingTypedAgentMention = function commitPendingTypedAgentMention(state, pluginState, pendingTypedAgentMention) {
|
|
195
209
|
var pendingMentionDetails = getAgentMentionDetailsAtPos(state, pendingTypedAgentMention.pos, function (attrs) {
|
|
196
210
|
return attrs.localId === pendingTypedAgentMention.localId;
|
|
197
|
-
});
|
|
211
|
+
}, pendingTypedAgentMention.name);
|
|
198
212
|
if (!pendingMentionDetails) {
|
|
199
213
|
return {
|
|
200
214
|
hasPublicPluginStateChanged: false,
|
|
@@ -206,7 +220,7 @@ var commitPendingTypedAgentMention = function commitPendingTypedAgentMention(sta
|
|
|
206
220
|
return commitResolvedPendingTypedAgentMention(pluginState, pendingMentionDetails);
|
|
207
221
|
};
|
|
208
222
|
var hasTrackedAgentMentionState = function hasTrackedAgentMentionState(pluginState) {
|
|
209
|
-
return Boolean(pluginState.pendingTypedAgentMention) || pluginState.lastInsertedAgentMentionId != null || pluginState.lastInsertedAgentMentionContext != null || pluginState.lastInsertedAgentMentionParentNodeType != null;
|
|
223
|
+
return Boolean(pluginState.pendingTypedAgentMention) || pluginState.lastInsertedAgentMentionId != null || pluginState.lastInsertedAgentMentionContext != null || pluginState.lastInsertedAgentMentionName != null || pluginState.lastInsertedAgentMentionParentNodeType != null;
|
|
210
224
|
};
|
|
211
225
|
|
|
212
226
|
/**
|
|
@@ -219,6 +233,7 @@ var clearTrackedAgentMentionState = function clearTrackedAgentMentionState(plugi
|
|
|
219
233
|
pendingTypedAgentMention: null,
|
|
220
234
|
lastInsertedAgentMentionId: null,
|
|
221
235
|
lastInsertedAgentMentionContext: null,
|
|
236
|
+
lastInsertedAgentMentionName: null,
|
|
222
237
|
lastInsertedAgentMentionParentNodeType: null
|
|
223
238
|
});
|
|
224
239
|
};
|
|
@@ -403,9 +418,10 @@ function createMentionPlugin(_ref2) {
|
|
|
403
418
|
});
|
|
404
419
|
var shouldResolveAgentMentionState = stepsTouchMentions || Boolean(newPluginState.lastInsertedAgentMentionId);
|
|
405
420
|
if (shouldResolveAgentMentionState) {
|
|
406
|
-
var _newPluginState$lastA, _newPluginState$lastI, _newPluginState$lastI2, _newPluginState$lastI3;
|
|
421
|
+
var _newPluginState$lastA, _newPluginState$lastI, _newPluginState$lastI2, _newPluginState$lastI3, _newPluginState$lastI4;
|
|
407
422
|
var agentMentionId = null;
|
|
408
423
|
var agentMentionContext = null;
|
|
424
|
+
var agentMentionName = null;
|
|
409
425
|
var agentMentionParentNodeType = null;
|
|
410
426
|
var newCount = 0;
|
|
411
427
|
var oldAgentMentionId = null;
|
|
@@ -429,15 +445,16 @@ function createMentionPlugin(_ref2) {
|
|
|
429
445
|
if (pendingTypedAgentMentionDetails === null && action === ACTIONS.SET_PENDING_TYPED_AGENT_MENTION && node.attrs.localId === (params === null || params === void 0 ? void 0 : params.localId)) {
|
|
430
446
|
pendingTypedAgentMentionDetails = getAgentMentionDetailsAtPos(newState, pos, function (attrs) {
|
|
431
447
|
return attrs.localId === params.localId;
|
|
432
|
-
});
|
|
448
|
+
}, params.name);
|
|
433
449
|
}
|
|
434
450
|
if (agentMentionId === null && node.attrs.id) {
|
|
435
451
|
var agentMentionDetails = getAgentMentionDetailsAtPos(newState, pos, function (attrs) {
|
|
436
452
|
return attrs.id === node.attrs.id;
|
|
437
|
-
});
|
|
453
|
+
}, params === null || params === void 0 ? void 0 : params.name);
|
|
438
454
|
if (agentMentionDetails) {
|
|
439
455
|
agentMentionId = agentMentionDetails.id;
|
|
440
456
|
agentMentionContext = agentMentionDetails.context;
|
|
457
|
+
agentMentionName = agentMentionDetails.name;
|
|
441
458
|
agentMentionParentNodeType = agentMentionDetails.parentNodeType;
|
|
442
459
|
}
|
|
443
460
|
}
|
|
@@ -481,10 +498,11 @@ function createMentionPlugin(_ref2) {
|
|
|
481
498
|
// above finds nothing. Check whether any agent mention survived in the document.
|
|
482
499
|
var resolvedFromFullDocFallback = false;
|
|
483
500
|
if (agentMentionId === null && newPluginState.lastInsertedAgentMentionId) {
|
|
484
|
-
var survivorDetails = getSurvivingAgentMentionDetails(newState, newPluginState.lastInsertedAgentMentionId);
|
|
501
|
+
var survivorDetails = getSurvivingAgentMentionDetails(newState, newPluginState.lastInsertedAgentMentionId, newPluginState.lastInsertedAgentMentionName);
|
|
485
502
|
if (survivorDetails) {
|
|
486
503
|
agentMentionId = survivorDetails.id;
|
|
487
504
|
agentMentionContext = survivorDetails.context;
|
|
505
|
+
agentMentionName = survivorDetails.name;
|
|
488
506
|
agentMentionParentNodeType = survivorDetails.parentNodeType;
|
|
489
507
|
resolvedFromFullDocFallback = true;
|
|
490
508
|
}
|
|
@@ -499,6 +517,7 @@ function createMentionPlugin(_ref2) {
|
|
|
499
517
|
pendingTypedAgentMention: {
|
|
500
518
|
id: pendingTypedAgentMentionDetailsForState.id,
|
|
501
519
|
localId: pendingTypedAgentMentionLocalId,
|
|
520
|
+
name: pendingTypedAgentMentionDetailsForState.name,
|
|
502
521
|
nodeSize: pendingTypedAgentMentionDetailsForState.nodeSize,
|
|
503
522
|
pos: pendingTypedAgentMentionDetailsForState.pos,
|
|
504
523
|
resetCount: 1
|
|
@@ -511,15 +530,17 @@ function createMentionPlugin(_ref2) {
|
|
|
511
530
|
pendingTypedAgentMention: null,
|
|
512
531
|
lastInsertedAgentMentionId: agentMentionId,
|
|
513
532
|
lastInsertedAgentMentionContext: agentMentionContext,
|
|
533
|
+
lastInsertedAgentMentionName: agentMentionName,
|
|
514
534
|
lastInsertedAgentMentionParentNodeType: agentMentionParentNodeType
|
|
515
535
|
}, newInsertionCount !== undefined ? {
|
|
516
536
|
lastAgentMentionInsertionCount: newInsertionCount
|
|
517
537
|
} : {});
|
|
518
538
|
hasPublicPluginStateChanged = true;
|
|
519
|
-
} else if (agentMentionId !== ((_newPluginState$lastI = newPluginState.lastInsertedAgentMentionId) !== null && _newPluginState$lastI !== void 0 ? _newPluginState$lastI : null) || agentMentionContext !== ((_newPluginState$lastI2 = newPluginState.lastInsertedAgentMentionContext) !== null && _newPluginState$lastI2 !== void 0 ? _newPluginState$lastI2 : null) ||
|
|
539
|
+
} else if (agentMentionId !== ((_newPluginState$lastI = newPluginState.lastInsertedAgentMentionId) !== null && _newPluginState$lastI !== void 0 ? _newPluginState$lastI : null) || agentMentionContext !== ((_newPluginState$lastI2 = newPluginState.lastInsertedAgentMentionContext) !== null && _newPluginState$lastI2 !== void 0 ? _newPluginState$lastI2 : null) || agentMentionName !== ((_newPluginState$lastI3 = newPluginState.lastInsertedAgentMentionName) !== null && _newPluginState$lastI3 !== void 0 ? _newPluginState$lastI3 : null) || agentMentionParentNodeType !== ((_newPluginState$lastI4 = newPluginState.lastInsertedAgentMentionParentNodeType) !== null && _newPluginState$lastI4 !== void 0 ? _newPluginState$lastI4 : null) || newInsertionCount !== undefined) {
|
|
520
540
|
newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
|
|
521
541
|
lastInsertedAgentMentionId: agentMentionId,
|
|
522
542
|
lastInsertedAgentMentionContext: agentMentionContext,
|
|
543
|
+
lastInsertedAgentMentionName: agentMentionName,
|
|
523
544
|
lastInsertedAgentMentionParentNodeType: agentMentionParentNodeType
|
|
524
545
|
}, newInsertionCount !== undefined ? {
|
|
525
546
|
lastAgentMentionInsertionCount: newInsertionCount
|
|
@@ -549,7 +570,7 @@ function createMentionPlugin(_ref2) {
|
|
|
549
570
|
var _pendingTypedAgentMention = newPluginState.pendingTypedAgentMention;
|
|
550
571
|
var pendingMentionDetails = getAgentMentionDetailsAtPos(newState, _pendingTypedAgentMention.pos, function (attrs) {
|
|
551
572
|
return attrs.localId === _pendingTypedAgentMention.localId;
|
|
552
|
-
});
|
|
573
|
+
}, _pendingTypedAgentMention.name);
|
|
553
574
|
if (!pendingMentionDetails) {
|
|
554
575
|
newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
|
|
555
576
|
pendingTypedAgentMention: null
|
|
@@ -529,7 +529,8 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
|
|
|
529
529
|
tr.setMeta(_key.mentionPluginKey, {
|
|
530
530
|
action: _main.ACTIONS.SET_PENDING_TYPED_AGENT_MENTION,
|
|
531
531
|
params: {
|
|
532
|
-
localId: mentionLocalId
|
|
532
|
+
localId: mentionLocalId,
|
|
533
|
+
name: name
|
|
533
534
|
}
|
|
534
535
|
});
|
|
535
536
|
}
|
|
@@ -21,10 +21,21 @@ const AGENT_USER_TYPES = new Set(['APP', 'AGENT']);
|
|
|
21
21
|
const isAgentUserType = userType => {
|
|
22
22
|
return typeof userType === 'string' && AGENT_USER_TYPES.has(userType);
|
|
23
23
|
};
|
|
24
|
+
const getAgentMentionName = (text, fallbackName) => {
|
|
25
|
+
const trimmedFallbackName = typeof fallbackName === 'string' ? fallbackName.trim() : '';
|
|
26
|
+
const normalizedFallbackName = (trimmedFallbackName.startsWith('@') ? trimmedFallbackName.slice(1).trim() : trimmedFallbackName) || null;
|
|
27
|
+
if (typeof text !== 'string') {
|
|
28
|
+
return normalizedFallbackName;
|
|
29
|
+
}
|
|
30
|
+
const trimmedText = text.trim();
|
|
31
|
+
const displayName = trimmedText.startsWith('@') ? trimmedText.slice(1).trim() : trimmedText;
|
|
32
|
+
const normalizedName = displayName || normalizedFallbackName;
|
|
33
|
+
return normalizedName;
|
|
34
|
+
};
|
|
24
35
|
const AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
|
|
25
36
|
const AGENT_MENTION_INACTIVITY_MS = 3000;
|
|
26
37
|
const PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
27
|
-
const PACKAGE_VERSION = "14.4.
|
|
38
|
+
const PACKAGE_VERSION = "14.4.2";
|
|
28
39
|
const setProvider = provider => (state, dispatch) => {
|
|
29
40
|
if (dispatch) {
|
|
30
41
|
dispatch(state.tr.setMeta(mentionPluginKey, {
|
|
@@ -62,7 +73,7 @@ const isLocalSelectionChange = (tr, hasPositionChanged) => {
|
|
|
62
73
|
* the document. Callers pass a matcher so mapped positions are only accepted
|
|
63
74
|
* when they still point at the same pending/tracked mention.
|
|
64
75
|
*/
|
|
65
|
-
const getAgentMentionDetailsAtPos = (state, pos, matchesMention) => {
|
|
76
|
+
const getAgentMentionDetailsAtPos = (state, pos, matchesMention, fallbackName) => {
|
|
66
77
|
var _parentNode$type$name;
|
|
67
78
|
if (pos < 0 || pos > state.doc.content.size) {
|
|
68
79
|
return null;
|
|
@@ -77,6 +88,7 @@ const getAgentMentionDetailsAtPos = (state, pos, matchesMention) => {
|
|
|
77
88
|
return {
|
|
78
89
|
id: node.attrs.id,
|
|
79
90
|
context: parentNode.textContent.trim() || null,
|
|
91
|
+
name: getAgentMentionName(node.attrs.text, fallbackName),
|
|
80
92
|
nodeSize: node.nodeSize,
|
|
81
93
|
parentEnd: $mentionPos.end($mentionPos.depth),
|
|
82
94
|
parentNodeType: (_parentNode$type$name = parentNode.type.name) !== null && _parentNode$type$name !== void 0 ? _parentNode$type$name : null,
|
|
@@ -90,7 +102,7 @@ const getAgentMentionDetailsAtPos = (state, pos, matchesMention) => {
|
|
|
90
102
|
* scan did not find one. Prefers the previously tracked mention ID when present;
|
|
91
103
|
* otherwise returns a surviving agent mention using the existing traversal order.
|
|
92
104
|
*/
|
|
93
|
-
const getSurvivingAgentMentionDetails = (state, preferredId) => {
|
|
105
|
+
const getSurvivingAgentMentionDetails = (state, preferredId, preferredName) => {
|
|
94
106
|
const mentionSchema = state.schema.nodes.mention;
|
|
95
107
|
let result = null;
|
|
96
108
|
state.doc.descendants((node, pos) => {
|
|
@@ -101,7 +113,7 @@ const getSurvivingAgentMentionDetails = (state, preferredId) => {
|
|
|
101
113
|
if (node.type !== mentionSchema || !isAgentUserType(node.attrs.userType) || !node.attrs.id) {
|
|
102
114
|
return true;
|
|
103
115
|
}
|
|
104
|
-
result = getAgentMentionDetailsAtPos(state, pos, attrs => attrs.id === node.attrs.id);
|
|
116
|
+
result = getAgentMentionDetailsAtPos(state, pos, attrs => attrs.id === node.attrs.id, node.attrs.id === preferredId ? preferredName : undefined);
|
|
105
117
|
return ((_result2 = result) === null || _result2 === void 0 ? void 0 : _result2.id) !== preferredId;
|
|
106
118
|
});
|
|
107
119
|
return result;
|
|
@@ -120,10 +132,11 @@ const getPendingTypedAgentMentionAfterDocChange = (state, tr, pendingTypedAgentM
|
|
|
120
132
|
if (mappedPos.deleted) {
|
|
121
133
|
return null;
|
|
122
134
|
}
|
|
123
|
-
const pendingMentionDetails = getAgentMentionDetailsAtPos(state, mappedPos.pos, attrs => attrs.localId === pendingTypedAgentMention.localId);
|
|
135
|
+
const pendingMentionDetails = getAgentMentionDetailsAtPos(state, mappedPos.pos, attrs => attrs.localId === pendingTypedAgentMention.localId, pendingTypedAgentMention.name);
|
|
124
136
|
return pendingMentionDetails ? {
|
|
125
137
|
id: pendingMentionDetails.id,
|
|
126
138
|
localId: pendingTypedAgentMention.localId,
|
|
139
|
+
name: pendingMentionDetails.name,
|
|
127
140
|
nodeSize: pendingMentionDetails.nodeSize,
|
|
128
141
|
pos: pendingMentionDetails.pos,
|
|
129
142
|
resetCount
|
|
@@ -159,6 +172,7 @@ const commitResolvedPendingTypedAgentMention = (pluginState, pendingMentionDetai
|
|
|
159
172
|
pendingTypedAgentMention: null,
|
|
160
173
|
lastInsertedAgentMentionId: pendingMentionDetails.id,
|
|
161
174
|
lastInsertedAgentMentionContext: pendingMentionDetails.context,
|
|
175
|
+
lastInsertedAgentMentionName: pendingMentionDetails.name,
|
|
162
176
|
lastInsertedAgentMentionParentNodeType: pendingMentionDetails.parentNodeType,
|
|
163
177
|
lastAgentMentionInsertionCount: ((_pluginState$lastAgen = pluginState.lastAgentMentionInsertionCount) !== null && _pluginState$lastAgen !== void 0 ? _pluginState$lastAgen : 0) + 1
|
|
164
178
|
}
|
|
@@ -171,7 +185,7 @@ const commitResolvedPendingTypedAgentMention = (pluginState, pendingMentionDetai
|
|
|
171
185
|
* public update.
|
|
172
186
|
*/
|
|
173
187
|
const commitPendingTypedAgentMention = (state, pluginState, pendingTypedAgentMention) => {
|
|
174
|
-
const pendingMentionDetails = getAgentMentionDetailsAtPos(state, pendingTypedAgentMention.pos, attrs => attrs.localId === pendingTypedAgentMention.localId);
|
|
188
|
+
const pendingMentionDetails = getAgentMentionDetailsAtPos(state, pendingTypedAgentMention.pos, attrs => attrs.localId === pendingTypedAgentMention.localId, pendingTypedAgentMention.name);
|
|
175
189
|
if (!pendingMentionDetails) {
|
|
176
190
|
return {
|
|
177
191
|
hasPublicPluginStateChanged: false,
|
|
@@ -183,20 +197,23 @@ const commitPendingTypedAgentMention = (state, pluginState, pendingTypedAgentMen
|
|
|
183
197
|
}
|
|
184
198
|
return commitResolvedPendingTypedAgentMention(pluginState, pendingMentionDetails);
|
|
185
199
|
};
|
|
186
|
-
const hasTrackedAgentMentionState = pluginState => Boolean(pluginState.pendingTypedAgentMention) || pluginState.lastInsertedAgentMentionId != null || pluginState.lastInsertedAgentMentionContext != null || pluginState.lastInsertedAgentMentionParentNodeType != null;
|
|
200
|
+
const hasTrackedAgentMentionState = pluginState => Boolean(pluginState.pendingTypedAgentMention) || pluginState.lastInsertedAgentMentionId != null || pluginState.lastInsertedAgentMentionContext != null || pluginState.lastInsertedAgentMentionName != null || pluginState.lastInsertedAgentMentionParentNodeType != null;
|
|
187
201
|
|
|
188
202
|
/**
|
|
189
203
|
* Clears agent mention state that points at a specific document snapshot.
|
|
190
204
|
* replaceDocument swaps content wholesale, so pending typed mentions and
|
|
191
205
|
* lastInserted* details from the previous document must be cleared together.
|
|
192
206
|
*/
|
|
193
|
-
const clearTrackedAgentMentionState = pluginState =>
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
207
|
+
const clearTrackedAgentMentionState = pluginState => {
|
|
208
|
+
return {
|
|
209
|
+
...pluginState,
|
|
210
|
+
pendingTypedAgentMention: null,
|
|
211
|
+
lastInsertedAgentMentionId: null,
|
|
212
|
+
lastInsertedAgentMentionContext: null,
|
|
213
|
+
lastInsertedAgentMentionName: null,
|
|
214
|
+
lastInsertedAgentMentionParentNodeType: null
|
|
215
|
+
};
|
|
216
|
+
};
|
|
200
217
|
export function createMentionPlugin({
|
|
201
218
|
pmPluginFactoryParams,
|
|
202
219
|
fireEvent,
|
|
@@ -381,9 +398,10 @@ export function createMentionPlugin({
|
|
|
381
398
|
});
|
|
382
399
|
const shouldResolveAgentMentionState = stepsTouchMentions || Boolean(newPluginState.lastInsertedAgentMentionId);
|
|
383
400
|
if (shouldResolveAgentMentionState) {
|
|
384
|
-
var _newPluginState$lastA, _newPluginState$lastI, _newPluginState$lastI2, _newPluginState$lastI3;
|
|
401
|
+
var _newPluginState$lastA, _newPluginState$lastI, _newPluginState$lastI2, _newPluginState$lastI3, _newPluginState$lastI4;
|
|
385
402
|
let agentMentionId = null;
|
|
386
403
|
let agentMentionContext = null;
|
|
404
|
+
let agentMentionName = null;
|
|
387
405
|
let agentMentionParentNodeType = null;
|
|
388
406
|
let newCount = 0;
|
|
389
407
|
let oldAgentMentionId = null;
|
|
@@ -399,13 +417,14 @@ export function createMentionPlugin({
|
|
|
399
417
|
}
|
|
400
418
|
newCount++;
|
|
401
419
|
if (pendingTypedAgentMentionDetails === null && action === ACTIONS.SET_PENDING_TYPED_AGENT_MENTION && node.attrs.localId === (params === null || params === void 0 ? void 0 : params.localId)) {
|
|
402
|
-
pendingTypedAgentMentionDetails = getAgentMentionDetailsAtPos(newState, pos, attrs => attrs.localId === params.localId);
|
|
420
|
+
pendingTypedAgentMentionDetails = getAgentMentionDetailsAtPos(newState, pos, attrs => attrs.localId === params.localId, params.name);
|
|
403
421
|
}
|
|
404
422
|
if (agentMentionId === null && node.attrs.id) {
|
|
405
|
-
const agentMentionDetails = getAgentMentionDetailsAtPos(newState, pos, attrs => attrs.id === node.attrs.id);
|
|
423
|
+
const agentMentionDetails = getAgentMentionDetailsAtPos(newState, pos, attrs => attrs.id === node.attrs.id, params === null || params === void 0 ? void 0 : params.name);
|
|
406
424
|
if (agentMentionDetails) {
|
|
407
425
|
agentMentionId = agentMentionDetails.id;
|
|
408
426
|
agentMentionContext = agentMentionDetails.context;
|
|
427
|
+
agentMentionName = agentMentionDetails.name;
|
|
409
428
|
agentMentionParentNodeType = agentMentionDetails.parentNodeType;
|
|
410
429
|
}
|
|
411
430
|
}
|
|
@@ -433,10 +452,11 @@ export function createMentionPlugin({
|
|
|
433
452
|
// above finds nothing. Check whether any agent mention survived in the document.
|
|
434
453
|
let resolvedFromFullDocFallback = false;
|
|
435
454
|
if (agentMentionId === null && newPluginState.lastInsertedAgentMentionId) {
|
|
436
|
-
const survivorDetails = getSurvivingAgentMentionDetails(newState, newPluginState.lastInsertedAgentMentionId);
|
|
455
|
+
const survivorDetails = getSurvivingAgentMentionDetails(newState, newPluginState.lastInsertedAgentMentionId, newPluginState.lastInsertedAgentMentionName);
|
|
437
456
|
if (survivorDetails) {
|
|
438
457
|
agentMentionId = survivorDetails.id;
|
|
439
458
|
agentMentionContext = survivorDetails.context;
|
|
459
|
+
agentMentionName = survivorDetails.name;
|
|
440
460
|
agentMentionParentNodeType = survivorDetails.parentNodeType;
|
|
441
461
|
resolvedFromFullDocFallback = true;
|
|
442
462
|
}
|
|
@@ -452,6 +472,7 @@ export function createMentionPlugin({
|
|
|
452
472
|
pendingTypedAgentMention: {
|
|
453
473
|
id: pendingTypedAgentMentionDetailsForState.id,
|
|
454
474
|
localId: pendingTypedAgentMentionLocalId,
|
|
475
|
+
name: pendingTypedAgentMentionDetailsForState.name,
|
|
455
476
|
nodeSize: pendingTypedAgentMentionDetailsForState.nodeSize,
|
|
456
477
|
pos: pendingTypedAgentMentionDetailsForState.pos,
|
|
457
478
|
resetCount: 1
|
|
@@ -465,17 +486,19 @@ export function createMentionPlugin({
|
|
|
465
486
|
pendingTypedAgentMention: null,
|
|
466
487
|
lastInsertedAgentMentionId: agentMentionId,
|
|
467
488
|
lastInsertedAgentMentionContext: agentMentionContext,
|
|
489
|
+
lastInsertedAgentMentionName: agentMentionName,
|
|
468
490
|
lastInsertedAgentMentionParentNodeType: agentMentionParentNodeType,
|
|
469
491
|
...(newInsertionCount !== undefined ? {
|
|
470
492
|
lastAgentMentionInsertionCount: newInsertionCount
|
|
471
493
|
} : {})
|
|
472
494
|
};
|
|
473
495
|
hasPublicPluginStateChanged = true;
|
|
474
|
-
} else if (agentMentionId !== ((_newPluginState$lastI = newPluginState.lastInsertedAgentMentionId) !== null && _newPluginState$lastI !== void 0 ? _newPluginState$lastI : null) || agentMentionContext !== ((_newPluginState$lastI2 = newPluginState.lastInsertedAgentMentionContext) !== null && _newPluginState$lastI2 !== void 0 ? _newPluginState$lastI2 : null) ||
|
|
496
|
+
} else if (agentMentionId !== ((_newPluginState$lastI = newPluginState.lastInsertedAgentMentionId) !== null && _newPluginState$lastI !== void 0 ? _newPluginState$lastI : null) || agentMentionContext !== ((_newPluginState$lastI2 = newPluginState.lastInsertedAgentMentionContext) !== null && _newPluginState$lastI2 !== void 0 ? _newPluginState$lastI2 : null) || agentMentionName !== ((_newPluginState$lastI3 = newPluginState.lastInsertedAgentMentionName) !== null && _newPluginState$lastI3 !== void 0 ? _newPluginState$lastI3 : null) || agentMentionParentNodeType !== ((_newPluginState$lastI4 = newPluginState.lastInsertedAgentMentionParentNodeType) !== null && _newPluginState$lastI4 !== void 0 ? _newPluginState$lastI4 : null) || newInsertionCount !== undefined) {
|
|
475
497
|
newPluginState = {
|
|
476
498
|
...newPluginState,
|
|
477
499
|
lastInsertedAgentMentionId: agentMentionId,
|
|
478
500
|
lastInsertedAgentMentionContext: agentMentionContext,
|
|
501
|
+
lastInsertedAgentMentionName: agentMentionName,
|
|
479
502
|
lastInsertedAgentMentionParentNodeType: agentMentionParentNodeType,
|
|
480
503
|
...(newInsertionCount !== undefined ? {
|
|
481
504
|
lastAgentMentionInsertionCount: newInsertionCount
|
|
@@ -505,7 +528,7 @@ export function createMentionPlugin({
|
|
|
505
528
|
const shouldCheckPendingTypedAgentMentionParent = isLocalSelectionChange(tr, hasPositionChanged);
|
|
506
529
|
if (isAgentMentionsExperimentEnabled && newPluginState.pendingTypedAgentMention && action !== ACTIONS.SET_PENDING_TYPED_AGENT_MENTION && action !== ACTIONS.COMMIT_PENDING_TYPED_AGENT_MENTION && shouldCheckPendingTypedAgentMentionParent) {
|
|
507
530
|
const pendingTypedAgentMention = newPluginState.pendingTypedAgentMention;
|
|
508
|
-
const pendingMentionDetails = getAgentMentionDetailsAtPos(newState, pendingTypedAgentMention.pos, attrs => attrs.localId === pendingTypedAgentMention.localId);
|
|
531
|
+
const pendingMentionDetails = getAgentMentionDetailsAtPos(newState, pendingTypedAgentMention.pos, attrs => attrs.localId === pendingTypedAgentMention.localId, pendingTypedAgentMention.name);
|
|
509
532
|
if (!pendingMentionDetails) {
|
|
510
533
|
newPluginState = {
|
|
511
534
|
...newPluginState,
|
|
@@ -28,10 +28,21 @@ var AGENT_USER_TYPES = new Set(['APP', 'AGENT']);
|
|
|
28
28
|
var isAgentUserType = function isAgentUserType(userType) {
|
|
29
29
|
return typeof userType === 'string' && AGENT_USER_TYPES.has(userType);
|
|
30
30
|
};
|
|
31
|
+
var getAgentMentionName = function getAgentMentionName(text, fallbackName) {
|
|
32
|
+
var trimmedFallbackName = typeof fallbackName === 'string' ? fallbackName.trim() : '';
|
|
33
|
+
var normalizedFallbackName = (trimmedFallbackName.startsWith('@') ? trimmedFallbackName.slice(1).trim() : trimmedFallbackName) || null;
|
|
34
|
+
if (typeof text !== 'string') {
|
|
35
|
+
return normalizedFallbackName;
|
|
36
|
+
}
|
|
37
|
+
var trimmedText = text.trim();
|
|
38
|
+
var displayName = trimmedText.startsWith('@') ? trimmedText.slice(1).trim() : trimmedText;
|
|
39
|
+
var normalizedName = displayName || normalizedFallbackName;
|
|
40
|
+
return normalizedName;
|
|
41
|
+
};
|
|
31
42
|
var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
|
|
32
43
|
var AGENT_MENTION_INACTIVITY_MS = 3000;
|
|
33
44
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
34
|
-
var PACKAGE_VERSION = "14.4.
|
|
45
|
+
var PACKAGE_VERSION = "14.4.2";
|
|
35
46
|
var setProvider = function setProvider(provider) {
|
|
36
47
|
return function (state, dispatch) {
|
|
37
48
|
if (dispatch) {
|
|
@@ -71,7 +82,7 @@ var isLocalSelectionChange = function isLocalSelectionChange(tr, hasPositionChan
|
|
|
71
82
|
* the document. Callers pass a matcher so mapped positions are only accepted
|
|
72
83
|
* when they still point at the same pending/tracked mention.
|
|
73
84
|
*/
|
|
74
|
-
var getAgentMentionDetailsAtPos = function getAgentMentionDetailsAtPos(state, pos, matchesMention) {
|
|
85
|
+
var getAgentMentionDetailsAtPos = function getAgentMentionDetailsAtPos(state, pos, matchesMention, fallbackName) {
|
|
75
86
|
var _parentNode$type$name;
|
|
76
87
|
if (pos < 0 || pos > state.doc.content.size) {
|
|
77
88
|
return null;
|
|
@@ -86,6 +97,7 @@ var getAgentMentionDetailsAtPos = function getAgentMentionDetailsAtPos(state, po
|
|
|
86
97
|
return {
|
|
87
98
|
id: node.attrs.id,
|
|
88
99
|
context: parentNode.textContent.trim() || null,
|
|
100
|
+
name: getAgentMentionName(node.attrs.text, fallbackName),
|
|
89
101
|
nodeSize: node.nodeSize,
|
|
90
102
|
parentEnd: $mentionPos.end($mentionPos.depth),
|
|
91
103
|
parentNodeType: (_parentNode$type$name = parentNode.type.name) !== null && _parentNode$type$name !== void 0 ? _parentNode$type$name : null,
|
|
@@ -99,7 +111,7 @@ var getAgentMentionDetailsAtPos = function getAgentMentionDetailsAtPos(state, po
|
|
|
99
111
|
* scan did not find one. Prefers the previously tracked mention ID when present;
|
|
100
112
|
* otherwise returns a surviving agent mention using the existing traversal order.
|
|
101
113
|
*/
|
|
102
|
-
var getSurvivingAgentMentionDetails = function getSurvivingAgentMentionDetails(state, preferredId) {
|
|
114
|
+
var getSurvivingAgentMentionDetails = function getSurvivingAgentMentionDetails(state, preferredId, preferredName) {
|
|
103
115
|
var mentionSchema = state.schema.nodes.mention;
|
|
104
116
|
var result = null;
|
|
105
117
|
state.doc.descendants(function (node, pos) {
|
|
@@ -112,7 +124,7 @@ var getSurvivingAgentMentionDetails = function getSurvivingAgentMentionDetails(s
|
|
|
112
124
|
}
|
|
113
125
|
result = getAgentMentionDetailsAtPos(state, pos, function (attrs) {
|
|
114
126
|
return attrs.id === node.attrs.id;
|
|
115
|
-
});
|
|
127
|
+
}, node.attrs.id === preferredId ? preferredName : undefined);
|
|
116
128
|
return ((_result2 = result) === null || _result2 === void 0 ? void 0 : _result2.id) !== preferredId;
|
|
117
129
|
});
|
|
118
130
|
return result;
|
|
@@ -132,10 +144,11 @@ var getPendingTypedAgentMentionAfterDocChange = function getPendingTypedAgentMen
|
|
|
132
144
|
}
|
|
133
145
|
var pendingMentionDetails = getAgentMentionDetailsAtPos(state, mappedPos.pos, function (attrs) {
|
|
134
146
|
return attrs.localId === pendingTypedAgentMention.localId;
|
|
135
|
-
});
|
|
147
|
+
}, pendingTypedAgentMention.name);
|
|
136
148
|
return pendingMentionDetails ? {
|
|
137
149
|
id: pendingMentionDetails.id,
|
|
138
150
|
localId: pendingTypedAgentMention.localId,
|
|
151
|
+
name: pendingMentionDetails.name,
|
|
139
152
|
nodeSize: pendingMentionDetails.nodeSize,
|
|
140
153
|
pos: pendingMentionDetails.pos,
|
|
141
154
|
resetCount: resetCount
|
|
@@ -172,6 +185,7 @@ var commitResolvedPendingTypedAgentMention = function commitResolvedPendingTyped
|
|
|
172
185
|
pendingTypedAgentMention: null,
|
|
173
186
|
lastInsertedAgentMentionId: pendingMentionDetails.id,
|
|
174
187
|
lastInsertedAgentMentionContext: pendingMentionDetails.context,
|
|
188
|
+
lastInsertedAgentMentionName: pendingMentionDetails.name,
|
|
175
189
|
lastInsertedAgentMentionParentNodeType: pendingMentionDetails.parentNodeType,
|
|
176
190
|
lastAgentMentionInsertionCount: ((_pluginState$lastAgen = pluginState.lastAgentMentionInsertionCount) !== null && _pluginState$lastAgen !== void 0 ? _pluginState$lastAgen : 0) + 1
|
|
177
191
|
})
|
|
@@ -186,7 +200,7 @@ var commitResolvedPendingTypedAgentMention = function commitResolvedPendingTyped
|
|
|
186
200
|
var commitPendingTypedAgentMention = function commitPendingTypedAgentMention(state, pluginState, pendingTypedAgentMention) {
|
|
187
201
|
var pendingMentionDetails = getAgentMentionDetailsAtPos(state, pendingTypedAgentMention.pos, function (attrs) {
|
|
188
202
|
return attrs.localId === pendingTypedAgentMention.localId;
|
|
189
|
-
});
|
|
203
|
+
}, pendingTypedAgentMention.name);
|
|
190
204
|
if (!pendingMentionDetails) {
|
|
191
205
|
return {
|
|
192
206
|
hasPublicPluginStateChanged: false,
|
|
@@ -198,7 +212,7 @@ var commitPendingTypedAgentMention = function commitPendingTypedAgentMention(sta
|
|
|
198
212
|
return commitResolvedPendingTypedAgentMention(pluginState, pendingMentionDetails);
|
|
199
213
|
};
|
|
200
214
|
var hasTrackedAgentMentionState = function hasTrackedAgentMentionState(pluginState) {
|
|
201
|
-
return Boolean(pluginState.pendingTypedAgentMention) || pluginState.lastInsertedAgentMentionId != null || pluginState.lastInsertedAgentMentionContext != null || pluginState.lastInsertedAgentMentionParentNodeType != null;
|
|
215
|
+
return Boolean(pluginState.pendingTypedAgentMention) || pluginState.lastInsertedAgentMentionId != null || pluginState.lastInsertedAgentMentionContext != null || pluginState.lastInsertedAgentMentionName != null || pluginState.lastInsertedAgentMentionParentNodeType != null;
|
|
202
216
|
};
|
|
203
217
|
|
|
204
218
|
/**
|
|
@@ -211,6 +225,7 @@ var clearTrackedAgentMentionState = function clearTrackedAgentMentionState(plugi
|
|
|
211
225
|
pendingTypedAgentMention: null,
|
|
212
226
|
lastInsertedAgentMentionId: null,
|
|
213
227
|
lastInsertedAgentMentionContext: null,
|
|
228
|
+
lastInsertedAgentMentionName: null,
|
|
214
229
|
lastInsertedAgentMentionParentNodeType: null
|
|
215
230
|
});
|
|
216
231
|
};
|
|
@@ -395,9 +410,10 @@ export function createMentionPlugin(_ref2) {
|
|
|
395
410
|
});
|
|
396
411
|
var shouldResolveAgentMentionState = stepsTouchMentions || Boolean(newPluginState.lastInsertedAgentMentionId);
|
|
397
412
|
if (shouldResolveAgentMentionState) {
|
|
398
|
-
var _newPluginState$lastA, _newPluginState$lastI, _newPluginState$lastI2, _newPluginState$lastI3;
|
|
413
|
+
var _newPluginState$lastA, _newPluginState$lastI, _newPluginState$lastI2, _newPluginState$lastI3, _newPluginState$lastI4;
|
|
399
414
|
var agentMentionId = null;
|
|
400
415
|
var agentMentionContext = null;
|
|
416
|
+
var agentMentionName = null;
|
|
401
417
|
var agentMentionParentNodeType = null;
|
|
402
418
|
var newCount = 0;
|
|
403
419
|
var oldAgentMentionId = null;
|
|
@@ -421,15 +437,16 @@ export function createMentionPlugin(_ref2) {
|
|
|
421
437
|
if (pendingTypedAgentMentionDetails === null && action === ACTIONS.SET_PENDING_TYPED_AGENT_MENTION && node.attrs.localId === (params === null || params === void 0 ? void 0 : params.localId)) {
|
|
422
438
|
pendingTypedAgentMentionDetails = getAgentMentionDetailsAtPos(newState, pos, function (attrs) {
|
|
423
439
|
return attrs.localId === params.localId;
|
|
424
|
-
});
|
|
440
|
+
}, params.name);
|
|
425
441
|
}
|
|
426
442
|
if (agentMentionId === null && node.attrs.id) {
|
|
427
443
|
var agentMentionDetails = getAgentMentionDetailsAtPos(newState, pos, function (attrs) {
|
|
428
444
|
return attrs.id === node.attrs.id;
|
|
429
|
-
});
|
|
445
|
+
}, params === null || params === void 0 ? void 0 : params.name);
|
|
430
446
|
if (agentMentionDetails) {
|
|
431
447
|
agentMentionId = agentMentionDetails.id;
|
|
432
448
|
agentMentionContext = agentMentionDetails.context;
|
|
449
|
+
agentMentionName = agentMentionDetails.name;
|
|
433
450
|
agentMentionParentNodeType = agentMentionDetails.parentNodeType;
|
|
434
451
|
}
|
|
435
452
|
}
|
|
@@ -473,10 +490,11 @@ export function createMentionPlugin(_ref2) {
|
|
|
473
490
|
// above finds nothing. Check whether any agent mention survived in the document.
|
|
474
491
|
var resolvedFromFullDocFallback = false;
|
|
475
492
|
if (agentMentionId === null && newPluginState.lastInsertedAgentMentionId) {
|
|
476
|
-
var survivorDetails = getSurvivingAgentMentionDetails(newState, newPluginState.lastInsertedAgentMentionId);
|
|
493
|
+
var survivorDetails = getSurvivingAgentMentionDetails(newState, newPluginState.lastInsertedAgentMentionId, newPluginState.lastInsertedAgentMentionName);
|
|
477
494
|
if (survivorDetails) {
|
|
478
495
|
agentMentionId = survivorDetails.id;
|
|
479
496
|
agentMentionContext = survivorDetails.context;
|
|
497
|
+
agentMentionName = survivorDetails.name;
|
|
480
498
|
agentMentionParentNodeType = survivorDetails.parentNodeType;
|
|
481
499
|
resolvedFromFullDocFallback = true;
|
|
482
500
|
}
|
|
@@ -491,6 +509,7 @@ export function createMentionPlugin(_ref2) {
|
|
|
491
509
|
pendingTypedAgentMention: {
|
|
492
510
|
id: pendingTypedAgentMentionDetailsForState.id,
|
|
493
511
|
localId: pendingTypedAgentMentionLocalId,
|
|
512
|
+
name: pendingTypedAgentMentionDetailsForState.name,
|
|
494
513
|
nodeSize: pendingTypedAgentMentionDetailsForState.nodeSize,
|
|
495
514
|
pos: pendingTypedAgentMentionDetailsForState.pos,
|
|
496
515
|
resetCount: 1
|
|
@@ -503,15 +522,17 @@ export function createMentionPlugin(_ref2) {
|
|
|
503
522
|
pendingTypedAgentMention: null,
|
|
504
523
|
lastInsertedAgentMentionId: agentMentionId,
|
|
505
524
|
lastInsertedAgentMentionContext: agentMentionContext,
|
|
525
|
+
lastInsertedAgentMentionName: agentMentionName,
|
|
506
526
|
lastInsertedAgentMentionParentNodeType: agentMentionParentNodeType
|
|
507
527
|
}, newInsertionCount !== undefined ? {
|
|
508
528
|
lastAgentMentionInsertionCount: newInsertionCount
|
|
509
529
|
} : {});
|
|
510
530
|
hasPublicPluginStateChanged = true;
|
|
511
|
-
} else if (agentMentionId !== ((_newPluginState$lastI = newPluginState.lastInsertedAgentMentionId) !== null && _newPluginState$lastI !== void 0 ? _newPluginState$lastI : null) || agentMentionContext !== ((_newPluginState$lastI2 = newPluginState.lastInsertedAgentMentionContext) !== null && _newPluginState$lastI2 !== void 0 ? _newPluginState$lastI2 : null) ||
|
|
531
|
+
} else if (agentMentionId !== ((_newPluginState$lastI = newPluginState.lastInsertedAgentMentionId) !== null && _newPluginState$lastI !== void 0 ? _newPluginState$lastI : null) || agentMentionContext !== ((_newPluginState$lastI2 = newPluginState.lastInsertedAgentMentionContext) !== null && _newPluginState$lastI2 !== void 0 ? _newPluginState$lastI2 : null) || agentMentionName !== ((_newPluginState$lastI3 = newPluginState.lastInsertedAgentMentionName) !== null && _newPluginState$lastI3 !== void 0 ? _newPluginState$lastI3 : null) || agentMentionParentNodeType !== ((_newPluginState$lastI4 = newPluginState.lastInsertedAgentMentionParentNodeType) !== null && _newPluginState$lastI4 !== void 0 ? _newPluginState$lastI4 : null) || newInsertionCount !== undefined) {
|
|
512
532
|
newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
|
|
513
533
|
lastInsertedAgentMentionId: agentMentionId,
|
|
514
534
|
lastInsertedAgentMentionContext: agentMentionContext,
|
|
535
|
+
lastInsertedAgentMentionName: agentMentionName,
|
|
515
536
|
lastInsertedAgentMentionParentNodeType: agentMentionParentNodeType
|
|
516
537
|
}, newInsertionCount !== undefined ? {
|
|
517
538
|
lastAgentMentionInsertionCount: newInsertionCount
|
|
@@ -541,7 +562,7 @@ export function createMentionPlugin(_ref2) {
|
|
|
541
562
|
var _pendingTypedAgentMention = newPluginState.pendingTypedAgentMention;
|
|
542
563
|
var pendingMentionDetails = getAgentMentionDetailsAtPos(newState, _pendingTypedAgentMention.pos, function (attrs) {
|
|
543
564
|
return attrs.localId === _pendingTypedAgentMention.localId;
|
|
544
|
-
});
|
|
565
|
+
}, _pendingTypedAgentMention.name);
|
|
545
566
|
if (!pendingMentionDetails) {
|
|
546
567
|
newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
|
|
547
568
|
pendingTypedAgentMention: null
|
|
@@ -520,7 +520,8 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref8) {
|
|
|
520
520
|
tr.setMeta(mentionPluginKey, {
|
|
521
521
|
action: ACTIONS.SET_PENDING_TYPED_AGENT_MENTION,
|
|
522
522
|
params: {
|
|
523
|
-
localId: mentionLocalId
|
|
523
|
+
localId: mentionLocalId,
|
|
524
|
+
name: name
|
|
524
525
|
}
|
|
525
526
|
});
|
|
526
527
|
}
|
|
@@ -46,6 +46,7 @@ export type MentionPluginOptions = MentionsPluginOptions;
|
|
|
46
46
|
export type AgentMentionDetails = {
|
|
47
47
|
context: string | null;
|
|
48
48
|
id: string;
|
|
49
|
+
name: string | null;
|
|
49
50
|
nodeSize: number;
|
|
50
51
|
/**
|
|
51
52
|
* @internal ProseMirror position used for parent-boundary checks.
|
|
@@ -75,6 +76,11 @@ export type MentionPluginState = {
|
|
|
75
76
|
* Null when no agent mention is present in the document.
|
|
76
77
|
*/
|
|
77
78
|
lastInsertedAgentMentionId?: string | null;
|
|
79
|
+
/**
|
|
80
|
+
* Display name of the most recently inserted agent mention.
|
|
81
|
+
* Derived from the mention node text and used for Rovo nudge copy.
|
|
82
|
+
*/
|
|
83
|
+
lastInsertedAgentMentionName?: string | null;
|
|
78
84
|
/**
|
|
79
85
|
* ProseMirror node type of the direct parent of the agent mention
|
|
80
86
|
* (e.g. 'taskItem', 'paragraph'). Determines auto-send vs. draft behaviour.
|
|
@@ -90,6 +96,7 @@ export type MentionPluginState = {
|
|
|
90
96
|
pendingTypedAgentMention?: {
|
|
91
97
|
id: string;
|
|
92
98
|
localId: string;
|
|
99
|
+
name: string | null;
|
|
93
100
|
nodeSize: number;
|
|
94
101
|
pos: number;
|
|
95
102
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-mentions",
|
|
3
|
-
"version": "14.4.
|
|
3
|
+
"version": "14.4.3",
|
|
4
4
|
"description": "Mentions plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"@atlaskit/lozenge": "^14.0.0",
|
|
36
36
|
"@atlaskit/mention": "^27.2.0",
|
|
37
37
|
"@atlaskit/platform-feature-flags": "^2.0.0",
|
|
38
|
-
"@atlaskit/popper": "^8.
|
|
38
|
+
"@atlaskit/popper": "^8.1.0",
|
|
39
39
|
"@atlaskit/portal": "^6.0.0",
|
|
40
40
|
"@atlaskit/primitives": "^20.0.0",
|
|
41
|
-
"@atlaskit/profilecard": "^26.
|
|
41
|
+
"@atlaskit/profilecard": "^26.2.0",
|
|
42
42
|
"@atlaskit/teams-app-config": "^2.0.0",
|
|
43
43
|
"@atlaskit/theme": "^26.0.0",
|
|
44
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
44
|
+
"@atlaskit/tmp-editor-statsig": "^112.0.0",
|
|
45
45
|
"@atlaskit/tokens": "^15.0.0",
|
|
46
46
|
"@atlaskit/tooltip": "^23.0.0",
|
|
47
47
|
"@atlaskit/user-picker": "^13.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.12.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"
|