@atlaskit/editor-common 94.14.2 → 94.16.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 +17 -0
- package/dist/cjs/element-browser/ElementBrowser.js +4 -2
- package/dist/cjs/element-browser/components/ElementList/ElementList.js +366 -21
- package/dist/cjs/element-browser/components/StatelessElementBrowser.js +14 -7
- package/dist/cjs/element-browser/constants.js +1 -1
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/quick-insert/utils.js +10 -5
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/es2019/element-browser/ElementBrowser.js +4 -2
- package/dist/es2019/element-browser/components/ElementList/ElementList.js +351 -5
- package/dist/es2019/element-browser/components/StatelessElementBrowser.js +14 -7
- package/dist/es2019/element-browser/constants.js +1 -1
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/quick-insert/utils.js +10 -5
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/esm/element-browser/ElementBrowser.js +4 -2
- package/dist/esm/element-browser/components/ElementList/ElementList.js +365 -20
- package/dist/esm/element-browser/components/StatelessElementBrowser.js +14 -7
- package/dist/esm/element-browser/constants.js +1 -1
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/quick-insert/utils.js +10 -5
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/types/analytics/index.d.ts +1 -0
- package/dist/types/element-browser/ElementBrowser.d.ts +2 -0
- package/dist/types/element-browser/components/ElementList/ElementList.d.ts +2 -0
- package/dist/types/element-browser/components/StatelessElementBrowser.d.ts +4 -1
- package/dist/types/element-browser/constants.d.ts +1 -1
- package/dist/types/extensibility/index.d.ts +1 -0
- package/dist/types/provider-factory.d.ts +1 -0
- package/dist/types/quick-insert/utils.d.ts +1 -1
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/types/quick-insert.d.ts +3 -3
- package/dist/types-ts4.5/analytics/index.d.ts +1 -0
- package/dist/types-ts4.5/element-browser/ElementBrowser.d.ts +2 -0
- package/dist/types-ts4.5/element-browser/components/ElementList/ElementList.d.ts +2 -0
- package/dist/types-ts4.5/element-browser/components/StatelessElementBrowser.d.ts +4 -1
- package/dist/types-ts4.5/element-browser/constants.d.ts +1 -1
- package/dist/types-ts4.5/extensibility/index.d.ts +1 -0
- package/dist/types-ts4.5/provider-factory.d.ts +1 -0
- package/dist/types-ts4.5/quick-insert/utils.d.ts +1 -1
- package/dist/types-ts4.5/types/index.d.ts +1 -1
- package/dist/types-ts4.5/types/quick-insert.d.ts +3 -3
- package/package.json +10 -7
|
@@ -7,7 +7,7 @@ import React, { Fragment, memo, useCallback, useEffect, useMemo, useState } from
|
|
|
7
7
|
|
|
8
8
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
9
9
|
import { css, jsx } from '@emotion/react';
|
|
10
|
-
import { Grid } from 'react-virtualized';
|
|
10
|
+
import { Grid, List } from 'react-virtualized';
|
|
11
11
|
import { AutoSizer } from 'react-virtualized/dist/commonjs/AutoSizer';
|
|
12
12
|
import { CellMeasurer, CellMeasurerCache } from 'react-virtualized/dist/commonjs/CellMeasurer';
|
|
13
13
|
import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext';
|
|
@@ -46,7 +46,7 @@ export const itemIcon = css({
|
|
|
46
46
|
height: `${ICON_HEIGHT}px`
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
|
-
function
|
|
49
|
+
function ElementListOld({
|
|
50
50
|
items,
|
|
51
51
|
mode,
|
|
52
52
|
selectedItemIndex,
|
|
@@ -94,8 +94,8 @@ function ElementList({
|
|
|
94
94
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
95
95
|
const cache = new CellMeasurerCache({
|
|
96
96
|
fixedWidth: true,
|
|
97
|
-
defaultHeight:
|
|
98
|
-
minHeight:
|
|
97
|
+
defaultHeight: 75,
|
|
98
|
+
minHeight: 75
|
|
99
99
|
});
|
|
100
100
|
const columnWidth = (containerWidth - ELEMENT_ITEM_PADDING * 2) / columnCount;
|
|
101
101
|
const rowCount = Math.ceil(items.length / columnCount);
|
|
@@ -103,7 +103,7 @@ function ElementList({
|
|
|
103
103
|
index
|
|
104
104
|
}) => cache.rowHeight({
|
|
105
105
|
index
|
|
106
|
-
}) <=
|
|
106
|
+
}) <= 75 ? 75 : cache.rowHeight({
|
|
107
107
|
index
|
|
108
108
|
}) + ELEMENT_ITEM_PADDING * 2;
|
|
109
109
|
const cellRenderer = useMemo(() => ({
|
|
@@ -200,6 +200,292 @@ function ElementList({
|
|
|
200
200
|
scrollToRow: Math.floor(selectedItemIndex / columnCount)
|
|
201
201
|
}))))));
|
|
202
202
|
}
|
|
203
|
+
function ElementListNew({
|
|
204
|
+
items,
|
|
205
|
+
mode,
|
|
206
|
+
selectedItemIndex,
|
|
207
|
+
focusedItemIndex,
|
|
208
|
+
columnCount,
|
|
209
|
+
setColumnCount,
|
|
210
|
+
createAnalyticsEvent,
|
|
211
|
+
emptyStateHandler,
|
|
212
|
+
selectedCategory,
|
|
213
|
+
selectedCategoryIndex,
|
|
214
|
+
searchTerm,
|
|
215
|
+
setFocusedCategoryIndex,
|
|
216
|
+
setFocusedItemIndex,
|
|
217
|
+
cache,
|
|
218
|
+
onInsertItem
|
|
219
|
+
}) {
|
|
220
|
+
const {
|
|
221
|
+
containerWidth,
|
|
222
|
+
ContainerWidthMonitor
|
|
223
|
+
} = useContainerWidth();
|
|
224
|
+
const [scrollbarWidth, setScrollbarWidth] = useState(SCROLLBAR_WIDTH);
|
|
225
|
+
const fullMode = mode === Modes.full;
|
|
226
|
+
useEffect(() => {
|
|
227
|
+
/**
|
|
228
|
+
* More of an optimization condition.
|
|
229
|
+
* Initially the containerWidths are reported 0 twice.
|
|
230
|
+
**/
|
|
231
|
+
if (fullMode && containerWidth > 0) {
|
|
232
|
+
setColumnCount(getColumnCount(containerWidth));
|
|
233
|
+
const updatedScrollbarWidth = getScrollbarWidth();
|
|
234
|
+
if (updatedScrollbarWidth > 0) {
|
|
235
|
+
setScrollbarWidth(updatedScrollbarWidth);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}, [fullMode, containerWidth, setColumnCount, scrollbarWidth]);
|
|
239
|
+
const onExternalLinkClick = useCallback(() => {
|
|
240
|
+
fireAnalyticsEvent(createAnalyticsEvent)({
|
|
241
|
+
payload: {
|
|
242
|
+
action: ACTION.VISITED,
|
|
243
|
+
actionSubject: ACTION_SUBJECT.SMART_LINK,
|
|
244
|
+
eventType: EVENT_TYPE.TRACK
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
}, [createAnalyticsEvent]);
|
|
248
|
+
|
|
249
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
250
|
+
const listCache = cache !== null && cache !== void 0 ? cache : new CellMeasurerCache({
|
|
251
|
+
fixedWidth: true,
|
|
252
|
+
defaultHeight: ELEMENT_ITEM_HEIGHT,
|
|
253
|
+
minHeight: ELEMENT_ITEM_HEIGHT
|
|
254
|
+
});
|
|
255
|
+
useEffect(() => {
|
|
256
|
+
// need to recalculate values if we have the same items, but they're reordered
|
|
257
|
+
listCache.clearAll();
|
|
258
|
+
}, [listCache, searchTerm]);
|
|
259
|
+
const rowHeight = ({
|
|
260
|
+
index
|
|
261
|
+
}) => {
|
|
262
|
+
return listCache.rowHeight({
|
|
263
|
+
index
|
|
264
|
+
});
|
|
265
|
+
};
|
|
266
|
+
return jsx(Fragment, null, jsx(ContainerWidthMonitor, null), jsx("div", {
|
|
267
|
+
css: elementItemsWrapper,
|
|
268
|
+
"data-testid": "element-items",
|
|
269
|
+
id: selectedCategory ? `browse-category-${selectedCategory}-tab` : 'browse-category-tab',
|
|
270
|
+
"aria-labelledby": selectedCategory ? `browse-category--${selectedCategory}-button` : 'browse-category-button',
|
|
271
|
+
role: "tabpanel",
|
|
272
|
+
tabIndex: items.length === 0 ? 0 : undefined
|
|
273
|
+
}, !items.length ? emptyStateHandler ? emptyStateHandler({
|
|
274
|
+
mode,
|
|
275
|
+
selectedCategory,
|
|
276
|
+
searchTerm
|
|
277
|
+
}) : jsx(EmptyState, {
|
|
278
|
+
onExternalLinkClick: onExternalLinkClick
|
|
279
|
+
}) : jsx(Fragment, null, containerWidth > 0 && jsx(AutoSizer, {
|
|
280
|
+
disableWidth: true
|
|
281
|
+
}, ({
|
|
282
|
+
height
|
|
283
|
+
}) => columnCount === 1 ? jsx(ElementListSingleColumn, {
|
|
284
|
+
cache: listCache,
|
|
285
|
+
setFocusedCategoryIndex: setFocusedCategoryIndex,
|
|
286
|
+
selectedCategoryIndex: selectedCategoryIndex,
|
|
287
|
+
items: items,
|
|
288
|
+
setFocusedItemIndex: setFocusedItemIndex,
|
|
289
|
+
fullMode: fullMode,
|
|
290
|
+
selectedItemIndex: selectedItemIndex,
|
|
291
|
+
focusedItemIndex: focusedItemIndex,
|
|
292
|
+
rowHeight: rowHeight,
|
|
293
|
+
containerWidth: containerWidth,
|
|
294
|
+
height: height,
|
|
295
|
+
onInsertItem: onInsertItem
|
|
296
|
+
}) : jsx(ElementListMultipleColumns, {
|
|
297
|
+
columnCount: columnCount,
|
|
298
|
+
cache: listCache,
|
|
299
|
+
setFocusedCategoryIndex: setFocusedCategoryIndex,
|
|
300
|
+
selectedCategoryIndex: selectedCategoryIndex,
|
|
301
|
+
items: items,
|
|
302
|
+
setFocusedItemIndex: setFocusedItemIndex,
|
|
303
|
+
fullMode: fullMode,
|
|
304
|
+
selectedItemIndex: selectedItemIndex,
|
|
305
|
+
focusedItemIndex: focusedItemIndex,
|
|
306
|
+
rowHeight: rowHeight,
|
|
307
|
+
containerWidth: containerWidth,
|
|
308
|
+
height: height,
|
|
309
|
+
onInsertItem: onInsertItem
|
|
310
|
+
})))));
|
|
311
|
+
}
|
|
312
|
+
const ElementListSingleColumn = props => {
|
|
313
|
+
const {
|
|
314
|
+
items,
|
|
315
|
+
fullMode,
|
|
316
|
+
setFocusedItemIndex,
|
|
317
|
+
rowHeight,
|
|
318
|
+
containerWidth,
|
|
319
|
+
height,
|
|
320
|
+
onInsertItem,
|
|
321
|
+
cache,
|
|
322
|
+
focusedItemIndex,
|
|
323
|
+
setFocusedCategoryIndex,
|
|
324
|
+
selectedCategoryIndex,
|
|
325
|
+
selectedItemIndex
|
|
326
|
+
} = props;
|
|
327
|
+
const rowRenderer = useMemo(() => ({
|
|
328
|
+
index,
|
|
329
|
+
key,
|
|
330
|
+
style,
|
|
331
|
+
parent
|
|
332
|
+
}) => {
|
|
333
|
+
return jsx(CellMeasurer, {
|
|
334
|
+
key: key,
|
|
335
|
+
cache: cache,
|
|
336
|
+
parent: parent,
|
|
337
|
+
columnIndex: 0,
|
|
338
|
+
rowIndex: index
|
|
339
|
+
}, jsx("div", {
|
|
340
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
341
|
+
style: style,
|
|
342
|
+
key: key
|
|
343
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766 -- Ignored via go/DSP-18766
|
|
344
|
+
,
|
|
345
|
+
className: "element-item-wrapper",
|
|
346
|
+
css: elementItemWrapperSingle,
|
|
347
|
+
onKeyDown: e => {
|
|
348
|
+
if (e.key === 'Tab') {
|
|
349
|
+
if (e.shiftKey && index === 0) {
|
|
350
|
+
if (setFocusedCategoryIndex) {
|
|
351
|
+
if (!!selectedCategoryIndex) {
|
|
352
|
+
setFocusedCategoryIndex(selectedCategoryIndex);
|
|
353
|
+
} else {
|
|
354
|
+
setFocusedCategoryIndex(0);
|
|
355
|
+
}
|
|
356
|
+
e.preventDefault();
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
// before focus jumps from elements list we need to rerender react-virtualized grid.
|
|
360
|
+
// Otherwise on the next render 'scrollToCell' will have same cached value
|
|
361
|
+
// and grid will not be scrolled to top.
|
|
362
|
+
// So Tab press on category will not work anymore due to invisible 1-t element.
|
|
363
|
+
else if (index === items.length - 2) {
|
|
364
|
+
setFocusedItemIndex(items.length - 1);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}, jsx(MemoizedElementItem, {
|
|
369
|
+
inlineMode: !fullMode,
|
|
370
|
+
index: index,
|
|
371
|
+
item: items[index],
|
|
372
|
+
selected: selectedItemIndex === index,
|
|
373
|
+
focus: focusedItemIndex === index,
|
|
374
|
+
setFocusedItemIndex: setFocusedItemIndex,
|
|
375
|
+
onInsertItem: onInsertItem
|
|
376
|
+
})));
|
|
377
|
+
},
|
|
378
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
379
|
+
[cache, items, fullMode, selectedItemIndex, focusedItemIndex, selectedCategoryIndex, setFocusedCategoryIndex, setFocusedItemIndex, props]);
|
|
380
|
+
return jsx(List, _extends({
|
|
381
|
+
rowRenderer: rowRenderer,
|
|
382
|
+
rowCount: items.length,
|
|
383
|
+
rowHeight: rowHeight,
|
|
384
|
+
width: containerWidth - ELEMENT_LIST_PADDING * 2,
|
|
385
|
+
height: height,
|
|
386
|
+
overscanRowCount: 3,
|
|
387
|
+
containerRole: "presentation",
|
|
388
|
+
role: "listbox"
|
|
389
|
+
}, selectedItemIndex !== undefined && {
|
|
390
|
+
scrollToIndex: selectedItemIndex
|
|
391
|
+
}));
|
|
392
|
+
};
|
|
393
|
+
const ElementListMultipleColumns = props => {
|
|
394
|
+
const {
|
|
395
|
+
columnCount,
|
|
396
|
+
items,
|
|
397
|
+
fullMode,
|
|
398
|
+
setFocusedItemIndex,
|
|
399
|
+
rowHeight,
|
|
400
|
+
containerWidth,
|
|
401
|
+
height,
|
|
402
|
+
onInsertItem,
|
|
403
|
+
cache,
|
|
404
|
+
focusedItemIndex,
|
|
405
|
+
setFocusedCategoryIndex,
|
|
406
|
+
selectedCategoryIndex,
|
|
407
|
+
selectedItemIndex
|
|
408
|
+
} = props;
|
|
409
|
+
const columnWidth = (containerWidth - ELEMENT_ITEM_PADDING * 2) / columnCount;
|
|
410
|
+
const rowCount = Math.ceil(items.length / columnCount);
|
|
411
|
+
const cellRenderer = useMemo(() => ({
|
|
412
|
+
columnIndex,
|
|
413
|
+
key,
|
|
414
|
+
parent,
|
|
415
|
+
rowIndex,
|
|
416
|
+
style
|
|
417
|
+
}) => {
|
|
418
|
+
const index = rowIndex * columnCount + columnIndex;
|
|
419
|
+
if (items[index] == null) {
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
return index > items.length - 1 ? null : jsx(CellMeasurer, {
|
|
423
|
+
cache: cache,
|
|
424
|
+
key: key,
|
|
425
|
+
rowIndex: rowIndex,
|
|
426
|
+
columnIndex: columnIndex,
|
|
427
|
+
parent: parent
|
|
428
|
+
}, jsx("div", {
|
|
429
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
430
|
+
style: style,
|
|
431
|
+
key: key
|
|
432
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766 -- Ignored via go/DSP-18766
|
|
433
|
+
,
|
|
434
|
+
className: "element-item-wrapper",
|
|
435
|
+
css: elementItemWrapper,
|
|
436
|
+
onKeyDown: e => {
|
|
437
|
+
if (e.key === 'Tab') {
|
|
438
|
+
if (e.shiftKey && index === 0) {
|
|
439
|
+
if (setFocusedCategoryIndex) {
|
|
440
|
+
if (!!selectedCategoryIndex) {
|
|
441
|
+
setFocusedCategoryIndex(selectedCategoryIndex);
|
|
442
|
+
} else {
|
|
443
|
+
setFocusedCategoryIndex(0);
|
|
444
|
+
}
|
|
445
|
+
e.preventDefault();
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
// before focus jumps from elements list we need to rerender react-virtualized grid.
|
|
449
|
+
// Otherwise on the next render 'scrollToCell' will have same cached value
|
|
450
|
+
// and grid will not be scrolled to top.
|
|
451
|
+
// So Tab press on category will not work anymore due to invisible 1-t element.
|
|
452
|
+
else if (index === items.length - 2) {
|
|
453
|
+
setFocusedItemIndex(items.length - 1);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}, jsx(MemoizedElementItem, {
|
|
458
|
+
inlineMode: !fullMode,
|
|
459
|
+
index: index,
|
|
460
|
+
item: items[index],
|
|
461
|
+
selected: selectedItemIndex === index,
|
|
462
|
+
focus: focusedItemIndex === index,
|
|
463
|
+
setFocusedItemIndex: setFocusedItemIndex,
|
|
464
|
+
onInsertItem: onInsertItem
|
|
465
|
+
})));
|
|
466
|
+
},
|
|
467
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
468
|
+
[cache, items, fullMode, selectedItemIndex, columnCount, focusedItemIndex, selectedCategoryIndex, setFocusedCategoryIndex, setFocusedItemIndex, props]);
|
|
469
|
+
return jsx(Grid, _extends({
|
|
470
|
+
cellRenderer: cellRenderer,
|
|
471
|
+
height: height,
|
|
472
|
+
width: containerWidth - ELEMENT_LIST_PADDING * 2 // containerWidth - padding on Left/Right (for focus outline)
|
|
473
|
+
/**
|
|
474
|
+
* Refresh Grid on WidthObserver value change.
|
|
475
|
+
* Length of the items used to force re-render to solve Firefox bug with react-virtualized retaining
|
|
476
|
+
* scroll position after updating the data. If new data has different number of cells, a re-render
|
|
477
|
+
* is forced to prevent the scroll position render bug.
|
|
478
|
+
*/,
|
|
479
|
+
key: containerWidth + items.length,
|
|
480
|
+
rowHeight: rowHeight,
|
|
481
|
+
rowCount: rowCount,
|
|
482
|
+
columnCount: columnCount,
|
|
483
|
+
columnWidth: columnWidth,
|
|
484
|
+
deferredMeasurementCache: cache
|
|
485
|
+
}, selectedItemIndex !== undefined && {
|
|
486
|
+
scrollToRow: Math.floor(selectedItemIndex / columnCount)
|
|
487
|
+
}));
|
|
488
|
+
};
|
|
203
489
|
const MemoizedElementItem = /*#__PURE__*/memo(ElementItem);
|
|
204
490
|
MemoizedElementItem.displayName = 'MemoizedElementItem';
|
|
205
491
|
export function ElementItem({
|
|
@@ -358,6 +644,17 @@ const elementItemsWrapper = css({
|
|
|
358
644
|
}
|
|
359
645
|
}
|
|
360
646
|
});
|
|
647
|
+
const elementItemWrapperSingle = css({
|
|
648
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
|
|
649
|
+
div: {
|
|
650
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
|
|
651
|
+
button: {
|
|
652
|
+
minHeight: '60px',
|
|
653
|
+
alignItems: 'flex-start',
|
|
654
|
+
padding: `${"var(--ds-space-150, 12px)"} ${"var(--ds-space-150, 12px)"} 11px`
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
});
|
|
361
658
|
const elementItemWrapper = css({
|
|
362
659
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
|
|
363
660
|
div: {
|
|
@@ -424,6 +721,55 @@ const itemIconStyle = css({
|
|
|
424
721
|
objectFit: 'cover'
|
|
425
722
|
}
|
|
426
723
|
});
|
|
724
|
+
function ElementList({
|
|
725
|
+
items,
|
|
726
|
+
mode,
|
|
727
|
+
selectedItemIndex,
|
|
728
|
+
focusedItemIndex,
|
|
729
|
+
columnCount,
|
|
730
|
+
setColumnCount,
|
|
731
|
+
createAnalyticsEvent,
|
|
732
|
+
emptyStateHandler,
|
|
733
|
+
selectedCategory,
|
|
734
|
+
selectedCategoryIndex,
|
|
735
|
+
searchTerm,
|
|
736
|
+
setFocusedCategoryIndex,
|
|
737
|
+
setFocusedItemIndex,
|
|
738
|
+
...props
|
|
739
|
+
}) {
|
|
740
|
+
if (fg('platform_editor_reduce_element_browser_padding')) {
|
|
741
|
+
return jsx(ElementListNew, _extends({
|
|
742
|
+
items: items,
|
|
743
|
+
mode: mode,
|
|
744
|
+
selectedItemIndex: selectedItemIndex,
|
|
745
|
+
focusedItemIndex: focusedItemIndex,
|
|
746
|
+
columnCount: columnCount,
|
|
747
|
+
setColumnCount: setColumnCount,
|
|
748
|
+
createAnalyticsEvent: createAnalyticsEvent,
|
|
749
|
+
emptyStateHandler: emptyStateHandler,
|
|
750
|
+
selectedCategory: selectedCategory,
|
|
751
|
+
selectedCategoryIndex: selectedCategoryIndex,
|
|
752
|
+
searchTerm: searchTerm,
|
|
753
|
+
setFocusedCategoryIndex: setFocusedCategoryIndex,
|
|
754
|
+
setFocusedItemIndex: setFocusedItemIndex
|
|
755
|
+
}, props));
|
|
756
|
+
}
|
|
757
|
+
return jsx(ElementListOld, _extends({
|
|
758
|
+
items: items,
|
|
759
|
+
mode: mode,
|
|
760
|
+
selectedItemIndex: selectedItemIndex,
|
|
761
|
+
focusedItemIndex: focusedItemIndex,
|
|
762
|
+
columnCount: columnCount,
|
|
763
|
+
setColumnCount: setColumnCount,
|
|
764
|
+
createAnalyticsEvent: createAnalyticsEvent,
|
|
765
|
+
emptyStateHandler: emptyStateHandler,
|
|
766
|
+
selectedCategory: selectedCategory,
|
|
767
|
+
selectedCategoryIndex: selectedCategoryIndex,
|
|
768
|
+
searchTerm: searchTerm,
|
|
769
|
+
setFocusedCategoryIndex: setFocusedCategoryIndex,
|
|
770
|
+
setFocusedItemIndex: setFocusedItemIndex
|
|
771
|
+
}, props));
|
|
772
|
+
}
|
|
427
773
|
const MemoizedElementListWithAnalytics = /*#__PURE__*/memo(withAnalyticsContext({
|
|
428
774
|
component: 'ElementList'
|
|
429
775
|
})(ElementList));
|
|
@@ -121,7 +121,8 @@ function StatelessElementBrowser(props) {
|
|
|
121
121
|
selectedCategory,
|
|
122
122
|
onSelectCategory,
|
|
123
123
|
searchTerm,
|
|
124
|
-
showCategories
|
|
124
|
+
showCategories,
|
|
125
|
+
cache
|
|
125
126
|
} = props;
|
|
126
127
|
const {
|
|
127
128
|
containerWidth,
|
|
@@ -230,7 +231,8 @@ function StatelessElementBrowser(props) {
|
|
|
230
231
|
onKeyPress: onItemsEnterTabKeyPress,
|
|
231
232
|
onKeyDown: onKeyDown,
|
|
232
233
|
viewMoreItem: viewMoreItem,
|
|
233
|
-
focusOnViewMore: focusOnViewMore
|
|
234
|
+
focusOnViewMore: focusOnViewMore,
|
|
235
|
+
cache: cache
|
|
234
236
|
})) : jsx(DesktopBrowser, _extends({}, props, {
|
|
235
237
|
selectedItemIndex: selectedItemIndex,
|
|
236
238
|
focusedItemIndex: focusedItemIndex,
|
|
@@ -244,7 +246,8 @@ function StatelessElementBrowser(props) {
|
|
|
244
246
|
focusedCategoryIndex: focusedCategoryIndex,
|
|
245
247
|
setFocusedCategoryIndex: setFocusedCategoryIndex,
|
|
246
248
|
selectedCategoryIndex: selectedCategoryIndex,
|
|
247
|
-
onSelectCategory: onSelectCategoryCB
|
|
249
|
+
onSelectCategory: onSelectCategoryCB,
|
|
250
|
+
cache: cache
|
|
248
251
|
})));
|
|
249
252
|
}
|
|
250
253
|
function MobileBrowser({
|
|
@@ -272,7 +275,8 @@ function MobileBrowser({
|
|
|
272
275
|
searchTerm,
|
|
273
276
|
createAnalyticsEvent,
|
|
274
277
|
emptyStateHandler,
|
|
275
|
-
viewMoreItem
|
|
278
|
+
viewMoreItem,
|
|
279
|
+
cache
|
|
276
280
|
}) {
|
|
277
281
|
return (
|
|
278
282
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
@@ -316,7 +320,8 @@ function MobileBrowser({
|
|
|
316
320
|
createAnalyticsEvent: createAnalyticsEvent,
|
|
317
321
|
emptyStateHandler: emptyStateHandler,
|
|
318
322
|
selectedCategory: selectedCategory,
|
|
319
|
-
searchTerm: searchTerm
|
|
323
|
+
searchTerm: searchTerm,
|
|
324
|
+
cache: cache
|
|
320
325
|
})), viewMoreItem && jsx(ViewMore, {
|
|
321
326
|
item: viewMoreItem,
|
|
322
327
|
focus: focusOnViewMore
|
|
@@ -347,7 +352,8 @@ function DesktopBrowser({
|
|
|
347
352
|
onKeyDown,
|
|
348
353
|
searchTerm,
|
|
349
354
|
createAnalyticsEvent,
|
|
350
|
-
emptyStateHandler
|
|
355
|
+
emptyStateHandler,
|
|
356
|
+
cache
|
|
351
357
|
}) {
|
|
352
358
|
return jsx("div", {
|
|
353
359
|
css: elementBrowserContainer,
|
|
@@ -406,7 +412,8 @@ function DesktopBrowser({
|
|
|
406
412
|
selectedCategory: selectedCategory,
|
|
407
413
|
selectedCategoryIndex: selectedCategoryIndex,
|
|
408
414
|
searchTerm: searchTerm,
|
|
409
|
-
setFocusedCategoryIndex: showCategories ? setFocusedCategoryIndex : undefined
|
|
415
|
+
setFocusedCategoryIndex: showCategories ? setFocusedCategoryIndex : undefined,
|
|
416
|
+
cache: cache
|
|
410
417
|
})));
|
|
411
418
|
}
|
|
412
419
|
const MemoizedElementBrowser = /*#__PURE__*/memo(withAnalyticsContext({
|
|
@@ -16,6 +16,6 @@ export const INLINE_SIDEBAR_HEIGHT = '54px';
|
|
|
16
16
|
export const SEARCH_ITEM_HEIGHT_WIDTH = '20px';
|
|
17
17
|
export const SCROLLBAR_WIDTH = 15;
|
|
18
18
|
export const ELEMENT_LIST_PADDING = 2;
|
|
19
|
-
export const ELEMENT_ITEM_HEIGHT =
|
|
19
|
+
export const ELEMENT_ITEM_HEIGHT = 60;
|
|
20
20
|
export const ELEMENT_ITEM_PADDING = 10;
|
|
21
21
|
export const ELEMENT_BROWSER_ID = 'editor-element-browser';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isFedRamp } from './environment';
|
|
2
2
|
const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
3
3
|
const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
4
|
-
const packageVersion = "94.
|
|
4
|
+
const packageVersion = "94.16.0";
|
|
5
5
|
const sanitiseSentryEvents = (data, _hint) => {
|
|
6
6
|
// Remove URL as it has UGC
|
|
7
7
|
// TODO: Sanitise the URL instead of just removing it
|
|
@@ -51,16 +51,21 @@ const options = {
|
|
|
51
51
|
* @returns {QuickInsertItem[]} - Returns a sorted array of QuickInsertItems based on the priority. If the query string is empty, it will return the array sorted by priority. If a query string is provided, it will return an array of QuickInsertItems that match the query string, sorted by relevance to the query.
|
|
52
52
|
*/
|
|
53
53
|
export function find(query, items, prioritySortingFn) {
|
|
54
|
+
if (query === '') {
|
|
55
|
+
// Copy and sort list by priority
|
|
56
|
+
return items.slice(0).sort((a, b) => (a.priority || Number.POSITIVE_INFINITY) - (b.priority || Number.POSITIVE_INFINITY));
|
|
57
|
+
}
|
|
54
58
|
const fuseOptions = {
|
|
55
59
|
...options
|
|
56
60
|
};
|
|
57
61
|
if (prioritySortingFn) {
|
|
58
|
-
|
|
62
|
+
const sortFn = prioritySortingFn(items);
|
|
63
|
+
// prioritySortingFn will trigger the experiment exposure, but sortFn
|
|
64
|
+
// will be undefined for the control group.
|
|
65
|
+
if (sortFn) {
|
|
66
|
+
fuseOptions.sortFn = sortFn;
|
|
67
|
+
}
|
|
59
68
|
}
|
|
60
69
|
const fuse = new Fuse(items, fuseOptions);
|
|
61
|
-
if (query === '') {
|
|
62
|
-
// Copy and sort list by priority
|
|
63
|
-
return items.slice(0).sort((a, b) => (a.priority || Number.POSITIVE_INFINITY) - (b.priority || Number.POSITIVE_INFINITY));
|
|
64
|
-
}
|
|
65
70
|
return fuse.search(query).map(result => result.item);
|
|
66
71
|
}
|
|
@@ -13,7 +13,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
|
|
|
13
13
|
import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
14
14
|
import Layer from '../Layer';
|
|
15
15
|
const packageName = "@atlaskit/editor-common";
|
|
16
|
-
const packageVersion = "94.
|
|
16
|
+
const packageVersion = "94.16.0";
|
|
17
17
|
const halfFocusRing = 1;
|
|
18
18
|
const dropOffset = '0, 8';
|
|
19
19
|
class DropList extends Component {
|
|
@@ -110,7 +110,8 @@ var ElementBrowser = /*#__PURE__*/function (_PureComponent) {
|
|
|
110
110
|
showCategories = _this$props.showCategories,
|
|
111
111
|
mode = _this$props.mode,
|
|
112
112
|
emptyStateHandler = _this$props.emptyStateHandler,
|
|
113
|
-
viewMoreItem = _this$props.viewMoreItem
|
|
113
|
+
viewMoreItem = _this$props.viewMoreItem,
|
|
114
|
+
cache = _this$props.cache;
|
|
114
115
|
var _this$state2 = this.state,
|
|
115
116
|
categories = _this$state2.categories,
|
|
116
117
|
searchTerm = _this$state2.searchTerm,
|
|
@@ -129,7 +130,8 @@ var ElementBrowser = /*#__PURE__*/function (_PureComponent) {
|
|
|
129
130
|
mode: mode,
|
|
130
131
|
searchTerm: searchTerm,
|
|
131
132
|
emptyStateHandler: emptyStateHandler,
|
|
132
|
-
viewMoreItem: viewMoreItem
|
|
133
|
+
viewMoreItem: viewMoreItem,
|
|
134
|
+
cache: cache
|
|
133
135
|
});
|
|
134
136
|
}
|
|
135
137
|
}]);
|