@atlaskit/editor-plugin-annotation 1.0.2 → 1.2.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 (43) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/commands/index.js +7 -4
  3. package/dist/cjs/plugin.js +15 -11
  4. package/dist/cjs/pm-plugins/inline-comment.js +1 -4
  5. package/dist/cjs/pm-plugins/plugin-factory.js +1 -33
  6. package/dist/cjs/pm-plugins/reducer.js +6 -12
  7. package/dist/cjs/toolbar.js +7 -2
  8. package/dist/cjs/types.js +7 -0
  9. package/dist/cjs/ui/InlineCommentView.js +1 -2
  10. package/dist/cjs/utils.js +14 -1
  11. package/dist/es2019/commands/index.js +6 -5
  12. package/dist/es2019/plugin.js +15 -11
  13. package/dist/es2019/pm-plugins/inline-comment.js +1 -2
  14. package/dist/es2019/pm-plugins/plugin-factory.js +1 -33
  15. package/dist/es2019/pm-plugins/reducer.js +6 -15
  16. package/dist/es2019/toolbar.js +7 -3
  17. package/dist/es2019/types.js +9 -0
  18. package/dist/es2019/ui/InlineCommentView.js +1 -2
  19. package/dist/es2019/utils.js +14 -2
  20. package/dist/esm/commands/index.js +7 -4
  21. package/dist/esm/plugin.js +15 -11
  22. package/dist/esm/pm-plugins/inline-comment.js +1 -4
  23. package/dist/esm/pm-plugins/plugin-factory.js +1 -33
  24. package/dist/esm/pm-plugins/reducer.js +6 -12
  25. package/dist/esm/toolbar.js +7 -2
  26. package/dist/esm/types.js +9 -0
  27. package/dist/esm/ui/InlineCommentView.js +1 -2
  28. package/dist/esm/utils.js +14 -1
  29. package/dist/types/commands/index.d.ts +2 -3
  30. package/dist/types/commands/transform.d.ts +11 -4
  31. package/dist/types/index.d.ts +1 -1
  32. package/dist/types/pm-plugins/types.d.ts +2 -1
  33. package/dist/types/toolbar.d.ts +1 -1
  34. package/dist/types/types.d.ts +20 -2
  35. package/dist/types/utils.d.ts +5 -5
  36. package/dist/types-ts4.5/commands/index.d.ts +2 -3
  37. package/dist/types-ts4.5/commands/transform.d.ts +13 -4
  38. package/dist/types-ts4.5/index.d.ts +1 -1
  39. package/dist/types-ts4.5/pm-plugins/types.d.ts +2 -1
  40. package/dist/types-ts4.5/toolbar.d.ts +1 -1
  41. package/dist/types-ts4.5/types.d.ts +20 -2
  42. package/dist/types-ts4.5/utils.d.ts +5 -5
  43. package/package.json +3 -5
@@ -1,22 +1,40 @@
1
1
  import type React from 'react';
2
2
  import type { AnnotationTypes } from '@atlaskit/adf-schema';
3
+ import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
4
  import type { AnnotationUpdateEmitter } from '@atlaskit/editor-common/annotation';
