@atlaskit/editor-plugin-type-ahead 0.5.0 → 0.6.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/editor-plugin-type-ahead
2
2
 
3
+ ## 0.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#41459](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41459) [`9874d0f70b0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9874d0f70b0) - [ED-20003] TypeAhead extraction: Replace the mobile view-subscription with proper API
8
+
3
9
  ## 0.5.0
4
10
 
5
11
  ### Minor Changes
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TYPE_AHEAD_POPUP_CONTENT_CLASS = exports.TYPE_AHEAD_DECORATION_KEY = exports.TYPE_AHEAD_DECORATION_ELEMENT_ID = exports.TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE = exports.CloseSelectionOptions = void 0;
7
+ var TYPE_AHEAD_DECORATION_KEY = exports.TYPE_AHEAD_DECORATION_KEY = 'typeahead_decoration_key';
8
+ var TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE = exports.TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE = 'typeaheadDecoration';
9
+ var TYPE_AHEAD_POPUP_CONTENT_CLASS = exports.TYPE_AHEAD_POPUP_CONTENT_CLASS = 'fabric-editor-typeahead';
10
+ var TYPE_AHEAD_DECORATION_ELEMENT_ID = exports.TYPE_AHEAD_DECORATION_ELEMENT_ID = 'typeahaed_decoration_element_id';
11
+ var CloseSelectionOptions = exports.CloseSelectionOptions = /*#__PURE__*/function (CloseSelectionOptions) {
12
+ CloseSelectionOptions["BEFORE_TEXT_INSERTED"] = "BEFORE_TEXT_INSERTED";
13
+ CloseSelectionOptions["AFTER_TEXT_INSERTED"] = "AFTER_TEXT_INSERTED";
14
+ return CloseSelectionOptions;
15
+ }({});
@@ -0,0 +1,9 @@
1
+ export const TYPE_AHEAD_DECORATION_KEY = 'typeahead_decoration_key';
2
+ export const TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE = 'typeaheadDecoration';
3
+ export const TYPE_AHEAD_POPUP_CONTENT_CLASS = 'fabric-editor-typeahead';
4
+ export const TYPE_AHEAD_DECORATION_ELEMENT_ID = 'typeahaed_decoration_element_id';
5
+ export let CloseSelectionOptions = /*#__PURE__*/function (CloseSelectionOptions) {
6
+ CloseSelectionOptions["BEFORE_TEXT_INSERTED"] = "BEFORE_TEXT_INSERTED";
7
+ CloseSelectionOptions["AFTER_TEXT_INSERTED"] = "AFTER_TEXT_INSERTED";
8
+ return CloseSelectionOptions;
9
+ }({});
@@ -0,0 +1,9 @@
1
+ export var TYPE_AHEAD_DECORATION_KEY = 'typeahead_decoration_key';
2
+ export var TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE = 'typeaheadDecoration';
3
+ export var TYPE_AHEAD_POPUP_CONTENT_CLASS = 'fabric-editor-typeahead';
4
+ export var TYPE_AHEAD_DECORATION_ELEMENT_ID = 'typeahaed_decoration_element_id';
5
+ export var CloseSelectionOptions = /*#__PURE__*/function (CloseSelectionOptions) {
6
+ CloseSelectionOptions["BEFORE_TEXT_INSERTED"] = "BEFORE_TEXT_INSERTED";
7
+ CloseSelectionOptions["AFTER_TEXT_INSERTED"] = "AFTER_TEXT_INSERTED";
8
+ return CloseSelectionOptions;
9
+ }({});
@@ -0,0 +1,8 @@
1
+ export declare const TYPE_AHEAD_DECORATION_KEY = "typeahead_decoration_key";
2
+ export declare const TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE = "typeaheadDecoration";
3
+ export declare const TYPE_AHEAD_POPUP_CONTENT_CLASS = "fabric-editor-typeahead";
4
+ export declare const TYPE_AHEAD_DECORATION_ELEMENT_ID = "typeahaed_decoration_element_id";
5
+ export declare enum CloseSelectionOptions {
6
+ BEFORE_TEXT_INSERTED = "BEFORE_TEXT_INSERTED",
7
+ AFTER_TEXT_INSERTED = "AFTER_TEXT_INSERTED"
8
+ }
@@ -1,9 +1,68 @@
1
1
  import type { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
2
2
  import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import type { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
4
- import type { Command, NextEditorPlugin, OptionalPlugin, TypeAheadHandler, TypeAheadItem } from '@atlaskit/editor-common/types';
4
+ import type { Command, NextEditorPlugin, OptionalPlugin, TypeAheadForceSelect, TypeAheadHandler, TypeAheadInsert, TypeAheadItem, TypeAheadItemRenderProps, TypeAheadSelectItem, TypeAheadStats, UiComponentFactoryParams } from '@atlaskit/editor-common/types';
5
5
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
6
- import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
6
+ import type { EditorState, ReadonlyTransaction, Transaction } from '@atlaskit/editor-prosemirror/state';
7
+ import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
8
+ import type { CloseSelectionOptions } from './constants';
9
+ export type { TypeAheadStats, TypeAheadItemRenderProps, TypeAheadInsert, TypeAheadSelectItem, TypeAheadItem, TypeAheadForceSelect, TypeAheadHandler, };
10
+ export type OnSelectItem = (props: {
11
+ index: number;
12
+ item: TypeAheadItem;
13
+ }) => void;
14
+ export interface TypeAheadStatsSerializable extends TypeAheadStats {
15
+ serialize: () => TypeAheadStats;
16
+ }
17
+ export interface TypeAheadStatsModifier extends TypeAheadStatsSerializable {
18
+ increaseArrowUp: () => void;
19
+ increaseArrowDown: () => void;
20
+ }
21
+ export interface TypeAheadStatsMobileModifier extends TypeAheadStatsSerializable {
22
+ resetTime: () => void;
23
+ closeTime: () => void;
24
+ }
25
+ export type TypeAheadPluginState = {
26
+ decorationSet: DecorationSet;
27
+ decorationElement: HTMLElement | null;
28
+ typeAheadHandlers: Array<TypeAheadHandler>;
29
+ query: string;
30
+ items: Array<TypeAheadItem>;
31
+ triggerHandler?: TypeAheadHandler;
32
+ selectedIndex: number;
33
+ stats: TypeAheadStatsSerializable | null;
34
+ inputMethod: TypeAheadInputMethod | null;
35
+ };
36
+ export type OnInsertSelectedItemProps = {
37
+ mode: SelectItemMode;
38
+ index: number;
39
+ query: string;
40
+ };
41
+ export type OnItemMatchProps = {
42
+ mode: SelectItemMode;
43
+ query: string;
44
+ };
45
+ export type OnInsertSelectedItem = (props: OnInsertSelectedItemProps) => void;
46
+ export type OnItemMatch = (props: OnItemMatchProps) => boolean;
47
+ export type OnTextInsertProps = {
48
+ forceFocusOnEditor: boolean;
49
+ setSelectionAt: CloseSelectionOptions;
50
+ text: string;
51
+ };
52
+ export type OnTextInsert = (props: OnTextInsertProps) => void;
53
+ export type InsertionTransactionMeta = (editorState: EditorState) => Transaction | false;
54
+ type PopupMountPoints = Pick<UiComponentFactoryParams, 'popupsMountPoint' | 'popupsBoundariesElement' | 'popupsScrollableElement'>;
55
+ export type PopupMountPointReference = Record<'current', PopupMountPoints | null>;
56
+ export type CreateTypeAheadDecorations = (tr: ReadonlyTransaction, options: {
57
+ triggerHandler: TypeAheadHandler;
58
+ inputMethod: TypeAheadInputMethod;
59
+ reopenQuery?: string;
60
+ }) => {
61
+ decorationSet: DecorationSet;
62
+ decorationElement: HTMLElement | null;
63
+ stats: TypeAheadStatsSerializable | null;
64
+ };
65
+ export type RemoveTypeAheadDecorations = (decorationSet?: DecorationSet) => boolean;
7
66
  export type TypeAheadInputMethod = INPUT_METHOD.INSERT_MENU | INPUT_METHOD.KEYBOARD | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.TOOLBAR;
8
67
  export type TypeAheadPluginOptions = {
9
68
  isMobile?: boolean;
@@ -34,6 +93,9 @@ export type TypeAheadPlugin = NextEditorPlugin<'typeAhead', {
34
93
  dependencies: [OptionalPlugin<AnalyticsPlugin>];
35
94
  sharedState: {
36
95
  query: string;
96
+ isOpen: boolean;
97
+ isAllowed: boolean;
98
+ currentHandler?: TypeAheadHandler;
37
99
  };
38
100
  actions: {
39
101
  isOpen: (editorState: EditorState) => boolean;
@@ -45,4 +107,3 @@ export type TypeAheadPlugin = NextEditorPlugin<'typeAhead', {
45
107
  openAtTransaction: (props: OpenTypeAheadProps) => (tr: Transaction) => boolean;
46
108
  };
47
109
  }>;
48
- export {};
@@ -0,0 +1,8 @@
1
+ export declare const TYPE_AHEAD_DECORATION_KEY = "typeahead_decoration_key";
2
+ export declare const TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE = "typeaheadDecoration";
3
+ export declare const TYPE_AHEAD_POPUP_CONTENT_CLASS = "fabric-editor-typeahead";
4
+ export declare const TYPE_AHEAD_DECORATION_ELEMENT_ID = "typeahaed_decoration_element_id";
5
+ export declare enum CloseSelectionOptions {
6
+ BEFORE_TEXT_INSERTED = "BEFORE_TEXT_INSERTED",
7
+ AFTER_TEXT_INSERTED = "AFTER_TEXT_INSERTED"
8
+ }
@@ -1,9 +1,68 @@
1
1
  import type { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
2
2
  import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import type { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
4
- import type { Command, NextEditorPlugin, OptionalPlugin, TypeAheadHandler, TypeAheadItem } from '@atlaskit/editor-common/types';
4
+ import type { Command, NextEditorPlugin, OptionalPlugin, TypeAheadForceSelect, TypeAheadHandler, TypeAheadInsert, TypeAheadItem, TypeAheadItemRenderProps, TypeAheadSelectItem, TypeAheadStats, UiComponentFactoryParams } from '@atlaskit/editor-common/types';
5
5
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
6
- import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
6
+ import type { EditorState, ReadonlyTransaction, Transaction } from '@atlaskit/editor-prosemirror/state';
7
+ import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
8
+ import type { CloseSelectionOptions } from './constants';
9
+ export type { TypeAheadStats, TypeAheadItemRenderProps, TypeAheadInsert, TypeAheadSelectItem, TypeAheadItem, TypeAheadForceSelect, TypeAheadHandler, };
10
+ export type OnSelectItem = (props: {
11
+ index: number;
12
+ item: TypeAheadItem;
13
+ }) => void;
14
+ export interface TypeAheadStatsSerializable extends TypeAheadStats {
15
+ serialize: () => TypeAheadStats;
16
+ }
17
+ export interface TypeAheadStatsModifier extends TypeAheadStatsSerializable {
18
+ increaseArrowUp: () => void;
19
+ increaseArrowDown: () => void;
20
+ }
21
+ export interface TypeAheadStatsMobileModifier extends TypeAheadStatsSerializable {
22
+ resetTime: () => void;
23
+ closeTime: () => void;
24
+ }
25
+ export type TypeAheadPluginState = {
26
+ decorationSet: DecorationSet;
27
+ decorationElement: HTMLElement | null;
28
+ typeAheadHandlers: Array<TypeAheadHandler>;
29
+ query: string;
30
+ items: Array<TypeAheadItem>;
31
+ triggerHandler?: TypeAheadHandler;
32
+ selectedIndex: number;
33
+ stats: TypeAheadStatsSerializable | null;
34
+ inputMethod: TypeAheadInputMethod | null;
35
+ };
36
+ export type OnInsertSelectedItemProps = {
37
+ mode: SelectItemMode;
38
+ index: number;
39
+ query: string;
40
+ };
41
+ export type OnItemMatchProps = {
42
+ mode: SelectItemMode;
43
+ query: string;
44
+ };
45
+ export type OnInsertSelectedItem = (props: OnInsertSelectedItemProps) => void;
46
+ export type OnItemMatch = (props: OnItemMatchProps) => boolean;
47
+ export type OnTextInsertProps = {
48
+ forceFocusOnEditor: boolean;
49
+ setSelectionAt: CloseSelectionOptions;
50
+ text: string;
51
+ };
52
+ export type OnTextInsert = (props: OnTextInsertProps) => void;
53
+ export type InsertionTransactionMeta = (editorState: EditorState) => Transaction | false;
54
+ type PopupMountPoints = Pick<UiComponentFactoryParams, 'popupsMountPoint' | 'popupsBoundariesElement' | 'popupsScrollableElement'>;
55
+ export type PopupMountPointReference = Record<'current', PopupMountPoints | null>;
56
+ export type CreateTypeAheadDecorations = (tr: ReadonlyTransaction, options: {
57
+ triggerHandler: TypeAheadHandler;
58
+ inputMethod: TypeAheadInputMethod;
59
+ reopenQuery?: string;
60
+ }) => {
61
+ decorationSet: DecorationSet;
62
+ decorationElement: HTMLElement | null;
63
+ stats: TypeAheadStatsSerializable | null;
64
+ };
65
+ export type RemoveTypeAheadDecorations = (decorationSet?: DecorationSet) => boolean;
7
66
  export type TypeAheadInputMethod = INPUT_METHOD.INSERT_MENU | INPUT_METHOD.KEYBOARD | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.TOOLBAR;
8
67
  export type TypeAheadPluginOptions = {
9
68
  isMobile?: boolean;
@@ -36,6 +95,9 @@ export type TypeAheadPlugin = NextEditorPlugin<'typeAhead', {
36
95
  ];
37
96
  sharedState: {
38
97
  query: string;
98
+ isOpen: boolean;
99
+ isAllowed: boolean;
100
+ currentHandler?: TypeAheadHandler;
39
101
  };
40
102
  actions: {
41
103
  isOpen: (editorState: EditorState) => boolean;
@@ -47,4 +109,3 @@ export type TypeAheadPlugin = NextEditorPlugin<'typeAhead', {
47
109
  openAtTransaction: (props: OpenTypeAheadProps) => (tr: Transaction) => boolean;
48
110
  };
49
111
  }>;
50
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-type-ahead",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Type-ahead plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,7 +31,7 @@
31
31
  ".": "./src/index.ts"
32
32
  },
33
33
  "dependencies": {
34
- "@atlaskit/editor-common": "^76.6.0",
34
+ "@atlaskit/editor-common": "^76.10.0",
35
35
  "@atlaskit/editor-plugin-analytics": "^0.2.0",
36
36
  "@atlaskit/editor-prosemirror": "1.1.0",
37
37
  "@babel/runtime": "^7.0.0"
package/report.api.md CHANGED
@@ -64,6 +64,9 @@ export type TypeAheadPlugin = NextEditorPlugin<
64
64
  dependencies: [OptionalPlugin<AnalyticsPlugin>];
65
65
  sharedState: {
66
66
  query: string;
67
+ isOpen: boolean;
68
+ isAllowed: boolean;
69
+ currentHandler?: TypeAheadHandler;
67
70
  };
68
71
  actions: {
69
72
  isOpen: (editorState: EditorState) => boolean;
@@ -47,6 +47,9 @@ export type TypeAheadPlugin = NextEditorPlugin<'typeAhead', {
47
47
  dependencies: [OptionalPlugin<AnalyticsPlugin>];
48
48
  sharedState: {
49
49
  query: string;
50
+ isOpen: boolean;
51
+ isAllowed: boolean;
52
+ currentHandler?: TypeAheadHandler;
50
53
  };
51
54
  actions: {
52
55
  isOpen: (editorState: EditorState) => boolean;