@atlaskit/editor-plugin-mentions 2.10.8 → 2.11.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 +20 -0
- package/dist/cjs/mentionsPlugin.js +57 -4
- package/dist/cjs/nodeviews/mention.js +8 -4
- package/dist/cjs/pm-plugins/main.js +30 -14
- package/dist/cjs/ui/InviteItem/index.js +15 -3
- package/dist/cjs/ui/Mention/index.js +6 -0
- package/dist/cjs/ui/ToolbarMention/index.js +2 -0
- package/dist/cjs/ui/type-ahead/analytics.js +16 -4
- package/dist/cjs/ui/type-ahead/index.js +19 -3
- package/dist/cjs/ui/type-ahead/utils.js +7 -0
- package/dist/es2019/mentionsPlugin.js +30 -3
- package/dist/es2019/nodeviews/mention.js +9 -5
- package/dist/es2019/pm-plugins/main.js +21 -5
- package/dist/es2019/ui/InviteItem/index.js +15 -3
- package/dist/es2019/ui/Mention/index.js +6 -0
- package/dist/es2019/ui/ToolbarMention/index.js +2 -0
- package/dist/es2019/ui/type-ahead/analytics.js +16 -4
- package/dist/es2019/ui/type-ahead/index.js +20 -4
- package/dist/es2019/ui/type-ahead/utils.js +9 -1
- package/dist/esm/mentionsPlugin.js +58 -5
- package/dist/esm/nodeviews/mention.js +8 -4
- package/dist/esm/pm-plugins/main.js +29 -14
- package/dist/esm/ui/InviteItem/index.js +15 -3
- package/dist/esm/ui/Mention/index.js +6 -0
- package/dist/esm/ui/ToolbarMention/index.js +2 -0
- package/dist/esm/ui/type-ahead/analytics.js +16 -4
- package/dist/esm/ui/type-ahead/index.js +19 -3
- package/dist/esm/ui/type-ahead/utils.js +8 -0
- package/dist/types/mentionsPluginType.d.ts +8 -0
- package/dist/types/nodeviews/mention.d.ts +3 -0
- package/dist/types/pm-plugins/main.d.ts +13 -2
- package/dist/types/types/index.d.ts +2 -0
- package/dist/types-ts4.5/mentionsPluginType.d.ts +8 -0
- package/dist/types-ts4.5/nodeviews/mention.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +13 -2
- package/dist/types-ts4.5/types/index.d.ts +2 -0
- package/package.json +6 -3
|
@@ -16,6 +16,9 @@ import { avatarStyle, capitalizedStyle, mentionItemSelectedStyle, mentionItemSty
|
|
|
16
16
|
export const INVITE_ITEM_DESCRIPTION = {
|
|
17
17
|
id: 'invite-teammate'
|
|
18
18
|
};
|
|
19
|
+
|
|
20
|
+
// Ignored via go/ees005
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
22
|
const leftClick = event => {
|
|
20
23
|
return event.button === 0 && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey;
|
|
21
24
|
};
|
|
@@ -28,13 +31,19 @@ const InviteItem = ({
|
|
|
28
31
|
userRole,
|
|
29
32
|
intl
|
|
30
33
|
}) => {
|
|
31
|
-
const onSelected = useCallback(
|
|
34
|
+
const onSelected = useCallback(
|
|
35
|
+
// Ignored via go/ees005
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
+
event => {
|
|
32
38
|
if (leftClick(event) && onSelection) {
|
|
33
39
|
event.preventDefault();
|
|
34
40
|
onSelection(INVITE_ITEM_DESCRIPTION, event);
|
|
35
41
|
}
|
|
36
42
|
}, [onSelection]);
|
|
37
|
-
const onItemMouseEnter = useCallback(
|
|
43
|
+
const onItemMouseEnter = useCallback(
|
|
44
|
+
// Ignored via go/ees005
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
46
|
+
event => {
|
|
38
47
|
if (onMouseEnter) {
|
|
39
48
|
onMouseEnter(INVITE_ITEM_DESCRIPTION, event);
|
|
40
49
|
}
|
|
@@ -62,7 +71,10 @@ const InviteItem = ({
|
|
|
62
71
|
})), jsx("div", {
|
|
63
72
|
css: nameSectionStyle,
|
|
64
73
|
"data-testid": "name-section"
|
|
65
|
-
}, jsx(FormattedMessage
|
|
74
|
+
}, jsx(FormattedMessage
|
|
75
|
+
// Ignored via go/ees005
|
|
76
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
77
|
+
, _extends({}, messages.inviteItemTitle, {
|
|
66
78
|
values: {
|
|
67
79
|
userRole: userRole || 'basic',
|
|
68
80
|
productName:
|
|
@@ -64,6 +64,8 @@ export const Mention = props => {
|
|
|
64
64
|
}, []);
|
|
65
65
|
const actionHandlers = {};
|
|
66
66
|
['onClick', 'onMouseEnter', 'onMouseLeave'].forEach(handler => {
|
|
67
|
+
// Ignored via go/ees005
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
67
69
|
actionHandlers[handler] = eventHandlers && eventHandlers[handler] || (() => {});
|
|
68
70
|
});
|
|
69
71
|
if (profilecardProvider) {
|
|
@@ -75,6 +77,8 @@ export const Mention = props => {
|
|
|
75
77
|
mentionProvider: mentionProvider,
|
|
76
78
|
profilecardProvider: profilecardProvider,
|
|
77
79
|
localId: localId
|
|
80
|
+
// Ignored via go/ees005
|
|
81
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
78
82
|
}, actionHandlers));
|
|
79
83
|
} else {
|
|
80
84
|
return /*#__PURE__*/React.createElement(ResourcedMention, _extends({
|
|
@@ -83,6 +87,8 @@ export const Mention = props => {
|
|
|
83
87
|
accessLevel: accessLevel,
|
|
84
88
|
mentionProvider: mentionProvider,
|
|
85
89
|
localId: localId
|
|
90
|
+
// Ignored via go/ees005
|
|
91
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
86
92
|
}, actionHandlers));
|
|
87
93
|
}
|
|
88
94
|
};
|
|
@@ -4,6 +4,8 @@ import { injectIntl } from 'react-intl-next';
|
|
|
4
4
|
import { mentionMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
5
|
import { TOOLBAR_BUTTON, ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
6
6
|
import MentionIcon from '@atlaskit/icon/glyph/editor/mention';
|
|
7
|
+
// Ignored via go/ees005
|
|
8
|
+
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
7
9
|
class ToolbarMention extends PureComponent {
|
|
8
10
|
constructor(...args) {
|
|
9
11
|
super(...args);
|
|
@@ -15,7 +15,10 @@ const extractAttributesFromQuery = query => {
|
|
|
15
15
|
}
|
|
16
16
|
return emptyQueryResponse;
|
|
17
17
|
};
|
|
18
|
-
export const buildTypeAheadCancelPayload = (duration, upKeyCount, downKeyCount, sessionId, query
|
|
18
|
+
export const buildTypeAheadCancelPayload = (duration, upKeyCount, downKeyCount, sessionId, query
|
|
19
|
+
// Ignored via go/ees005
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
21
|
+
) => {
|
|
19
22
|
const {
|
|
20
23
|
queryLength,
|
|
21
24
|
spaceInQuery
|
|
@@ -63,7 +66,10 @@ export const buildTypeAheadInviteItemViewedPayload = (sessionId, contextIdentifi
|
|
|
63
66
|
}
|
|
64
67
|
};
|
|
65
68
|
};
|
|
66
|
-
export const buildTypeAheadInviteItemClickedPayload = (duration, upKeyCount, downKeyCount, sessionId, insertType, query, contextIdentifierProvider, userRole
|
|
69
|
+
export const buildTypeAheadInviteItemClickedPayload = (duration, upKeyCount, downKeyCount, sessionId, insertType, query, contextIdentifierProvider, userRole
|
|
70
|
+
// Ignored via go/ees005
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
72
|
+
) => {
|
|
67
73
|
const {
|
|
68
74
|
queryLength,
|
|
69
75
|
spaceInQuery
|
|
@@ -93,7 +99,10 @@ export const buildTypeAheadInviteItemClickedPayload = (duration, upKeyCount, dow
|
|
|
93
99
|
}
|
|
94
100
|
};
|
|
95
101
|
};
|
|
96
|
-
export const buildTypeAheadInsertedPayload = (duration, upKeyCount, downKeyCount, sessionId, insertType, mention, mentionLocalId, mentionList, query, contextIdentifierProvider, taskListId, taskItemId
|
|
102
|
+
export const buildTypeAheadInsertedPayload = (duration, upKeyCount, downKeyCount, sessionId, insertType, mention, mentionLocalId, mentionList, query, contextIdentifierProvider, taskListId, taskItemId
|
|
103
|
+
// Ignored via go/ees005
|
|
104
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
105
|
+
) => {
|
|
97
106
|
const {
|
|
98
107
|
queryLength,
|
|
99
108
|
spaceInQuery
|
|
@@ -135,7 +144,10 @@ export const buildTypeAheadInsertedPayload = (duration, upKeyCount, downKeyCount
|
|
|
135
144
|
}
|
|
136
145
|
};
|
|
137
146
|
};
|
|
138
|
-
export const buildTypeAheadRenderedPayload = (duration, userIds, query, teams
|
|
147
|
+
export const buildTypeAheadRenderedPayload = (duration, userIds, query, teams
|
|
148
|
+
// Ignored via go/ees005
|
|
149
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
150
|
+
) => {
|
|
139
151
|
const {
|
|
140
152
|
queryLength,
|
|
141
153
|
spaceInQuery
|
|
@@ -107,7 +107,11 @@ const buildAndSendElementsTypeAheadAnalytics = fireEvent => ({
|
|
|
107
107
|
userOrTeamIds = null;
|
|
108
108
|
teams = mentions.map(mention => isTeamType(mention.userType) ? {
|
|
109
109
|
teamId: mention.id,
|
|
110
|
+
// Ignored via go/ees005
|
|
111
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
110
112
|
includesYou: mention.context.includesYou,
|
|
113
|
+
// Ignored via go/ees005
|
|
114
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
111
115
|
memberCount: mention.context.memberCount
|
|
112
116
|
} : null).filter(m => !!m);
|
|
113
117
|
}
|
|
@@ -119,7 +123,10 @@ const buildAndSendElementsTypeAheadAnalytics = fireEvent => ({
|
|
|
119
123
|
* When a team mention is selected, we render a team link and list of member/user mentions
|
|
120
124
|
* in editor content
|
|
121
125
|
*/
|
|
122
|
-
const buildNodesForTeamMention = (schema, selectedMention, mentionProvider, sanitizePrivateContent
|
|
126
|
+
const buildNodesForTeamMention = (schema, selectedMention, mentionProvider, sanitizePrivateContent
|
|
127
|
+
// Ignored via go/ees005
|
|
128
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
129
|
+
) => {
|
|
123
130
|
const {
|
|
124
131
|
nodes,
|
|
125
132
|
marks
|
|
@@ -136,7 +143,10 @@ const buildNodesForTeamMention = (schema, selectedMention, mentionProvider, sani
|
|
|
136
143
|
const teamLink = context && context.teamLink ? context.teamLink : defaultTeamLink;
|
|
137
144
|
const teamLinkNode = fg('team-mention-inline-smartlink') ? schema.nodes.inlineCard.create({
|
|
138
145
|
url: teamLink
|
|
139
|
-
}) :
|
|
146
|
+
}) :
|
|
147
|
+
// Ignored via go/ees005
|
|
148
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
149
|
+
schema.text(name, [marks.link.create({
|
|
140
150
|
href: teamLink
|
|
141
151
|
})]);
|
|
142
152
|
const openBracketText = schema.text('(');
|
|
@@ -251,6 +261,8 @@ export const createTypeAheadConfig = ({
|
|
|
251
261
|
onOpen: () => {
|
|
252
262
|
firstQueryWithoutResults = null;
|
|
253
263
|
},
|
|
264
|
+
// Ignored via go/ees005
|
|
265
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
254
266
|
selectItem(state, item, insert, {
|
|
255
267
|
mode,
|
|
256
268
|
stats,
|
|
@@ -270,7 +282,8 @@ export const createTypeAheadConfig = ({
|
|
|
270
282
|
name,
|
|
271
283
|
nickname,
|
|
272
284
|
accessLevel,
|
|
273
|
-
userType
|
|
285
|
+
userType,
|
|
286
|
+
isXProductUser
|
|
274
287
|
} = item.mention;
|
|
275
288
|
const trimmedNickname = nickname && nickname.startsWith('@') ? nickname.slice(1) : nickname;
|
|
276
289
|
const renderName = mentionInsertDisplayName || !trimmedNickname ? name : trimmedNickname;
|
|
@@ -328,6 +341,9 @@ export const createTypeAheadConfig = ({
|
|
|
328
341
|
if (mentionProvider && isTeamType(userType)) {
|
|
329
342
|
return insert(buildNodesForTeamMention(schema, item.mention, mentionProvider, sanitizePrivateContent));
|
|
330
343
|
}
|
|
344
|
+
if (isXProductUser && mentionProvider && mentionProvider.inviteXProductUser) {
|
|
345
|
+
mentionProvider.inviteXProductUser(id);
|
|
346
|
+
}
|
|
331
347
|
|
|
332
348
|
// Don't insert into document if document data is sanitized.
|
|
333
349
|
const text = sanitizePrivateContent ? '' : `@${renderName}`;
|
|
@@ -360,7 +376,7 @@ export const createTypeAheadConfig = ({
|
|
|
360
376
|
const pluginState = getMentionPluginState(editorState);
|
|
361
377
|
if (pluginState !== null && pluginState !== void 0 && pluginState.mentionProvider) {
|
|
362
378
|
const mentionProvider = pluginState.mentionProvider;
|
|
363
|
-
for (
|
|
379
|
+
for (const key of subscriptionKeys) {
|
|
364
380
|
mentionProvider.unsubscribe(key);
|
|
365
381
|
}
|
|
366
382
|
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { INVITE_ITEM_DESCRIPTION } from '../InviteItem';
|
|
2
|
+
|
|
3
|
+
// Ignored via go/ees005
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2
5
|
export const isTeamType = userType => userType === 'TEAM';
|
|
6
|
+
|
|
7
|
+
// Ignored via go/ees005
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3
9
|
export const isTeamStats = stat => stat && !isNaN(stat.teamMentionDuration);
|
|
4
10
|
export const isInviteItem = mention => mention && mention.id === INVITE_ITEM_DESCRIPTION.id;
|
|
5
11
|
|
|
@@ -10,11 +16,13 @@ export const shouldKeepInviteItem = (query, firstQueryWithoutResults) => {
|
|
|
10
16
|
if (!firstQueryWithoutResults) {
|
|
11
17
|
return true;
|
|
12
18
|
}
|
|
13
|
-
|
|
19
|
+
const lastIndexWithResults = firstQueryWithoutResults.length - 1;
|
|
14
20
|
let suffix = query.slice(lastIndexWithResults);
|
|
15
21
|
if (query[lastIndexWithResults - 1] === ' ') {
|
|
16
22
|
suffix = ' ' + suffix;
|
|
17
23
|
}
|
|
24
|
+
// Ignored via go/ees005
|
|
25
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
18
26
|
const depletedExtraWords = /\s[^\s]+\s/.test(suffix);
|
|
19
27
|
return !depletedExtraWords;
|
|
20
28
|
};
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
3
|
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; }
|
|
3
4
|
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) { _defineProperty(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; }
|
|
5
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
6
|
import React from 'react';
|
|
5
7
|
import uuid from 'uuid';
|
|
6
8
|
import { mention } from '@atlaskit/adf-schema';
|
|
7
9
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
8
10
|
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
9
11
|
import { IconMention } from '@atlaskit/editor-common/quick-insert';
|
|
12
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
13
|
import { mentionPluginKey } from './pm-plugins/key';
|
|
11
|
-
import { createMentionPlugin } from './pm-plugins/main';
|
|
14
|
+
import { ACTIONS, createMentionPlugin } from './pm-plugins/main';
|
|
12
15
|
import { SecondaryToolbarComponent } from './ui/SecondaryToolbarComponent';
|
|
13
16
|
import { createTypeAheadConfig } from './ui/type-ahead';
|
|
14
17
|
var mentionsPlugin = function mentionsPlugin(_ref) {
|
|
15
18
|
var options = _ref.config,
|
|
16
19
|
api = _ref.api;
|
|
17
20
|
var sessionId = uuid();
|
|
21
|
+
var previousMediaProvider;
|
|
18
22
|
var fireEvent = function fireEvent(payload, channel) {
|
|
19
23
|
var _api$analytics;
|
|
20
24
|
var fireAnalyticsEvent = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 ? void 0 : _api$analytics.fireAnalyticsEvent;
|
|
@@ -46,7 +50,12 @@ var mentionsPlugin = function mentionsPlugin(_ref) {
|
|
|
46
50
|
return [{
|
|
47
51
|
name: 'mention',
|
|
48
52
|
plugin: function plugin(pmPluginFactoryParams) {
|
|
49
|
-
return createMentionPlugin(
|
|
53
|
+
return createMentionPlugin({
|
|
54
|
+
pmPluginFactoryParams: pmPluginFactoryParams,
|
|
55
|
+
fireEvent: fireEvent,
|
|
56
|
+
options: options,
|
|
57
|
+
api: api
|
|
58
|
+
});
|
|
50
59
|
}
|
|
51
60
|
}];
|
|
52
61
|
},
|
|
@@ -72,7 +81,51 @@ var mentionsPlugin = function mentionsPlugin(_ref) {
|
|
|
72
81
|
if (options !== null && options !== void 0 && options.handleMentionsChanged) {
|
|
73
82
|
options.handleMentionsChanged(mentionChanges);
|
|
74
83
|
}
|
|
75
|
-
}
|
|
84
|
+
},
|
|
85
|
+
setProvider: function () {
|
|
86
|
+
var _setProvider = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(providerPromise) {
|
|
87
|
+
var _api$core$actions$exe;
|
|
88
|
+
var provider;
|
|
89
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
90
|
+
while (1) switch (_context.prev = _context.next) {
|
|
91
|
+
case 0:
|
|
92
|
+
if (fg('platform_editor_mention_provider_via_plugin_config')) {
|
|
93
|
+
_context.next = 2;
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
return _context.abrupt("return", false);
|
|
97
|
+
case 2:
|
|
98
|
+
_context.next = 4;
|
|
99
|
+
return providerPromise;
|
|
100
|
+
case 4:
|
|
101
|
+
provider = _context.sent;
|
|
102
|
+
if (!(previousMediaProvider === provider)) {
|
|
103
|
+
_context.next = 7;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
return _context.abrupt("return", false);
|
|
107
|
+
case 7:
|
|
108
|
+
previousMediaProvider = provider;
|
|
109
|
+
return _context.abrupt("return", (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (_ref3) {
|
|
110
|
+
var tr = _ref3.tr;
|
|
111
|
+
return tr.setMeta(mentionPluginKey, {
|
|
112
|
+
action: ACTIONS.SET_PROVIDER,
|
|
113
|
+
params: {
|
|
114
|
+
provider: provider
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
})) !== null && _api$core$actions$exe !== void 0 ? _api$core$actions$exe : false);
|
|
118
|
+
case 9:
|
|
119
|
+
case "end":
|
|
120
|
+
return _context.stop();
|
|
121
|
+
}
|
|
122
|
+
}, _callee);
|
|
123
|
+
}));
|
|
124
|
+
function setProvider(_x) {
|
|
125
|
+
return _setProvider.apply(this, arguments);
|
|
126
|
+
}
|
|
127
|
+
return setProvider;
|
|
128
|
+
}()
|
|
76
129
|
},
|
|
77
130
|
getSharedState: function getSharedState(editorState) {
|
|
78
131
|
if (!editorState) {
|
|
@@ -84,8 +137,8 @@ var mentionsPlugin = function mentionsPlugin(_ref) {
|
|
|
84
137
|
});
|
|
85
138
|
},
|
|
86
139
|
pluginsOptions: {
|
|
87
|
-
quickInsert: function quickInsert(
|
|
88
|
-
var formatMessage =
|
|
140
|
+
quickInsert: function quickInsert(_ref4) {
|
|
141
|
+
var formatMessage = _ref4.formatMessage;
|
|
89
142
|
return [{
|
|
90
143
|
id: 'mention',
|
|
91
144
|
title: formatMessage(messages.mention),
|
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
2
3
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
3
4
|
import { Mention } from '../ui/Mention';
|
|
4
5
|
export var MentionNodeView = function MentionNodeView(props) {
|
|
5
|
-
var providerFactory = props.providerFactory
|
|
6
|
+
var providerFactory = props.providerFactory,
|
|
7
|
+
pluginInjectionApi = props.pluginInjectionApi;
|
|
6
8
|
var _props$node$attrs = props.node.attrs,
|
|
7
9
|
id = _props$node$attrs.id,
|
|
8
10
|
text = _props$node$attrs.text,
|
|
9
11
|
accessLevel = _props$node$attrs.accessLevel,
|
|
10
12
|
localId = _props$node$attrs.localId;
|
|
13
|
+
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['mention']),
|
|
14
|
+
mentionState = _useSharedPluginState.mentionState;
|
|
15
|
+
var mentionProvider = mentionState === null || mentionState === void 0 ? void 0 : mentionState.mentionProvider;
|
|
11
16
|
var renderAssistiveTextWithProviders = function renderAssistiveTextWithProviders(providers) {
|
|
12
17
|
var _props$options;
|
|
13
|
-
var
|
|
14
|
-
mentionProvider = _ref.mentionProvider;
|
|
18
|
+
var mentionProviderPromise = mentionProvider ? Promise.resolve(mentionProvider) : providers.mentionProvider;
|
|
15
19
|
var profilecardProvider = (_props$options = props.options) === null || _props$options === void 0 ? void 0 : _props$options.profilecardProvider;
|
|
16
20
|
return /*#__PURE__*/React.createElement(Mention, {
|
|
17
21
|
id: id,
|
|
18
22
|
text: text,
|
|
19
23
|
accessLevel: accessLevel,
|
|
20
|
-
mentionProvider:
|
|
24
|
+
mentionProvider: mentionProviderPromise,
|
|
21
25
|
profilecardProvider: profilecardProvider,
|
|
22
26
|
localId: localId
|
|
23
27
|
});
|
|
@@ -12,11 +12,11 @@ import { MentionNodeView } from '../nodeviews/mention';
|
|
|
12
12
|
import { MENTION_PROVIDER_REJECTED, MENTION_PROVIDER_UNDEFINED } from '../types';
|
|
13
13
|
import { mentionPluginKey } from './key';
|
|
14
14
|
import { canMentionBeCreatedInRange } from './utils';
|
|
15
|
-
var ACTIONS = {
|
|
15
|
+
export var ACTIONS = {
|
|
16
16
|
SET_PROVIDER: 'SET_PROVIDER'
|
|
17
17
|
};
|
|
18
18
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
19
|
-
var PACKAGE_VERSION = "2.
|
|
19
|
+
var PACKAGE_VERSION = "2.11.0";
|
|
20
20
|
var setProvider = function setProvider(provider) {
|
|
21
21
|
return function (state, dispatch) {
|
|
22
22
|
if (dispatch) {
|
|
@@ -30,9 +30,16 @@ var setProvider = function setProvider(provider) {
|
|
|
30
30
|
return true;
|
|
31
31
|
};
|
|
32
32
|
};
|
|
33
|
-
export function createMentionPlugin(
|
|
33
|
+
export function createMentionPlugin(_ref) {
|
|
34
|
+
var pmPluginFactoryParams = _ref.pmPluginFactoryParams,
|
|
35
|
+
fireEvent = _ref.fireEvent,
|
|
36
|
+
options = _ref.options,
|
|
37
|
+
api = _ref.api;
|
|
34
38
|
var mentionProvider;
|
|
35
|
-
var sendAnalytics = function sendAnalytics(event, actionSubject, action, attributes
|
|
39
|
+
var sendAnalytics = function sendAnalytics(event, actionSubject, action, attributes
|
|
40
|
+
// Ignored via go/ees005
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
42
|
+
) {
|
|
36
43
|
if (event === SLI_EVENT_TYPE || event === SMART_EVENT_TYPE) {
|
|
37
44
|
fireEvent({
|
|
38
45
|
action: action,
|
|
@@ -55,13 +62,15 @@ export function createMentionPlugin(pmPluginFactoryParams, fireEvent, options) {
|
|
|
55
62
|
canInsertMention: canInsertMention
|
|
56
63
|
};
|
|
57
64
|
},
|
|
65
|
+
// Ignored via go/ees005
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
58
67
|
apply: function apply(tr, pluginState, oldState, newState) {
|
|
59
|
-
var
|
|
68
|
+
var _ref2 = tr.getMeta(mentionPluginKey) || {
|
|
60
69
|
action: null,
|
|
61
70
|
params: null
|
|
62
71
|
},
|
|
63
|
-
action =
|
|
64
|
-
params =
|
|
72
|
+
action = _ref2.action,
|
|
73
|
+
params = _ref2.params;
|
|
65
74
|
var hasNewPluginState = false;
|
|
66
75
|
var newPluginState = pluginState;
|
|
67
76
|
var hasPositionChanged = oldState.selection.from !== newState.selection.from || oldState.selection.to !== newState.selection.to;
|
|
@@ -92,6 +101,7 @@ export function createMentionPlugin(pmPluginFactoryParams, fireEvent, options) {
|
|
|
92
101
|
Component: MentionNodeView,
|
|
93
102
|
extraComponentProps: {
|
|
94
103
|
providerFactory: pmPluginFactoryParams.providerFactory,
|
|
104
|
+
pluginInjectionApi: api,
|
|
95
105
|
options: options
|
|
96
106
|
}
|
|
97
107
|
})
|
|
@@ -136,7 +146,12 @@ export function createMentionPlugin(pmPluginFactoryParams, fireEvent, options) {
|
|
|
136
146
|
}
|
|
137
147
|
return;
|
|
138
148
|
};
|
|
139
|
-
|
|
149
|
+
var providerViaConfig = fg('platform_editor_mention_provider_via_plugin_config');
|
|
150
|
+
if (providerViaConfig && options !== null && options !== void 0 && options.mentionProvider) {
|
|
151
|
+
providerHandler('mentionProvider', options === null || options === void 0 ? void 0 : options.mentionProvider);
|
|
152
|
+
} else {
|
|
153
|
+
pmPluginFactoryParams.providerFactory.subscribe('mentionProvider', providerHandler);
|
|
154
|
+
}
|
|
140
155
|
return {
|
|
141
156
|
destroy: function destroy() {
|
|
142
157
|
if (pmPluginFactoryParams.providerFactory) {
|
|
@@ -151,16 +166,16 @@ export function createMentionPlugin(pmPluginFactoryParams, fireEvent, options) {
|
|
|
151
166
|
if (options !== null && options !== void 0 && options.handleMentionsChanged && fg('confluence_updated_mentions_livepages')) {
|
|
152
167
|
var mentionSchema = newState.schema.nodes.mention;
|
|
153
168
|
var mentionNodesBefore = findChildrenByType(prevState.doc, mentionSchema);
|
|
154
|
-
var mentionLocalIdsAfter = new Set(findChildrenByType(newState.doc, mentionSchema).map(function (
|
|
155
|
-
var node =
|
|
169
|
+
var mentionLocalIdsAfter = new Set(findChildrenByType(newState.doc, mentionSchema).map(function (_ref3) {
|
|
170
|
+
var node = _ref3.node;
|
|
156
171
|
return node.attrs.localId;
|
|
157
172
|
}));
|
|
158
173
|
if (mentionNodesBefore.length > mentionLocalIdsAfter.size) {
|
|
159
|
-
var deletedMentions = mentionNodesBefore.filter(function (
|
|
160
|
-
var node = _ref3.node;
|
|
161
|
-
return !mentionLocalIdsAfter.has(node.attrs.localId);
|
|
162
|
-
}).map(function (_ref4) {
|
|
174
|
+
var deletedMentions = mentionNodesBefore.filter(function (_ref4) {
|
|
163
175
|
var node = _ref4.node;
|
|
176
|
+
return !mentionLocalIdsAfter.has(node.attrs.localId);
|
|
177
|
+
}).map(function (_ref5) {
|
|
178
|
+
var node = _ref5.node;
|
|
164
179
|
return {
|
|
165
180
|
type: 'deleted',
|
|
166
181
|
id: node.attrs.id,
|
|
@@ -16,6 +16,9 @@ import { avatarStyle, capitalizedStyle, mentionItemSelectedStyle, mentionItemSty
|
|
|
16
16
|
export var INVITE_ITEM_DESCRIPTION = {
|
|
17
17
|
id: 'invite-teammate'
|
|
18
18
|
};
|
|
19
|
+
|
|
20
|
+
// Ignored via go/ees005
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
22
|
var leftClick = function leftClick(event) {
|
|
20
23
|
return event.button === 0 && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey;
|
|
21
24
|
};
|
|
@@ -27,13 +30,19 @@ var InviteItem = function InviteItem(_ref) {
|
|
|
27
30
|
selected = _ref.selected,
|
|
28
31
|
userRole = _ref.userRole,
|
|
29
32
|
intl = _ref.intl;
|
|
30
|
-
var onSelected = useCallback(
|
|
33
|
+
var onSelected = useCallback(
|
|
34
|
+
// Ignored via go/ees005
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
|
+
function (event) {
|
|
31
37
|
if (leftClick(event) && onSelection) {
|
|
32
38
|
event.preventDefault();
|
|
33
39
|
onSelection(INVITE_ITEM_DESCRIPTION, event);
|
|
34
40
|
}
|
|
35
41
|
}, [onSelection]);
|
|
36
|
-
var onItemMouseEnter = useCallback(
|
|
42
|
+
var onItemMouseEnter = useCallback(
|
|
43
|
+
// Ignored via go/ees005
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
45
|
+
function (event) {
|
|
37
46
|
if (onMouseEnter) {
|
|
38
47
|
onMouseEnter(INVITE_ITEM_DESCRIPTION, event);
|
|
39
48
|
}
|
|
@@ -61,7 +70,10 @@ var InviteItem = function InviteItem(_ref) {
|
|
|
61
70
|
})), jsx("div", {
|
|
62
71
|
css: nameSectionStyle,
|
|
63
72
|
"data-testid": "name-section"
|
|
64
|
-
}, jsx(FormattedMessage
|
|
73
|
+
}, jsx(FormattedMessage
|
|
74
|
+
// Ignored via go/ees005
|
|
75
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
76
|
+
, _extends({}, messages.inviteItemTitle, {
|
|
65
77
|
values: {
|
|
66
78
|
userRole: userRole || 'basic',
|
|
67
79
|
productName:
|
|
@@ -88,6 +88,8 @@ export var Mention = function Mention(props) {
|
|
|
88
88
|
}, []);
|
|
89
89
|
var actionHandlers = {};
|
|
90
90
|
['onClick', 'onMouseEnter', 'onMouseLeave'].forEach(function (handler) {
|
|
91
|
+
// Ignored via go/ees005
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
91
93
|
actionHandlers[handler] = eventHandlers && eventHandlers[handler] || function () {};
|
|
92
94
|
});
|
|
93
95
|
if (profilecardProvider) {
|
|
@@ -99,6 +101,8 @@ export var Mention = function Mention(props) {
|
|
|
99
101
|
mentionProvider: mentionProvider,
|
|
100
102
|
profilecardProvider: profilecardProvider,
|
|
101
103
|
localId: localId
|
|
104
|
+
// Ignored via go/ees005
|
|
105
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
102
106
|
}, actionHandlers));
|
|
103
107
|
} else {
|
|
104
108
|
return /*#__PURE__*/React.createElement(ResourcedMention, _extends({
|
|
@@ -107,6 +111,8 @@ export var Mention = function Mention(props) {
|
|
|
107
111
|
accessLevel: accessLevel,
|
|
108
112
|
mentionProvider: mentionProvider,
|
|
109
113
|
localId: localId
|
|
114
|
+
// Ignored via go/ees005
|
|
115
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
110
116
|
}, actionHandlers));
|
|
111
117
|
}
|
|
112
118
|
};
|
|
@@ -11,6 +11,8 @@ import { injectIntl } from 'react-intl-next';
|
|
|
11
11
|
import { mentionMessages as messages } from '@atlaskit/editor-common/messages';
|
|
12
12
|
import { TOOLBAR_BUTTON, ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
13
13
|
import MentionIcon from '@atlaskit/icon/glyph/editor/mention';
|
|
14
|
+
// Ignored via go/ees005
|
|
15
|
+
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
14
16
|
var ToolbarMention = /*#__PURE__*/function (_PureComponent) {
|
|
15
17
|
function ToolbarMention() {
|
|
16
18
|
var _this;
|
|
@@ -15,7 +15,10 @@ var extractAttributesFromQuery = function extractAttributesFromQuery(query) {
|
|
|
15
15
|
}
|
|
16
16
|
return emptyQueryResponse;
|
|
17
17
|
};
|
|
18
|
-
export var buildTypeAheadCancelPayload = function buildTypeAheadCancelPayload(duration, upKeyCount, downKeyCount, sessionId, query
|
|
18
|
+
export var buildTypeAheadCancelPayload = function buildTypeAheadCancelPayload(duration, upKeyCount, downKeyCount, sessionId, query
|
|
19
|
+
// Ignored via go/ees005
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
21
|
+
) {
|
|
19
22
|
var _extractAttributesFro = extractAttributesFromQuery(query),
|
|
20
23
|
queryLength = _extractAttributesFro.queryLength,
|
|
21
24
|
spaceInQuery = _extractAttributesFro.spaceInQuery;
|
|
@@ -65,7 +68,10 @@ export var buildTypeAheadInviteItemViewedPayload = function buildTypeAheadInvite
|
|
|
65
68
|
}
|
|
66
69
|
};
|
|
67
70
|
};
|
|
68
|
-
export var buildTypeAheadInviteItemClickedPayload = function buildTypeAheadInviteItemClickedPayload(duration, upKeyCount, downKeyCount, sessionId, insertType, query, contextIdentifierProvider, userRole
|
|
71
|
+
export var buildTypeAheadInviteItemClickedPayload = function buildTypeAheadInviteItemClickedPayload(duration, upKeyCount, downKeyCount, sessionId, insertType, query, contextIdentifierProvider, userRole
|
|
72
|
+
// Ignored via go/ees005
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
74
|
+
) {
|
|
69
75
|
var _extractAttributesFro2 = extractAttributesFromQuery(query),
|
|
70
76
|
queryLength = _extractAttributesFro2.queryLength,
|
|
71
77
|
spaceInQuery = _extractAttributesFro2.spaceInQuery;
|
|
@@ -93,7 +99,10 @@ export var buildTypeAheadInviteItemClickedPayload = function buildTypeAheadInvit
|
|
|
93
99
|
}
|
|
94
100
|
};
|
|
95
101
|
};
|
|
96
|
-
export var buildTypeAheadInsertedPayload = function buildTypeAheadInsertedPayload(duration, upKeyCount, downKeyCount, sessionId, insertType, mention, mentionLocalId, mentionList, query, contextIdentifierProvider, taskListId, taskItemId
|
|
102
|
+
export var buildTypeAheadInsertedPayload = function buildTypeAheadInsertedPayload(duration, upKeyCount, downKeyCount, sessionId, insertType, mention, mentionLocalId, mentionList, query, contextIdentifierProvider, taskListId, taskItemId
|
|
103
|
+
// Ignored via go/ees005
|
|
104
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
105
|
+
) {
|
|
97
106
|
var _extractAttributesFro3 = extractAttributesFromQuery(query),
|
|
98
107
|
queryLength = _extractAttributesFro3.queryLength,
|
|
99
108
|
spaceInQuery = _extractAttributesFro3.spaceInQuery;
|
|
@@ -134,7 +143,10 @@ export var buildTypeAheadInsertedPayload = function buildTypeAheadInsertedPayloa
|
|
|
134
143
|
}
|
|
135
144
|
};
|
|
136
145
|
};
|
|
137
|
-
export var buildTypeAheadRenderedPayload = function buildTypeAheadRenderedPayload(duration, userIds, query, teams
|
|
146
|
+
export var buildTypeAheadRenderedPayload = function buildTypeAheadRenderedPayload(duration, userIds, query, teams
|
|
147
|
+
// Ignored via go/ees005
|
|
148
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
149
|
+
) {
|
|
138
150
|
var _extractAttributesFro4 = extractAttributesFromQuery(query),
|
|
139
151
|
queryLength = _extractAttributesFro4.queryLength,
|
|
140
152
|
spaceInQuery = _extractAttributesFro4.spaceInQuery;
|
|
@@ -121,7 +121,11 @@ var buildAndSendElementsTypeAheadAnalytics = function buildAndSendElementsTypeAh
|
|
|
121
121
|
teams = mentions.map(function (mention) {
|
|
122
122
|
return isTeamType(mention.userType) ? {
|
|
123
123
|
teamId: mention.id,
|
|
124
|
+
// Ignored via go/ees005
|
|
125
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
124
126
|
includesYou: mention.context.includesYou,
|
|
127
|
+
// Ignored via go/ees005
|
|
128
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
125
129
|
memberCount: mention.context.memberCount
|
|
126
130
|
} : null;
|
|
127
131
|
}).filter(function (m) {
|
|
@@ -137,7 +141,10 @@ var buildAndSendElementsTypeAheadAnalytics = function buildAndSendElementsTypeAh
|
|
|
137
141
|
* When a team mention is selected, we render a team link and list of member/user mentions
|
|
138
142
|
* in editor content
|
|
139
143
|
*/
|
|
140
|
-
var buildNodesForTeamMention = function buildNodesForTeamMention(schema, selectedMention, mentionProvider, sanitizePrivateContent
|
|
144
|
+
var buildNodesForTeamMention = function buildNodesForTeamMention(schema, selectedMention, mentionProvider, sanitizePrivateContent
|
|
145
|
+
// Ignored via go/ees005
|
|
146
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
147
|
+
) {
|
|
141
148
|
var nodes = schema.nodes,
|
|
142
149
|
marks = schema.marks;
|
|
143
150
|
var name = selectedMention.name,
|
|
@@ -150,7 +157,10 @@ var buildNodesForTeamMention = function buildNodesForTeamMention(schema, selecte
|
|
|
150
157
|
var teamLink = context && context.teamLink ? context.teamLink : defaultTeamLink;
|
|
151
158
|
var teamLinkNode = fg('team-mention-inline-smartlink') ? schema.nodes.inlineCard.create({
|
|
152
159
|
url: teamLink
|
|
153
|
-
}) :
|
|
160
|
+
}) :
|
|
161
|
+
// Ignored via go/ees005
|
|
162
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
163
|
+
schema.text(name, [marks.link.create({
|
|
154
164
|
href: teamLink
|
|
155
165
|
})]);
|
|
156
166
|
var openBracketText = schema.text('(');
|
|
@@ -261,6 +271,8 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref6) {
|
|
|
261
271
|
onOpen: function onOpen() {
|
|
262
272
|
firstQueryWithoutResults = null;
|
|
263
273
|
},
|
|
274
|
+
// Ignored via go/ees005
|
|
275
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
264
276
|
selectItem: function selectItem(state, item, insert, _ref9) {
|
|
265
277
|
var _api$contextIdentifie3, _api$contextIdentifie4;
|
|
266
278
|
var mode = _ref9.mode,
|
|
@@ -275,7 +287,8 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref6) {
|
|
|
275
287
|
name = _item$mention.name,
|
|
276
288
|
nickname = _item$mention.nickname,
|
|
277
289
|
accessLevel = _item$mention.accessLevel,
|
|
278
|
-
userType = _item$mention.userType
|
|
290
|
+
userType = _item$mention.userType,
|
|
291
|
+
isXProductUser = _item$mention.isXProductUser;
|
|
279
292
|
var trimmedNickname = nickname && nickname.startsWith('@') ? nickname.slice(1) : nickname;
|
|
280
293
|
var renderName = mentionInsertDisplayName || !trimmedNickname ? name : trimmedNickname;
|
|
281
294
|
var _ref10 = (_api$contextIdentifie3 = api === null || api === void 0 || (_api$contextIdentifie4 = api.contextIdentifier) === null || _api$contextIdentifie4 === void 0 ? void 0 : _api$contextIdentifie4.sharedState.currentState()) !== null && _api$contextIdentifie3 !== void 0 ? _api$contextIdentifie3 : {},
|
|
@@ -332,6 +345,9 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref6) {
|
|
|
332
345
|
if (mentionProvider && isTeamType(userType)) {
|
|
333
346
|
return insert(buildNodesForTeamMention(schema, item.mention, mentionProvider, sanitizePrivateContent));
|
|
334
347
|
}
|
|
348
|
+
if (isXProductUser && mentionProvider && mentionProvider.inviteXProductUser) {
|
|
349
|
+
mentionProvider.inviteXProductUser(id);
|
|
350
|
+
}
|
|
335
351
|
|
|
336
352
|
// Don't insert into document if document data is sanitized.
|
|
337
353
|
var text = sanitizePrivateContent ? '' : "@".concat(renderName);
|