4
- import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
5
+ import type { Command, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
5
6
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
6
7
  import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
8
+ import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
7
9
  import type { Slice } from '@atlaskit/editor-prosemirror/model';
8
10
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
9
11
  import type { InlineCommentPluginState } from './pm-plugins/types';
10
12
  type StripNonExistingAnnotations = (slice: Slice, state: EditorState) => boolean | undefined;
13
+ /**
14
+ * type of target that annotation apply to.
15
+ * This is used to apply correct decoration to a draft comment
16
+ */
17
+ export type TargetType = 'block' | 'inline';
18
+ /**
19
+ * The source of draft comment being created
20
+ */
21
+ export type InlineCommentInputMethod = INPUT_METHOD.TOOLBAR | INPUT_METHOD.SHORTCUT | INPUT_METHOD.FLOATING_TB;
22
+ type SetInlineCommentDraftState = (drafting: boolean, inputMethod: InlineCommentInputMethod,
23
+ /** @default 'inline' */
24
+ targetType?: TargetType,
25
+ /** check for platform_editor_media_comments_base feature gate */
26
+ isCommentOnMediaOn?: boolean) => Command;
11
27
  export type AnnotationPlugin = NextEditorPlugin<'annotation', {
12
28
  pluginConfiguration: AnnotationProviders | undefined;
13
29
  sharedState: InlineCommentPluginState | undefined;
14
30
  dependencies: [
15
31
  OptionalPlugin<AnalyticsPlugin>,
16
- OptionalPlugin<EditorViewModePlugin>
32
+ OptionalPlugin<EditorViewModePlugin>,
33
+ OptionalPlugin<FeatureFlagsPlugin>
17
34
  ];
18
35
  actions: {
19
36
  stripNonExistingAnnotations: StripNonExistingAnnotations;
37
+ setInlineCommentDraftState: SetInlineCommentDraftState;
20
38
  };
21
39
  }>;
22
40
  export type AnnotationInfo = {
@@ -1,11 +1,11 @@
1
- import type { AnalyticsEventPayloadCallback, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
1
+ import type { AnalyticsEventPayloadCallback } from '@atlaskit/editor-common/analytics';
2
2
  import { containsAnyAnnotations, hasAnnotationMark } from '@atlaskit/editor-common/utils';
3
3
  import type { Mark, Node, ResolvedPos, Schema, Slice } from '@atlaskit/editor-prosemirror/model';
4
4
  import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
5
5
  import { AllSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
6
6
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
7
7
  import type { InlineCommentPluginState } from './pm-plugins/types';
8
- import type { AnnotationInfo } from './types';
8
+ import type { AnnotationInfo, InlineCommentInputMethod, TargetType } from './types';
9
9
  import { AnnotationSelectionType } from './types';
10
10
  export { hasAnnotationMark, containsAnyAnnotations };
11
11
  /**
@@ -14,7 +14,7 @@ export { hasAnnotationMark, containsAnyAnnotations };
14
14
  */
15
15
  export declare const surroundingMarks: ($pos: ResolvedPos) => (readonly Mark[])[];
16
16
  export declare const getAllAnnotations: (doc: Node) => string[];
17
- export declare const addDraftDecoration: (start: number, end: number) => Decoration;
17
+ export declare const addDraftDecoration: (start: number, end: number, targetType?: TargetType) => Decoration;
18
18
  export declare const getAnnotationViewKey: (annotations: AnnotationInfo[]) => string;
19
19
  export declare const findAnnotationsInSelection: (selection: Selection, doc: Node) => AnnotationInfo[];
20
20
  /**
@@ -27,8 +27,8 @@ export declare const getPluginState: (state: EditorState) => InlineCommentPlugin
27
27
  /**
28
28
  * get payload for the open/close analytics event
29
29
  */
30
- export declare const getDraftCommandAnalyticsPayload: (drafting: boolean, inputMethod: INPUT_METHOD.TOOLBAR | INPUT_METHOD.SHORTCUT) => AnalyticsEventPayloadCallback;
31
- export declare const isSelectionValid: (state: EditorState) => AnnotationSelectionType;
30
+ export declare const getDraftCommandAnalyticsPayload: (drafting: boolean, inputMethod: InlineCommentInputMethod) => AnalyticsEventPayloadCallback;
31
+ export declare const isSelectionValid: (state: EditorState, isCommentOnMediaOn?: boolean) => AnnotationSelectionType;
32
32
  export declare const hasInvalidNodes: (state: EditorState) => boolean;
33
33
  /**
34
34
  * Checks if any of the nodes in a given selection are completely whitespace
@@ -1,14 +1,13 @@
1
1
  import { AnnotationTypes } from '@atlaskit/adf-schema';
2
2
  import type { EditorAnalyticsAPI, RESOLVE_METHOD } from '@atlaskit/editor-common/analytics';
3
- import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
3
  import type { Command, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
5
4
  import type { InlineCommentMap, InlineCommentMouseData } from '../pm-plugins/types';
6
- import type { AnnotationPlugin } from '../types';
5
+ import type { AnnotationPlugin, InlineCommentInputMethod, TargetType } from '../types';
7
6
  export declare const updateInlineCommentResolvedState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (partialNewState: InlineCommentMap, resolveMethod?: RESOLVE_METHOD) => Command;
8
7
  export declare const closeComponent: () => Command;
9
8
  export declare const clearDirtyMark: () => Command;
10
9
  export declare const removeInlineCommentNearSelection: (id: string) => Command;
11
- export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (drafting: boolean, inputMethod?: INPUT_METHOD.TOOLBAR | INPUT_METHOD.SHORTCUT) => Command;
10
+ export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, isCommentOnMediaOn?: boolean) => Command;
12
11
  export declare const addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string) => Command;
13
12
  export declare const updateMouseState: (mouseData: InlineCommentMouseData) => Command;
14
13
  export declare const setSelectedAnnotation: (id: string) => Command;
@@ -1,6 +1,6 @@
1
- import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
1
  import type { EditorAnalyticsAPI, RESOLVE_METHOD } from '@atlaskit/editor-common/analytics';
3
2
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
3
+ import type { InlineCommentInputMethod } from '../types';
4
4
  declare const _default: {
5
5
  addAnnotationMark: (id: string) => (transaction: Transaction, state: EditorState) => Transaction;
6
6
  addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI: import("@atlaskit/editor-common/types").PublicPluginAPI<[
@@ -74,10 +74,15 @@ declare const _default: {
74
74
  };
75
75
  }, {
76
76
  mode?: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode | undefined;
77
- } | undefined>>
77
+ } | undefined>>,
78
+ import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
79
+ pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
80
+ sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
81
+ }, import("@atlaskit/editor-common/types").FeatureFlags>>
78
82
  ];
79
83
  actions: {
80
84
  stripNonExistingAnnotations: (slice: import("prosemirror-model").Slice, state: EditorState) => boolean | undefined;
85
+ setInlineCommentDraftState: (drafting: boolean, inputMethod: InlineCommentInputMethod, targetType?: import("../types").TargetType | undefined, isCommentOnMediaOn?: boolean | undefined) => import("@atlaskit/editor-common/types").Command;
81
86
  };
82
87
  }, import("../types").AnnotationProviders | undefined>,
83
88
  import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
@@ -146,9 +151,13 @@ declare const _default: {
146
151
  };
147
152
  }, {
148
153
  mode?: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode | undefined;
149
- } | undefined>>
154
+ } | undefined>>,
155
+ import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
156
+ pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
157
+ sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
158
+ }, import("@atlaskit/editor-common/types").FeatureFlags>>
150
159
  ]> | undefined) => (id: string) => (transaction: Transaction, state: EditorState) => Transaction;
151
- addOpenCloseAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (drafting: boolean, method?: INPUT_METHOD.SHORTCUT | INPUT_METHOD.TOOLBAR) => (transaction: Transaction, state: EditorState) => Transaction;
160
+ addOpenCloseAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (drafting: boolean, method?: InlineCommentInputMethod) => (transaction: Transaction, state: EditorState) => Transaction;
152
161
  addInsertAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
153
162
  addResolveAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (method?: RESOLVE_METHOD | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
154
163
  };
@@ -1,3 +1,3 @@
1
1
  export { annotationPlugin } from './plugin';
2
- export type { AnnotationPlugin, AnnotationProviders, InlineCommentAnnotationProvider, AnnotationInfo, InlineCommentCreateComponentProps, InlineCommentViewComponentProps, AnnotationState, AnnotationTypeProvider, InlineCommentState, } from './types';
2
+ export type { AnnotationPlugin, AnnotationProviders, InlineCommentAnnotationProvider, AnnotationInfo, InlineCommentCreateComponentProps, InlineCommentViewComponentProps, AnnotationState, AnnotationTypeProvider, InlineCommentState, TargetType, InlineCommentInputMethod, } from './types';
3
3
  export type { InlineCommentMap, InlineCommentPluginState, InlineCommentPluginOptions, InlineCommentAction, } from './pm-plugins/types';
@@ -3,7 +3,7 @@ import type { Dispatch, EventDispatcher } from '@atlaskit/editor-common/event-di
3
3
  import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
4
4
  import type { EditorState, SelectionBookmark } from '@atlaskit/editor-prosemirror/state';
5
5
  import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
6
- import type { AnnotationInfo, InlineCommentAnnotationProvider } from '../types';
6
+ import type { AnnotationInfo, InlineCommentAnnotationProvider, TargetType } from '../types';
7
7
  export declare enum ACTIONS {
8
8
  UPDATE_INLINE_COMMENT_STATE = 0,
9
9
  SET_INLINE_COMMENT_DRAFT_STATE = 1,
@@ -35,6 +35,7 @@ export type InlineCommentAction = {
35
35
  data: {
36
36
  drafting: boolean;
37
37
  editorState: EditorState;
38
+ targetType?: TargetType;
38
39
  };
39
40
  } | {
40
41
  type: ACTIONS.INLINE_COMMENT_UPDATE_MOUSE_STATE;
@@ -2,4 +2,4 @@ import type { IntlShape } from 'react-intl-next';
2
2
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
3
  import type { FloatingToolbarConfig } from '@atlaskit/editor-common/types';
4
4
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
5
- export declare const buildToolbar: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (state: EditorState, intl: IntlShape, isToolbarAbove?: boolean) => FloatingToolbarConfig | undefined;
5
+ export declare const buildToolbar: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (state: EditorState, intl: IntlShape, isToolbarAbove?: boolean, isCommentOnMediaOn?: boolean) => FloatingToolbarConfig | undefined;
@@ -1,22 +1,40 @@
1
1
  import type React from 'react';
2
2
  import type { AnnotationTypes } from '@atlaskit/adf-schema';
3
+ import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
4
  import type { AnnotationUpdateEmitter } from '@atlaskit/editor-common/annotation';
4
- import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
5
+ import type { Command, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
5
6
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
6
7
  import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
8
+ import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
7
9
  import type { Slice } from '@atlaskit/editor-prosemirror/model';
8
10
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
9
11
  import type { InlineCommentPluginState } from './pm-plugins/types';
10
12
  type StripNonExistingAnnotations = (slice: Slice, state: EditorState) => boolean | undefined;
13
+ /**
14
+ * type of target that annotation apply to.
15
+ * This is used to apply correct decoration to a draft comment
16
+ */
17
+ export type TargetType = 'block' | 'inline';
18
+ /**
19
+ * The source of draft comment being created
20
+ */
21
+ export type InlineCommentInputMethod = INPUT_METHOD.TOOLBAR | INPUT_METHOD.SHORTCUT | INPUT_METHOD.FLOATING_TB;
22
+ type SetInlineCommentDraftState = (drafting: boolean, inputMethod: InlineCommentInputMethod,
23
+ /** @default 'inline' */
24
+ targetType?: TargetType,
25
+ /** check for platform_editor_media_comments_base feature gate */
26
+ isCommentOnMediaOn?: boolean) => Command;
11
27
  export type AnnotationPlugin = NextEditorPlugin<'annotation', {
12
28
  pluginConfiguration: AnnotationProviders | undefined;
13
29
  sharedState: InlineCommentPluginState | undefined;
14
30
  dependencies: [
15
31
  OptionalPlugin<AnalyticsPlugin>,
16
- OptionalPlugin<EditorViewModePlugin>
32
+ OptionalPlugin<EditorViewModePlugin>,
33
+ OptionalPlugin<FeatureFlagsPlugin>
17
34
  ];
18
35
  actions: {
19
36
  stripNonExistingAnnotations: StripNonExistingAnnotations;
37
+ setInlineCommentDraftState: SetInlineCommentDraftState;
20
38
  };
21
39
  }>;
22
40
  export type AnnotationInfo = {
@@ -1,11 +1,11 @@
1
- import type { AnalyticsEventPayloadCallback, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
1
+ import type { AnalyticsEventPayloadCallback } from '@atlaskit/editor-common/analytics';
2
2
  import { containsAnyAnnotations, hasAnnotationMark } from '@atlaskit/editor-common/utils';
3
3
  import type { Mark, Node, ResolvedPos, Schema, Slice } from '@atlaskit/editor-prosemirror/model';
4
4
  import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
5
5
  import { AllSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
6
6
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
7
7
  import type { InlineCommentPluginState } from './pm-plugins/types';
8
- import type { AnnotationInfo } from './types';
8
+ import type { AnnotationInfo, InlineCommentInputMethod, TargetType } from './types';
9
9
  import { AnnotationSelectionType } from './types';
10
10
  export { hasAnnotationMark, containsAnyAnnotations };
11
11
  /**
@@ -14,7 +14,7 @@ export { hasAnnotationMark, containsAnyAnnotations };
14
14
  */
15
15
  export declare const surroundingMarks: ($pos: ResolvedPos) => (readonly Mark[])[];
16
16
  export declare const getAllAnnotations: (doc: Node) => string[];
17
- export declare const addDraftDecoration: (start: number, end: number) => Decoration;
17
+ export declare const addDraftDecoration: (start: number, end: number, targetType?: TargetType) => Decoration;
18
18
  export declare const getAnnotationViewKey: (annotations: AnnotationInfo[]) => string;
19
19
  export declare const findAnnotationsInSelection: (selection: Selection, doc: Node) => AnnotationInfo[];
20
20
  /**
@@ -27,8 +27,8 @@ export declare const getPluginState: (state: EditorState) => InlineCommentPlugin
27
27
  /**
28
28
  * get payload for the open/close analytics event
29
29
  */
30
- export declare const getDraftCommandAnalyticsPayload: (drafting: boolean, inputMethod: INPUT_METHOD.TOOLBAR | INPUT_METHOD.SHORTCUT) => AnalyticsEventPayloadCallback;
31
- export declare const isSelectionValid: (state: EditorState) => AnnotationSelectionType;
30
+ export declare const getDraftCommandAnalyticsPayload: (drafting: boolean, inputMethod: InlineCommentInputMethod) => AnalyticsEventPayloadCallback;
31
+ export declare const isSelectionValid: (state: EditorState, isCommentOnMediaOn?: boolean) => AnnotationSelectionType;
32
32
  export declare const hasInvalidNodes: (state: EditorState) => boolean;
33
33
  /**
34
34
  * Checks if any of the nodes in a given selection are completely whitespace
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-annotation",
3
- "version": "1.0.2",
3
+ "version": "1.2.0",
4
4
  "description": "Annotation plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,9 +33,10 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@atlaskit/adf-schema": "^35.5.2",
36
- "@atlaskit/editor-common": "^78.10.0",
36
+ "@atlaskit/editor-common": "^78.11.0",
37
37
  "@atlaskit/editor-plugin-analytics": "^1.0.0",
38
38
  "@atlaskit/editor-plugin-editor-viewmode": "^1.0.0",
39
+ "@atlaskit/editor-plugin-feature-flags": "^1.0.0",
39
40
  "@atlaskit/editor-prosemirror": "3.0.0",
40
41
  "@atlaskit/icon": "^22.1.0",
41
42
  "@atlaskit/platform-feature-flags": "^0.2.0",
@@ -93,9 +94,6 @@
93
94
  },
94
95
  "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0",
95
96
  "platform-feature-flags": {
96
- "platform.editor.annotation.decouple-inline-comment-closed_flmox": {
97
- "type": "boolean"
98
- },
99
97
  "platform.editor.enable-selection-toolbar_ucdwd": {
100
98
  "type": "boolean"
101
99
  }