@atlaskit/editor-plugin-type-ahead 2.7.10 → 2.7.12

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.
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { SelectItemMode, TypeAheadAvailableNodes } from '@atlaskit/editor-common/type-ahead';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
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';
@@ -72,8 +73,15 @@ export const TypeAheadMenu = /*#__PURE__*/React.memo(({
72
73
 
73
74
  // @ts-ignore
74
75
  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) {
76
+ let showMoreOptionsButton = false;
77
+ if (editorExperiment('platform_editor_controls', 'variant1')) {
78
+ if (fg('platform_editor_controls_patch_12')) {
79
+ showMoreOptionsButton = !!(triggerHandler !== null && triggerHandler !== void 0 && triggerHandler.getMoreOptionsButtonConfig);
80
+ } else {
81
+ showMoreOptionsButton = (triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.id) === TypeAheadAvailableNodes.QUICK_INSERT && !!openElementBrowserModal;
82
+ }
83
+ }
84
+ if (!isOpen || !triggerHandler || !(decorationElement instanceof HTMLElement) || !openElementBrowserModal && items.length === 0 && !errorInfo) {
77
85
  return null;
78
86
  }
79
87
  return /*#__PURE__*/React.createElement(TypeAheadPopup, {
@@ -92,6 +100,6 @@ export const TypeAheadMenu = /*#__PURE__*/React.memo(({
92
100
  isEmptyQuery: !query,
93
101
  cancel: cancel,
94
102
  api: api,
95
- showViewMore: showViewMore
103
+ showMoreOptionsButton: showMoreOptionsButton
96
104
  });
97
105
  });
@@ -83,7 +83,7 @@ export const TypeAheadPopup = /*#__PURE__*/React.memo(props => {
83
83
  isEmptyQuery,
84
84
  cancel,
85
85
  api,
86
- showViewMore
86
+ showMoreOptionsButton
87
87
  } = props;
88
88
  const ref = useRef(null);
89
89
  const {
@@ -147,11 +147,11 @@ export const TypeAheadPopup = /*#__PURE__*/React.memo(props => {
147
147
  triggerHandler]);
148
148
  const [fitHeight, setFitHeight] = useState(defaultMenuHeight);
149
149
  const fitHeightWithViewMore = useMemo(() => {
150
- if (showViewMore) {
150
+ if (showMoreOptionsButton) {
151
151
  return fitHeight - VIEWMORE_BUTTON_HEIGHT;
152
152
  }
153
153
  return fitHeight;
154
- }, [fitHeight, showViewMore]);
154
+ }, [fitHeight, showMoreOptionsButton]);
155
155
  const getFitHeight = useCallback(() => {
156
156
  if (!anchorElement || !popupsMountPoint) {
157
157
  return;
@@ -314,20 +314,21 @@ export const TypeAheadPopup = /*#__PURE__*/React.memo(props => {
314
314
  closeTypeAhead(tr);
315
315
  editorView.dispatch(tr);
316
316
  };
317
- const onViewMoreClick = useCallback(() => {
318
- close(editorView);
319
- if (openElementBrowserModal && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_4')) {
317
+ const onMoreOptionsClicked = useCallback(() => {
318
+ if (
319
+ // eslint-disable-next-line @atlaskit/platform/no-preconditioning
320
+ openElementBrowserModal && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_4') && (!fg('platform_editor_controls_patch_12') || triggerHandler.id === TypeAheadAvailableNodes.QUICK_INSERT)) {
320
321
  activityStateRef.current = {
321
322
  inputMethod: INPUT_METHOD.MOUSE,
322
323
  closeAction: ACTION.VIEW_MORE,
323
324
  invocationMethod: activityStateRef.current.invocationMethod
324
325
  };
325
326
  }
326
-
327
- // TODO: ED-26959 - when clean up, remove config in quick insert plugin
328
- // platform/packages/editor/editor-plugin-quick-insert/src/quickInsertPlugin.tsx (typeAhead.openElementBrowserModal)
329
- openElementBrowserModal === null || openElementBrowserModal === void 0 ? void 0 : openElementBrowserModal();
330
- }, [editorView, openElementBrowserModal]);
327
+ if (!fg('platform_editor_controls_patch_12')) {
328
+ close(editorView);
329
+ openElementBrowserModal === null || openElementBrowserModal === void 0 ? void 0 : openElementBrowserModal();
330
+ }
331
+ }, [editorView, openElementBrowserModal, triggerHandler.id]);
331
332
  return jsx(Popup, {
332
333
  zIndex: akEditorFloatingDialogZIndex,
333
334
  target: anchorElement,
@@ -354,7 +355,7 @@ export const TypeAheadPopup = /*#__PURE__*/React.memo(props => {
354
355
  }
355
356
  }
356
357
  }, jsx("div", {
357
- css: [typeAheadContent, moreElementsInQuickInsertViewEnabled && typeAheadContentOverride, showViewMore && typeAheadWrapperWithViewMoreOverride]
358
+ css: [typeAheadContent, moreElementsInQuickInsertViewEnabled && typeAheadContentOverride, showMoreOptionsButton && typeAheadWrapperWithViewMoreOverride]
358
359
  // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
359
360
  ,
360
361
  tabIndex: 0
@@ -384,8 +385,8 @@ export const TypeAheadPopup = /*#__PURE__*/React.memo(props => {
384
385
  triggerHandler: triggerHandler,
385
386
  moreElementsInQuickInsertViewEnabled: moreElementsInQuickInsertViewEnabled,
386
387
  api: api,
387
- showViewMore: showViewMore,
388
- onViewMoreClick: onViewMoreClick
388
+ showMoreOptionsButton: showMoreOptionsButton,
389
+ onMoreOptionsClicked: onMoreOptionsClicked
389
390
  }))));
390
391
  });
391
392
  TypeAheadPopup.displayName = 'TypeAheadPopup';
@@ -27,12 +27,19 @@ export const WrapperTypeAhead = /*#__PURE__*/React.memo(({
27
27
  }) => {
28
28
  // @ts-ignore
29
29
  const openElementBrowserModal = triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.openElementBrowserModal;
30
- const showViewMore = (triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.id) === TypeAheadAvailableNodes.QUICK_INSERT && !!openElementBrowserModal && editorExperiment('platform_editor_controls', 'variant1');
30
+ let showMoreOptionsButton = false;
31
+ if (editorExperiment('platform_editor_controls', 'variant1')) {
32
+ if (fg('platform_editor_controls_patch_12')) {
33
+ showMoreOptionsButton = !!(triggerHandler !== null && triggerHandler !== void 0 && triggerHandler.getMoreOptionsButtonConfig);
34
+ } else {
35
+ showMoreOptionsButton = (triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.id) === TypeAheadAvailableNodes.QUICK_INSERT && !!openElementBrowserModal;
36
+ }
37
+ }
31
38
  const [closed, setClosed] = useState(false);
32
39
  const [query, setQuery] = useState(reopenQuery || '');
33
40
  const queryRef = useRef(query);
34
41
  const editorViewRef = useRef(editorView);
35
- const items = useLoadItems(triggerHandler, editorView, query, showViewMore);
42
+ const items = useLoadItems(triggerHandler, editorView, query, showMoreOptionsButton);
36
43
  useEffect(() => {
37
44
  if (!closed && fg('platform_editor_ease_of_use_metrics')) {
38
45
  var _api$metrics;
@@ -1,23 +1,17 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
1
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
5
- import { fg } from '@atlaskit/platform-feature-flags';
6
2
  export var fireTypeAheadClosedAnalyticsEvent = function fireTypeAheadClosedAnalyticsEvent(api, closeAction, hasQuery, inputMethod) {
7
3
  var _api$analytics;
8
4
  var invocationMethod = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
9
- var additionalAttributes = fg('platform_editor_controls_patch_analytics') ? {
10
- invocationMethod: invocationMethod
11
- } : {};
12
5
  api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent({
13
6
  action: ACTION.CLOSED,
14
7
  actionSubject: ACTION_SUBJECT.TYPEAHEAD,
15
8
  actionSubjectId: ACTION_SUBJECT_ID.TYPEAHEAD_QUICK_INSERT,
16
- attributes: _objectSpread({
9
+ attributes: {
17
10
  inputMethod: inputMethod,
18
11
  closeAction: closeAction,
19
- hasQuery: hasQuery
20
- }, additionalAttributes),
12
+ hasQuery: hasQuery,
13
+ invocationMethod: invocationMethod
14
+ },
21
15
  eventType: EVENT_TYPE.TRACK
22
16
  });
23
17
  };
@@ -0,0 +1,71 @@
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
5
+ import { useEffect, useRef } from 'react';
6
+
7
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
8
+ import { css, jsx } from '@emotion/react';
9
+ import { ButtonItem, Section } from '@atlaskit/menu';
10
+ import { N30 } from '@atlaskit/theme/colors';
11
+ var buttonStyles = css({
12
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
13
+ '& > button:hover': {
14
+ backgroundColor: "var(--ds-background-neutral-subtle-hovered, ".concat(N30, ")")
15
+ },
16
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
17
+ '& > button:focus': {
18
+ backgroundColor: "var(--ds-background-neutral-subtle-hovered, ".concat(N30, ")")
19
+ }
20
+ });
21
+ export var MoreOptions = function MoreOptions(_ref) {
22
+ var onClick = _ref.onClick,
23
+ isFocused = _ref.isFocused,
24
+ title = _ref.title,
25
+ ariaLabel = _ref.ariaLabel,
26
+ iconBefore = _ref.iconBefore;
27
+ var ref = useRef(null);
28
+ useEffect(function () {
29
+ if (isFocused && ref.current) {
30
+ ref.current.focus();
31
+ }
32
+ }, [isFocused]);
33
+ useEffect(function () {
34
+ if (!ref.current) {
35
+ return;
36
+ }
37
+ var element = ref.current;
38
+ var handleEnter = function handleEnter(e) {
39
+ if (e.key === 'Enter') {
40
+ onClick();
41
+ // Prevent keydown listener in TypeaheadList from handling Enter pressed
42
+ e.stopPropagation();
43
+ } else if (e.key === 'Tab') {
44
+ // TypeaheadList will try to insert selected item on Tab press
45
+ // hence stop propagation to prevent that and treat this as noop
46
+ e.stopPropagation();
47
+ e.preventDefault();
48
+ }
49
+ };
50
+
51
+ // Ignored via go/ees005
52
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
53
+ element === null || element === void 0 || element.addEventListener('keydown', handleEnter);
54
+ return function () {
55
+ // Ignored via go/ees005
56
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
57
+ element === null || element === void 0 || element.removeEventListener('keydown', handleEnter);
58
+ };
59
+ });
60
+ return jsx(Section, {
61
+ hasSeparator: true
62
+ }, jsx("span", {
63
+ css: buttonStyles
64
+ }, jsx(ButtonItem, {
65
+ ref: ref,
66
+ onClick: onClick,
67
+ iconBefore: iconBefore,
68
+ "aria-label": ariaLabel,
69
+ testId: "type-ahead-more-options-button"
70
+ }, title)));
71
+ };
@@ -18,10 +18,12 @@ import { AssistiveText } from '@atlaskit/editor-common/ui';
18
18
  import { MenuGroup } from '@atlaskit/menu';
19
19
  import { fg } from '@atlaskit/platform-feature-flags';
20
20
  import { Text, Box } from '@atlaskit/primitives/compiled';
21
+ import { closeTypeAhead } from '../pm-plugins/commands/close-type-ahead';
21
22
  import { updateSelectedIndex } from '../pm-plugins/commands/update-selected-index';
22
23
  import { TYPE_AHEAD_DECORATION_ELEMENT_ID } from '../pm-plugins/constants';
23
24
  import { getTypeAheadListAriaLabels, moveSelectedIndex } from '../pm-plugins/utils';
24
25
  import { ListRow } from './ListRow';
26
+ import { MoreOptions } from './MoreOptions';
25
27
  import { TypeAheadListItem } from './TypeAheadListItem';
26
28
  import { ViewMore } from './ViewMore';
27
29
  var LIST_ITEM_ESTIMATED_HEIGHT = 64;
@@ -46,7 +48,7 @@ var TypeaheadAssistiveTextPureComponent = /*#__PURE__*/React.memo(function (_ref
46
48
  });
47
49
  });
48
50
  var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref2) {
49
- var _decorationElement$qu2;
51
+ var _triggerHandler$getMo, _decorationElement$qu2;
50
52
  var items = _ref2.items,
51
53
  selectedIndex = _ref2.selectedIndex,
52
54
  editorView = _ref2.editorView,
@@ -57,8 +59,8 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref2) {
57
59
  triggerHandler = _ref2.triggerHandler,
58
60
  moreElementsInQuickInsertViewEnabled = _ref2.moreElementsInQuickInsertViewEnabled,
59
61
  api = _ref2.api,
60
- showViewMore = _ref2.showViewMore,
61
- onViewMoreClick = _ref2.onViewMoreClick;
62
+ showMoreOptionsButton = _ref2.showMoreOptionsButton,
63
+ onMoreOptionsClicked = _ref2.onMoreOptionsClicked;
62
64
  var listRef = useRef();
63
65
  var listContainerRef = useRef(null);
64
66
  var lastVisibleIndexes = useRef({
@@ -69,7 +71,7 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref2) {
69
71
  });
70
72
 
71
73
  // Exclude view more item from the count
72
- var itemsLength = showViewMore ? items.length - 1 : items.length;
74
+ var itemsLength = showMoreOptionsButton ? Math.max(items.length - 1, 0) : items.length;
73
75
  var estimatedHeight = itemsLength * LIST_ITEM_ESTIMATED_HEIGHT;
74
76
  var _useState = useState(Math.min(estimatedHeight, fitHeight)),
75
77
  _useState2 = _slicedToArray(_useState, 2),
@@ -136,7 +138,7 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref2) {
136
138
  // to calculate each height. THen, we can schedule a new frame when this one finishs.
137
139
  requestAnimationFrame(function () {
138
140
  requestAnimationFrame(function () {
139
- var isViewMoreSelected = showViewMore && selectedIndex === itemsLength;
141
+ var isViewMoreSelected = showMoreOptionsButton && selectedIndex === itemsLength;
140
142
  var isSelectedItemVisible = selectedIndex >= lastVisibleStartIndex && selectedIndex <= lastVisibleStopIndex ||
141
143
  // view more is always visible, hence no scrolling
142
144
  isViewMoreSelected;
@@ -149,7 +151,7 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref2) {
149
151
  }
150
152
  });
151
153
  });
152
- }, [selectedIndex, lastVisibleStartIndex, lastVisibleStopIndex, itemsLength, showViewMore]);
154
+ }, [selectedIndex, lastVisibleStartIndex, lastVisibleStopIndex, itemsLength, showMoreOptionsButton]);
153
155
  var _onMouseMove = function onMouseMove(event, index) {
154
156
  event.preventDefault();
155
157
  event.stopPropagation();
@@ -162,7 +164,7 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref2) {
162
164
  if (!listRef.current) {
163
165
  return;
164
166
  }
165
- var isViewMoreSelected = showViewMore && selectedIndex === itemsLength;
167
+ var isViewMoreSelected = showMoreOptionsButton && selectedIndex === itemsLength;
166
168
  var isSelectedItemVisible = selectedIndex >= lastVisibleStartIndex && selectedIndex <= lastVisibleStopIndex ||
167
169
  // view more is always visible, hence no scrolling
168
170
  isViewMoreSelected;
@@ -173,7 +175,7 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref2) {
173
175
  } else if (selectedIndex === -1) {
174
176
  listRef.current.scrollToRow(0);
175
177
  }
176
- }, [selectedIndex, lastVisibleStartIndex, lastVisibleStopIndex, itemsLength, showViewMore]);
178
+ }, [selectedIndex, lastVisibleStartIndex, lastVisibleStopIndex, itemsLength, showMoreOptionsButton]);
177
179
  useLayoutEffect(function () {
178
180
  setCache(new CellMeasurerCache({
179
181
  fixedWidth: true,
@@ -192,14 +194,14 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref2) {
192
194
  }, [items]);
193
195
  useLayoutEffect(function () {
194
196
  // Exclude view more item from the count
195
- var itemsToRender = showViewMore ? items.slice(0, -1) : items;
197
+ var itemsToRender = showMoreOptionsButton ? items.slice(0, -1) : items;
196
198
  var height = Math.min(itemsToRender.reduce(function (prevValue, currentValue, index) {
197
199
  return prevValue + cache.rowHeight({
198
200
  index: index
199
201
  });
200
202
  }, 0), fitHeight);
201
203
  setHeight(height);
202
- }, [items, cache, fitHeight, showViewMore]);
204
+ }, [items, cache, fitHeight, showMoreOptionsButton]);
203
205
  useLayoutEffect(function () {
204
206
  if (!listContainerRef.current) {
205
207
  return;
@@ -259,13 +261,27 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref2) {
259
261
  return item.isDisabledOffline !== true;
260
262
  });
261
263
  }, [items]);
262
- var renderRow = function renderRow(_ref4) {
263
- var index = _ref4.index,
264
- key = _ref4.key,
265
- style = _ref4.style,
266
- parent = _ref4.parent,
267
- isScrolling = _ref4.isScrolling,
268
- isVisible = _ref4.isVisible;
264
+ var config = triggerHandler === null || triggerHandler === void 0 || (_triggerHandler$getMo = triggerHandler.getMoreOptionsButtonConfig) === null || _triggerHandler$getMo === void 0 ? void 0 : _triggerHandler$getMo.call(triggerHandler, intl);
265
+ var handleClick = function handleClick() {
266
+ if (onMoreOptionsClicked) {
267
+ onMoreOptionsClicked();
268
+ }
269
+ api === null || api === void 0 || api.core.actions.execute(function (_ref4) {
270
+ var tr = _ref4.tr;
271
+ closeTypeAhead(tr);
272
+ config === null || config === void 0 || config.onClick({
273
+ tr: tr
274
+ });
275
+ return tr;
276
+ });
277
+ };
278
+ var renderRow = function renderRow(_ref5) {
279
+ var index = _ref5.index,
280
+ key = _ref5.key,
281
+ style = _ref5.style,
282
+ parent = _ref5.parent,
283
+ isScrolling = _ref5.isScrolling,
284
+ isVisible = _ref5.isVisible;
269
285
  var currentItem = items[index];
270
286
  return jsx(CellMeasurer, {
271
287
  key: key,
@@ -273,9 +289,9 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref2) {
273
289
  parent: parent,
274
290
  columnIndex: 0,
275
291
  rowIndex: index
276
- }, fg('platform_editor_typeahead_dynamic_height_fix') ? function (_ref5) {
277
- var measure = _ref5.measure,
278
- registerChild = _ref5.registerChild;
292
+ }, fg('platform_editor_typeahead_dynamic_height_fix') ? function (_ref6) {
293
+ var measure = _ref6.measure,
294
+ registerChild = _ref6.registerChild;
279
295
  return jsx(ListRow, {
280
296
  registerChild: registerChild,
281
297
  measure: measure,
@@ -384,8 +400,14 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref2) {
384
400
  }, jsx("div", {
385
401
  id: menuGroupId,
386
402
  ref: listContainerRef
387
- }, !showViewMore || itemsLength ? ListContent : EmptyResultView, showViewMore && onViewMoreClick && jsx(ViewMore, {
388
- onClick: onViewMoreClick,
403
+ }, !showMoreOptionsButton || itemsLength ? ListContent : EmptyResultView, fg('platform_editor_controls_patch_12') ? showMoreOptionsButton && config && jsx(MoreOptions, {
404
+ title: config.title,
405
+ ariaLabel: config.ariaLabel,
406
+ onClick: handleClick,
407
+ isFocused: selectedIndex === itemsLength,
408
+ iconBefore: config.iconBefore
409
+ }) : showMoreOptionsButton && onMoreOptionsClicked && jsx(ViewMore, {
410
+ onClick: onMoreOptionsClicked,
389
411
  isFocused: selectedIndex === itemsLength
390
412
  }), jsx(TypeaheadAssistiveTextPureComponent, {
391
413
  numberOfResults: itemsLength.toString()
@@ -1,6 +1,7 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import React from 'react';
3
3
  import { SelectItemMode, TypeAheadAvailableNodes } from '@atlaskit/editor-common/type-ahead';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
4
5
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
6
  import { updateSelectedIndex } from '../pm-plugins/commands/update-selected-index';
6
7
  import { useItemInsert } from './hooks/use-item-insert';
@@ -74,8 +75,15 @@ export var TypeAheadMenu = /*#__PURE__*/React.memo(function (_ref) {
74
75
 
75
76
  // @ts-ignore
76
77
  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) {
78
+ var showMoreOptionsButton = false;
79
+ if (editorExperiment('platform_editor_controls', 'variant1')) {
80
+ if (fg('platform_editor_controls_patch_12')) {
81
+ showMoreOptionsButton = !!(triggerHandler !== null && triggerHandler !== void 0 && triggerHandler.getMoreOptionsButtonConfig);
82
+ } else {
83
+ showMoreOptionsButton = (triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.id) === TypeAheadAvailableNodes.QUICK_INSERT && !!openElementBrowserModal;
84
+ }
85
+ }
86
+ if (!isOpen || !triggerHandler || !(decorationElement instanceof HTMLElement) || !openElementBrowserModal && items.length === 0 && !errorInfo) {
79
87
  return null;
80
88
  }
81
89
  return /*#__PURE__*/React.createElement(TypeAheadPopup, {
@@ -94,6 +102,6 @@ export var TypeAheadMenu = /*#__PURE__*/React.memo(function (_ref) {
94
102
  isEmptyQuery: !query,
95
103
  cancel: cancel,
96
104
  api: api,
97
- showViewMore: showViewMore
105
+ showMoreOptionsButton: showMoreOptionsButton
98
106
  });
99
107
  });
@@ -81,7 +81,7 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
81
81
  isEmptyQuery = props.isEmptyQuery,
82
82
  cancel = props.cancel,
83
83
  api = props.api,
84
- showViewMore = props.showViewMore;
84
+ showMoreOptionsButton = props.showMoreOptionsButton;
85
85
  var ref = useRef(null);
86
86
  var _useSharedState = useSharedState(api),
87
87
  moreElementsInQuickInsertView = _useSharedState.moreElementsInQuickInsertView;
@@ -150,11 +150,11 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
150
150
  fitHeight = _useState2[0],
151
151
  setFitHeight = _useState2[1];
152
152
  var fitHeightWithViewMore = useMemo(function () {
153
- if (showViewMore) {
153
+ if (showMoreOptionsButton) {
154
154
  return fitHeight - VIEWMORE_BUTTON_HEIGHT;
155
155
  }
156
156
  return fitHeight;
157
- }, [fitHeight, showViewMore]);
157
+ }, [fitHeight, showMoreOptionsButton]);
158
158
  var getFitHeight = useCallback(function () {
159
159
  if (!anchorElement || !popupsMountPoint) {
160
160
  return;
@@ -303,20 +303,21 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
303
303
  closeTypeAhead(tr);
304
304
  editorView.dispatch(tr);
305
305
  };
306
- var onViewMoreClick = useCallback(function () {
307
- close(editorView);
308
- if (openElementBrowserModal && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_4')) {
306
+ var onMoreOptionsClicked = useCallback(function () {
307
+ if (
308
+ // eslint-disable-next-line @atlaskit/platform/no-preconditioning
309
+ openElementBrowserModal && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_4') && (!fg('platform_editor_controls_patch_12') || triggerHandler.id === TypeAheadAvailableNodes.QUICK_INSERT)) {
309
310
  activityStateRef.current = {
310
311
  inputMethod: INPUT_METHOD.MOUSE,
311
312
  closeAction: ACTION.VIEW_MORE,
312
313
  invocationMethod: activityStateRef.current.invocationMethod
313
314
  };
314
315
  }
315
-
316
- // TODO: ED-26959 - when clean up, remove config in quick insert plugin
317
- // platform/packages/editor/editor-plugin-quick-insert/src/quickInsertPlugin.tsx (typeAhead.openElementBrowserModal)
318
- openElementBrowserModal === null || openElementBrowserModal === void 0 || openElementBrowserModal();
319
- }, [editorView, openElementBrowserModal]);
316
+ if (!fg('platform_editor_controls_patch_12')) {
317
+ close(editorView);
318
+ openElementBrowserModal === null || openElementBrowserModal === void 0 || openElementBrowserModal();
319
+ }
320
+ }, [editorView, openElementBrowserModal, triggerHandler.id]);
320
321
  return jsx(Popup, {
321
322
  zIndex: akEditorFloatingDialogZIndex,
322
323
  target: anchorElement,
@@ -343,7 +344,7 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
343
344
  }
344
345
  }
345
346
  }, jsx("div", {
346
- css: [typeAheadContent, moreElementsInQuickInsertViewEnabled && typeAheadContentOverride, showViewMore && typeAheadWrapperWithViewMoreOverride]
347
+ css: [typeAheadContent, moreElementsInQuickInsertViewEnabled && typeAheadContentOverride, showMoreOptionsButton && typeAheadWrapperWithViewMoreOverride]
347
348
  // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
348
349
  ,
349
350
  tabIndex: 0
@@ -373,8 +374,8 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
373
374
  triggerHandler: triggerHandler,
374
375
  moreElementsInQuickInsertViewEnabled: moreElementsInQuickInsertViewEnabled,
375
376
  api: api,
376
- showViewMore: showViewMore,
377
- onViewMoreClick: onViewMoreClick
377
+ showMoreOptionsButton: showMoreOptionsButton,
378
+ onMoreOptionsClicked: onMoreOptionsClicked
378
379
  }))));
379
380
  });
380
381
  TypeAheadPopup.displayName = 'TypeAheadPopup';
@@ -27,7 +27,14 @@ export var WrapperTypeAhead = /*#__PURE__*/React.memo(function (_ref) {
27
27
  api = _ref.api;
28
28
  // @ts-ignore
29
29
  var openElementBrowserModal = triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.openElementBrowserModal;
30
- var showViewMore = (triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.id) === TypeAheadAvailableNodes.QUICK_INSERT && !!openElementBrowserModal && editorExperiment('platform_editor_controls', 'variant1');
30
+ var showMoreOptionsButton = false;
31
+ if (editorExperiment('platform_editor_controls', 'variant1')) {
32
+ if (fg('platform_editor_controls_patch_12')) {
33
+ showMoreOptionsButton = !!(triggerHandler !== null && triggerHandler !== void 0 && triggerHandler.getMoreOptionsButtonConfig);
34
+ } else {
35
+ showMoreOptionsButton = (triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.id) === TypeAheadAvailableNodes.QUICK_INSERT && !!openElementBrowserModal;
36
+ }
37
+ }
31
38
  var _useState = useState(false),
32
39
  _useState2 = _slicedToArray(_useState, 2),
33
40
  closed = _useState2[0],
@@ -38,7 +45,7 @@ export var WrapperTypeAhead = /*#__PURE__*/React.memo(function (_ref) {
38
45
  setQuery = _useState4[1];
39
46
  var queryRef = useRef(query);
40
47
  var editorViewRef = useRef(editorView);
41
- var items = useLoadItems(triggerHandler, editorView, query, showViewMore);
48
+ var items = useLoadItems(triggerHandler, editorView, query, showMoreOptionsButton);
42
49
  useEffect(function () {
43
50
  if (!closed && fg('platform_editor_ease_of_use_metrics')) {
44
51
  var _api$metrics;
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import { jsx } from '@emotion/react';
3
+ type Props = {
4
+ onClick: () => void;
5
+ isFocused: boolean;
6
+ title: string;
7
+ ariaLabel?: string;
8
+ iconBefore?: React.ReactNode;
9
+ };
10
+ export declare const MoreOptions: ({ onClick, isFocused, title, ariaLabel, iconBefore }: Props) => jsx.JSX.Element;
11
+ export {};
@@ -20,8 +20,8 @@ export declare const TypeAheadList: React.FC<import("react-intl-next").WithIntlP
20
20
  triggerHandler?: TypeAheadHandler | undefined;
21
21
  moreElementsInQuickInsertViewEnabled?: boolean | undefined;
22
22
  api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
23
- showViewMore?: boolean | undefined;
24
- onViewMoreClick?: (() => void) | undefined;
23
+ showMoreOptionsButton?: boolean | undefined;
24
+ onMoreOptionsClicked?: (() => void) | undefined;
25
25
  } & WrappedComponentProps>> & {
26
26
  WrappedComponent: React.ComponentType<{
27
27
  items: Array<TypeAheadItem>;
@@ -33,7 +33,7 @@ export declare const TypeAheadList: React.FC<import("react-intl-next").WithIntlP
33
33
  triggerHandler?: TypeAheadHandler | undefined;
34
34
  moreElementsInQuickInsertViewEnabled?: boolean | undefined;
35
35
  api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
36
- showViewMore?: boolean | undefined;
37
- onViewMoreClick?: (() => void) | undefined;
36
+ showMoreOptionsButton?: boolean | undefined;
37
+ onMoreOptionsClicked?: (() => void) | undefined;
38
38
  } & WrappedComponentProps>;
39
39
  };
@@ -30,7 +30,7 @@ type TypeAheadPopupProps = {
30
30
  forceFocusOnEditor: boolean;
31
31
  }) => void;
32
32
  api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
33
- showViewMore?: boolean;
33
+ showMoreOptionsButton?: boolean;
34
34
  };
35
35
  export declare const TypeAheadPopup: React.MemoExoticComponent<(props: TypeAheadPopupProps) => jsx.JSX.Element>;
36
36
  export {};
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import { jsx } from '@emotion/react';
3
+ type Props = {
4
+ onClick: () => void;
5
+ isFocused: boolean;
6
+ title: string;
7
+ ariaLabel?: string;
8
+ iconBefore?: React.ReactNode;
9
+ };
10
+ export declare const MoreOptions: ({ onClick, isFocused, title, ariaLabel, iconBefore }: Props) => jsx.JSX.Element;
11
+ export {};
@@ -20,8 +20,8 @@ export declare const TypeAheadList: React.FC<import("react-intl-next").WithIntlP
20
20
  triggerHandler?: TypeAheadHandler | undefined;
21
21
  moreElementsInQuickInsertViewEnabled?: boolean | undefined;
22
22
  api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
23
- showViewMore?: boolean | undefined;
24
- onViewMoreClick?: (() => void) | undefined;
23
+ showMoreOptionsButton?: boolean | undefined;
24
+ onMoreOptionsClicked?: (() => void) | undefined;
25
25
  } & WrappedComponentProps>> & {
26
26
  WrappedComponent: React.ComponentType<{
27
27
  items: Array<TypeAheadItem>;
@@ -33,7 +33,7 @@ export declare const TypeAheadList: React.FC<import("react-intl-next").WithIntlP
33
33
  triggerHandler?: TypeAheadHandler | undefined;
34
34
  moreElementsInQuickInsertViewEnabled?: boolean | undefined;
35
35
  api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
36
- showViewMore?: boolean | undefined;
37
- onViewMoreClick?: (() => void) | undefined;
36
+ showMoreOptionsButton?: boolean | undefined;
37
+ onMoreOptionsClicked?: (() => void) | undefined;
38
38
  } & WrappedComponentProps>;
39
39
  };
@@ -30,7 +30,7 @@ type TypeAheadPopupProps = {
30
30
  forceFocusOnEditor: boolean;
31
31
  }) => void;
32
32
  api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
33
- showViewMore?: boolean;
33
+ showMoreOptionsButton?: boolean;
34
34
  };
35
35
  export declare const TypeAheadPopup: React.MemoExoticComponent<(props: TypeAheadPopupProps) => jsx.JSX.Element>;
36
36
  export {};