@atlaskit/editor-plugin-type-ahead 2.0.5 → 2.1.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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/editor-plugin-type-ahead
2
2
 
3
+ ## 2.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#120472](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/120472)
8
+ [`73c800ab5f2fc`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/73c800ab5f2fc) -
9
+ ED-26766 update adf-schema from 47.2.1 to 47.6.0 and adf-schema-json from 1.27.0 to 1.31.0
10
+
11
+ ### Patch Changes
12
+
13
+ - [#121073](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/121073)
14
+ [`9c197731fcbf8`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9c197731fcbf8) -
15
+ [ux] [ED-26824] When platform_editor_controls is enabled, add 'View more' button to quick
16
+ insertpopup to open element browser modal
17
+ - Updated dependencies
18
+
3
19
  ## 2.0.5
4
20
 
5
21
  ### Patch Changes
@@ -12,8 +12,10 @@ var _react2 = require("@emotion/react");
12
12
  var _reactIntlNext = require("react-intl-next");
13
13
  var _CellMeasurer = require("react-virtualized/dist/commonjs/CellMeasurer");
14
14
  var _List = require("react-virtualized/dist/commonjs/List");
15
+ var _messages = require("@atlaskit/editor-common/messages");
15
16
  var _typeAhead = require("@atlaskit/editor-common/type-ahead");
16
17
  var _menu = require("@atlaskit/menu");
18
+ var _primitives = require("@atlaskit/primitives");
17
19
  var _updateSelectedIndex = require("../pm-plugins/commands/update-selected-index");
18
20
  var _constants = require("../pm-plugins/constants");
19
21
  var _utils = require("../pm-plugins/utils");
@@ -60,7 +62,8 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref2) {
60
62
  decorationElement = _ref2.decorationElement,
61
63
  triggerHandler = _ref2.triggerHandler,
62
64
  moreElementsInQuickInsertViewEnabled = _ref2.moreElementsInQuickInsertViewEnabled,
63
- api = _ref2.api;
65
+ api = _ref2.api,
66
+ showViewMore = _ref2.showViewMore;
64
67
  var listRef = (0, _react.useRef)();
65
68
  var listContainerRef = (0, _react.useRef)(null);
66
69
  var lastVisibleIndexes = (0, _react.useRef)({
@@ -287,13 +290,21 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref2) {
287
290
  return null;
288
291
  }
289
292
  var menuGroupId = ((_decorationElement$qu2 = decorationElement.querySelector("[role='combobox']")) === null || _decorationElement$qu2 === void 0 ? void 0 : _decorationElement$qu2.getAttribute('aria-controls')) || _constants.TYPE_AHEAD_DECORATION_ELEMENT_ID;
290
- return (0, _react2.jsx)(_menu.MenuGroup, {
291
- "aria-label": popupAriaLabel,
292
- "aria-relevant": "additions removals"
293
- }, (0, _react2.jsx)("div", {
294
- id: menuGroupId,
295
- ref: listContainerRef
296
- }, (0, _react2.jsx)(_List.List, {
293
+ var EmptyResultView = (0, _react2.jsx)(_primitives.Box, {
294
+ paddingBlock: "space.150",
295
+ paddingInline: "space.250"
296
+ }, (0, _react2.jsx)(_primitives.Text, {
297
+ align: "center",
298
+ as: "p"
299
+ }, intl.formatMessage(_typeAhead.typeAheadListMessages.emptySearchResults)), (0, _react2.jsx)(_primitives.Text, {
300
+ align: "center",
301
+ as: "p"
302
+ }, intl.formatMessage(_typeAhead.typeAheadListMessages.emptySearchResultsSuggestion, {
303
+ buttonName: (0, _react2.jsx)(_primitives.Text, {
304
+ weight: "medium"
305
+ }, intl.formatMessage(_messages.toolbarInsertBlockMessages.viewMore))
306
+ })));
307
+ var ListContent = (0, _react2.jsx)(_List.List, {
297
308
  rowRenderer: renderRow,
298
309
  ref: listRef,
299
310
  rowCount: items.length,
@@ -323,7 +334,14 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref2) {
323
334
  }
324
335
  }
325
336
  }), moreElementsInQuickInsertViewEnabled && list]
326
- }), (0, _react2.jsx)(TypeaheadAssistiveTextPureComponent, {
337
+ });
338
+ return (0, _react2.jsx)(_menu.MenuGroup, {
339
+ "aria-label": popupAriaLabel,
340
+ "aria-relevant": "additions removals"
341
+ }, (0, _react2.jsx)("div", {
342
+ id: menuGroupId,
343
+ ref: listContainerRef
344
+ }, !showViewMore || items.length ? ListContent : EmptyResultView, (0, _react2.jsx)(TypeaheadAssistiveTextPureComponent, {
327
345
  numberOfResults: items.length.toString()
328
346
  })));
329
347
  });
@@ -8,6 +8,7 @@ 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 _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
11
12
  var _updateSelectedIndex = require("../pm-plugins/commands/update-selected-index");
12
13
  var _useItemInsert3 = require("./hooks/use-item-insert");
13
14
  var _TypeAheadPopup = require("./TypeAheadPopup");
@@ -77,7 +78,11 @@ var TypeAheadMenu = exports.TypeAheadMenu = /*#__PURE__*/_react.default.memo(fun
77
78
  return;
78
79
  }
