@atlaskit/editor-plugin-type-ahead 25.0.6 → 26.0.1

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 CHANGED
@@ -1,5 +1,29 @@
1
1
  # @atlaskit/editor-plugin-type-ahead
2
2
 
3
+ ## 26.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`5351e01090c9c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5351e01090c9c) -
8
+ Show the five strongest matches first, then remaining matches in category order without category
9
+ titles, in slash-command and toolbar insert search. Share the row projection across rendering and
10
+ keyboard selection under the platform_editor_slash_command experiment.
11
+ - Updated dependencies
12
+
13
+ ## 26.0.0
14
+
15
+ ### Patch Changes
16
+
17
+ - [`1cb97ba88fb58`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1cb97ba88fb58) -
18
+ Clean up experiment `platform_editor_insert_menu_ai` (keep control).
19
+
20
+ Breaking changes (`@atlaskit/editor-common`): removed `getEmptyItem` from `TypeAheadHandler`, and
21
+ removed the unused messages `typeAheadListMessages.emptySearchResultsSuggestionNew`,
22
+ `typeAheadListMessages.emptySearchResultsSuggestionAskRovoOnly` and
23
+ `toolbarInsertBlockMessages.askRovo`.
24
+
25
+ - Updated dependencies
26
+
3
27
  ## 25.0.6
4
28
 
5
29
  ### Patch Changes
@@ -18,7 +18,6 @@ var _messages = require("@atlaskit/editor-common/messages");
18
18
  var _typeAhead = require("@atlaskit/editor-common/type-ahead");
19
19
  var _ui = require("@atlaskit/editor-common/ui");
20
20
  var _menuGroup = _interopRequireDefault(require("@atlaskit/menu/menu-group"));
21
- var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
22
21
  var _fg = require("@atlaskit/platform-feature-flags/fg");
23
22
  var _compiled = require("@atlaskit/primitives/compiled");
