@atlaskit/editor-plugin-type-ahead 13.2.0 → 13.2.2

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 (69) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/pm-plugins/commands/insert-type-ahead-item.js +96 -1
  3. package/dist/cjs/ui/ContentComponent.js +4 -0
  4. package/dist/cjs/ui/InputQuery.js +21 -14
  5. package/dist/cjs/ui/WrapperTypeAhead.js +23 -1
  6. package/dist/cjs/ui/hooks/use-load-items.js +6 -1
  7. package/dist/cjs/ui/registered-menu/PassThrough.js +10 -0
  8. package/dist/cjs/ui/registered-menu/RegisteredTypeAheadMenu.js +146 -0
  9. package/dist/cjs/ui/registered-menu/TypeAheadContext.js +8 -0
  10. package/dist/cjs/ui/registered-menu/TypeAheadItemRow.js +27 -0
  11. package/dist/cjs/ui/registered-menu/TypeAheadProvider.js +8 -0
  12. package/dist/cjs/ui/registered-menu/buildTypeAheadMenuModel.js +50 -0
  13. package/dist/cjs/ui/registered-menu/getTypeAheadItemId.js +9 -0
  14. package/dist/cjs/ui/registered-menu/quick-insert/TypeAheadQuickInsertItem.js +37 -0
  15. package/dist/cjs/ui/registered-menu/quick-insert/TypeAheadQuickInsertProvider.js +41 -0
  16. package/dist/cjs/ui/registered-menu/typeAheadMenuTypes.js +5 -0
  17. package/dist/cjs/ui/registered-menu/typeAheadSurfaces.js +26 -0
  18. package/dist/cjs/ui/registered-menu/useTypeAheadContext.js +15 -0
  19. package/dist/es2019/pm-plugins/commands/insert-type-ahead-item.js +97 -0
  20. package/dist/es2019/ui/ContentComponent.js +4 -0
  21. package/dist/es2019/ui/InputQuery.js +15 -8
  22. package/dist/es2019/ui/WrapperTypeAhead.js +23 -1
  23. package/dist/es2019/ui/hooks/use-load-items.js +6 -2
  24. package/dist/es2019/ui/registered-menu/PassThrough.js +3 -0
  25. package/dist/es2019/ui/registered-menu/RegisteredTypeAheadMenu.js +127 -0
  26. package/dist/es2019/ui/registered-menu/TypeAheadContext.js +2 -0
  27. package/dist/es2019/ui/registered-menu/TypeAheadItemRow.js +18 -0
  28. package/dist/es2019/ui/registered-menu/TypeAheadProvider.js +2 -0
  29. package/dist/es2019/ui/registered-menu/buildTypeAheadMenuModel.js +24 -0
  30. package/dist/es2019/ui/registered-menu/getTypeAheadItemId.js +1 -0
  31. package/dist/es2019/ui/registered-menu/quick-insert/TypeAheadQuickInsertItem.js +25 -0
  32. package/dist/es2019/ui/registered-menu/quick-insert/TypeAheadQuickInsertProvider.js +33 -0
  33. package/dist/es2019/ui/registered-menu/typeAheadMenuTypes.js +1 -0
  34. package/dist/es2019/ui/registered-menu/typeAheadSurfaces.js +20 -0
  35. package/dist/es2019/ui/registered-menu/useTypeAheadContext.js +9 -0
  36. package/dist/esm/pm-plugins/commands/insert-type-ahead-item.js +95 -0
  37. package/dist/esm/ui/ContentComponent.js +4 -0
  38. package/dist/esm/ui/InputQuery.js +21 -14
  39. package/dist/esm/ui/WrapperTypeAhead.js +23 -1
  40. package/dist/esm/ui/hooks/use-load-items.js +6 -1
  41. package/dist/esm/ui/registered-menu/PassThrough.js +4 -0
  42. package/dist/esm/ui/registered-menu/RegisteredTypeAheadMenu.js +137 -0
  43. package/dist/esm/ui/registered-menu/TypeAheadContext.js +2 -0
  44. package/dist/esm/ui/registered-menu/TypeAheadItemRow.js +19 -0
  45. package/dist/esm/ui/registered-menu/TypeAheadProvider.js +2 -0
  46. package/dist/esm/ui/registered-menu/buildTypeAheadMenuModel.js +44 -0
  47. package/dist/esm/ui/registered-menu/getTypeAheadItemId.js +3 -0
  48. package/dist/esm/ui/registered-menu/quick-insert/TypeAheadQuickInsertItem.js +28 -0
  49. package/dist/esm/ui/registered-menu/quick-insert/TypeAheadQuickInsertProvider.js +33 -0
  50. package/dist/esm/ui/registered-menu/typeAheadMenuTypes.js +1 -0
  51. package/dist/esm/ui/registered-menu/typeAheadSurfaces.js +20 -0
  52. package/dist/esm/ui/registered-menu/useTypeAheadContext.js +9 -0
  53. package/dist/types/pm-plugins/commands/insert-type-ahead-item.d.ts +7 -0
  54. package/dist/types/typeAheadPluginType.d.ts +3 -1
  55. package/dist/types/ui/InputQuery.d.ts +10 -2
  56. package/dist/types/ui/hooks/use-load-items.d.ts +1 -1
  57. package/dist/types/ui/registered-menu/PassThrough.d.ts +2 -0
  58. package/dist/types/ui/registered-menu/RegisteredTypeAheadMenu.d.ts +30 -0
  59. package/dist/types/ui/registered-menu/TypeAheadContext.d.ts +14 -0
  60. package/dist/types/ui/registered-menu/TypeAheadItemRow.d.ts +11 -0
  61. package/dist/types/ui/registered-menu/TypeAheadProvider.d.ts +3 -0
  62. package/dist/types/ui/registered-menu/buildTypeAheadMenuModel.d.ts +7 -0
  63. package/dist/types/ui/registered-menu/getTypeAheadItemId.d.ts +1 -0
  64. package/dist/types/ui/registered-menu/quick-insert/TypeAheadQuickInsertItem.d.ts +3 -0
  65. package/dist/types/ui/registered-menu/quick-insert/TypeAheadQuickInsertProvider.d.ts +2 -0
  66. package/dist/types/ui/registered-menu/typeAheadMenuTypes.d.ts +9 -0
  67. package/dist/types/ui/registered-menu/typeAheadSurfaces.d.ts +17 -0
  68. package/dist/types/ui/registered-menu/useTypeAheadContext.d.ts +2 -0
  69. package/package.json +8 -4
