@atlaskit/editor-plugin-mentions 17.0.0 → 17.1.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 +23 -0
- package/dist/cjs/mentionsPlugin.js +16 -6
- package/dist/cjs/pm-plugins/main.js +1 -1
- package/dist/cjs/ui/AnchoredPopup.js +5 -0
- package/dist/cjs/ui/InlineInvitePopupContainer.js +1 -2
- package/dist/cjs/ui/PopperWrapper.js +14 -9
- package/dist/cjs/ui/ProfileCardComponent.js +36 -11
- package/dist/cjs/ui/quick-insert/MentionQuickInsertMenuItem.js +41 -0
- package/dist/cjs/ui/quick-insert/getMentionQuickInsertComponents.js +41 -0
- package/dist/cjs/ui/type-ahead/MentionItemWithProfileCard.js +106 -0
- package/dist/cjs/ui/type-ahead/index.js +80 -71
- package/dist/cjs/ui/type-ahead/utils.js +7 -1
- package/dist/cjs/ui/useFocusTrap.js +5 -3
- package/dist/es2019/mentionsPlugin.js +13 -3
- package/dist/es2019/pm-plugins/main.js +1 -1
- package/dist/es2019/ui/AnchoredPopup.js +5 -0
- package/dist/es2019/ui/InlineInvitePopupContainer.js +1 -2
- package/dist/es2019/ui/PopperWrapper.js +10 -8
- package/dist/es2019/ui/ProfileCardComponent.js +35 -10
- package/dist/es2019/ui/quick-insert/MentionQuickInsertMenuItem.js +36 -0
- package/dist/es2019/ui/quick-insert/getMentionQuickInsertComponents.js +30 -0
- package/dist/es2019/ui/type-ahead/MentionItemWithProfileCard.js +91 -0
- package/dist/es2019/ui/type-ahead/index.js +22 -8
- package/dist/es2019/ui/type-ahead/utils.js +2 -0
- package/dist/es2019/ui/useFocusTrap.js +4 -3
- package/dist/esm/mentionsPlugin.js +13 -3
- package/dist/esm/pm-plugins/main.js +1 -1
- package/dist/esm/ui/AnchoredPopup.js +5 -0
- package/dist/esm/ui/InlineInvitePopupContainer.js +1 -2
- package/dist/esm/ui/PopperWrapper.js +13 -8
- package/dist/esm/ui/ProfileCardComponent.js +36 -11
- package/dist/esm/ui/quick-insert/MentionQuickInsertMenuItem.js +33 -0
- package/dist/esm/ui/quick-insert/getMentionQuickInsertComponents.js +34 -0
- package/dist/esm/ui/type-ahead/MentionItemWithProfileCard.js +98 -0
- package/dist/esm/ui/type-ahead/index.js +78 -69
- package/dist/esm/ui/type-ahead/utils.js +6 -0
- package/dist/esm/ui/useFocusTrap.js +5 -3
- package/dist/types/mentionsPluginType.d.ts +3 -1
- package/dist/types/ui/PopperWrapper.d.ts +15 -2
- package/dist/types/ui/ProfileCardComponent.d.ts +6 -1
- package/dist/types/ui/quick-insert/MentionQuickInsertMenuItem.d.ts +10 -0
- package/dist/types/ui/quick-insert/getMentionQuickInsertComponents.d.ts +8 -0
- package/dist/types/ui/type-ahead/MentionItemWithProfileCard.d.ts +15 -0
- package/dist/types/ui/type-ahead/index.d.ts +3 -1
- package/dist/types/ui/type-ahead/utils.d.ts +2 -0
- package/dist/types/ui/useFocusTrap.d.ts +2 -1
- package/package.json +9 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-mentions
|
|
2
2
|
|
|
3
|
+
## 17.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`6997a74055219`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6997a74055219) -
|
|
8
|
+
Add profile card on hover in the mentions typeahead for agent mentions
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
14
|
+
## 17.0.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [`4273da2e1a648`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4273da2e1a648) -
|
|
19
|
+
Register native Quick Insert items behind `platform_editor_slash_command`.
|
|
20
|
+
- [`fa754a973daeb`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/fa754a973daeb) -
|
|
21
|
+
Keep the pending mention chip visible until the invite popup is dismissed on failure, instead of
|
|
22
|
+
removing it immediately, and fix keyboard navigation in the project role picker rendered inside
|
|
23
|
+
the popup.
|
|
24
|
+
- Updated dependencies
|
|
25
|
+
|
|
3
26
|
## 17.0.0
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
|
@@ -16,11 +16,11 @@ var _uuid = _interopRequireDefault(require("uuid"));
|
|
|
16
16
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
17
17
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
18
18
|
var _providerFactory = require("@atlaskit/editor-common/provider-factory");
|
|
19
|
-
var
|
|
19
|
+
var _assets = require("@atlaskit/editor-common/assets");
|
|
20
20
|
var _resource = require("@atlaskit/mention/resource");
|
|
21
21
|
var _types = require("@atlaskit/mention/types");
|
|
22
22
|
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
23
|
-
var
|
|
23
|
+
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
24
24
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
25
25
|
var _editorCommands = require("./editor-commands");
|
|
26
26
|
var _mentionNodeSpec = require("./nodeviews/mentionNodeSpec");
|
|
@@ -30,6 +30,7 @@ var _main = require("./pm-plugins/main");
|
|
|
30
30
|
var _InlineInvitePopupContainer = require("./ui/InlineInvitePopupContainer");
|
|
31
31
|
var _SecondaryToolbarComponent = require("./ui/SecondaryToolbarComponent");
|
|
32
32
|
var _typeAhead = require("./ui/type-ahead");
|
|
33
|
+
var _getMentionQuickInsertComponents = require("./ui/quick-insert/getMentionQuickInsertComponents");
|
|
33
34
|
var _excluded2 = ["pendingPastedAgentMention"]; // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
34
35
|
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" != _typeof(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 _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
35
36
|
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; }
|
|
@@ -110,9 +111,18 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref3) {
|
|
|
110
111
|
handleMentionsChanged: options === null || options === void 0 ? void 0 : options.handleMentionsChanged,
|
|
111
112
|
enableAgentSectioning: options === null || options === void 0 ? void 0 : options.enableAgentSectioning,
|
|
112
113
|
showAgentMentionsLabsLozenge: options === null || options === void 0 ? void 0 : options.showAgentMentionsLabsLozenge,
|
|
114
|
+
profilecardProvider: options === null || options === void 0 ? void 0 : options.profilecardProvider,
|
|
113
115
|
fireEvent: fireEvent,
|
|
114
116
|
api: api
|
|
115
117
|
});
|
|
118
|
+
var isRegisteredSlashCommandEnabled = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_slash_command');
|
|
119
|
+
if (isRegisteredSlashCommandEnabled) {
|
|
120
|
+
var _api$uiControlRegistr;
|
|
121
|
+
api === null || api === void 0 || (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 || _api$uiControlRegistr.actions.register((0, _getMentionQuickInsertComponents.getMentionQuickInsertComponents)({
|
|
122
|
+
api: api,
|
|
123
|
+
typeAhead: typeAhead
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
116
126
|
return {
|
|
117
127
|
name: 'mention',
|
|
118
128
|
nodes: function nodes() {
|
|
@@ -164,7 +174,7 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref3) {
|
|
|
164
174
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(Component, {
|
|
165
175
|
mentionProvider: mentionProvider,
|
|
166
176
|
api: api
|
|
167
|
-
}), (0,
|
|
177
|
+
}), (0, _fg.fg)('inline_invite_from_mentions_kill_switch') && /*#__PURE__*/_react.default.createElement(_InlineInvitePopupContainer.InlineInvitePopupContainer, {
|
|
168
178
|
mentionProvider: mentionProvider,
|
|
169
179
|
api: api,
|
|
170
180
|
editorView: editorView
|
|
@@ -219,7 +229,7 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref3) {
|
|
|
219
229
|
return _regenerator.default.wrap(function (_context) {
|
|
220
230
|
while (1) switch (_context.prev = _context.next) {
|
|
221
231
|
case 0:
|
|
222
|
-
if ((0,
|
|
232
|
+
if ((0, _fg.fg)('platform_editor_mention_provider_via_plugin_config')) {
|
|
223
233
|
_context.next = 1;
|
|
224
234
|
break;
|
|
225
235
|
}
|
|
@@ -282,7 +292,7 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref3) {
|
|
|
282
292
|
});
|
|
283
293
|
},
|
|
284
294
|
pluginsOptions: {
|
|
285
|
-
quickInsert: function
|
|
295
|
+
quickInsert: isRegisteredSlashCommandEnabled ? undefined : function (_ref9) {
|
|
286
296
|
var formatMessage = _ref9.formatMessage;
|
|
287
297
|
return [{
|
|
288
298
|
id: 'mention',
|
|
@@ -292,7 +302,7 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref3) {
|
|
|
292
302
|
priority: 400,
|
|
293
303
|
keyshortcut: '@',
|
|
294
304
|
icon: function icon() {
|
|
295
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
305
|
+
return /*#__PURE__*/_react.default.createElement(_assets.IconMention, null);
|
|
296
306
|
},
|
|
297
307
|
action: function action(insert, state) {
|
|
298
308
|
var _api$typeAhead3;
|
|
@@ -67,7 +67,7 @@ var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
|
|
|
67
67
|
var AGENT_MENTION_INACTIVITY_MS = 3000;
|
|
68
68
|
var MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
|
|
69
69
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
70
|
-
var PACKAGE_VERSION = "
|
|
70
|
+
var PACKAGE_VERSION = "17.0.1";
|
|
71
71
|
var setProvider = function setProvider(provider) {
|
|
72
72
|
return function (state, dispatch) {
|
|
73
73
|
if (dispatch) {
|
|
@@ -33,5 +33,10 @@ function AnchoredPopup(_ref) {
|
|
|
33
33
|
placement: "bottom-start",
|
|
34
34
|
content: renderContent,
|
|
35
35
|
trigger: renderTrigger
|
|
36
|
+
// Drops this popup's own `overflow: auto`, which otherwise clips the role picker's
|
|
37
|
+
// menu — it renders as a normal DOM child here (not a body portal) so it stays inside
|
|
38
|
+
// this popup's focus trap.
|
|
39
|
+
,
|
|
40
|
+
shouldRenderToParent: true
|
|
36
41
|
});
|
|
37
42
|
}
|
|
@@ -104,7 +104,6 @@ var InlineInvitePopupContainer = exports.InlineInvitePopupContainer = function I
|
|
|
104
104
|
}
|
|
105
105
|
var invitedUser = (_result$invited$ = result.invited[0]) !== null && _result$invited$ !== void 0 ? _result$invited$ : result.requested[0];
|
|
106
106
|
if (!invitedUser || !(api !== null && api !== void 0 && (_api$core2 = api.core) !== null && _api$core2 !== void 0 && (_api$core2 = _api$core2.actions) !== null && _api$core2 !== void 0 && _api$core2.execute) || !(api !== null && api !== void 0 && (_api$mention = api.mention) !== null && _api$mention !== void 0 && (_api$mention = _api$mention.commands) !== null && _api$mention !== void 0 && _api$mention.insertMention)) {
|
|
107
|
-
removePendingMention();
|
|
108
107
|
return;
|
|
109
108
|
}
|
|
110
109
|
var userId = invitedUser.id,
|
|
@@ -122,7 +121,7 @@ var InlineInvitePopupContainer = exports.InlineInvitePopupContainer = function I
|
|
|
122
121
|
}));
|
|
123
122
|
pendingMentionRef.current = null;
|
|
124
123
|
setAnchorElement(null);
|
|
125
|
-
}, [api
|
|
124
|
+
}, [api]);
|
|
126
125
|
var handleReady = (0, _react.useCallback)(function (show) {
|
|
127
126
|
if (!provider) {
|
|
128
127
|
return;
|
|
@@ -10,7 +10,7 @@ exports.RepositionOnUpdate = void 0;
|
|
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
|
-
var
|
|
13
|
+
var _main = require("@atlaskit/popper/main");
|
|
14
14
|
var _portal = _interopRequireDefault(require("@atlaskit/portal"));
|
|
15
15
|
var _constants = require("@atlaskit/theme/constants");
|
|
16
16
|
var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
|
|
@@ -84,22 +84,27 @@ function useResizeAwarePopper(_ref2) {
|
|
|
84
84
|
*/
|
|
85
85
|
function Popup(_ref3) {
|
|
86
86
|
var referenceElement = _ref3.referenceElement,
|
|
87
|
-
children = _ref3.children
|
|
87
|
+
children = _ref3.children,
|
|
88
|
+
_ref3$placement = _ref3.placement,
|
|
89
|
+
placement = _ref3$placement === void 0 ? 'bottom-end' : _ref3$placement,
|
|
90
|
+
_ref3$offset = _ref3.offset,
|
|
91
|
+
offset = _ref3$offset === void 0 ? [0, 8] : _ref3$offset,
|
|
92
|
+
_ref3$disableFocusTra = _ref3.disableFocusTrap,
|
|
93
|
+
disableFocusTrap = _ref3$disableFocusTra === void 0 ? false : _ref3$disableFocusTra;
|
|
88
94
|
var _React$useState = _react.default.useState(null),
|
|
89
95
|
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
|
|
90
96
|
targetRef = _React$useState2[0],
|
|
91
97
|
setPopupRef = _React$useState2[1];
|
|
92
98
|
(0, _useFocusTrap.useFocusTrap)({
|
|
93
|
-
targetRef: targetRef
|
|
99
|
+
targetRef: targetRef,
|
|
100
|
+
enabled: !disableFocusTrap
|
|
94
101
|
});
|
|
95
102
|
return /*#__PURE__*/_react.default.createElement(_react.Suspense, null, /*#__PURE__*/_react.default.createElement(_portal.default, {
|
|
96
103
|
zIndex: _constants.layers.modal()
|
|
97
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
98
|
-
referenceElement: referenceElement
|
|
99
|
-
|
|
100
|
-
,
|
|
101
|
-
offset: [0, 8],
|
|
102
|
-
placement: "bottom-end",
|
|
104
|
+
}, /*#__PURE__*/_react.default.createElement(_main.Popper, {
|
|
105
|
+
referenceElement: referenceElement,
|
|
106
|
+
offset: offset,
|
|
107
|
+
placement: placement,
|
|
103
108
|
strategy: "fixed"
|
|
104
109
|
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
105
110
|
,
|
|
@@ -154,7 +154,11 @@ function ProfileCardComponent(_ref5) {
|
|
|
154
154
|
activeMention = _ref5.activeMention,
|
|
155
155
|
dom = _ref5.dom,
|
|
156
156
|
closeComponent = _ref5.closeComponent,
|
|
157
|
-
onAgentMentionChatClick = _ref5.onAgentMentionChatClick
|
|
157
|
+
onAgentMentionChatClick = _ref5.onAgentMentionChatClick,
|
|
158
|
+
placement = _ref5.placement,
|
|
159
|
+
offset = _ref5.offset,
|
|
160
|
+
disableFocusTrap = _ref5.disableFocusTrap,
|
|
161
|
+
hideActions = _ref5.hideActions;
|
|
158
162
|
var _useState11 = (0, _react.useState)(undefined),
|
|
159
163
|
_useState12 = (0, _slicedToArray2.default)(_useState11, 2),
|
|
160
164
|
provider = _useState12[0],
|
|
@@ -181,20 +185,28 @@ function ProfileCardComponent(_ref5) {
|
|
|
181
185
|
});
|
|
182
186
|
if (!(0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false)) {
|
|
183
187
|
return /*#__PURE__*/React.createElement(_PopperWrapper.Popup, {
|
|
184
|
-
referenceElement: dom
|
|
188
|
+
referenceElement: dom,
|
|
189
|
+
placement: placement,
|
|
190
|
+
offset: offset,
|
|
191
|
+
disableFocusTrap: disableFocusTrap
|
|
185
192
|
}, /*#__PURE__*/React.createElement(UserProfileCardContent, {
|
|
186
193
|
accessLevel: accessLevel,
|
|
187
194
|
id: id,
|
|
188
195
|
provider: provider,
|
|
189
|
-
text: text
|
|
196
|
+
text: text,
|
|
197
|
+
hideActions: hideActions
|
|
190
198
|
}));
|
|
191
199
|
}
|
|
192
200
|
var isAgentMention = isAgentMentionType(userType);
|
|
193
201
|
return /*#__PURE__*/React.createElement(_PopperWrapper.Popup, {
|
|
194
|
-
referenceElement: dom
|
|
202
|
+
referenceElement: dom,
|
|
203
|
+
placement: placement,
|
|
204
|
+
offset: offset,
|
|
205
|
+
disableFocusTrap: disableFocusTrap
|
|
195
206
|
}, isAgentMention && provider && id ? /*#__PURE__*/React.createElement(AgentProfileCardContent, {
|
|
196
207
|
accountId: id,
|
|
197
208
|
provider: provider,
|
|
209
|
+
hideActions: hideActions,
|
|
198
210
|
text: (0, _expVal.expVal)('platform_editor_reduced_agent_profile_cards', 'isEnabled', false) ? text : undefined,
|
|
199
211
|
onChatClick: onAgentMentionChatClick && (0, _platformFeatureFlags.fg)('platform_editor_agent_mentions_drop_one_fixes') ? function (event, agentStudioId) {
|
|
200
212
|
return (
|
|
@@ -207,17 +219,19 @@ function ProfileCardComponent(_ref5) {
|
|
|
207
219
|
accessLevel: accessLevel,
|
|
208
220
|
id: id,
|
|
209
221
|
provider: provider,
|
|
210
|
-
text: text
|
|
222
|
+
text: text,
|
|
223
|
+
hideActions: hideActions
|
|
211
224
|
}));
|
|
212
225
|
}
|
|
213
226
|
var UserProfileCardContent = function UserProfileCardContent(_ref8) {
|
|
214
227
|
var accessLevel = _ref8.accessLevel,
|
|
215
228
|
id = _ref8.id,
|
|
216
229
|
provider = _ref8.provider,
|
|
217
|
-
text = _ref8.text
|
|
230
|
+
text = _ref8.text,
|
|
231
|
+
hideActions = _ref8.hideActions;
|
|
218
232
|
var actions = (0, _react.useMemo)(function () {
|
|
219
|
-
return provider === null || provider === void 0 ? void 0 : provider.getActions(id, text !== null && text !== void 0 ? text : '', accessLevel);
|
|
220
|
-
}, [accessLevel, id, provider, text]);
|
|
233
|
+
return hideActions ? [] : provider === null || provider === void 0 ? void 0 : provider.getActions(id, text !== null && text !== void 0 ? text : '', accessLevel);
|
|
234
|
+
}, [hideActions, accessLevel, id, provider, text]);
|
|
221
235
|
var _useProfileCardState = useProfileCardState({
|
|
222
236
|
id: id,
|
|
223
237
|
provider: provider
|
|
@@ -259,18 +273,29 @@ var AgentProfileCardContent = function AgentProfileCardContent(_ref9) {
|
|
|
259
273
|
var accountId = _ref9.accountId,
|
|
260
274
|
provider = _ref9.provider,
|
|
261
275
|
text = _ref9.text,
|
|
262
|
-
onChatClick = _ref9.onChatClick
|
|
276
|
+
onChatClick = _ref9.onChatClick,
|
|
277
|
+
hideActions = _ref9.hideActions;
|
|
263
278
|
var agentName = (text !== null && text !== void 0 ? text : '').replace(LEADING_AT_SIGN_RE, '');
|
|
264
279
|
return (0, _expVal.expVal)('platform_editor_reduced_agent_profile_cards', 'isEnabled', false) ? /*#__PURE__*/React.createElement(AgentProfileCardResourcedLazy, {
|
|
265
280
|
accountId: accountId,
|
|
266
281
|
cloudId: provider.cloudId,
|
|
267
282
|
resourceClient: provider.resourceClient,
|
|
268
283
|
agentName: agentName,
|
|
269
|
-
onChatClick: onChatClick
|
|
284
|
+
onChatClick: onChatClick,
|
|
285
|
+
hideAgentActions: hideActions,
|
|
286
|
+
hideConversationStarters: hideActions,
|
|
287
|
+
hideStarButton: hideActions,
|
|
288
|
+
hideAiDisclaimer: hideActions,
|
|
289
|
+
showCreatorNameWithoutLink: hideActions
|
|
270
290
|
}) : /*#__PURE__*/React.createElement(AgentProfileCardResourcedLazy, {
|
|
271
291
|
accountId: accountId,
|
|
272
292
|
cloudId: provider.cloudId,
|
|
273
293
|
resourceClient: provider.resourceClient,
|
|
274
|
-
onChatClick: onChatClick
|
|
294
|
+
onChatClick: onChatClick,
|
|
295
|
+
hideAgentActions: hideActions,
|
|
296
|
+
hideConversationStarters: hideActions,
|
|
297
|
+
hideStarButton: hideActions,
|
|
298
|
+
hideAiDisclaimer: hideActions,
|
|
299
|
+
showCreatorNameWithoutLink: hideActions
|
|
275
300
|
});
|
|
276
301
|
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.MentionQuickInsertMenuItem = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _reactIntl = require("react-intl");
|
|
10
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
12
|
+
var _assets = require("@atlaskit/editor-common/assets");
|
|
13
|
+
var _menuItem = require("@atlaskit/editor-common/quick-insert/menu-item");
|
|
14
|
+
var _key = require("../../pm-plugins/key");
|
|
15
|
+
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" != _typeof(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 _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
16
|
+
var MentionQuickInsertMenuItem = exports.MentionQuickInsertMenuItem = function MentionQuickInsertMenuItem(_ref) {
|
|
17
|
+
var api = _ref.api,
|
|
18
|
+
typeAhead = _ref.typeAhead;
|
|
19
|
+
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
20
|
+
formatMessage = _useIntl.formatMessage;
|
|
21
|
+
var onSelect = (0, _react.useCallback)(function (_ref2) {
|
|
22
|
+
var _mentionPluginKey$get, _api$typeAhead;
|
|
23
|
+
var editorView = _ref2.editorView,
|
|
24
|
+
insert = _ref2.insert;
|
|
25
|
+
if (((_mentionPluginKey$get = _key.mentionPluginKey.getState(editorView.state)) === null || _mentionPluginKey$get === void 0 ? void 0 : _mentionPluginKey$get.canInsertMention) === false) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
var tr = insert(undefined);
|
|
29
|
+
api === null || api === void 0 || (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 || _api$typeAhead.actions.openAtTransaction({
|
|
30
|
+
triggerHandler: typeAhead,
|
|
31
|
+
inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT
|
|
32
|
+
})(tr);
|
|
33
|
+
return tr;
|
|
34
|
+
}, [api, typeAhead]);
|
|
35
|
+
return /*#__PURE__*/_react.default.createElement(_menuItem.QuickInsertMenuItem, {
|
|
36
|
+
iconBefore: /*#__PURE__*/_react.default.createElement(_assets.IconMention, null),
|
|
37
|
+
onSelect: onSelect,
|
|
38
|
+
shortcut: "@",
|
|
39
|
+
title: formatMessage(_messages.toolbarInsertBlockMessages.mention)
|
|
40
|
+
});
|
|
41
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getMentionQuickInsertComponents = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
10
|
+
var _createQuickInsertMatcher = require("@atlaskit/editor-common/quick-insert/create-quick-insert-matcher");
|
|
11
|
+
var _keys = require("@atlaskit/editor-common/quick-insert/keys");
|
|
12
|
+
var _rank = require("@atlaskit/editor-common/quick-insert/rank");
|
|
13
|
+
var _MentionQuickInsertMenuItem = require("./MentionQuickInsertMenuItem");
|
|
14
|
+
var getMentionQuickInsertComponents = exports.getMentionQuickInsertComponents = function getMentionQuickInsertComponents(_ref) {
|
|
15
|
+
var api = _ref.api,
|
|
16
|
+
typeAhead = _ref.typeAhead;
|
|
17
|
+
return [{
|
|
18
|
+
key: _keys.MENTION_MENU_ITEM.key,
|
|
19
|
+
type: _keys.MENTION_MENU_ITEM.type,
|
|
20
|
+
parents: [{
|
|
21
|
+
key: _keys.MEDIA_SECTION.key,
|
|
22
|
+
type: _keys.MEDIA_SECTION.type,
|
|
23
|
+
rank: _rank.MEDIA_SECTION_RANK[_keys.MENTION_MENU_ITEM.key]
|
|
24
|
+
}],
|
|
25
|
+
match: (0, _createQuickInsertMatcher.createQuickInsertMatcher)(function (_ref2) {
|
|
26
|
+
var formatMessage = _ref2.formatMessage;
|
|
27
|
+
return {
|
|
28
|
+
description: formatMessage(_messages.toolbarInsertBlockMessages.mentionDescription),
|
|
29
|
+
keywords: ['team', 'user'],
|
|
30
|
+
shortcut: '@',
|
|
31
|
+
title: formatMessage(_messages.toolbarInsertBlockMessages.mention)
|
|
32
|
+
};
|
|
33
|
+
}),
|
|
34
|
+
component: function component() {
|
|
35
|
+
return /*#__PURE__*/_react.default.createElement(_MentionQuickInsertMenuItem.MentionQuickInsertMenuItem, {
|
|
36
|
+
api: api,
|
|
37
|
+
typeAhead: typeAhead
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}];
|
|
41
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.MentionItemWithProfileCard = MentionItemWithProfileCard;
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _item = require("@atlaskit/mention/item");
|
|
12
|
+
var _compiled = require("@atlaskit/primitives/compiled");
|
|
13
|
+
var _ProfileCardComponent = require("../ProfileCardComponent");
|
|
14
|
+
var _utils = require("./utils");
|
|
15
|
+
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" != _typeof(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 _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
16
|
+
// Delay before mounting the card and fetching the profile data
|
|
17
|
+
var SHOW_DELAY_MS = 600;
|
|
18
|
+
var HIDE_DELAY_MS = 200;
|
|
19
|
+
/**
|
|
20
|
+
* Renders a mentions typeahead row that shows a (reduced) profile card
|
|
21
|
+
* when hovered
|
|
22
|
+
*/
|
|
23
|
+
function MentionItemWithProfileCard(_ref) {
|
|
24
|
+
var mention = _ref.mention,
|
|
25
|
+
selected = _ref.selected,
|
|
26
|
+
onSelection = _ref.onSelection,
|
|
27
|
+
height = _ref.height,
|
|
28
|
+
profilecardProvider = _ref.profilecardProvider;
|
|
29
|
+
var _useState = (0, _react.useState)(null),
|
|
30
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
31
|
+
referenceElement = _useState2[0],
|
|
32
|
+
setReferenceElement = _useState2[1];
|
|
33
|
+
var showTimerRef = (0, _react.useRef)();
|
|
34
|
+
var hideTimerRef = (0, _react.useRef)();
|
|
35
|
+
var clearTimers = (0, _react.useCallback)(function () {
|
|
36
|
+
clearTimeout(showTimerRef.current);
|
|
37
|
+
clearTimeout(hideTimerRef.current);
|
|
38
|
+
}, []);
|
|
39
|
+
(0, _react.useEffect)(function () {
|
|
40
|
+
return clearTimers;
|
|
41
|
+
}, [clearTimers]);
|
|
42
|
+
var isAgent = (0, _utils.isAgentMention)(mention);
|
|
43
|
+
var handleMouseEnter = (0, _react.useCallback)(function (_mention, event) {
|
|
44
|
+
// Currently showing profile cards for agents only
|
|
45
|
+
if (mention.isPlaceholder || !mention.id || !profilecardProvider || !isAgent) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
var rowElement = event === null || event === void 0 ? void 0 : event.currentTarget;
|
|
49
|
+
if (!(rowElement instanceof HTMLElement)) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
clearTimers();
|
|
53
|
+
showTimerRef.current = setTimeout(function () {
|
|
54
|
+
setReferenceElement(rowElement);
|
|
55
|
+
}, SHOW_DELAY_MS);
|
|
56
|
+
}, [mention.isPlaceholder, mention.id, isAgent, profilecardProvider, clearTimers]);
|
|
57
|
+
var scheduleHide = (0, _react.useCallback)(function () {
|
|
58
|
+
clearTimeout(hideTimerRef.current);
|
|
59
|
+
hideTimerRef.current = setTimeout(function () {
|
|
60
|
+
setReferenceElement(null);
|
|
61
|
+
}, HIDE_DELAY_MS);
|
|
62
|
+
}, []);
|
|
63
|
+
var cancelHide = (0, _react.useCallback)(function () {
|
|
64
|
+
clearTimeout(hideTimerRef.current);
|
|
65
|
+
}, []);
|
|
66
|
+
var handleMouseLeave = (0, _react.useCallback)(function () {
|
|
67
|
+
clearTimeout(showTimerRef.current);
|
|
68
|
+
scheduleHide();
|
|
69
|
+
}, [scheduleHide]);
|
|
70
|
+
var closeCard = (0, _react.useCallback)(function () {
|
|
71
|
+
clearTimers();
|
|
72
|
+
setReferenceElement(null);
|
|
73
|
+
}, [clearTimers]);
|
|
74
|
+
var userType = isAgent ? 'APP' : undefined;
|
|
75
|
+
var activeMention = (0, _react.useMemo)(function () {
|
|
76
|
+
return {
|
|
77
|
+
attrs: {
|
|
78
|
+
id: mention.id,
|
|
79
|
+
text: mention.name,
|
|
80
|
+
userType: userType,
|
|
81
|
+
accessLevel: mention.accessLevel
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}, [mention.id, mention.name, mention.accessLevel, userType]);
|
|
85
|
+
return /*#__PURE__*/_react.default.createElement(_compiled.Box, {
|
|
86
|
+
testId: "mention-item-with-profile-card",
|
|
87
|
+
onMouseOver: cancelHide,
|
|
88
|
+
onMouseOut: scheduleHide,
|
|
89
|
+
onMouseLeave: handleMouseLeave,
|
|
90
|
+
onBlur: handleMouseLeave
|
|
91
|
+
}, /*#__PURE__*/_react.default.createElement(_item.MentionItem, {
|
|
92
|
+
mention: mention,
|
|
93
|
+
selected: selected,
|
|
94
|
+
onMouseEnter: handleMouseEnter,
|
|
95
|
+
onSelection: onSelection,
|
|
96
|
+
height: height
|
|
97
|
+
}), referenceElement && profilecardProvider && /*#__PURE__*/_react.default.createElement(_ProfileCardComponent.ProfileCardComponent, {
|
|
98
|
+
activeMention: activeMention,
|
|
99
|
+
profilecardProvider: profilecardProvider,
|
|
100
|
+
dom: referenceElement,
|
|
101
|
+
closeComponent: closeCard,
|
|
102
|
+
placement: "right",
|
|
103
|
+
disableFocusTrap: true,
|
|
104
|
+
hideActions: true
|
|
105
|
+
}));
|
|
106
|
+
}
|