@atlaskit/editor-common 134.13.0 → 134.15.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/cjs/monitoring/error.js +1 -1
  3. package/dist/cjs/quick-insert/QuickInsertPreviewContent.compiled.css +1 -0
  4. package/dist/cjs/quick-insert/QuickInsertPreviewContent.js +8 -5
  5. package/dist/cjs/quick-insert/messages.js +30 -0
  6. package/dist/cjs/registered-menu/PreviewItemIndexContext.js +12 -0
  7. package/dist/cjs/registered-menu/RegisteredMenuList.js +8 -12
  8. package/dist/cjs/registered-menu/RegisteredMenuListItemRow.js +11 -11
  9. package/dist/cjs/registered-menu/useRegisteredMenu.js +59 -39
  10. package/dist/cjs/registered-menu/useRegisteredMenuSelection.js +4 -0
  11. package/dist/cjs/ui/DropList/index.js +1 -1
  12. package/dist/es2019/monitoring/error.js +1 -1
  13. package/dist/es2019/quick-insert/QuickInsertPreviewContent.compiled.css +1 -0
  14. package/dist/es2019/quick-insert/QuickInsertPreviewContent.js +8 -5
  15. package/dist/es2019/quick-insert/messages.js +30 -0
  16. package/dist/es2019/registered-menu/PreviewItemIndexContext.js +6 -0
  17. package/dist/es2019/registered-menu/RegisteredMenuList.js +7 -10
  18. package/dist/es2019/registered-menu/RegisteredMenuListItemRow.js +11 -11
  19. package/dist/es2019/registered-menu/useRegisteredMenu.js +51 -32
  20. package/dist/es2019/registered-menu/useRegisteredMenuSelection.js +2 -0
  21. package/dist/es2019/ui/DropList/index.js +1 -1
  22. package/dist/esm/monitoring/error.js +1 -1
  23. package/dist/esm/quick-insert/QuickInsertPreviewContent.compiled.css +1 -0
  24. package/dist/esm/quick-insert/QuickInsertPreviewContent.js +8 -5
  25. package/dist/esm/quick-insert/messages.js +30 -0
  26. package/dist/esm/registered-menu/PreviewItemIndexContext.js +6 -0
  27. package/dist/esm/registered-menu/RegisteredMenuList.js +8 -12
  28. package/dist/esm/registered-menu/RegisteredMenuListItemRow.js +11 -11
  29. package/dist/esm/registered-menu/useRegisteredMenu.js +60 -39
  30. package/dist/esm/registered-menu/useRegisteredMenuSelection.js +4 -0
  31. package/dist/esm/ui/DropList/index.js +1 -1
  32. package/dist/types/quick-insert/messages.d.ts +1 -1
  33. package/dist/types/quick-insert/preview.d.ts +6 -0
  34. package/dist/types/registered-menu/PreviewItemIndexContext.d.ts +2 -0
  35. package/dist/types/registered-menu/RegisteredMenuList.d.ts +8 -7
  36. package/dist/types/registered-menu/RegisteredMenuListItemRow.d.ts +5 -5
  37. package/dist/types/registered-menu/useRegisteredMenu.d.ts +7 -6
  38. package/dist/types/registered-menu/useRegisteredMenuSelection.d.ts +2 -0
  39. package/package.json +2 -2
  40. package/dist/cjs/registered-menu/ActiveMenuItemKeyContext.js +0 -11
  41. package/dist/es2019/registered-menu/ActiveMenuItemKeyContext.js +0 -5
  42. package/dist/esm/registered-menu/ActiveMenuItemKeyContext.js +0 -5
  43. package/dist/types/registered-menu/ActiveMenuItemKeyContext.d.ts +0 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 134.15.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`5dc6e8c217a9a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5dc6e8c217a9a) -
8
+ [EDITOR-10045] Under the `platform_editor_slash_command` experiment, `useRegisteredMenu` and
9
+ `RegisteredMenuList` show a preview only on the selected row, so hovering one copy of an item
10
+ listed in two sections previews only that copy. `useRegisteredMenu` returns `isPreviewOpen` and
11
+ `RegisteredMenuList` accepts an `isPreviewOpen` prop, replacing `activeItemKey`; the item
12
+ callbacks take the item index instead of its key.
13
+
14
+ ## 134.14.0
15
+
16
+ ### Minor Changes
17
+
18
+ - [`1754902b31de6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1754902b31de6) -
19
+ Element Browser (platform_editor_slash_command experiment): Quick Insert preview images accept an
20
+ optional `objectFit` (`contain` by default, or `cover` to crop the image to fill its area). Item
21
+ titles in Element Browser tiles and slash-menu previews use `color.text`. Adds Element Browser
22
+ messages for the dialog title, search, category and result labels.
23
+
24
+ ### Patch Changes
25
+
26
+ - Updated dependencies
27
+
3
28
  ## 134.13.0
4
29
 
