@atlaskit/editor-plugin-type-ahead 11.3.5 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/commands/package.json +1 -8
  3. package/dist/cjs/pm-plugins/commands/update-section-title.js +6 -9
  4. package/dist/cjs/ui/TypeAheadList.js +75 -48
  5. package/dist/cjs/ui/TypeAheadPopup.js +1 -0
  6. package/dist/cjs/ui/hooks/build-sectioned-result.js +8 -4
  7. package/dist/es2019/pm-plugins/commands/update-section-title.js +5 -5
  8. package/dist/es2019/ui/TypeAheadList.js +42 -11
  9. package/dist/es2019/ui/TypeAheadPopup.js +1 -0
  10. package/dist/es2019/ui/hooks/build-sectioned-result.js +8 -4
  11. package/dist/esm/pm-plugins/commands/update-section-title.js +6 -8
  12. package/dist/esm/ui/TypeAheadList.js +75 -48
  13. package/dist/esm/ui/TypeAheadPopup.js +1 -0
  14. package/dist/esm/ui/hooks/build-sectioned-result.js +8 -4
  15. package/dist/types/pm-plugins/commands/update-section-title.d.ts +1 -1
  16. package/dist/types/typeAheadPluginType.d.ts +2 -2
  17. package/dist/types/types/index.d.ts +4 -4
  18. package/dist/types/ui/TypeAheadList.d.ts +4 -1
  19. package/package.json +20 -28
  20. package/type-ahead-plugin/package.json +1 -8
  21. package/type-ahead-plugin-type/package.json +1 -8
  22. package/types/package.json +1 -8
  23. package/dist/types-ts4.5/entry-points/commands.d.ts +0 -1
  24. package/dist/types-ts4.5/entry-points/type-ahead-plugin-type.d.ts +0 -1
  25. package/dist/types-ts4.5/entry-points/type-ahead-plugin.d.ts +0 -1
  26. package/dist/types-ts4.5/entry-points/types.d.ts +0 -1
  27. package/dist/types-ts4.5/index.d.ts +0 -3
  28. package/dist/types-ts4.5/pm-plugins/actions.d.ts +0 -12
  29. package/dist/types-ts4.5/pm-plugins/analytics.d.ts +0 -8
  30. package/dist/types-ts4.5/pm-plugins/api.d.ts +0 -60
  31. package/dist/types-ts4.5/pm-plugins/commands/clear-list-error.d.ts +0 -2
  32. package/dist/types-ts4.5/pm-plugins/commands/close-type-ahead.d.ts +0 -2
  33. package/dist/types-ts4.5/pm-plugins/commands/insert-type-ahead-item.d.ts +0 -12
  34. package/dist/types-ts4.5/pm-plugins/commands/insert-utils.d.ts +0 -18
  35. package/dist/types-ts4.5/pm-plugins/commands/open-typeahead-at-cursor.d.ts +0 -5
  36. package/dist/types-ts4.5/pm-plugins/commands/set-selection-before-query.d.ts +0 -2
  37. package/dist/types-ts4.5/pm-plugins/commands/update-list-error.d.ts +0 -2
  38. package/dist/types-ts4.5/pm-plugins/commands/update-list-items.d.ts +0 -3
  39. package/dist/types-ts4.5/pm-plugins/commands/update-query.d.ts +0 -2
  40. package/dist/types-ts4.5/pm-plugins/commands/update-section-title.d.ts +0 -2
  41. package/dist/types-ts4.5/pm-plugins/commands/update-selected-index.d.ts +0 -3
  42. package/dist/types-ts4.5/pm-plugins/constants.d.ts +0 -8
  43. package/dist/types-ts4.5/pm-plugins/decorations.d.ts +0 -17
  44. package/dist/types-ts4.5/pm-plugins/input-rules.d.ts +0 -6
  45. package/dist/types-ts4.5/pm-plugins/insert-item-plugin.d.ts +0 -2
  46. package/dist/types-ts4.5/pm-plugins/isInsertionTransaction.d.ts +0 -4
  47. package/dist/types-ts4.5/pm-plugins/item-is-disabled.d.ts +0 -3
  48. package/dist/types-ts4.5/pm-plugins/key.d.ts +0 -3
  49. package/dist/types-ts4.5/pm-plugins/main.d.ts +0 -18
  50. package/dist/types-ts4.5/pm-plugins/reducer.d.ts +0 -10
  51. package/dist/types-ts4.5/pm-plugins/stats-modifier.d.ts +0 -20
  52. package/dist/types-ts4.5/pm-plugins/utils.d.ts +0 -42
  53. package/dist/types-ts4.5/typeAheadPlugin.d.ts +0 -10
  54. package/dist/types-ts4.5/typeAheadPluginType.d.ts +0 -52
  55. package/dist/types-ts4.5/types/index.d.ts +0 -114
  56. package/dist/types-ts4.5/ui/ContentComponent.d.ts +0 -12
  57. package/dist/types-ts4.5/ui/InputQuery.d.ts +0 -31
  58. package/dist/types-ts4.5/ui/ListRow.d.ts +0 -21
  59. package/dist/types-ts4.5/ui/MoreOptions.d.ts +0 -16
  60. package/dist/types-ts4.5/ui/TypeAheadErrorFallback/EmptyState.d.ts +0 -9
  61. package/dist/types-ts4.5/ui/TypeAheadErrorFallback/GenericErrorSVG.d.ts +0 -6
  62. package/dist/types-ts4.5/ui/TypeAheadErrorFallback/MinHeightContainer.d.ts +0 -10
  63. package/dist/types-ts4.5/ui/TypeAheadErrorFallback/index.d.ts +0 -6
  64. package/dist/types-ts4.5/ui/TypeAheadList.d.ts +0 -55
  65. package/dist/types-ts4.5/ui/TypeAheadListItem.d.ts +0 -25
  66. package/dist/types-ts4.5/ui/TypeAheadMenu.d.ts +0 -14
  67. package/dist/types-ts4.5/ui/TypeAheadPopup.d.ts +0 -38
  68. package/dist/types-ts4.5/ui/WrapperTypeAhead.d.ts +0 -21
  69. package/dist/types-ts4.5/ui/hooks/build-sectioned-result.d.ts +0 -11
  70. package/dist/types-ts4.5/ui/hooks/use-item-insert.d.ts +0 -9
  71. package/dist/types-ts4.5/ui/hooks/use-load-items.d.ts +0 -5
  72. package/dist/types-ts4.5/ui/hooks/use-on-force-select.d.ts +0 -11
