@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
|
@@ -5,7 +5,8 @@ import uuid from 'uuid/v4';
|
|
|
5
5
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
7
|
import { navigateToTeamsApp } from '@atlaskit/teams-app-config/navigation';
|
|
8
|
-
import {
|
|
8
|
+
import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
9
|
+
import { isAgentMentionType, ProfileCardComponent } from '../ui/ProfileCardComponent';
|
|
9
10
|
export const profileCardRenderer = ({
|
|
10
11
|
dom,
|
|
11
12
|
options,
|
|
@@ -27,88 +28,102 @@ export const profileCardRenderer = ({
|
|
|
27
28
|
renderingProfileCard = false;
|
|
28
29
|
(_cleanupSelection = cleanupSelection) === null || _cleanupSelection === void 0 ? void 0 : _cleanupSelection();
|
|
29
30
|
};
|
|
31
|
+
const renderProfileCardPopup = renderProfileCard => {
|
|
32
|
+
var _api$selection;
|
|
33
|
+
if (!(dom instanceof HTMLElement) || renderingProfileCard) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const referenceElement = dom;
|
|
37
|
+
referenceElement.setAttribute('aria-expanded', 'true');
|
|
38
|
+
renderingProfileCard = true;
|
|
39
|
+
portalProviderAPI.render(() => renderProfileCard(referenceElement), referenceElement, key);
|
|
40
|
+
cleanupSelection = api === null || api === void 0 ? void 0 : (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : _api$selection.sharedState.onChange(({
|
|
41
|
+
nextSharedState
|
|
42
|
+
}) => {
|
|
43
|
+
const selection = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.selection;
|
|
44
|
+
if (selection instanceof NodeSelection ? selection.node === node : false) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
removeProfileCard === null || removeProfileCard === void 0 ? void 0 : removeProfileCard();
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
const renderEditorProfileCard = () => {
|
|
51
|
+
renderProfileCardPopup(referenceElement => /*#__PURE__*/React.createElement(ProfileCardComponent, {
|
|
52
|
+
activeMention: node,
|
|
53
|
+
profilecardProvider: options === null || options === void 0 ? void 0 : options.profilecardProvider,
|
|
54
|
+
dom: referenceElement,
|
|
55
|
+
closeComponent: removeProfileCard
|
|
56
|
+
}));
|
|
57
|
+
};
|
|
58
|
+
const renderUserProfileCard = ({
|
|
59
|
+
userId,
|
|
60
|
+
cloudId,
|
|
61
|
+
renderUserMentionCard
|
|
62
|
+
}) => {
|
|
63
|
+
if (!renderUserMentionCard) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
renderProfileCardPopup(referenceElement => /*#__PURE__*/React.createElement(React.Fragment, null, renderUserMentionCard({
|
|
67
|
+
userId,
|
|
68
|
+
cloudId,
|
|
69
|
+
children: null,
|
|
70
|
+
referenceElement
|
|
71
|
+
})));
|
|
72
|
+
return true;
|
|
73
|
+
};
|
|
74
|
+
const navigateToProfile = (userId, cloudId) => {
|
|
75
|
+
if (navigatingToProfile) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
navigatingToProfile = true;
|
|
79
|
+
const {
|
|
80
|
+
href,
|
|
81
|
+
target
|
|
82
|
+
} = navigateToTeamsApp({
|
|
83
|
+
type: 'USER',
|
|
84
|
+
payload: {
|
|
85
|
+
userId
|
|
86
|
+
},
|
|
87
|
+
cloudId
|
|
88
|
+
});
|
|
89
|
+
window.open(href, target, 'noopener,noreferrer');
|
|
90
|
+
};
|
|
91
|
+
const renderDefaultProfileCard = (userId, provider) => {
|
|
92
|
+
if (renderUserProfileCard({
|
|
93
|
+
userId,
|
|
94
|
+
cloudId: provider.cloudId,
|
|
95
|
+
renderUserMentionCard: provider.renderUserMentionCard
|
|
96
|
+
})) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
navigateToProfile(userId, provider.cloudId);
|
|
100
|
+
};
|
|
30
101
|
const listenerCleanup = bind(dom, {
|
|
31
102
|
type: 'click',
|
|
32
103
|
listener: () => {
|
|
33
104
|
if (fg('people-teams_migrate-user-profile-card')) {
|
|
34
|
-
var _node$attrs;
|
|
105
|
+
var _node$attrs, _options$profilecardP;
|
|
35
106
|
const userId = (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.id;
|
|
36
|
-
if (userId) {
|
|
37
|
-
|
|
38
|
-
navigatingToProfile = false;
|
|
39
|
-
options === null || options === void 0 ? void 0 : (_options$profilecardP = options.profilecardProvider) === null || _options$profilecardP === void 0 ? void 0 : _options$profilecardP.then(provider => {
|
|
40
|
-
// If a consumer (e.g. Confluence) has supplied a custom profile card
|
|
41
|
-
// renderer, render it into the portal instead of navigating away. The
|
|
42
|
-
// consumer owns its own popup/positioning behavior - subsequent clicks
|
|
43
|
-
// while the card is already open are no-ops here so the card's own
|
|
44
|
-
// outside-click / toggle logic can take over.
|
|
45
|
-
if (provider.renderUserMentionCard) {
|
|
46
|
-
if (dom instanceof HTMLElement && !renderingProfileCard) {
|
|
47
|
-
var _api$selection;
|
|
48
|
-
dom.setAttribute('aria-expanded', 'true');
|
|
49
|
-
renderingProfileCard = true;
|
|
50
|
-
portalProviderAPI.render(() => {
|
|
51
|
-
var _provider$renderUserM;
|
|
52
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, (_provider$renderUserM = provider.renderUserMentionCard) === null || _provider$renderUserM === void 0 ? void 0 : _provider$renderUserM.call(provider, {
|
|
53
|
-
userId,
|
|
54
|
-
cloudId: provider.cloudId,
|
|
55
|
-
children: null,
|
|
56
|
-
referenceElement: dom
|
|
57
|
-
}));
|
|
58
|
-
}, dom, key);
|
|
59
|
-
cleanupSelection = api === null || api === void 0 ? void 0 : (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : _api$selection.sharedState.onChange(({
|
|
60
|
-
nextSharedState
|
|
61
|
-
}) => {
|
|
62
|
-
const selection = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.selection;
|
|
63
|
-
if (selection instanceof NodeSelection ? selection.node === node : false) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
removeProfileCard === null || removeProfileCard === void 0 ? void 0 : removeProfileCard();
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
if (navigatingToProfile) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
navigatingToProfile = true;
|
|
75
|
-
const {
|
|
76
|
-
href,
|
|
77
|
-
target
|
|
78
|
-
} = navigateToTeamsApp({
|
|
79
|
-
type: 'USER',
|
|
80
|
-
payload: {
|
|
81
|
-
userId
|
|
82
|
-
},
|
|
83
|
-
cloudId: provider.cloudId
|
|
84
|
-
});
|
|
85
|
-
window.open(href, target, 'noopener,noreferrer');
|
|
86
|
-
});
|
|
107
|
+
if (!userId) {
|
|
108
|
+
return;
|
|
87
109
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
renderingProfileCard = true;
|
|
94
|
-
portalProviderAPI.render(() => /*#__PURE__*/React.createElement(ProfileCardComponent, {
|
|
95
|
-
activeMention: node,
|
|
96
|
-
profilecardProvider: options === null || options === void 0 ? void 0 : options.profilecardProvider,
|
|
97
|
-
dom: dom,
|
|
98
|
-
closeComponent: removeProfileCard
|
|
99
|
-
}), dom, key);
|
|
100
|
-
// If we change the selection we should also remove the profile card. The "deselectNode"
|
|
101
|
-
// should usually catch this, but it's possible (ie. on triple click) for this not to be called
|
|
102
|
-
// which means the profile card gets stuck open until you click + change selection
|
|
103
|
-
cleanupSelection = api === null || api === void 0 ? void 0 : (_api$selection2 = api.selection) === null || _api$selection2 === void 0 ? void 0 : _api$selection2.sharedState.onChange(({
|
|
104
|
-
nextSharedState
|
|
105
|
-
}) => {
|
|
106
|
-
const selection = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.selection;
|
|
107
|
-
if (selection instanceof NodeSelection ? selection.node === node : false) {
|
|
110
|
+
navigatingToProfile = false;
|
|
111
|
+
options === null || options === void 0 ? void 0 : (_options$profilecardP = options.profilecardProvider) === null || _options$profilecardP === void 0 ? void 0 : _options$profilecardP.then(provider => {
|
|
112
|
+
var _node$attrs2;
|
|
113
|
+
if (!expVal('platform_editor_agent_mentions', 'isEnabled', false)) {
|
|
114
|
+
renderDefaultProfileCard(userId, provider);
|
|
108
115
|
return;
|
|
109
116
|
}
|
|
110
|
-
|
|
117
|
+
if (isAgentMentionType((_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.userType)) {
|
|
118
|
+
renderEditorProfileCard();
|
|
119
|
+
} else {
|
|
120
|
+
renderDefaultProfileCard(userId, provider);
|
|
121
|
+
}
|
|
111
122
|
});
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (options !== null && options !== void 0 && options.profilecardProvider) {
|
|
126
|
+
renderEditorProfileCard();
|
|
112
127
|
}
|
|
113
128
|
}
|
|
114
129
|
});
|
|
@@ -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.2.
|
|
15
|
+
const PACKAGE_VERSION = "12.2.11";
|
|
16
16
|
const setProvider = provider => (state, dispatch) => {
|
|
17
17
|
if (dispatch) {
|
|
18
18
|
dispatch(state.tr.setMeta(mentionPluginKey, {
|
|
@@ -2,11 +2,20 @@
|
|
|
2
2
|
import "./ProfileCardComponent.compiled.css";
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
-
import { useEffect,
|
|
5
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
6
6
|
import { bind } from 'bind-event-listener';
|
|
7
|
+
import Loadable from 'react-loadable';
|
|
7
8
|
import { ProfileCardLazy } from '@atlaskit/profilecard/user';
|
|
8
9
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
10
|
+
import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
9
11
|
import { Popup } from './PopperWrapper';
|
|
12
|
+
const AgentProfileCardResourcedLazy = Loadable({
|
|
13
|
+
loader: () => import( /* webpackChunkName: "@atlaskit-internal_editor-plugin-mentions-agent-profile-card-resourced" */
|
|
14
|
+
'@atlaskit/profilecard/agent-profile-card-resourced').then(({
|
|
15
|
+
AgentProfileCardResourced
|
|
16
|
+
}) => AgentProfileCardResourced),
|
|
17
|
+
loading: () => null
|
|
18
|
+
});
|
|
10
19
|
const styles = {
|
|
11
20
|
loadingStyles: "_2rko12b0 _16qs130s"
|
|
12
21
|
};
|
|
@@ -16,6 +25,7 @@ const LoadingWrapper = ({
|
|
|
16
25
|
}) => isLoading ? /*#__PURE__*/React.createElement("div", {
|
|
17
26
|
className: ax([styles.loadingStyles])
|
|
18
27
|
}, children) : children;
|
|
28
|
+
export const isAgentMentionType = userType => userType === 'APP' || userType === 'AGENT';
|
|
19
29
|
export const useProfileCardState = ({
|
|
20
30
|
id,
|
|
21
31
|
provider
|
|
@@ -61,6 +71,10 @@ export const useProfileCardState = ({
|
|
|
61
71
|
hasError
|
|
62
72
|
};
|
|
63
73
|
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Renders the profile card popup for an editor mention node.
|
|
77
|
+
*/
|
|
64
78
|
export function ProfileCardComponent({
|
|
65
79
|
profilecardProvider,
|
|
66
80
|
activeMention,
|
|
@@ -77,20 +91,9 @@ export function ProfileCardComponent({
|
|
|
77
91
|
const {
|
|
78
92
|
id,
|
|
79
93
|
text,
|
|
80
|
-
accessLevel
|
|
94
|
+
accessLevel,
|
|
95
|
+
userType
|
|
81
96
|
} = (_ref = activeMention.attrs) !== null && _ref !== void 0 ? _ref : {};
|
|
82
|
-
const actions = useMemo(() => provider === null || provider === void 0 ? void 0 : provider.getActions(id, text !== null && text !== void 0 ? text : '', accessLevel), [accessLevel, id, provider, text]);
|
|
83
|
-
const {
|
|
84
|
-
data,
|
|
85
|
-
reportingLinesData,
|
|
86
|
-
shouldShowGiveKudos,
|
|
87
|
-
teamCentralBaseUrl,
|
|
88
|
-
isLoading,
|
|
89
|
-
hasError
|
|
90
|
-
} = useProfileCardState({
|
|
91
|
-
id,
|
|
92
|
-
provider
|
|
93
|
-
});
|
|
94
97
|
useEffect(() => {
|
|
95
98
|
return bind(window, {
|
|
96
99
|
type: 'keydown',
|
|
@@ -101,9 +104,56 @@ export function ProfileCardComponent({
|
|
|
101
104
|
}
|
|
102
105
|
});
|
|
103
106
|
});
|
|
107
|
+
if (!expVal('platform_editor_agent_mentions', 'isEnabled', false)) {
|
|
108
|
+
return /*#__PURE__*/React.createElement(Popup, {
|
|
109
|
+
referenceElement: dom
|
|
110
|
+
}, /*#__PURE__*/React.createElement(UserProfileCardContent, {
|
|
111
|
+
accessLevel: accessLevel,
|
|
112
|
+
id: id,
|
|
113
|
+
provider: provider,
|
|
114
|
+
text: text
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
117
|
+
const isAgentMention = isAgentMentionType(userType);
|
|
104
118
|
return /*#__PURE__*/React.createElement(Popup, {
|
|
105
119
|
referenceElement: dom
|
|
106
|
-
}, /*#__PURE__*/React.createElement(
|
|
120
|
+
}, isAgentMention && provider && id ? /*#__PURE__*/React.createElement(AgentProfileCardContent, {
|
|
121
|
+
accountId: id,
|
|
122
|
+
provider: provider
|
|
123
|
+
}) : /*#__PURE__*/React.createElement(UserProfileCardContent, {
|
|
124
|
+
accessLevel: accessLevel,
|
|
125
|
+
id: id,
|
|
126
|
+
provider: provider,
|
|
127
|
+
text: text
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
const AgentProfileCardContent = ({
|
|
131
|
+
accountId,
|
|
132
|
+
provider
|
|
133
|
+
}) => /*#__PURE__*/React.createElement(AgentProfileCardResourcedLazy, {
|
|
134
|
+
accountId: accountId,
|
|
135
|
+
cloudId: provider.cloudId,
|
|
136
|
+
resourceClient: provider.resourceClient
|
|
137
|
+
});
|
|
138
|
+
const UserProfileCardContent = ({
|
|
139
|
+
accessLevel,
|
|
140
|
+
id,
|
|
141
|
+
provider,
|
|
142
|
+
text
|
|
143
|
+
}) => {
|
|
144
|
+
const actions = useMemo(() => provider === null || provider === void 0 ? void 0 : provider.getActions(id, text !== null && text !== void 0 ? text : '', accessLevel), [accessLevel, id, provider, text]);
|
|
145
|
+
const {
|
|
146
|
+
data,
|
|
147
|
+
reportingLinesData,
|
|
148
|
+
shouldShowGiveKudos,
|
|
149
|
+
teamCentralBaseUrl,
|
|
150
|
+
isLoading,
|
|
151
|
+
hasError
|
|
152
|
+
} = useProfileCardState({
|
|
153
|
+
id,
|
|
154
|
+
provider
|
|
155
|
+
});
|
|
156
|
+
return /*#__PURE__*/React.createElement(LoadingWrapper, {
|
|
107
157
|
isLoading: isLoading
|
|
108
158
|
}, /*#__PURE__*/React.createElement(ProfileCardLazy, {
|
|
109
159
|
avatarUrl: data === null || data === void 0 ? void 0 : data.avatarUrl,
|
|
@@ -128,5 +178,5 @@ export function ProfileCardComponent({
|
|
|
128
178
|
isKudosEnabled: shouldShowGiveKudos,
|
|
129
179
|
teamCentralBaseUrl: teamCentralBaseUrl,
|
|
130
180
|
isRenderedInPortal: expValEquals('editor_a11y_7152_profile_card_tab_order', 'isEnabled', true)
|
|
131
|
-
}))
|
|
132
|
-
}
|
|
181
|
+
}));
|
|
182
|
+
};
|
|
@@ -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,
|
|
@@ -5,7 +5,8 @@ import uuid from 'uuid/v4';
|
|
|
5
5
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
7
|
import { navigateToTeamsApp } from '@atlaskit/teams-app-config/navigation';
|
|
8
|
-
import {
|
|
8
|
+
import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
9
|
+
import { isAgentMentionType, ProfileCardComponent } from '../ui/ProfileCardComponent';
|
|
9
10
|
export var profileCardRenderer = function profileCardRenderer(_ref) {
|
|
10
11
|
var dom = _ref.dom,
|
|
11
12
|
options = _ref.options,
|
|
@@ -26,87 +27,105 @@ export var profileCardRenderer = function profileCardRenderer(_ref) {
|
|
|
26
27
|
renderingProfileCard = false;
|
|
27
28
|
(_cleanupSelection = cleanupSelection) === null || _cleanupSelection === void 0 || _cleanupSelection();
|
|
28
29
|
};
|
|
30
|
+
var renderProfileCardPopup = function renderProfileCardPopup(renderProfileCard) {
|
|
31
|
+
var _api$selection;
|
|
32
|
+
if (!(dom instanceof HTMLElement) || renderingProfileCard) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
var referenceElement = dom;
|
|
36
|
+
referenceElement.setAttribute('aria-expanded', 'true');
|
|
37
|
+
renderingProfileCard = true;
|
|
38
|
+
portalProviderAPI.render(function () {
|
|
39
|
+
return renderProfileCard(referenceElement);
|
|
40
|
+
}, referenceElement, key);
|
|
41
|
+
cleanupSelection = api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : _api$selection.sharedState.onChange(function (_ref2) {
|
|
42
|
+
var nextSharedState = _ref2.nextSharedState;
|
|
43
|
+
var selection = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.selection;
|
|
44
|
+
if (selection instanceof NodeSelection ? selection.node === node : false) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
removeProfileCard === null || removeProfileCard === void 0 || removeProfileCard();
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
var renderEditorProfileCard = function renderEditorProfileCard() {
|
|
51
|
+
renderProfileCardPopup(function (referenceElement) {
|
|
52
|
+
return /*#__PURE__*/React.createElement(ProfileCardComponent, {
|
|
53
|
+
activeMention: node,
|
|
54
|
+
profilecardProvider: options === null || options === void 0 ? void 0 : options.profilecardProvider,
|
|
55
|
+
dom: referenceElement,
|
|
56
|
+
closeComponent: removeProfileCard
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
var renderUserProfileCard = function renderUserProfileCard(_ref3) {
|
|
61
|
+
var userId = _ref3.userId,
|
|
62
|
+
cloudId = _ref3.cloudId,
|
|
63
|
+
renderUserMentionCard = _ref3.renderUserMentionCard;
|
|
64
|
+
if (!renderUserMentionCard) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
renderProfileCardPopup(function (referenceElement) {
|
|
68
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, renderUserMentionCard({
|
|
69
|
+
userId: userId,
|
|
70
|
+
cloudId: cloudId,
|
|
71
|
+
children: null,
|
|
72
|
+
referenceElement: referenceElement
|
|
73
|
+
}));
|
|
74
|
+
});
|
|
75
|
+
return true;
|
|
76
|
+
};
|
|
77
|
+
var navigateToProfile = function navigateToProfile(userId, cloudId) {
|
|
78
|
+
if (navigatingToProfile) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
navigatingToProfile = true;
|
|
82
|
+
var _navigateToTeamsApp = navigateToTeamsApp({
|
|
83
|
+
type: 'USER',
|
|
84
|
+
payload: {
|
|
85
|
+
userId: userId
|
|
86
|
+
},
|
|
87
|
+
cloudId: cloudId
|
|
88
|
+
}),
|
|
89
|
+
href = _navigateToTeamsApp.href,
|
|
90
|
+
target = _navigateToTeamsApp.target;
|
|
91
|
+
window.open(href, target, 'noopener,noreferrer');
|
|
92
|
+
};
|
|
93
|
+
var renderDefaultProfileCard = function renderDefaultProfileCard(userId, provider) {
|
|
94
|
+
if (renderUserProfileCard({
|
|
95
|
+
userId: userId,
|
|
96
|
+
cloudId: provider.cloudId,
|
|
97
|
+
renderUserMentionCard: provider.renderUserMentionCard
|
|
98
|
+
})) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
navigateToProfile(userId, provider.cloudId);
|
|
102
|
+
};
|
|
29
103
|
var listenerCleanup = bind(dom, {
|
|
30
104
|
type: 'click',
|
|
31
105
|
listener: function listener() {
|
|
32
106
|
if (fg('people-teams_migrate-user-profile-card')) {
|
|
33
|
-
var _node$attrs;
|
|
107
|
+
var _node$attrs, _options$profilecardP;
|
|
34
108
|
var userId = (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.id;
|
|
35
|
-
if (userId) {
|
|
36
|
-
|
|
37
|
-
navigatingToProfile = false;
|
|
38
|
-
options === null || options === void 0 || (_options$profilecardP = options.profilecardProvider) === null || _options$profilecardP === void 0 || _options$profilecardP.then(function (provider) {
|
|
39
|
-
// If a consumer (e.g. Confluence) has supplied a custom profile card
|
|
40
|
-
// renderer, render it into the portal instead of navigating away. The
|
|
41
|
-
// consumer owns its own popup/positioning behavior - subsequent clicks
|
|
42
|
-
// while the card is already open are no-ops here so the card's own
|
|
43
|
-
// outside-click / toggle logic can take over.
|
|
44
|
-
if (provider.renderUserMentionCard) {
|
|
45
|
-
if (dom instanceof HTMLElement && !renderingProfileCard) {
|
|
46
|
-
var _api$selection;
|
|
47
|
-
dom.setAttribute('aria-expanded', 'true');
|
|
48
|
-
renderingProfileCard = true;
|
|
49
|
-
portalProviderAPI.render(function () {
|
|
50
|
-
var _provider$renderUserM;
|
|
51
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, (_provider$renderUserM = provider.renderUserMentionCard) === null || _provider$renderUserM === void 0 ? void 0 : _provider$renderUserM.call(provider, {
|
|
52
|
-
userId: userId,
|
|
53
|
-
cloudId: provider.cloudId,
|
|
54
|
-
children: null,
|
|
55
|
-
referenceElement: dom
|
|
56
|
-
}));
|
|
57
|
-
}, dom, key);
|
|
58
|
-
cleanupSelection = api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : _api$selection.sharedState.onChange(function (_ref2) {
|
|
59
|
-
var nextSharedState = _ref2.nextSharedState;
|
|
60
|
-
var selection = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.selection;
|
|
61
|
-
if (selection instanceof NodeSelection ? selection.node === node : false) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
removeProfileCard === null || removeProfileCard === void 0 || removeProfileCard();
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
if (navigatingToProfile) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
navigatingToProfile = true;
|
|
73
|
-
var _navigateToTeamsApp = navigateToTeamsApp({
|
|
74
|
-
type: 'USER',
|
|
75
|
-
payload: {
|
|
76
|
-
userId: userId
|
|
77
|
-
},
|
|
78
|
-
cloudId: provider.cloudId
|
|
79
|
-
}),
|
|
80
|
-
href = _navigateToTeamsApp.href,
|
|
81
|
-
target = _navigateToTeamsApp.target;
|
|
82
|
-
window.open(href, target, 'noopener,noreferrer');
|
|
83
|
-
});
|
|
109
|
+
if (!userId) {
|
|
110
|
+
return;
|
|
84
111
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
renderingProfileCard = true;
|
|
91
|
-
portalProviderAPI.render(function () {
|
|
92
|
-
return /*#__PURE__*/React.createElement(ProfileCardComponent, {
|
|
93
|
-
activeMention: node,
|
|
94
|
-
profilecardProvider: options === null || options === void 0 ? void 0 : options.profilecardProvider,
|
|
95
|
-
dom: dom,
|
|
96
|
-
closeComponent: removeProfileCard
|
|
97
|
-
});
|
|
98
|
-
}, dom, key);
|
|
99
|
-
// If we change the selection we should also remove the profile card. The "deselectNode"
|
|
100
|
-
// should usually catch this, but it's possible (ie. on triple click) for this not to be called
|
|
101
|
-
// which means the profile card gets stuck open until you click + change selection
|
|
102
|
-
cleanupSelection = api === null || api === void 0 || (_api$selection2 = api.selection) === null || _api$selection2 === void 0 ? void 0 : _api$selection2.sharedState.onChange(function (_ref3) {
|
|
103
|
-
var nextSharedState = _ref3.nextSharedState;
|
|
104
|
-
var selection = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.selection;
|
|
105
|
-
if (selection instanceof NodeSelection ? selection.node === node : false) {
|
|
112
|
+
navigatingToProfile = false;
|
|
113
|
+
options === null || options === void 0 || (_options$profilecardP = options.profilecardProvider) === null || _options$profilecardP === void 0 || _options$profilecardP.then(function (provider) {
|
|
114
|
+
var _node$attrs2;
|
|
115
|
+
if (!expVal('platform_editor_agent_mentions', 'isEnabled', false)) {
|
|
116
|
+
renderDefaultProfileCard(userId, provider);
|
|
106
117
|
return;
|
|
107
118
|
}
|
|
108
|
-
|
|
119
|
+
if (isAgentMentionType((_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.userType)) {
|
|
120
|
+
renderEditorProfileCard();
|
|
121
|
+
} else {
|
|
122
|
+
renderDefaultProfileCard(userId, provider);
|
|
123
|
+
}
|
|
109
124
|
});
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (options !== null && options !== void 0 && options.profilecardProvider) {
|
|
128
|
+
renderEditorProfileCard();
|
|
110
129
|
}
|
|
111
130
|
}
|
|
112
131
|
});
|
|
@@ -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.2.
|
|
18
|
+
var PACKAGE_VERSION = "12.2.11";
|
|
19
19
|
var setProvider = function setProvider(provider) {
|
|
20
20
|
return function (state, dispatch) {
|
|
21
21
|
if (dispatch) {
|