5
30
  ### Minor Changes
@@ -27,7 +27,7 @@ var NETWORK_FAILURE_REGEX = /^network failure/i;
27
27
  var RESIZE_OBSERVER_LOOP_REGEX = /ResizeObserver loop completed with undelivered notifications/;
28
28
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
29
29
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
30
- var packageVersion = "134.12.0";
30
+ var packageVersion = "134.14.0";
31
31
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
32
32
  // Remove URL as it has UGC
33
33
  // Ignored via go/ees007
@@ -27,6 +27,7 @@
27
27
  ._4t3i1osq{height:100%}
28
28
  ._4t3i68cl{height:90pt}
29
29
  ._4t3i7vkz{height:1pc}
30
+ ._5ral1dfr{object-fit:cover}
30
31
  ._5ral1f51{object-fit:contain}
31
32
  ._6rthu2gc{margin-block-end:var(--ds-space-100,8px)}
32
33
  ._bfhkhfxm{background-color:var(--ds-surface-sunken,#f8f8f8)}
@@ -28,13 +28,14 @@ var layoutStyles = {
28
28
  var styles = {
29
29
  root: "_1e0c1txw _2lx21bp4 _16jlkb7n _1ul9idpf",
30
30
  content: "_zulpu2gc _1e0c1txw _2lx21bp4 _16jlkb7n",
31
- title: "_11c81qyo _16jlidpf _1o9zkb7n _i0dl1wug _syazazsu _1ul9idpf _1i4qfg65",
31
+ title: "_11c81qyo _16jlidpf _1o9zkb7n _i0dl1wug _syazi7uo _1ul9idpf _1i4qfg65",
32
32
  clampedTitle: "_1reo15vq _18m915vq _1e0ccj1k _sudp1e54 _1yyjcs5v",
33
33
  description: "_11c8fhey _1reo15vq _18m915vq _syazi7uo _1e0ccj1k _1i4qfg65 _sudp1e54 _1yyjegat",
34
34
  unclampedDescription: "_11c8fhey _syazi7uo _1i4qfg65",
35
35
  disabledText: "_syaz1gmx",
36
36
  imageArea: "_2rko12b0 _1reo15vq _18m915vq _bfhkhfxm _4t3i68cl _6rthu2gc _1bsb1osq",
37
37
  image: "_1e0c1ule _4t3i1osq _5ral1f51 _1bsb1osq",
38
+ imageCover: "_5ral1dfr",
38
39
  imageHidden: "_3um015vq",
39
40
  attribution: "_zulp1b66 _4cvr1h6o _syazazsu _1e0c1txw _1pfh1wug _1i4qfg65",
40
41
  compactAttribution: "_11c8wadc",
@@ -46,7 +47,7 @@ var styles = {
46
47
  * Element Browser tiles. It fills its container; callers own its width and accessible name.
47
48
  */
48
49
  var QuickInsertPreviewContent = exports.QuickInsertPreviewContent = function QuickInsertPreviewContent(_ref) {
49
- var _preview$attribution, _preview$attribution2;
50
+ var _preview$attribution, _preview$attribution2, _preview$image;
50
51
  var description = _ref.description,
51
52
  icon = _ref.icon,
52
53
  id = _ref.id,
@@ -83,7 +84,8 @@ var QuickInsertPreviewContent = exports.QuickInsertPreviewContent = function Qui
83
84
  className: (0, _runtime.ax)([styles.root])
84
85
  }, imageUrl && /*#__PURE__*/_react.default.createElement(PreviewImage, {
85
86
  key: imageUrl,
86
- imageUrl: imageUrl
87
+ imageUrl: imageUrl,
88
+ objectFit: (_preview$image = preview.image) === null || _preview$image === void 0 ? void 0 : _preview$image.objectFit
87
89
  }), /*#__PURE__*/_react.default.createElement("div", {
88
90
  className: (0, _runtime.ax)([styles.content])
89
91
  }, shortcut ? /*#__PURE__*/_react.default.createElement(_inline.Inline, {
@@ -110,7 +112,8 @@ var QuickInsertPreviewContent = exports.QuickInsertPreviewContent = function Qui
110
112
  }))))));
111
113
  };
112
114
  var PreviewImage = function PreviewImage(_ref2) {
113
- var imageUrl = _ref2.imageUrl;
115
+ var imageUrl = _ref2.imageUrl,
116
+ objectFit = _ref2.objectFit;
114
117
  var _useState = (0, _react.useState)(false),
115
118
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
116
119
  hasFailed = _useState2[0],
@@ -137,6 +140,6 @@ var PreviewImage = function PreviewImage(_ref2) {
137
140
  onError: function onError() {
138
141
  return setHasFailed(true);
139
142
  },
140
- className: (0, _runtime.ax)([styles.image, !hasLoaded && styles.imageHidden])
143
+ className: (0, _runtime.ax)([styles.image, objectFit === 'cover' && styles.imageCover, !hasLoaded && styles.imageHidden])
141
144
  }));
