@atlaskit/editor-plugin-type-ahead 0.6.0 → 0.7.1

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 (160) hide show
  1. package/.eslintrc.js +5 -0
  2. package/CHANGELOG.md +12 -0
  3. package/dist/cjs/api.js +215 -0
  4. package/dist/cjs/commands/insert-type-ahead-item.js +205 -0
  5. package/dist/cjs/commands/update-list-items.js +23 -0
  6. package/dist/cjs/commands/update-query.js +27 -0
  7. package/dist/cjs/commands/update-selected-index.js +27 -0
  8. package/dist/cjs/index.js +8 -1
  9. package/dist/cjs/insert-utils.js +107 -0
  10. package/dist/cjs/messages.js +79 -0
  11. package/dist/cjs/plugin.js +382 -0
  12. package/dist/cjs/pm-plugins/actions.js +16 -0
  13. package/dist/cjs/pm-plugins/decorations.js +148 -0
  14. package/dist/cjs/pm-plugins/input-rules.js +36 -0
  15. package/dist/cjs/pm-plugins/insert-item-plugin.js +22 -0
  16. package/dist/cjs/pm-plugins/key.js +8 -0
  17. package/dist/cjs/pm-plugins/main.js +110 -0
  18. package/dist/cjs/pm-plugins/reducer.js +158 -0
  19. package/dist/cjs/pm-plugins/utils.js +18 -0
  20. package/dist/cjs/stats-modifier.js +42 -0
  21. package/dist/cjs/transforms/close-type-ahead.js +13 -0
  22. package/dist/cjs/transforms/open-typeahead-at-cursor.js +75 -0
  23. package/dist/cjs/transforms/set-selection-before-query.js +18 -0
  24. package/dist/cjs/ui/AssistiveText.js +120 -0
  25. package/dist/cjs/ui/InputQuery.js +400 -0
  26. package/dist/cjs/ui/TypeAheadList.js +285 -0
  27. package/dist/cjs/ui/TypeAheadListItem.js +175 -0
  28. package/dist/cjs/ui/TypeAheadPopup.js +230 -0
  29. package/dist/cjs/ui/WrapperTypeAhead.js +127 -0
  30. package/dist/cjs/ui/hooks/use-item-insert.js +109 -0
  31. package/dist/cjs/ui/hooks/use-load-items.js +50 -0
  32. package/dist/cjs/ui/hooks/use-on-force-select.js +41 -0
  33. package/dist/cjs/utils.js +130 -0
  34. package/dist/es2019/api.js +205 -0
  35. package/dist/es2019/commands/insert-type-ahead-item.js +204 -0
  36. package/dist/es2019/commands/update-list-items.js +17 -0
  37. package/dist/es2019/commands/update-query.js +21 -0
  38. package/dist/es2019/commands/update-selected-index.js +21 -0
  39. package/dist/es2019/index.js +1 -1
  40. package/dist/es2019/insert-utils.js +106 -0
  41. package/dist/es2019/messages.js +73 -0
  42. package/dist/es2019/plugin.js +381 -0
  43. package/dist/es2019/pm-plugins/actions.js +10 -0
  44. package/dist/es2019/pm-plugins/decorations.js +148 -0
  45. package/dist/es2019/pm-plugins/input-rules.js +29 -0
  46. package/dist/es2019/pm-plugins/insert-item-plugin.js +16 -0
  47. package/dist/es2019/pm-plugins/key.js +2 -0
  48. package/dist/es2019/pm-plugins/main.js +106 -0
  49. package/dist/es2019/pm-plugins/reducer.js +160 -0
  50. package/dist/es2019/pm-plugins/utils.js +12 -0
  51. package/dist/es2019/stats-modifier.js +33 -0
  52. package/dist/es2019/transforms/close-type-ahead.js +7 -0
  53. package/dist/es2019/transforms/open-typeahead-at-cursor.js +71 -0
  54. package/dist/es2019/transforms/set-selection-before-query.js +10 -0
  55. package/dist/es2019/ui/AssistiveText.js +88 -0
  56. package/dist/es2019/ui/InputQuery.js +392 -0
  57. package/dist/es2019/ui/TypeAheadList.js +273 -0
  58. package/dist/es2019/ui/TypeAheadListItem.js +212 -0
  59. package/dist/es2019/ui/TypeAheadPopup.js +233 -0
  60. package/dist/es2019/ui/WrapperTypeAhead.js +109 -0
  61. package/dist/es2019/ui/hooks/use-item-insert.js +112 -0
  62. package/dist/es2019/ui/hooks/use-load-items.js +41 -0
  63. package/dist/es2019/ui/hooks/use-on-force-select.js +38 -0
  64. package/dist/es2019/utils.js +126 -0
  65. package/dist/esm/api.js +209 -0
  66. package/dist/esm/commands/insert-type-ahead-item.js +198 -0
  67. package/dist/esm/commands/update-list-items.js +17 -0
  68. package/dist/esm/commands/update-query.js +21 -0
  69. package/dist/esm/commands/update-selected-index.js +21 -0
  70. package/dist/esm/index.js +1 -1
  71. package/dist/esm/insert-utils.js +101 -0
  72. package/dist/esm/messages.js +73 -0
  73. package/dist/esm/plugin.js +374 -0
  74. package/dist/esm/pm-plugins/actions.js +10 -0
  75. package/dist/esm/pm-plugins/decorations.js +141 -0
  76. package/dist/esm/pm-plugins/input-rules.js +29 -0
  77. package/dist/esm/pm-plugins/insert-item-plugin.js +16 -0
  78. package/dist/esm/pm-plugins/key.js +2 -0
  79. package/dist/esm/pm-plugins/main.js +104 -0
  80. package/dist/esm/pm-plugins/reducer.js +151 -0
  81. package/dist/esm/pm-plugins/utils.js +12 -0
  82. package/dist/esm/stats-modifier.js +35 -0
  83. package/dist/esm/transforms/close-type-ahead.js +7 -0
  84. package/dist/esm/transforms/open-typeahead-at-cursor.js +69 -0
  85. package/dist/esm/transforms/set-selection-before-query.js +12 -0
  86. package/dist/esm/ui/AssistiveText.js +115 -0
  87. package/dist/esm/ui/InputQuery.js +389 -0
  88. package/dist/esm/ui/TypeAheadList.js +276 -0
  89. package/dist/esm/ui/TypeAheadListItem.js +165 -0
  90. package/dist/esm/ui/TypeAheadPopup.js +220 -0
  91. package/dist/esm/ui/WrapperTypeAhead.js +117 -0
  92. package/dist/esm/ui/hooks/use-item-insert.js +103 -0
  93. package/dist/esm/ui/hooks/use-load-items.js +43 -0
  94. package/dist/esm/ui/hooks/use-on-force-select.js +35 -0
  95. package/dist/esm/utils.js +124 -0
  96. package/dist/types/api.d.ts +60 -0
  97. package/dist/types/commands/insert-type-ahead-item.d.ts +12 -0
  98. package/dist/types/commands/update-list-items.d.ts +3 -0
  99. package/dist/types/commands/update-query.d.ts +2 -0
  100. package/dist/types/commands/update-selected-index.d.ts +2 -0
  101. package/dist/types/index.d.ts +2 -1
  102. package/dist/types/insert-utils.d.ts +18 -0
  103. package/dist/types/messages.d.ts +72 -0
  104. package/dist/types/plugin.d.ts +10 -0
  105. package/dist/types/pm-plugins/actions.d.ts +9 -0
  106. package/dist/types/pm-plugins/decorations.d.ts +14 -0
  107. package/dist/types/pm-plugins/input-rules.d.ts +6 -0
  108. package/dist/types/pm-plugins/insert-item-plugin.d.ts +2 -0
  109. package/dist/types/pm-plugins/key.d.ts +3 -0
  110. package/dist/types/pm-plugins/main.d.ts +14 -0
  111. package/dist/types/pm-plugins/reducer.d.ts +10 -0
  112. package/dist/types/pm-plugins/utils.d.ts +4 -0
  113. package/dist/types/stats-modifier.d.ts +20 -0
  114. package/dist/types/transforms/close-type-ahead.d.ts +2 -0
  115. package/dist/types/transforms/open-typeahead-at-cursor.d.ts +11 -0
  116. package/dist/types/transforms/set-selection-before-query.d.ts +2 -0
  117. package/dist/types/ui/AssistiveText.d.ts +33 -0
  118. package/dist/types/ui/InputQuery.d.ts +26 -0
  119. package/dist/types/ui/TypeAheadList.d.ts +25 -0
  120. package/dist/types/ui/TypeAheadListItem.d.ts +18 -0
  121. package/dist/types/ui/TypeAheadPopup.d.ts +29 -0
  122. package/dist/types/ui/WrapperTypeAhead.d.ts +20 -0
  123. package/dist/types/ui/hooks/use-item-insert.d.ts +3 -0
  124. package/dist/types/ui/hooks/use-load-items.d.ts +3 -0
  125. package/dist/types/ui/hooks/use-on-force-select.d.ts +11 -0
  126. package/dist/types/utils.d.ts +27 -0
  127. package/dist/types-ts4.5/api.d.ts +60 -0
  128. package/dist/types-ts4.5/commands/insert-type-ahead-item.d.ts +12 -0
  129. package/dist/types-ts4.5/commands/update-list-items.d.ts +3 -0
  130. package/dist/types-ts4.5/commands/update-query.d.ts +2 -0
  131. package/dist/types-ts4.5/commands/update-selected-index.d.ts +2 -0
  132. package/dist/types-ts4.5/index.d.ts +2 -1
  133. package/dist/types-ts4.5/insert-utils.d.ts +18 -0
  134. package/dist/types-ts4.5/messages.d.ts +72 -0
  135. package/dist/types-ts4.5/plugin.d.ts +10 -0
  136. package/dist/types-ts4.5/pm-plugins/actions.d.ts +9 -0
  137. package/dist/types-ts4.5/pm-plugins/decorations.d.ts +14 -0
  138. package/dist/types-ts4.5/pm-plugins/input-rules.d.ts +6 -0
  139. package/dist/types-ts4.5/pm-plugins/insert-item-plugin.d.ts +2 -0
  140. package/dist/types-ts4.5/pm-plugins/key.d.ts +3 -0
  141. package/dist/types-ts4.5/pm-plugins/main.d.ts +14 -0
  142. package/dist/types-ts4.5/pm-plugins/reducer.d.ts +10 -0
  143. package/dist/types-ts4.5/pm-plugins/utils.d.ts +4 -0
  144. package/dist/types-ts4.5/stats-modifier.d.ts +20 -0
  145. package/dist/types-ts4.5/transforms/close-type-ahead.d.ts +2 -0
  146. package/dist/types-ts4.5/transforms/open-typeahead-at-cursor.d.ts +11 -0
  147. package/dist/types-ts4.5/transforms/set-selection-before-query.d.ts +2 -0
  148. package/dist/types-ts4.5/ui/AssistiveText.d.ts +33 -0
  149. package/dist/types-ts4.5/ui/InputQuery.d.ts +26 -0
  150. package/dist/types-ts4.5/ui/TypeAheadList.d.ts +25 -0
  151. package/dist/types-ts4.5/ui/TypeAheadListItem.d.ts +18 -0
  152. package/dist/types-ts4.5/ui/TypeAheadPopup.d.ts +29 -0
  153. package/dist/types-ts4.5/ui/WrapperTypeAhead.d.ts +20 -0
  154. package/dist/types-ts4.5/ui/hooks/use-item-insert.d.ts +7 -0
  155. package/dist/types-ts4.5/ui/hooks/use-load-items.d.ts +3 -0
  156. package/dist/types-ts4.5/ui/hooks/use-on-force-select.d.ts +11 -0
  157. package/dist/types-ts4.5/utils.d.ts +27 -0
  158. package/package.json +21 -25
  159. package/report.api.md +29 -1
  160. package/tmp/api-report-tmp.d.ts +26 -0