79
80
  }, [isOpen, query, onItemMatch]);
80
- if (!isOpen || !triggerHandler || !(decorationElement instanceof HTMLElement) || items.length === 0 && !errorInfo) {
81
+
82
+ // @ts-ignore
83
+ var openElementBrowserModal = triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.openElementBrowserModal;
84
+ var showViewMore = (triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.id) === _typeAhead.TypeAheadAvailableNodes.QUICK_INSERT && !!openElementBrowserModal && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1');
85
+ if (!isOpen || !triggerHandler || !(decorationElement instanceof HTMLElement) || !showViewMore && items.length === 0 && !errorInfo) {
81
86
  return null;
82
87
  }
83
88
  return /*#__PURE__*/_react.default.createElement(_TypeAheadPopup.TypeAheadPopup, {
@@ -95,6 +100,7 @@ var TypeAheadMenu = exports.TypeAheadMenu = /*#__PURE__*/_react.default.memo(fun
95
100
  decorationSet: decorationSet,
96
101
  isEmptyQuery: !query,
97
102
  cancel: cancel,
98
- api: api
103
+ api: api,
104
+ showViewMore: showViewMore
99
105
  });
100
106
  });
@@ -20,6 +20,7 @@ var _colors = require("@atlaskit/theme/colors");
20
20
  var _constants = require("../pm-plugins/constants");
21
21
  var _TypeAheadErrorFallback = require("./TypeAheadErrorFallback");
22
22
  var _TypeAheadList = require("./TypeAheadList");
23
+ var _ViewMore = require("./ViewMore");
23
24
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
24
25
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
25
26
  /**
@@ -30,6 +31,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
30
31
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
31
32
 
32
33
  var DEFAULT_TYPEAHEAD_MENU_HEIGHT = 380;
34
+ var VIEWMORE_BUTTON_HEIGHT = 53;
33
35
  var DEFAULT_TYPEAHEAD_MENU_HEIGHT_NEW = 480;
34
36
  var ITEM_PADDING = 12;
35
37
  var typeAheadContent = (0, _react2.css)({
@@ -46,6 +48,10 @@ var typeAheadContent = (0, _react2.css)({
46
48
  var typeAheadContentOverride = (0, _react2.css)({
47
49
  maxHeight: "".concat(DEFAULT_TYPEAHEAD_MENU_HEIGHT_NEW, "px")
48
50
  });
51
+ var typeAheadWrapperWithViewMoreOverride = (0, _react2.css)({
52
+ display: 'flex',
53
+ flexDirection: 'column'
54
+ });
49
55
  var Highlight = function Highlight(_ref) {
50
56
  var state = _ref.state,
51
57
  triggerHandler = _ref.triggerHandler;
@@ -68,7 +74,8 @@ var TypeAheadPopup = exports.TypeAheadPopup = /*#__PURE__*/_react.default.memo(f
68
74
  onItemInsert = props.onItemInsert,
69
75
  isEmptyQuery = props.isEmptyQuery,
70
76
  cancel = props.cancel,
71
- api = props.api;
77
+ api = props.api,
78
+ showViewMore = props.showViewMore;
72
79
  var ref = (0, _react.useRef)(null);
73
80
  var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['featureFlags']),
74
81
  featureFlagsState = _useSharedPluginState.featureFlagsState;
@@ -130,6 +137,12 @@ var TypeAheadPopup = exports.TypeAheadPopup = /*#__PURE__*/_react.default.memo(f
130
137
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
131
138
  fitHeight = _useState2[0],
132
139
  setFitHeight = _useState2[1];
140
+ var fitHeightWithViewMore = (0, _react.useMemo)(function () {
141
+ if (showViewMore) {
142
+ return fitHeight - VIEWMORE_BUTTON_HEIGHT;
143
+ }
144
+ return fitHeight;
145
+ }, [fitHeight, showViewMore]);
133
146
  var getFitHeight = (0, _react.useCallback)(function () {
134
147
  if (!anchorElement || !popupsMountPoint) {
135
148
  return;
@@ -269,6 +282,19 @@ var TypeAheadPopup = exports.TypeAheadPopup = /*#__PURE__*/_react.default.memo(f
269
282
  element === null || element === void 0 || element.removeEventListener('keydown', escape);
270
283
  };
271
284
  }, [ref, cancel]);
285
+
286
+ // @ts-ignore
287
+ var openElementBrowserModal = triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.openElementBrowserModal;
288
+ var onViewMoreClick = (0, _react.useCallback)(function () {
289
+ // TODO: when clean up, remove config in quick insert plugin
290
+ // platform/packages/editor/editor-plugin-quick-insert/src/quickInsertPlugin.tsx (typeAhead.openElementBrowserModal)
291
+ openElementBrowserModal === null || openElementBrowserModal === void 0 || openElementBrowserModal();
292
+ cancel({
293
+ addPrefixTrigger: false,
294
+ setSelectionAt: _constants.CloseSelectionOptions.AFTER_TEXT_INSERTED,
295
+ forceFocusOnEditor: false
296
+ });
297
+ }, [openElementBrowserModal, cancel]);
272
298
  return (0, _react2.jsx)(_ui.Popup, {
273
299
  zIndex: _editorSharedStyles.akEditorFloatingDialogZIndex,
274
300
  target: anchorElement,
@@ -281,7 +307,7 @@ var TypeAheadPopup = exports.TypeAheadPopup = /*#__PURE__*/_react.default.memo(f
281
307
  ariaLabel: null,
282
308
  preventOverflow: true
283
309
  }, (0, _react2.jsx)("div", {
284
- css: [typeAheadContent, moreElementsInQuickInsertViewEnabled && typeAheadContentOverride]
310
+ css: [typeAheadContent, moreElementsInQuickInsertViewEnabled && typeAheadContentOverride, showViewMore && typeAheadWrapperWithViewMoreOverride]
285
311
  // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
286
312
  ,
287
313
  tabIndex: 0
@@ -296,12 +322,15 @@ var TypeAheadPopup = exports.TypeAheadPopup = /*#__PURE__*/_react.default.memo(f
296
322
  items: items,
297
323
  selectedIndex: selectedIndex,
298
324
  onItemClick: onItemInsert,
299
- fitHeight: fitHeight,
325
+ fitHeight: fitHeightWithViewMore,
300
326
  editorView: editorView,
301
327
  decorationElement: anchorElement,
302
328
  triggerHandler: triggerHandler,
303
329
  moreElementsInQuickInsertViewEnabled: moreElementsInQuickInsertViewEnabled,
304
- api: api
330
+ api: api,
331
+ showViewMore: showViewMore
332
+ }), showViewMore && (0, _react2.jsx)(_ViewMore.ViewMore, {
333
+ onClick: onViewMoreClick
305
334
  }))));
306
335
  });