@@ -19,7 +19,7 @@ import { AssistiveText } from '@atlaskit/editor-common/ui';
19
19
  import { MenuGroup } from '@atlaskit/menu';
20
20
  import { Text, Box } from '@atlaskit/primitives/compiled';
21
21
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
22
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
22
+ import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
23
23
  import { closeTypeAhead } from '../pm-plugins/commands/close-type-ahead';
24
24
  import { updateSelectedIndex } from '../pm-plugins/commands/update-selected-index';
25
25
  import { TYPE_AHEAD_DECORATION_ELEMENT_ID } from '../pm-plugins/constants';
@@ -35,9 +35,34 @@ var list = css({
35
35
  padding: "var(--ds-space-100, 8px)".concat(" ", "var(--ds-space-150, 12px)")
36
36
  }
37
37
  });
38
- export var buildTypeAheadRows = function buildTypeAheadRows(_ref) {
39
- var itemsLength = _ref.itemsLength,
40
- sections = _ref.sections;
38
+ /**
39
+ * Resolves section title visibility before rows are built so hidden titles do not
40
+ * occupy virtualized list rows. A single populated section keeps the existing
41
+ * no-title behaviour unless it opts in with `showWhenOnlySection`; multiple
42
+ * populated sections show titles by default. `showWhenQueryPresent: false`
43
+ * takes precedence once the query is non-empty.
44
+ */
45
+ var shouldRenderSectionTitle = function shouldRenderSectionTitle(_ref) {
46
+ var _section$sectionTitle;
47
+ var isEmptyQuery = _ref.isEmptyQuery,
48
+ populatedSectionCount = _ref.populatedSectionCount,
49
+ section = _ref.section;
50
+ if (!expVal('platform_editor_agent_mentions', 'isEnabled', false)) {
51
+ return populatedSectionCount > 1;
52
+ }
53
+ if (!isEmptyQuery && ((_section$sectionTitle = section.sectionTitleDisplay) === null || _section$sectionTitle === void 0 ? void 0 : _section$sectionTitle.showWhenQueryPresent) === false) {
54
+ return false;
55
+ }
56
+ if (populatedSectionCount === 1) {
57
+ var _section$sectionTitle2;
58
+ return ((_section$sectionTitle2 = section.sectionTitleDisplay) === null || _section$sectionTitle2 === void 0 ? void 0 : _section$sectionTitle2.showWhenOnlySection) === true;
59
+ }
60
+ return true;
61
+ };
62
+ export var buildTypeAheadRows = function buildTypeAheadRows(_ref2) {
63
+ var isEmptyQuery = _ref2.isEmptyQuery,
64
+ itemsLength = _ref2.itemsLength,
65
+ sections = _ref2.sections;
41
66
  if (sections.length === 0) {
42
67
  return Array.from({
43
68
  length: itemsLength
@@ -55,13 +80,21 @@ export var buildTypeAheadRows = function buildTypeAheadRows(_ref) {
55
80
  return [section.startIndex, section];
56
81
  }));
57
82
  var rows = [];
83
+ var populatedSectionCount = sortedSections.length;
58
84
  for (var itemIndex = 0; itemIndex < itemsLength; itemIndex++) {
59
85
  var section = sectionsByStartIndex.get(itemIndex);
60
86
  if (section) {
61
- rows.push({
62
- type: 'section',
87
+ var shouldRenderTitle = shouldRenderSectionTitle({
88
+ isEmptyQuery: isEmptyQuery,
89
+ populatedSectionCount: populatedSectionCount,
63
90
  section: section
64
91
  });
92
+ if (shouldRenderTitle) {
93
+ rows.push({
94
+ type: 'section',
95
+ section: section
96
+ });
97
+ }
65
98
  }
66
99
  rows.push({
67
100
  type: 'item',
@@ -70,8 +103,8 @@ export var buildTypeAheadRows = function buildTypeAheadRows(_ref) {
70
103
  }
71
104
  return rows;
72
105
  };
73
- var TypeaheadAssistiveTextPureComponent = /*#__PURE__*/React.memo(function (_ref2) {
74
- var numberOfResults = _ref2.numberOfResults;
106
+ var TypeaheadAssistiveTextPureComponent = /*#__PURE__*/React.memo(function (_ref3) {
107
+ var numberOfResults = _ref3.numberOfResults;
75
108
  var intl = useIntl();
76
109
  return jsx(AssistiveText, {
77
110
  assistiveText: intl.formatMessage(typeAheadListMessages.searchResultsLabel, {
@@ -83,22 +116,24 @@ var TypeaheadAssistiveTextPureComponent = /*#__PURE__*/React.memo(function (_ref
83
116
  id: TYPE_AHEAD_DECORATION_ELEMENT_ID + '__popup'
84
117
  });
85
118
  });
86
- var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref3) {
119
+ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref4) {
87
120
  var _itemRowIndexByItemIn, _triggerHandler$getMo, _decorationElement$qu2;
88
- var items = _ref3.items,
89
- sections = _ref3.sections,
90
- emptyItem = _ref3.emptyItem,
91
- selectedIndex = _ref3.selectedIndex,
92
- editorView = _ref3.editorView,
93
- onItemClick = _ref3.onItemClick,
94
- intl = _ref3.intl,
95
- fitHeight = _ref3.fitHeight,
96
- decorationElement = _ref3.decorationElement,
97
- triggerHandler = _ref3.triggerHandler,
98
- moreElementsInQuickInsertViewEnabled = _ref3.moreElementsInQuickInsertViewEnabled,
99
- api = _ref3.api,
100
- showMoreOptionsButton = _ref3.showMoreOptionsButton,
101
- onMoreOptionsClicked = _ref3.onMoreOptionsClicked;
121
+ var items = _ref4.items,
122
+ sections = _ref4.sections,
123
+ emptyItem = _ref4.emptyItem,
124
+ selectedIndex = _ref4.selectedIndex,
125
+ _ref4$isEmptyQuery = _ref4.isEmptyQuery,
126
+ isEmptyQuery = _ref4$isEmptyQuery === void 0 ? true : _ref4$isEmptyQuery,
127
+ editorView = _ref4.editorView,
128
+ onItemClick = _ref4.onItemClick,
129
+ intl = _ref4.intl,
130
+ fitHeight = _ref4.fitHeight,
131
+ decorationElement = _ref4.decorationElement,
132
+ triggerHandler = _ref4.triggerHandler,
133
+ moreElementsInQuickInsertViewEnabled = _ref4.moreElementsInQuickInsertViewEnabled,
134
+ api = _ref4.api,
135
+ showMoreOptionsButton = _ref4.showMoreOptionsButton,
136
+ onMoreOptionsClicked = _ref4.onMoreOptionsClicked;
102
137
  var listRef = useRef();
103
138
  var listContainerRef = useRef(null);
104
139
  var lastInputMethodRef = useRef('keyboard');
@@ -127,10 +162,11 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref3) {
127
162
  setCache = _useState4[1];
128
163
  var listRows = useMemo(function () {
129
164
  return buildTypeAheadRows({
165
+ isEmptyQuery: isEmptyQuery,
130
166
  itemsLength: itemsLength,
131
167
  sections: sections || []
132
168
  });
133
- }, [itemsLength, sections]);
169
+ }, [isEmptyQuery, itemsLength, sections]);
134
170
  var itemRowIndexByItemIndex = useMemo(function () {
135
171
  var rowIndexByItemIndex = new Map();
136
172
  listRows.forEach(function (row, rowIndex) {
@@ -141,11 +177,6 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref3) {
141
177
  return rowIndexByItemIndex;
142
178
  }, [listRows]);
143
179
  var selectedItemRowIndex = selectedIndex >= 0 ? (_itemRowIndexByItemIn = itemRowIndexByItemIndex.get(selectedIndex)) !== null && _itemRowIndexByItemIn !== void 0 ? _itemRowIndexByItemIn : -1 : -1;
144
- var populatedSectionCount = useMemo(function () {
145
- return listRows.filter(function (row) {
146
- return row.type === 'section';
147
- }).length;
148
- }, [listRows]);
149
180
  var onItemsRendered = useCallback(function (props) {
150
181
  lastVisibleIndexes.current = props;
151
182
  }, []);
@@ -182,8 +213,8 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref3) {
182
213
  var lastVisibleStopIndex = lastVisibleIndexes.current.stopIndex;
183
214
  var onScroll = useCallback(
184
215
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
185
- function (_ref4) {
186
- var scrollUpdateWasRequested = _ref4.scrollUpdateWasRequested;
216
+ function (_ref5) {
217
+ var scrollUpdateWasRequested = _ref5.scrollUpdateWasRequested;
187
218
  if (!scrollUpdateWasRequested) {
188
219
  return;
189
220
  }
@@ -269,7 +300,7 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref3) {
269
300
  }, [items, sections]);
270
301
  useLayoutEffect(function () {
271
302
  // Exclude view more item from the count
272
- var itemsToRender = editorExperiment('platform_editor_agent_mentions', true) ? listRows : showMoreOptionsButton ? items.slice(0, -1) : items;
303
+ var itemsToRender = expVal('platform_editor_agent_mentions', 'isEnabled', false) ? listRows : showMoreOptionsButton ? items.slice(0, -1) : items;
273
304
  var height = Math.min(
274
305
  // eslint-disable-next-line @atlassian/perf-linting/no-expensive-computations-in-render -- Ignored via go/ees017 (to be fixed)
275
306
  itemsToRender.reduce(function (prevValue, currentValue, index) {
@@ -341,8 +372,8 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref3) {
341
372
  if (onMoreOptionsClicked) {
342
373
  onMoreOptionsClicked();
343
374
  }
344
- api === null || api === void 0 || api.core.actions.execute(function (_ref5) {
345
- var tr = _ref5.tr;
375
+ api === null || api === void 0 || api.core.actions.execute(function (_ref6) {
376
+ var tr = _ref6.tr;
346
377
  closeTypeAhead(tr);
347
378
  config === null || config === void 0 || config.onClick({
348
379
  tr: tr
@@ -350,26 +381,25 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref3) {
350
381
  return tr;
351
382
  });
352
383
  };
353
- var renderRow = function renderRow(_ref6) {
354
- var index = _ref6.index,
355
- key = _ref6.key,
356
- style = _ref6.style,
357
- parent = _ref6.parent,
358
- isScrolling = _ref6.isScrolling,
359
- isVisible = _ref6.isVisible;
384
+ var renderRow = function renderRow(_ref7) {
385
+ var index = _ref7.index,
386
+ key = _ref7.key,
387
+ style = _ref7.style,
388
+ parent = _ref7.parent,
389
+ isScrolling = _ref7.isScrolling,
390
+ isVisible = _ref7.isVisible;
360
391
  var currentRow = listRows[index];
361
392
  if (!currentRow) {
362
393
  return null;
363
394
  }
364
- var shouldHideSingleSectionTitle = currentRow.type === 'section' && populatedSectionCount === 1 && !currentRow.section.showTitleWhenOnlySection;
365
395
  return jsx(CellMeasurer, {
366
396
  key: key,
367
397
  cache: cache,
368
398
  parent: parent,
369
399
  columnIndex: 0,
370
400
  rowIndex: index
371
- }, function (_ref7) {
372
- var measure = _ref7.measure;
401
+ }, function (_ref8) {
402
+ var measure = _ref8.measure;
373
403
  return jsx(ListRow, {
374
404
  measure: measure,
375
405
  index: index
@@ -383,10 +413,7 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref3) {
383
413
  onMouseMove: function onMouseMove(e) {
384
414
  return _onMouseMove(e, currentRow);
385
415
  }
386
- }, currentRow.type === 'section' ?
387
- // Preserve the existing collapsed-title behaviour for single-section results unless
388
- // the gated section title API explicitly asks for the title to remain visible.
389
- shouldHideSingleSectionTitle ? null : jsx(Box, {
416
+ }, currentRow.type === 'section' ? jsx(Box, {
390
417
  paddingInline: "space.150",
391
418
  paddingBlock: "space.050"
392
419
  }, jsx(Text, {
@@ -341,6 +341,7 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
341
341
  triggerHandler: triggerHandler
342
342
  }), jsx(TypeAheadList, {
343
343
  items: items,
344
+ isEmptyQuery: isEmptyQuery,
344
345
  sections: sections,
345
346
  emptyItem: emptyItem,
346
347
  selectedIndex: selectedIndex
@@ -2,13 +2,13 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
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; } } }; }
3
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; } }
4
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; }
5
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
+ import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
6
6
  export var buildSectionedResult = function buildSectionedResult(_ref) {
7
7
  var _triggerHandler$getSe;
8
8
  var items = _ref.items,
9
9
  triggerHandler = _ref.triggerHandler,
10
10
  intl = _ref.intl;
11
- if (!editorExperiment('platform_editor_agent_mentions', true) || !intl) {
11
+ if (!expVal('platform_editor_agent_mentions', 'isEnabled', false) || !intl) {
12
12
  return {
13
13
  items: items,
14
14
  sections: []
@@ -98,12 +98,16 @@ export var buildSectionedResult = function buildSectionedResult(_ref) {
98
98
  return items[i];
99
99
  })));
100
100
  var endIndex = flattenedItems.length - 1;
101
- sections.push({
101
+ var resolvedSection = {
102
102
  endIndex: endIndex,
103
103
  id: _section.id,
104
104
  startIndex: startIndex,
105
105
  title: _section.title
106
- });
106
+ };
107
+ if (_section.sectionTitleDisplay) {
108
+ resolvedSection.sectionTitleDisplay = _section.sectionTitleDisplay;
109
+ }
110
+ sections.push(resolvedSection);
107
111
  }
108
112
 
109
113
  // Append items not claimed by any section and not excluded by a limit
@@ -1,2 +1,2 @@
1
1
  import type { Command, TypeAheadSectionTitleUpdate } from '@atlaskit/editor-common/types';
2
- export declare const updateSectionTitle: ({ id, title, showTitleWhenOnlySection, }: TypeAheadSectionTitleUpdate) => Command;
2
+ export declare const updateSectionTitle: ({ id, title, sectionTitleDisplay, }: TypeAheadSectionTitleUpdate) => Command;
@@ -34,8 +34,8 @@ export type TypeAheadPlugin = NextEditorPlugin<'typeAhead', {
34
34
  /**
35
35
  * Updates the display title for an existing typeahead section in the current typeahead session.
36
36
  *
37
- * The optional `showTitleWhenOnlySection` flag keeps the title visible when this section is
38
- * the only populated section. It does not render titles for empty sections.
37
+ * Optional `sectionTitleDisplay` rules can control whether the title stays visible once
38
+ * there is a query, or keep the title visible when this section is the only populated section.
39
39
  */
40
40
  updateSectionTitle?: (props: TypeAheadSectionTitleUpdate) => boolean;
41
41
  };
@@ -1,6 +1,7 @@
1
1
  import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import type { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
3
3
  import type { TypeAheadHandler, TypeAheadItem, TypeAheadStats, UiComponentFactoryParams } from '@atlaskit/editor-common/types';
4
+ import type { TypeAheadSectionTitleDisplay } from '@atlaskit/editor-common/types/type-ahead';
4
5
  import type { EditorState, ReadonlyTransaction, Transaction } from '@atlaskit/editor-prosemirror/state';
5
6
  import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
6
7
  export type { TypeAheadHandler } from '@atlaskit/editor-common/types';
@@ -24,7 +25,7 @@ export interface TypeAheadStatsMobileModifier extends TypeAheadStatsSerializable
24
25
  closeTime: () => void;
25
26
  resetTime: () => void;
26
27
  }
27
- export type TypeAheadSectionTitleUpdateState = Pick<TypeAheadResolvedSection, 'showTitleWhenOnlySection' | 'title'>;
28
+ export type TypeAheadSectionTitleUpdateState = Pick<TypeAheadResolvedSection, 'sectionTitleDisplay' | 'title'>;
28
29
  export type TypeAheadPluginState = {
29
30
  decorationElement: HTMLElement | null;
30
31
  decorationSet: DecorationSet;
@@ -47,10 +48,9 @@ export type TypeAheadResolvedSection = {
47
48
  endIndex: number;
48
49
  id: string;
49
50
  /**
50
- * Keeps this section's title visible when it is the only section with matching items.
51
- * Does not render the title for an empty section.
51
+ * Section title display rules copied from the section definition and optional runtime updates.
52
52
  */
53
- showTitleWhenOnlySection?: boolean;
53
+ sectionTitleDisplay?: TypeAheadSectionTitleDisplay;
54
54
  startIndex: number;
55
55
  title: string;
56
56
  };
@@ -17,7 +17,8 @@ type TypeAheadRowEntry = {
17
17
  itemIndex: number;
18
18
  type: 'item';
19
19
  };
20
- export declare const buildTypeAheadRows: ({ itemsLength, sections, }: {
20
+ export declare const buildTypeAheadRows: ({ isEmptyQuery, itemsLength, sections, }: {
21
+ isEmptyQuery: boolean;
21
22
  itemsLength: number;
22
23
  sections: Array<TypeAheadResolvedSection>;
23
24
  }) => Array<TypeAheadRowEntry>;
@@ -27,6 +28,7 @@ export declare const TypeAheadList: React.FC<WithIntlProps<{
27
28
  editorView: EditorView;
28
29
  emptyItem?: TypeAheadItem;
29
30
  fitHeight: number;
31
+ isEmptyQuery?: boolean;
30
32
  items: Array<TypeAheadItem>;
31
33
  moreElementsInQuickInsertViewEnabled?: boolean;
32
34
  onItemClick: (mode: SelectItemMode, index: number, inputMethod?: InputMethodType) => void;
@@ -42,6 +44,7 @@ export declare const TypeAheadList: React.FC<WithIntlProps<{
42
44
  editorView: EditorView;
43
45
  emptyItem?: TypeAheadItem;
44
46
  fitHeight: number;
47
+ isEmptyQuery?: boolean;
45
48
  items: Array<TypeAheadItem>;
46
49
  moreElementsInQuickInsertViewEnabled?: boolean;
47
50
  onItemClick: (mode: SelectItemMode, index: number, inputMethod?: InputMethodType) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-type-ahead",
3
- "version": "11.3.5",
3
+ "version": "12.0.0",
4
4
  "description": "Type-ahead plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -16,37 +16,29 @@
16
16
  "module": "dist/esm/index.js",
17
17
  "module:es2019": "dist/es2019/index.js",
18
18
  "types": "dist/types/index.d.ts",
19
- "typesVersions": {
20
- ">=4.5 <4.9": {
21
- "*": [
22
- "dist/types-ts4.5/*",
23
- "dist/types-ts4.5/index.d.ts"
24
- ]
25
- }
26
- },
27
19
  "sideEffects": [
28
20
  "*.compiled.css"
29
21
  ],
30
22
  "atlaskit:src": "src/index.ts",
31
23
  "dependencies": {
32
- "@atlaskit/adf-schema": "^54.0.0",
33
- "@atlaskit/editor-plugin-analytics": "^11.0.0",
34
- "@atlaskit/editor-plugin-connectivity": "^11.0.0",
35
- "@atlaskit/editor-plugin-context-panel": "^13.0.0",
36
- "@atlaskit/editor-plugin-metrics": "^12.0.0",
37
- "@atlaskit/editor-prosemirror": "^7.3.0",
38
- "@atlaskit/editor-shared-styles": "^3.11.0",
39
- "@atlaskit/feature-gate-js-client": "^5.8.0",
40
- "@atlaskit/heading": "^5.4.0",
41
- "@atlaskit/insm": "^0.4.0",
42
- "@atlaskit/menu": "^8.5.0",
43
- "@atlaskit/platform-feature-flags": "^1.1.0",
44
- "@atlaskit/primitives": "^19.0.0",
45
- "@atlaskit/prosemirror-history": "^0.2.0",
46
- "@atlaskit/prosemirror-input-rules": "^3.7.0",
47
- "@atlaskit/tmp-editor-statsig": "^102.0.0",
48
- "@atlaskit/tokens": "^13.4.0",
49
- "@atlaskit/visually-hidden": "^3.1.0",
24
+ "@atlaskit/adf-schema": "^55.0.0",
25
+ "@atlaskit/editor-plugin-analytics": "^12.0.0",
26
+ "@atlaskit/editor-plugin-connectivity": "^12.0.0",
27
+ "@atlaskit/editor-plugin-context-panel": "^14.0.0",
28
+ "@atlaskit/editor-plugin-metrics": "^13.0.0",
29
+ "@atlaskit/editor-prosemirror": "^8.0.0",
30
+ "@atlaskit/editor-shared-styles": "^4.0.0",
31
+ "@atlaskit/feature-gate-js-client": "^6.0.0",
32
+ "@atlaskit/heading": "^6.0.0",
33
+ "@atlaskit/insm": "^1.0.0",
34
+ "@atlaskit/menu": "^9.0.0",
35
+ "@atlaskit/platform-feature-flags": "^2.0.0",
36
+ "@atlaskit/primitives": "^20.0.0",
37
+ "@atlaskit/prosemirror-history": "^1.0.0",
38
+ "@atlaskit/prosemirror-input-rules": "^4.0.0",
39
+ "@atlaskit/tmp-editor-statsig": "^104.0.0",
40
+ "@atlaskit/tokens": "^14.0.0",
41
+ "@atlaskit/visually-hidden": "^4.0.0",
50
42
  "@babel/runtime": "^7.0.0",
51
43
  "@emotion/react": "^11.7.1",
52
44
  "lodash": "^4.17.21",
@@ -56,7 +48,7 @@
56
48
  "w3c-keyname": "^2.1.8"
57
49
  },
58
50
  "peerDependencies": {
59
- "@atlaskit/editor-common": "^115.15.0",
51
+ "@atlaskit/editor-common": "^116.0.0",
60
52
  "react": "^18.2.0",
61
53
  "react-dom": "^18.2.0",
62
54
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
@@ -6,12 +6,5 @@
6
6
  "sideEffects": [
7
7
  "*.compiled.css"
8
8
  ],
9
- "types": "../dist/types/entry-points/type-ahead-plugin.d.ts",
10
- "typesVersions": {
11
- ">=4.5 <5.9": {
12
- "*": [
13
- "../dist/types-ts4.5/entry-points/type-ahead-plugin.d.ts"
14
- ]
15
- }
16
- }
9
+ "types": "../dist/types/entry-points/type-ahead-plugin.d.ts"
17
10
  }
@@ -6,12 +6,5 @@
6
6
  "sideEffects": [
7
7
  "*.compiled.css"
8
8
  ],
9
- "types": "../dist/types/entry-points/type-ahead-plugin-type.d.ts",
10
- "typesVersions": {
11
- ">=4.5 <5.9": {
12
- "*": [
13
- "../dist/types-ts4.5/entry-points/type-ahead-plugin-type.d.ts"
14
- ]
15
- }
16
- }
9
+ "types": "../dist/types/entry-points/type-ahead-plugin-type.d.ts"
17
10
  }
@@ -6,12 +6,5 @@
6
6
  "sideEffects": [
7
7
  "*.compiled.css"
8
8
  ],
9
- "types": "../dist/types/entry-points/types.d.ts",
10
- "typesVersions": {
11
- ">=4.5 <5.9": {
12
- "*": [
13
- "../dist/types-ts4.5/entry-points/types.d.ts"
14
- ]
15
- }
16
- }
9
+ "types": "../dist/types/entry-points/types.d.ts"
17
10
  }
@@ -1 +0,0 @@
1
- export { openTypeAhead, openTypeAheadAtCursor, } from '../pm-plugins/commands/open-typeahead-at-cursor';
@@ -1 +0,0 @@
1
- export type { TypeAheadPlugin } from '../typeAheadPluginType';
@@ -1 +0,0 @@
1
- export { typeAheadPlugin } from '../typeAheadPlugin';
@@ -1 +0,0 @@
1
- export type { OpenTypeAheadProps, TypeAheadHandler, TypeAheadInputMethod, TypeAheadPluginOptions, TypeAheadPluginState, TypeAheadPluginSharedState, } from '../types/index';
@@ -1,3 +0,0 @@
1
- export { typeAheadPlugin } from './typeAheadPlugin';
2
- export type { TypeAheadPlugin } from './typeAheadPluginType';
3
- export type { OpenTypeAheadProps, TypeAheadHandler, TypeAheadInputMethod, TypeAheadPluginOptions, TypeAheadPluginState, TypeAheadPluginSharedState, } from './types';
@@ -1,12 +0,0 @@
1
- export declare enum ACTIONS {
2
- OPEN_TYPEAHEAD_AT_CURSOR = "OPEN_TYPEAHEAD_AT_CURSOR",
3
- CLOSE_TYPE_AHEAD = "CLOSE_TYPE_AHEAD",
4
- CHANGE_QUERY = "CHANGE_QUERY",
5
- INSERT_ITEM = "INSERT_ITEM",
6
- INSERT_RAW_QUERY = "INSERT_RAW_QUERY",
7
- UPDATE_LIST_ITEMS = "UPDATE_LIST_ITEMS",
8
- UPDATE_LIST_ERROR = "UPDATE_LIST_ERROR",
9
- CLEAR_LIST_ERROR = "CLEAR_LIST_ERROR",
10
- UPDATE_SELECTED_INDEX = "UPDATE_SELECTED_INDEX",
11
- UPDATE_SECTION_TITLE = "UPDATE_SECTION_TITLE"
12
- }
@@ -1,8 +0,0 @@
1
- import { ACTION } from '@atlaskit/editor-common/analytics';
2
- import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
- import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
- import type { TypeAheadPlugin } from '../typeAheadPluginType';
5
- import type { TypeAheadInputMethod } from '../types';
6
- export type CloseActionType = ACTION.INSERTED | ACTION.CANCELLED | ACTION.VIEW_MORE;
7
- export type InputMethodType = INPUT_METHOD.KEYBOARD | INPUT_METHOD.MOUSE;
8
- export declare const fireTypeAheadClosedAnalyticsEvent: (api: ExtractInjectionAPI<TypeAheadPlugin> | undefined, closeAction: CloseActionType | null, hasQuery: boolean, inputMethod: InputMethodType | null, invocationMethod?: TypeAheadInputMethod | null) => void;
@@ -1,60 +0,0 @@
1
- import type { TypeAheadItem } from '@atlaskit/editor-common/provider-factory';
2
- import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
3
- import type { Command } from '@atlaskit/editor-common/types';
4
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
- import type { TypeAheadHandler, TypeAheadInputMethod } from '../types';
6
- type CloseOptions = {
7
- attachCommand?: Command;
8
- insertCurrentQueryAsRawText: boolean;
9
- };
10
- type InsertItemProps = {
11
- contentItem: TypeAheadItem;
12
- query: string;
13
- sourceListItem: TypeAheadItem[];
14
- };
15
- /**
16
- * Please do not use it. Ping #help-editor and talk to the Lego team before use it.
17
- *
18
- * @private
19
- * @deprecated
20
- *
21
- */
22
- export declare const createTypeAheadTools: (editorView: EditorView) => {
23
- close: (options?: CloseOptions) => boolean;
24
- currentQuery: () => string | undefined;
25
- insertItemEmoji: ({ contentItem, query, sourceListItem }: InsertItemProps) => boolean;
26
- insertItemMention: ({ contentItem, query, sourceListItem }: InsertItemProps) => boolean;
27
- insertItemQuickInsert: ({ contentItem, query, sourceListItem }: InsertItemProps) => boolean;
28
- isOpen: () => TypeAheadHandler | false;
29
- openEmoji: (inputMethod: TypeAheadInputMethod) => boolean;
30
- openMention: (inputMethod: TypeAheadInputMethod) => boolean;
31
- openQuickInsert: (inputMethod: TypeAheadInputMethod) => boolean;
32
- searchEmoji: (query?: string) => {
33
- close: (options?: CloseOptions) => boolean;
34
- insert: ({ index, mode }: {
35
- index: number;
36
- mode?: SelectItemMode;
37
- }) => Promise<void>;
38
- result: () => Promise<TypeAheadItem[] | undefined>;
39
- type: (appendValue: string) => Promise<TypeAheadItem[]> | undefined;
40
- };
41
- searchMention: (query?: string) => {
42
- close: (options?: CloseOptions) => boolean;
43
- insert: ({ index, mode }: {
44
- index: number;
45
- mode?: SelectItemMode;
46
- }) => Promise<void>;
47
- result: () => Promise<TypeAheadItem[] | undefined>;
48
- type: (appendValue: string) => Promise<TypeAheadItem[]> | undefined;
49
- };
50
- searchQuickInsert: (query?: string) => {
51
- close: (options?: CloseOptions) => boolean;
52
- insert: ({ index, mode }: {
53
- index: number;
54
- mode?: SelectItemMode;
55
- }) => Promise<void>;
56
- result: () => Promise<TypeAheadItem[] | undefined>;
57
- type: (appendValue: string) => Promise<TypeAheadItem[]> | undefined;
58
- };
59
- };
60
- export {};
@@ -1,2 +0,0 @@
1
- import type { EditorCommand } from '@atlaskit/editor-common/types';
2
- export declare const clearListError: () => EditorCommand;
@@ -1,2 +0,0 @@
1
- import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
- export declare const closeTypeAhead: (tr: Transaction) => Transaction;
@@ -1,12 +0,0 @@
1
- import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
2
- import type { TypeAheadHandler, TypeAheadItem } from '@atlaskit/editor-common/types';
3
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
- type Props = {
5
- handler: TypeAheadHandler;
6
- item: TypeAheadItem;
7
- mode: SelectItemMode;
8
- query: string;
9
- sourceListItem: Array<TypeAheadItem>;
10
- };
11
- export declare const insertTypeAheadItem: (view: EditorView) => ({ item, handler, mode, query, sourceListItem }: Props) => void;
12
- export {};
@@ -1,18 +0,0 @@
1
- import { Fragment, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
- import type { Transaction } from '@atlaskit/editor-prosemirror/state';
3
- type Position = {
4
- end: number;
5
- start: number;
6
- };
7
- export declare const insertBlockNode: ({ node, tr, position, }: {
8
- node: PMNode;
9
- position: Position;
10
- tr: Transaction;
11
- }) => Transaction;
12
- export declare const insertInlineNodeOrFragment: ({ maybeFragment, tr, position, selectInlineNode, }: {
13
- maybeFragment: Fragment | PMNode;
14
- position: Position;
15
- selectInlineNode: boolean;
16
- tr: Transaction;
17
- }) => Transaction;
18
- export {};
@@ -1,5 +0,0 @@
1
- import type { EditorCommand } from '@atlaskit/editor-common/types';
2
- import type { Transaction } from '@atlaskit/editor-prosemirror/state';
3
- import type { OpenTypeAheadProps } from '../../types';
4
- export declare const openTypeAhead: (props: OpenTypeAheadProps) => (tr: Transaction) => void;
5
- export declare const openTypeAheadAtCursor: ({ triggerHandler, inputMethod, query, removePrefixTriggerOnCancel, }: OpenTypeAheadProps) => EditorCommand;
@@ -1,2 +0,0 @@
1
- import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
- export declare const setSelectionBeforeQuery: (rawText: string) => (tr: Transaction) => void;
@@ -1,2 +0,0 @@
1
- import type { Command } from '@atlaskit/editor-common/types';
2
- export declare const updateListError: (errorInfo: Record<string, string>) => Command;
@@ -1,3 +0,0 @@
1
- import type { Command, TypeAheadItem } from '@atlaskit/editor-common/types';
2
- import type { TypeAheadResolvedSection } from '../../types';
3
- export declare const updateListItem: (items: Array<TypeAheadItem>, sections?: Array<TypeAheadResolvedSection>) => Command;
@@ -1,2 +0,0 @@
1
- import type { Command } from '@atlaskit/editor-common/types';
2
- export declare const updateQuery: (query: string) => Command;
@@ -1,2 +0,0 @@
1
- import type { Command, TypeAheadSectionTitleUpdate } from '@atlaskit/editor-common/types';
2
- export declare const updateSectionTitle: ({ id, title, showTitleWhenOnlySection, }: TypeAheadSectionTitleUpdate) => Command;
@@ -1,3 +0,0 @@
1
- import type { Command, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
- import type { TypeAheadPlugin } from '../../typeAheadPluginType';
3
- export declare const updateSelectedIndex: (selectedIndex: number, api: ExtractInjectionAPI<TypeAheadPlugin> | undefined) => Command;