@@ -0,0 +1,14 @@
1
+ import type { IntlShape } from 'react-intl-next';
2
+ import type { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
3
+ import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
4
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
+ import type { PopupMountPointReference, TypeAheadHandler } from '../types';
6
+ type Props = {
7
+ reactDispatch: Dispatch;
8
+ popupMountRef: PopupMountPointReference;
9
+ typeAheadHandlers: Array<TypeAheadHandler>;
10
+ createAnalyticsEvent?: CreateUIAnalyticsEvent;
11
+ getIntl: () => IntlShape;
12
+ };
13
+ export declare function createPlugin({ reactDispatch, popupMountRef, createAnalyticsEvent, typeAheadHandlers, getIntl, }: Props): SafePlugin;
14
+ export {};
@@ -0,0 +1,10 @@
1
+ import { InsertTypeAheadStep } from '@atlaskit/adf-schema/steps';
2
+ import type { ReadonlyTransaction } from '@atlaskit/editor-prosemirror/state';
3
+ import type { CreateTypeAheadDecorations, PopupMountPointReference, RemoveTypeAheadDecorations, TypeAheadHandler, TypeAheadPluginState } from '../types';
4
+ export type ReducerOptions = {
5
+ popupMountRef: PopupMountPointReference;
6
+ createDecorations: CreateTypeAheadDecorations;
7
+ removeDecorations: RemoveTypeAheadDecorations;
8
+ typeAheadHandlers: Array<TypeAheadHandler>;
9
+ };
10
+ export declare const createReducer: ({ typeAheadHandlers, removeDecorations, createDecorations, }: ReducerOptions) => (tr: ReadonlyTransaction, currentPluginState: TypeAheadPluginState, typeAheadStepOverride: InsertTypeAheadStep | null) => TypeAheadPluginState;
@@ -0,0 +1,4 @@
1
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ import type { InsertionTransactionMeta } from '../types';
3
+ import type { ACTIONS } from './actions';
4
+ export declare const isInsertionTransaction: (transactions: readonly Transaction[], action: ACTIONS) => InsertionTransactionMeta | null;
@@ -0,0 +1,20 @@
1
+ import type { TypeAheadStatsModifier } from './types';
2
+ export declare class StatsModifier implements TypeAheadStatsModifier {
3
+ startedAt: number;
4
+ endedAt: number;
5
+ keyCount: {
6
+ arrowUp: number;
7
+ arrowDown: number;
8
+ };
9
+ constructor();
10
+ increaseArrowUp: () => void;
11
+ increaseArrowDown: () => void;
12
+ serialize: () => {
13
+ startedAt: number;
14
+ endedAt: number;
15
+ keyCount: {
16
+ arrowUp: number;
17
+ arrowDown: number;
18
+ };
19
+ };
20
+ }
@@ -0,0 +1,2 @@
1
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ export declare const closeTypeAhead: (tr: Transaction) => Transaction;
@@ -0,0 +1,11 @@
1
+ import type { EditorCommand } from '@atlaskit/editor-common/types';
2
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
3
+ import type { TypeAheadHandler, TypeAheadInputMethod } from '../types';
4
+ type Props = {
5
+ triggerHandler: TypeAheadHandler;
6
+ inputMethod: TypeAheadInputMethod;
7
+ query?: string;
8
+ };
9
+ export declare const openTypeAhead: (props: Props) => (tr: Transaction) => void;
10
+ export declare const openTypeAheadAtCursor: ({ triggerHandler, inputMethod, query }: Props) => EditorCommand;
11
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ export declare const setSelectionBeforeQuery: (rawText: string) => (tr: Transaction) => void;
@@ -0,0 +1,33 @@
1
+ /** @jsx jsx */
2
+ /// <reference types="lodash" />
3
+ import React from 'react';
4
+ import { jsx } from '@emotion/react';
5
+ import debounce from 'lodash/debounce';
6
+ type Cancelable = ReturnType<typeof debounce>;
7
+ type AssistiveTextProps = {
8
+ assistiveText: string;
9
+ isInFocus: boolean;
10
+ id: string;
11
+ statusDebounceMillis?: number;
12
+ debounce?: boolean;
13
+ };
14
+ type AssistiveTextState = {
15
+ bump: boolean;
16
+ debounced: boolean;
17
+ silenced: boolean;
18
+ };
19
+ declare class AssistveTextComponent extends React.Component<AssistiveTextProps, AssistiveTextState> {
20
+ static defaultProps: AssistiveTextProps;
21
+ debounceStatusUpdate: (() => void) & Cancelable;
22
+ state: {
23
+ bump: boolean;
24
+ debounced: boolean;
25
+ silenced: boolean;
26
+ };
27
+ componentWillMount(): void;
28
+ componentWillUnmount(): void;
29
+ componentWillReceiveProps(): void;
30
+ render(): jsx.JSX.Element;
31
+ }
32
+ export declare const AssistiveText: typeof AssistveTextComponent;
33
+ export {};
@@ -0,0 +1,26 @@
1
+ /** @jsx jsx */
2
+ import React from 'react';
3
+ import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
4
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
+ import { CloseSelectionOptions } from '../constants';
6
+ type InputQueryProps = {
7
+ triggerQueryPrefix: string;
8
+ onQueryChange: (query: string) => void;
9
+ onItemSelect: (mode: SelectItemMode) => void;
10
+ selectNextItem: () => void;
11
+ selectPreviousItem: () => void;
12
+ cancel: (props: {
13
+ forceFocusOnEditor: boolean;
14
+ setSelectionAt: CloseSelectionOptions;
15
+ addPrefixTrigger: boolean;
16
+ text: string;
17
+ }) => void;
18
+ onQueryFocus: () => void;
19
+ forceFocus: boolean;
20
+ onUndoRedo?: (inputType: 'historyUndo' | 'historyRedo') => boolean;
21
+ reopenQuery?: string;
22
+ editorView: EditorView;
23
+ items: any[];
24
+ };
25
+ export declare const InputQuery: React.FC<InputQueryProps>;
26
+ export {};
@@ -0,0 +1,25 @@
1
+ /** @jsx jsx */
2
+ import React from 'react';
3
+ import type { WrappedComponentProps } from 'react-intl-next';
4
+ import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
5
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { TypeAheadHandler, TypeAheadItem } from '../types';
7
+ export declare const TypeAheadList: React.FC<import("react-intl-next").WithIntlProps<{
8
+ items: Array<TypeAheadItem>;
9
+ selectedIndex: number;
10
+ editorView: EditorView;
11
+ onItemClick: (mode: SelectItemMode, index: number) => void;
12
+ fitHeight: number;
13
+ decorationElement: HTMLElement;
14
+ triggerHandler?: TypeAheadHandler | undefined;
15
+ } & WrappedComponentProps<"intl">>> & {
16
+ WrappedComponent: React.ComponentType<{
17
+ items: Array<TypeAheadItem>;
18
+ selectedIndex: number;
19
+ editorView: EditorView;
20
+ onItemClick: (mode: SelectItemMode, index: number) => void;
21
+ fitHeight: number;
22
+ decorationElement: HTMLElement;
23
+ triggerHandler?: TypeAheadHandler | undefined;
24
+ } & WrappedComponentProps<"intl">>;
25
+ };
@@ -0,0 +1,18 @@
1
+ /** @jsx jsx */
2
+ import React from 'react';
3
+ import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
4
+ import type { TypeAheadItem } from '../types';
5
+ export declare const ICON_HEIGHT = 40;
6
+ export declare const ICON_WIDTH = 40;
7
+ export declare const ITEM_PADDING = 12;
8
+ export declare const itemIcon: import("@emotion/react").SerializedStyles;
9
+ type TypeAheadListItemProps = {
10
+ item: TypeAheadItem;
11
+ itemsLength: number;
12
+ itemIndex: number;
13
+ selectedIndex: number;
14
+ ariaLabel?: string;
15
+ onItemClick: (mode: SelectItemMode, index: number) => void;
16
+ };
17
+ export declare const TypeAheadListItem: React.FC<TypeAheadListItemProps>;
18
+ export {};
@@ -0,0 +1,29 @@
1
+ /** @jsx jsx */
2
+ import React from 'react';
3
+ import type { FireAnalyticsCallback } from '@atlaskit/editor-common/analytics';
4
+ import type { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
5
+ import type { DecorationSet, EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import { CloseSelectionOptions } from '../constants';
7
+ import type { OnSelectItem, TypeAheadHandler, TypeAheadItem } from '../types';
8
+ type TypeAheadPopupProps = {
9
+ triggerHandler: TypeAheadHandler;
10
+ editorView: EditorView;
11
+ anchorElement: HTMLElement;
12
+ popupsMountPoint?: HTMLElement;
13
+ popupsBoundariesElement?: HTMLElement;
14
+ popupsScrollableElement?: HTMLElement;
15
+ fireAnalyticsCallback: FireAnalyticsCallback;
16
+ items: Array<TypeAheadItem>;
17
+ selectedIndex: number;
18
+ setSelectedItem: OnSelectItem;
19
+ decorationSet: DecorationSet;
20
+ isEmptyQuery: boolean;
21
+ onItemInsert: (mode: SelectItemMode, index: number) => void;
22
+ cancel: (params: {
23
+ setSelectionAt: CloseSelectionOptions;
24
+ addPrefixTrigger: boolean;
25
+ forceFocusOnEditor: boolean;
26
+ }) => void;
27
+ };
28
+ export declare const TypeAheadPopup: React.FC<TypeAheadPopupProps>;
29
+ export {};
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import type { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ import type { TypeAheadHandler, TypeAheadInputMethod } from '../types';
5
+ type WrapperProps = {
6
+ triggerHandler: TypeAheadHandler;
7
+ editorView: EditorView;
8
+ anchorElement: HTMLElement;
9
+ getDecorationPosition: () => number | undefined;
10
+ shouldFocusCursorInsideQuery: boolean;
11
+ onUndoRedo?: (inputType: 'historyUndo' | 'historyRedo') => boolean;
12
+ reopenQuery?: string;
13
+ popupsMountPoint?: HTMLElement;
14
+ popupsBoundariesElement?: HTMLElement;
15
+ popupsScrollableElement?: HTMLElement;
16
+ createAnalyticsEvent?: CreateUIAnalyticsEvent;
17
+ inputMethod?: TypeAheadInputMethod;
18
+ };
19
+ export declare const WrapperTypeAhead: React.FC<WrapperProps>;
20
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
+ import type { OnInsertSelectedItem, OnItemMatch, OnTextInsert, TypeAheadHandler, TypeAheadItem } from '../../types';
3
+ export declare const useItemInsert: (triggerHandler: TypeAheadHandler, editorView: EditorView, items: Array<TypeAheadItem>) => [OnInsertSelectedItem, OnTextInsert, OnItemMatch];
@@ -0,0 +1,3 @@
1
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
+ import type { TypeAheadHandler, TypeAheadItem } from '../../types';
3
+ export declare const useLoadItems: (triggerHandler: TypeAheadHandler, editorView: EditorView, query: string) => Array<TypeAheadItem>;
@@ -0,0 +1,11 @@
1
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
+ import type { TypeAheadHandler, TypeAheadItem } from '../../types';
3
+ type Props = {
4
+ triggerHandler: TypeAheadHandler;
5
+ items: Array<TypeAheadItem>;
6
+ query: string;
7
+ editorView: EditorView;
8
+ closePopup: () => void;
9
+ };
10
+ export declare const useOnForceSelect: ({ triggerHandler, items, query, editorView, closePopup, }: Props) => void;
11
+ export {};
@@ -0,0 +1,27 @@
1
+ import type { IntlShape } from 'react-intl-next';
2
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ import type { TypeAheadHandler, TypeAheadItem } from './types';
5
+ export declare const isTypeAheadHandler: (handler: any) => handler is TypeAheadHandler;
6
+ /** Is a typeahead plugin open? */
7
+ export declare const isTypeAheadOpen: (editorState: EditorState) => boolean;
8
+ export declare const getPluginState: (editorState: EditorState) => import("./types").TypeAheadPluginState | undefined;
9
+ export declare const getTypeAheadHandler: (editorState: EditorState) => TypeAheadHandler | undefined;
10
+ export declare const getTypeAheadQuery: (editorState: EditorState) => string | undefined;
11
+ export declare const isTypeAheadAllowed: (state: EditorState) => boolean;
12
+ export declare const findHandler: (id: string, state: EditorState) => TypeAheadHandler | null;
13
+ export declare const findHandlerByTrigger: ({ trigger, editorState, }: {
14
+ trigger: string;
15
+ editorState: EditorState;
16
+ }) => TypeAheadHandler | null;
17
+ type MoveSelectedIndexProps = {
18
+ editorView: EditorView;
19
+ direction: 'next' | 'previous';
20
+ };
21
+ export declare const moveSelectedIndex: ({ editorView, direction }: MoveSelectedIndexProps) => () => void;
22
+ type TypeAheadAssistiveLabels = {
23
+ popupAriaLabel: string;
24
+ listItemAriaLabel?: string;
25
+ };
26
+ export declare const getTypeAheadListAriaLabels: (trigger: string | undefined, intl: IntlShape, item?: TypeAheadItem) => TypeAheadAssistiveLabels;
27
+ export {};
@@ -0,0 +1,60 @@
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
+ insertCurrentQueryAsRawText: boolean;
8
+ attachCommand?: Command;
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
+ isOpen: () => TypeAheadHandler | false;
24
+ currentQuery: () => string | undefined;
25
+ close: (options?: CloseOptions) => boolean;
26
+ openMention: (inputMethod: TypeAheadInputMethod) => boolean;
27
+ searchMention: (query?: string) => {
28
+ type: (appendValue: string) => Promise<TypeAheadItem[]> | undefined;
29
+ result: () => Promise<TypeAheadItem[] | undefined>;
30
+ close: (options?: CloseOptions) => boolean;
31
+ insert: ({ index, mode }: {
32
+ index: number;
33
+ mode?: SelectItemMode | undefined;
34
+ }) => Promise<void>;
35
+ };
36
+ openQuickInsert: (inputMethod: TypeAheadInputMethod) => boolean;
37
+ searchQuickInsert: (query?: string) => {
38
+ type: (appendValue: string) => Promise<TypeAheadItem[]> | undefined;
39
+ result: () => Promise<TypeAheadItem[] | undefined>;
40
+ close: (options?: CloseOptions) => boolean;
41
+ insert: ({ index, mode }: {
42
+ index: number;
43
+ mode?: SelectItemMode | undefined;
44
+ }) => Promise<void>;
45
+ };
46
+ openEmoji: (inputMethod: TypeAheadInputMethod) => boolean;
47
+ searchEmoji: (query?: string) => {
48
+ type: (appendValue: string) => Promise<TypeAheadItem[]> | undefined;
49
+ result: () => Promise<TypeAheadItem[] | undefined>;
50
+ close: (options?: CloseOptions) => boolean;
51
+ insert: ({ index, mode }: {
52
+ index: number;
53
+ mode?: SelectItemMode | undefined;
54
+ }) => Promise<void>;
55
+ };
56
+ insertItemMention: ({ contentItem, query, sourceListItem }: InsertItemProps) => boolean;
57
+ insertItemEmoji: ({ contentItem, query, sourceListItem }: InsertItemProps) => boolean;
58
+ insertItemQuickInsert: ({ contentItem, query, sourceListItem }: InsertItemProps) => boolean;
59
+ };
60
+ export {};
@@ -0,0 +1,12 @@
1
+ import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
2
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
+ import type { TypeAheadHandler, TypeAheadItem } from '../types';
4
+ type Props = {
5
+ item: TypeAheadItem;
6
+ handler: TypeAheadHandler;
7
+ mode: SelectItemMode;
8
+ sourceListItem: Array<TypeAheadItem>;
9
+ query: string;
10
+ };
11
+ export declare const insertTypeAheadItem: (view: EditorView) => ({ item, handler, mode, query, sourceListItem }: Props) => void;
12
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { Command } from '@atlaskit/editor-common/types';
2
+ import type { TypeAheadItem } from '../types';
3
+ export declare const updateListItem: (items: Array<TypeAheadItem>) => Command;
@@ -0,0 +1,2 @@
1
+ import type { Command } from '@atlaskit/editor-common/types';
2
+ export declare const updateQuery: (query: string) => Command;
@@ -0,0 +1,2 @@
1
+ import type { Command } from '@atlaskit/editor-common/types';
2
+ export declare const updateSelectedIndex: (selectedIndex: number) => Command;
@@ -1 +1,2 @@
1
- export type { TypeAheadPlugin, TypeAheadPluginOptions, TypeAheadInputMethod, } from './types';
1
+ export { typeAheadPlugin } from './plugin';
2
+ export type { TypeAheadHandler, TypeAheadInputMethod, TypeAheadPlugin, TypeAheadPluginOptions, TypeAheadPluginState, } from './types';
@@ -0,0 +1,18 @@
1
+ import { Fragment, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
3
+ type Position = {
4
+ start: number;
5
+ end: number;
6
+ };
7
+ export declare const insertBlockNode: ({ node, tr, position, }: {
8
+ node: PMNode;
9
+ tr: Transaction;
10
+ position: Position;
11
+ }) => Transaction;
12
+ export declare const insertInlineNodeOrFragment: ({ maybeFragment, tr, position, selectInlineNode, }: {
13
+ maybeFragment: Fragment | PMNode;
14
+ tr: Transaction;
15
+ position: Position;
16
+ selectInlineNode: boolean;
17
+ }) => Transaction;
18
+ export {};
@@ -0,0 +1,72 @@
1
+ export declare const typeAheadListMessages: {
2
+ typeAheadPopupLabel: {
3
+ id: string;
4
+ defaultMessage: string;
5
+ description: string;
6
+ };
7
+ quickInsertPopupLabel: {
8
+ id: string;
9
+ defaultMessage: string;
10
+ description: string;
11
+ };
12
+ quickInsertInputLabel: {
13
+ id: string;
14
+ defaultMessage: string;
15
+ description: string;
16
+ };
17
+ emojiPopupLabel: {
18
+ id: string;
19
+ defaultMessage: string;
20
+ description: string;
21
+ };
22
+ emojiInputLabel: {
23
+ id: string;
24
+ defaultMessage: string;
25
+ description: string;
26
+ };
27
+ mentionPopupLabel: {
28
+ id: string;
29
+ defaultMessage: string;
30
+ description: string;
31
+ };
32
+ mentionInputLabel: {
33
+ id: string;
34
+ defaultMessage: string;
35
+ description: string;
36
+ };
37
+ metionListItemLabel: {
38
+ id: string;
39
+ defaultMessage: string;
40
+ description: string;
41
+ };
42
+ emojiListItemLabel: {
43
+ id: string;
44
+ defaultMessage: string;
45
+ description: string;
46
+ };
47
+ inputQueryAssistiveLabel: {
48
+ id: string;
49
+ defaultMessage: string;
50
+ description: string;
51
+ };
52
+ searchResultsLabel: {
53
+ id: string;
54
+ defaultMessage: string;
55
+ description: string;
56
+ };
57
+ noSearchResultsLabel: {
58
+ id: string;
59
+ defaultMessage: string;
60
+ description: string;
61
+ };
62
+ descriptionLabel: {
63
+ id: string;
64
+ defaultMessage: string;
65
+ description: string;
66
+ };
67
+ shortcutLabel: {
68
+ id: string;
69
+ defaultMessage: string;
70
+ description: string;
71
+ };
72
+ };
@@ -0,0 +1,10 @@
1
+ import type { TypeAheadPlugin } from './types';
2
+ /**
3
+ *
4
+ * Revamped typeahead using decorations instead of the `typeAheadQuery` mark
5
+ *
6
+ * https://product-fabric.atlassian.net/wiki/spaces/E/pages/2992177582/Technical+TypeAhead+Data+Flow
7
+ *
8
+ *
9
+ */
10
+ export declare const typeAheadPlugin: TypeAheadPlugin;
@@ -0,0 +1,9 @@
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_SELECTED_INDEX = "UPDATE_SELECTED_INDEX"
9
+ }
@@ -0,0 +1,14 @@
1
+ import type { IntlShape } from 'react-intl-next';
2
+ import type { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
3
+ import type { CreateTypeAheadDecorations, PopupMountPointReference, RemoveTypeAheadDecorations } from '../types';
4
+ type FactoryProps = {
5
+ intl: IntlShape;
6
+ popupMountRef: PopupMountPointReference;
7
+ createAnalyticsEvent?: CreateUIAnalyticsEvent;
8
+ };
9
+ type FactoryReturn = {
10
+ createDecorations: CreateTypeAheadDecorations;
11
+ removeDecorations: RemoveTypeAheadDecorations;
12
+ };
13
+ export declare const factoryDecorations: ({ intl, popupMountRef, createAnalyticsEvent, }: FactoryProps) => FactoryReturn;
14
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import type { FeatureFlags } from '@atlaskit/editor-common/types';
3
+ import type { Schema } from '@atlaskit/editor-prosemirror/model';
4
+ import type { TypeAheadHandler } from '../types';
5
+ export declare function inputRulePlugin(schema: Schema, typeAheads: TypeAheadHandler[], featureFlags: FeatureFlags): SafePlugin | undefined;
6
+ export default inputRulePlugin;
@@ -0,0 +1,2 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ export declare function createPlugin(): SafePlugin;
@@ -0,0 +1,3 @@
1
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
+ import type { TypeAheadPluginState } from '../types';
3
+ export declare const pluginKey: PluginKey<TypeAheadPluginState>;
@@ -0,0 +1,14 @@
1
+ import type { IntlShape } from 'react-intl-next';
2
+ import type { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
3
+ import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
4
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
+ import type { PopupMountPointReference, TypeAheadHandler } from '../types';
6
+ type Props = {
7
+ reactDispatch: Dispatch;
8
+ popupMountRef: PopupMountPointReference;
9
+ typeAheadHandlers: Array<TypeAheadHandler>;
10
+ createAnalyticsEvent?: CreateUIAnalyticsEvent;
11
+ getIntl: () => IntlShape;
12
+ };
13
+ export declare function createPlugin({ reactDispatch, popupMountRef, createAnalyticsEvent, typeAheadHandlers, getIntl, }: Props): SafePlugin;
14
+ export {};
@@ -0,0 +1,10 @@
1
+ import { InsertTypeAheadStep } from '@atlaskit/adf-schema/steps';
2
+ import type { ReadonlyTransaction } from '@atlaskit/editor-prosemirror/state';
3
+ import type { CreateTypeAheadDecorations, PopupMountPointReference, RemoveTypeAheadDecorations, TypeAheadHandler, TypeAheadPluginState } from '../types';
4
+ export type ReducerOptions = {
5
+ popupMountRef: PopupMountPointReference;
6
+ createDecorations: CreateTypeAheadDecorations;
7
+ removeDecorations: RemoveTypeAheadDecorations;
8
+ typeAheadHandlers: Array<TypeAheadHandler>;
9
+ };
10
+ export declare const createReducer: ({ typeAheadHandlers, removeDecorations, createDecorations, }: ReducerOptions) => (tr: ReadonlyTransaction, currentPluginState: TypeAheadPluginState, typeAheadStepOverride: InsertTypeAheadStep | null) => TypeAheadPluginState;
@@ -0,0 +1,4 @@
1
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ import type { InsertionTransactionMeta } from '../types';
3
+ import type { ACTIONS } from './actions';
4
+ export declare const isInsertionTransaction: (transactions: readonly Transaction[], action: ACTIONS) => InsertionTransactionMeta | null;
@@ -0,0 +1,20 @@
1
+ import type { TypeAheadStatsModifier } from './types';
2
+ export declare class StatsModifier implements TypeAheadStatsModifier {
3
+ startedAt: number;
4
+ endedAt: number;
5
+ keyCount: {
6
+ arrowUp: number;
7
+ arrowDown: number;
8
+ };
9
+ constructor();
10
+ increaseArrowUp: () => void;
11
+ increaseArrowDown: () => void;
12
+ serialize: () => {
13
+ startedAt: number;
14
+ endedAt: number;
15
+ keyCount: {
16
+ arrowUp: number;
17
+ arrowDown: number;
18
+ };
19
+ };
20
+ }
@@ -0,0 +1,2 @@
1
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ export declare const closeTypeAhead: (tr: Transaction) => Transaction;
@@ -0,0 +1,11 @@
1
+ import type { EditorCommand } from '@atlaskit/editor-common/types';
2
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
3
+ import type { TypeAheadHandler, TypeAheadInputMethod } from '../types';
4
+ type Props = {
5
+ triggerHandler: TypeAheadHandler;
6
+ inputMethod: TypeAheadInputMethod;
7
+ query?: string;
8
+ };
9
+ export declare const openTypeAhead: (props: Props) => (tr: Transaction) => void;
10
+ export declare const openTypeAheadAtCursor: ({ triggerHandler, inputMethod, query }: Props) => EditorCommand;
11
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ export declare const setSelectionBeforeQuery: (rawText: string) => (tr: Transaction) => void;
@@ -0,0 +1,33 @@
1
+ /// <reference types="lodash" />
2
+ /** @jsx jsx */
3
+ import React from 'react';
4
+ import { jsx } from '@emotion/react';
5
+ import debounce from 'lodash/debounce';
6
+ type Cancelable = ReturnType<typeof debounce>;
7
+ type AssistiveTextProps = {
8
+ assistiveText: string;
9
+ isInFocus: boolean;
10
+ id: string;
11
+ statusDebounceMillis?: number;
12
+ debounce?: boolean;
13
+ };
14
+ type AssistiveTextState = {
15
+ bump: boolean;
16
+ debounced: boolean;
17
+ silenced: boolean;
18
+ };
19
+ declare class AssistveTextComponent extends React.Component<AssistiveTextProps, AssistiveTextState> {
20
+ static defaultProps: AssistiveTextProps;
21
+ debounceStatusUpdate: (() => void) & Cancelable;
22
+ state: {
23
+ bump: boolean;
24
+ debounced: boolean;
25
+ silenced: boolean;
26
+ };
27
+ componentWillMount(): void;
28
+ componentWillUnmount(): void;
29
+ componentWillReceiveProps(): void;
30
+ render(): jsx.JSX.Element;
31
+ }
32
+ export declare const AssistiveText: typeof AssistveTextComponent;
33
+ export {};