@@ -9,6 +9,7 @@ import type { TypeAheadItem } from '@atlaskit/editor-common/types';
9
9
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
10
10
  import { CloseSelectionOptions } from '../pm-plugins/constants';
11
11
  type InputQueryProps = {
12
+ activeDescendantId?: string;
12
13
  cancel: (props: {
13
14
  addPrefixTrigger: boolean;
14
15
  forceFocusOnEditor: boolean;
@@ -17,15 +18,22 @@ type InputQueryProps = {
17
18
  }) => void;
18
19
  editorView: EditorView;
19
20
  forceFocus: boolean;
20
- items: TypeAheadItem[];
21
+ /**
22
+ * @private
23
+ * @deprecated Pass `optionCount` instead.
24
+ */
25
+ items?: TypeAheadItem[];
26
+ listId?: string;
21
27
  onItemSelect: (mode: SelectItemMode) => void;
22
28
  onQueryChange: (query: string) => void;
23
29
  onQueryFocus: () => void;
24
30
  onUndoRedo?: (inputType: 'historyUndo' | 'historyRedo') => boolean;
31
+ optionCount?: number;
25
32
  reopenQuery?: string;
26
33
  selectNextItem: () => void;
27
34
  selectPreviousItem: () => void;
35
+ shouldKeepOpenOnRegisteredMenu?: boolean;
28
36
  triggerQueryPrefix: string;
29
37
  };
30
- export declare const InputQuery: React.MemoExoticComponent<({ triggerQueryPrefix, cancel, onQueryChange, onItemSelect, selectNextItem, selectPreviousItem, forceFocus, reopenQuery, onQueryFocus, onUndoRedo, editorView, items, }: InputQueryProps) => jsx.JSX.Element>;
38
+ export declare const InputQuery: React.MemoExoticComponent<({ activeDescendantId, triggerQueryPrefix, cancel, onQueryChange, onItemSelect, selectNextItem, selectPreviousItem, forceFocus, reopenQuery, onQueryFocus, onUndoRedo, editorView, items, listId, optionCount, shouldKeepOpenOnRegisteredMenu, }: InputQueryProps) => jsx.JSX.Element>;
31
39
  export {};
@@ -2,4 +2,4 @@ import type { IntlShape } from 'react-intl';
2
2
  import type { ExtractInjectionAPI, TypeAheadHandler, TypeAheadItem } from '@atlaskit/editor-common/types';
3
3
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
4
  import type { TypeAheadPlugin } from '../../typeAheadPluginType';
5
- export declare const useLoadItems: (triggerHandler: TypeAheadHandler, editorView: EditorView, query: string, showViewMore?: boolean, api?: ExtractInjectionAPI<TypeAheadPlugin> | undefined, intl?: IntlShape) => Array<TypeAheadItem>;
5
+ export declare const useLoadItems: (triggerHandler: TypeAheadHandler, editorView: EditorView, query: string, showViewMore?: boolean, api?: ExtractInjectionAPI<TypeAheadPlugin> | undefined, intl?: IntlShape, enabled?: boolean) => Array<TypeAheadItem>;
@@ -0,0 +1,2 @@
1
+ import type React from 'react';
2
+ export declare const PassThrough: ({ children }: React.PropsWithChildren) => React.ReactNode;
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import type { ExtractInjectionAPI, TypeAheadHandler } from '@atlaskit/editor-common/types';
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ import type { CloseSelectionOptions } from '../../pm-plugins/constants';
5
+ import type { TypeAheadPlugin } from '../../typeAheadPluginType';
6
+ import type { TypeAheadSurface } from './typeAheadSurfaces';
7
+ type Props = {
8
+ anchorElement: HTMLElement;
9
+ api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
10
+ cancel: (params: {
11
+ addPrefixTrigger: boolean;
12
+ forceFocusOnEditor: boolean;
13
+ setSelectionAt: CloseSelectionOptions;
14
+ text: string;
15
+ }) => void;
16
+ editorView: EditorView;
17
+ forceFocus: boolean;
18
+ onClose: () => void;
19
+ onUndoRedo?: (inputType: 'historyUndo' | 'historyRedo') => boolean;
20
+ popupsBoundariesElement?: HTMLElement;
21
+ popupsMountPoint?: HTMLElement;
22
+ popupsScrollableElement?: HTMLElement;
23
+ query: string;
24
+ reopenQuery?: string;
25
+ setQuery: (query: string) => void;
26
+ surface: TypeAheadSurface;
27
+ triggerHandler: TypeAheadHandler;
28
+ };
29
+ export declare const RegisteredTypeAheadMenu: ({ anchorElement, api, cancel, editorView, forceFocus, onClose, onUndoRedo, popupsBoundariesElement, popupsMountPoint, popupsScrollableElement, query, reopenQuery, setQuery, surface, triggerHandler, }: Props) => React.JSX.Element;
30
+ export {};
@@ -0,0 +1,14 @@
1
+ import type { Context } from 'react';
2
+ import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
+ import type { ExtractInjectionAPI, TypeAheadHandler } from '@atlaskit/editor-common/types';
4
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
+ import type { TypeAheadPlugin } from '../../typeAheadPluginType';
6
+ export type TypeAheadContextValue = {
7
+ api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
8
+ editorView: EditorView;
9
+ inputMethod: INPUT_METHOD.QUICK_INSERT;
10
+ onClose: () => void;
11
+ query: string;
12
+ triggerHandler: TypeAheadHandler;
13
+ };
14
+ export declare const TypeAheadContext: Context<TypeAheadContextValue | null>;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { RegisterMenuItem } from '@atlaskit/editor-ui-control-model/types';
3
+ import type { TypeAheadItemComponent } from './typeAheadMenuTypes';
4
+ export declare const TypeAheadItemRow: ({ isSelected, itemIndex, Item, listId, onItemHover, registration, }: {
5
+ isSelected: boolean;
6
+ Item: TypeAheadItemComponent;
7
+ itemIndex: number;
8
+ listId: string;
9
+ onItemHover: (itemIndex: number) => void;
10
+ registration: RegisterMenuItem;
11
+ }) => React.JSX.Element;
@@ -0,0 +1,3 @@
1
+ import type { Provider } from 'react';
2
+ import type { TypeAheadContextValue } from './TypeAheadContext';
3
+ export declare const TypeAheadProvider: Provider<TypeAheadContextValue | null>;
@@ -0,0 +1,7 @@
1
+ import type { SurfaceIdentifier } from '@atlaskit/editor-ui-control-model/surface-renderer/types';
2
+ import type { RegisterComponent, RegisterMenuItem } from '@atlaskit/editor-ui-control-model/types';
3
+ export type TypeAheadMenuModel = {
4
+ items: RegisterMenuItem[];
5
+ root: RegisterComponent | undefined;
6
+ };
7
+ export declare const buildTypeAheadMenuModel: (components: RegisterComponent[], rootComponent: SurfaceIdentifier) => TypeAheadMenuModel;
@@ -0,0 +1 @@
1
+ export declare const getTypeAheadItemId: (listId: string, itemIndex: number) => string;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import type { TypeAheadItemRenderProps } from '../typeAheadMenuTypes';
3
+ export declare const TypeAheadQuickInsertItem: ({ id, isSelected, onMouseMove, registration, }: TypeAheadItemRenderProps) => React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const TypeAheadQuickInsertProvider: ({ children, }: React.PropsWithChildren) => React.JSX.Element;
@@ -0,0 +1,9 @@
1
+ import type React from 'react';
2
+ import type { RegisterMenuItem } from '@atlaskit/editor-ui-control-model/types';
3
+ export type TypeAheadItemRenderProps = {
4
+ id: string;
5
+ isSelected: boolean;
6
+ onMouseMove: () => void;
7
+ registration: RegisterMenuItem;
8
+ };
9
+ export type TypeAheadItemComponent = React.ComponentType<TypeAheadItemRenderProps>;
@@ -0,0 +1,17 @@
1
+ import type React from 'react';
2
+ import type { MessageDescriptor } from 'react-intl';
3
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
+ import { TypeAheadAvailableNodes } from '@atlaskit/editor-common/type-ahead';
5
+ import type { TypeAheadItemComponent } from './typeAheadMenuTypes';
6
+ export type TypeAheadSurface = {
7
+ inputMethod: INPUT_METHOD.QUICK_INSERT;
8
+ Item: TypeAheadItemComponent;
9
+ listIdPrefix: string;
10
+ listLabel: MessageDescriptor;
11
+ Provider: React.ComponentType<React.PropsWithChildren>;
12
+ root: {
13
+ key: string;
14
+ type: 'menu';
15
+ };
16
+ };
17
+ export declare const getTypeAheadSurface: (id?: TypeAheadAvailableNodes) => TypeAheadSurface | undefined;
@@ -0,0 +1,2 @@
1
+ import type { TypeAheadContextValue } from './TypeAheadContext';
2
+ export declare const useTypeAheadContext: () => TypeAheadContextValue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-type-ahead",
3
- "version": "13.2.0",
3
+ "version": "13.2.2",
4
4
  "description": "Type-ahead plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -21,22 +21,25 @@
21
21
  ],
