@atlaskit/editor-plugin-mentions 12.2.10 → 12.3.0
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 +18 -0
- package/dist/cjs/editor-commands/index.js +9 -3
- package/dist/cjs/nodeviews/profileCardRenderer.js +91 -72
- package/dist/cjs/pm-plugins/main.js +1 -1
- package/dist/cjs/ui/ProfileCardComponent.js +95 -36
- package/dist/cjs/ui/type-ahead/index.js +23 -18
- package/dist/es2019/editor-commands/index.js +7 -3
- package/dist/es2019/nodeviews/profileCardRenderer.js +89 -74
- package/dist/es2019/pm-plugins/main.js +1 -1
- package/dist/es2019/ui/ProfileCardComponent.js +67 -17
- package/dist/es2019/ui/type-ahead/index.js +21 -16
- package/dist/esm/editor-commands/index.js +9 -3
- package/dist/esm/nodeviews/profileCardRenderer.js +92 -73
- package/dist/esm/pm-plugins/main.js +1 -1
- package/dist/esm/ui/ProfileCardComponent.js +91 -34
- 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/ProfileCardComponent.d.ts +4 -0
- 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/ProfileCardComponent.d.ts +4 -0
- package/dist/types-ts4.5/ui/type-ahead/index.d.ts +1 -0
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-mentions
|
|
2
2
|
|
|
3
|
+
## 12.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`3b29bddd3f460`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3b29bddd3f460) -
|
|
8
|
+
Suppress human invite flow for agent mentions
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
14
|
+
## 12.2.11
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [`8a065eba1d509`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8a065eba1d509) -
|
|
19
|
+
Show agent profile cards for agent mentions in the editor.
|
|
20
|
+
|
|
3
21
|
## 12.2.10
|
|
4
22
|
|
|
5
23
|
### 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,
|
|
@@ -11,6 +11,7 @@ var _v = _interopRequireDefault(require("uuid/v4"));
|
|
|
11
11
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
12
12
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
13
|
var _navigation = require("@atlaskit/teams-app-config/navigation");
|
|
14
|
+
var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
|
|
14
15
|
var _ProfileCardComponent = require("../ui/ProfileCardComponent");
|
|
15
16
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
16
17
|
|
|
@@ -34,87 +35,105 @@ var profileCardRenderer = exports.profileCardRenderer = function profileCardRend
|
|
|
34
35
|
renderingProfileCard = false;
|
|
35
36
|
(_cleanupSelection = cleanupSelection) === null || _cleanupSelection === void 0 || _cleanupSelection();
|
|
36
37
|
};
|
|
38
|
+
var renderProfileCardPopup = function renderProfileCardPopup(renderProfileCard) {
|
|
39
|
+
var _api$selection;
|
|
40
|
+
if (!(dom instanceof HTMLElement) || renderingProfileCard) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
var referenceElement = dom;
|
|
44
|
+
referenceElement.setAttribute('aria-expanded', 'true');
|
|
45
|
+
renderingProfileCard = true;
|
|
46
|
+
portalProviderAPI.render(function () {
|
|
47
|
+
return renderProfileCard(referenceElement);
|
|
48
|
+
}, referenceElement, key);
|
|
49
|
+
cleanupSelection = api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : _api$selection.sharedState.onChange(function (_ref2) {
|
|
50
|
+
var nextSharedState = _ref2.nextSharedState;
|
|
51
|
+
var selection = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.selection;
|
|
52
|
+
if (selection instanceof _state.NodeSelection ? selection.node === node : false) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
removeProfileCard === null || removeProfileCard === void 0 || removeProfileCard();
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
var renderEditorProfileCard = function renderEditorProfileCard() {
|
|
59
|
+
renderProfileCardPopup(function (referenceElement) {
|
|
60
|
+
return /*#__PURE__*/_react.default.createElement(_ProfileCardComponent.ProfileCardComponent, {
|
|
61
|
+
activeMention: node,
|
|
62
|
+
profilecardProvider: options === null || options === void 0 ? void 0 : options.profilecardProvider,
|
|
63
|
+
dom: referenceElement,
|
|
64
|
+
closeComponent: removeProfileCard
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
var renderUserProfileCard = function renderUserProfileCard(_ref3) {
|
|
69
|
+
var userId = _ref3.userId,
|
|
70
|
+
cloudId = _ref3.cloudId,
|
|
71
|
+
renderUserMentionCard = _ref3.renderUserMentionCard;
|
|
72
|
+
if (!renderUserMentionCard) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
renderProfileCardPopup(function (referenceElement) {
|
|
76
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, renderUserMentionCard({
|
|
77
|
+
userId: userId,
|
|
78
|
+
cloudId: cloudId,
|
|
79
|
+
children: null,
|
|
80
|
+
referenceElement: referenceElement
|
|
81
|
+
}));
|
|
82
|
+
});
|
|
83
|
+
return true;
|
|
84
|
+
};
|
|
85
|
+
var navigateToProfile = function navigateToProfile(userId, cloudId) {
|
|
86
|
+
if (navigatingToProfile) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
navigatingToProfile = true;
|
|
90
|
+
var _navigateToTeamsApp = (0, _navigation.navigateToTeamsApp)({
|
|
91
|
+
type: 'USER',
|
|
92
|
+
payload: {
|
|
93
|
+
userId: userId
|
|
94
|
+
},
|
|
95
|
+
cloudId: cloudId
|
|
96
|
+
}),
|
|
97
|
+
href = _navigateToTeamsApp.href,
|
|
98
|
+
target = _navigateToTeamsApp.target;
|
|
99
|
+
window.open(href, target, 'noopener,noreferrer');
|
|
100
|
+
};
|
|
101
|
+
var renderDefaultProfileCard = function renderDefaultProfileCard(userId, provider) {
|
|
102
|
+
if (renderUserProfileCard({
|
|
103
|
+
userId: userId,
|
|
104
|
+
cloudId: provider.cloudId,
|
|
105
|
+
renderUserMentionCard: provider.renderUserMentionCard
|
|
106
|
+
})) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
navigateToProfile(userId, provider.cloudId);
|
|
110
|
+
};
|
|
37
111
|
var listenerCleanup = (0, _bindEventListener.bind)(dom, {
|
|
38
112
|
type: 'click',
|
|
39
113
|
listener: function listener() {
|
|
40
114
|
if ((0, _platformFeatureFlags.fg)('people-teams_migrate-user-profile-card')) {
|
|
41
|
-
var _node$attrs;
|
|
115
|
+
var _node$attrs, _options$profilecardP;
|
|
42
116
|
var userId = (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.id;
|
|
43
|
-
if (userId) {
|
|
44
|
-
|
|
45
|
-
navigatingToProfile = false;
|
|
46
|
-
options === null || options === void 0 || (_options$profilecardP = options.profilecardProvider) === null || _options$profilecardP === void 0 || _options$profilecardP.then(function (provider) {
|
|
47
|
-
// If a consumer (e.g. Confluence) has supplied a custom profile card
|
|
48
|
-
// renderer, render it into the portal instead of navigating away. The
|
|
49
|
-
// consumer owns its own popup/positioning behavior - subsequent clicks
|
|
50
|
-
// while the card is already open are no-ops here so the card's own
|
|
51
|
-
// outside-click / toggle logic can take over.
|
|
52
|
-
if (provider.renderUserMentionCard) {
|
|
53
|
-
if (dom instanceof HTMLElement && !renderingProfileCard) {
|
|
54
|
-
var _api$selection;
|
|
55
|
-
dom.setAttribute('aria-expanded', 'true');
|
|
56
|
-
renderingProfileCard = true;
|
|
57
|
-
portalProviderAPI.render(function () {
|
|
58
|
-
var _provider$renderUserM;
|
|
59
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, (_provider$renderUserM = provider.renderUserMentionCard) === null || _provider$renderUserM === void 0 ? void 0 : _provider$renderUserM.call(provider, {
|
|
60
|
-
userId: userId,
|
|
61
|
-
cloudId: provider.cloudId,
|
|
62
|
-
children: null,
|
|
63
|
-
referenceElement: dom
|
|
64
|
-
}));
|
|
65
|
-
}, dom, key);
|
|
66
|
-
cleanupSelection = api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : _api$selection.sharedState.onChange(function (_ref2) {
|
|
67
|
-
var nextSharedState = _ref2.nextSharedState;
|
|
68
|
-
var selection = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.selection;
|
|
69
|
-
if (selection instanceof _state.NodeSelection ? selection.node === node : false) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
removeProfileCard === null || removeProfileCard === void 0 || removeProfileCard();
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
if (navigatingToProfile) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
navigatingToProfile = true;
|
|
81
|
-
var _navigateToTeamsApp = (0, _navigation.navigateToTeamsApp)({
|
|
82
|
-
type: 'USER',
|
|
83
|
-
payload: {
|
|
84
|
-
userId: userId
|
|
85
|
-
},
|
|
86
|
-
cloudId: provider.cloudId
|
|
87
|
-
}),
|
|
88
|
-
href = _navigateToTeamsApp.href,
|
|
89
|
-
target = _navigateToTeamsApp.target;
|
|
90
|
-
window.open(href, target, 'noopener,noreferrer');
|
|
91
|
-
});
|
|
117
|
+
if (!userId) {
|
|
118
|
+
return;
|
|
92
119
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
renderingProfileCard = true;
|
|
99
|
-
portalProviderAPI.render(function () {
|
|
100
|
-
return /*#__PURE__*/_react.default.createElement(_ProfileCardComponent.ProfileCardComponent, {
|
|
101
|
-
activeMention: node,
|
|
102
|
-
profilecardProvider: options === null || options === void 0 ? void 0 : options.profilecardProvider,
|
|
103
|
-
dom: dom,
|
|
104
|
-
closeComponent: removeProfileCard
|
|
105
|
-
});
|
|
106
|
-
}, dom, key);
|
|
107
|
-
// If we change the selection we should also remove the profile card. The "deselectNode"
|
|
108
|
-
// should usually catch this, but it's possible (ie. on triple click) for this not to be called
|
|
109
|
-
// which means the profile card gets stuck open until you click + change selection
|
|
110
|
-
cleanupSelection = api === null || api === void 0 || (_api$selection2 = api.selection) === null || _api$selection2 === void 0 ? void 0 : _api$selection2.sharedState.onChange(function (_ref3) {
|
|
111
|
-
var nextSharedState = _ref3.nextSharedState;
|
|
112
|
-
var selection = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.selection;
|
|
113
|
-
if (selection instanceof _state.NodeSelection ? selection.node === node : false) {
|
|
120
|
+
navigatingToProfile = false;
|
|
121
|
+
options === null || options === void 0 || (_options$profilecardP = options.profilecardProvider) === null || _options$profilecardP === void 0 || _options$profilecardP.then(function (provider) {
|
|
122
|
+
var _node$attrs2;
|
|
123
|
+
if (!(0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false)) {
|
|
124
|
+
renderDefaultProfileCard(userId, provider);
|
|
114
125
|
return;
|
|
115
126
|
}
|
|
116
|
-
|
|
127
|
+
if ((0, _ProfileCardComponent.isAgentMentionType)((_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.userType)) {
|
|
128
|
+
renderEditorProfileCard();
|
|
129
|
+
} else {
|
|
130
|
+
renderDefaultProfileCard(userId, provider);
|
|
131
|
+
}
|
|
117
132
|
});
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (options !== null && options !== void 0 && options.profilecardProvider) {
|
|
136
|
+
renderEditorProfileCard();
|
|
118
137
|
}
|
|
119
138
|
}
|
|
120
139
|
});
|
|
@@ -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.2.
|
|
26
|
+
var PACKAGE_VERSION = "12.2.11";
|
|
27
27
|
var setProvider = function setProvider(provider) {
|
|
28
28
|
return function (state, dispatch) {
|
|
29
29
|
if (dispatch) {
|
|
@@ -2,37 +2,56 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
5
|
Object.defineProperty(exports, "__esModule", {
|
|
7
6
|
value: true
|
|
8
7
|
});
|
|
9
8
|
exports.ProfileCardComponent = ProfileCardComponent;
|
|
10
|
-
exports.useProfileCardState = void 0;
|
|
9
|
+
exports.useProfileCardState = exports.isAgentMentionType = void 0;
|
|
11
10
|
require("./ProfileCardComponent.compiled.css");
|
|
12
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
12
|
var React = _react;
|
|
14
13
|
var _runtime = require("@compiled/react/runtime");
|
|
15
14
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
15
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
16
16
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
17
17
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
18
18
|
var _bindEventListener = require("bind-event-listener");
|
|
19
|
+
var _reactLoadable = _interopRequireDefault(require("react-loadable"));
|
|
19
20
|
var _user = require("@atlaskit/profilecard/user");
|
|
20
21
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
22
|
+
var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
|
|
21
23
|
var _PopperWrapper = require("./PopperWrapper");
|
|
22
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" !=
|
|
24
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != (0, _typeof2.default)(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
|
|
25
|
+
var AgentProfileCardResourcedLazy = (0, _reactLoadable.default)({
|
|
26
|
+
loader: function loader() {
|
|
27
|
+
return Promise.resolve().then(function () {
|
|
28
|
+
return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_editor-plugin-mentions-agent-profile-card-resourced" */
|
|
29
|
+
'@atlaskit/profilecard/agent-profile-card-resourced'));
|
|
30
|
+
}).then(function (_ref) {
|
|
31
|
+
var AgentProfileCardResourced = _ref.AgentProfileCardResourced;
|
|
32
|
+
return AgentProfileCardResourced;
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
loading: function loading() {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
23
39
|
var styles = {
|
|
24
40
|
loadingStyles: "_2rko12b0 _16qs130s"
|
|
25
41
|
};
|
|
26
|
-
var LoadingWrapper = function LoadingWrapper(
|
|
27
|
-
var children =
|
|
28
|
-
isLoading =
|
|
42
|
+
var LoadingWrapper = function LoadingWrapper(_ref2) {
|
|
43
|
+
var children = _ref2.children,
|
|
44
|
+
isLoading = _ref2.isLoading;
|
|
29
45
|
return isLoading ? /*#__PURE__*/React.createElement("div", {
|
|
30
46
|
className: (0, _runtime.ax)([styles.loadingStyles])
|
|
31
47
|
}, children) : children;
|
|
32
48
|
};
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
|
|
49
|
+
var isAgentMentionType = exports.isAgentMentionType = function isAgentMentionType(userType) {
|
|
50
|
+
return userType === 'APP' || userType === 'AGENT';
|
|
51
|
+
};
|
|
52
|
+
var useProfileCardState = exports.useProfileCardState = function useProfileCardState(_ref3) {
|
|
53
|
+
var id = _ref3.id,
|
|
54
|
+
provider = _ref3.provider;
|
|
36
55
|
var _useState = (0, _react.useState)(),
|
|
37
56
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
38
57
|
data = _useState2[0],
|
|
@@ -61,7 +80,7 @@ var useProfileCardState = exports.useProfileCardState = function useProfileCardS
|
|
|
61
80
|
// From: packages/people-and-teams/profilecard/src/components/User/ProfileCardTrigger.tsx
|
|
62
81
|
(0, _react.useEffect)(function () {
|
|
63
82
|
var fetchData = /*#__PURE__*/function () {
|
|
64
|
-
var
|
|
83
|
+
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
65
84
|
var _yield$Promise$all, _yield$Promise$all2, _data, reportingLines, shouldGiveKudos, _teamCentralBaseUrl, _t;
|
|
66
85
|
return _regenerator.default.wrap(function (_context) {
|
|
67
86
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -108,7 +127,7 @@ var useProfileCardState = exports.useProfileCardState = function useProfileCardS
|
|
|
108
127
|
}, _callee, null, [[2, 4, 5, 6]]);
|
|
109
128
|
}));
|
|
110
129
|
return function fetchData() {
|
|
111
|
-
return
|
|
130
|
+
return _ref4.apply(this, arguments);
|
|
112
131
|
};
|
|
113
132
|
}();
|
|
114
133
|
fetchData();
|
|
@@ -122,12 +141,16 @@ var useProfileCardState = exports.useProfileCardState = function useProfileCardS
|
|
|
122
141
|
hasError: hasError
|
|
123
142
|
};
|
|
124
143
|
};
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Renders the profile card popup for an editor mention node.
|
|
147
|
+
*/
|
|
148
|
+
function ProfileCardComponent(_ref5) {
|
|
149
|
+
var _ref7;
|
|
150
|
+
var profilecardProvider = _ref5.profilecardProvider,
|
|
151
|
+
activeMention = _ref5.activeMention,
|
|
152
|
+
dom = _ref5.dom,
|
|
153
|
+
closeComponent = _ref5.closeComponent;
|
|
131
154
|
var _useState11 = (0, _react.useState)(undefined),
|
|
132
155
|
_useState12 = (0, _slicedToArray2.default)(_useState11, 2),
|
|
133
156
|
provider = _useState12[0],
|
|
@@ -137,10 +160,58 @@ function ProfileCardComponent(_ref4) {
|
|
|
137
160
|
setProvider(p);
|
|
138
161
|
});
|
|
139
162
|
}, [profilecardProvider]);
|
|
140
|
-
var
|
|
141
|
-
id =
|
|
142
|
-
text =
|
|
143
|
-
accessLevel =
|
|
163
|
+
var _ref6 = (_ref7 = activeMention.attrs) !== null && _ref7 !== void 0 ? _ref7 : {},
|
|
164
|
+
id = _ref6.id,
|
|
165
|
+
text = _ref6.text,
|
|
166
|
+
accessLevel = _ref6.accessLevel,
|
|
167
|
+
userType = _ref6.userType;
|
|
168
|
+
(0, _react.useEffect)(function () {
|
|
169
|
+
return (0, _bindEventListener.bind)(window, {
|
|
170
|
+
type: 'keydown',
|
|
171
|
+
listener: function listener(e) {
|
|
172
|
+
if (e.key === 'Escape') {
|
|
173
|
+
closeComponent();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
if (!(0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false)) {
|
|
179
|
+
return /*#__PURE__*/React.createElement(_PopperWrapper.Popup, {
|
|
180
|
+
referenceElement: dom
|
|
181
|
+
}, /*#__PURE__*/React.createElement(UserProfileCardContent, {
|
|
182
|
+
accessLevel: accessLevel,
|
|
183
|
+
id: id,
|
|
184
|
+
provider: provider,
|
|
185
|
+
text: text
|
|
186
|
+
}));
|
|
187
|
+
}
|
|
188
|
+
var isAgentMention = isAgentMentionType(userType);
|
|
189
|
+
return /*#__PURE__*/React.createElement(_PopperWrapper.Popup, {
|
|
190
|
+
referenceElement: dom
|
|
191
|
+
}, isAgentMention && provider && id ? /*#__PURE__*/React.createElement(AgentProfileCardContent, {
|
|
192
|
+
accountId: id,
|
|
193
|
+
provider: provider
|
|
194
|
+
}) : /*#__PURE__*/React.createElement(UserProfileCardContent, {
|
|
195
|
+
accessLevel: accessLevel,
|
|
196
|
+
id: id,
|
|
197
|
+
provider: provider,
|
|
198
|
+
text: text
|
|
199
|
+
}));
|
|
200
|
+
}
|
|
201
|
+
var AgentProfileCardContent = function AgentProfileCardContent(_ref8) {
|
|
202
|
+
var accountId = _ref8.accountId,
|
|
203
|
+
provider = _ref8.provider;
|
|
204
|
+
return /*#__PURE__*/React.createElement(AgentProfileCardResourcedLazy, {
|
|
205
|
+
accountId: accountId,
|
|
206
|
+
cloudId: provider.cloudId,
|
|
207
|
+
resourceClient: provider.resourceClient
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
var UserProfileCardContent = function UserProfileCardContent(_ref9) {
|
|
211
|
+
var accessLevel = _ref9.accessLevel,
|
|
212
|
+
id = _ref9.id,
|
|
213
|
+
provider = _ref9.provider,
|
|
214
|
+
text = _ref9.text;
|
|
144
215
|
var actions = (0, _react.useMemo)(function () {
|
|
145
216
|
return provider === null || provider === void 0 ? void 0 : provider.getActions(id, text !== null && text !== void 0 ? text : '', accessLevel);
|
|
146
217
|
}, [accessLevel, id, provider, text]);
|
|
@@ -154,19 +225,7 @@ function ProfileCardComponent(_ref4) {
|
|
|
154
225
|
teamCentralBaseUrl = _useProfileCardState.teamCentralBaseUrl,
|
|
155
226
|
isLoading = _useProfileCardState.isLoading,
|
|
156
227
|
hasError = _useProfileCardState.hasError;
|
|
157
|
-
|
|
158
|
-
return (0, _bindEventListener.bind)(window, {
|
|
159
|
-
type: 'keydown',
|
|
160
|
-
listener: function listener(e) {
|
|
161
|
-
if (e.key === 'Escape') {
|
|
162
|
-
closeComponent();
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
return /*#__PURE__*/React.createElement(_PopperWrapper.Popup, {
|
|
168
|
-
referenceElement: dom
|
|
169
|
-
}, /*#__PURE__*/React.createElement(LoadingWrapper, {
|
|
228
|
+
return /*#__PURE__*/React.createElement(LoadingWrapper, {
|
|
170
229
|
isLoading: isLoading
|
|
171
230
|
}, /*#__PURE__*/React.createElement(_user.ProfileCardLazy, {
|
|
172
231
|
avatarUrl: data === null || data === void 0 ? void 0 : data.avatarUrl,
|
|
@@ -191,5 +250,5 @@ function ProfileCardComponent(_ref4) {
|
|
|
191
250
|
isKudosEnabled: shouldShowGiveKudos,
|
|
192
251
|
teamCentralBaseUrl: teamCentralBaseUrl,
|
|
193
252
|
isRenderedInPortal: (0, _expValEquals.expValEquals)('editor_a11y_7152_profile_card_tab_order', 'isEnabled', true)
|
|
194
|
-
}))
|
|
195
|
-
}
|
|
253
|
+
}));
|
|
254
|
+
};
|
|
@@ -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,
|