142
145
  };
@@ -210,5 +210,35 @@ var messages = exports.messages = (0, _reactIntl.defineMessages)({
210
210
  id: 'editor-common.quick-insert.previewAttributionMicrosoft.ai-non-final',
211
211
  defaultMessage: 'Microsoft',
212
212
  description: 'Microsoft company name shown as the creator in a slash-command preview attribution.'
213
+ },
214
+ elementBrowserAllElements: {
215
+ id: 'editor.quick-insert.all-elements',
216
+ defaultMessage: 'All elements',
217
+ description: 'Heading above the remaining elements in the element browser All category, shown below the Recommended elements.'
218
+ },
219
+ elementBrowserCategoriesLabel: {
220
+ id: 'editor.quick-insert.categories-label',
221
+ defaultMessage: 'Element categories',
222
+ description: 'Accessible label for the group of category buttons in the element browser sidebar, read by screen readers.'
223
+ },
224
+ elementBrowserResultsAvailable: {
225
+ id: 'editor.quick-insert.results-available',
226
+ defaultMessage: '{count, plural, one {# result available} other {# results available}}',
227
+ description: 'Shown in the element browser footer. Tells the user how many elements match the current search and category.'
228
+ },
229
+ elementBrowserResultsLabel: {
230
+ id: 'editor.quick-insert.results-label',
231
+ defaultMessage: 'Element results',
232
+ description: 'Accessible label for the list of elements in the element browser, read by screen readers.'
233
+ },
234
+ elementBrowserSearch: {
235
+ id: 'editor.quick-insert.search',
236
+ defaultMessage: 'Search elements',
237
+ description: 'Accessible label for the search field at the top of the element browser, used to filter the elements that can be inserted.'
238
+ },
239
+ elementBrowserTitle: {
240
+ id: 'editor.quick-insert.title',
241
+ defaultMessage: 'Insert elements',
242
+ description: 'Title of the element browser dialog, where users browse and insert elements such as tables, panels and macros.'
213
243
  }
214
244
  });
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PreviewItemIndexContext = void 0;
7
+ var _react = require("react");
8
+ // The list caches rendered rows while scrolling, so those rows may not receive
9
+ // updated props. We pass the index of the item showing its preview through context
10
+ // so their styling updates without rebuilding the wrappers that measure row height.
11
+ // Each row compares it with its own index, which a cached row still has right.
12
+ var PreviewItemIndexContext = exports.PreviewItemIndexContext = /*#__PURE__*/(0, _react.createContext)(undefined);
@@ -11,8 +11,8 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
11
11
  var _react = _interopRequireWildcard(require("react"));
12
12
  var _CellMeasurer = require("react-virtualized/dist/commonjs/CellMeasurer");
13
13
  var _List = require("react-virtualized/dist/commonjs/List");
14
- var _ActiveMenuItemKeyContext = require("./ActiveMenuItemKeyContext");
15
14
  var _MeasuredRow = require("./MeasuredRow");
15
+ var _PreviewItemIndexContext = require("./PreviewItemIndexContext");
16
16
  var _RegisteredMenuListItemRow = require("./RegisteredMenuListItemRow");
17
17
  var _useMenuListHeight2 = require("./useMenuListHeight");
18
18
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
@@ -24,7 +24,8 @@ var RegisteredMenuList = exports.RegisteredMenuList = function RegisteredMenuLis
24
24
  var rows = _ref.rows,
25
25
  Item = _ref.Item,
26
26
  selectedItemIndex = _ref.selectedItemIndex,
27
- activeItemKey = _ref.activeItemKey,
27
+ _ref$isPreviewOpen = _ref.isPreviewOpen,
28
+ isPreviewOpen = _ref$isPreviewOpen === void 0 ? false : _ref$isPreviewOpen,
28
29
  maxHeight = _ref.maxHeight,
29
30
  width = _ref.width,
30
31
  getItemId = _ref.getItemId,
@@ -126,13 +127,8 @@ var RegisteredMenuList = exports.RegisteredMenuList = function RegisteredMenuLis
126
127
  overscanStopIndex = _ref3.overscanStopIndex,
127
128
  startIndex = _ref3.startIndex,
128
129
  stopIndex = _ref3.stopIndex;
