@atlaskit/editor-plugin-mentions 14.5.18 → 14.6.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 +11 -0
- package/dist/cjs/mentionsPlugin.js +2 -2
- package/dist/cjs/pm-plugins/main.js +1 -1
- package/dist/cjs/ui/type-ahead/index.js +46 -34
- package/dist/es2019/mentionsPlugin.js +2 -2
- package/dist/es2019/pm-plugins/main.js +1 -1
- package/dist/es2019/ui/type-ahead/index.js +30 -26
- package/dist/esm/mentionsPlugin.js +2 -2
- package/dist/esm/pm-plugins/main.js +1 -1
- package/dist/esm/ui/type-ahead/index.js +46 -34
- package/dist/types/types/index.d.ts +7 -0
- package/dist/types/ui/type-ahead/index.d.ts +5 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-mentions
|
|
2
2
|
|
|
3
|
+
## 14.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`f8280f6b24eec`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f8280f6b24eec) -
|
|
8
|
+
Allow editor surfaces to control agent mention picker sectioning independently.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
3
14
|
## 14.5.18
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -19,7 +19,6 @@ var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
|
19
19
|
var _resource = require("@atlaskit/mention/resource");
|
|
20
20
|
var _types = require("@atlaskit/mention/types");
|
|
21
21
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
22
|
-
var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
|
|
23
22
|
var _editorCommands = require("./editor-commands");
|
|
24
23
|
var _mentionNodeSpec = require("./nodeviews/mentionNodeSpec");
|
|
25
24
|
var _key = require("./pm-plugins/key");
|
|
@@ -105,6 +104,7 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref3) {
|
|
|
105
104
|
mentionInsertDisplayName: options === null || options === void 0 ? void 0 : options.insertDisplayName,
|
|
106
105
|
HighlightComponent: options === null || options === void 0 ? void 0 : options.HighlightComponent,
|
|
107
106
|
handleMentionsChanged: options === null || options === void 0 ? void 0 : options.handleMentionsChanged,
|
|
107
|
+
enableAgentSectioning: options === null || options === void 0 ? void 0 : options.enableAgentSectioning,
|
|
108
108
|
fireEvent: fireEvent,
|
|
109
109
|
api: api
|
|
110
110
|
});
|
|
@@ -198,7 +198,7 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref3) {
|
|
|
198
198
|
},
|
|
199
199
|
updateSectionTitle: function updateSectionTitle(props) {
|
|
200
200
|
var _api$typeAhead$action, _api$typeAhead2, _api$typeAhead2$updat;
|
|
201
|
-
if (!(0
|
|
201
|
+
if (!(options !== null && options !== void 0 && options.enableAgentSectioning)) {
|
|
202
202
|
return false;
|
|
203
203
|
}
|
|
204
204
|
return (_api$typeAhead$action = api === null || api === void 0 || (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 || (_api$typeAhead2 = _api$typeAhead2.actions) === null || _api$typeAhead2 === void 0 || (_api$typeAhead2$updat = _api$typeAhead2.updateSectionTitle) === null || _api$typeAhead2$updat === void 0 ? void 0 : _api$typeAhead2$updat.call(_api$typeAhead2, props)) !== null && _api$typeAhead$action !== void 0 ? _api$typeAhead$action : false;
|
|
@@ -53,7 +53,7 @@ var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
|
|
|
53
53
|
var AGENT_MENTION_INACTIVITY_MS = 3000;
|
|
54
54
|
var MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
|
|
55
55
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
56
|
-
var PACKAGE_VERSION = "14.5.
|
|
56
|
+
var PACKAGE_VERSION = "14.5.18";
|
|
57
57
|
var setProvider = function setProvider(provider) {
|
|
58
58
|
return function (state, dispatch) {
|
|
59
59
|
if (dispatch) {
|
|
@@ -101,28 +101,37 @@ var withInviteItem = function withInviteItem(_ref3) {
|
|
|
101
101
|
inviteItem]);
|
|
102
102
|
};
|
|
103
103
|
};
|
|
104
|
-
var
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
104
|
+
var makeMentionToTypeaheadItem = function makeMentionToTypeaheadItem(useRefreshedItemHeight) {
|
|
105
|
+
return function (mention) {
|
|
106
|
+
var itemHeight = useRefreshedItemHeight ? _item.MENTION_ITEM_HEIGHT_REFRESHED : _item.MENTION_ITEM_HEIGHT;
|
|
107
|
+
return {
|
|
108
|
+
title: mention.id,
|
|
109
|
+
render: function render(_ref4) {
|
|
110
|
+
var isSelected = _ref4.isSelected,
|
|
111
|
+
onClick = _ref4.onClick,
|
|
112
|
+
onHover = _ref4.onHover;
|
|
113
|
+
return /*#__PURE__*/_react.default.createElement(_item.MentionItem, {
|
|
114
|
+
mention: mention,
|
|
115
|
+
selected: isSelected,
|
|
116
|
+
onMouseEnter: onHover,
|
|
117
|
+
onSelection: onClick,
|
|
118
|
+
height: itemHeight
|
|
119
|
+
});
|
|
120
|
+
},
|
|
121
|
+
getCustomComponentHeight: function getCustomComponentHeight() {
|
|
122
|
+
return itemHeight;
|
|
123
|
+
},
|
|
124
|
+
mention: mention
|
|
125
|
+
};
|
|
124
126
|
};
|
|
125
127
|
};
|
|
128
|
+
var mentionToTypeaheadItem = exports.mentionToTypeaheadItem = function mentionToTypeaheadItem(mention) {
|
|
129
|
+
return makeMentionToTypeaheadItem((0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false))(mention);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Caches mention typeahead items by mention ID.
|
|
134
|
+
*/
|
|
126
135
|
function memoize(fn
|
|
127
136
|
// eslint-disable-next-line @typescript-eslint/method-signature-style -- ignored via go/ees013 (to be fixed)
|
|
128
137
|
) {
|
|
@@ -145,7 +154,6 @@ function memoize(fn
|
|
|
145
154
|
clear: seen.clear.bind(seen)
|
|
146
155
|
};
|
|
147
156
|
}
|
|
148
|
-
var memoizedToItem = memoize(mentionToTypeaheadItem);
|
|
149
157
|
var buildAndSendElementsTypeAheadAnalytics = function buildAndSendElementsTypeAheadAnalytics(fireEvent) {
|
|
150
158
|
return function (_ref5) {
|
|
151
159
|
var query = _ref5.query,
|
|
@@ -255,7 +263,8 @@ var buildNodesForTeamMention = function buildNodesForTeamMention(schema, selecte
|
|
|
255
263
|
var makeTransformMentionsToTypeAheadItems = function makeTransformMentionsToTypeAheadItems(_ref6) {
|
|
256
264
|
var fireEvent = _ref6.fireEvent,
|
|
257
265
|
getFirstQueryWithoutResults = _ref6.getFirstQueryWithoutResults,
|
|
258
|
-
setFirstQueryWithoutResults = _ref6.setFirstQueryWithoutResults
|
|
266
|
+
setFirstQueryWithoutResults = _ref6.setFirstQueryWithoutResults,
|
|
267
|
+
toItem = _ref6.toItem;
|
|
259
268
|
return function (_ref7) {
|
|
260
269
|
var mentions = _ref7.mentions,
|
|
261
270
|
query = _ref7.query,
|
|
@@ -264,7 +273,7 @@ var makeTransformMentionsToTypeAheadItems = function makeTransformMentionsToType
|
|
|
264
273
|
contextIdentifierProvider = _ref7.contextIdentifierProvider,
|
|
265
274
|
sessionId = _ref7.sessionId;
|
|
266
275
|
var mentionItems = mentions.map(function (mention) {
|
|
267
|
-
return
|
|
276
|
+
return toItem(mention);
|
|
268
277
|
});
|
|
269
278
|
buildAndSendElementsTypeAheadAnalytics(fireEvent)({
|
|
270
279
|
query: query,
|
|
@@ -298,7 +307,9 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
|
|
|
298
307
|
fireEvent = _ref8.fireEvent,
|
|
299
308
|
HighlightComponent = _ref8.HighlightComponent,
|
|
300
309
|
api = _ref8.api,
|
|
301
|
-
handleMentionsChanged = _ref8.handleMentionsChanged
|
|
310
|
+
handleMentionsChanged = _ref8.handleMentionsChanged,
|
|
311
|
+
_ref8$enableAgentSect = _ref8.enableAgentSectioning,
|
|
312
|
+
enableAgentSectioning = _ref8$enableAgentSect === void 0 ? false : _ref8$enableAgentSect;
|
|
302
313
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
303
314
|
var sessionId = (0, _uuid.default)();
|
|
304
315
|
var firstQueryWithoutResults = null;
|
|
@@ -310,7 +321,8 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
|
|
|
310
321
|
},
|
|
311
322
|
setFirstQueryWithoutResults: function setFirstQueryWithoutResults(query) {
|
|
312
323
|
firstQueryWithoutResults = query;
|
|
313
|
-
}
|
|
324
|
+
},
|
|
325
|
+
toItem: memoize(makeMentionToTypeaheadItem(enableAgentSectioning)).call
|
|
314
326
|
});
|
|
315
327
|
var typeAhead = {
|
|
316
328
|
id: _typeAhead.TypeAheadAvailableNodes.MENTION,
|
|
@@ -372,35 +384,35 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
|
|
|
372
384
|
},
|
|
373
385
|
getSections: function getSections(_ref1) {
|
|
374
386
|
var intl = _ref1.intl;
|
|
375
|
-
|
|
387
|
+
if (!enableAgentSectioning) {
|
|
388
|
+
return [];
|
|
389
|
+
}
|
|
390
|
+
return [{
|
|
376
391
|
id: 'people',
|
|
377
392
|
title: intl.formatMessage(_messages.mentionMessages.typeAheadSectionPeople),
|
|
378
393
|
filter: function filter(item) {
|
|
379
394
|
return !isAgentTypeAheadItem(item);
|
|
380
395
|
},
|
|
381
|
-
limit:
|
|
382
|
-
}, (0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false) ? {
|
|
396
|
+
limit: 5,
|
|
383
397
|
sectionTitleDisplay: {
|
|
384
398
|
showWhenQueryPresent: false,
|
|
385
399
|
showWhenOnlySection: true
|
|
386
400
|
}
|
|
387
|
-
}
|
|
401
|
+
}, {
|
|
388
402
|
id: 'agents',
|
|
389
403
|
title: intl.formatMessage(_messages.mentionMessages.typeAheadSectionAgents),
|
|
390
404
|
filter: function filter(item) {
|
|
391
405
|
return isAgentTypeAheadItem(item);
|
|
392
406
|
},
|
|
393
|
-
limit:
|
|
394
|
-
}, (0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false) ? {
|
|
407
|
+
limit: 5,
|
|
395
408
|
sectionTitleDisplay: {
|
|
396
409
|
showWhenQueryPresent: false,
|
|
397
410
|
showWhenOnlySection: true
|
|
398
|
-
}
|
|
399
|
-
} : {}), (0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false) ? {
|
|
411
|
+
},
|
|
400
412
|
lozenge: /*#__PURE__*/_react.default.createElement(_lozenge.default, {
|
|
401
413
|
appearance: "new"
|
|
402
414
|
}, intl.formatMessage(_messages.mentionMessages.typeAheadSectionAgentsLabsLozengeLabel))
|
|
403
|
-
}
|
|
415
|
+
}];
|
|
404
416
|
},
|
|
405
417
|
onOpen: function onOpen() {
|
|
406
418
|
firstQueryWithoutResults = null;
|
|
@@ -9,7 +9,6 @@ import { IconMention } from '@atlaskit/editor-common/quick-insert';
|
|
|
9
9
|
import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
|
|
10
10
|
import { MentionNameStatus, isPromise } from '@atlaskit/mention/types';
|
|
11
11
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
|
-
import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
13
12
|
import { insertMention } from './editor-commands';
|
|
14
13
|
import { mentionNodeSpec } from './nodeviews/mentionNodeSpec';
|
|
15
14
|
import { mentionPluginKey } from './pm-plugins/key';
|
|
@@ -103,6 +102,7 @@ const mentionsPlugin = ({
|
|
|
103
102
|
mentionInsertDisplayName: options === null || options === void 0 ? void 0 : options.insertDisplayName,
|
|
104
103
|
HighlightComponent: options === null || options === void 0 ? void 0 : options.HighlightComponent,
|
|
105
104
|
handleMentionsChanged: options === null || options === void 0 ? void 0 : options.handleMentionsChanged,
|
|
105
|
+
enableAgentSectioning: options === null || options === void 0 ? void 0 : options.enableAgentSectioning,
|
|
106
106
|
fireEvent,
|
|
107
107
|
api
|
|
108
108
|
});
|
|
@@ -195,7 +195,7 @@ const mentionsPlugin = ({
|
|
|
195
195
|
},
|
|
196
196
|
updateSectionTitle: props => {
|
|
197
197
|
var _api$typeAhead$action2, _api$typeAhead2, _api$typeAhead2$actio, _api$typeAhead2$actio2;
|
|
198
|
-
if (!
|
|
198
|
+
if (!(options !== null && options !== void 0 && options.enableAgentSectioning)) {
|
|
199
199
|
return false;
|
|
200
200
|
}
|
|
201
201
|
return (_api$typeAhead$action2 = api === null || api === void 0 ? void 0 : (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 ? void 0 : (_api$typeAhead2$actio = _api$typeAhead2.actions) === null || _api$typeAhead2$actio === void 0 ? void 0 : (_api$typeAhead2$actio2 = _api$typeAhead2$actio.updateSectionTitle) === null || _api$typeAhead2$actio2 === void 0 ? void 0 : _api$typeAhead2$actio2.call(_api$typeAhead2$actio, props)) !== null && _api$typeAhead$action2 !== void 0 ? _api$typeAhead$action2 : false;
|
|
@@ -38,7 +38,7 @@ const AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
|
|
|
38
38
|
const AGENT_MENTION_INACTIVITY_MS = 3000;
|
|
39
39
|
const MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
|
|
40
40
|
const PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
41
|
-
const PACKAGE_VERSION = "14.5.
|
|
41
|
+
const PACKAGE_VERSION = "14.5.18";
|
|
42
42
|
const setProvider = provider => (state, dispatch) => {
|
|
43
43
|
if (dispatch) {
|
|
44
44
|
dispatch(state.tr.setMeta(mentionPluginKey, {
|
|
@@ -78,8 +78,8 @@ const withInviteItem = ({
|
|
|
78
78
|
// invite item should be shown at the bottom
|
|
79
79
|
inviteItem];
|
|
80
80
|
};
|
|
81
|
-
|
|
82
|
-
const itemHeight =
|
|
81
|
+
const makeMentionToTypeaheadItem = useRefreshedItemHeight => mention => {
|
|
82
|
+
const itemHeight = useRefreshedItemHeight ? MENTION_ITEM_HEIGHT_REFRESHED : MENTION_ITEM_HEIGHT;
|
|
83
83
|
return {
|
|
84
84
|
title: mention.id,
|
|
85
85
|
render: ({
|
|
@@ -99,6 +99,11 @@ export const mentionToTypeaheadItem = mention => {
|
|
|
99
99
|
mention
|
|
100
100
|
};
|
|
101
101
|
};
|
|
102
|
+
export const mentionToTypeaheadItem = mention => makeMentionToTypeaheadItem(expVal('platform_editor_agent_mentions', 'isEnabled', false))(mention);
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Caches mention typeahead items by mention ID.
|
|
106
|
+
*/
|
|
102
107
|
export function memoize(fn
|
|
103
108
|
// eslint-disable-next-line @typescript-eslint/method-signature-style -- ignored via go/ees013 (to be fixed)
|
|
104
109
|
) {
|
|
@@ -121,7 +126,6 @@ export function memoize(fn
|
|
|
121
126
|
clear: seen.clear.bind(seen)
|
|
122
127
|
};
|
|
123
128
|
}
|
|
124
|
-
const memoizedToItem = memoize(mentionToTypeaheadItem);
|
|
125
129
|
const buildAndSendElementsTypeAheadAnalytics = fireEvent => ({
|
|
126
130
|
query,
|
|
127
131
|
mentions,
|
|
@@ -228,7 +232,8 @@ const buildNodesForTeamMention = (schema, selectedMention, mentionProvider, sani
|
|
|
228
232
|
const makeTransformMentionsToTypeAheadItems = ({
|
|
229
233
|
fireEvent,
|
|
230
234
|
getFirstQueryWithoutResults,
|
|
231
|
-
setFirstQueryWithoutResults
|
|
235
|
+
setFirstQueryWithoutResults,
|
|
236
|
+
toItem
|
|
232
237
|
}) => {
|
|
233
238
|
return ({
|
|
234
239
|
mentions,
|
|
@@ -238,7 +243,7 @@ const makeTransformMentionsToTypeAheadItems = ({
|
|
|
238
243
|
contextIdentifierProvider,
|
|
239
244
|
sessionId
|
|
240
245
|
}) => {
|
|
241
|
-
const mentionItems = mentions.map(mention =>
|
|
246
|
+
const mentionItems = mentions.map(mention => toItem(mention));
|
|
242
247
|
buildAndSendElementsTypeAheadAnalytics(fireEvent)({
|
|
243
248
|
query,
|
|
244
249
|
mentions,
|
|
@@ -271,7 +276,8 @@ export const createTypeAheadConfig = ({
|
|
|
271
276
|
fireEvent,
|
|
272
277
|
HighlightComponent,
|
|
273
278
|
api,
|
|
274
|
-
handleMentionsChanged
|
|
279
|
+
handleMentionsChanged,
|
|
280
|
+
enableAgentSectioning = false
|
|
275
281
|
}) => {
|
|
276
282
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
277
283
|
let sessionId = uuid();
|
|
@@ -282,7 +288,8 @@ export const createTypeAheadConfig = ({
|
|
|
282
288
|
getFirstQueryWithoutResults: () => firstQueryWithoutResults,
|
|
283
289
|
setFirstQueryWithoutResults: query => {
|
|
284
290
|
firstQueryWithoutResults = query;
|
|
285
|
-
}
|
|
291
|
+
},
|
|
292
|
+
toItem: memoize(makeMentionToTypeaheadItem(enableAgentSectioning)).call
|
|
286
293
|
});
|
|
287
294
|
const typeAhead = {
|
|
288
295
|
id: TypeAheadAvailableNodes.MENTION,
|
|
@@ -348,33 +355,30 @@ export const createTypeAheadConfig = ({
|
|
|
348
355
|
getSections({
|
|
349
356
|
intl
|
|
350
357
|
}) {
|
|
358
|
+
if (!enableAgentSectioning) {
|
|
359
|
+
return [];
|
|
360
|
+
}
|
|
351
361
|
return [{
|
|
352
362
|
id: 'people',
|
|
353
363
|
title: intl.formatMessage(mentionMessages.typeAheadSectionPeople),
|
|
354
364
|
filter: item => !isAgentTypeAheadItem(item),
|
|
355
|
-
limit:
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
}
|
|
361
|
-
} : {})
|
|
365
|
+
limit: 5,
|
|
366
|
+
sectionTitleDisplay: {
|
|
367
|
+
showWhenQueryPresent: false,
|
|
368
|
+
showWhenOnlySection: true
|
|
369
|
+
}
|
|
362
370
|
}, {
|
|
363
371
|
id: 'agents',
|
|
364
372
|
title: intl.formatMessage(mentionMessages.typeAheadSectionAgents),
|
|
365
373
|
filter: item => isAgentTypeAheadItem(item),
|
|
366
|
-
limit:
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
lozenge: /*#__PURE__*/React.createElement(Lozenge, {
|
|
375
|
-
appearance: "new"
|
|
376
|
-
}, intl.formatMessage(mentionMessages.typeAheadSectionAgentsLabsLozengeLabel))
|
|
377
|
-
} : {})
|
|
374
|
+
limit: 5,
|
|
375
|
+
sectionTitleDisplay: {
|
|
376
|
+
showWhenQueryPresent: false,
|
|
377
|
+
showWhenOnlySection: true
|
|
378
|
+
},
|
|
379
|
+
lozenge: /*#__PURE__*/React.createElement(Lozenge, {
|
|
380
|
+
appearance: "new"
|
|
381
|
+
}, intl.formatMessage(mentionMessages.typeAheadSectionAgentsLabsLozengeLabel))
|
|
378
382
|
}];
|
|
379
383
|
},
|
|
380
384
|
onOpen: () => {
|
|
@@ -14,7 +14,6 @@ import { IconMention } from '@atlaskit/editor-common/quick-insert';
|
|
|
14
14
|
import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
|
|
15
15
|
import { MentionNameStatus, isPromise } from '@atlaskit/mention/types';
|
|
16
16
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
17
|
-
import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
18
17
|
import { insertMention } from './editor-commands';
|
|
19
18
|
import { mentionNodeSpec } from './nodeviews/mentionNodeSpec';
|
|
20
19
|
import { mentionPluginKey } from './pm-plugins/key';
|
|
@@ -97,6 +96,7 @@ var mentionsPlugin = function mentionsPlugin(_ref3) {
|
|
|
97
96
|
mentionInsertDisplayName: options === null || options === void 0 ? void 0 : options.insertDisplayName,
|
|
98
97
|
HighlightComponent: options === null || options === void 0 ? void 0 : options.HighlightComponent,
|
|
99
98
|
handleMentionsChanged: options === null || options === void 0 ? void 0 : options.handleMentionsChanged,
|
|
99
|
+
enableAgentSectioning: options === null || options === void 0 ? void 0 : options.enableAgentSectioning,
|
|
100
100
|
fireEvent: fireEvent,
|
|
101
101
|
api: api
|
|
102
102
|
});
|
|
@@ -190,7 +190,7 @@ var mentionsPlugin = function mentionsPlugin(_ref3) {
|
|
|
190
190
|
},
|
|
191
191
|
updateSectionTitle: function updateSectionTitle(props) {
|
|
192
192
|
var _api$typeAhead$action, _api$typeAhead2, _api$typeAhead2$updat;
|
|
193
|
-
if (!
|
|
193
|
+
if (!(options !== null && options !== void 0 && options.enableAgentSectioning)) {
|
|
194
194
|
return false;
|
|
195
195
|
}
|
|
196
196
|
return (_api$typeAhead$action = api === null || api === void 0 || (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 || (_api$typeAhead2 = _api$typeAhead2.actions) === null || _api$typeAhead2 === void 0 || (_api$typeAhead2$updat = _api$typeAhead2.updateSectionTitle) === null || _api$typeAhead2$updat === void 0 ? void 0 : _api$typeAhead2$updat.call(_api$typeAhead2, props)) !== null && _api$typeAhead$action !== void 0 ? _api$typeAhead$action : false;
|
|
@@ -45,7 +45,7 @@ var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
|
|
|
45
45
|
var AGENT_MENTION_INACTIVITY_MS = 3000;
|
|
46
46
|
var MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
|
|
47
47
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
48
|
-
var PACKAGE_VERSION = "14.5.
|
|
48
|
+
var PACKAGE_VERSION = "14.5.18";
|
|
49
49
|
var setProvider = function setProvider(provider) {
|
|
50
50
|
return function (state, dispatch) {
|
|
51
51
|
if (dispatch) {
|
|
@@ -92,28 +92,37 @@ var withInviteItem = function withInviteItem(_ref3) {
|
|
|
92
92
|
inviteItem]);
|
|
93
93
|
};
|
|
94
94
|
};
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
95
|
+
var makeMentionToTypeaheadItem = function makeMentionToTypeaheadItem(useRefreshedItemHeight) {
|
|
96
|
+
return function (mention) {
|
|
97
|
+
var itemHeight = useRefreshedItemHeight ? MENTION_ITEM_HEIGHT_REFRESHED : MENTION_ITEM_HEIGHT;
|
|
98
|
+
return {
|
|
99
|
+
title: mention.id,
|
|
100
|
+
render: function render(_ref4) {
|
|
101
|
+
var isSelected = _ref4.isSelected,
|
|
102
|
+
onClick = _ref4.onClick,
|
|
103
|
+
onHover = _ref4.onHover;
|
|
104
|
+
return /*#__PURE__*/React.createElement(MentionItem, {
|
|
105
|
+
mention: mention,
|
|
106
|
+
selected: isSelected,
|
|
107
|
+
onMouseEnter: onHover,
|
|
108
|
+
onSelection: onClick,
|
|
109
|
+
height: itemHeight
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
getCustomComponentHeight: function getCustomComponentHeight() {
|
|
113
|
+
return itemHeight;
|
|
114
|
+
},
|
|
115
|
+
mention: mention
|
|
116
|
+
};
|
|
115
117
|
};
|
|
116
118
|
};
|
|
119
|
+
export var mentionToTypeaheadItem = function mentionToTypeaheadItem(mention) {
|
|
120
|
+
return makeMentionToTypeaheadItem(expVal('platform_editor_agent_mentions', 'isEnabled', false))(mention);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Caches mention typeahead items by mention ID.
|
|
125
|
+
*/
|
|
117
126
|
export function memoize(fn
|
|
118
127
|
// eslint-disable-next-line @typescript-eslint/method-signature-style -- ignored via go/ees013 (to be fixed)
|
|
119
128
|
) {
|
|
@@ -136,7 +145,6 @@ export function memoize(fn
|
|
|
136
145
|
clear: seen.clear.bind(seen)
|
|
137
146
|
};
|
|
138
147
|
}
|
|
139
|
-
var memoizedToItem = memoize(mentionToTypeaheadItem);
|
|
140
148
|
var buildAndSendElementsTypeAheadAnalytics = function buildAndSendElementsTypeAheadAnalytics(fireEvent) {
|
|
141
149
|
return function (_ref5) {
|
|
142
150
|
var query = _ref5.query,
|
|
@@ -246,7 +254,8 @@ var buildNodesForTeamMention = function buildNodesForTeamMention(schema, selecte
|
|
|
246
254
|
var makeTransformMentionsToTypeAheadItems = function makeTransformMentionsToTypeAheadItems(_ref6) {
|
|
247
255
|
var fireEvent = _ref6.fireEvent,
|
|
248
256
|
getFirstQueryWithoutResults = _ref6.getFirstQueryWithoutResults,
|
|
249
|
-
setFirstQueryWithoutResults = _ref6.setFirstQueryWithoutResults
|
|
257
|
+
setFirstQueryWithoutResults = _ref6.setFirstQueryWithoutResults,
|
|
258
|
+
toItem = _ref6.toItem;
|
|
250
259
|
return function (_ref7) {
|
|
251
260
|
var mentions = _ref7.mentions,
|
|
252
261
|
query = _ref7.query,
|
|
@@ -255,7 +264,7 @@ var makeTransformMentionsToTypeAheadItems = function makeTransformMentionsToType
|
|
|
255
264
|
contextIdentifierProvider = _ref7.contextIdentifierProvider,
|
|
256
265
|
sessionId = _ref7.sessionId;
|
|
257
266
|
var mentionItems = mentions.map(function (mention) {
|
|
258
|
-
return
|
|
267
|
+
return toItem(mention);
|
|
259
268
|
});
|
|
260
269
|
buildAndSendElementsTypeAheadAnalytics(fireEvent)({
|
|
261
270
|
query: query,
|
|
@@ -289,7 +298,9 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref8) {
|
|
|
289
298
|
fireEvent = _ref8.fireEvent,
|
|
290
299
|
HighlightComponent = _ref8.HighlightComponent,
|
|
291
300
|
api = _ref8.api,
|
|
292
|
-
handleMentionsChanged = _ref8.handleMentionsChanged
|
|
301
|
+
handleMentionsChanged = _ref8.handleMentionsChanged,
|
|
302
|
+
_ref8$enableAgentSect = _ref8.enableAgentSectioning,
|
|
303
|
+
enableAgentSectioning = _ref8$enableAgentSect === void 0 ? false : _ref8$enableAgentSect;
|
|
293
304
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
294
305
|
var sessionId = uuid();
|
|
295
306
|
var firstQueryWithoutResults = null;
|
|
@@ -301,7 +312,8 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref8) {
|
|
|
301
312
|
},
|
|
302
313
|
setFirstQueryWithoutResults: function setFirstQueryWithoutResults(query) {
|
|
303
314
|
firstQueryWithoutResults = query;
|
|
304
|
-
}
|
|
315
|
+
},
|
|
316
|
+
toItem: memoize(makeMentionToTypeaheadItem(enableAgentSectioning)).call
|
|
305
317
|
});
|
|
306
318
|
var typeAhead = {
|
|
307
319
|
id: TypeAheadAvailableNodes.MENTION,
|
|
@@ -363,35 +375,35 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref8) {
|
|
|
363
375
|
},
|
|
364
376
|
getSections: function getSections(_ref1) {
|
|
365
377
|
var intl = _ref1.intl;
|
|
366
|
-
|
|
378
|
+
if (!enableAgentSectioning) {
|
|
379
|
+
return [];
|
|
380
|
+
}
|
|
381
|
+
return [{
|
|
367
382
|
id: 'people',
|
|
368
383
|
title: intl.formatMessage(mentionMessages.typeAheadSectionPeople),
|
|
369
384
|
filter: function filter(item) {
|
|
370
385
|
return !isAgentTypeAheadItem(item);
|
|
371
386
|
},
|
|
372
|
-
limit:
|
|
373
|
-
}, expVal('platform_editor_agent_mentions', 'isEnabled', false) ? {
|
|
387
|
+
limit: 5,
|
|
374
388
|
sectionTitleDisplay: {
|
|
375
389
|
showWhenQueryPresent: false,
|
|
376
390
|
showWhenOnlySection: true
|
|
377
391
|
}
|
|
378
|
-
}
|
|
392
|
+
}, {
|
|
379
393
|
id: 'agents',
|
|
380
394
|
title: intl.formatMessage(mentionMessages.typeAheadSectionAgents),
|
|
381
395
|
filter: function filter(item) {
|
|
382
396
|
return isAgentTypeAheadItem(item);
|
|
383
397
|
},
|
|
384
|
-
limit:
|
|
385
|
-
}, expVal('platform_editor_agent_mentions', 'isEnabled', false) ? {
|
|
398
|
+
limit: 5,
|
|
386
399
|
sectionTitleDisplay: {
|
|
387
400
|
showWhenQueryPresent: false,
|
|
388
401
|
showWhenOnlySection: true
|
|
389
|
-
}
|
|
390
|
-
} : {}), expVal('platform_editor_agent_mentions', 'isEnabled', false) ? {
|
|
402
|
+
},
|
|
391
403
|
lozenge: /*#__PURE__*/React.createElement(Lozenge, {
|
|
392
404
|
appearance: "new"
|
|
393
405
|
}, intl.formatMessage(mentionMessages.typeAheadSectionAgentsLabsLozengeLabel))
|
|
394
|
-
}
|
|
406
|
+
}];
|
|
395
407
|
},
|
|
396
408
|
onOpen: function onOpen() {
|
|
397
409
|
firstQueryWithoutResults = null;
|
|
@@ -34,6 +34,13 @@ export interface MentionsPluginOptions extends MentionPluginConfig {
|
|
|
34
34
|
* Takes priority over `MentionProvider.shouldHighlightMention()` if both are present.
|
|
35
35
|
*/
|
|
36
36
|
currentUserId?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Enables People / Agents sectioning in the mentions typeahead.
|
|
39
|
+
*
|
|
40
|
+
* Consumers own the rollout decision for their editor surface; the shared
|
|
41
|
+
* mentions plugin only applies the resulting presentation option.
|
|
42
|
+
*/
|
|
43
|
+
enableAgentSectioning?: boolean;
|
|
37
44
|
/**
|
|
38
45
|
* Optional getter injected by Rovo-aware consumers to check whether the Rovo
|
|
39
46
|
* panel is currently open. When provided, the mentions plugin uses it to
|
|
@@ -4,17 +4,21 @@ import type { MentionDescription } from '@atlaskit/mention/resource';
|
|
|
4
4
|
import type { MentionsPlugin } from '../../mentionsPluginType';
|
|
5
5
|
import type { FireElementsChannelEvent, MentionChange } from '../../types';
|
|
6
6
|
export declare const mentionToTypeaheadItem: (mention: MentionDescription) => TypeAheadItem;
|
|
7
|
+
/**
|
|
8
|
+
* Caches mention typeahead items by mention ID.
|
|
9
|
+
*/
|
|
7
10
|
export declare function memoize<ResultFn extends (mention: MentionDescription) => TypeAheadItem>(fn: ResultFn): {
|
|
8
11
|
call: ResultFn;
|
|
9
12
|
clear(): void;
|
|
10
13
|
};
|
|
11
14
|
type Props = {
|
|
12
15
|
api: ExtractInjectionAPI<MentionsPlugin> | undefined;
|
|
16
|
+
enableAgentSectioning?: boolean;
|
|
13
17
|
fireEvent: FireElementsChannelEvent;
|
|
14
18
|
handleMentionsChanged?: (mentionChanges: MentionChange[]) => void;
|
|
15
19
|
HighlightComponent?: React.ComponentType<React.PropsWithChildren<unknown>>;
|
|
16
20
|
mentionInsertDisplayName?: boolean;
|
|
17
21
|
sanitizePrivateContent?: boolean;
|
|
18
22
|
};
|
|
19
|
-
export declare const createTypeAheadConfig: ({ sanitizePrivateContent, mentionInsertDisplayName, fireEvent, HighlightComponent, api, handleMentionsChanged, }: Props) => TypeAheadHandler;
|
|
23
|
+
export declare const createTypeAheadConfig: ({ sanitizePrivateContent, mentionInsertDisplayName, fireEvent, HighlightComponent, api, handleMentionsChanged, enableAgentSectioning, }: Props) => TypeAheadHandler;
|
|
20
24
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-mentions",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.6.0",
|
|
4
4
|
"description": "Mentions plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@atlaskit/profilecard": "^26.8.0",
|
|
42
42
|
"@atlaskit/teams-app-config": "^2.1.0",
|
|
43
43
|
"@atlaskit/theme": "^26.1.0",
|
|
44
|
-
"@atlaskit/tmp-editor-statsig": "^124.
|
|
44
|
+
"@atlaskit/tmp-editor-statsig": "^124.1.0",
|
|
45
45
|
"@atlaskit/tokens": "^15.5.0",
|
|
46
46
|
"@atlaskit/tooltip": "^23.1.0",
|
|
47
47
|
"@atlaskit/user-picker": "^13.4.0",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"uuid": "^3.1.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@atlaskit/editor-common": "^116.
|
|
56
|
+
"@atlaskit/editor-common": "^116.25.0",
|
|
57
57
|
"react": "^18.2.0",
|
|
58
58
|
"react-dom": "^18.2.0",
|
|
59
59
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|