307
336
  TypeAheadPopup.displayName = 'TypeAheadPopup';
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.ViewMore = void 0;
8
+ var _react = require("@emotion/react");
9
+ var _reactIntlNext = require("react-intl-next");
10
+ var _messages = require("@atlaskit/editor-common/messages");
11
+ var _showMoreHorizontalEditorMore = _interopRequireDefault(require("@atlaskit/icon/core/migration/show-more-horizontal--editor-more"));
12
+ var _menu = require("@atlaskit/menu");
13
+ var _colors = require("@atlaskit/theme/colors");
14
+ /**
15
+ * @jsxRuntime classic
16
+ * @jsx jsx
17
+ */
18
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
19
+
20
+ var buttonStyles = (0, _react.css)({
21
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
22
+ '& > button:hover': {
23
+ backgroundColor: "var(--ds-background-neutral-subtle-hovered, ".concat(_colors.N30, ")")
24
+ }
25
+ });
26
+ var ViewMore = exports.ViewMore = function ViewMore(_ref) {
27
+ var onClick = _ref.onClick;
28
+ var _useIntl = (0, _reactIntlNext.useIntl)(),
29
+ formatMessage = _useIntl.formatMessage;
30
+ return (0, _react.jsx)(_menu.Section, {
31
+ hasSeparator: true
32
+ }, (0, _react.jsx)("span", {
33
+ css: buttonStyles
34
+ }, (0, _react.jsx)(_menu.ButtonItem, {
35
+ onClick: onClick,
36
+ iconBefore: (0, _react.jsx)(_showMoreHorizontalEditorMore.default, {
37
+ label: ""
38
+ }),
39
+ "aria-describedby": formatMessage(_messages.toolbarInsertBlockMessages.viewMore),
40
+ "data-testid": "quick-insert-view-more-elements-item"
41
+ }, formatMessage(_messages.toolbarInsertBlockMessages.viewMore))));
42
+ };
@@ -10,8 +10,10 @@ import { css, jsx } from '@emotion/react';
10
10
  import { injectIntl, useIntl } from 'react-intl-next';
11
11
  import { CellMeasurer, CellMeasurerCache } from 'react-virtualized/dist/commonjs/CellMeasurer';
12
12
  import { List } from 'react-virtualized/dist/commonjs/List';
13
+ import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
13
14
  import { SelectItemMode, typeAheadListMessages } from '@atlaskit/editor-common/type-ahead';
14
15
  import { MenuGroup } from '@atlaskit/menu';
16
+ import { Text, Box } from '@atlaskit/primitives';
15
17
  import { updateSelectedIndex } from '../pm-plugins/commands/update-selected-index';
16
18
  import { TYPE_AHEAD_DECORATION_ELEMENT_ID } from '../pm-plugins/constants';
17
19
  import { getTypeAheadListAriaLabels, moveSelectedIndex } from '../pm-plugins/utils';
