@atlaskit/editor-plugin-type-ahead 0.4.0 → 0.5.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.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#41143](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41143) [`7d6dfe2befa`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7d6dfe2befa) - [ED-20003] Replace TyepAhead API for Editor Plugin Injection API
8
+
3
9
  ## 0.4.0
4
10
 
5
11
  ### Minor Changes
@@ -1,30 +1,48 @@
1
1
  import type { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
2
2
  import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
- import type { EditorCommand, NextEditorPlugin, TypeAheadHandler } from '@atlaskit/editor-common/types';
4
- import type { EditorState } from '@atlaskit/editor-prosemirror/state';
3
+ import type { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
4
+ import type { Command, NextEditorPlugin, OptionalPlugin, TypeAheadHandler, TypeAheadItem } from '@atlaskit/editor-common/types';
5
+ import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
6
+ import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
5
7
  export type TypeAheadInputMethod = INPUT_METHOD.INSERT_MENU | INPUT_METHOD.KEYBOARD | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.TOOLBAR;
6
- type Props = {
8
+ export type TypeAheadPluginOptions = {
9
+ isMobile?: boolean;
10
+ createAnalyticsEvent?: CreateUIAnalyticsEvent;
11
+ };
12
+ type OpenTypeAheadProps = {
7
13
  triggerHandler: TypeAheadHandler;
8
14
  inputMethod: TypeAheadInputMethod;
9
15
  query?: string;
10
16
  };
11
- export type TypeAheadPluginOptions = {
12
- isMobile?: boolean;
13
- createAnalyticsEvent?: CreateUIAnalyticsEvent;
17
+ type InsertTypeAheadItemProps = {
18
+ triggerHandler: TypeAheadHandler;
19
+ contentItem: TypeAheadItem;
20
+ query: string;
21
+ sourceListItem: TypeAheadItem[];
22
+ mode?: SelectItemMode;
23
+ };
24
+ type CloseTypeAheadProps = {
25
+ insertCurrentQueryAsRawText: boolean;
26
+ attachCommand?: Command;
14
27
  };
15
- type OpenTypeAheadAtCursorType = (props: Props) => EditorCommand;
16
28
  /**
17
29
  * Type ahead plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
18
30
  * from `@atlaskit/editor-core`.
19
31
  */
20
32
  export type TypeAheadPlugin = NextEditorPlugin<'typeAhead', {
21
33
  pluginConfiguration: TypeAheadPluginOptions | undefined;
34
+ dependencies: [OptionalPlugin<AnalyticsPlugin>];
35
+ sharedState: {
36
+ query: string;
37
+ };
22
38
  actions: {
23
39
  isOpen: (editorState: EditorState) => boolean;
24
40
  isAllowed: (editorState: EditorState) => boolean;
25
- };
26
- commands: {
27
- openTypeAheadAtCursor: OpenTypeAheadAtCursorType;
41
+ insert: (props: InsertTypeAheadItemProps) => boolean;
42
+ findHandlerByTrigger: (trigger: string) => TypeAheadHandler | null;
43
+ open: (props: OpenTypeAheadProps) => boolean;
44
+ close: (props: CloseTypeAheadProps) => boolean;
45
+ openAtTransaction: (props: OpenTypeAheadProps) => (tr: Transaction) => boolean;
28
46
  };
29
47
  }>;
30
48
  export {};
@@ -1,30 +1,50 @@
1
1
  import type { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
2
2
  import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
- import type { EditorCommand, NextEditorPlugin, TypeAheadHandler } from '@atlaskit/editor-common/types';
4
- import type { EditorState } from '@atlaskit/editor-prosemirror/state';
3
+ import type { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
4
+ import type { Command, NextEditorPlugin, OptionalPlugin, TypeAheadHandler, TypeAheadItem } from '@atlaskit/editor-common/types';
5
+ import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
6
+ import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
5
7
  export type TypeAheadInputMethod = INPUT_METHOD.INSERT_MENU | INPUT_METHOD.KEYBOARD | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.TOOLBAR;
6
- type Props = {
8
+ export type TypeAheadPluginOptions = {
9
+ isMobile?: boolean;
10
+ createAnalyticsEvent?: CreateUIAnalyticsEvent;
11
+ };
12
+ type OpenTypeAheadProps = {
7
13
  triggerHandler: TypeAheadHandler;
8
14
  inputMethod: TypeAheadInputMethod;
9
15
  query?: string;
10
16
  };
11
- export type TypeAheadPluginOptions = {
12
- isMobile?: boolean;
13
- createAnalyticsEvent?: CreateUIAnalyticsEvent;
17
+ type InsertTypeAheadItemProps = {
18
+ triggerHandler: TypeAheadHandler;
19
+ contentItem: TypeAheadItem;
20
+ query: string;
21
+ sourceListItem: TypeAheadItem[];
22
+ mode?: SelectItemMode;
23
+ };
24
+ type CloseTypeAheadProps = {
25
+ insertCurrentQueryAsRawText: boolean;
26
+ attachCommand?: Command;
14
27
  };
15
- type OpenTypeAheadAtCursorType = (props: Props) => EditorCommand;
16
28
  /**
17
29
  * Type ahead plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
18
30
  * from `@atlaskit/editor-core`.
19
31
  */
20
32
  export type TypeAheadPlugin = NextEditorPlugin<'typeAhead', {
21
33
  pluginConfiguration: TypeAheadPluginOptions | undefined;
34
+ dependencies: [
35
+ OptionalPlugin<AnalyticsPlugin>
36
+ ];
37
+ sharedState: {
38
+ query: string;
39
+ };
22
40
  actions: {
23
41
  isOpen: (editorState: EditorState) => boolean;
24
42
  isAllowed: (editorState: EditorState) => boolean;
25
- };
26
- commands: {
27
- openTypeAheadAtCursor: OpenTypeAheadAtCursorType;
43
+ insert: (props: InsertTypeAheadItemProps) => boolean;
44
+ findHandlerByTrigger: (trigger: string) => TypeAheadHandler | null;
45
+ open: (props: OpenTypeAheadProps) => boolean;
46
+ close: (props: CloseTypeAheadProps) => boolean;
47
+ openAtTransaction: (props: OpenTypeAheadProps) => (tr: Transaction) => boolean;
28
48
  };
29
49
  }>;
30
50
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-type-ahead",
3
- "version": "0.4.0",
3
+ "version": "0.5.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,8 @@
31
31
  ".": "./src/index.ts"
32
32
  },
33
33
  "dependencies": {
34
- "@atlaskit/editor-common": "^76.1.0",
34
+ "@atlaskit/editor-common": "^76.6.0",
35
+ "@atlaskit/editor-plugin-analytics": "^0.2.0",
35
36
  "@atlaskit/editor-prosemirror": "1.1.0",
36
37
  "@babel/runtime": "^7.0.0"
37
38
  },
package/report.api.md CHANGED
@@ -15,18 +15,35 @@
15
15
  <!--SECTION START: Main Entry Types-->
16
16
 
17
17
  ```ts
18
+ import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
19
+ import type { Command } from '@atlaskit/editor-common/types';
18
20
  import type { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
19
- import type { EditorCommand } from '@atlaskit/editor-common/types';
20
21
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
21
22
  import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
22
23
  import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
24
+ import type { OptionalPlugin } from '@atlaskit/editor-common/types';
25
+ import type { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
26
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
23
27
  import type { TypeAheadHandler } from '@atlaskit/editor-common/types';
28
+ import type { TypeAheadItem } from '@atlaskit/editor-common/types';
24
29
 
25
30
  // @public (undocumented)
26
- type OpenTypeAheadAtCursorType = (props: Props) => EditorCommand;
31
+ type CloseTypeAheadProps = {
32
+ insertCurrentQueryAsRawText: boolean;
33
+ attachCommand?: Command;
34
+ };
27
35
 
28
36
  // @public (undocumented)
29
- type Props = {
37
+ type InsertTypeAheadItemProps = {
38
+ triggerHandler: TypeAheadHandler;
39
+ contentItem: TypeAheadItem;
40
+ query: string;
41
+ sourceListItem: TypeAheadItem[];
42
+ mode?: SelectItemMode;
43
+ };
44
+
45
+ // @public (undocumented)
46
+ type OpenTypeAheadProps = {
30
47
  triggerHandler: TypeAheadHandler;
31
48
  inputMethod: TypeAheadInputMethod;
32
49
  query?: string;
@@ -44,12 +61,20 @@ export type TypeAheadPlugin = NextEditorPlugin<
44
61
  'typeAhead',
45
62
  {
46
63
  pluginConfiguration: TypeAheadPluginOptions | undefined;
64
+ dependencies: [OptionalPlugin<AnalyticsPlugin>];
65
+ sharedState: {
66
+ query: string;
67
+ };
47
68
  actions: {
48
69
  isOpen: (editorState: EditorState) => boolean;
49
70
  isAllowed: (editorState: EditorState) => boolean;
50
- };
51
- commands: {
52
- openTypeAheadAtCursor: OpenTypeAheadAtCursorType;
71
+ insert: (props: InsertTypeAheadItemProps) => boolean;
72
+ findHandlerByTrigger: (trigger: string) => TypeAheadHandler | null;
73
+ open: (props: OpenTypeAheadProps) => boolean;
74
+ close: (props: CloseTypeAheadProps) => boolean;
75
+ openAtTransaction: (
76
+ props: OpenTypeAheadProps,
77
+ ) => (tr: Transaction) => boolean;
53
78
  };
54
79
  }
55
80
  >;
@@ -4,18 +4,35 @@
4
4
 
5
5
  ```ts
6
6
 
7
+ import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
8
+ import type { Command } from '@atlaskit/editor-common/types';
7
9
  import type { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
8
- import type { EditorCommand } from '@atlaskit/editor-common/types';
9
10
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
10
11
  import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
11
12
  import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
13
+ import type { OptionalPlugin } from '@atlaskit/editor-common/types';
14
+ import type { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
15
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
12
16
  import type { TypeAheadHandler } from '@atlaskit/editor-common/types';
17
+ import type { TypeAheadItem } from '@atlaskit/editor-common/types';
13
18
 
14
19
  // @public (undocumented)
15
- type OpenTypeAheadAtCursorType = (props: Props) => EditorCommand;
20
+ type CloseTypeAheadProps = {
21
+ insertCurrentQueryAsRawText: boolean;
22
+ attachCommand?: Command;
23
+ };
16
24
 
17
25
  // @public (undocumented)
18
- type Props = {
26
+ type InsertTypeAheadItemProps = {
27
+ triggerHandler: TypeAheadHandler;
28
+ contentItem: TypeAheadItem;
29
+ query: string;
30
+ sourceListItem: TypeAheadItem[];
31
+ mode?: SelectItemMode;
32
+ };
33
+
34
+ // @public (undocumented)
35
+ type OpenTypeAheadProps = {
19
36
  triggerHandler: TypeAheadHandler;
20
37
  inputMethod: TypeAheadInputMethod;
21
38
  query?: string;
@@ -27,12 +44,18 @@ export type TypeAheadInputMethod = INPUT_METHOD.INSERT_MENU | INPUT_METHOD.KEYBO
27
44
  // @public
28
45
  export type TypeAheadPlugin = NextEditorPlugin<'typeAhead', {
29
46
  pluginConfiguration: TypeAheadPluginOptions | undefined;
47
+ dependencies: [OptionalPlugin<AnalyticsPlugin>];
48
+ sharedState: {
49
+ query: string;
50
+ };
30
51
  actions: {
31
52
  isOpen: (editorState: EditorState) => boolean;
32
53
  isAllowed: (editorState: EditorState) => boolean;
33
- };
34
- commands: {
35
- openTypeAheadAtCursor: OpenTypeAheadAtCursorType;
54
+ insert: (props: InsertTypeAheadItemProps) => boolean;
55
+ findHandlerByTrigger: (trigger: string) => TypeAheadHandler | null;
56
+ open: (props: OpenTypeAheadProps) => boolean;
57
+ close: (props: CloseTypeAheadProps) => boolean;
58
+ openAtTransaction: (props: OpenTypeAheadProps) => (tr: Transaction) => boolean;
36
59
  };
37
60
  }>;
38
61