@atlaskit/editor-plugin-mentions 12.2.11 → 12.3.1
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 +17 -0
- package/dist/cjs/editor-commands/index.js +9 -3
- package/dist/cjs/pm-plugins/main.js +1 -1
- package/dist/cjs/ui/type-ahead/index.js +23 -18
- package/dist/es2019/editor-commands/index.js +7 -3
- package/dist/es2019/pm-plugins/main.js +1 -1
- package/dist/es2019/ui/type-ahead/index.js +21 -16
- package/dist/esm/editor-commands/index.js +9 -3
- package/dist/esm/pm-plugins/main.js +1 -1
- package/dist/esm/ui/type-ahead/index.js +23 -18
- package/dist/types/editor-commands/index.d.ts +2 -1
- package/dist/types/mentionsPluginType.d.ts +1 -0
- package/dist/types/types/index.d.ts +2 -1
- package/dist/types/ui/type-ahead/index.d.ts +1 -0
- package/dist/types-ts4.5/editor-commands/index.d.ts +2 -1
- package/dist/types-ts4.5/mentionsPluginType.d.ts +1 -0
- package/dist/types-ts4.5/types/index.d.ts +2 -1
- package/dist/types-ts4.5/ui/type-ahead/index.d.ts +1 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-mentions
|
|
2
2
|
|
|
3
|
+
## 12.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 12.3.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`3b29bddd3f460`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3b29bddd3f460) -
|
|
14
|
+
Suppress human invite flow for agent mentions
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 12.2.11
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -9,13 +9,18 @@ var _uuid = _interopRequireDefault(require("uuid"));
|
|
|
9
9
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
10
10
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
11
11
|
var _resource = require("@atlaskit/mention/resource");
|
|
12
|
+
var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
|
|
12
13
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
13
14
|
|
|
15
|
+
var isAgentUserType = function isAgentUserType(userType) {
|
|
16
|
+
return userType === 'APP' || userType === 'AGENT';
|
|
17
|
+
};
|
|
14
18
|
var createSingleMentionFragment = exports.createSingleMentionFragment = function createSingleMentionFragment(_ref) {
|
|
15
19
|
var mentionInsertDisplayName = _ref.mentionInsertDisplayName,
|
|
16
20
|
mentionProvider = _ref.mentionProvider,
|
|
17
21
|
tr = _ref.tr,
|
|
18
|
-
sanitizePrivateContent = _ref.sanitizePrivateContent
|
|
22
|
+
sanitizePrivateContent = _ref.sanitizePrivateContent,
|
|
23
|
+
suppressInviteXProductUser = _ref.suppressInviteXProductUser;
|
|
19
24
|
return function (_ref2) {
|
|
20
25
|
var name = _ref2.name,
|
|
21
26
|
id = _ref2.id,
|
|
@@ -27,7 +32,7 @@ var createSingleMentionFragment = exports.createSingleMentionFragment = function
|
|
|
27
32
|
var schema = tr.doc.type.schema;
|
|
28
33
|
var trimmedNickname = nickname && nickname.startsWith('@') ? nickname.slice(1) : nickname;
|
|
29
34
|
var renderName = mentionInsertDisplayName || !trimmedNickname ? name : trimmedNickname;
|
|
30
|
-
if (isXProductUser && mentionProvider && mentionProvider.inviteXProductUser) {
|
|
35
|
+
if (!suppressInviteXProductUser && isXProductUser && mentionProvider !== null && mentionProvider !== void 0 && mentionProvider.inviteXProductUser) {
|
|
31
36
|
mentionProvider.inviteXProductUser(id, name);
|
|
32
37
|
}
|
|
33
38
|
|
|
@@ -70,7 +75,8 @@ var insertMention = exports.insertMention = function insertMention(_ref3) {
|
|
|
70
75
|
sanitizePrivateContent: sanitizePrivateContent,
|
|
71
76
|
mentionProvider: mentionProvider,
|
|
72
77
|
mentionInsertDisplayName: mentionInsertDisplayName,
|
|
73
|
-
tr: tr
|
|
78
|
+
tr: tr,
|
|
79
|
+
suppressInviteXProductUser: (0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false) && isAgentUserType(userType)
|
|
74
80
|
})({
|
|
75
81
|
name: name,
|
|
76
82
|
id: id,
|
|
@@ -23,7 +23,7 @@ var ACTIONS = exports.ACTIONS = {
|
|
|
23
23
|
SET_PROVIDER: 'SET_PROVIDER'
|
|
24
24
|
};
|
|
25
25
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
26
|
-
var PACKAGE_VERSION = "12.
|
|
26
|
+
var PACKAGE_VERSION = "12.3.0";
|
|
27
27
|
var setProvider = function setProvider(provider) {
|
|
28
28
|
return function (state, dispatch) {
|
|
29
29
|
if (dispatch) {
|
|
@@ -20,6 +20,7 @@ var _item = require("@atlaskit/mention/item");
|
|
|
20
20
|
var _resource = require("@atlaskit/mention/resource");
|
|
21
21
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
22
22
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
23
|
+
var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
|
|
23
24
|
var _editorCommands = require("../../editor-commands");
|
|
24
25
|
var _mentionPlaceholder = require("../../pm-plugins/mentionPlaceholder");
|
|
25
26
|
var _utils2 = require("../../pm-plugins/utils");
|
|
@@ -33,9 +34,12 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
33
34
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
34
35
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
35
36
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
36
|
-
var
|
|
37
|
+
var isAgentUserType = function isAgentUserType(userType) {
|
|
37
38
|
return userType === 'APP' || userType === 'AGENT';
|
|
38
39
|
};
|
|
40
|
+
var isAgentMention = function isAgentMention(mention) {
|
|
41
|
+
return isAgentUserType(mention.userType) || mention.appType === 'agent';
|
|
42
|
+
};
|
|
39
43
|
var createInviteItem = function createInviteItem(_ref) {
|
|
40
44
|
var mentionProvider = _ref.mentionProvider,
|
|
41
45
|
onInviteItemMount = _ref.onInviteItemMount,
|
|
@@ -325,7 +329,7 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
|
|
|
325
329
|
title: intl.formatMessage(_messages.mentionMessages.typeAheadSectionPeople),
|
|
326
330
|
filter: function filter(item) {
|
|
327
331
|
var _item$mention;
|
|
328
|
-
return !
|
|
332
|
+
return !isAgentUserType(((_item$mention = item.mention) === null || _item$mention === void 0 ? void 0 : _item$mention.userType) || '');
|
|
329
333
|
},
|
|
330
334
|
limit: 6
|
|
331
335
|
}, {
|
|
@@ -333,7 +337,7 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
|
|
|
333
337
|
title: intl.formatMessage(_messages.mentionMessages.typeAheadSectionAgents),
|
|
334
338
|
filter: function filter(item) {
|
|
335
339
|
var _item$mention2;
|
|
336
|
-
return
|
|
340
|
+
return isAgentUserType(((_item$mention2 = item.mention) === null || _item$mention2 === void 0 ? void 0 : _item$mention2.userType) || '');
|
|
337
341
|
}
|
|
338
342
|
}];
|
|
339
343
|
},
|
|
@@ -361,6 +365,7 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
|
|
|
361
365
|
var mentionContext = _objectSpread(_objectSpread({}, contextIdentifierProvider), {}, {
|
|
362
366
|
sessionId: sessionId
|
|
363
367
|
});
|
|
368
|
+
var shouldSuppressInviteForAgentMention = (0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false) && isAgentMention(item.mention);
|
|
364
369
|
if (mentionProvider && !(0, _utils3.isInviteItem)(item.mention)) {
|
|
365
370
|
mentionProvider.recordMentionSelection(item.mention, mentionContext);
|
|
366
371
|
}
|
|
@@ -412,21 +417,20 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
|
|
|
412
417
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
413
418
|
var mentionLocalId = (0, _uuid.default)();
|
|
414
419
|
if (handleMentionsChanged) {
|
|
420
|
+
var mentionChange = _objectSpread({
|
|
421
|
+
id: id,
|
|
422
|
+
localId: mentionLocalId,
|
|
423
|
+
method: 'typed',
|
|
424
|
+
type: 'added'
|
|
425
|
+
}, shouldSuppressInviteForAgentMention ? {
|
|
426
|
+
shouldSuppressMentionNotification: true
|
|
427
|
+
} : {});
|
|
415
428
|
if (taskItemId) {
|
|
416
|
-
handleMentionsChanged([{
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
id: id,
|
|
420
|
-
taskLocalId: taskItemId,
|
|
421
|
-
method: 'typed'
|
|
422
|
-
}]);
|
|
429
|
+
handleMentionsChanged([_objectSpread(_objectSpread({}, mentionChange), {}, {
|
|
430
|
+
taskLocalId: taskItemId
|
|
431
|
+
})]);
|
|
423
432
|
} else {
|
|
424
|
-
handleMentionsChanged([
|
|
425
|
-
type: 'added',
|
|
426
|
-
localId: mentionLocalId,
|
|
427
|
-
id: id,
|
|
428
|
-
method: 'typed'
|
|
429
|
-
}]);
|
|
433
|
+
handleMentionsChanged([mentionChange]);
|
|
430
434
|
}
|
|
431
435
|
}
|
|
432
436
|
fireEvent((0, _analytics.buildTypeAheadInsertedPayload)(pickerElapsedTime, stats.keyCount.arrowUp, stats.keyCount.arrowDown, sessionId, mode, item.mention, mentionLocalId, sourceListItem.map(function (x) {
|
|
@@ -438,14 +442,15 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
|
|
|
438
442
|
if (mentionProvider && (0, _utils3.isTeamType)(userType)) {
|
|
439
443
|
return insert(buildNodesForTeamMention(schema, item.mention, mentionProvider, sanitizePrivateContent));
|
|
440
444
|
}
|
|
441
|
-
if (isXProductUser && mentionProvider && mentionProvider.inviteXProductUser) {
|
|
445
|
+
if (!shouldSuppressInviteForAgentMention && isXProductUser && mentionProvider && mentionProvider.inviteXProductUser) {
|
|
442
446
|
mentionProvider.inviteXProductUser(id, name);
|
|
443
447
|
}
|
|
444
448
|
return insert((0, _editorCommands.createSingleMentionFragment)({
|
|
445
449
|
mentionProvider: mentionProvider,
|
|
446
450
|
mentionInsertDisplayName: mentionInsertDisplayName,
|
|
447
451
|
tr: state.tr,
|
|
448
|
-
sanitizePrivateContent: sanitizePrivateContent
|
|
452
|
+
sanitizePrivateContent: sanitizePrivateContent,
|
|
453
|
+
suppressInviteXProductUser: shouldSuppressInviteForAgentMention
|
|
449
454
|
})({
|
|
450
455
|
name: name,
|
|
451
456
|
id: id,
|
|
@@ -3,11 +3,14 @@ import uuid from 'uuid';
|
|
|
3
3
|
import { getAnnotationMarksForPos } from '@atlaskit/editor-common/utils';
|
|
4
4
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
|
|
6
|
+
import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
7
|
+
const isAgentUserType = userType => userType === 'APP' || userType === 'AGENT';
|
|
6
8
|
export const createSingleMentionFragment = ({
|
|
7
9
|
mentionInsertDisplayName,
|
|
8
10
|
mentionProvider,
|
|
9
11
|
tr,
|
|
10
|
-
sanitizePrivateContent
|
|
12
|
+
sanitizePrivateContent,
|
|
13
|
+
suppressInviteXProductUser
|
|
11
14
|
}) => ({
|
|
12
15
|
name,
|
|
13
16
|
id,
|
|
@@ -20,7 +23,7 @@ export const createSingleMentionFragment = ({
|
|
|
20
23
|
const schema = tr.doc.type.schema;
|
|
21
24
|
const trimmedNickname = nickname && nickname.startsWith('@') ? nickname.slice(1) : nickname;
|
|
22
25
|
const renderName = mentionInsertDisplayName || !trimmedNickname ? name : trimmedNickname;
|
|
23
|
-
if (isXProductUser && mentionProvider && mentionProvider.inviteXProductUser) {
|
|
26
|
+
if (!suppressInviteXProductUser && isXProductUser && mentionProvider !== null && mentionProvider !== void 0 && mentionProvider.inviteXProductUser) {
|
|
24
27
|
mentionProvider.inviteXProductUser(id, name);
|
|
25
28
|
}
|
|
26
29
|
|
|
@@ -64,7 +67,8 @@ export const insertMention = ({
|
|
|
64
67
|
sanitizePrivateContent,
|
|
65
68
|
mentionProvider,
|
|
66
69
|
mentionInsertDisplayName,
|
|
67
|
-
tr
|
|
70
|
+
tr,
|
|
71
|
+
suppressInviteXProductUser: expVal('platform_editor_agent_mentions', 'isEnabled', false) && isAgentUserType(userType)
|
|
68
72
|
})({
|
|
69
73
|
name,
|
|
70
74
|
id,
|
|
@@ -12,7 +12,7 @@ export const ACTIONS = {
|
|
|
12
12
|
SET_PROVIDER: 'SET_PROVIDER'
|
|
13
13
|
};
|
|
14
14
|
const PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
15
|
-
const PACKAGE_VERSION = "12.
|
|
15
|
+
const PACKAGE_VERSION = "12.3.0";
|
|
16
16
|
const setProvider = provider => (state, dispatch) => {
|
|
17
17
|
if (dispatch) {
|
|
18
18
|
dispatch(state.tr.setMeta(mentionPluginKey, {
|
|
@@ -10,6 +10,7 @@ import { MENTION_ITEM_HEIGHT, MentionItem } from '@atlaskit/mention/item';
|
|
|
10
10
|
import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
|
|
11
11
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
12
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
13
|
+
import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
13
14
|
import { createSingleMentionFragment } from '../../editor-commands';
|
|
14
15
|
import { mentionPlaceholderPluginKey, MENTION_PLACEHOLDER_ACTIONS } from '../../pm-plugins/mentionPlaceholder';
|
|
15
16
|
import { getMentionPluginState } from '../../pm-plugins/utils';
|
|
@@ -17,7 +18,8 @@ import InviteItem, { INVITE_ITEM_DESCRIPTION } from '../InviteItem';
|
|
|
17
18
|
import InviteItemWithEmailDomain from '../InviteItem/InviteItemWithEmailDomain';
|
|
18
19
|
import { buildTypeAheadCancelPayload, buildTypeAheadInsertedPayload, buildTypeAheadInviteItemClickedPayload, buildTypeAheadInviteItemViewedPayload, buildTypeAheadRenderedPayload } from './analytics';
|
|
19
20
|
import { isInviteItem, isTeamStats, isTeamType, shouldKeepInviteItem } from './utils';
|
|
20
|
-
const
|
|
21
|
+
const isAgentUserType = userType => userType === 'APP' || userType === 'AGENT';
|
|
22
|
+
const isAgentMention = mention => isAgentUserType(mention.userType) || mention.appType === 'agent';
|
|
21
23
|
const createInviteItem = ({
|
|
22
24
|
mentionProvider,
|
|
23
25
|
onInviteItemMount,
|
|
@@ -305,7 +307,7 @@ export const createTypeAheadConfig = ({
|
|
|
305
307
|
title: intl.formatMessage(mentionMessages.typeAheadSectionPeople),
|
|
306
308
|
filter: item => {
|
|
307
309
|
var _item$mention;
|
|
308
|
-
return !
|
|
310
|
+
return !isAgentUserType(((_item$mention = item.mention) === null || _item$mention === void 0 ? void 0 : _item$mention.userType) || '');
|
|
309
311
|
},
|
|
310
312
|
limit: 6
|
|
311
313
|
}, {
|
|
@@ -313,7 +315,7 @@ export const createTypeAheadConfig = ({
|
|
|
313
315
|
title: intl.formatMessage(mentionMessages.typeAheadSectionAgents),
|
|
314
316
|
filter: item => {
|
|
315
317
|
var _item$mention2;
|
|
316
|
-
return
|
|
318
|
+
return isAgentUserType(((_item$mention2 = item.mention) === null || _item$mention2 === void 0 ? void 0 : _item$mention2.userType) || '');
|
|
317
319
|
}
|
|
318
320
|
}];
|
|
319
321
|
},
|
|
@@ -349,6 +351,7 @@ export const createTypeAheadConfig = ({
|
|
|
349
351
|
...contextIdentifierProvider,
|
|
350
352
|
sessionId
|
|
351
353
|
};
|
|
354
|
+
const shouldSuppressInviteForAgentMention = expVal('platform_editor_agent_mentions', 'isEnabled', false) && isAgentMention(item.mention);
|
|
352
355
|
if (mentionProvider && !isInviteItem(item.mention)) {
|
|
353
356
|
mentionProvider.recordMentionSelection(item.mention, mentionContext);
|
|
354
357
|
}
|
|
@@ -402,21 +405,22 @@ export const createTypeAheadConfig = ({
|
|
|
402
405
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
403
406
|
const mentionLocalId = uuid();
|
|
404
407
|
if (handleMentionsChanged) {
|
|
408
|
+
const mentionChange = {
|
|
409
|
+
id,
|
|
410
|
+
localId: mentionLocalId,
|
|
411
|
+
method: 'typed',
|
|
412
|
+
type: 'added',
|
|
413
|
+
...(shouldSuppressInviteForAgentMention ? {
|
|
414
|
+
shouldSuppressMentionNotification: true
|
|
415
|
+
} : {})
|
|
416
|
+
};
|
|
405
417
|
if (taskItemId) {
|
|
406
418
|
handleMentionsChanged([{
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
id,
|
|
410
|
-
taskLocalId: taskItemId,
|
|
411
|
-
method: 'typed'
|
|
419
|
+
...mentionChange,
|
|
420
|
+
taskLocalId: taskItemId
|
|
412
421
|
}]);
|
|
413
422
|
} else {
|
|
414
|
-
handleMentionsChanged([
|
|
415
|
-
type: 'added',
|
|
416
|
-
localId: mentionLocalId,
|
|
417
|
-
id,
|
|
418
|
-
method: 'typed'
|
|
419
|
-
}]);
|
|
423
|
+
handleMentionsChanged([mentionChange]);
|
|
420
424
|
}
|
|
421
425
|
}
|
|
422
426
|
fireEvent(buildTypeAheadInsertedPayload(pickerElapsedTime, stats.keyCount.arrowUp, stats.keyCount.arrowDown, sessionId, mode, item.mention, mentionLocalId, sourceListItem.map(x => x.mention), query, contextIdentifierProvider, taskListId, taskItemId));
|
|
@@ -426,14 +430,15 @@ export const createTypeAheadConfig = ({
|
|
|
426
430
|
if (mentionProvider && isTeamType(userType)) {
|
|
427
431
|
return insert(buildNodesForTeamMention(schema, item.mention, mentionProvider, sanitizePrivateContent));
|
|
428
432
|
}
|
|
429
|
-
if (isXProductUser && mentionProvider && mentionProvider.inviteXProductUser) {
|
|
433
|
+
if (!shouldSuppressInviteForAgentMention && isXProductUser && mentionProvider && mentionProvider.inviteXProductUser) {
|
|
430
434
|
mentionProvider.inviteXProductUser(id, name);
|
|
431
435
|
}
|
|
432
436
|
return insert(createSingleMentionFragment({
|
|
433
437
|
mentionProvider,
|
|
434
438
|
mentionInsertDisplayName,
|
|
435
439
|
tr: state.tr,
|
|
436
|
-
sanitizePrivateContent
|
|
440
|
+
sanitizePrivateContent,
|
|
441
|
+
suppressInviteXProductUser: shouldSuppressInviteForAgentMention
|
|
437
442
|
})({
|
|
438
443
|
name,
|
|
439
444
|
id,
|
|
@@ -3,11 +3,16 @@ import uuid from 'uuid';
|
|
|
3
3
|
import { getAnnotationMarksForPos } from '@atlaskit/editor-common/utils';
|
|
4
4
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
|
|
6
|
+
import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
7
|
+
var isAgentUserType = function isAgentUserType(userType) {
|
|
8
|
+
return userType === 'APP' || userType === 'AGENT';
|
|
9
|
+
};
|
|
6
10
|
export var createSingleMentionFragment = function createSingleMentionFragment(_ref) {
|
|
7
11
|
var mentionInsertDisplayName = _ref.mentionInsertDisplayName,
|
|
8
12
|
mentionProvider = _ref.mentionProvider,
|
|
9
13
|
tr = _ref.tr,
|
|
10
|
-
sanitizePrivateContent = _ref.sanitizePrivateContent
|
|
14
|
+
sanitizePrivateContent = _ref.sanitizePrivateContent,
|
|
15
|
+
suppressInviteXProductUser = _ref.suppressInviteXProductUser;
|
|
11
16
|
return function (_ref2) {
|
|
12
17
|
var name = _ref2.name,
|
|
13
18
|
id = _ref2.id,
|
|
@@ -19,7 +24,7 @@ export var createSingleMentionFragment = function createSingleMentionFragment(_r
|
|
|
19
24
|
var schema = tr.doc.type.schema;
|
|
20
25
|
var trimmedNickname = nickname && nickname.startsWith('@') ? nickname.slice(1) : nickname;
|
|
21
26
|
var renderName = mentionInsertDisplayName || !trimmedNickname ? name : trimmedNickname;
|
|
22
|
-
if (isXProductUser && mentionProvider && mentionProvider.inviteXProductUser) {
|
|
27
|
+
if (!suppressInviteXProductUser && isXProductUser && mentionProvider !== null && mentionProvider !== void 0 && mentionProvider.inviteXProductUser) {
|
|
23
28
|
mentionProvider.inviteXProductUser(id, name);
|
|
24
29
|
}
|
|
25
30
|
|
|
@@ -62,7 +67,8 @@ export var insertMention = function insertMention(_ref3) {
|
|
|
62
67
|
sanitizePrivateContent: sanitizePrivateContent,
|
|
63
68
|
mentionProvider: mentionProvider,
|
|
64
69
|
mentionInsertDisplayName: mentionInsertDisplayName,
|
|
65
|
-
tr: tr
|
|
70
|
+
tr: tr,
|
|
71
|
+
suppressInviteXProductUser: expVal('platform_editor_agent_mentions', 'isEnabled', false) && isAgentUserType(userType)
|
|
66
72
|
})({
|
|
67
73
|
name: name,
|
|
68
74
|
id: id,
|
|
@@ -15,7 +15,7 @@ export var ACTIONS = {
|
|
|
15
15
|
SET_PROVIDER: 'SET_PROVIDER'
|
|
16
16
|
};
|
|
17
17
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
18
|
-
var PACKAGE_VERSION = "12.
|
|
18
|
+
var PACKAGE_VERSION = "12.3.0";
|
|
19
19
|
var setProvider = function setProvider(provider) {
|
|
20
20
|
return function (state, dispatch) {
|
|
21
21
|
if (dispatch) {
|
|
@@ -17,6 +17,7 @@ import { MENTION_ITEM_HEIGHT, MentionItem } from '@atlaskit/mention/item';
|
|
|
17
17
|
import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
|
|
18
18
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
19
19
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
20
|
+
import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
20
21
|
import { createSingleMentionFragment } from '../../editor-commands';
|
|
21
22
|
import { mentionPlaceholderPluginKey, MENTION_PLACEHOLDER_ACTIONS } from '../../pm-plugins/mentionPlaceholder';
|
|
22
23
|
import { getMentionPluginState } from '../../pm-plugins/utils';
|
|
@@ -24,9 +25,12 @@ import InviteItem, { INVITE_ITEM_DESCRIPTION } from '../InviteItem';
|
|
|
24
25
|
import InviteItemWithEmailDomain from '../InviteItem/InviteItemWithEmailDomain';
|
|
25
26
|
import { buildTypeAheadCancelPayload, buildTypeAheadInsertedPayload, buildTypeAheadInviteItemClickedPayload, buildTypeAheadInviteItemViewedPayload, buildTypeAheadRenderedPayload } from './analytics';
|
|
26
27
|
import { isInviteItem, isTeamStats, isTeamType, shouldKeepInviteItem } from './utils';
|
|
27
|
-
var
|
|
28
|
+
var isAgentUserType = function isAgentUserType(userType) {
|
|
28
29
|
return userType === 'APP' || userType === 'AGENT';
|
|
29
30
|
};
|
|
31
|
+
var isAgentMention = function isAgentMention(mention) {
|
|
32
|
+
return isAgentUserType(mention.userType) || mention.appType === 'agent';
|
|
33
|
+
};
|
|
30
34
|
var createInviteItem = function createInviteItem(_ref) {
|
|
31
35
|
var mentionProvider = _ref.mentionProvider,
|
|
32
36
|
onInviteItemMount = _ref.onInviteItemMount,
|
|
@@ -316,7 +320,7 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref6) {
|
|
|
316
320
|
title: intl.formatMessage(mentionMessages.typeAheadSectionPeople),
|
|
317
321
|
filter: function filter(item) {
|
|
318
322
|
var _item$mention;
|
|
319
|
-
return !
|
|
323
|
+
return !isAgentUserType(((_item$mention = item.mention) === null || _item$mention === void 0 ? void 0 : _item$mention.userType) || '');
|
|
320
324
|
},
|
|
321
325
|
limit: 6
|
|
322
326
|
}, {
|
|
@@ -324,7 +328,7 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref6) {
|
|
|
324
328
|
title: intl.formatMessage(mentionMessages.typeAheadSectionAgents),
|
|
325
329
|
filter: function filter(item) {
|
|
326
330
|
var _item$mention2;
|
|
327
|
-
return
|
|
331
|
+
return isAgentUserType(((_item$mention2 = item.mention) === null || _item$mention2 === void 0 ? void 0 : _item$mention2.userType) || '');
|
|
328
332
|
}
|
|
329
333
|
}];
|
|
330
334
|
},
|
|
@@ -352,6 +356,7 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref6) {
|
|
|
352
356
|
var mentionContext = _objectSpread(_objectSpread({}, contextIdentifierProvider), {}, {
|
|
353
357
|
sessionId: sessionId
|
|
354
358
|
});
|
|
359
|
+
var shouldSuppressInviteForAgentMention = expVal('platform_editor_agent_mentions', 'isEnabled', false) && isAgentMention(item.mention);
|
|
355
360
|
if (mentionProvider && !isInviteItem(item.mention)) {
|
|
356
361
|
mentionProvider.recordMentionSelection(item.mention, mentionContext);
|
|
357
362
|
}
|
|
@@ -403,21 +408,20 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref6) {
|
|
|
403
408
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
404
409
|
var mentionLocalId = uuid();
|
|
405
410
|
if (handleMentionsChanged) {
|
|
411
|
+
var mentionChange = _objectSpread({
|
|
412
|
+
id: id,
|
|
413
|
+
localId: mentionLocalId,
|
|
414
|
+
method: 'typed',
|
|
415
|
+
type: 'added'
|
|
416
|
+
}, shouldSuppressInviteForAgentMention ? {
|
|
417
|
+
shouldSuppressMentionNotification: true
|
|
418
|
+
} : {});
|
|
406
419
|
if (taskItemId) {
|
|
407
|
-
handleMentionsChanged([{
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
id: id,
|
|
411
|
-
taskLocalId: taskItemId,
|
|
412
|
-
method: 'typed'
|
|
413
|
-
}]);
|
|
420
|
+
handleMentionsChanged([_objectSpread(_objectSpread({}, mentionChange), {}, {
|
|
421
|
+
taskLocalId: taskItemId
|
|
422
|
+
})]);
|
|
414
423
|
} else {
|
|
415
|
-
handleMentionsChanged([
|
|
416
|
-
type: 'added',
|
|
417
|
-
localId: mentionLocalId,
|
|
418
|
-
id: id,
|
|
419
|
-
method: 'typed'
|
|
420
|
-
}]);
|
|
424
|
+
handleMentionsChanged([mentionChange]);
|
|
421
425
|
}
|
|
422
426
|
}
|
|
423
427
|
fireEvent(buildTypeAheadInsertedPayload(pickerElapsedTime, stats.keyCount.arrowUp, stats.keyCount.arrowDown, sessionId, mode, item.mention, mentionLocalId, sourceListItem.map(function (x) {
|
|
@@ -429,14 +433,15 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref6) {
|
|
|
429
433
|
if (mentionProvider && isTeamType(userType)) {
|
|
430
434
|
return insert(buildNodesForTeamMention(schema, item.mention, mentionProvider, sanitizePrivateContent));
|
|
431
435
|
}
|
|
432
|
-
if (isXProductUser && mentionProvider && mentionProvider.inviteXProductUser) {
|
|
436
|
+
if (!shouldSuppressInviteForAgentMention && isXProductUser && mentionProvider && mentionProvider.inviteXProductUser) {
|
|
433
437
|
mentionProvider.inviteXProductUser(id, name);
|
|
434
438
|
}
|
|
435
439
|
return insert(createSingleMentionFragment({
|
|
436
440
|
mentionProvider: mentionProvider,
|
|
437
441
|
mentionInsertDisplayName: mentionInsertDisplayName,
|
|
438
442
|
tr: state.tr,
|
|
439
|
-
sanitizePrivateContent: sanitizePrivateContent
|
|
443
|
+
sanitizePrivateContent: sanitizePrivateContent,
|
|
444
|
+
suppressInviteXProductUser: shouldSuppressInviteForAgentMention
|
|
440
445
|
})({
|
|
441
446
|
name: name,
|
|
442
447
|
id: id,
|
|
@@ -25,8 +25,9 @@ type SingleMentionFragmentParams = {
|
|
|
25
25
|
mentionInsertDisplayName: boolean | undefined;
|
|
26
26
|
mentionProvider: MentionProvider | undefined;
|
|
27
27
|
sanitizePrivateContent: boolean | undefined;
|
|
28
|
+
suppressInviteXProductUser?: boolean;
|
|
28
29
|
tr: Transaction;
|
|
29
30
|
};
|
|
30
|
-
export declare const createSingleMentionFragment: ({ mentionInsertDisplayName, mentionProvider, tr, sanitizePrivateContent, }: SingleMentionFragmentParams) => ({ name, id, userType, nickname, localId, accessLevel, isXProductUser, }: InsertMentionParameters) => Fragment;
|
|
31
|
+
export declare const createSingleMentionFragment: ({ mentionInsertDisplayName, mentionProvider, tr, sanitizePrivateContent, suppressInviteXProductUser, }: SingleMentionFragmentParams) => ({ name, id, userType, nickname, localId, accessLevel, isXProductUser, }: InsertMentionParameters) => Fragment;
|
|
31
32
|
export declare const insertMention: ({ sanitizePrivateContent, api, mentionInsertDisplayName }: InternalParams) => ({ name, id, userType, localId, nickname, accessLevel, isXProductUser, }: InsertMentionParameters) => EditorCommand;
|
|
32
33
|
export {};
|
|
@@ -11,6 +11,7 @@ export type MentionActionOpenTypeAhead = (inputMethod: TypeAheadInputMethod) =>
|
|
|
11
11
|
export type MentionActionAnnounceMentionsInsertion = (mentionIds: {
|
|
12
12
|
id: string;
|
|
13
13
|
localId: string;
|
|
14
|
+
shouldSuppressMentionNotification?: boolean;
|
|
14
15
|
taskLocalId?: string;
|
|
15
16
|
type: 'added' | 'deleted';
|
|
16
17
|
}[]) => void;
|
|
@@ -17,12 +17,12 @@ export interface MentionPluginConfig {
|
|
|
17
17
|
export type MentionsChangedHandler = (changes: {
|
|
18
18
|
id: string;
|
|
19
19
|
localId: string;
|
|
20
|
+
shouldSuppressMentionNotification?: boolean;
|
|
20
21
|
taskLocalId?: string;
|
|
21
22
|
type: 'added' | 'deleted';
|
|
22
23
|
}[]) => void;
|
|
23
24
|
export interface MentionsPluginOptions extends MentionPluginConfig {
|
|
24
25
|
allowZeroWidthSpaceAfter?: boolean;
|
|
25
|
-
handleMentionsChanged?: MentionsChangedHandler;
|
|
26
26
|
/**
|
|
27
27
|
* User ID to highlight as a self-mention (typically the current user).
|
|
28
28
|
*
|
|
@@ -31,6 +31,7 @@ export interface MentionsPluginOptions extends MentionPluginConfig {
|
|
|
31
31
|
* Takes priority over `MentionProvider.shouldHighlightMention()` if both are present.
|
|
32
32
|
*/
|
|
33
33
|
currentUserId?: string;
|
|
34
|
+
handleMentionsChanged?: MentionsChangedHandler;
|
|
34
35
|
mentionProvider?: Providers['mentionProvider'];
|
|
35
36
|
sanitizePrivateContent?: boolean;
|
|
36
37
|
}
|
|
@@ -25,8 +25,9 @@ type SingleMentionFragmentParams = {
|
|
|
25
25
|
mentionInsertDisplayName: boolean | undefined;
|
|
26
26
|
mentionProvider: MentionProvider | undefined;
|
|
27
27
|
sanitizePrivateContent: boolean | undefined;
|
|
28
|
+
suppressInviteXProductUser?: boolean;
|
|
28
29
|
tr: Transaction;
|
|
29
30
|
};
|
|
30
|
-
export declare const createSingleMentionFragment: ({ mentionInsertDisplayName, mentionProvider, tr, sanitizePrivateContent, }: SingleMentionFragmentParams) => ({ name, id, userType, nickname, localId, accessLevel, isXProductUser, }: InsertMentionParameters) => Fragment;
|
|
31
|
+
export declare const createSingleMentionFragment: ({ mentionInsertDisplayName, mentionProvider, tr, sanitizePrivateContent, suppressInviteXProductUser, }: SingleMentionFragmentParams) => ({ name, id, userType, nickname, localId, accessLevel, isXProductUser, }: InsertMentionParameters) => Fragment;
|
|
31
32
|
export declare const insertMention: ({ sanitizePrivateContent, api, mentionInsertDisplayName }: InternalParams) => ({ name, id, userType, localId, nickname, accessLevel, isXProductUser, }: InsertMentionParameters) => EditorCommand;
|
|
32
33
|
export {};
|
|
@@ -11,6 +11,7 @@ export type MentionActionOpenTypeAhead = (inputMethod: TypeAheadInputMethod) =>
|
|
|
11
11
|
export type MentionActionAnnounceMentionsInsertion = (mentionIds: {
|
|
12
12
|
id: string;
|
|
13
13
|
localId: string;
|
|
14
|
+
shouldSuppressMentionNotification?: boolean;
|
|
14
15
|
taskLocalId?: string;
|
|
15
16
|
type: 'added' | 'deleted';
|
|
16
17
|
}[]) => void;
|
|
@@ -17,12 +17,12 @@ export interface MentionPluginConfig {
|
|
|
17
17
|
export type MentionsChangedHandler = (changes: {
|
|
18
18
|
id: string;
|
|
19
19
|
localId: string;
|
|
20
|
+
shouldSuppressMentionNotification?: boolean;
|
|
20
21
|
taskLocalId?: string;
|
|
21
22
|
type: 'added' | 'deleted';
|
|
22
23
|
}[]) => void;
|
|
23
24
|
export interface MentionsPluginOptions extends MentionPluginConfig {
|
|
24
25
|
allowZeroWidthSpaceAfter?: boolean;
|
|
25
|
-
handleMentionsChanged?: MentionsChangedHandler;
|
|
26
26
|
/**
|
|
27
27
|
* User ID to highlight as a self-mention (typically the current user).
|
|
28
28
|
*
|
|
@@ -31,6 +31,7 @@ export interface MentionsPluginOptions extends MentionPluginConfig {
|
|
|
31
31
|
* Takes priority over `MentionProvider.shouldHighlightMention()` if both are present.
|
|
32
32
|
*/
|
|
33
33
|
currentUserId?: string;
|
|
34
|
+
handleMentionsChanged?: MentionsChangedHandler;
|
|
34
35
|
mentionProvider?: Providers['mentionProvider'];
|
|
35
36
|
sanitizePrivateContent?: boolean;
|
|
36
37
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-mentions",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.3.1",
|
|
4
4
|
"description": "Mentions plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@atlaskit/profilecard": "^25.7.0",
|
|
49
49
|
"@atlaskit/teams-app-config": "^1.12.0",
|
|
50
50
|
"@atlaskit/theme": "^25.0.0",
|
|
51
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
51
|
+
"@atlaskit/tmp-editor-statsig": "^86.0.0",
|
|
52
52
|
"@atlaskit/tokens": "^13.1.0",
|
|
53
53
|
"@atlaskit/user-picker": "^12.1.0",
|
|
54
54
|
"@babel/runtime": "^7.0.0",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"uuid": "^3.1.0"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"@atlaskit/editor-common": "^114.
|
|
62
|
+
"@atlaskit/editor-common": "^114.54.0",
|
|
63
63
|
"react": "^18.2.0",
|
|
64
64
|
"react-dom": "^18.2.0",
|
|
65
65
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|