@@ -49,7 +51,8 @@ const TypeAheadListComponent = /*#__PURE__*/React.memo(({
49
51
  decorationElement,
50
52
  triggerHandler,
51
53
  moreElementsInQuickInsertViewEnabled,
52
- api
54
+ api,
55
+ showViewMore
53
56
  }) => {
54
57
  var _decorationElement$qu2;
55
58
  const listRef = useRef();
@@ -266,13 +269,21 @@ const TypeAheadListComponent = /*#__PURE__*/React.memo(({
266
269
  return null;
267
270
  }
268
271
  const menuGroupId = ((_decorationElement$qu2 = decorationElement.querySelector(`[role='combobox']`)) === null || _decorationElement$qu2 === void 0 ? void 0 : _decorationElement$qu2.getAttribute('aria-controls')) || TYPE_AHEAD_DECORATION_ELEMENT_ID;
269
- return jsx(MenuGroup, {
270
- "aria-label": popupAriaLabel,
271
- "aria-relevant": "additions removals"
272
- }, jsx("div", {
273
- id: menuGroupId,
274
- ref: listContainerRef
275
- }, jsx(List, {
272
+ const EmptyResultView = jsx(Box, {
273
+ paddingBlock: "space.150",
274
+ paddingInline: "space.250"
275
+ }, jsx(Text, {
276
+ align: "center",
277
+ as: "p"
278
+ }, intl.formatMessage(typeAheadListMessages.emptySearchResults)), jsx(Text, {
279
+ align: "center",
280
+ as: "p"
281
+ }, intl.formatMessage(typeAheadListMessages.emptySearchResultsSuggestion, {
282
+ buttonName: jsx(Text, {
283
+ weight: "medium"
284
+ }, intl.formatMessage(messages.viewMore))
285
+ })));
286
+ const ListContent = jsx(List, {
276
287
  rowRenderer: renderRow,
277
288
  ref: listRef,
278
289
  rowCount: items.length,
@@ -302,7 +313,14 @@ const TypeAheadListComponent = /*#__PURE__*/React.memo(({
302
313
  }
303
314
  }
304
315
  }), moreElementsInQuickInsertViewEnabled && list]
305
- }), jsx(TypeaheadAssistiveTextPureComponent, {
316
+ });
317
+ return jsx(MenuGroup, {
318
+ "aria-label": popupAriaLabel,
319
+ "aria-relevant": "additions removals"
320
+ }, jsx("div", {
321
+ id: menuGroupId,
322
+ ref: listContainerRef
323
+ }, !showViewMore || items.length ? ListContent : EmptyResultView, jsx(TypeaheadAssistiveTextPureComponent, {
306
324
  numberOfResults: items.length.toString()
307
325
  })));
308
326
  });
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
2
+ import { SelectItemMode, TypeAheadAvailableNodes } from '@atlaskit/editor-common/type-ahead';
3
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
3
4
  import { updateSelectedIndex } from '../pm-plugins/commands/update-selected-index';
4
5
  import { useItemInsert } from './hooks/use-item-insert';
5
6
  import { TypeAheadPopup } from './TypeAheadPopup';
@@ -68,7 +69,11 @@ export const TypeAheadMenu = /*#__PURE__*/React.memo(({
68
69
  return;
69
70
  }
70
71
  }, [isOpen, query, onItemMatch]);
71
- if (!isOpen || !triggerHandler || !(decorationElement instanceof HTMLElement) || items.length === 0 && !errorInfo) {
72
+
73
+ // @ts-ignore
74
+ const openElementBrowserModal = triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.openElementBrowserModal;
75
+ const showViewMore = (triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.id) === TypeAheadAvailableNodes.QUICK_INSERT && !!openElementBrowserModal && editorExperiment('platform_editor_controls', 'variant1');
76
+ if (!isOpen || !triggerHandler || !(decorationElement instanceof HTMLElement) || !showViewMore && items.length === 0 && !errorInfo) {
72
77
  return null;
73
78
  }
74
79
  return /*#__PURE__*/React.createElement(TypeAheadPopup, {
@@ -86,6 +91,7 @@ export const TypeAheadMenu = /*#__PURE__*/React.memo(({
86
91
  decorationSet: decorationSet,
87
92
  isEmptyQuery: !query,
88
93
  cancel: cancel,
89
- api: api
94
+ api: api,
95
+ showViewMore: showViewMore
90
96
  });
91
97
  });
@@ -17,7 +17,9 @@ import { N0, N50A, N60A } from '@atlaskit/theme/colors';
17
17
  import { CloseSelectionOptions, TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE, TYPE_AHEAD_POPUP_CONTENT_CLASS } from '../pm-plugins/constants';
18
18
  import { TypeAheadErrorFallback } from './TypeAheadErrorFallback';
19
19
  import { TypeAheadList } from './TypeAheadList';
20
+ import { ViewMore } from './ViewMore';
20
21
  const DEFAULT_TYPEAHEAD_MENU_HEIGHT = 380;
22
+ const VIEWMORE_BUTTON_HEIGHT = 53;
21
23
  const DEFAULT_TYPEAHEAD_MENU_HEIGHT_NEW = 480;
22
24
  const ITEM_PADDING = 12;
23
25
  const typeAheadContent = css({
@@ -34,6 +36,10 @@ const typeAheadContent = css({
34
36
  const typeAheadContentOverride = css({
35
37
  maxHeight: `${DEFAULT_TYPEAHEAD_MENU_HEIGHT_NEW}px`
36
38
  });
39
+ const typeAheadWrapperWithViewMoreOverride = css({
40
+ display: 'flex',
41
+ flexDirection: 'column'
42
+ });
37
43
  const Highlight = ({
38
44
  state,
39
45
  triggerHandler
@@ -58,7 +64,8 @@ export const TypeAheadPopup = /*#__PURE__*/React.memo(props => {
58
64
  onItemInsert,
59
65
  isEmptyQuery,
60
66
  cancel,
61
- api
67
+ api,
68
+ showViewMore
62
69
  } = props;
63
70
  const ref = useRef(null);
64
71
  const {
@@ -115,6 +122,12 @@ export const TypeAheadPopup = /*#__PURE__*/React.memo(props => {
115
122
  // eslint-disable-next-line react-hooks/exhaustive-deps
116
123
  triggerHandler]);
117
124
  const [fitHeight, setFitHeight] = useState(defaultMenuHeight);
125
+ const fitHeightWithViewMore = useMemo(() => {
126
+ if (showViewMore) {
127
+ return fitHeight - VIEWMORE_BUTTON_HEIGHT;
128
+ }
129
+ return fitHeight;
130
+ }, [fitHeight, showViewMore]);
118
131
  const getFitHeight = useCallback(() => {
119
132
  if (!anchorElement || !popupsMountPoint) {
120
133
  return;
@@ -262,6 +275,19 @@ export const TypeAheadPopup = /*#__PURE__*/React.memo(props => {
262
275
  element === null || element === void 0 ? void 0 : element.removeEventListener('keydown', escape);
263
276
  };
264
277
  }, [ref, cancel]);
278
+
279
+ // @ts-ignore
280
+ const openElementBrowserModal = triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.openElementBrowserModal;
281
+ const onViewMoreClick = useCallback(() => {
282
+ // TODO: when clean up, remove config in quick insert plugin
283
+ // platform/packages/editor/editor-plugin-quick-insert/src/quickInsertPlugin.tsx (typeAhead.openElementBrowserModal)
284
+ openElementBrowserModal === null || openElementBrowserModal === void 0 ? void 0 : openElementBrowserModal();
285
+ cancel({
286
+ addPrefixTrigger: false,
287
+ setSelectionAt: CloseSelectionOptions.AFTER_TEXT_INSERTED,
288
+ forceFocusOnEditor: false
289
+ });
290
+ }, [openElementBrowserModal, cancel]);
265
291
  return jsx(Popup, {
266
292
  zIndex: akEditorFloatingDialogZIndex,
267
293
  target: anchorElement,
@@ -274,7 +300,7 @@ export const TypeAheadPopup = /*#__PURE__*/React.memo(props => {
274
300
  ariaLabel: null,
275
301
  preventOverflow: true
276
302
  }, jsx("div", {
277
- css: [typeAheadContent, moreElementsInQuickInsertViewEnabled && typeAheadContentOverride]
303
+ css: [typeAheadContent, moreElementsInQuickInsertViewEnabled && typeAheadContentOverride, showViewMore && typeAheadWrapperWithViewMoreOverride]
278
304
  // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
279
305
  ,
280
306
  tabIndex: 0
@@ -289,12 +315,15 @@ export const TypeAheadPopup = /*#__PURE__*/React.memo(props => {
289
315
  items: items,
290
316
  selectedIndex: selectedIndex,
291
317
  onItemClick: onItemInsert,
292
- fitHeight: fitHeight,
318
+ fitHeight: fitHeightWithViewMore,
293
319
  editorView: editorView,
294
320
  decorationElement: anchorElement,
295
321
  triggerHandler: triggerHandler,
296
322
  moreElementsInQuickInsertViewEnabled: moreElementsInQuickInsertViewEnabled,
297
- api: api
323
+ api: api,
324
+ showViewMore: showViewMore
325
+ }), showViewMore && jsx(ViewMore, {
326
+ onClick: onViewMoreClick
298
327
  }))));
299
328
  });
300
329
  TypeAheadPopup.displayName = 'TypeAheadPopup';
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
5
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
6
+ import { css, jsx } from '@emotion/react';
7
+ import { useIntl } from 'react-intl-next';
8
+ import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
9
+ import ShowMoreHorizontalIcon from '@atlaskit/icon/core/migration/show-more-horizontal--editor-more';
10
+ import { ButtonItem, Section } from '@atlaskit/menu';
11
+ import { N30 } from '@atlaskit/theme/colors';
12
+ const buttonStyles = css({
13
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
14
+ '& > button:hover': {
15
+ backgroundColor: `var(--ds-background-neutral-subtle-hovered, ${N30})`
16
+ }
17
+ });
18
+ export const ViewMore = ({
19
+ onClick
20
+ }) => {
21
+ const {
22
+ formatMessage
23
+ } = useIntl();
24
+ return jsx(Section, {
25
+ hasSeparator: true
26
+ }, jsx("span", {
27
+ css: buttonStyles
28
+ }, jsx(ButtonItem, {
29
+ onClick: onClick,
30
+ iconBefore: jsx(ShowMoreHorizontalIcon, {
31
+ label: ""
32
+ }),
33
+ "aria-describedby": formatMessage(messages.viewMore),
34
+ "data-testid": "quick-insert-view-more-elements-item"
35
+ }, formatMessage(messages.viewMore))));
36
+ };
@@ -11,8 +11,10 @@ import { css, jsx } from '@emotion/react';
11
11
  import { injectIntl, useIntl } from 'react-intl-next';
12
12
  import { CellMeasurer, CellMeasurerCache } from 'react-virtualized/dist/commonjs/CellMeasurer';
13
13
  import { List } from 'react-virtualized/dist/commonjs/List';
14
+ import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
14
15
  import { SelectItemMode, typeAheadListMessages } from '@atlaskit/editor-common/type-ahead';
15
16
  import { MenuGroup } from '@atlaskit/menu';
17
+ import { Text, Box } from '@atlaskit/primitives';
16
18
  import { updateSelectedIndex } from '../pm-plugins/commands/update-selected-index';
17
19
  import { TYPE_AHEAD_DECORATION_ELEMENT_ID } from '../pm-plugins/constants';
18
20
  import { getTypeAheadListAriaLabels, moveSelectedIndex } from '../pm-plugins/utils';
@@ -50,7 +52,8 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref2) {
50
52
  decorationElement = _ref2.decorationElement,
51
53
  triggerHandler = _ref2.triggerHandler,
52
54
  moreElementsInQuickInsertViewEnabled = _ref2.moreElementsInQuickInsertViewEnabled,
53
- api = _ref2.api;
55
+ api = _ref2.api,
56
+ showViewMore = _ref2.showViewMore;
54
57
  var listRef = useRef();
55
58
  var listContainerRef = useRef(null);
56
59
  var lastVisibleIndexes = useRef({
@@ -277,13 +280,21 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref2) {
277
280
  return null;
278
281
  }
279
282
  var menuGroupId = ((_decorationElement$qu2 = decorationElement.querySelector("[role='combobox']")) === null || _decorationElement$qu2 === void 0 ? void 0 : _decorationElement$qu2.getAttribute('aria-controls')) || TYPE_AHEAD_DECORATION_ELEMENT_ID;
280
- return jsx(MenuGroup, {
281
- "aria-label": popupAriaLabel,
282
- "aria-relevant": "additions removals"
283
- }, jsx("div", {
284
- id: menuGroupId,
285
- ref: listContainerRef
286
- }, jsx(List, {
283
+ var EmptyResultView = jsx(Box, {
284
+ paddingBlock: "space.150",
285
+ paddingInline: "space.250"
286
+ }, jsx(Text, {
287
+ align: "center",
288
+ as: "p"
289
+ }, intl.formatMessage(typeAheadListMessages.emptySearchResults)), jsx(Text, {
290
+ align: "center",
291
+ as: "p"
292
+ }, intl.formatMessage(typeAheadListMessages.emptySearchResultsSuggestion, {
293
+ buttonName: jsx(Text, {
294
+ weight: "medium"
295
+ }, intl.formatMessage(messages.viewMore))
296
+ })));
297
+ var ListContent = jsx(List, {
287
298
  rowRenderer: renderRow,
288
299
  ref: listRef,
289
300
  rowCount: items.length,
@@ -313,7 +324,14 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref2) {
313
324
  }
314
325
  }
315
326
  }), moreElementsInQuickInsertViewEnabled && list]
316
- }), jsx(TypeaheadAssistiveTextPureComponent, {
327
+ });
328
+ return jsx(MenuGroup, {
329
+ "aria-label": popupAriaLabel,
330
+ "aria-relevant": "additions removals"
331
+ }, jsx("div", {
332
+ id: menuGroupId,
333
+ ref: listContainerRef
334
+ }, !showViewMore || items.length ? ListContent : EmptyResultView, jsx(TypeaheadAssistiveTextPureComponent, {
317
335
  numberOfResults: items.length.toString()
318
336
  })));
319
337
  });
@@ -1,6 +1,7 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import React from 'react';
3
- import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
3
+ import { SelectItemMode, TypeAheadAvailableNodes } from '@atlaskit/editor-common/type-ahead';
4
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
4
5
  import { updateSelectedIndex } from '../pm-plugins/commands/update-selected-index';
5
6
  import { useItemInsert } from './hooks/use-item-insert';
6
7
  import { TypeAheadPopup } from './TypeAheadPopup';
@@ -70,7 +71,11 @@ export var TypeAheadMenu = /*#__PURE__*/React.memo(function (_ref) {
70
71
  return;
71
72
  }
72
73
  }, [isOpen, query, onItemMatch]);
73
- if (!isOpen || !triggerHandler || !(decorationElement instanceof HTMLElement) || items.length === 0 && !errorInfo) {
74
+
75
+ // @ts-ignore
76
+ var openElementBrowserModal = triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.openElementBrowserModal;
77
+ var showViewMore = (triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.id) === TypeAheadAvailableNodes.QUICK_INSERT && !!openElementBrowserModal && editorExperiment('platform_editor_controls', 'variant1');
78
+ if (!isOpen || !triggerHandler || !(decorationElement instanceof HTMLElement) || !showViewMore && items.length === 0 && !errorInfo) {
74
79
  return null;
75
80
  }
76
81
  return /*#__PURE__*/React.createElement(TypeAheadPopup, {
@@ -88,6 +93,7 @@ export var TypeAheadMenu = /*#__PURE__*/React.memo(function (_ref) {
88
93
  decorationSet: decorationSet,
89
94
  isEmptyQuery: !query,
90
95
  cancel: cancel,
91
- api: api
96
+ api: api,
97
+ showViewMore: showViewMore
92
98
  });
93
99
  });
@@ -18,7 +18,9 @@ import { N0, N50A, N60A } from '@atlaskit/theme/colors';
18
18
  import { CloseSelectionOptions, TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE, TYPE_AHEAD_POPUP_CONTENT_CLASS } from '../pm-plugins/constants';
19
19
  import { TypeAheadErrorFallback } from './TypeAheadErrorFallback';
20
20
  import { TypeAheadList } from './TypeAheadList';
21
+ import { ViewMore } from './ViewMore';
21
22
  var DEFAULT_TYPEAHEAD_MENU_HEIGHT = 380;
23
+ var VIEWMORE_BUTTON_HEIGHT = 53;
22
24
  var DEFAULT_TYPEAHEAD_MENU_HEIGHT_NEW = 480;
23
25
  var ITEM_PADDING = 12;
24
26
  var typeAheadContent = css({
@@ -35,6 +37,10 @@ var typeAheadContent = css({
35
37
  var typeAheadContentOverride = css({
36
38
  maxHeight: "".concat(DEFAULT_TYPEAHEAD_MENU_HEIGHT_NEW, "px")
37
39
  });
40
+ var typeAheadWrapperWithViewMoreOverride = css({
41
+ display: 'flex',
42
+ flexDirection: 'column'
43
+ });
38
44
  var Highlight = function Highlight(_ref) {
39
45
  var state = _ref.state,
40
46
  triggerHandler = _ref.triggerHandler;
@@ -57,7 +63,8 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
57
63
  onItemInsert = props.onItemInsert,
58
64
  isEmptyQuery = props.isEmptyQuery,
59
65
  cancel = props.cancel,
60
- api = props.api;
66
+ api = props.api,
67
+ showViewMore = props.showViewMore;
61
68
  var ref = useRef(null);
62
69
  var _useSharedPluginState = useSharedPluginState(api, ['featureFlags']),
63
70
  featureFlagsState = _useSharedPluginState.featureFlagsState;
@@ -119,6 +126,12 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
119
126
  _useState2 = _slicedToArray(_useState, 2),
120
127
  fitHeight = _useState2[0],
121
128
  setFitHeight = _useState2[1];
129
+ var fitHeightWithViewMore = useMemo(function () {
130
+ if (showViewMore) {
131
+ return fitHeight - VIEWMORE_BUTTON_HEIGHT;
132
+ }
133
+ return fitHeight;
134
+ }, [fitHeight, showViewMore]);
122
135
  var getFitHeight = useCallback(function () {
123
136
  if (!anchorElement || !popupsMountPoint) {
124
137
  return;
@@ -258,6 +271,19 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
258
271
  element === null || element === void 0 || element.removeEventListener('keydown', escape);
259
272
  };
260
273
  }, [ref, cancel]);
274
+
275
+ // @ts-ignore
276
+ var openElementBrowserModal = triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.openElementBrowserModal;
277
+ var onViewMoreClick = useCallback(function () {
278
+ // TODO: when clean up, remove config in quick insert plugin
279
+ // platform/packages/editor/editor-plugin-quick-insert/src/quickInsertPlugin.tsx (typeAhead.openElementBrowserModal)
280
+ openElementBrowserModal === null || openElementBrowserModal === void 0 || openElementBrowserModal();
281
+ cancel({
282
+ addPrefixTrigger: false,
283
+ setSelectionAt: CloseSelectionOptions.AFTER_TEXT_INSERTED,
284
+ forceFocusOnEditor: false
285
+ });
286
+ }, [openElementBrowserModal, cancel]);
261
287
  return jsx(Popup, {
262
288
  zIndex: akEditorFloatingDialogZIndex,
263
289
  target: anchorElement,
@@ -270,7 +296,7 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
270
296
  ariaLabel: null,
271
297
  preventOverflow: true
272
298
  }, jsx("div", {
273
- css: [typeAheadContent, moreElementsInQuickInsertViewEnabled && typeAheadContentOverride]
299
+ css: [typeAheadContent, moreElementsInQuickInsertViewEnabled && typeAheadContentOverride, showViewMore && typeAheadWrapperWithViewMoreOverride]
274
300
  // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
275
301
  ,
276
302
  tabIndex: 0
@@ -285,12 +311,15 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
285
311
  items: items,
286
312
  selectedIndex: selectedIndex,
287
313
  onItemClick: onItemInsert,
288
- fitHeight: fitHeight,
314
+ fitHeight: fitHeightWithViewMore,
289
315
  editorView: editorView,
290
316
  decorationElement: anchorElement,
291
317
  triggerHandler: triggerHandler,
292
318
  moreElementsInQuickInsertViewEnabled: moreElementsInQuickInsertViewEnabled,
293
- api: api
319
+ api: api,
320
+ showViewMore: showViewMore
321
+ }), showViewMore && jsx(ViewMore, {
322
+ onClick: onViewMoreClick
294
323
  }))));
295
324
  });
296
325
  TypeAheadPopup.displayName = 'TypeAheadPopup';
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
5
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
6
+ import { css, jsx } from '@emotion/react';
7
+ import { useIntl } from 'react-intl-next';
8
+ import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
9
+ import ShowMoreHorizontalIcon from '@atlaskit/icon/core/migration/show-more-horizontal--editor-more';
10
+ import { ButtonItem, Section } from '@atlaskit/menu';
11
+ import { N30 } from '@atlaskit/theme/colors';
12
+ var buttonStyles = css({
13
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
14
+ '& > button:hover': {
15
+ backgroundColor: "var(--ds-background-neutral-subtle-hovered, ".concat(N30, ")")
16
+ }
17
+ });
18
+ export var ViewMore = function ViewMore(_ref) {
19
+ var onClick = _ref.onClick;
20
+ var _useIntl = useIntl(),
21
+ formatMessage = _useIntl.formatMessage;
22
+ return jsx(Section, {
23
+ hasSeparator: true
24
+ }, jsx("span", {
25
+ css: buttonStyles
26
+ }, jsx(ButtonItem, {
27
+ onClick: onClick,
28
+ iconBefore: jsx(ShowMoreHorizontalIcon, {
29
+ label: ""
30
+ }),
31
+ "aria-describedby": formatMessage(messages.viewMore),
32
+ "data-testid": "quick-insert-view-more-elements-item"
33
+ }, formatMessage(messages.viewMore))));
34
+ };
@@ -19,6 +19,7 @@ export declare const TypeAheadList: React.FC<import("react-intl-next").WithIntlP
19
19
  triggerHandler?: TypeAheadHandler | undefined;
20
20
  moreElementsInQuickInsertViewEnabled?: boolean | undefined;
21
21
  api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
22
+ showViewMore?: boolean | undefined;
22
23
  } & WrappedComponentProps>> & {
23
24
  WrappedComponent: React.ComponentType<{
24
25
  items: Array<TypeAheadItem>;
@@ -30,5 +31,6 @@ export declare const TypeAheadList: React.FC<import("react-intl-next").WithIntlP
30
31
  triggerHandler?: TypeAheadHandler | undefined;
31
32
  moreElementsInQuickInsertViewEnabled?: boolean | undefined;
32
33
  api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
34
+ showViewMore?: boolean | undefined;
33
35
  } & WrappedComponentProps>;
34
36
  };
@@ -30,6 +30,7 @@ type TypeAheadPopupProps = {
30
30
  forceFocusOnEditor: boolean;
31
31
  }) => void;
32
32
  api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
33
+ showViewMore?: boolean;
33
34
  };
34
35
  export declare const TypeAheadPopup: React.MemoExoticComponent<(props: TypeAheadPopupProps) => jsx.JSX.Element>;
35
36
  export {};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
5
+ import { jsx } from '@emotion/react';
6
+ export declare const ViewMore: ({ onClick, }: {
7
+ onClick: (e: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => void;
8
+ }) => jsx.JSX.Element;
@@ -19,6 +19,7 @@ export declare const TypeAheadList: React.FC<import("react-intl-next").WithIntlP
19
19
  triggerHandler?: TypeAheadHandler | undefined;
20
20
  moreElementsInQuickInsertViewEnabled?: boolean | undefined;
21
21
  api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
22
+ showViewMore?: boolean | undefined;
22
23
  } & WrappedComponentProps>> & {
23
24
  WrappedComponent: React.ComponentType<{
24
25
  items: Array<TypeAheadItem>;
@@ -30,5 +31,6 @@ export declare const TypeAheadList: React.FC<import("react-intl-next").WithIntlP
30
31
  triggerHandler?: TypeAheadHandler | undefined;
31
32
  moreElementsInQuickInsertViewEnabled?: boolean | undefined;
32
33
  api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
34
+ showViewMore?: boolean | undefined;
33
35
  } & WrappedComponentProps>;
34
36
  };
@@ -30,6 +30,7 @@ type TypeAheadPopupProps = {
30
30
  forceFocusOnEditor: boolean;
31
31
  }) => void;
32
32
  api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
33
+ showViewMore?: boolean;
33
34
  };
34
35
  export declare const TypeAheadPopup: React.MemoExoticComponent<(props: TypeAheadPopupProps) => jsx.JSX.Element>;
35
36
  export {};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
5
+ import { jsx } from '@emotion/react';
6
+ export declare const ViewMore: ({ onClick, }: {
7
+ onClick: (e: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => void;
8
+ }) => jsx.JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-type-ahead",
3
- "version": "2.0.5",
3
+ "version": "2.1.0",
4
4
  "description": "Type-ahead plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,10 +33,10 @@
33
33
  ".": "./src/index.ts"
34
34
  },
35
35
  "dependencies": {
36
- "@atlaskit/adf-schema": "^47.2.1",
37
- "@atlaskit/editor-common": "^100.4.0",
36
+ "@atlaskit/adf-schema": "^47.6.0",
37
+ "@atlaskit/editor-common": "^100.5.0",
38
38
  "@atlaskit/editor-element-browser": "^0.1.0",
39
- "@atlaskit/editor-plugin-analytics": "^2.0.0",
39
+ "@atlaskit/editor-plugin-analytics": "^2.1.0",
40
40
  "@atlaskit/editor-plugin-connectivity": "^2.0.0",
41
41
  "@atlaskit/editor-plugin-context-panel": "^3.0.0",
42
42
  "@atlaskit/editor-prosemirror": "7.0.0",
@@ -48,7 +48,7 @@
48
48
  "@atlaskit/primitives": "^14.1.0",
49
49
  "@atlaskit/prosemirror-input-rules": "^3.3.0",
50
50
  "@atlaskit/theme": "^17.0.0",
51
- "@atlaskit/tmp-editor-statsig": "^3.3.0",
51
+ "@atlaskit/tmp-editor-statsig": "^3.4.0",
52
52
  "@atlaskit/tokens": "^4.3.0",
53
53
  "@babel/runtime": "^7.0.0",
54
54
  "@emotion/react": "^11.7.1",