@atlaskit/editor-plugin-type-ahead 10.2.2 → 10.3.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 (47) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/pm-plugins/commands/update-list-items.js +3 -1
  3. package/dist/cjs/pm-plugins/main.js +1 -0
  4. package/dist/cjs/pm-plugins/reducer.js +7 -1
  5. package/dist/cjs/typeAheadPlugin.js +3 -1
  6. package/dist/cjs/ui/ContentComponent.js +10 -7
  7. package/dist/cjs/ui/TypeAheadList.js +126 -52
  8. package/dist/cjs/ui/TypeAheadMenu.js +3 -0
  9. package/dist/cjs/ui/TypeAheadPopup.js +3 -0
  10. package/dist/cjs/ui/WrapperTypeAhead.js +3 -1
  11. package/dist/cjs/ui/hooks/build-sectioned-result.js +131 -0
  12. package/dist/cjs/ui/hooks/use-load-items.js +12 -4
  13. package/dist/es2019/pm-plugins/commands/update-list-items.js +3 -2
  14. package/dist/es2019/pm-plugins/main.js +1 -0
  15. package/dist/es2019/pm-plugins/reducer.js +6 -1
  16. package/dist/es2019/typeAheadPlugin.js +3 -1
  17. package/dist/es2019/ui/ContentComponent.js +10 -7
  18. package/dist/es2019/ui/TypeAheadList.js +85 -23
  19. package/dist/es2019/ui/TypeAheadMenu.js +2 -0
  20. package/dist/es2019/ui/TypeAheadPopup.js +2 -0
  21. package/dist/es2019/ui/WrapperTypeAhead.js +3 -1
  22. package/dist/es2019/ui/hooks/build-sectioned-result.js +83 -0
  23. package/dist/es2019/ui/hooks/use-load-items.js +13 -4
  24. package/dist/esm/pm-plugins/commands/update-list-items.js +3 -1
  25. package/dist/esm/pm-plugins/main.js +1 -0
  26. package/dist/esm/pm-plugins/reducer.js +7 -1
  27. package/dist/esm/typeAheadPlugin.js +3 -1
  28. package/dist/esm/ui/ContentComponent.js +10 -7
  29. package/dist/esm/ui/TypeAheadList.js +126 -52
  30. package/dist/esm/ui/TypeAheadMenu.js +3 -0
  31. package/dist/esm/ui/TypeAheadPopup.js +3 -0
  32. package/dist/esm/ui/WrapperTypeAhead.js +3 -1
  33. package/dist/esm/ui/hooks/build-sectioned-result.js +124 -0
  34. package/dist/esm/ui/hooks/use-load-items.js +12 -4
  35. package/dist/types/pm-plugins/commands/update-list-items.d.ts +2 -1
  36. package/dist/types/types/index.d.ts +8 -0
  37. package/dist/types/ui/TypeAheadList.d.ts +3 -1
  38. package/dist/types/ui/TypeAheadPopup.d.ts +3 -2
  39. package/dist/types/ui/hooks/build-sectioned-result.d.ts +11 -0
  40. package/dist/types/ui/hooks/use-load-items.d.ts +2 -1
  41. package/dist/types-ts4.5/pm-plugins/commands/update-list-items.d.ts +2 -1
  42. package/dist/types-ts4.5/types/index.d.ts +8 -0
  43. package/dist/types-ts4.5/ui/TypeAheadList.d.ts +3 -1
  44. package/dist/types-ts4.5/ui/TypeAheadPopup.d.ts +3 -2
  45. package/dist/types-ts4.5/ui/hooks/build-sectioned-result.d.ts +11 -0
  46. package/dist/types-ts4.5/ui/hooks/use-load-items.d.ts +2 -1
  47. package/package.json +4 -4
@@ -9,7 +9,7 @@ import type { ExtractInjectionAPI, TypeAheadItem } from '@atlaskit/editor-common
9
9
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
10
10
  import type { InputMethodType } from '../pm-plugins/analytics';
11
11
  import type { TypeAheadPlugin } from '../typeAheadPluginType';