129
- if (activeItemKey) {
130
- var activeRowIndex = rows.findIndex(function (row) {
131
- return row.type === 'menu-item' && row.key === activeItemKey;
132
- });
133
- if (activeRowIndex >= 0 && (activeRowIndex < startIndex || activeRowIndex > stopIndex)) {
134
- onItemVisibilityChange(activeItemKey, false);
135
- }
130
+ if (isPreviewOpen && selectedRowIndex >= 0 && (selectedRowIndex < startIndex || selectedRowIndex > stopIndex)) {
131
+ onItemVisibilityChange(selectedItemIndex, false);
136
132
  }
137
133
  updateHeight();
138
134
  var indexes = (0, _toConsumableArray2.default)(itemIndexByRowIndex).filter(function (_ref4) {
@@ -148,7 +144,7 @@ var RegisteredMenuList = exports.RegisteredMenuList = function RegisteredMenuLis
148
144
  startIndex: (_indexes$ = indexes[0]) !== null && _indexes$ !== void 0 ? _indexes$ : -1,
149
145
  stopIndex: (_indexes = indexes[indexes.length - 1]) !== null && _indexes !== void 0 ? _indexes : -1
150
146
  });
151
- }, [activeItemKey, itemIndexByRowIndex, onItemVisibilityChange, onRenderedItemsChange, rows, updateHeight]);
147
+ }, [isPreviewOpen, itemIndexByRowIndex, onItemVisibilityChange, onRenderedItemsChange, selectedItemIndex, selectedRowIndex, updateHeight]);
152
148
  var renderRow = (0, _react.useCallback)(function (_ref8) {
153
149
  var index = _ref8.index,
154
150
  key = _ref8.key,
@@ -208,8 +204,8 @@ var RegisteredMenuList = exports.RegisteredMenuList = function RegisteredMenuLis
208
204
  if (rows.length === 0) {
209
205
  return null;
210
206
  }
211
- return /*#__PURE__*/_react.default.createElement(_ActiveMenuItemKeyContext.ActiveMenuItemKeyContext.Provider, {
212
- value: activeItemKey
207
+ return /*#__PURE__*/_react.default.createElement(_PreviewItemIndexContext.PreviewItemIndexContext.Provider, {
208
+ value: isPreviewOpen ? selectedItemIndex : undefined
213
209
  }, /*#__PURE__*/_react.default.createElement(_List.List, {
214
210
  "aria-readonly": ariaReadonly,
215
211
  containerRole: containerRole,
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.RegisteredMenuListItemRow = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
- var _ActiveMenuItemKeyContext = require("./ActiveMenuItemKeyContext");
9
+ var _PreviewItemIndexContext = require("./PreviewItemIndexContext");
10
10
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
11
11
  /**
12
12
  * Connects a rendered item to the list's active state and interaction callbacks.
@@ -27,35 +27,35 @@ var RegisteredMenuListItemRow = exports.RegisteredMenuListItemRow = function Reg
27
27
  registration = _ref.registration,
28
28
  rowIndex = _ref.rowIndex,
29
29
  selectedItemIndex = _ref.selectedItemIndex;
30
- var activeItemKey = (0, _react.useContext)(_ActiveMenuItemKeyContext.ActiveMenuItemKeyContext);
30
+ var previewItemIndex = (0, _react.useContext)(_PreviewItemIndexContext.PreviewItemIndexContext);
31
31
  (0, _react.useLayoutEffect)(function () {
32
- onItemVisibilityChange(registration.key, isVisible);
32
+ onItemVisibilityChange(itemIndex, isVisible);
33
33
  return function () {
34
- return onItemVisibilityChange(registration.key, false);
34
+ return onItemVisibilityChange(itemIndex, false);
35
35
  };
36
- }, [isVisible, onItemVisibilityChange, registration.key]);
36
+ }, [isVisible, itemIndex, onItemVisibilityChange]);
37
37
  var onBlur = (0, _react.useCallback)(function (event) {
38
38
  if (!event.currentTarget.contains(event.relatedTarget)) {
39
- onItemBlur(registration.key);
39
+ onItemBlur(itemIndex);
40
40
  }
41
- }, [onItemBlur, registration.key]);
41
+ }, [itemIndex, onItemBlur]);
42
42
  return /*#__PURE__*/_react.default.createElement("div", {
43
43
  onBlur: onBlur,
44
44
  onFocus: function onFocus() {
45
- return onItemFocus(itemIndex, registration.key);
45
+ return onItemFocus(itemIndex);
46
46
  },
47
47
  onMouseLeave: function onMouseLeave() {
48
- return onItemLeave(registration.key);
48
+ return onItemLeave(itemIndex);
49
49
  },
50
50
  onMouseMove: function onMouseMove() {
51
- return onItemHover(itemIndex, registration.key);
51
+ return onItemHover(itemIndex);
52
52
  }
53
53
  }, /*#__PURE__*/_react.default.createElement(Item, {
54
54
  id: getItemId({
55
55
  itemIndex: itemIndex,
56
56
  rowIndex: rowIndex
57
57
  }),
58
- isActive: activeItemKey === registration.key,
58
+ isActive: previewItemIndex === itemIndex,
59
59
  isSelected: itemIndex === selectedItemIndex,
60
60
  registration: registration
61
61
  }));
@@ -11,6 +11,8 @@ var _react = require("react");
11
11
  var _surfaceRenderer = require("@atlaskit/editor-ui-control-model/surface-renderer");
12
12
  var _useRegisteredMenuSelection = require("./useRegisteredMenuSelection");
13
13
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
14
+ /** An open preview always belongs to the selected item, so only whether it's open is stored. */
15
+
14
16
  var getSelectableItemIdentity = function getSelectableItemIdentity(item, scope) {
15
17
  return JSON.stringify([scope.type, scope.type === 'section' ? scope.sectionKey : undefined, (0, _surfaceRenderer.getComponentIdentity)(item)]);
16
18
  };
@@ -69,78 +71,96 @@ var useRegisteredMenu = exports.useRegisteredMenu = function useRegisteredMenu(_
69
71
  identities: selectableItemIdentities,
70
72
  resetKey: resetKey
71
73
  });
72
- var selectedItemIndex = selection.selectedIndex,
74
+ var getSelectedIndex = selection.getSelectedIndex,
75
+ selectedItemIndex = selection.selectedIndex,
73
76
  selectionSource = selection.selectionSource,
74
77
  select = selection.select;
75
78
  var _useState = (0, _react.useState)(),
76
79
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
77
80
  activation = _useState2[0],
78
- setItemActivation = _useState2[1];
79
- var activeItemKey = (activation === null || activation === void 0 ? void 0 : activation.model) === model && activation.resetKey === resetKey ? activation.itemKey : undefined;
81
+ setActivation = _useState2[1];
82
+ var isPreviewOpen = (activation === null || activation === void 0 ? void 0 : activation.model) === model && activation.resetKey === resetKey;
80
83
  (0, _react.useLayoutEffect)(function () {
81
- setItemActivation(undefined);
84
+ setActivation(undefined);
82
85
  }, [model, resetKey]);
86
+
87
+ /**
88
+ * Closes the preview when the event comes from the selected item, optionally only for one source.
89
+ * Rows report leaving, blur and visibility from effects, including cleanups. Reading the latest
90
+ * selection keeps this callback stable, so a selection change doesn't re-run those effects and
91
+ * a row's cleanup can't close the preview that just moved to another row.
92
+ */
93
+ var closePreviewFor = (0, _react.useCallback)(function (index, source) {
94
+ if (index !== getSelectedIndex()) {
95
+ return;
96
+ }
97
+ setActivation(function (current) {
98
+ return current && (source === undefined || current.source === source) ? undefined : current;
99
+ });
100
+ }, [getSelectedIndex]);
101
+
102
+ // Only listed items show a preview; the footer comes after them.
103
+ var hasPreview = (0, _react.useCallback)(function (index) {
104
+ return index < selectableItems.length;
105
+ }, [selectableItems]);
83
106
  var activateKeyboardItem = (0, _react.useCallback)(function (index) {
84
- var item = selectableItems[index];
85
- setItemActivation(item ? {
86
- itemKey: item.key,
107
+ setActivation(hasPreview(index) ? {
87
108
  model: model,
88
109
  resetKey: resetKey,
89
110
  source: 'keyboard'
90
111
  } : undefined);
91
- }, [model, resetKey, selectableItems]);
112
+ }, [hasPreview, model, resetKey]);
92
113
  var selectNext = (0, _react.useCallback)(function () {
93
114
  activateKeyboardItem(selection.selectNext());
94
115
  }, [selection.selectNext, activateKeyboardItem]);
95
116
  var selectPrevious = (0, _react.useCallback)(function () {
96
117
  activateKeyboardItem(selection.selectPrevious());
97
118
  }, [selection.selectPrevious, activateKeyboardItem]);
98
- var onItemHover = (0, _react.useCallback)(function (index, itemKey) {
119
+ var onItemHover = (0, _react.useCallback)(function (index) {
99
120
  select(index, 'pointer');
100
- setItemActivation(function (current) {
101
- if (itemKey && (current === null || current === void 0 ? void 0 : current.itemKey) === itemKey && current.model === model && current.resetKey === resetKey && current.source === 'pointer') {
121
+ setActivation(function (current) {
122
+ if (!hasPreview(index)) {
123
+ return undefined;
124
+ }
125
+ if ((current === null || current === void 0 ? void 0 : current.model) === model && current.resetKey === resetKey && current.source === 'pointer') {
102
126
  return current;
103
127
  }
104
- return itemKey ? {
105
- itemKey: itemKey,
128
+ return {
106
129
  model: model,
107
130
  resetKey: resetKey,
108
131
  source: 'pointer'
109
- } : undefined;
132
+ };
110
133
  });
111
- }, [model, resetKey, select]);
112
- var onItemFocus = (0, _react.useCallback)(function (index, itemKey) {
134
+ }, [hasPreview, model, resetKey, select]);
135
+ var onItemFocus = (0, _react.useCallback)(function (index) {
136
+ var isSelectedItem = index === selectedItemIndex;
113
137
  // A press focuses the item the pointer already selected. Scrolling it then would move it before the click lands.
114
- select(index, index === selectedItemIndex && selectionSource === 'pointer' ? 'pointer' : 'keyboard');
115
- setItemActivation(function (current) {
116
- if (itemKey && (current === null || current === void 0 ? void 0 : current.itemKey) === itemKey && current.model === model && current.resetKey === resetKey) {
138
+ select(index, isSelectedItem && selectionSource === 'pointer' ? 'pointer' : 'keyboard');
139
+ setActivation(function (current) {
140
+ if (!hasPreview(index)) {
141
+ return undefined;
142
+ }
143
+ if (isSelectedItem && (current === null || current === void 0 ? void 0 : current.model) === model && current.resetKey === resetKey) {
117
144
  return current;
118
145
  }
119
- return itemKey ? {
120
- itemKey: itemKey,
146
+ return {
121
147
  model: model,
122
148
  resetKey: resetKey,
123
149
  source: 'keyboard'
124
- } : undefined;
125
- });
126
- }, [model, resetKey, select, selectedItemIndex, selectionSource]);
127
- var onItemLeave = (0, _react.useCallback)(function (itemKey) {
128
- setItemActivation(function (current) {
129
- return (current === null || current === void 0 ? void 0 : current.source) === 'pointer' && current.itemKey === itemKey ? undefined : current;
130
- });
131
- }, []);
132
- var onItemBlur = (0, _react.useCallback)(function (itemKey) {
133
- setItemActivation(function (current) {
134
- return (current === null || current === void 0 ? void 0 : current.itemKey) === itemKey ? undefined : current;
150
+ };
135
151
  });
136
- }, []);
137
- var onItemVisibilityChange = (0, _react.useCallback)(function (itemKey, isVisible) {
152
+ }, [hasPreview, model, resetKey, select, selectedItemIndex, selectionSource]);
153
+ var onItemLeave = (0, _react.useCallback)(function (index) {
154
+ return closePreviewFor(index, 'pointer');
155
+ }, [closePreviewFor]);
156
+ var onItemBlur = (0, _react.useCallback)(function (index) {
157
+ return closePreviewFor(index);
158
+ }, [closePreviewFor]);
159
+ var onItemVisibilityChange = (0, _react.useCallback)(function (index, isVisible) {
138
160
  if (!isVisible) {
139
- setItemActivation(function (current) {
140
- return (current === null || current === void 0 ? void 0 : current.source) === 'pointer' && current.itemKey === itemKey ? undefined : current;
141
- });
161
+ closePreviewFor(index, 'pointer');
142
162
  }
143
- }, []);
163
+ }, [closePreviewFor]);
144
164
  return {
145
165
  rows: rows,
146
166
  selectableItems: selectableItems,
@@ -149,7 +169,7 @@ var useRegisteredMenu = exports.useRegisteredMenu = function useRegisteredMenu(_
149
169
  select: select,
150
170
  selectNext: selectNext,
151
171
  selectPrevious: selectPrevious,
152
- activeItemKey: activeItemKey,
172
+ isPreviewOpen: isPreviewOpen,
153
173
  onItemHover: onItemHover,
154
174
  onItemFocus: onItemFocus,
155
175
  onItemLeave: onItemLeave,
@@ -73,7 +73,11 @@ var useRegisteredMenuSelection = exports.useRegisteredMenuSelection = function u
73
73
  select(previousIndex, 'keyboard');
74
74
  return previousIndex;
75
75
  }, [itemCount, select]);
76
+ var getSelectedIndex = (0, _react.useCallback)(function () {
77
+ return selectedIndexRef.current;
78
+ }, []);
76
79
  return {
80
+ getSelectedIndex: getSelectedIndex,
77
81
  selectedIndex: selectedIndex,
78
82
  selectionSource: selectionSource,
79
83
  select: select,
@@ -23,7 +23,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
23
23
  * @jsx jsx
24
24
  */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
25
25
  var packageName = "@atlaskit/editor-common";
26
- var packageVersion = "134.12.0";
26
+ var packageVersion = "134.14.0";
27
27
  var halfFocusRing = 1;
28
28
  var dropOffset = '0, 8';
29
29
  // Ignored via go/ees005
@@ -13,7 +13,7 @@ const NETWORK_FAILURE_REGEX = /^network failure/i;
13
13
  const RESIZE_OBSERVER_LOOP_REGEX = /ResizeObserver loop completed with undelivered notifications/;
14
14
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
15
15
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
16
- const packageVersion = "134.12.0";
16
+ const packageVersion = "134.14.0";
17
17
  const sanitiseSentryEvents = (data, _hint) => {
18
18
  // Remove URL as it has UGC
19
19
  // Ignored via go/ees007
@@ -27,6 +27,7 @@
27
27
  ._4t3i1osq{height:100%}
28
28
  ._4t3i68cl{height:90pt}
29
29
  ._4t3i7vkz{height:1pc}
30
+ ._5ral1dfr{object-fit:cover}
30
31
  ._5ral1f51{object-fit:contain}
31
32
  ._6rthu2gc{margin-block-end:var(--ds-space-100,8px)}
32
33
  ._bfhkhfxm{background-color:var(--ds-surface-sunken,#f8f8f8)}
@@ -20,13 +20,14 @@ const layoutStyles = {
20
20
  const styles = {
21
21
  root: "_1e0c1txw _2lx21bp4 _16jlkb7n _1ul9idpf",
22
22
  content: "_zulpu2gc _1e0c1txw _2lx21bp4 _16jlkb7n",
23
- title: "_11c81qyo _16jlidpf _1o9zkb7n _i0dl1wug _syazazsu _1ul9idpf _1i4qfg65",
23
+ title: "_11c81qyo _16jlidpf _1o9zkb7n _i0dl1wug _syazi7uo _1ul9idpf _1i4qfg65",
24
24
  clampedTitle: "_1reo15vq _18m915vq _1e0ccj1k _sudp1e54 _1yyjcs5v",
25
25
  description: "_11c8fhey _1reo15vq _18m915vq _syazi7uo _1e0ccj1k _1i4qfg65 _sudp1e54 _1yyjegat",
26
26
  unclampedDescription: "_11c8fhey _syazi7uo _1i4qfg65",
27
27
  disabledText: "_syaz1gmx",
28
28
  imageArea: "_2rko12b0 _1reo15vq _18m915vq _bfhkhfxm _4t3i68cl _6rthu2gc _1bsb1osq",
29
29
  image: "_1e0c1ule _4t3i1osq _5ral1f51 _1bsb1osq",
30
+ imageCover: "_5ral1dfr",
30
31
  imageHidden: "_3um015vq",
31
32
  attribution: "_zulp1b66 _4cvr1h6o _syazazsu _1e0c1txw _1pfh1wug _1i4qfg65",
32
33
  compactAttribution: "_11c8wadc",
@@ -48,7 +49,7 @@ export const QuickInsertPreviewContent = ({
48
49
  shouldClampText = true,
49
50
  title
50
51
  }) => {
51
- var _preview$attribution, _preview$attribution2;
52
+ var _preview$attribution, _preview$attribution2, _preview$image;
52
53
  const {
53
54
  formatMessage
54
55
  } = useIntl();
@@ -76,7 +77,8 @@ export const QuickInsertPreviewContent = ({
76
77
  className: ax([styles.root])
77
78
  }, imageUrl && /*#__PURE__*/React.createElement(PreviewImage, {
78
79
  key: imageUrl,
79
- imageUrl: imageUrl
80
+ imageUrl: imageUrl,
81
+ objectFit: (_preview$image = preview.image) === null || _preview$image === void 0 ? void 0 : _preview$image.objectFit
80
82
  }), /*#__PURE__*/React.createElement("div", {
81
83
  className: ax([styles.content])
82
84
  }, shortcut ? /*#__PURE__*/React.createElement(Inline, {
@@ -103,7 +105,8 @@ export const QuickInsertPreviewContent = ({
103
105
  }))))));
104
106
  };
105
107
  const PreviewImage = ({
106
- imageUrl
108
+ imageUrl,
109
+ objectFit
107
110
  }) => {
108
111
  const [hasFailed, setHasFailed] = useState(false);
109
112
  const [hasLoaded, setHasLoaded] = useState(false);
@@ -121,6 +124,6 @@ const PreviewImage = ({
121
124
  alt: "",
122
125
  onLoad: () => setHasLoaded(true),
123
126
  onError: () => setHasFailed(true),
124
- className: ax([styles.image, !hasLoaded && styles.imageHidden])
127
+ className: ax([styles.image, objectFit === 'cover' && styles.imageCover, !hasLoaded && styles.imageHidden])
125
128
  }));
126
129
  };
@@ -204,5 +204,35 @@ export const messages = defineMessages({
204
204
  id: 'editor-common.quick-insert.previewAttributionMicrosoft.ai-non-final',
205
205
  defaultMessage: 'Microsoft',
206
206
  description: 'Microsoft company name shown as the creator in a slash-command preview attribution.'
207
+ },
208
+ elementBrowserAllElements: {
209
+ id: 'editor.quick-insert.all-elements',
210
+ defaultMessage: 'All elements',
211
+ description: 'Heading above the remaining elements in the element browser All category, shown below the Recommended elements.'
212
+ },
213
+ elementBrowserCategoriesLabel: {
214
+ id: 'editor.quick-insert.categories-label',
215
+ defaultMessage: 'Element categories',
216
+ description: 'Accessible label for the group of category buttons in the element browser sidebar, read by screen readers.'
217
+ },
218
+ elementBrowserResultsAvailable: {
219
+ id: 'editor.quick-insert.results-available',
220
+ defaultMessage: '{count, plural, one {# result available} other {# results available}}',
221
+ description: 'Shown in the element browser footer. Tells the user how many elements match the current search and category.'
222
+ },
223
+ elementBrowserResultsLabel: {
224
+ id: 'editor.quick-insert.results-label',
225
+ defaultMessage: 'Element results',
226
+ description: 'Accessible label for the list of elements in the element browser, read by screen readers.'
227
+ },
228
+ elementBrowserSearch: {
229
+ id: 'editor.quick-insert.search',
230
+ defaultMessage: 'Search elements',
231
+ description: 'Accessible label for the search field at the top of the element browser, used to filter the elements that can be inserted.'
232
+ },
233
+ elementBrowserTitle: {
234
+ id: 'editor.quick-insert.title',
235
+ defaultMessage: 'Insert elements',
236
+ description: 'Title of the element browser dialog, where users browse and insert elements such as tables, panels and macros.'
207
237
  }
208
238
  });
@@ -0,0 +1,6 @@
1
+ import { createContext } from 'react';
2
+ // The list caches rendered rows while scrolling, so those rows may not receive
3
+ // updated props. We pass the index of the item showing its preview through context
4
+ // so their styling updates without rebuilding the wrappers that measure row height.
5
+ // Each row compares it with its own index, which a cached row still has right.
6
+ export const PreviewItemIndexContext = /*#__PURE__*/createContext(undefined);
@@ -1,8 +1,8 @@
1
1
  import React, { useCallback, useLayoutEffect, useMemo, useRef } from 'react';
2
2
  import { CellMeasurer, CellMeasurerCache } from 'react-virtualized/dist/commonjs/CellMeasurer';
3
3
  import { List } from 'react-virtualized/dist/commonjs/List';
4
- import { ActiveMenuItemKeyContext } from './ActiveMenuItemKeyContext';
5
4
  import { MeasuredRow } from './MeasuredRow';
5
+ import { PreviewItemIndexContext } from './PreviewItemIndexContext';
6
6
  import { RegisteredMenuListItemRow } from './RegisteredMenuListItemRow';
7
7
  import { useMenuListHeight } from './useMenuListHeight';
8
8
  const ESTIMATED_ROW_HEIGHT = 44;
@@ -10,7 +10,7 @@ export const RegisteredMenuList = ({
10
10
  rows,
11
11
  Item,
12
12
  selectedItemIndex,
13
- activeItemKey,
13
+ isPreviewOpen = false,
14
14
  maxHeight,
15
15
  width,
16
16
  getItemId,
@@ -92,11 +92,8 @@ export const RegisteredMenuList = ({
92
92
  stopIndex
93
93
  }) => {
94
94
  var _indexes$, _indexes;
95
- if (activeItemKey) {
96
- const activeRowIndex = rows.findIndex(row => row.type === 'menu-item' && row.key === activeItemKey);
97
- if (activeRowIndex >= 0 && (activeRowIndex < startIndex || activeRowIndex > stopIndex)) {
98
- onItemVisibilityChange(activeItemKey, false);
99
- }
95
+ if (isPreviewOpen && selectedRowIndex >= 0 && (selectedRowIndex < startIndex || selectedRowIndex > stopIndex)) {
96
+ onItemVisibilityChange(selectedItemIndex, false);
100
97
  }
101
98
  updateHeight();
102
99
  const indexes = [...itemIndexByRowIndex].filter(([rowIndex]) => rowIndex >= overscanStartIndex && rowIndex <= overscanStopIndex).map(([, itemIndex]) => itemIndex);
@@ -104,7 +101,7 @@ export const RegisteredMenuList = ({
104
101
  startIndex: (_indexes$ = indexes[0]) !== null && _indexes$ !== void 0 ? _indexes$ : -1,
105
102
  stopIndex: (_indexes = indexes[indexes.length - 1]) !== null && _indexes !== void 0 ? _indexes : -1
106
103
  });
107
- }, [activeItemKey, itemIndexByRowIndex, onItemVisibilityChange, onRenderedItemsChange, rows, updateHeight]);
104
+ }, [isPreviewOpen, itemIndexByRowIndex, onItemVisibilityChange, onRenderedItemsChange, selectedItemIndex, selectedRowIndex, updateHeight]);
108
105
  const renderRow = useCallback(({
109
106
  index,
110
107
  key,
@@ -160,8 +157,8 @@ export const RegisteredMenuList = ({
160
157
  if (rows.length === 0) {
161
158
  return null;
162
159
  }
163
- return /*#__PURE__*/React.createElement(ActiveMenuItemKeyContext.Provider, {
164
- value: activeItemKey
160
+ return /*#__PURE__*/React.createElement(PreviewItemIndexContext.Provider, {
161
+ value: isPreviewOpen ? selectedItemIndex : undefined
165
162
  }, /*#__PURE__*/React.createElement(List, {
166
163
  "aria-readonly": ariaReadonly,
167
164
  containerRole: containerRole,