24
23
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
@@ -127,7 +126,6 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref4) {
127
126
  var _itemRowIndexByItemIn, _triggerHandler$getMo, _decorationElement$qu2;
128
127
  var items = _ref4.items,
129
128
  sections = _ref4.sections,
130
- emptyItem = _ref4.emptyItem,
131
129
  selectedIndex = _ref4.selectedIndex,
132
130
  _ref4$isEmptyQuery = _ref4.isEmptyQuery,
133
131
  isEmptyQuery = _ref4$isEmptyQuery === void 0 ? true : _ref4$isEmptyQuery,
@@ -154,7 +152,6 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref4) {
154
152
 
155
153
  // Exclude view more item from the count
156
154
  var itemsLength = showMoreOptionsButton ? Math.max(items.length - 1, 0) : items.length;
157
- var isEmptyStateActive = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_insert_menu_ai') && !!emptyItem && itemsLength === 1 && items[0] === emptyItem;
158
155
  var estimatedHeight = itemsLength * LIST_ITEM_ESTIMATED_HEIGHT;
159
156
  var _useState = (0, _react.useState)(Math.min(estimatedHeight, fitHeight)),
160
157
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
@@ -494,10 +491,7 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref4) {
494
491
  }, intl.formatMessage(_typeAhead.typeAheadListMessages.emptySearchResults)), (0, _react2.jsx)(_compiled.Text, {
495
492
  align: "center",
496
493
  as: "p"
497
- }, intl.formatMessage((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_insert_menu_ai') ? showMoreOptionsButton ? _typeAhead.typeAheadListMessages.emptySearchResultsSuggestionNew : _typeAhead.typeAheadListMessages.emptySearchResultsSuggestionAskRovoOnly : _typeAhead.typeAheadListMessages.emptySearchResultsSuggestion, {
498
- askRovoName: (0, _react2.jsx)(_compiled.Text, {
499
- weight: "medium"
500
- }, intl.formatMessage(_messages.toolbarInsertBlockMessages.askRovo)),
494
+ }, intl.formatMessage(_typeAhead.typeAheadListMessages.emptySearchResultsSuggestion, {
501
495
  buttonName: (0, _react2.jsx)(_compiled.Text, {
502
496
  weight: "medium"
503
497
  }, intl.formatMessage(_messages.toolbarInsertBlockMessages.viewMore))
@@ -538,7 +532,7 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref4) {
538
532
  }, (0, _react2.jsx)("div", {
539
533
  id: menuGroupId,
540
534
  ref: listContainerRef
541
- }, isEmptyStateActive && EmptyResultView, isEmptyStateActive ? ListContent : !showMoreOptionsButton || itemsLength ? ListContent : EmptyResultView, showMoreOptionsButton && config && (0, _react2.jsx)(_MoreOptions.MoreOptions, {
535
+ }, !showMoreOptionsButton || itemsLength ? ListContent : EmptyResultView, showMoreOptionsButton && config && (0, _react2.jsx)(_MoreOptions.MoreOptions, {
542
536
  title: config.title,
543
537
  ariaLabel: config.ariaLabel,
544
538
  onClick: handleClick,
@@ -8,7 +8,6 @@ exports.TypeAheadMenu = void 0;
8
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
9
  var _react = _interopRequireDefault(require("react"));
10
10
  var _typeAhead = require("@atlaskit/editor-common/type-ahead");
11
- var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
12
11
  var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
13
12
  var _updateSelectedIndex = require("../pm-plugins/commands/update-selected-index");
14
13
  var _useItemInsert3 = require("./hooks/use-item-insert");
@@ -88,13 +87,7 @@ var TypeAheadMenu = exports.TypeAheadMenu = /*#__PURE__*/_react.default.memo(fun
88
87
  if ((0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1')) {
89
88
  showMoreOptionsButton = !!(triggerHandler !== null && triggerHandler !== void 0 && triggerHandler.getMoreOptionsButtonConfig);
90
89
  }
91
- var emptyItem = _react.default.useMemo(function () {
92
- var _triggerHandler$getEm;
93
- return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_insert_menu_ai') ? triggerHandler === null || triggerHandler === void 0 || (_triggerHandler$getEm = triggerHandler.getEmptyItem) === null || _triggerHandler$getEm === void 0 ? void 0 : _triggerHandler$getEm.call(triggerHandler, {
94
- editorState: editorView.state
95
- }) : undefined;
96
- }, [triggerHandler, editorView.state]);
97
- if (!isOpen || !triggerHandler || !(decorationElement instanceof HTMLElement) || !openElementBrowserModal && items.length === 0 && !errorInfo && !emptyItem) {
90
+ if (!isOpen || !triggerHandler || !(decorationElement instanceof HTMLElement) || !openElementBrowserModal && items.length === 0 && !errorInfo) {
98
91
  return null;
99
92
  }
100
93
  return /*#__PURE__*/_react.default.createElement(_TypeAheadPopup.TypeAheadPopup, {
@@ -106,7 +99,6 @@ var TypeAheadMenu = exports.TypeAheadMenu = /*#__PURE__*/_react.default.memo(fun
106
99
  triggerHandler: triggerHandler,
107
100
  items: items,
108
101
  sections: sections,
109
- emptyItem: emptyItem,
110
102
  errorInfo: errorInfo,
111
103
  selectedIndex: selectedIndex,
112
104
  setSelectedItem: setSelectedItem,
@@ -75,7 +75,6 @@ var TypeAheadPopup = exports.TypeAheadPopup = /*#__PURE__*/_react.default.memo(f
75
75
  items = props.items,
76
76
  _props$sections = props.sections,
77
77
  sections = _props$sections === void 0 ? [] : _props$sections,
78
- emptyItem = props.emptyItem,
79
78
  errorInfo = props.errorInfo,
80
79
  selectedIndex = props.selectedIndex,
81
80
  onItemInsert = props.onItemInsert,
@@ -349,7 +348,6 @@ var TypeAheadPopup = exports.TypeAheadPopup = /*#__PURE__*/_react.default.memo(f
349
348
  items: items,
350
349
  isEmptyQuery: isEmptyQuery,
351
350
  sections: sections,
352
- emptyItem: emptyItem,
353
351
  selectedIndex: selectedIndex
354
352
  // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
355
353
  ,
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.useLoadItems = void 0;
8
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
9
  var _react = require("react");
10
- var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
11
10
  var _clearListError = require("../../pm-plugins/commands/clear-list-error");
12
11
  var _updateListError = require("../../pm-plugins/commands/update-list-error");
13
12
  var _updateListItems = require("../../pm-plugins/commands/update-list-items");
@@ -48,19 +47,14 @@ var useLoadItems = exports.useLoadItems = function useLoadItems(triggerHandler,
48
47
  * Promise path and the opt-in multi-emit `subscribeToItemsUpdates`
49
48
  * path. Renders the dropdown with whatever items it is given.
50
49
  *
51
- * Both paths share the empty-state injection, section-building
52
- * and "View more" placeholder logic — extracting this helper
50
+ * Both paths share the section-building and "View more"
51
+ * placeholder logic — extracting this helper
53
52
  * avoids any chance the two paths drift in subtle rendering
54
53
  * behaviour.
55
54
  */
56
55
  var renderResult = function renderResult(result) {
57
- var _triggerHandler$getEm;
58
- var emptyItem = result.length === 0 && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_insert_menu_ai') ? (_triggerHandler$getEm = triggerHandler.getEmptyItem) === null || _triggerHandler$getEm === void 0 ? void 0 : _triggerHandler$getEm.call(triggerHandler, {
59
- editorState: editorView.state
60
- }) : undefined;
61
- var rawList = result.length > 0 ? result : emptyItem ? [emptyItem] : EMPTY_LIST_ITEM;
62
56
  var _buildSectionedResult = (0, _buildSectionedResult2.buildSectionedResult)({
63
- items: rawList,
57
+ items: result.length > 0 ? result : EMPTY_LIST_ITEM,
64
58
  triggerHandler: triggerHandler,
65
59
  intl: intl !== null && intl !== void 0 ? intl : null
66
60
  }),
@@ -9,7 +9,6 @@ Object.defineProperty(exports, "__esModule", {
9
9
  exports.RegisteredTypeAheadMenu = void 0;
10
10
  require("./RegisteredTypeAheadMenu.compiled.css");
11
11
  var _runtime = require("@compiled/react/runtime");
12
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
12
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
14
13
  var _react = _interopRequireWildcard(require("react"));
15
14
  var _reactIntl = require("react-intl");
@@ -107,9 +106,8 @@ var RegisteredTypeAheadMenu = exports.RegisteredTypeAheadMenu = function Registe
107
106
  });
108
107
  }, [components, formatMessage, hasSectionOverflowItems, isSlashCommandEnabled, query, surfaceContext, surface.root]);
109
108
  var rows = (0, _react.useMemo)(function () {
110
- var _menuModel$fallbackIt;
111
- return [].concat((0, _toConsumableArray2.default)(menuModel.sections.flat()), (0, _toConsumableArray2.default)((_menuModel$fallbackIt = menuModel.fallbackItems) !== null && _menuModel$fallbackIt !== void 0 ? _menuModel$fallbackIt : []));
112
- }, [menuModel.fallbackItems, menuModel.sections]);
109
+ return (0, _registeredMenuModel.getQuickInsertMenuRows)(menuModel);
110
+ }, [menuModel]);
113
111
  var _useState5 = (0, _react.useState)(),
114
112
  _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
115
113
  previewActivation = _useState6[0],
@@ -7,11 +7,11 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.TypeAheadMenuRenderer = void 0;
9
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
10
  var _react = _interopRequireWildcard(require("react"));
12
11
  var _reactIntl = require("react-intl");
13
12
  var _CellMeasurer = require("react-virtualized/dist/commonjs/CellMeasurer");
14
13
  var _List = require("react-virtualized/dist/commonjs/List");
14
+ var _registeredMenuModel = require("@atlaskit/editor-common/quick-insert/registered-menu-model");
15
15
  var _useMenuListHeight2 = require("@atlaskit/editor-common/quick-insert/use-menu-list-height");
16
16
  var _typeAhead = require("@atlaskit/editor-common/type-ahead");
17
17
  var _compiled = require("@atlaskit/primitives/compiled");
@@ -41,9 +41,8 @@ var TypeAheadMenuRenderer = exports.TypeAheadMenuRenderer = function TypeAheadMe
41
41
  var intl = (0, _reactIntl.useIntl)();
42
42
  var listRef = (0, _react.useRef)(null);
43
43
  var rows = (0, _react.useMemo)(function () {
44
- var _model$fallbackItems;
45
- return [].concat((0, _toConsumableArray2.default)(model.sections.flat()), (0, _toConsumableArray2.default)((_model$fallbackItems = model.fallbackItems) !== null && _model$fallbackItems !== void 0 ? _model$fallbackItems : []));
46
- }, [model.fallbackItems, model.sections]);
44
+ return (0, _registeredMenuModel.getQuickInsertMenuRows)(model);
45
+ }, [model]);
47
46
  var cache = (0, _react.useMemo)(function () {
48
47
  return new _CellMeasurer.CellMeasurerCache({
49
48
  defaultHeight: ESTIMATED_ROW_HEIGHT,
@@ -15,7 +15,6 @@ import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/
15
15
  import { SelectItemMode, typeAheadListMessages } from '@atlaskit/editor-common/type-ahead';
16
16
  import { AssistiveText } from '@atlaskit/editor-common/ui';
17
17
  import MenuGroup from '@atlaskit/menu/menu-group';
18
- import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
19
18
  import { fg } from '@atlaskit/platform-feature-flags/fg';
20
19
  import { Box, Inline, Text } from '@atlaskit/primitives/compiled';
21
20
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
@@ -112,7 +111,6 @@ const TypeaheadAssistiveTextPureComponent = /*#__PURE__*/React.memo(({
112
111
  const TypeAheadListComponent = /*#__PURE__*/React.memo(({
113
112
  items,
114
113
  sections,
115
- emptyItem,
116
114
  selectedIndex,
117
115
  isEmptyQuery = true,
118
116
  editorView,
@@ -140,7 +138,6 @@ const TypeAheadListComponent = /*#__PURE__*/React.memo(({
140
138
 
141
139
  // Exclude view more item from the count
142
140
  const itemsLength = showMoreOptionsButton ? Math.max(items.length - 1, 0) : items.length;
143
- const isEmptyStateActive = isExperimentEnabled('platform_editor_insert_menu_ai') && !!emptyItem && itemsLength === 1 && items[0] === emptyItem;
144
141
  const estimatedHeight = itemsLength * LIST_ITEM_ESTIMATED_HEIGHT;
145
142
  const [height, setHeight] = useState(Math.min(estimatedHeight, fitHeight));
146
143
  const [cache, setCache] = useState(new CellMeasurerCache({
@@ -466,10 +463,7 @@ const TypeAheadListComponent = /*#__PURE__*/React.memo(({
466
463
  }, intl.formatMessage(typeAheadListMessages.emptySearchResults)), jsx(Text, {
467
464
  align: "center",
468
465
  as: "p"
469
- }, intl.formatMessage(isExperimentEnabled('platform_editor_insert_menu_ai') ? showMoreOptionsButton ? typeAheadListMessages.emptySearchResultsSuggestionNew : typeAheadListMessages.emptySearchResultsSuggestionAskRovoOnly : typeAheadListMessages.emptySearchResultsSuggestion, {
470
- askRovoName: jsx(Text, {
471
- weight: "medium"
472
- }, intl.formatMessage(messages.askRovo)),
466
+ }, intl.formatMessage(typeAheadListMessages.emptySearchResultsSuggestion, {
473
467
  buttonName: jsx(Text, {
474
468
  weight: "medium"
475
469
  }, intl.formatMessage(messages.viewMore))
@@ -510,7 +504,7 @@ const TypeAheadListComponent = /*#__PURE__*/React.memo(({
510
504
  }, jsx("div", {
511
505
  id: menuGroupId,
512
506
  ref: listContainerRef
513
- }, isEmptyStateActive && EmptyResultView, isEmptyStateActive ? ListContent : !showMoreOptionsButton || itemsLength ? ListContent : EmptyResultView, showMoreOptionsButton && config && jsx(MoreOptions, {
507
+ }, !showMoreOptionsButton || itemsLength ? ListContent : EmptyResultView, showMoreOptionsButton && config && jsx(MoreOptions, {
514
508
  title: config.title,
515
509
  ariaLabel: config.ariaLabel,
516
510
  onClick: handleClick,
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
2
  import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
3
- import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
4
3
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
5
4
  import { updateSelectedIndex } from '../pm-plugins/commands/update-selected-index';
6
5
  import { useItemInsert } from './hooks/use-item-insert';
@@ -78,13 +77,7 @@ export const TypeAheadMenu = /*#__PURE__*/React.memo(({
78
77
  if (editorExperiment('platform_editor_controls', 'variant1')) {
79
78
  showMoreOptionsButton = !!(triggerHandler !== null && triggerHandler !== void 0 && triggerHandler.getMoreOptionsButtonConfig);
80
79
  }
81
- const emptyItem = React.useMemo(() => {
82
- var _triggerHandler$getEm;
83
- return isExperimentEnabled('platform_editor_insert_menu_ai') ? triggerHandler === null || triggerHandler === void 0 ? void 0 : (_triggerHandler$getEm = triggerHandler.getEmptyItem) === null || _triggerHandler$getEm === void 0 ? void 0 : _triggerHandler$getEm.call(triggerHandler, {
84
- editorState: editorView.state
85
- }) : undefined;
86
- }, [triggerHandler, editorView.state]);
87
- if (!isOpen || !triggerHandler || !(decorationElement instanceof HTMLElement) || !openElementBrowserModal && items.length === 0 && !errorInfo && !emptyItem) {
80
+ if (!isOpen || !triggerHandler || !(decorationElement instanceof HTMLElement) || !openElementBrowserModal && items.length === 0 && !errorInfo) {
88
81
  return null;
89
82
  }
90
83
  return /*#__PURE__*/React.createElement(TypeAheadPopup, {
@@ -96,7 +89,6 @@ export const TypeAheadMenu = /*#__PURE__*/React.memo(({
96
89
  triggerHandler: triggerHandler,
97
90
  items: items,
98
91
  sections: sections,
99
- emptyItem: emptyItem,
100
92
  errorInfo: errorInfo,
101
93
  selectedIndex: selectedIndex,
102
94
  setSelectedItem: setSelectedItem,
@@ -65,7 +65,6 @@ export const TypeAheadPopup = /*#__PURE__*/React.memo(props => {
65
65
  popupsScrollableElement,
66
66
  items,
67
67
  sections = [],
68
- emptyItem,
69
68
  errorInfo,
70
69
  selectedIndex,
71
70
  onItemInsert,
@@ -344,7 +343,6 @@ export const TypeAheadPopup = /*#__PURE__*/React.memo(props => {
344
343
  items: items,
345
344
  isEmptyQuery: isEmptyQuery,
346
345
  sections: sections,
347
- emptyItem: emptyItem,
348
346
  selectedIndex: selectedIndex
349
347
  // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
350
348
  ,
@@ -1,5 +1,4 @@
1
1
  import { useEffect, useRef, useState } from 'react';
2
- import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
3
2
  import { clearListError } from '../../pm-plugins/commands/clear-list-error';
4
3
  import { updateListError } from '../../pm-plugins/commands/update-list-error';
5
4
  import { updateListItem } from '../../pm-plugins/commands/update-list-items';
@@ -36,22 +35,17 @@ export const useLoadItems = (triggerHandler, editorView, query, showViewMore, ap
36
35
  * Promise path and the opt-in multi-emit `subscribeToItemsUpdates`
37
36
  * path. Renders the dropdown with whatever items it is given.
38
37
  *
39
- * Both paths share the empty-state injection, section-building
40
- * and "View more" placeholder logic — extracting this helper
38
+ * Both paths share the section-building and "View more"
39
+ * placeholder logic — extracting this helper
41
40
  * avoids any chance the two paths drift in subtle rendering
42
41
  * behaviour.
43
42
  */
44
43
  const renderResult = result => {
45
- var _triggerHandler$getEm;
46
- const emptyItem = result.length === 0 && isExperimentEnabled('platform_editor_insert_menu_ai') ? (_triggerHandler$getEm = triggerHandler.getEmptyItem) === null || _triggerHandler$getEm === void 0 ? void 0 : _triggerHandler$getEm.call(triggerHandler, {
47
- editorState: editorView.state
48
- }) : undefined;
49
- const rawList = result.length > 0 ? result : emptyItem ? [emptyItem] : EMPTY_LIST_ITEM;
50
44
  const {
51
45
  items: list,
52
46
  sections
53
47
  } = buildSectionedResult({
54
- items: rawList,
48
+ items: result.length > 0 ? result : EMPTY_LIST_ITEM,
55
49
  triggerHandler,
56
50
  intl: intl !== null && intl !== void 0 ? intl : null
57
51
  });
@@ -3,7 +3,7 @@ import "./RegisteredTypeAheadMenu.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React, { useCallback, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';
5
5
  import { useIntl } from 'react-intl';
6
- import { buildQuickInsertMenuModel, getMatchingQuickInsertComponents, selectQuickInsertCategoryItems } from '@atlaskit/editor-common/quick-insert/registered-menu-model';
6
+ import { buildQuickInsertMenuModel, getMatchingQuickInsertComponents, getQuickInsertMenuRows, selectQuickInsertCategoryItems } from '@atlaskit/editor-common/quick-insert/registered-menu-model';
7
7
  import { useMenuPopupSizing } from '@atlaskit/editor-common/quick-insert/use-menu-popup-sizing';
8
8
  import { isSectionOverflowItemKey } from '@atlaskit/editor-common/type-ahead-is-section-overflow-item-key';
9
9
  import { TYPE_AHEAD_SURFACE_CONTEXT } from '@atlaskit/editor-common/type-ahead-surface-context';
@@ -80,10 +80,7 @@ export const RegisteredTypeAheadMenu = ({
80
80
  formatMessage,
81
81
  surfaceContext
82
82
  }), [components, formatMessage, hasSectionOverflowItems, isSlashCommandEnabled, query, surfaceContext, surface.root]);
83
- const rows = useMemo(() => {
84
- var _menuModel$fallbackIt;
85
- return [...menuModel.sections.flat(), ...((_menuModel$fallbackIt = menuModel.fallbackItems) !== null && _menuModel$fallbackIt !== void 0 ? _menuModel$fallbackIt : [])];
86
- }, [menuModel.fallbackItems, menuModel.sections]);
83
+ const rows = useMemo(() => getQuickInsertMenuRows(menuModel), [menuModel]);
87
84
  const [previewActivation, setPreviewActivation] = useState();
88
85
  const activePreviewItemKey = (previewActivation === null || previewActivation === void 0 ? void 0 : previewActivation.menuModel) === menuModel ? previewActivation.itemKey : undefined;
89
86
  const selectableRowIndexes = useMemo(() => rows.flatMap((registration, rowIndex) => registration.type === 'menu-item' ? [rowIndex] : []), [rows]);
@@ -2,6 +2,7 @@ import React, { useCallback, useLayoutEffect, useMemo, useRef } from 'react';
2
2
  import { useIntl } from 'react-intl';
3
3
  import { CellMeasurerCache } from 'react-virtualized/dist/commonjs/CellMeasurer';
4
4
  import { List } from 'react-virtualized/dist/commonjs/List';
5
+ import { getQuickInsertMenuRows } from '@atlaskit/editor-common/quick-insert/registered-menu-model';
5
6
  import { useMenuListHeight } from '@atlaskit/editor-common/quick-insert/use-menu-list-height';
6
7
  import { typeAheadListMessages } from '@atlaskit/editor-common/type-ahead';
7
8
  import { Box, Text } from '@atlaskit/primitives/compiled';
@@ -27,10 +28,7 @@ export const TypeAheadMenuRenderer = ({
27
28
  var _model$root$component;
28
29
  const intl = useIntl();
29
30
  const listRef = useRef(null);
30
- const rows = useMemo(() => {
31
- var _model$fallbackItems;
32
- return [...model.sections.flat(), ...((_model$fallbackItems = model.fallbackItems) !== null && _model$fallbackItems !== void 0 ? _model$fallbackItems : [])];
33
- }, [model.fallbackItems, model.sections]);
31
+ const rows = useMemo(() => getQuickInsertMenuRows(model), [model]);
34
32
  const cache = useMemo(() => new CellMeasurerCache({
35
33
  defaultHeight: ESTIMATED_ROW_HEIGHT,
36
34
  fixedWidth: true
@@ -17,7 +17,6 @@ import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/
17
17
  import { SelectItemMode, typeAheadListMessages } from '@atlaskit/editor-common/type-ahead';
18
18
  import { AssistiveText } from '@atlaskit/editor-common/ui';
19
19
  import MenuGroup from '@atlaskit/menu/menu-group';
20
- import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
21
20
  import { fg } from '@atlaskit/platform-feature-flags/fg';
22
21
  import { Box, Inline, Text } from '@atlaskit/primitives/compiled';
23
22
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
@@ -118,7 +117,6 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref4) {
118
117
  var _itemRowIndexByItemIn, _triggerHandler$getMo, _decorationElement$qu2;
119
118
  var items = _ref4.items,
120
119
  sections = _ref4.sections,
121
- emptyItem = _ref4.emptyItem,
122
120
  selectedIndex = _ref4.selectedIndex,
123
121
  _ref4$isEmptyQuery = _ref4.isEmptyQuery,
124
122
  isEmptyQuery = _ref4$isEmptyQuery === void 0 ? true : _ref4$isEmptyQuery,
@@ -145,7 +143,6 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref4) {
145
143
 
146
144
  // Exclude view more item from the count
147
145
  var itemsLength = showMoreOptionsButton ? Math.max(items.length - 1, 0) : items.length;
148
- var isEmptyStateActive = isExperimentEnabled('platform_editor_insert_menu_ai') && !!emptyItem && itemsLength === 1 && items[0] === emptyItem;
149
146
  var estimatedHeight = itemsLength * LIST_ITEM_ESTIMATED_HEIGHT;
150
147
  var _useState = useState(Math.min(estimatedHeight, fitHeight)),
151
148
  _useState2 = _slicedToArray(_useState, 2),
@@ -485,10 +482,7 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref4) {
485
482
  }, intl.formatMessage(typeAheadListMessages.emptySearchResults)), jsx(Text, {
486
483
  align: "center",
487
484
  as: "p"
488
- }, intl.formatMessage(isExperimentEnabled('platform_editor_insert_menu_ai') ? showMoreOptionsButton ? typeAheadListMessages.emptySearchResultsSuggestionNew : typeAheadListMessages.emptySearchResultsSuggestionAskRovoOnly : typeAheadListMessages.emptySearchResultsSuggestion, {
489
- askRovoName: jsx(Text, {
490
- weight: "medium"
491
- }, intl.formatMessage(messages.askRovo)),
485
+ }, intl.formatMessage(typeAheadListMessages.emptySearchResultsSuggestion, {
492
486
  buttonName: jsx(Text, {
493
487
  weight: "medium"
494
488
  }, intl.formatMessage(messages.viewMore))
@@ -529,7 +523,7 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref4) {
529
523
  }, jsx("div", {
530
524
  id: menuGroupId,
531
525
  ref: listContainerRef
532
- }, isEmptyStateActive && EmptyResultView, isEmptyStateActive ? ListContent : !showMoreOptionsButton || itemsLength ? ListContent : EmptyResultView, showMoreOptionsButton && config && jsx(MoreOptions, {
526
+ }, !showMoreOptionsButton || itemsLength ? ListContent : EmptyResultView, showMoreOptionsButton && config && jsx(MoreOptions, {
533
527
  title: config.title,
534
528
  ariaLabel: config.ariaLabel,
535
529
  onClick: handleClick,
@@ -1,7 +1,6 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import React from 'react';
3
3
  import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
4
- import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
5
4
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
6
5
  import { updateSelectedIndex } from '../pm-plugins/commands/update-selected-index';
7
6
  import { useItemInsert } from './hooks/use-item-insert';
@@ -81,13 +80,7 @@ export var TypeAheadMenu = /*#__PURE__*/React.memo(function (_ref) {
81
80
  if (editorExperiment('platform_editor_controls', 'variant1')) {
82
81
  showMoreOptionsButton = !!(triggerHandler !== null && triggerHandler !== void 0 && triggerHandler.getMoreOptionsButtonConfig);
83
82
  }
84
- var emptyItem = React.useMemo(function () {
85
- var _triggerHandler$getEm;
86
- return isExperimentEnabled('platform_editor_insert_menu_ai') ? triggerHandler === null || triggerHandler === void 0 || (_triggerHandler$getEm = triggerHandler.getEmptyItem) === null || _triggerHandler$getEm === void 0 ? void 0 : _triggerHandler$getEm.call(triggerHandler, {
87
- editorState: editorView.state
88
- }) : undefined;
89
- }, [triggerHandler, editorView.state]);
90
- if (!isOpen || !triggerHandler || !(decorationElement instanceof HTMLElement) || !openElementBrowserModal && items.length === 0 && !errorInfo && !emptyItem) {
83
+ if (!isOpen || !triggerHandler || !(decorationElement instanceof HTMLElement) || !openElementBrowserModal && items.length === 0 && !errorInfo) {
91
84
  return null;
92
85
  }
93
86
  return /*#__PURE__*/React.createElement(TypeAheadPopup, {
@@ -99,7 +92,6 @@ export var TypeAheadMenu = /*#__PURE__*/React.memo(function (_ref) {
99
92
  triggerHandler: triggerHandler,
100
93
  items: items,
101
94
  sections: sections,
102
- emptyItem: emptyItem,
103
95
  errorInfo: errorInfo,
104
96
  selectedIndex: selectedIndex,
105
97
  setSelectedItem: setSelectedItem,
@@ -65,7 +65,6 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
65
65
  items = props.items,
66
66
  _props$sections = props.sections,
67
67
  sections = _props$sections === void 0 ? [] : _props$sections,
68
- emptyItem = props.emptyItem,
69
68
  errorInfo = props.errorInfo,
70
69
  selectedIndex = props.selectedIndex,
71
70
  onItemInsert = props.onItemInsert,
@@ -339,7 +338,6 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
339
338
  items: items,
340
339
  isEmptyQuery: isEmptyQuery,
341
340
  sections: sections,
342
- emptyItem: emptyItem,
343
341
  selectedIndex: selectedIndex
344
342
  // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
345
343
  ,
@@ -1,6 +1,5 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import { useEffect, useRef, useState } from 'react';
3
- import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
4
3
  import { clearListError } from '../../pm-plugins/commands/clear-list-error';
5
4
  import { updateListError } from '../../pm-plugins/commands/update-list-error';
6
5
  import { updateListItem } from '../../pm-plugins/commands/update-list-items';
@@ -41,19 +40,14 @@ export var useLoadItems = function useLoadItems(triggerHandler, editorView, quer
41
40
  * Promise path and the opt-in multi-emit `subscribeToItemsUpdates`
42
41
  * path. Renders the dropdown with whatever items it is given.
43
42
  *
44
- * Both paths share the empty-state injection, section-building
45
- * and "View more" placeholder logic — extracting this helper
43
+ * Both paths share the section-building and "View more"
44
+ * placeholder logic — extracting this helper
46
45
  * avoids any chance the two paths drift in subtle rendering
47
46
  * behaviour.
48
47
  */
49
48
  var renderResult = function renderResult(result) {
50
- var _triggerHandler$getEm;
51
- var emptyItem = result.length === 0 && isExperimentEnabled('platform_editor_insert_menu_ai') ? (_triggerHandler$getEm = triggerHandler.getEmptyItem) === null || _triggerHandler$getEm === void 0 ? void 0 : _triggerHandler$getEm.call(triggerHandler, {
52
- editorState: editorView.state
53
- }) : undefined;
54
- var rawList = result.length > 0 ? result : emptyItem ? [emptyItem] : EMPTY_LIST_ITEM;
55
49
  var _buildSectionedResult = buildSectionedResult({
56
- items: rawList,
50
+ items: result.length > 0 ? result : EMPTY_LIST_ITEM,
57
51
  triggerHandler: triggerHandler,
58
52
  intl: intl !== null && intl !== void 0 ? intl : null
59
53
  }),
@@ -1,11 +1,10 @@
1
1
  /* RegisteredTypeAheadMenu.tsx generated by @compiled/babel-plugin v3.0.2 */
2
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
3
  import "./RegisteredTypeAheadMenu.compiled.css";
5
4
  import { ax, ix } from "@compiled/react/runtime";
6
5
  import React, { useCallback, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';
7
6
  import { useIntl } from 'react-intl';
8
- import { buildQuickInsertMenuModel, getMatchingQuickInsertComponents, selectQuickInsertCategoryItems } from '@atlaskit/editor-common/quick-insert/registered-menu-model';
7
+ import { buildQuickInsertMenuModel, getMatchingQuickInsertComponents, getQuickInsertMenuRows, selectQuickInsertCategoryItems } from '@atlaskit/editor-common/quick-insert/registered-menu-model';
9
8
  import { useMenuPopupSizing } from '@atlaskit/editor-common/quick-insert/use-menu-popup-sizing';
10
9
  import { isSectionOverflowItemKey } from '@atlaskit/editor-common/type-ahead-is-section-overflow-item-key';
11
10
  import { TYPE_AHEAD_SURFACE_CONTEXT } from '@atlaskit/editor-common/type-ahead-surface-context';
@@ -98,9 +97,8 @@ export var RegisteredTypeAheadMenu = function RegisteredTypeAheadMenu(_ref) {
98
97
  });
99
98
  }, [components, formatMessage, hasSectionOverflowItems, isSlashCommandEnabled, query, surfaceContext, surface.root]);
100
99
  var rows = useMemo(function () {
101
- var _menuModel$fallbackIt;
102
- return [].concat(_toConsumableArray(menuModel.sections.flat()), _toConsumableArray((_menuModel$fallbackIt = menuModel.fallbackItems) !== null && _menuModel$fallbackIt !== void 0 ? _menuModel$fallbackIt : []));
103
- }, [menuModel.fallbackItems, menuModel.sections]);
100
+ return getQuickInsertMenuRows(menuModel);
101
+ }, [menuModel]);
104
102
  var _useState5 = useState(),
105
103
  _useState6 = _slicedToArray(_useState5, 2),
106
104
  previewActivation = _useState6[0],
@@ -1,5 +1,4 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
2
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
4
3
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
5
4
  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; }
@@ -7,6 +6,7 @@ import React, { useCallback, useLayoutEffect, useMemo, useRef } from 'react';
7
6
  import { useIntl } from 'react-intl';
8
7
  import { CellMeasurerCache } from 'react-virtualized/dist/commonjs/CellMeasurer';
9
8
  import { List } from 'react-virtualized/dist/commonjs/List';
9
+ import { getQuickInsertMenuRows } from '@atlaskit/editor-common/quick-insert/registered-menu-model';
10
10
  import { useMenuListHeight } from '@atlaskit/editor-common/quick-insert/use-menu-list-height';
11
11
  import { typeAheadListMessages } from '@atlaskit/editor-common/type-ahead';
12
12
  import { Box, Text } from '@atlaskit/primitives/compiled';
@@ -32,9 +32,8 @@ export var TypeAheadMenuRenderer = function TypeAheadMenuRenderer(_ref) {
32
32
  var intl = useIntl();
33
33
  var listRef = useRef(null);
34
34
  var rows = useMemo(function () {
35
- var _model$fallbackItems;
36
- return [].concat(_toConsumableArray(model.sections.flat()), _toConsumableArray((_model$fallbackItems = model.fallbackItems) !== null && _model$fallbackItems !== void 0 ? _model$fallbackItems : []));
37
- }, [model.fallbackItems, model.sections]);
35
+ return getQuickInsertMenuRows(model);
36
+ }, [model]);
38
37
  var cache = useMemo(function () {
39
38
  return new CellMeasurerCache({
40
39
  defaultHeight: ESTIMATED_ROW_HEIGHT,
@@ -26,7 +26,6 @@ export declare const TypeAheadList: React.FC<WithIntlProps<{
26
26
  api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
27
27
  decorationElement: HTMLElement;
28
28
  editorView: EditorView;
29
- emptyItem?: TypeAheadItem;
30
29
  fitHeight: number;
31
30
  isEmptyQuery?: boolean;
32
31
  items: Array<TypeAheadItem>;
@@ -42,7 +41,6 @@ export declare const TypeAheadList: React.FC<WithIntlProps<{
42
41
  api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
43
42
  decorationElement: HTMLElement;
44
43
  editorView: EditorView;
45
- emptyItem?: TypeAheadItem;
46
44
  fitHeight: number;
47
45
  isEmptyQuery?: boolean;
48
46
  items: Array<TypeAheadItem>;
@@ -20,7 +20,6 @@ type TypeAheadPopupProps = {
20
20
  }) => void;
21
21
  decorationSet: DecorationSet;
22
22
  editorView: EditorView;
23
- emptyItem?: TypeAheadItem;
24
23
  errorInfo: TypeAheadErrorInfo;
25
24
  isEmptyQuery: boolean;
26
25
  items: Array<TypeAheadItem>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-type-ahead",
3
- "version": "25.0.6",
3
+ "version": "26.0.1",
4
4
  "description": "Type-ahead plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -21,13 +21,13 @@
21
21
  ],
22
22
  "atlaskit:src": "src/index.ts",
23
23
  "dependencies": {
24
- "@atlaskit/adf-schema": "^57.6.0",
24
+ "@atlaskit/adf-schema": "^57.7.0",
25
25
  "@atlaskit/css": "^1.1.0",
26
- "@atlaskit/editor-plugin-analytics": "^24.0.0",
27
- "@atlaskit/editor-plugin-connectivity": "^24.0.0",
28
- "@atlaskit/editor-plugin-context-panel": "^26.0.0",
29
- "@atlaskit/editor-plugin-metrics": "^25.0.0",
30
- "@atlaskit/editor-plugin-ui-control-registry": "^18.0.0",
26
+ "@atlaskit/editor-plugin-analytics": "^25.0.0",
27
+ "@atlaskit/editor-plugin-connectivity": "^25.0.0",
28
+ "@atlaskit/editor-plugin-context-panel": "^27.0.0",
29
+ "@atlaskit/editor-plugin-metrics": "^26.0.0",
30
+ "@atlaskit/editor-plugin-ui-control-registry": "^19.0.0",
31
31
  "@atlaskit/editor-prosemirror": "^9.0.0",
32
32
  "@atlaskit/editor-shared-styles": "^4.3.0",
33
33
  "@atlaskit/editor-ui-control-model": "^2.10.0",
@@ -42,7 +42,7 @@
42
42
  "@atlaskit/primitives": "^22.5.0",
43
43
  "@atlaskit/prosemirror-history": "^1.3.0",
44
44
  "@atlaskit/prosemirror-input-rules": "^4.1.0",
45
- "@atlaskit/tmp-editor-statsig": "^224.0.0",
45
+ "@atlaskit/tmp-editor-statsig": "^225.0.0",
46
46
  "@atlaskit/tokens": "^20.3.0",
47
47
  "@atlaskit/visually-hidden": "^4.4.0",
48
48
  "@babel/runtime": "^7.0.0",
@@ -54,7 +54,7 @@
54
54
  "w3c-keyname": "^2.1.8"
55
55
  },
56
56
  "peerDependencies": {
57
- "@atlaskit/editor-common": "^128.4.0",
57
+ "@atlaskit/editor-common": "^129.1.0",
58
58
  "react": "^18.2.0 || ^19.2.0",
59
59
  "react-dom": "^18.2.0 || ^19.2.0",
60
60
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"