12
- import type { TypeAheadHandler } from '../types';
12
+ import type { TypeAheadHandler, TypeAheadResolvedSection } from '../types';
13
13
  export declare const TypeAheadList: React.FC<WithIntlProps<{
14
14
  api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
15
15
  decorationElement: HTMLElement;
@@ -20,6 +20,7 @@ export declare const TypeAheadList: React.FC<WithIntlProps<{
20
20
  moreElementsInQuickInsertViewEnabled?: boolean;
21
21
  onItemClick: (mode: SelectItemMode, index: number, inputMethod?: InputMethodType) => void;
22
22
  onMoreOptionsClicked?: () => void;
23
+ sections?: Array<TypeAheadResolvedSection>;
23
24
  selectedIndex: number;
24
25
  showMoreOptionsButton?: boolean;
25
26
  triggerHandler?: TypeAheadHandler;
@@ -34,6 +35,7 @@ export declare const TypeAheadList: React.FC<WithIntlProps<{
34
35
  moreElementsInQuickInsertViewEnabled?: boolean;
35
36
  onItemClick: (mode: SelectItemMode, index: number, inputMethod?: InputMethodType) => void;
36
37
  onMoreOptionsClicked?: () => void;
38
+ sections?: Array<TypeAheadResolvedSection>;
37
39
  selectedIndex: number;
38
40
  showMoreOptionsButton?: boolean;
39
41
  triggerHandler?: TypeAheadHandler;
@@ -5,11 +5,11 @@
5
5
  import React from 'react';
6
6
  import { jsx } from '@emotion/react';
7
7
  import type { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
8
- import type { ExtractInjectionAPI, TypeAheadHandler, TypeAheadItem } from '@atlaskit/editor-common/types';
8
+ import type { ExtractInjectionAPI, TypeAheadItem, TypeAheadHandler } from '@atlaskit/editor-common/types';
9
9
  import type { DecorationSet, EditorView } from '@atlaskit/editor-prosemirror/view';
10
10
  import { CloseSelectionOptions } from '../pm-plugins/constants';
11
11
  import type { TypeAheadPlugin } from '../typeAheadPluginType';
12
- import type { OnSelectItem, TypeAheadErrorInfo } from '../types';
12
+ import type { OnSelectItem, TypeAheadErrorInfo, TypeAheadResolvedSection } from '../types';
13
13
  type TypeAheadPopupProps = {
14
14
  anchorElement: HTMLElement;
15
15
  api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
@@ -24,6 +24,7 @@ type TypeAheadPopupProps = {
24
24
  errorInfo: TypeAheadErrorInfo;
25
25
  isEmptyQuery: boolean;
26
26
  items: Array<TypeAheadItem>;
27
+ sections?: Array<TypeAheadResolvedSection>;
27
28
  onItemInsert: (mode: SelectItemMode, index: number) => void;
28
29
  popupsBoundariesElement?: HTMLElement;
29
30
  popupsMountPoint?: HTMLElement;
@@ -0,0 +1,11 @@
1
+ import type { IntlShape } from 'react-intl';
2
+ import type { TypeAheadHandler, TypeAheadItem } from '@atlaskit/editor-common/types';
3
+ import type { TypeAheadResolvedSection } from '../../types';
4
+ export declare const buildSectionedResult: ({ items, triggerHandler, intl, }: {
5
+ items: Array<TypeAheadItem>;
6
+ triggerHandler: TypeAheadHandler;
7
+ intl: IntlShape | null;
8
+ }) => {
9
+ items: Array<TypeAheadItem>;
10
+ sections: Array<TypeAheadResolvedSection>;
11
+ };
@@ -1,4 +1,5 @@
1
+ import type { IntlShape } from 'react-intl';
1
2
  import type { ExtractInjectionAPI, TypeAheadHandler, TypeAheadItem } from '@atlaskit/editor-common/types';
2
3
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
4
  import type { TypeAheadPlugin } from '../../typeAheadPluginType';
4
- export declare const useLoadItems: (triggerHandler: TypeAheadHandler, editorView: EditorView, query: string, showViewMore?: boolean, api?: ExtractInjectionAPI<TypeAheadPlugin> | undefined) => Array<TypeAheadItem>;
5
+ export declare const useLoadItems: (triggerHandler: TypeAheadHandler, editorView: EditorView, query: string, showViewMore?: boolean, api?: ExtractInjectionAPI<TypeAheadPlugin> | undefined, intl?: IntlShape) => Array<TypeAheadItem>;
@@ -1,2 +1,3 @@
1
1
  import type { Command, TypeAheadItem } from '@atlaskit/editor-common/types';
2
- export declare const updateListItem: (items: Array<TypeAheadItem>) => Command;
2
+ import type { TypeAheadResolvedSection } from '../../types';
3
+ export declare const updateListItem: (items: Array<TypeAheadItem>, sections?: Array<TypeAheadResolvedSection>) => Command;
@@ -35,11 +35,18 @@ export type TypeAheadPluginState = {
35
35
  * If true, removes the trigger character from query when typeahead is closed
36
36
  */
37
37
  removePrefixTriggerOnCancel?: boolean;
38
+ sections: Array<TypeAheadResolvedSection>;
38
39
  selectedIndex: number;
39
40
  stats: TypeAheadStatsSerializable | null;
40
41
  triggerHandler?: TypeAheadHandler;
41
42
  typeAheadHandlers: Array<TypeAheadHandler>;
42
43
  };
44
+ export type TypeAheadResolvedSection = {
45
+ endIndex: number;
46
+ id: string;
47
+ startIndex: number;
48
+ title: string;
49
+ };
43
50
  export type OnInsertSelectedItemProps = {
44
51
  index: number;
45
52
  mode: SelectItemMode;
@@ -88,6 +95,7 @@ export interface TypeAheadPluginSharedState {
88
95
  isOpen: boolean;
89
96
  items: Array<TypeAheadItem>;
90
97
  query: string;
98
+ sections: Array<TypeAheadResolvedSection>;
91
99
  selectedIndex: number;
92
100
  triggerHandler?: TypeAheadHandler;
93
101
  }
@@ -9,7 +9,7 @@ import type { ExtractInjectionAPI, TypeAheadItem } from '@atlaskit/editor-common
9
9
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
10
10
  import type { InputMethodType } from '../pm-plugins/analytics';
11
11
  import type { TypeAheadPlugin } from '../typeAheadPluginType';
12
- import type { TypeAheadHandler } from '../types';
12
+ import type { TypeAheadHandler, TypeAheadResolvedSection } from '../types';
13
13
  export declare const TypeAheadList: React.FC<WithIntlProps<{
14
14
  api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
15
15
  decorationElement: HTMLElement;
@@ -20,6 +20,7 @@ export declare const TypeAheadList: React.FC<WithIntlProps<{
20
20
  moreElementsInQuickInsertViewEnabled?: boolean;
21
21
  onItemClick: (mode: SelectItemMode, index: number, inputMethod?: InputMethodType) => void;
22
22
  onMoreOptionsClicked?: () => void;
23
+ sections?: Array<TypeAheadResolvedSection>;
23
24
  selectedIndex: number;
24
25
  showMoreOptionsButton?: boolean;
25
26
  triggerHandler?: TypeAheadHandler;
@@ -34,6 +35,7 @@ export declare const TypeAheadList: React.FC<WithIntlProps<{
34
35
  moreElementsInQuickInsertViewEnabled?: boolean;
35
36
  onItemClick: (mode: SelectItemMode, index: number, inputMethod?: InputMethodType) => void;
36
37
  onMoreOptionsClicked?: () => void;
38
+ sections?: Array<TypeAheadResolvedSection>;
37
39
  selectedIndex: number;
38
40
  showMoreOptionsButton?: boolean;
39
41
  triggerHandler?: TypeAheadHandler;
@@ -5,11 +5,11 @@
5
5
  import React from 'react';
6
6
  import { jsx } from '@emotion/react';
7
7
  import type { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
8
- import type { ExtractInjectionAPI, TypeAheadHandler, TypeAheadItem } from '@atlaskit/editor-common/types';
8
+ import type { ExtractInjectionAPI, TypeAheadItem, TypeAheadHandler } from '@atlaskit/editor-common/types';
9
9
  import type { DecorationSet, EditorView } from '@atlaskit/editor-prosemirror/view';
10
10
  import { CloseSelectionOptions } from '../pm-plugins/constants';
11
11
  import type { TypeAheadPlugin } from '../typeAheadPluginType';
12
- import type { OnSelectItem, TypeAheadErrorInfo } from '../types';
12
+ import type { OnSelectItem, TypeAheadErrorInfo, TypeAheadResolvedSection } from '../types';
13
13
  type TypeAheadPopupProps = {
14
14
  anchorElement: HTMLElement;
15
15
  api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
@@ -24,6 +24,7 @@ type TypeAheadPopupProps = {
24
24
  errorInfo: TypeAheadErrorInfo;
25
25
  isEmptyQuery: boolean;
26
26
  items: Array<TypeAheadItem>;
27
+ sections?: Array<TypeAheadResolvedSection>;
27
28
  onItemInsert: (mode: SelectItemMode, index: number) => void;
28
29
  popupsBoundariesElement?: HTMLElement;
29
30
  popupsMountPoint?: HTMLElement;
@@ -0,0 +1,11 @@
1
+ import type { IntlShape } from 'react-intl';
2
+ import type { TypeAheadHandler, TypeAheadItem } from '@atlaskit/editor-common/types';
3
+ import type { TypeAheadResolvedSection } from '../../types';
4
+ export declare const buildSectionedResult: ({ items, triggerHandler, intl, }: {
5
+ items: Array<TypeAheadItem>;
6
+ triggerHandler: TypeAheadHandler;
7
+ intl: IntlShape | null;
8
+ }) => {
9
+ items: Array<TypeAheadItem>;
10
+ sections: Array<TypeAheadResolvedSection>;
11
+ };
@@ -1,4 +1,5 @@
1
+ import type { IntlShape } from 'react-intl';
1
2
  import type { ExtractInjectionAPI, TypeAheadHandler, TypeAheadItem } from '@atlaskit/editor-common/types';
2
3
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
4
  import type { TypeAheadPlugin } from '../../typeAheadPluginType';
4
- export declare const useLoadItems: (triggerHandler: TypeAheadHandler, editorView: EditorView, query: string, showViewMore?: boolean, api?: ExtractInjectionAPI<TypeAheadPlugin> | undefined) => Array<TypeAheadItem>;
5
+ export declare const useLoadItems: (triggerHandler: TypeAheadHandler, editorView: EditorView, query: string, showViewMore?: boolean, api?: ExtractInjectionAPI<TypeAheadPlugin> | undefined, intl?: IntlShape) => Array<TypeAheadItem>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-type-ahead",
3
- "version": "10.2.2",
3
+ "version": "10.3.0",
4
4
  "description": "Type-ahead plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -29,7 +29,7 @@
29
29
  ],
30
30
  "atlaskit:src": "src/index.ts",
31
31
  "dependencies": {
32
- "@atlaskit/adf-schema": "^52.14.0",
32
+ "@atlaskit/adf-schema": "^52.15.0",
33
33
  "@atlaskit/editor-plugin-analytics": "^10.1.0",
34
34
  "@atlaskit/editor-plugin-connectivity": "^10.1.0",
35
35
  "@atlaskit/editor-plugin-context-panel": "^12.1.0",
@@ -44,7 +44,7 @@
44
44
  "@atlaskit/primitives": "^19.0.0",
45
45
  "@atlaskit/prosemirror-history": "^0.2.0",
46
46
  "@atlaskit/prosemirror-input-rules": "^3.7.0",
47
- "@atlaskit/tmp-editor-statsig": "^84.0.0",
47
+ "@atlaskit/tmp-editor-statsig": "^84.3.0",
48
48
  "@atlaskit/tokens": "^13.0.0",
49
49
  "@atlaskit/visually-hidden": "^3.1.0",
50
50
  "@babel/runtime": "^7.0.0",
@@ -56,7 +56,7 @@
56
56
  "w3c-keyname": "^2.1.8"
57
57
  },
58
58
  "peerDependencies": {
59
- "@atlaskit/editor-common": "^114.47.0",
59
+ "@atlaskit/editor-common": "^114.50.0",
60
60
  "react": "^18.2.0",
61
61
  "react-dom": "^18.2.0",
62
62
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"