22
22
  "atlaskit:src": "src/index.ts",
23
23
  "dependencies": {
24
- "@atlaskit/adf-schema": "^56.2.0",
24
+ "@atlaskit/adf-schema": "^56.4.0",
25
25
  "@atlaskit/editor-plugin-analytics": "^12.1.0",
26
26
  "@atlaskit/editor-plugin-connectivity": "^12.1.0",
27
27
  "@atlaskit/editor-plugin-context-panel": "^14.1.0",
28
28
  "@atlaskit/editor-plugin-metrics": "^13.1.0",
29
+ "@atlaskit/editor-plugin-ui-control-registry": "^6.1.0",
29
30
  "@atlaskit/editor-prosemirror": "^8.0.0",
30
31
  "@atlaskit/editor-shared-styles": "^4.0.0",
32
+ "@atlaskit/editor-ui-control-model": "^2.4.0",
31
33
  "@atlaskit/feature-gate-js-client": "^6.0.0",
32
34
  "@atlaskit/heading": "^7.0.0",
33
35
  "@atlaskit/insm": "^1.2.0",
34
36
  "@atlaskit/menu": "^9.2.0",
37
+ "@atlaskit/platform-feature-experiments": "^0.3.0",
35
38
  "@atlaskit/platform-feature-flags": "^2.1.0",
36
39
  "@atlaskit/primitives": "^22.2.0",
37
40
  "@atlaskit/prosemirror-history": "^1.1.0",
38
41
  "@atlaskit/prosemirror-input-rules": "^4.0.0",
39
- "@atlaskit/tmp-editor-statsig": "^135.7.0",
42
+ "@atlaskit/tmp-editor-statsig": "^136.1.0",
40
43
  "@atlaskit/tokens": "^16.3.0",
41
44
  "@atlaskit/visually-hidden": "^4.2.0",
42
45
  "@babel/runtime": "^7.0.0",
@@ -48,12 +51,13 @@
48
51
  "w3c-keyname": "^2.1.8"
49
52
  },
50
53
  "peerDependencies": {
51
- "@atlaskit/editor-common": "^116.45.0",
54
+ "@atlaskit/editor-common": "^116.49.0",
52
55
  "react": "^18.2.0 || ^19.2.0",
53
56
  "react-dom": "^18.2.0 || ^19.2.0",
54
57
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
55
58
  },
56
59
  "devDependencies": {
60
+ "@atlassian/testing-library": "^0.11.0",
57
61
  "@testing-library/react": "^16.3.0",
58
62
  "@types/react-virtualized": "^9.18.12",
59
63
  "react": "^19.2.0",